Initial ISO stuff

This commit is contained in:
Fergal Moran
2020-06-04 23:42:52 +01:00
parent 5cddaac0b7
commit 68af92c29d
4 changed files with 30 additions and 2 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
.vscode
*.o
*.bin
vm/
*.iso

View File

@@ -13,5 +13,21 @@ objs = loader.o kernel.o
ferglos.bin: linker.ld $(objs)
ld $(LDPARAMS) -T $< -o $@ $(objs)
install: ferglos.bin
sudo cp $< /boot/ferglos.bin
ferglos.iso: ferglos.bin
mkdir -p iso/boot/grub
cp ferglos.bin iso/boot/ferglos.bin
echo 'set timeout=0' > iso/boot/grub/grub.cfg
echo 'set default=0' >> iso/boot/grub/grub.cfg
echo '' >> iso/boot/grub/grub.cfg
echo 'menuentry "FerglOS" {' >> iso/boot/grub/grub.cfg
echo ' multiboot /boot/ferglos.bin' >> iso/boot/grub/grub.cfg
echo ' boot' >> iso/boot/grub/grub.cfg
echo '}' >> iso/boot/grub/grub.cfg
grub-mkrescue --output=ferglos.iso iso
rm -rf iso
run: ferglos.iso
/usr/lib/virtualbox/VirtualBoxVM --startvm FerglOS
clean:
rm -rfv iso *.o *.bin

View File

@@ -9,8 +9,14 @@ void printf(char* str) {
}
}
typedef void (*constructor)();
extern "C" constructor start_ctors;
extern "C" constructor end_ctors;
extern "C" void call_constructors() {
for (constructor* i = &start_ctors; i != (constructor*)end_ctors; i++) {
(*i)();
}
}
/*
take in the multiboot structure and the GRUB magic number

View File

@@ -9,10 +9,14 @@
.section .text
.extern ferglos_Main
.extern call_constructors
.global loader
loader:
mov $kernel_stack, %esp
call call_constructors
push %eax
push %ebx
call ferglos_Main