Fixed kernel compiling & linking problems

pull/19/head
E. Almqvist 3 years ago
parent a5ba69a1d3
commit 4b028524f0
  1. 12
      compile.sh
  2. 2
      src/bootloader.asm
  3. 6
      src/kernel.c
  4. 2
      src/lib/vga.c

@ -6,11 +6,11 @@ fail="[FAIL]"
srcDir=src srcDir=src
binDir=bin binDir=bin
echo -n "Compiling bootloader... " echo "Compiling bootloader... "
nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin && echo $done nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin
echo -n "Compiling kernel... " echo "Compiling kernel... "
gcc -ffreestanding -c $srcDir/kernel.c -o $binDir/kernel.o && ld -o $binDir/kernel.bin -Ttext 0x1000 $binDir/kernel.o --oformat binary 2>/dev/null && echo $done gcc -fno-pie -m32 -Os -ffreestanding -c $srcDir/kernel.c -o $binDir/kernel.o && gcc -o $binDir/kernel.bin $binDir/kernel.o -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32
echo -n "Creating OS image... " echo "Creating OS image... "
cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image && echo $done cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image

@ -38,7 +38,7 @@ BEGIN_PM:
load_kernel: load_kernel:
mov bx, KERNEL_OFFSET ; Load kernel at the kernel offset mov bx, KERNEL_OFFSET ; Load kernel at the kernel offset
mov dh, 15 ; Read 15 sectors mov dh, 7 ; Read 15 sectors
mov dl, [BOOT_DRIVE] ; Drive index mov dl, [BOOT_DRIVE] ; Drive index
call disk_read ; Load the kernel call disk_read ; Load the kernel

@ -1,8 +1,6 @@
//#include "lib/vga.c" #include "lib/vga.c"
void main() { void main() {
// Do kernel stuff // Do kernel stuff
char* vidmem = (char*)(0xb8000); println("C-Printing test!", 16);
*vidmem = 'X';
//println("C-Printing test!", 16);
} }

@ -10,7 +10,7 @@ char* get_cursor_pos(unsigned int row, unsigned int col) { return (char*)(VIDEO_
void print(char* str, unsigned int str_len) { void print(char* str, unsigned int str_len) {
for( unsigned int i = 0; i < str_len; i++ ) { for( unsigned int i = 0; i < str_len; i++ ) {
*get_cursor_pos(i, cursor_y) = str[i]; // write to video memory *get_cursor_pos(cursor_y, i) = 'X'; // write to video memory
} }
} }

Loading…
Cancel
Save