Changed to using Boch to better handle debugging the kernel. Updated build system with a new script to handle working with the build_numbers.c file.
This commit is contained in:
@@ -1,2 +1,5 @@
|
|||||||
*.o
|
*.o
|
||||||
*.elf
|
*.elf
|
||||||
|
*.log
|
||||||
|
*.iso
|
||||||
|
*.bin
|
||||||
|
|||||||
@@ -1,50 +1,33 @@
|
|||||||
|
.DELETE_ON_ERROR:
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
GCCPARAMS = -m32 -fno-pie -nostdlib -fstrength-reduce -fomit-frame-pointer -finline-functions -fno-builtin -nostdinc -fno-stack-protector
|
GCCPARAMS = -m32 -fno-pie -nostdlib -fstrength-reduce -fomit-frame-pointer -finline-functions -fno-builtin -nostdinc -fno-stack-protector
|
||||||
ASPARAMS = -f elf32
|
ASPARAMS = -f elf32
|
||||||
LDPARAMS = -m elf_i386
|
LDPARAMS = -m elf_i386
|
||||||
INCBULDNUM = sh make_buildnum.sh
|
|
||||||
|
|
||||||
SRC := kernel
|
SRC := kernel
|
||||||
OBJ := obj
|
OBJ := obj
|
||||||
|
|
||||||
SOURCES := $(wildcard $(SRC)/*.c)
|
SOURCES := $(wildcard $(SRC)/*.c)
|
||||||
ASMSOURCES := $(wildcard $(SRC)/*.asm)
|
ASMSOURCES := $(wildcard $(SRC)/*.s)
|
||||||
OBJECTS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SOURCES))
|
OBJECTS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SOURCES))
|
||||||
ASMOBJECTS := $(patsubst $(SRC)/%.asm, $(OBJ)/%.o, $(ASMSOURCES))
|
ASMOBJECTS := $(patsubst $(SRC)/%.s, $(OBJ)/%.o, $(ASMSOURCES))
|
||||||
|
|
||||||
run: kernel.iso
|
run: kernel.iso
|
||||||
qemu-system-x86_64 -serial pipe:/tmp/guest -m 256M -cdrom kernel.iso &
|
bochs -f support_files/boch.txt -q
|
||||||
|
|
||||||
$(OBJ)/%.o: $(SRC)/%.c
|
$(OBJ)/%.o: $(SRC)/%.c
|
||||||
mkdir -p $(@D)
|
|
||||||
$(CC) $(GCCPARAMS) $(SRC) -c -o $@ $<
|
$(CC) $(GCCPARAMS) $(SRC) -c -o $@ $<
|
||||||
|
|
||||||
$(OBJ)/%.o: $(SRC)/%.asm
|
$(OBJ)/%.o: $(SRC)/%.s
|
||||||
mkdir -p $(@D)
|
|
||||||
nasm $(ASPARAMS) -o $@ $<
|
nasm $(ASPARAMS) -o $@ $<
|
||||||
|
|
||||||
kernel.bin: $(OBJECTS) $(ASMOBJECTS)
|
kernel.o: build_numbers.c $(OBJECTS) $(ASMOBJECTS)
|
||||||
@#Crap way to increment the build number, but will do for now
|
@sh support_files/run_linker.sh "$(LDPARAMS)" obj/bin/$@ "$(OBJECTS)" "$(ASMOBJECTS)"
|
||||||
@#thanks to my limited knowledge of Makefiles.
|
|
||||||
@#Sadly this number in the compiled code will always be off by one with this method....
|
|
||||||
@sh make_buildnum.sh
|
|
||||||
mkdir -p obj/bin
|
|
||||||
ld $(LDPARAMS) -T linker.ld -o obj/bin/$@ $(OBJECTS) $(ASMOBJECTS)
|
|
||||||
|
|
||||||
kernel.iso: kernel.bin
|
kernel.iso: kernel.o
|
||||||
mkdir iso
|
cp obj/bin/kernel.o iso/boot/kernel.bin
|
||||||
mkdir iso/boot
|
|
||||||
mkdir iso/boot/grub
|
|
||||||
cp obj/bin/kernel.bin iso/boot/kernel.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 "SDOS" {' >> iso/boot/grub/grub.cfg
|
|
||||||
echo ' multiboot /boot/kernel.bin' >> iso/boot/grub/grub.cfg
|
|
||||||
echo ' boot' >> iso/boot/grub/grub.cfg
|
|
||||||
echo '}' >> iso/boot/grub/grub.cfg
|
|
||||||
grub-mkrescue --output=kernel.iso iso
|
grub-mkrescue --output=kernel.iso iso
|
||||||
rm -rf iso
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
@@ -52,4 +35,4 @@ clean:
|
|||||||
|
|
||||||
.PHONY: resetbuild
|
.PHONY: resetbuild
|
||||||
resetbuild:
|
resetbuild:
|
||||||
echo 0 > build.number
|
@sh support_files/handle_build_numbers.sh build_numbers.c reset
|
||||||
|
|||||||
+1
-4
@@ -1,6 +1,3 @@
|
|||||||
#ifndef KERNEL_VERSION_NUMBER
|
#ifndef KERNEL_VERSION_NUMBER
|
||||||
#define KERNEL_VERSION_NUMBER "1.4.10-40"
|
#define KERNEL_VERSION_NUMBER "1.4.10-0"
|
||||||
#endif
|
|
||||||
#ifndef CONSOLE_VERSION_NUMBER
|
|
||||||
#define CONSOLE_VERSION_NUMBER "0.4.5-0"
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
set timeout=0
|
||||||
|
set default=0
|
||||||
|
|
||||||
|
menuentry "SDOS" {
|
||||||
|
multiboot /boot/kernel.bin
|
||||||
|
boot
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
void kmain()
|
||||||
|
{
|
||||||
|
asm("hlt");
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
global loader
|
||||||
|
|
||||||
|
MAGIC_NUMBER equ 0x1BADB002
|
||||||
|
FLAGS equ 0x0
|
||||||
|
CHECKSUM equ -MAGIC_NUMBER
|
||||||
|
KERNEL_STACK_SIZE equ 4096 ; size of stack in bytes
|
||||||
|
|
||||||
|
section .text:
|
||||||
|
align 4
|
||||||
|
dd MAGIC_NUMBER
|
||||||
|
dd FLAGS
|
||||||
|
dd CHECKSUM
|
||||||
|
|
||||||
|
loader:
|
||||||
|
extern kmain
|
||||||
|
call kmain
|
||||||
|
;mov eax, 0xCAFEBABE
|
||||||
|
;mov esp, kernel_stack + KERNEL_STACK_SIZE ; piont ESP to the start of the stack (end of memory area)
|
||||||
|
.loop:
|
||||||
|
jmp .loop
|
||||||
|
|
||||||
|
section .bss
|
||||||
|
alignb 4
|
||||||
|
resb KERNEL_STACK_SIZE ; reserve stack for kernel
|
||||||
|
kernel_stack:
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
global loader
|
|
||||||
|
|
||||||
MAGIC_NUMBER equ 0x1BADB002
|
|
||||||
FLAGS equ 0x0
|
|
||||||
CHECKSUM equ -MAGIC_NUMBER
|
|
||||||
|
|
||||||
section .text:
|
|
||||||
align 4
|
|
||||||
dd MAGIC_NUMBER
|
|
||||||
dd FLAGS
|
|
||||||
dd CHECKSUM
|
|
||||||
|
|
||||||
loader:
|
|
||||||
mov eax, 0xCAFEBABE
|
|
||||||
.loop:
|
|
||||||
jmp .loop
|
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
megs: 32
|
||||||
|
display_library: x
|
||||||
|
romimage: file=/usr/share/bochs/BIOS-bochs-latest
|
||||||
|
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
|
||||||
|
ata0-master: type=cdrom, path=kernel.iso, status=inserted
|
||||||
|
boot: cdrom
|
||||||
|
log: bochs.log
|
||||||
|
clock: sync=realtime, time0=local
|
||||||
|
cpu: count=1, ips=1000000
|
||||||
@@ -45,23 +45,13 @@ while IFS=' ' read -ra line; do
|
|||||||
#It doesn't matter what its value is only that one is present.
|
#It doesn't matter what its value is only that one is present.
|
||||||
#If there isn't a second parameter set, then we increment the meta build
|
#If there isn't a second parameter set, then we increment the meta build
|
||||||
#number, otherwise we decrement.
|
#number, otherwise we decrement.
|
||||||
if [ "$2" == "" ]
|
if [ "$2" != "reset" ]
|
||||||
then
|
then
|
||||||
echo "Incrementing meta build number."
|
echo "Incrementing meta build number."
|
||||||
meta=$(($i + 1))
|
meta=$(($i + 1))
|
||||||
elif [ "$2" == "reset" ]
|
else
|
||||||
then
|
|
||||||
echo "Resetting meta build number."
|
echo "Resetting meta build number."
|
||||||
meta=0
|
meta=0
|
||||||
else
|
|
||||||
if [ "$i" -gt 0 ]
|
|
||||||
then
|
|
||||||
echo "Decrementing meta build number."
|
|
||||||
meta=$(($i - 1))
|
|
||||||
else
|
|
||||||
echo "Meta build number already zero, nothing to be done."
|
|
||||||
meta=0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#Handles the final linking of the OS binaries to build the kernel.
|
||||||
|
#This script will allow for rolling back the build number found in the
|
||||||
|
#build_numbers.c file.
|
||||||
|
|
||||||
|
ld $1 -T support_files/link.ld -o $2 $3 $4
|
||||||
|
|
||||||
|
if [[ $? == 0 ]]
|
||||||
|
then
|
||||||
|
./support_files/handle_build_numbers.sh build_numbers.c
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user