2023-06-14 03:44:25 +03:00
|
|
|
format elf
|
|
|
|
use32
|
2023-06-13 09:45:04 +03:00
|
|
|
|
2023-06-12 11:46:47 +03:00
|
|
|
MULTIBOOT_PAGE_ALIGN equ (1 shl 0)
|
|
|
|
MULTIBOOT_MEMORY_INFO equ (1 shl 1)
|
2023-06-14 03:44:25 +03:00
|
|
|
MULTIBOOT_VIDEO_REQUEST equ (0 shl 2)
|
2023-06-12 11:46:47 +03:00
|
|
|
MULTIBOOT_AOUT_KLUDGE equ (1 shl 16)
|
|
|
|
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
|
2023-06-14 03:44:25 +03:00
|
|
|
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO or MULTIBOOT_VIDEO_REQUEST
|
2023-06-12 11:46:47 +03:00
|
|
|
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
|
|
|
|
|
|
|
|
.multiboot: align 4
|
|
|
|
dd MULTIBOOT_HEADER_MAGIC
|
|
|
|
dd MULTIBOOT_HEADER_FLAGS
|
|
|
|
dd MULTIBOOT_CHECKSUM
|
2023-06-14 03:44:25 +03:00
|
|
|
; dd 0 ; header address
|
|
|
|
; dd 0 ; load address
|
|
|
|
; dd 0 ; load end address
|
|
|
|
; dd 0 ; bss end address
|
|
|
|
; dd 0 ; entry address
|
|
|
|
; dd 0 ; video mode_type (0:fb, 1:txt) (set flags[2]!)
|
|
|
|
; dd 1024 ; video width
|
|
|
|
; dd 768 ; video height
|
|
|
|
; dd 32 ; video depth
|
2023-06-12 11:46:47 +03:00
|
|
|
|
|
|
|
section '.bss' writable align 16
|
|
|
|
stack_bottom:
|
|
|
|
rb 16384
|
|
|
|
stack_top:
|
|
|
|
|
2023-06-13 09:45:04 +03:00
|
|
|
section '.text' executable
|
|
|
|
public _start
|
|
|
|
extrn kmain
|
|
|
|
|
|
|
|
disable_cursor:
|
|
|
|
pushf
|
|
|
|
push eax
|
|
|
|
push edx
|
2023-06-14 03:44:25 +03:00
|
|
|
|
2023-06-13 09:45:04 +03:00
|
|
|
mov dx, 0x3D4
|
|
|
|
mov al, 0xA ; low cursor shape register
|
|
|
|
out dx, al
|
2023-06-14 03:44:25 +03:00
|
|
|
|
2023-06-13 09:45:04 +03:00
|
|
|
inc dx
|
|
|
|
mov al, 0x20 ; bits 6-7 unused, bit 5 disables the cursor, bits 0-4 control the cursor shape
|
|
|
|
out dx, al
|
2023-06-14 03:44:25 +03:00
|
|
|
|
2023-06-13 09:45:04 +03:00
|
|
|
pop edx
|
|
|
|
pop eax
|
|
|
|
popf
|
|
|
|
ret
|
|
|
|
|
2023-06-12 11:46:47 +03:00
|
|
|
_start:
|
2023-06-13 09:45:04 +03:00
|
|
|
; Setup stack
|
2023-06-14 03:44:25 +03:00
|
|
|
mov esp, stack_top
|
2023-06-13 09:45:04 +03:00
|
|
|
|
|
|
|
; Call the main kernel function.
|
|
|
|
call disable_cursor
|
|
|
|
call kmain
|
|
|
|
|
|
|
|
|
2023-06-12 11:46:47 +03:00
|
|
|
@@:
|
2023-06-13 09:45:04 +03:00
|
|
|
cli
|
|
|
|
hlt
|
|
|
|
jmp @b
|