diff --git a/Qcommon.c b/Qcommon.c index 3689294..4965d6b 100644 --- a/Qcommon.c +++ b/Qcommon.c @@ -1,4 +1,8 @@ -#include +//#include + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; #define COM1_BASE_PORT 0x3F8 @@ -35,15 +39,14 @@ void serial_write(const char *msg) } } -extern void writechar(); +extern void bios_write(const char *msg, unsigned length); void main() { - serial_write("init\r\n"); - writechar(); - serial_write("foo\r\n"); + bios_write("init\r\n", 6); + bios_write("karlos\r\n", 8); for (;;) { - //__asm__ ("hlt" :); + __asm__ ("hlt" :); } } diff --git a/Rnbp.S b/Rnbp.S index b534e48..418bc83 100644 --- a/Rnbp.S +++ b/Rnbp.S @@ -71,15 +71,6 @@ _start: cli mov %ss, %ax mov %ax, real_ss - push $msg_start - call dbgmsg - add $2, %sp - - xor %bx, %bx - mov $0x0E, %ah - mov $'B', %al - int $0x10 - // initialize our own BSS section mov $_bss_start, %di mov $_bss_end, %cx @@ -133,22 +124,38 @@ dbgmsg: push %bp pop %bp ret - .global writechar + .global bios_write .code32 -writechar: push %ebp +bios_write: push %ebp mov %esp, %ebp push %ebx + mov 8+0(%ebp), %edx + mov 8+4(%ebp), %ecx + PROT16 .code16 REAL +.bwloop: test %ecx, %ecx + jz .bwreturn + xor %bx, %bx mov $0x0E, %ah - mov $'A', %al - int $0x10 + mov (%edx), %al - PROT + push %ecx + push %edx + int $0x10 + pop %edx + pop %ecx + + add $1, %edx + sub $1, %ecx + + jmp .bwloop + +.bwreturn: PROT PROT32 .code32 @@ -176,7 +183,8 @@ GDT: // entry 0: null descriptor // TODO: 32-bit TSS .set GDT_SIZE, . - GDT GDT_PTR: .word GDT_SIZE - 1 - .quad GDT + .word GDT + .word 0, 0, 0 msg_start: .asciz "Netboot via fernlader v2 ...\r\n" msg_a20: .asciz " * Enabling A20 Gate\r\n" diff --git a/config.mk b/config.mk index fbe74d1..7c43e8c 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,7 @@ -CC = cc +#CC = /usr/local/x86_64-karlos-toolchain/bin/x86_64-karlos-gcc +#LD = /usr/local/x86_64-karlos-toolchain/bin/x86_64-karlos-ld +CC = gcc LD = ld -CFLAGS = -no-pie -fno-pic -fno-stack-protector -LDFLAGS = -Tfernlader.ld +CFLAGS = -no-pie -fno-pic -fno-stack-protector -nostdinc -m32 +LDFLAGS = -Tfernlader.ld -m elf_i386