Hello all,
I have a task switching problem, but I don't understand. I'm writing a little
OS on x86. I use the pmode but not the paging.
During my first switching, the kernel stop at the fisrt second assembler instruction of the new task ("push bp") . I'm using Bochs emulator to test
my kernel. At the start I initialise the CPU (GDT, TSS ...). Then, the main of the kernel is executed. At this point, I call a function. Then in this function I call a task switching (to the new task).
The task swithing code is :
asm (" push %%ds;
push %%es;
push %%fs;
push %%gs;
pushal;
movl $0x10, %%ebx;
mov %%bx, %%ds;
mov %%bx, %%es;
movl %%esp, %%eax;
movl %%eax, %0;
movl %1, %%eax;
movl %%eax, %%esp;
popal;
pop %%gs;
pop %%fs;
pop %%es;
pop %%ds;
iretl;"
:"=r"(CURRENT->OS_TCB_SP)
:"r"(NEXT->OS_TCB_SP)
:"%eax"
);
The result of Bochs emulator is :
00001998341p[CPU ] >>PANIC<< exception(): 3rd (13) exception with no resolution
00001998341i[SYS ] Last time is 1055862947
00001998341i[CPU ] protected mode
00001998341i[CPU ] CS.d_b = 32 bit
00001998341i[CPU ] SS.d_b = 32 bit
00001998341i[CPU ] | EAX=00000000 EBX=00000000 ECX=00000000 EDX=00000000
00001998341i[CPU ] | ESP=00003690 EBP=00000000 ESI=00000000 EDI=00000000
00001998341i[CPU ] | IOPL=0 NV UP EI PL NZ NA PO NC
00001998341i[CPU ] | SEG selector base limit G D
00001998341i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00001998341i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001998341i[CPU ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001998341i[CPU ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001998341i[CPU ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001998341i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001998341i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00001998341i[CPU ] | EIP=0000111c (0000111c)
00001998341i[CPU ] | CR0=0x60000011 CR1=0x00000000 CR2=0x00000000
00001998341i[CPU ] | CR3=0x00000000 CR4=0x00000000
00001998341i[ ] restoring default signal behavior
00001998341i[CTRL ] quit_sim called with exit code 1
A part of the assembler code of the kernel
0000011A 89F6 mov si,si // start of the new task
0000011C 55 push bp
0000011D 89E5 mov bp,sp
0000011F 83EC08 sub sp,byte +0x8
00000122 E80500 call 0x12a
00000125 0000 add [bx+si],al
00000127 C9 leave
00000128 C3 ret
00000129 8D7600 lea si,[bp+0x0] // start of task switching
0000012C 55 push bp
0000012D 89E5 mov bp,sp
0000012F 8B15 mov dx,[di]
00000131 FC cld
00000132 3400 xor al,0x0
00000134 008B0A1E add [bp+di+0x1e0a],cl
00000138 06 push es
00000139 0FA0 push fs
0000013B 0FA8 push gs
0000013D 60 pusha
0000013E BB1000 mov bx,0x10
00000141 0000 add [bx+si],al
00000143 8EDB mov ds,bx
00000145 8EC3 mov es,bx
00000147 89E0 mov ax,sp
00000149 89C2 mov dx,ax
0000014B 89C8 mov ax,cx
0000014D 89C4 mov sp,ax
0000014F 61 popa
00000150 0FA9 pop gs
00000152 0FA1 pop fs
00000154 07 pop es
00000155 1F pop ds
00000156 CF iret
What do you think about my problem ? Have you a idea ?
Thanks in advance.
myos