Posted: Fri Jan 26, 2007 6:36 pm
Check if bit TI of any selector, used in switching, is set to '1'.
The Place to Start for Operating System Developers
http://f.osdev.org/
When it does this, what are the values of the selectors loaded into your segment registers? I don't know whether bochs would load the selectors before or after testing them, so what are the top few words of your stack?cg123 wrote:..well, I've got another problem.
Now it triple faults on the iret with this message:
fetch_raw_descriptor: LDT: index (105f)20b > limit (0)
...but I don't have an LDT. Is that in itself the problem, or...
Yes, this is what I want to see too .I don't know whether bochs would load the selectors before or after testing them, so what are the top few words of your stack?
Code: Select all
_irq0:
cli
jmp _swap
_tnum:
dd 0
_swap:
;push
pushad
push ds
push es
push fs
push gs
mov eax,[_tnum]
inc eax
mov ebx,eax
mov ecx,8
mul ecx
add eax,_procdata
mov esp,[eax]
cmp esp,0
jne .go2
; go to proc 1
mov [_tnum],DWORD 0
jmp _swap
.go2:
mov [_tnum],ebx
sti
mov al,0x20
out 0x20,al
;pop
pop gs
pop fs
pop es
pop ds
popad
iret
section .bss
global _procdata
_procdata:
%rep 256
resd 2 ; esp, sleep
%endrep
Code: Select all
typedef struct {
unsigned int esp;
unsigned int sleep;
} proc_t;
extern proc_t procdata[256];
char kstacks[256][1024];
unsigned int c_stack(unsigned int num,unsigned eip)
{
unsigned int* ptr = (unsigned int*)&kstacks[num][1024];
ptr--;
*ptr--=0x202;
*ptr--=0x08;
*ptr--=eip;
*ptr--=0;
*ptr--=0;
*ptr--=0;
*ptr--=0;
*ptr--=0;
*ptr--=0;
*ptr--=0;
*ptr--=0;
*ptr--=0x10;
*ptr--=0x10;
*ptr--=0x10;
*ptr=0x10;
proc_t p;
p.esp = (unsigned int)ptr;
p.sleep = 0;
procdata[num] = p;
return (unsigned int)ptr;
}
Code: Select all
_swap:
;push
pushad
push ds
push es
push fs
push gs
; save esp
mov eax,[_tnum]
mov ecx,8
mul ecx
add eax,_procdata
mov [eax],esp
; increment task
mov eax,[_tnum]
inc eax
mov ebx,eax
; load esp
mov ecx,8
mul ecx
add eax,_procdata
mov esp,[eax]
cmp esp,0
jne .go2
; go to proc 1
mov [_tnum],DWORD 0
jmp _swap
.go2:
add eax,4
cmp DWORD [eax],0
je .go
inc ebx
mov [_tnum],ebx
mov ebx,[eax]
dec ebx
mov [eax],ebx
jmp _swap
.go:
mov [_tnum],ebx
sti
mov al,0x20
out 0x20,al
;pop
pop gs
pop fs
pop es
pop ds
popad
iret