kernel/src/start32.asm

278 lines
4.4 KiB
NASM

format binary
use32
org 0x100000
MB_HEADER_MAGIC equ 0x1BADB002
MB_PAGE_ALIGN equ (1 shl 0)
MB_MEMORY_INFO equ (1 shl 1)
MB_VIDEO_REQUEST equ (1 shl 2)
MB_AOUT_KLUDGE equ (1 shl 16)
MB_HEADER_FLAGS equ MB_PAGE_ALIGN or MB_MEMORY_INFO or MB_VIDEO_REQUEST
MB_HEADER_FLAGS equ MB_PAGE_ALIGN or MB_MEMORY_INFO or MB_VIDEO_REQUEST or MB_AOUT_KLUDGE
MB_CHECKSUM equ -(MB_HEADER_MAGIC + MB_HEADER_FLAGS)
VWIDTH equ 640
VHEIGHT equ 480
VDEPTH equ 32
multiboot:
dd MB_HEADER_MAGIC
dd MB_HEADER_FLAGS
dd MB_CHECKSUM
dd multiboot ; header address
dd 0x100000 ; load address
dd bss_start ; load end address
dd bss_end ; bss end address
dd start ; entry address
dd 0 ; video mode_type (0:fb, 1:txt) (set flags[2]!)
dd VWIDTH ; video width
dd VHEIGHT ; video height
dd VDEPTH ; video depth
start:
; Setup stack
mov ebp, stack_top
mov esp, stack_top
push ebx
push eax
call serialinit
push stuff.bootmsg
call serialwrite
add esp, 4
call mbootgetinfo
add esp, 2*4
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
push stuff.rpostxt
call serialwrite
add esp, 4
push dword esp
push dword 10
xor eax, eax
mov al, [mbootinfo.fb_rpos]
push dword eax
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.gpostxt
call serialwrite
add esp, 4
push dword esp
push dword 10
xor eax, eax
mov al, [mbootinfo.fb_gpos]
push dword eax
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.bpostxt
call serialwrite
add esp, 4
push dword esp
push dword 10
xor eax, eax
mov al, [mbootinfo.fb_bpos]
push dword eax
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.rmasksizetxt
call serialwrite
add esp, 4
push dword esp
push dword 10
xor eax, eax
mov al, [mbootinfo.fb_rmasksize]
push dword eax
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.gmasksizetxt
call serialwrite
add esp, 4
push dword esp
push dword 10
xor eax, eax
mov al, [mbootinfo.fb_gmasksize]
push dword eax
call __uitoa
add esp, 3*4
push esp
call serialwrite
add esp, 4
push stuff.bmasksizetxt
call serialwrite
add esp, 4
push dword esp
push dword 10
xor eax, eax
mov al, [mbootinfo.fb_bmasksize]
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
; Draw a test pixel to bottom right corner
push 0xff
push 0xff
push 0xff
push VHEIGHT-1
push VWIDTH-1
call putpixel
add esp, 3*4
rOSkalogodraw:
mov esi, roskalogo
mov eax, 0 ;Brightness
mov ebx, 0 ;y
mov ecx, 0 ;x
.loop:
lodsb
push eax ;b
push eax ;g
push eax ;r
push ebx ;y
push ecx ;x
call putpixel
pop ecx
pop ebx
pop eax
pop eax
pop eax
inc ecx
cmp byte cl, [roskalogo.w]
jne .loop
mov ecx, 0
inc ebx
cmp byte bl, [roskalogo.h]
jne .loop
.done:
jmp hang
hang:
push .msg
call serialwrite
cli
.loop:
hlt
jmp .loop
.msg db 10, "Halting...", 10, 0
include "src/serial.asm"
include "src/mbootinfo.asm"
include "src/itoa.asm"
include "src/framebuffer.asm"
include "src/roskalogoraw.asm"
stuff:
.bootmsg db 10, "=== rOSka ===", 10, 0
.fbaddrmsgpfx db 10, "Framebuffer address: 0x", 0
.fbdimensionsmsgpfx db 10, "Framebuffer dimensions: ", 0
.x db "x", 0
.rpostxt db 10, "rPos: ", 0
.gpostxt db 10, "gPos: ", 0
.bpostxt db 10, "bPos: ", 0
.rmasksizetxt db 10, "rMaskSize: ", 0
.gmasksizetxt db 10, "gMaskSize: ", 0
.bmasksizetxt db 10, "bMaskSize: ", 0
align 4096
bss_start:
;align 4096
;pagedir:
; rb 4096
;align 4096
;pagetable1:
; rb 4096
align 4096
stack_bottom:
rb 16384
stack_top:
bss_end: