From b6851ab0b53018dce16a8c0496a1dee35654dda8 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 18 Sep 2015 02:56:07 -0700 Subject: [PATCH] Support stuff for keyboard --- Makefile | 5 +++-- c_keyboard.c | 9 +++++++++ keyboard.asm | 4 ++++ x86_vram_functions.asm | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 c_keyboard.c diff --git a/Makefile b/Makefile index 433937a..66e48d2 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,10 @@ baremetal_gamarjoba: baremetal_gamarjoba.asm include.c run_baremetal_gamarjoba: baremetal_gamarjoba qemu-system-i386 -kernel baremetal_gamarjoba -keyboard: keyboard.asm +keyboard: keyboard.asm c_keyboard.c + gcc -m32 -ffreestanding -o c_keyboard.o -c c_keyboard.c nasm -f elf32 keyboard.asm - ld -m elf_i386 -nostdlib -T linker.ld keyboard.o -o keyboard + ld -m elf_i386 -nostdlib -T linker.ld keyboard.o c_keyboard.o -o keyboard run_keyboard: keyboard qemu-system-i386 -kernel keyboard diff --git a/c_keyboard.c b/c_keyboard.c new file mode 100644 index 0000000..035d816 --- /dev/null +++ b/c_keyboard.c @@ -0,0 +1,9 @@ + +extern int write_to_coord(int x, int y, int x86_specifier); +extern int clear(int x86_specifier); + +void c_entry() { + write_to_coord(1,1, (0xf0 << 8) | 'm'); + write_to_coord(1,5, (0xf0 << 8) | 'j'); + write_to_coord(2,5, (0xf0 << 8) | 'j'); +} diff --git a/keyboard.asm b/keyboard.asm index deb101e..fd74a74 100644 --- a/keyboard.asm +++ b/keyboard.asm @@ -1,14 +1,17 @@ %include "multiboot_header.asm" %include "x86_vram.asm" +extern c_entry section .bss stack resb 0x1000 section .data +[bits 32] section .text + global boot: mov esp, stack + 0x1000 xor ebp, ebp @@ -18,6 +21,7 @@ main: push word BG.BLACK | ' ' call clear add esp, 2 + call c_entry halt: hlt diff --git a/x86_vram_functions.asm b/x86_vram_functions.asm index fdd559a..4f29021 100644 --- a/x86_vram_functions.asm +++ b/x86_vram_functions.asm @@ -3,6 +3,7 @@ ; first argument is row, 1 byte ; second argument is column, 1 byte ; third argument is cell, 2 bytes +global write_to_coord write_to_coord: push ebp mov ebp, esp @@ -30,6 +31,7 @@ write_to_coord: ; takes character/attribute in edi ; writes it to all cells on screen +global clear clear: push ebp mov ebp, esp