Here is the code if you didn't understand what I'm saying (These are only the relevant parts of the files):
kmain.c:
Code: Select all
#include <../include/kernel/screen.h>
void kmain(void* mbd, unsigned int magic)
{
cls();
....
}
Code: Select all
#ifndef SCREEN_H
#define SCREEN_H
#include <../include/kernel/common.h>
extern void cls();
#endif
Code: Select all
#include <../include/kernel/screen.h>
uint16_t *video = (uint16_t *) 0xB8000;
uint8_t xpos = 0;
uint8_t ypos = 0;
void cls()
{
uint8_t aByte = (0 << 4) | (15 & 0x0F);
uint16_t blank = 0x20 | (aByte << 8);
uint32_t i;
for (i = 0; i < 80*25; i++)
{
video[i] = blank;
}
xpos = 0;
ypos = 0;
}
Code: Select all
CSOURCES=kernel.c screen.c
SOURCES=loader.o kernel.o screen.o
CFLAGS=-nostdlib -nostdinc -fno-builtin -I../include/
LDFLAGS=-Tlinker.ld
all:
nasm -f elf -o loader.o loader.s
gcc -o kernel.o -c kernel.c $(CFLAGS)
gcc -o screen.o -c screen.c $(CFLAGS)
i586-elf-ld $(LDFLAGS) -o kernel.bin $(SOURCES)
cat kpad kernel.bin > floppy.img
linker.ld
Code: Select all
ENTRY (loader)
SECTIONS{
. = 0x00100000;
.text :{
*(.text)
}
.rodata ALIGN (0x1000) : {
*(.rodata)
}
.data ALIGN (0x1000) : {
*(.data)
}
.bss : {
sbss = .;
*(COMMON)
*(.bss)
ebss = .;
}
}