make unreal mode unreal again
This commit is contained in:
@@ -149,7 +149,7 @@ main:
|
|||||||
add sp, 0x6
|
add sp, 0x6
|
||||||
|
|
||||||
call SetTextMode
|
call SetTextMode
|
||||||
call disable_cursor
|
call disable_cursor_bios
|
||||||
print_string HelloPrompt_info
|
print_string HelloPrompt_info
|
||||||
|
|
||||||
; enable A20 gate
|
; enable A20 gate
|
||||||
@@ -185,14 +185,6 @@ main:
|
|||||||
hcf:
|
hcf:
|
||||||
ERROR STEVIA_DEBUG_OK
|
ERROR STEVIA_DEBUG_OK
|
||||||
|
|
||||||
; ##############################
|
|
||||||
;
|
|
||||||
; SYSTEM CONFIGURATION FUNCTIONS
|
|
||||||
;
|
|
||||||
; ##############################
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ##############################
|
; ##############################
|
||||||
;
|
;
|
||||||
; SYSTEM CONFIGURATION FUNCTIONS
|
; SYSTEM CONFIGURATION FUNCTIONS
|
||||||
@@ -201,56 +193,38 @@ hcf:
|
|||||||
ALIGN 4, db 0x90
|
ALIGN 4, db 0x90
|
||||||
EnterUnrealMode:
|
EnterUnrealMode:
|
||||||
__CDECL16_ENTRY
|
__CDECL16_ENTRY
|
||||||
.func:
|
cli ; no interrupts
|
||||||
cli ; no interrupts
|
.func:
|
||||||
push ds ; save real mode data/stack selectors
|
|
||||||
push es
|
|
||||||
push fs
|
|
||||||
push gs
|
|
||||||
push ss
|
|
||||||
|
|
||||||
push cs ; save real mode code selector
|
|
||||||
xor ax, ax ;
|
|
||||||
pop ax ; save cs to ax to setup far jump
|
|
||||||
mov word [__UNREAL_SEGMENT], ax
|
|
||||||
|
|
||||||
lgdt [((__STAGE2_SEGMENT << 4) + unreal_gdt_info)] ; load unreal gdt
|
lgdt [((__STAGE2_SEGMENT << 4) + unreal_gdt_info)] ; load unreal gdt
|
||||||
|
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
or al,1 ; set pmode bit
|
or al,1 ; set pmode bit
|
||||||
mov cr0, eax ; switch to pmode
|
mov cr0, eax ; switch to pmode
|
||||||
jmp short $+2
|
jmp short $+2 ; i-cache flush
|
||||||
|
|
||||||
;jmp far 0x0008:EnterUnrealMode.load_cs
|
; set cs to a pm code segment (0x8) w/ the following
|
||||||
|
;jmp far 0x0008:EnterUnrealMode.set_segs
|
||||||
db 0xEA ; jmp far imm16:imm16
|
db 0xEA ; jmp far imm16:imm16
|
||||||
dw EnterUnrealMode.load_cs ; error_far_ptr
|
dw EnterUnrealMode.set_segs ; error_far_ptr
|
||||||
dw 0x0008 ; error_far_seg
|
dw 0x0008 ; error_far_seg
|
||||||
.load_cs:
|
.set_segs:
|
||||||
mov bx, 0x10 ; select descriptor 2
|
mov ax, 0x10 ; select descriptor 2
|
||||||
mov ds, bx ; 10h = 0001_0000b
|
mov ds, ax ; 10h = 0001_0000b
|
||||||
|
mov es, ax ; es to big data
|
||||||
mov ss, bx
|
|
||||||
mov es, bx
|
mov ss, ax ; big stack
|
||||||
mov fs, bx
|
mov fs, ax
|
||||||
mov gs, bx ; other data/stack to index 2 (off 0x10)
|
mov gs, ax ; extra segments to big data as well
|
||||||
|
.pm_start:
|
||||||
|
; code here is running in protected mode
|
||||||
|
.pm_end:
|
||||||
|
mov eax, cr0
|
||||||
and al,0xFE ; toggle bit 1 of cr0
|
and al,0xFE ; toggle bit 1 of cr0
|
||||||
mov cr0, eax ; back to realmode
|
mov cr0, eax ; back to realmode
|
||||||
jmp short $+2
|
jmp short $+2 ; i-cache flush
|
||||||
|
|
||||||
;jmp far 0x0008:EnterUnrealMode.unload_cs
|
|
||||||
db 0xEA ; jmp far imm16:imm16
|
|
||||||
dw EnterUnrealMode.unload_cs ; error_far_ptr
|
|
||||||
__UNREAL_SEGMENT:
|
|
||||||
dw 0x0000 ; error_far_seg
|
|
||||||
EnterUnrealMode.unload_cs:
|
|
||||||
pop ss
|
|
||||||
pop gs
|
|
||||||
pop fs
|
|
||||||
pop es
|
|
||||||
pop ds ; get back old segments
|
|
||||||
sti
|
|
||||||
.endp:
|
.endp:
|
||||||
|
sti ; re-enable interupts
|
||||||
__CDECL16_EXIT
|
__CDECL16_EXIT
|
||||||
ret
|
ret
|
||||||
end_text:
|
end_text:
|
||||||
|
|||||||
Reference in New Issue
Block a user