Compare commits
4 Commits
a53534acd2
...
01ec6da0cc
| Author | SHA1 | Date | |
|---|---|---|---|
| 01ec6da0cc | |||
| 2e2b4f991d | |||
| d7b29d9113 | |||
| 69d82dc0c2 |
@@ -26,20 +26,20 @@ SetTextMode:
|
|||||||
xor ah, ah ; Set Video mode BIOS function
|
xor ah, ah ; Set Video mode BIOS function
|
||||||
mov al, 0x03 ; 16 color 80x25 Text mode
|
mov al, 0x03 ; 16 color 80x25 Text mode
|
||||||
int 0x10 ; Call video interrupt
|
int 0x10 ; Call video interrupt
|
||||||
; TODO: check for carry and clear carry before call
|
|
||||||
|
|
||||||
mov ah, 0x05 ; Select active display page BIOS function
|
mov ah, 0x05 ; Select active display page BIOS function
|
||||||
xor al, al ; page 0
|
xor al, al ; page 0
|
||||||
int 0x10 ; call video interrupt
|
int 0x10 ; call video interrupt
|
||||||
; TODO: check for carry and clear carry before call
|
|
||||||
.endp:
|
.endp:
|
||||||
popf
|
popf
|
||||||
__CDECL16_EXIT
|
__CDECL16_EXIT
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; disables blinking text mode cursor
|
; disables blinking text mode cursor via crtc pokes
|
||||||
|
; 0x3D4/0x3D5 for color, mono at 0x3B4/0x3B5
|
||||||
ALIGN 4, db 0x90
|
ALIGN 4, db 0x90
|
||||||
disable_cursor:
|
disable_cursor_crtc:
|
||||||
__CDECL16_ENTRY
|
__CDECL16_ENTRY
|
||||||
.func:
|
.func:
|
||||||
mov dx, 0x3D4
|
mov dx, 0x3D4
|
||||||
@@ -53,6 +53,24 @@ disable_cursor:
|
|||||||
__CDECL16_EXIT
|
__CDECL16_EXIT
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; disables blinking text mode cursor via BIOS int 10h, ah = 01
|
||||||
|
ALIGN 4, db 0x90
|
||||||
|
disable_cursor_bios:
|
||||||
|
__CDECL16_ENTRY
|
||||||
|
.func:
|
||||||
|
push bx
|
||||||
|
mov ah, 03h ; read cursor pos & shape
|
||||||
|
xor bh, bh
|
||||||
|
int 10h ; CH=top scanline, CL=bottom
|
||||||
|
|
||||||
|
or ch, 20h ; set bit 5 = disable
|
||||||
|
mov ah, 01h ; set leaf 01h
|
||||||
|
int 10h
|
||||||
|
pop bx
|
||||||
|
.endp:
|
||||||
|
__CDECL16_EXIT
|
||||||
|
ret
|
||||||
|
|
||||||
; Prints a C-Style string (null terminated) using BIOS vga teletype call
|
; Prints a C-Style string (null terminated) using BIOS vga teletype call
|
||||||
; void PrintString(char* buf)
|
; void PrintString(char* buf)
|
||||||
ALIGN 4, db 0x90
|
ALIGN 4, db 0x90
|
||||||
|
|||||||
@@ -14,14 +14,17 @@
|
|||||||
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
%ifnmacro __CDECL16_ENTRY
|
%ifnmacro __CDECL16_ENTRY
|
||||||
%macro __CDECL16_ENTRY 0
|
%macro __CDECL16_ENTRY 0-1
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
sub sp, 0x10
|
|
||||||
|
|
||||||
push si
|
push si
|
||||||
push di
|
push di
|
||||||
push bx
|
push bx
|
||||||
|
|
||||||
|
%if %0 = 1
|
||||||
|
sub sp, %1 ; reserve locals only when needed
|
||||||
|
%endif
|
||||||
%endmacro
|
%endmacro
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ init:
|
|||||||
cld
|
cld
|
||||||
rep stosb ; zero bss section
|
rep stosb ; zero bss section
|
||||||
|
|
||||||
sub sp, 0x20 ; local varible space
|
sub sp, 0x20 ; local varible space (32 bytes)
|
||||||
push bp ; setup top of stack frame
|
push bp ; setup top of stack frame
|
||||||
|
|
||||||
xor cx, cx
|
xor cx, cx
|
||||||
@@ -96,7 +96,7 @@ main:
|
|||||||
mov ah, 0x41
|
mov ah, 0x41
|
||||||
mov bx, 0x55AA
|
mov bx, 0x55AA
|
||||||
mov dl, 0x80
|
mov dl, 0x80
|
||||||
|
|
||||||
clc
|
clc
|
||||||
int 0x13
|
int 0x13
|
||||||
jnc main.find_active
|
jnc main.find_active
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ init:
|
|||||||
cld
|
cld
|
||||||
rep stosb
|
rep stosb
|
||||||
|
|
||||||
sub sp, 0x20 ; local varible space
|
sub sp, 0x20 ; local varible space (32 bytes)
|
||||||
push bp
|
push bp
|
||||||
|
|
||||||
sti ; all done with inital setup and relocation, reenable interupts
|
sti ; all done with inital setup and relocation, reenable interupts
|
||||||
|
|||||||
Reference in New Issue
Block a user