2018-12-22 23:58:57 +01:00
|
|
|
;=----------------------------------------------------------------------------=;
|
|
|
|
; GNU GPL OS/K ;
|
|
|
|
; ;
|
|
|
|
; Authors: spectral` ;
|
|
|
|
; NeoX ;
|
|
|
|
; ;
|
|
|
|
; Desc: Kernel (second stage) Loader for OS/K INCLUDED FUNCTIONS ;
|
|
|
|
; (x86_64 architecture only) ;
|
|
|
|
;=----------------------------------------------------------------------------=;
|
2018-12-24 18:13:58 +01:00
|
|
|
|
2018-12-22 23:58:57 +01:00
|
|
|
[BITS 16]
|
|
|
|
|
|
|
|
disable_cursor:
|
|
|
|
pushf
|
|
|
|
push eax
|
|
|
|
push edx
|
|
|
|
mov dx, 0x3D4
|
|
|
|
mov al, 0xA ; low cursor shape register
|
|
|
|
out dx, al
|
|
|
|
inc dx
|
|
|
|
mov al, 0x20 ; bits 6-7 unused, bit 5 disables the cursor, bits 0-4 control the cursor shape
|
|
|
|
out dx, al
|
|
|
|
pop edx
|
|
|
|
pop eax
|
|
|
|
popf
|
|
|
|
ret
|
|
|
|
|
|
|
|
get_dimensions:
|
|
|
|
push eax
|
|
|
|
push ebx
|
|
|
|
mov ah, 0x0F
|
|
|
|
int 0x10
|
|
|
|
mov [VGA_HEIGHT], ah
|
|
|
|
mov [VIDEO_MODE], al
|
|
|
|
pop ebx
|
|
|
|
pop eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
Is64bits:
|
|
|
|
;-----------------------------------------------------------------------;
|
|
|
|
; Checks if the CPU is compatible with 64-bits operating systems ;
|
|
|
|
; If the 21th bit of the eax register is set, then CPUID is supported ;
|
|
|
|
; We then test CPUID's result to see if long mode is supported ;
|
|
|
|
;-----------------------------------------------------------------------;
|
|
|
|
pushfd ; recovering the flags in eax
|
|
|
|
pop eax
|
|
|
|
mov ecx, eax
|
|
|
|
xor eax, 0x200000
|
|
|
|
push eax
|
|
|
|
popfd
|
|
|
|
pushfd
|
|
|
|
pop eax
|
|
|
|
xor eax, ecx
|
|
|
|
shr eax, 21
|
|
|
|
and eax, 1 ; magical spell of murta
|
|
|
|
push ecx
|
|
|
|
popfd
|
|
|
|
test eax, eax
|
|
|
|
jz .NonCompat ; if (CPUID non supporté) goto NonCompat
|
|
|
|
mov eax, 0x80000000
|
|
|
|
cpuid
|
|
|
|
cmp eax, 0x80000001
|
|
|
|
jb .NonCompat ; if (eax <= 0x80000001) goto NonCompat
|
|
|
|
mov eax, 0x80000001
|
|
|
|
cpuid
|
|
|
|
test edx, 1 << 29
|
|
|
|
jz .NonCompat ; if (edx != 1 << 29) goto NonCompat
|
|
|
|
ret ; back to mbr.s
|
|
|
|
.NonCompat:
|
|
|
|
stc
|
|
|
|
ret
|
|
|
|
|
|
|
|
PrintB:
|
|
|
|
;---------------------------------------------------;
|
|
|
|
; Print out a simple string. ;
|
|
|
|
; ;
|
|
|
|
; Expects: DS:SI = String to print ;
|
|
|
|
; ;
|
|
|
|
; Returns: None ;
|
|
|
|
; ;
|
|
|
|
;---------------------------------------------------;
|
|
|
|
lodsb ; Load byte from ds:si to al
|
|
|
|
or al, al ; If al is empty stop looping
|
|
|
|
jz .done ; Done looping and return
|
|
|
|
mov ah, 0x0e ; Teletype output
|
|
|
|
int 0x10 ; Video interupt
|
|
|
|
jmp PrintB ; Loop untill string is null
|
|
|
|
.done:
|
|
|
|
ret
|