To solve this problem, I created a task entry in the linked list that represents the kernel process (got it's register values during the first call to the scheduler) and then treated the kernel just as any ordinary task. Creating the kernel thread still worked, and switching from the kernel to the thread did work, the thread still did it's work, but with the next scheduler call, when switching back to the kernel, nothing happens when putting the kernel's values into the regs structure - everything OK so far -, but afterwards, a page fault is triggered with 0x10 in CR2.
Could anyone help me? I know my writing is a little bit complicated, and I don't know if registering the kernel as a task was a good idea...
This is the Bochs snapshot:
Code: Select all
0 Multiboot Module(s) loaden. Please reboot if you didn't expect this.
Physical Memory Manager: 120M avaiRegistered kernel with ID 0
lable on RAM
Task Manager...
Switched to task 1: CS: 0x8,DS: 0x10,ES: 0x10,FS: 0x10,GS: 0x10,SS: 0xC01088F4
AAAAAAAAAAAAAAAAAAAASwitched to task 0: CS: 0x8,DS: 0x10,ES: 0x2BAD0010,FS: 0xC0
100010,GS: 0xC0101869,SS: 0xC0100788
Kernel Panic!!!
Page Fault => 0x10
The Hermes Kernel cannot recover from this fault.
If your computer doesn't reboot in 5 seconds, please do it manually.
Edit: Here the piece of code which most probably triggered the error (after returning from irq_handler):
Code: Select all
irq_common_stub:
pushad
push ds
push es
push fs
push gs
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push eax
mov eax, irq_handler
call eax
pop eax
pop gs
pop fs
pop es
pop ds
popad
add esp, 8
iret