mirror of
https://github.com/fergalmoran/ferglos.git
synced 2025-12-22 09:28:22 +00:00
Initial Makefile building
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.vscode
|
||||
loader.o
|
||||
17
Makefile
Normal file
17
Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
GPPPARAMS = -m32
|
||||
ASPARAMS = --32
|
||||
LDPARAMS = -melf_i386
|
||||
|
||||
objs = loader.o kernel.o
|
||||
|
||||
%.o: %.cpp
|
||||
g++ $(GPPPARAMS) -o $@ -c $<
|
||||
|
||||
%.o: %.s
|
||||
as $(ASPARAMS) -o $@ $<
|
||||
|
||||
ferglos.bin: linker.ld $(objs)
|
||||
ld $(LDPARAMS) -T linker.ld $< -o $@ $(objs)
|
||||
|
||||
install: ferglos.bin
|
||||
sudo cp $< /boot/ferglos.bin
|
||||
10
kernel.cpp
Normal file
10
kernel.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
take in the multiboot structure and the GRUB magic number
|
||||
not sure I actually need magic_num though
|
||||
*/
|
||||
void ferglos_Main(void* mb_struct, unsigned int magic_num) {
|
||||
printf("Hello, Sailor!");
|
||||
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
27
loader.s
Normal file
27
loader.s
Normal file
@@ -0,0 +1,27 @@
|
||||
.set MAGIC, 0x1badb002
|
||||
.set FLAGS, (1<<0 | 1<<1)
|
||||
.set CHECKSUM, -(MAGIC + FLAGS) ; #GRUB needs all this stuff, I'll figure out why later
|
||||
|
||||
.section multiboot
|
||||
.long MAGIC
|
||||
.long FLAGS
|
||||
.long CHECKSUM
|
||||
|
||||
.section .text
|
||||
.extern ferglos_Main
|
||||
.global loader
|
||||
|
||||
loader:
|
||||
mov $kernel_stack, %esp
|
||||
push %eax
|
||||
push %ebx
|
||||
call ferglos_Main
|
||||
|
||||
_stop:; #infinite loop to ensure kernel stays running
|
||||
cli
|
||||
hlt
|
||||
jmp _stop
|
||||
|
||||
.section .bss
|
||||
.space 2*1024*1024; #2MiB padding to ensure ESP doesn't get landed onto anything useful
|
||||
kernel_stack:
|
||||
Reference in New Issue
Block a user