toaruos/start.asm

66 lines
1.1 KiB
NASM
Raw Normal View History

2011-01-16 04:01:19 +03:00
[BITS 32]
global start
start:
mov esp, _sys_stack
jmp stublet
ALIGN 4
mboot:
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
; GRUB Multiboot header, boot signature
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge (must be physical addresses)
; Linker script fills these in
dd mboot
dd code
dd bss
dd end
dd start
; Main entrypoint
stublet:
extern main
call main
jmp $
2011-01-16 06:11:17 +03:00
; Global Descriptor Table
2011-01-16 04:59:11 +03:00
global gdt_flush
extern gp
gdt_flush:
lgdt [gp]
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:flush2
flush2:
ret
2011-01-16 04:01:19 +03:00
2011-01-16 06:11:17 +03:00
; Interrupt Descriptor Table
global idt_load
extern idtp
idt_load:
lidt [idtp]
ret
2011-01-16 04:01:19 +03:00
; Interrupt Service Routines
2011-01-16 06:11:17 +03:00
2011-01-16 04:01:19 +03:00
; BSS Section
SECTION .bss
resb 8192 ; 8KB of memory reserved
_sys_stack:
; This line intentionally left blank