Compare commits
3 Commits
01ec6da0cc
...
b9b3e92632
| Author | SHA1 | Date | |
|---|---|---|---|
| b9b3e92632 | |||
| 5fac10f02c | |||
| fa4524aa59 |
@@ -110,9 +110,9 @@ ALIGN 4, db 0x90
|
|||||||
PrintCharacter:
|
PrintCharacter:
|
||||||
__CDECL16_ENTRY
|
__CDECL16_ENTRY
|
||||||
.func:
|
.func:
|
||||||
movzx ax, byte [bp + 4] ; AL = character c
|
mov al, byte [bp + 4] ; AL = character c
|
||||||
mov ah, 0x0E ; INT 0x10, AH=0x0E call
|
mov ah, 0x0E ; INT 0x10, AH=0x0E call
|
||||||
mov bx, 0x0007 ; BH = page no. BL =Text attribute 0x07 is lightgrey font on black background
|
mov bx, 0x0007 ; BH = page no. BL =Text attribute
|
||||||
int 0x10 ; call video interrupt
|
int 0x10 ; call video interrupt
|
||||||
; TODO: check for carry and clear carry before call
|
; TODO: check for carry and clear carry before call
|
||||||
.endp:
|
.endp:
|
||||||
|
|||||||
@@ -67,4 +67,35 @@
|
|||||||
mov sp, bp
|
mov sp, bp
|
||||||
pop bp
|
pop bp
|
||||||
%endmacro
|
%endmacro
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%ifnmacro __DEFLAT_DS_ES
|
||||||
|
%macro __DEFLAT_DS_ES 0
|
||||||
|
mov ax, __STAGE2_SEGMENT
|
||||||
|
mov ds, ax
|
||||||
|
mov es, ax
|
||||||
|
%endmacro
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%ifnmacro __REFLAT_DS_ES
|
||||||
|
%macro __REFLAT_ES 0
|
||||||
|
cli ; no interrupts
|
||||||
|
lgdt [((__STAGE2_SEGMENT << 4) + unreal_gdt_info)] ; load unreal gdt
|
||||||
|
|
||||||
|
mov eax, cr0
|
||||||
|
or eax, 1 ; set pmode bit
|
||||||
|
mov cr0, eax ; switch to pmode
|
||||||
|
jmp short $+2 ; i-cache flush
|
||||||
|
|
||||||
|
mov ax, 0x10 ; select descriptor 2
|
||||||
|
mov ds, ax ; 10h = 0001_0000b
|
||||||
|
mov es, ax ; es to big data
|
||||||
|
|
||||||
|
mov eax, cr0
|
||||||
|
and eax, ~1 ; toggle bit 1 of cr0
|
||||||
|
mov cr0, eax ; back to realmode
|
||||||
|
jmp short $+2 ; i-cache flush
|
||||||
|
sti
|
||||||
|
|
||||||
|
%endmacro
|
||||||
%endif
|
%endif
|
||||||
@@ -192,21 +192,22 @@ hcf:
|
|||||||
; ##############################
|
; ##############################
|
||||||
ALIGN 4, db 0x90
|
ALIGN 4, db 0x90
|
||||||
EnterUnrealMode:
|
EnterUnrealMode:
|
||||||
|
__BOCHS_MAGIC_DEBUG
|
||||||
__CDECL16_ENTRY
|
__CDECL16_ENTRY
|
||||||
cli ; no interrupts
|
cli ; no interrupts
|
||||||
.func:
|
.func:
|
||||||
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 eax, 1 ; set pmode bit
|
||||||
mov cr0, eax ; switch to pmode
|
mov cr0, eax ; switch to pmode
|
||||||
jmp short $+2 ; i-cache flush
|
;jmp short $+2 ; i-cache flush
|
||||||
|
|
||||||
; set cs to a pm code segment (0x8) w/ the following
|
; set cs to a pm code segment (0x8) w/ the following
|
||||||
;jmp far 0x0008:EnterUnrealMode.set_segs
|
jmp 0x0008:EnterUnrealMode.set_segs
|
||||||
db 0xEA ; jmp far imm16:imm16
|
;db 0xEA ; jmp far imm16:imm16
|
||||||
dw EnterUnrealMode.set_segs ; error_far_ptr
|
;dw EnterUnrealMode.set_segs ; error_far_ptr
|
||||||
dw 0x0008 ; error_far_seg
|
;dw 0x0008 ; error_far_seg
|
||||||
.set_segs:
|
.set_segs:
|
||||||
mov ax, 0x10 ; select descriptor 2
|
mov ax, 0x10 ; select descriptor 2
|
||||||
mov ds, ax ; 10h = 0001_0000b
|
mov ds, ax ; 10h = 0001_0000b
|
||||||
@@ -216,13 +217,14 @@ EnterUnrealMode:
|
|||||||
mov fs, ax
|
mov fs, ax
|
||||||
mov gs, ax ; extra segments to big data as well
|
mov gs, ax ; extra segments to big data as well
|
||||||
.pm_start:
|
.pm_start:
|
||||||
; code here is running in protected mode
|
; code here is running in protected mode w/ descriptor 0x8
|
||||||
|
; insert any PM test code needed here
|
||||||
.pm_end:
|
.pm_end:
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
and al,0xFE ; toggle bit 1 of cr0
|
and eax, ~1 ; toggle bit 1 of cr0
|
||||||
mov cr0, eax ; back to realmode
|
mov cr0, eax ; back to realmode
|
||||||
jmp short $+2 ; i-cache flush
|
jmp 0x0000:EnterUnrealMode.endp
|
||||||
|
;jmp short $+2 ; i-cache flush
|
||||||
.endp:
|
.endp:
|
||||||
sti ; re-enable interupts
|
sti ; re-enable interupts
|
||||||
__CDECL16_EXIT
|
__CDECL16_EXIT
|
||||||
@@ -302,14 +304,14 @@ unreal_gdt_start:
|
|||||||
; entry 0 (null descriptor)
|
; entry 0 (null descriptor)
|
||||||
dq 0 ; first entry is null
|
dq 0 ; first entry is null
|
||||||
|
|
||||||
; entry 1 (16bit code 64KiB limit)
|
; entry 1 (0x8) (16bit code 64KiB limit)
|
||||||
dd 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0
|
dd 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0
|
||||||
db 0x00 ; Base Address 23:16
|
db 0x00 ; Base Address 23:16
|
||||||
db 1001_1010b ; Access Byte: Present, ring0, S = 1, executable (1), non-conforming, readable, Accessed
|
db 1001_1010b ; Access Byte: Present, ring0, S = 1, executable (1), non-conforming, readable, Accessed
|
||||||
db 0000_0000b ; Flags: GR = 4KiB, attr = <DB/L/Avl>, Granularity = 4KiB & 16:19 of limit
|
db 0000_0000b ; Flags: GR = 4KiB, attr = <DB/L/Avl>, Granularity = 4KiB & 16:19 of limit
|
||||||
db 0x00 ; Base Address 31:24
|
db 0x00 ; Base Address 31:24
|
||||||
|
|
||||||
; entry 2 (16bit data segment with 4 GiB flat mapping)
|
; entry 2 (0x10) (16bit data segment with 4 GiB flat mapping)
|
||||||
dd 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0
|
dd 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0
|
||||||
db 0x00 ; Base Address(23:16)
|
db 0x00 ; Base Address(23:16)
|
||||||
db 1001_0010b ; Access Byte: Present, ring0, S = 1, data (0), non-confirming, writable, present
|
db 1001_0010b ; Access Byte: Present, ring0, S = 1, data (0), non-confirming, writable, present
|
||||||
|
|||||||
Reference in New Issue
Block a user