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
77d4fa74
authored
Dec 13, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Trying again
parent
ae98eb9f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
6 deletions
src/PCB.c
src/PCB.h
src/elf.c
src/idta.asm
src/kern.c
src/pit.c
src/PCB.c
View file @
77d4fa74
...
...
@@ -90,4 +90,5 @@ void proc_setup()
{
procs
[
i
]
=
NULL
;
}
kstack
=
kmalloc
(
4096
);
}
src/PCB.h
View file @
77d4fa74
...
...
@@ -4,6 +4,8 @@
#include <stdint.h>
#include "mem.h"
void
*
kstack
;
typedef
struct
//all regs in proc
{
uint32_t
edi
;
...
...
@@ -26,6 +28,9 @@ typedef struct//all regs in proc
uint32_t
trap
;
uint32_t
mmm
;
uint32_t
why
;
uint32_t
err
;
uint32_t
eip
;
...
...
@@ -68,5 +73,5 @@ void syscall();
void
addproc
(
process
*
proc
);
void
settf
(
trapframe
*
tf
);
void
proc_setup
();
int
yield
();
#endif
src/elf.c
View file @
77d4fa74
...
...
@@ -83,5 +83,5 @@ void load_elf(elf_header* elf_start)
pcb
->
tf
->
eip
=
(
uint32_t
)
elf_start
->
program_entry_position
;
addproc
(
pcb
);
asm
(
"mov $3, %eax; int 0x80"
);
//
asm("mov $3, %eax; int 0x80");
}
src/idta.asm
View file @
77d4fa74
extern
default_handler
extern
idt_ftoi
extern
kstack
%macro
error_interrupt
1
global
interrupt_handler_
%1
interrupt_handler_
%1
:
push
ebp
push
esp
mov
ebp
,
kstack
mov
esp
,
kstack
push
dword
%1
jmp
common_handler
%endmacro
...
...
@@ -12,6 +17,10 @@ interrupt_handler_%1:
global
interrupt_handler_
%1
interrupt_handler_
%1
:
push
dword
0
push
ebp
push
esp
mov
ebp
,
kstack
mov
esp
,
kstack
push
dword
%1
jmp
common_handler
%endmacro
...
...
@@ -29,7 +38,10 @@ common_handler:
pop
dword
es
pop
dword
ds
add
esp
,
8
add
esp
,
4
pop
esp
pop
ebp
add
esp
,
4
iret
regular_interrupt
0
...
...
src/kern.c
View file @
77d4fa74
...
...
@@ -38,11 +38,11 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
serial_writestring
(
"IDT initialized
\n
"
);
disable_int
();
pic_init
(
0x20
,
0x28
);
pit_init
();
//
pit_init();
io_init
();
proc_setup
();
pit_start_counter
(
100
,
PIT_OCW_CONT_0
,
PIT_OCW_MODE_SQWVGEN
);
enable_int
();
//
pit_start_counter(100, PIT_OCW_CONT_0, PIT_OCW_MODE_SQWVGEN);
//
enable_int();
/* Since there is no support for newlines in terminal_putchar
* yet, '\n' will produce some VGA specific character instead.
...
...
@@ -84,6 +84,11 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
load_elf
((
elf_header
*
)
&
elf_hello
);
pit_init
();
pit_start_counter
(
100
,
PIT_OCW_CONT_0
,
PIT_OCW_MODE_SQWVGEN
);
enable_int
();
test_idt
();
while
(
true
)
{
...
...
src/pit.c
View file @
77d4fa74
...
...
@@ -18,6 +18,7 @@ void pit_irq()
pic_command
(
0
,
PIC_OCW2_EOI
);
//serial_writestring("PIT tickn\n");
//asm volatile("nop;nop;nop;popa; iret;");
yield
();
}
void
pit_command
(
uint8_t
cmd
)
...
...
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