Merge pull request #19 from E-Almqvist/dev

VGA stuff
pull/25/head
Elias Almqvist 3 years ago committed by GitHub
commit c572bca0cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      compile.sh
  2. 2
      src/bootloader.asm
  3. 11
      src/kernel.c
  4. 22
      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,7 +1,10 @@
// VGA base address: 0xb8000
// Charpos = 0xb8000 + 2(row*80 + col)
#include "lib/vga.c"
void main() {
char* video_mem = (char*)0xb8000; // VGA Video Memory location
*video_mem = 'X';
// Do kernel stuff
char* vidmem = (char*)0xb8000;
*vidmem = 'X';
for( int i = 0; i < 16; i++ ) {
println("C-Printing test!", 16);
}
}

@ -0,0 +1,22 @@
// VGA Graphics Library
// VGA base address: 0xb8000
// Charpos = 0xb8000 + 2(row*80 + col)
#define VIDEO_MEM (char*)0xb8000
#define GET_INDEX(s, c) (int)(c-s)
static int cursor_y = 0;
char* get_cursor_pos(unsigned int col, unsigned int row) {
return (char*)(VIDEO_MEM + 2*((row*80) + col));
}
void print(char* str, unsigned int str_len) {
for( char* c = str; *c != '\0'; c++ )
*get_cursor_pos( GET_INDEX(str, c), cursor_y ) = 'Y';
}
void println(char* str, unsigned int str_len) {
print(str, str_len);
cursor_y++; // Increment to next y-pos (newline)
}
Loading…
Cancel
Save