Compare commits

..

4 Commits

5 changed files with 52 additions and 57 deletions

View File

@@ -26,20 +26,20 @@ SetTextMode:
xor ah, ah ; Set Video mode BIOS function
mov al, 0x03 ; 16 color 80x25 Text mode
int 0x10 ; Call video interrupt
; TODO: check for carry and clear carry before call
mov ah, 0x05 ; Select active display page BIOS function
xor al, al ; page 0
int 0x10 ; call video interrupt
; TODO: check for carry and clear carry before call
.endp:
popf
__CDECL16_EXIT
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
disable_cursor:
disable_cursor_crtc:
__CDECL16_ENTRY
.func:
mov dx, 0x3D4
@@ -53,6 +53,24 @@ disable_cursor:
__CDECL16_EXIT
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
; void PrintString(char* buf)
ALIGN 4, db 0x90

View File

@@ -14,14 +14,17 @@
; along with this program. If not, see <https://www.gnu.org/licenses/>.
%ifnmacro __CDECL16_ENTRY
%macro __CDECL16_ENTRY 0
%macro __CDECL16_ENTRY 0-1
push bp
mov bp, sp
sub sp, 0x10
push si
push di
push bx
%if %0 = 1
sub sp, %1 ; reserve locals only when needed
%endif
%endmacro
%endif

View File

@@ -58,7 +58,7 @@ init:
cld
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
xor cx, cx
@@ -96,7 +96,7 @@ main:
mov ah, 0x41
mov bx, 0x55AA
mov dl, 0x80
clc
int 0x13
jnc main.find_active

View File

@@ -149,7 +149,7 @@ main:
add sp, 0x6
call SetTextMode
call disable_cursor
call disable_cursor_bios
print_string HelloPrompt_info
; enable A20 gate
@@ -185,14 +185,6 @@ main:
hcf:
ERROR STEVIA_DEBUG_OK
; ##############################
;
; SYSTEM CONFIGURATION FUNCTIONS
;
; ##############################
; ##############################
;
; SYSTEM CONFIGURATION FUNCTIONS
@@ -201,56 +193,38 @@ hcf:
ALIGN 4, db 0x90
EnterUnrealMode:
__CDECL16_ENTRY
.func:
cli ; no interrupts
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
cli ; no interrupts
.func:
lgdt [((__STAGE2_SEGMENT << 4) + unreal_gdt_info)] ; load unreal gdt
mov eax, cr0
or al,1 ; set pmode bit
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
dw EnterUnrealMode.load_cs ; error_far_ptr
dw EnterUnrealMode.set_segs ; error_far_ptr
dw 0x0008 ; error_far_seg
.load_cs:
mov bx, 0x10 ; select descriptor 2
mov ds, bx ; 10h = 0001_0000b
mov ss, bx
mov es, bx
mov fs, bx
mov gs, bx ; other data/stack to index 2 (off 0x10)
.set_segs:
mov ax, 0x10 ; select descriptor 2
mov ds, ax ; 10h = 0001_0000b
mov es, ax ; es to big data
mov ss, ax ; big stack
mov fs, ax
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
mov cr0, eax ; back to realmode
jmp short $+2
;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
jmp short $+2 ; i-cache flush
.endp:
sti ; re-enable interupts
__CDECL16_EXIT
ret
end_text:

View File

@@ -72,7 +72,7 @@ init:
cld
rep stosb
sub sp, 0x20 ; local varible space
sub sp, 0x20 ; local varible space (32 bytes)
push bp
sti ; all done with inital setup and relocation, reenable interupts