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. 4
      src/lib/vga.c

@ -6,11 +6,11 @@ fail="[FAIL]"
srcDir=src
binDir=bin
echo -n "Compiling bootloader... "
nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin && echo $done
echo "Compiling bootloader... "
nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin
echo -n "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
echo "Compiling kernel... "
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... "
cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image && echo $done
echo "Creating OS image... "
cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image

@ -38,7 +38,7 @@ BEGIN_PM:
load_kernel:
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
call disk_read ; Load the kernel

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

@ -10,11 +10,11 @@ char* get_cursor_pos(unsigned int row, unsigned int col) { return (char*)(VIDEO_
void print(char* str, unsigned int str_len) {
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
}
}
void println(char* str, unsigned int str_len) {
print(str, str_len);
cursor_y++; // Increment to next y-pos (newline)
cursor_y++; // Increment to next y-pos (newline)
}

Loading…
Cancel
Save