Call a c function.

This commit is contained in:
Thomas Lovén 2017-11-17 22:58:14 +01:00
parent 0a4b5ebd51
commit ab1a471857
3 changed files with 30 additions and 3 deletions

View File

@ -6,7 +6,7 @@ SRC := $(wildcard **/*.[cS])
OBJ := $(patsubst %, %.o, $(basename $(SRC))) OBJ := $(patsubst %, %.o, $(basename $(SRC)))
CFLAGS ?= -Wall -Wextra -pedantic CFLAGS ?= -Wall -Wextra -pedantic
CFLAGS += -ffreestanding CFLAGS += -ffreestanding -mcmodel=large
CFLAGS += -ggdb -O0 CFLAGS += -ggdb -O0
ASFLAGS += -ggdb ASFLAGS += -ggdb
CPPFLAGS += -I include CPPFLAGS += -I include

View File

@ -65,5 +65,6 @@ _start:
mov rax, 0 mov rax, 0
movabs [BootP4], rax movabs [BootP4], rax
//; Loop infinitely .extern kmain
jmp $ movabs rax, offset kmain
jmp rax

26
src/kernel/boot/kmain.c Normal file
View File

@ -0,0 +1,26 @@
#include <memory.h>
void clear_screen()
{
unsigned char *vidmem = (void *)(0xB8000 + KERNEL_OFFSET);
for(int i=0; i < 80*24*2; i++)
*vidmem++ = 0;
}
void print_string(char *str)
{
unsigned char *vidmem = (void *)(0xB8000 + KERNEL_OFFSET);
while(*str)
{
*vidmem++ = *str++;
*vidmem++ = 0x7;
}
}
void kmain()
{
clear_screen();
print_string("Hello from c, world!");
for(;;);
}