-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
669afc4
commit c1b4368
Showing
6 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FILES = ./build/kernel.asm.o | ||
|
||
all: ./bin/boot.bin $(FILES) | ||
dd -f=./bin/boot.bin >> ./bin/os.bin | ||
|
||
./bin/boot.bin: ./src/boot/boot.asm | ||
nasm -f bin ./src/boot/boot.asm -o ./bin/boot.bin | ||
./build/kernel.asm.o: ./src/kernel.asm | ||
nasm -f elf -g ./src/kernel.asm -o ./build/kernel.asm.o | ||
clean: | ||
rm -rf ./bin/boot.bin |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#/bin/bash | ||
export PREFIX="$HOME/opt/cross" | ||
export TARGET=i686-elf | ||
export PATH="$PREFIX/bin:$PATH" | ||
make all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
ORG 0x7c00 | ||
BITS 16 | ||
|
||
CODE_SEG equ gdt_code - gdt_start | ||
DATA_SEG equ gdt_data - gdt_start | ||
|
||
_start: | ||
jmp short start | ||
nop | ||
times 33 db 0 | ||
|
||
start: | ||
jmp 0:step2 | ||
|
||
step2: | ||
cli ; disable interrupts | ||
mov ax, 0x00 | ||
mov ds, ax | ||
mov es, ax | ||
mov ss, ax | ||
mov sp, 0x7c00 | ||
sti ; enable interrupts | ||
|
||
load_protected: | ||
cli | ||
lgdt[gdt_descriptor] | ||
mov eax, cr0 | ||
or eax, 1 | ||
mov cr0, eax | ||
;jmp CODE_SEG:load32 | ||
jmp $ | ||
|
||
|
||
;GDT | ||
gdt_start: | ||
gdt_null: | ||
dd 0x0 | ||
dd 0x0 | ||
|
||
gdt_code: | ||
dw 0xffff | ||
dw 0 | ||
db 0 | ||
db 0x9a | ||
db 11001111b | ||
db 0 | ||
|
||
gdt_data: | ||
dw 0xffff | ||
dw 0 | ||
db 0 | ||
db 0x92 | ||
db 11001111b | ||
db 0 | ||
gdt_end: | ||
|
||
gdt_descriptor: | ||
dw gdt_end - gdt_start - 1 | ||
dd gdt_start | ||
|
||
times 510-($-$$) db 0 | ||
dw 0xAA55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
BITS 32 | ||
|
||
load32: | ||
mov ax, DATA_SEG | ||
mov ds, ax | ||
mov es, ax | ||
mov fs, ax | ||
mov gs, ax | ||
mov ss, ax | ||
mov ebp, 0x00200000 | ||
mov esp, ebp | ||
|
||
in al, 0x92 | ||
or al, 2 | ||
out 0x92, al | ||
|
||
jmp $ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ENTRY(_start) | ||
OUTPUT_FORMAT(binary) | ||
SECTIONS | ||
{ | ||
. = 1M; | ||
.text : | ||
{ | ||
*(.text) | ||
} | ||
|
||
.rodata : | ||
{ | ||
*(.rodata) | ||
} | ||
|
||
.data : | ||
{ | ||
*(.data) | ||
} | ||
|
||
.bss : | ||
{ | ||
*(COMMON) | ||
*(.bss) | ||
} | ||
} |