1
1
Fork 0

Multiboot parsing and uitoa impl

This commit is contained in:
Lauren Toivanen 2023-07-24 21:48:21 +03:00
parent ebf9982c07
commit e16da3adc8
Signed by: jt
GPG key ID: 9151B109B73ECAD5
4 changed files with 291 additions and 45 deletions

View file

@ -5,7 +5,7 @@ org 0x100000
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_PAGE_ALIGN equ (1 shl 0)
MULTIBOOT_MEMORY_INFO equ (1 shl 1)
MULTIBOOT_VIDEO_REQUEST equ (0 shl 2)
MULTIBOOT_VIDEO_REQUEST equ (1 shl 2)
MULTIBOOT_AOUT_KLUDGE equ (1 shl 16)
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO or MULTIBOOT_VIDEO_REQUEST
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO or MULTIBOOT_VIDEO_REQUEST or MULTIBOOT_AOUT_KLUDGE
@ -27,68 +27,98 @@ multiboot:
start:
; Setup stack
mov ebp, stack_bottom
mov ebp, stack_top
mov esp, stack_top
push ebx
push eax
cmp eax, 0x2badb002
jne multibootnomagic
mov byte [0xb8000], '!'
push stuff.bootmsg
call printbootmsg
call serialinit
push stuff.bootmsg
call serialwrite
add esp, 4
call mbootgetinfo
add esp, 2*4
mov eax, [mbootinfo.fb_addr]
mov dword [eax], 0xffffffff
push stuff.fbaddrmsgpfx
call serialwrite
add esp, 4
sub esp, 36 ;Reserve stack for return
push dword esp ;Destination address
push dword 16 ;Base
push dword [mbootinfo.fb_addr] ;source
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.fbdimensionsmsgpfx
call serialwrite
add esp, 4
push dword esp ;destination address
push dword 10 ;base
push dword [mbootinfo.fb_width]
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.x
call serialwrite
add esp, 4
push dword esp ;destination address
push dword 10 ;base
push dword [mbootinfo.fb_height]
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.x
call serialwrite
add esp, 4
push dword esp ;destination address
push dword 10 ;base
xor eax, eax
mov al, [mbootinfo.fb_bpp]
push dword eax
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
add esp, 36 ;Clean reserved uitoa return string from stack
jmp hang
hang:
push .msg
call serialwrite
cli
.loop:
hlt
jmp hang
multibootnomagic:
mov esi, .msg
mov edi, 0xb8000
mov ah, 64
cld
.loop:
lodsb
or al, al
jz .done
stosw
jmp .loop
.done:
jmp hang
.msg db "No multiboot magic", 0
printbootmsg:
push ebp
mov ebp, esp
pushad
mov esi, [ebp+8]
mov edi, 0xb8000
cld
.loop:
lodsb
or al, al
jz .done
stosb
inc edi
jmp .loop
.done:
popad
pop ebp
ret
.msg db 10, "Halting...", 10, 0
include "src/serial.asm"
include "src/mbootinfo.asm"
include "src/itoa.asm"
stuff:
.bootmsg db "=== KoalemOS ===", 10, 0
.bootmsg db 10, "=== KoalemOS ===", 10, 0
.fbaddrmsgpfx db 10, "Framebuffer address: 0x", 0
.fbdimensionsmsgpfx db 10, "Framebuffer dimensions: ", 0
.x db "x", 0
stack_bottom: