Any ideas why this is getting messed up? Some type of page fault is happening. Memory constants prefixed with SCM_ are globally mapped in the kernel's page directory and all process's page directories.
All emulators crash and Bochs gives me this:
Code:
00049502853i[CPU0 ] | EAX=83e58955 EBX=00004004 ECX=00000000 EDX=00000000
00049502853i[CPU0 ] | ESP=ffc01f88 EBP=00d92000 ESI=00000000 EDI=00000000
00049502853i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00049502853i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00049502853i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
00049502853i[CPU0 ] | DS:0023( 0004| 0| 3) 00000000 ffffffff 1 1
00049502853i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00049502853i[CPU0 ] | ES:0023( 0004| 0| 3) 00000000 ffffffff 1 1
00049502853i[CPU0 ] | FS:0023( 0004| 0| 3) 00000000 ffffffff 1 1
00049502853i[CPU0 ] | GS:0023( 0004| 0| 3) 00000000 ffffffff 1 1
00049502853i[CPU0 ] | EIP=ffc04068 (ffc04068)
00049502853i[CPU0 ] | CR0=0xe0000031 CR2=0x00507848
00049502853i[CPU0 ] | CR3=0x00d86000 CR4=0x00000000
00049502853i[CPU0 ] 0x00000000ffc04068>> iret : CF
00049502853p[CPU0 ] >>PANIC<< exception(): 3rd (14) exception with no resolution
Code:
; This code is globally mapped to the address SCM_TASK_START
align 0x1000
.startNewUserTask:
mov ax, USER_DATASEG
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; Copy stack to this task's kernel stack
push KPROCESS_KSTACK
push DWORD [ebx+KTask.owner]
call DWORD [KernelGetInfoForProcess]
mov edi, eax
add edi, 0x1000 - StateInfo_size
mov eax, esp
push StateInfo_size
push eax
push edi
call DWORD [_MemCopy]
; Switch CR3 and switch stacks
push KPROCESS_CR3
push DWORD [ebx+KTask.owner]
call DWORD [KernelGetInfoForProcess]
mov edi, eax
mov cr3, eax
mov esp, SCM_KERNEL_STACK + 0x1000 - StateInfo_size
mov eax, esp
push USER_DATASEG
push DWORD [eax+StateInfo.esp]
push 0x200 ; No flags just interrupt enable
push USER_CODESEG
push DWORD [eax+StateInfo.eip]
mov ebp, DWORD [eax+StateInfo.ebp]
mov eax, DWORD [eax+StateInfo.eip]
mov eax, DWORD [eax] ; Just to see value references correct data in Bochs, which it does
xor ecx, ecx
xor edx, edx
xor esi, esi
xor edi, edi
iret