Compare commits

...

5 commits

4 changed files with 9 additions and 29 deletions

View file

@ -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 tcc -m32 -nostdlib -Wl,-Ttext,0x100000 start32.o kernel.o vga.o -o kernel-i386.elf
qemu-multiboot: 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 qemu-image: kernel-i386.elf mount
cp kernel-i386.elf mnt/ cp kernel-i386.elf mnt/
sync sync
qemu-system-i386 koalemos.img qemu-system-i386 koalemos.img -serial stdio
mount: koalemos.img mnt/ mount: koalemos.img mnt/
@if ! mountpoint -q "mnt/"; then \ @if ! mountpoint -q "mnt/"; then \

View file

@ -1,11 +1,9 @@
#include "multiboot.h" #include "multiboot.h"
#include "vga.h" #include "vga.h"
/* static inline void outb(unsigned short port, unsigned char val) {
static inline void outb(unsigned int port, unsigned char val) {
asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory"); asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
} }
*/
char* itoa(int value, int base) { char* itoa(int value, int base) {
char* result; char* result;
@ -36,9 +34,8 @@ char* itoa(int value, int base) {
void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) { void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
// Cursor disabling // Cursor disabling
// TODO: outb function outb(0x3D4, 0x0A);
//outb(0x3D4, 0x0A); outb(0x3D5, 0x20);
//outb(0x3D5, 0x20);
//cls(); //cls();
vga_init(VGA_COLOR_BLACK, VGA_COLOR_GRAY); vga_init(VGA_COLOR_BLACK, VGA_COLOR_GRAY);
@ -78,5 +75,4 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
} }
vga_write_line("\nExecution finished, halting..."); vga_write_line("\nExecution finished, halting...");
*(unsigned char *)0xb8000 = '!';
} }

View file

@ -32,30 +32,10 @@ section '.text' executable
public _start public _start
extrn kmain 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: _start:
; Setup stack ; Setup stack
mov esp, stack_top mov esp, stack_top
call disable_cursor
; Call the main kernel function. ; Call the main kernel function.
push ebx push ebx
push eax push eax

4
vga.h
View file

@ -1,3 +1,5 @@
#ifndef HEADER_VGA
#define HEADER_VGA
enum vga_color { enum vga_color {
VGA_COLOR_BLACK = 0, 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_color( const char* text, enum vga_color fg, enum vga_color bg);
void vga_write_line(const char* text); void vga_write_line(const char* text);
void vga_write_line_color( const char* text, enum vga_color fg, enum vga_color bg); void vga_write_line_color( const char* text, enum vga_color fg, enum vga_color bg);
#endif