From e1230ce493aaabc939563957f1af9aad8258685e Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Wed, 14 Jun 2023 20:39:30 +0300 Subject: [PATCH 1/5] Qemu serial stdout --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a7b0e50..6f106c0 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,11 @@ kernel-i386.elf: kernel.o start32.o vga.o tcc -m32 -nostdlib -Wl,-Ttext,0x100000 start32.o kernel.o vga.o -o kernel-i386.elf qemu-multiboot: kernel-i386.elf - qemu-system-i386 -kernel kernel-i386.elf -serial file:CON + qemu-system-i386 -kernel kernel-i386.elf -serial stdio qemu-image: kernel-i386.elf mount cp kernel-i386.elf mnt/ sync - qemu-system-i386 koalemos.img + qemu-system-i386 koalemos.img -serial stdio mount: koalemos.img mnt/ @if ! mountpoint -q "mnt/"; then \ From 65471819593b3176bb0b4a83171dc3178d504861 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Wed, 14 Jun 2023 20:40:50 +0300 Subject: [PATCH 2/5] C Header guards --- vga.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vga.h b/vga.h index 60c0666..b2aa979 100644 --- a/vga.h +++ b/vga.h @@ -1,3 +1,5 @@ +#ifndef HEADER_VGA +#define HEADER_VGA enum vga_color { VGA_COLOR_BLACK = 0, @@ -18,3 +20,5 @@ void vga_write(const char* text); void vga_write_color( const char* text, enum vga_color fg, enum vga_color bg); void vga_write_line(const char* text); void vga_write_line_color( const char* text, enum vga_color fg, enum vga_color bg); + +#endif From 94657a7b471fe56e9cb29820aadf5686b025a942 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Wed, 14 Jun 2023 20:49:23 +0300 Subject: [PATCH 3/5] OUTB implementation --- kernel.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel.c b/kernel.c index f917e01..6fc31c9 100644 --- a/kernel.c +++ b/kernel.c @@ -1,11 +1,9 @@ #include "multiboot.h" #include "vga.h" -/* -static inline void outb(unsigned int port, unsigned char val) { +static inline void outb(unsigned short port, unsigned char val) { asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory"); } -*/ char* itoa(int value, int base) { char* result; From f45698bb00e819be76dbe9f2d5fecc4d27e7c4d4 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Wed, 14 Jun 2023 20:49:47 +0300 Subject: [PATCH 4/5] Cursor disabling moced from assembly to C --- kernel.c | 5 ++--- start32.asm | 20 -------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/kernel.c b/kernel.c index 6fc31c9..e03eb37 100644 --- a/kernel.c +++ b/kernel.c @@ -34,9 +34,8 @@ char* itoa(int value, int base) { void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) { // Cursor disabling - // TODO: outb function - //outb(0x3D4, 0x0A); - //outb(0x3D5, 0x20); + outb(0x3D4, 0x0A); + outb(0x3D5, 0x20); //cls(); vga_init(VGA_COLOR_BLACK, VGA_COLOR_GRAY); diff --git a/start32.asm b/start32.asm index 4d80e11..29fb6c4 100644 --- a/start32.asm +++ b/start32.asm @@ -32,30 +32,10 @@ section '.text' executable public _start extrn kmain -disable_cursor: - pushf - push eax - push edx - - mov dx, 0x3D4 - mov al, 0xA ; low cursor shape register - out dx, al - - inc dx - mov al, 0x20 ; bits 6-7 unused, bit 5 disables the cursor, bits 0-4 control the cursor shape - out dx, al - - pop edx - pop eax - popf - ret - _start: ; Setup stack mov esp, stack_top - call disable_cursor - ; Call the main kernel function. push ebx push eax From e9fd2e98bf2cfec54c6767f78c6fb57114d3cbbd Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Wed, 14 Jun 2023 20:50:21 +0300 Subject: [PATCH 5/5] Removing an oopsie --- kernel.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel.c b/kernel.c index e03eb37..7f0abd6 100644 --- a/kernel.c +++ b/kernel.c @@ -75,5 +75,4 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) { } vga_write_line("\nExecution finished, halting..."); - *(unsigned char *)0xb8000 = '!'; }