I've written a function to switch from PMode into Real Mode.
But if i execute this funktion, the cpu triple faults!
This is the funktion:
Code: Select all
[global _shutdown]
_shutdown:
[BITS 32]
cli ; Interrupts werden verboten
mov eax, REAL_CODE_SEL
mov ss, eax
;nun wechseln wir in den 16-Bit Protected Mode
jmp dword REAL_CODE_SEL:prm
[BITS 16]
prm:
; Wir verlassen den Protected Mode
mov eax, cr0
and al, 0xFE
mov cr0, eax
jmp dword 0x00:rm
rm:
; Stack anpassen
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ax, 0x1000
mov ss, ax
; Die alte 16-Bit IDT wiederherstellen..
mov dx, 0x70
in al, dx
and al, 0x7F
out dx, al
sti
jmp $
; Shutdown will comming soon
Code: Select all
REAL_CODE_SEL equ $-gdt
dw 0xFFFF
dw 0
db 0
db 0x9A
db 0 ;16-bit
db 0
Code: Select all
00968283000i[CPU ] protected mode
00968283000i[CPU ] CS.d_b = 32 bit
00968283000i[CPU ] SS.d_b = 32 bit
00968283000i[CPU ] | EAX=000006c4 EBX=00000fff ECX=00000064 EDX=0000000f
00968283000i[CPU ] | ESP=000006e0 EBP=000006e8 ESI=00000fff EDI=000c3000
00968283000i[CPU ] | IOPL=0 NV UP DI PL NZ NA PO NC
00968283000i[CPU ] | SEG selector base limit G D
00968283000i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00968283000i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00968283000i[CPU ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00968283000i[CPU ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00968283000i[CPU ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00968283000i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00968283000i[CPU ] | CS:0018( 0003| 0| 0) 00000000 000fffff 1 1
00968283000i[CPU ] | EIP=ff80ae37 (ff80ae37)
00968283000i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0x00000000
00968283000i[CPU ] | CR3=0x0009e000 CR4=0x00000000
00968283000i[ ] restoring default signal behavior
00968283000i[CTRL ] quit_sim called with exit code 1
thx for every help.. wacky