1
1
Fork 0
kernel/roska.fasm

137 lines
2.3 KiB
Text

format binary
use32
org 0x100000
; multiboot skips us to 32bit mode
; 16bit mode required to set video mode
; multiboot might not set our video mode (looking at you, syslinux!)
; TODO: make the own bootloader and ditch multiboot
; users can(will) have inexpensive small harddrives or usbs dedicated to this shit
multiboot:
dd 0x1BADB002 ; magic
dd 00000000000000010000000000000000b ; aout kludge flag
dd 0xE4514FFE ; mboot checksum
dd 0x100000 ; header address
dd 0x100000 ; load address
dd 0 ; load end address, 0=assume whole file
dd 0 ; bss end address, 0=don't zero-init
dd 0x100030 ; entry address
; we don't ask for video mode really as it's too unreliable
; but here's it zeroed-out anyway
dd 0 ; videomode 0=linear 1=ega text
dd 0 ; width 0=no pref
dd 0 ; height 0=no pref
dd 0 ; depth 0=no pref
start:
; Setup stack
mov ebp, stack_top
mov esp, stack_top
;push ebx ; mboot info struct addr
;push eax ; 0x2BADB002
mov [mbootmagic], eax
;mov [mbootaddr], ebx
call con_disable_cursor
call conclear
mov esi, msg.roskainiting
call conwriteln
hang:
;cli
.loop:
;hlt
jmp .loop
;give character in AL
conputchar:
mov ah, [txtbuf.col]
mov dx, ax
; dx has the whole character cell now
xor eax, eax
mov al, [txtbuf.y]
mov bl, 80
mul bl
movzx bx, [txtbuf.x]
add ax, bx
add ax, ax
add eax, 0xb8000
mov [eax], dx
cmp bl, 79
je connewline
inc bl
mov [txtbuf.x], bl
ret
conwriteln:
lodsb
cmp al, 0
je connewline
call conputchar
jmp conwriteln
connewline:
mov [txtbuf.x], 0
mov al, [txtbuf.y]
cmp al, 24
je conscroll
inc al
mov [txtbuf.y], al
ret
conscroll:
ret
conclear:
mov ecx, 80*25
mov edi, 0xb8000
mov ah, 0x07
mov al, 0
rep stosw
mov [txtbuf.col], ah
mov [txtbuf.x], 0
mov [txtbuf.y], 0
ret
con_disable_cursor:
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
ret
mbootaddr: dd 0
mbootmagic: dd 0
txtbuf:
.x db 0
.y db 0
.col db 0x07 ;gray on black
fb:
.addr dd 0
.pitch dd 0
.width dd 0
.height dd 0
.depth db 0
.bytespp db 0
.rpos db 0
;.rmasksize db 0
.gpos db 0
;.gmasksize db 0
.bpos db 0
;.bmasksize db 0
msg:
.roskainiting db "rOSka initializing...", 0
align 4096
bss_start:
align 4096
stack_bottom:
rb 16384
stack_top:
bss_end: