Commit 77d4fa74 by malcolm

Trying again

parent ae98eb9f
......@@ -90,4 +90,5 @@ void proc_setup()
{
procs[i]=NULL;
}
kstack = kmalloc(4096);
}
......@@ -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
......@@ -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");
}
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
......
......@@ -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)
{
......
......@@ -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)
......
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