blob: b62801824de30bc23671ae21f213f6b12e06e727 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
[bits 32]
global start
start:
mov esp, _sys_stack ; Points stack to stack area
jmp stublet
; Align with 4 Bytes
ALIGN 4
mboot:
; Multiboot macros
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_VIDEO_MODE equ 1<<2
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_VIDEO_MODE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
; GRUB Multiboot header
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge
dd mboot
dd code
dd bss
dd end
dd start
; Request linear graphics mode
dd 0
dd 640 ; width
dd 480 ; height
dd 8 ; bpp
; Endless loop
stublet:
extern kernel_main
call kernel_main
jmp $
[global copy_page_physical]
copy_page_physical:
push ebx
pushf
cli
mov ebx, [esp+12]
mov ecx, [esp+16]
; Disable paging
mov edx, cr0
and edx, 0x7fffffff
mov cr0, edx
mov edx, 0x400
%include "src/kernel/gdt/gdt.asm"
%include "src/kernel/interrupts/idt.asm"
%include "src/kernel/interrupts/isr.asm"
%include "src/kernel/interrupts/irq.asm"
%include "src/kernel/interact.asm"
; Store the stack
SECTION .bss
resb 0x2000 ; Reserve 8KiB
_sys_stack:
|