Commit 77d4fa74 by malcolm

Trying again

parent ae98eb9f
...@@ -90,4 +90,5 @@ void proc_setup() ...@@ -90,4 +90,5 @@ void proc_setup()
{ {
procs[i]=NULL; procs[i]=NULL;
} }
kstack = kmalloc(4096);
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include <stdint.h> #include <stdint.h>
#include "mem.h" #include "mem.h"
void* kstack;
typedef struct//all regs in proc typedef struct//all regs in proc
{ {
uint32_t edi; uint32_t edi;
...@@ -26,6 +28,9 @@ typedef struct//all regs in proc ...@@ -26,6 +28,9 @@ typedef struct//all regs in proc
uint32_t trap; uint32_t trap;
uint32_t mmm;
uint32_t why;
uint32_t err; uint32_t err;
uint32_t eip; uint32_t eip;
...@@ -68,5 +73,5 @@ void syscall(); ...@@ -68,5 +73,5 @@ void syscall();
void addproc(process* proc); void addproc(process* proc);
void settf(trapframe* tf); void settf(trapframe* tf);
void proc_setup(); void proc_setup();
int yield();
#endif #endif
...@@ -83,5 +83,5 @@ void load_elf(elf_header* elf_start) ...@@ -83,5 +83,5 @@ void load_elf(elf_header* elf_start)
pcb->tf->eip = (uint32_t)elf_start->program_entry_position; pcb->tf->eip = (uint32_t)elf_start->program_entry_position;
addproc(pcb); addproc(pcb);
asm("mov $3, %eax; int 0x80"); //asm("mov $3, %eax; int 0x80");
} }
extern default_handler extern default_handler
extern idt_ftoi extern idt_ftoi
extern kstack
%macro error_interrupt 1 %macro error_interrupt 1
global interrupt_handler_%1 global interrupt_handler_%1
interrupt_handler_%1: interrupt_handler_%1:
push ebp
push esp
mov ebp, kstack
mov esp, kstack
push dword %1 push dword %1
jmp common_handler jmp common_handler
%endmacro %endmacro
...@@ -12,6 +17,10 @@ interrupt_handler_%1: ...@@ -12,6 +17,10 @@ interrupt_handler_%1:
global interrupt_handler_%1 global interrupt_handler_%1
interrupt_handler_%1: interrupt_handler_%1:
push dword 0 push dword 0
push ebp
push esp
mov ebp, kstack
mov esp, kstack
push dword %1 push dword %1
jmp common_handler jmp common_handler
%endmacro %endmacro
...@@ -29,7 +38,10 @@ common_handler: ...@@ -29,7 +38,10 @@ common_handler:
pop dword es pop dword es
pop dword ds pop dword ds
add esp, 8 add esp, 4
pop esp
pop ebp
add esp, 4
iret iret
regular_interrupt 0 regular_interrupt 0
......
...@@ -38,11 +38,11 @@ void kernel_main(multiboot_info* mbt, uint32_t magic) ...@@ -38,11 +38,11 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
serial_writestring("IDT initialized\n"); serial_writestring("IDT initialized\n");
disable_int(); disable_int();
pic_init(0x20,0x28); pic_init(0x20,0x28);
pit_init(); //pit_init();
io_init(); io_init();
proc_setup(); proc_setup();
pit_start_counter(100, PIT_OCW_CONT_0, PIT_OCW_MODE_SQWVGEN); //pit_start_counter(100, PIT_OCW_CONT_0, PIT_OCW_MODE_SQWVGEN);
enable_int(); //enable_int();
/* Since there is no support for newlines in terminal_putchar /* Since there is no support for newlines in terminal_putchar
* yet, '\n' will produce some VGA specific character instead. * yet, '\n' will produce some VGA specific character instead.
...@@ -84,6 +84,11 @@ void kernel_main(multiboot_info* mbt, uint32_t magic) ...@@ -84,6 +84,11 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
load_elf((elf_header*)&elf_hello); load_elf((elf_header*)&elf_hello);
pit_init();
pit_start_counter(100, PIT_OCW_CONT_0, PIT_OCW_MODE_SQWVGEN);
enable_int();
test_idt(); test_idt();
while(true) while(true)
{ {
......
...@@ -18,6 +18,7 @@ void pit_irq() ...@@ -18,6 +18,7 @@ void pit_irq()
pic_command(0, PIC_OCW2_EOI); pic_command(0, PIC_OCW2_EOI);
//serial_writestring("PIT tickn\n"); //serial_writestring("PIT tickn\n");
//asm volatile("nop;nop;nop;popa; iret;"); //asm volatile("nop;nop;nop;popa; iret;");
yield();
} }
void pit_command(uint8_t cmd) void pit_command(uint8_t cmd)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment