Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
70c0f742
authored
Dec 07, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
debug serial output and fixed syscalls
parent
af2a722f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
8 deletions
src/PCB.c
src/PCB.h
src/exceptions.c
src/idt.c
src/test.c
src/PCB.c
View file @
70c0f742
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#define NUM_PROCS 16
#define NUM_PROCS 16
process
*
procs
[
NUM_PROCS
];
process
*
procs
[
NUM_PROCS
];
int
curproc
=
-
1
;
int
curproc
=
0
;
int
firstfree
=
0
;
int
firstfree
=
0
;
//process* curproc;
//process* curproc;
...
@@ -18,6 +18,11 @@ void addproc(process* proc)
...
@@ -18,6 +18,11 @@ void addproc(process* proc)
//curproc=proc;
//curproc=proc;
}
}
void
settf
(
trapframe
*
tf
)
{
procs
[
curproc
]
->
tf
=
tf
;
}
void
schedule
()
void
schedule
()
{
{
int
old
=
curproc
;
int
old
=
curproc
;
...
@@ -46,13 +51,13 @@ int yield()
...
@@ -46,13 +51,13 @@ int yield()
int
print1
()
int
print1
()
{
{
terminal_writestring
(
"1"
);
terminal_writestring
(
"1
\n
"
);
return
1
;
return
1
;
}
}
int
print2
()
int
print2
()
{
{
terminal_writestring
(
"2"
);
terminal_writestring
(
"2
\n
"
);
return
2
;
return
2
;
}
}
...
@@ -63,13 +68,18 @@ void syscall()
...
@@ -63,13 +68,18 @@ void syscall()
{
{
int
num
=
procs
[
curproc
]
->
tf
->
eax
;
int
num
=
procs
[
curproc
]
->
tf
->
eax
;
serial_hexword
(
num
);
serial_writestring
(
" SYSCALLED
\n
"
);
if
(
num
>
0
&&
num
<
NUM_SYSCALLS
&&
syscalls
[
num
])
if
(
num
>
0
&&
num
<
NUM_SYSCALLS
&&
syscalls
[
num
])
{
{
procs
[
curproc
]
->
tf
->
eax
=
syscalls
[
num
]();
procs
[
curproc
]
->
tf
->
eax
=
syscalls
[
num
]();
}
}
else
else
{
{
serial_writestring
(
"UNKNOWN SYSCALL CALLED
\n
"
);
serial_writestring
(
"UNKNOWN SYSCALL CALLED "
);
serial_hexword
(
num
);
serial_writestring
(
"
\n
"
);
procs
[
curproc
]
->
tf
->
eax
=
-
1
;
procs
[
curproc
]
->
tf
->
eax
=
-
1
;
}
}
}
}
...
...
src/PCB.h
View file @
70c0f742
...
@@ -66,6 +66,7 @@ typedef struct
...
@@ -66,6 +66,7 @@ typedef struct
extern
void
context_switch
(
context
**
old
,
context
*
new
);
extern
void
context_switch
(
context
**
old
,
context
*
new
);
void
syscall
();
void
syscall
();
void
addproc
(
process
*
proc
);
void
addproc
(
process
*
proc
);
void
settf
(
trapframe
*
tf
);
void
proc_setup
();
void
proc_setup
();
#endif
#endif
src/exceptions.c
View file @
70c0f742
...
@@ -59,7 +59,14 @@ void int_general_protection_fault(uint32_t __attribute__((unused))error)
...
@@ -59,7 +59,14 @@ void int_general_protection_fault(uint32_t __attribute__((unused))error)
}
}
void
int_page_fault
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_page_fault
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"PAGE FAULT ERROR
\n
"
);
serial_writestring
(
"PAGE FAULT ERROR "
);
serial_hexword
(
error
);
uint32_t
cr2
;
asm
volatile
(
"movl %%cr2, %0"
:
"=r"
(
cr2
)
:
);
//register uint32_t cr2 asm("%%cr2");
serial_writestring
(
" "
);
serial_hexword
(
cr2
);
serial_writestring
(
"
\n
"
);
}
}
void
int_reserved
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_reserved
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
...
...
src/idt.c
View file @
70c0f742
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "string.h"
#include "string.h"
#include "serial.h"
#include "serial.h"
#include "exceptions.h"
#include "exceptions.h"
#include "PCB.h"
#pragma GCC push_options
#pragma GCC push_options
#pragma GCC optimize ("0")
#pragma GCC optimize ("0")
...
@@ -45,6 +46,7 @@ void load_error_handlers()
...
@@ -45,6 +46,7 @@ void load_error_handlers()
void
default_handler
(
trapframe
reg
)
void
default_handler
(
trapframe
reg
)
{
{
settf
(
&
reg
);
if
(
reg
.
trap
<
32
)
if
(
reg
.
trap
<
32
)
reg
.
eip
+=
2
;
reg
.
eip
+=
2
;
if
(
handlers
[
reg
.
trap
]
!=
NULL
)
if
(
handlers
[
reg
.
trap
]
!=
NULL
)
...
@@ -105,7 +107,7 @@ int idt_init(uint16_t code_sel)
...
@@ -105,7 +107,7 @@ int idt_init(uint16_t code_sel)
idtsetup
();
idtsetup
();
idt_install
();
idt_install
();
load_error_handlers
();
load_error_handlers
();
handlers
[
0x
10
0
]
=
syscall
;
handlers
[
0x
8
0
]
=
syscall
;
return
0
;
return
0
;
}
}
#pragma GCC pop_options
#pragma GCC pop_options
src/test.c
View file @
70c0f742
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
void
test_idt
()
void
test_idt
()
{
{
asm
(
"
int $0x80"
);
asm
volatile
(
"mov $4, %eax;
int $0x80"
);
asm
(
"int $0x90"
);
asm
volatile
(
"int $0x90"
);
}
}
void
test_mem
()
void
test_mem
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment