Commit 4ca65e96 by malcolm

trying to make things work

parent ae98eb9f
...@@ -31,7 +31,13 @@ void schedule() ...@@ -31,7 +31,13 @@ void schedule()
{ {
curproc=(curproc<NUM_PROCS-1)?curproc+1:0; curproc=(curproc<NUM_PROCS-1)?curproc+1:0;
} }
context_switch(&procs[old]->ctxt, procs[curproc]->ctxt); serial_writestring("Gonna context switch with:\neip ");
serial_hexword(procs[curproc]->ctxt->eip);
serial_writestring("\nebp ");
serial_hexword(procs[curproc]->ctxt->ebp);
serial_writestring("\n");
context_switch(&procs[old]->ctxt, procs[curproc]->ctxt, procs[curproc]->mem);
serial_writestring("Switched\n");
//procs[old]->state=RUNNABLE; //procs[old]->state=RUNNABLE;
procs[curproc]->state=RUNNING; procs[curproc]->state=RUNNING;
//process* t = curproc; //process* t = curproc;
......
...@@ -63,10 +63,10 @@ typedef struct ...@@ -63,10 +63,10 @@ typedef struct
enum procstate state; enum procstate state;
}__attribute__((packed)) process; }__attribute__((packed)) process;
extern void context_switch(context** old, context* new); extern void context_switch(context** old, context* new, page_directory_entry* cr3);
void syscall(); 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");
} }
...@@ -38,11 +38,9 @@ void kernel_main(multiboot_info* mbt, uint32_t magic) ...@@ -38,11 +38,9 @@ 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);
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 +82,11 @@ void kernel_main(multiboot_info* mbt, uint32_t magic) ...@@ -84,6 +82,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);
serial_writestring("Enabling interrupts\n");
enable_int();
//schedule();
test_idt(); test_idt();
while(true) while(true)
{ {
......
...@@ -16,6 +16,7 @@ void pit_irq() ...@@ -16,6 +16,7 @@ void pit_irq()
_pit_ticks++; _pit_ticks++;
//serial_writestring("PIT tick\n"); //serial_writestring("PIT tick\n");
pic_command(0, PIC_OCW2_EOI); pic_command(0, PIC_OCW2_EOI);
yield();
//serial_writestring("PIT tickn\n"); //serial_writestring("PIT tickn\n");
//asm volatile("nop;nop;nop;popa; iret;"); //asm volatile("nop;nop;nop;popa; iret;");
} }
......
...@@ -2,6 +2,7 @@ global context_switch ...@@ -2,6 +2,7 @@ global context_switch
context_switch: context_switch:
mov eax, [esp+4] mov eax, [esp+4]
mov edx, [esp+8] mov edx, [esp+8]
mov ecx, [esp+12]
push ebp push ebp
push ebx push ebx
...@@ -16,4 +17,5 @@ context_switch: ...@@ -16,4 +17,5 @@ context_switch:
pop ebx pop ebx
pop ebp pop ebp
mov cr3, ecx
ret ret
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