Code: Select all
// main.c -- Defines the C-code kernel entry point, calls initialisation routines.
// Made for JamesM's tutorials <www.jamesmolloy.co.uk>
#include "monitor.h"
#include "multiboot.h"
u8int cursor_x1 = 1;
void temp_write(u16int *videoOut, u32int n) {
s32int tmp;
char noZeroes = 1;
int i;
for (i = 28; i > 0; i -= 4)
{
tmp = (n >> i) & 0xF;
if (!tmp && noZeroes)
{
continue;
}
if (tmp >= 0xA)
{
noZeroes = 0;
*videoOut++ = (tmp-0xA+'a') + (0x1e<<8);
}
else
{
noZeroes = 0;
*videoOut++ = (tmp+'0') + (0x1e<<8);
}
}
tmp = n & 0xF;
if (tmp >= 0xA)
{
*videoOut++ = (tmp-0xA+'a') + (0x1e<<8);
}
else
{
*videoOut++ = (tmp+'0') + (0x1e<<8);
}
}
int main(struct multiboot_info *mboot_ptr)
{
temp_write((u16int *)0xB8000+400, cursor_x1++);
temp_write((u16int *)0xB8000+420, cursor_x1++);
return 0;
}
I'm compiling with Eclipse and it uses...
gcc -I/usr/src/linux-headers-3.2.0-33 -O0 -g3 -Wall -c -fmessage-length=0 -ffreestanding -m64 -nostdlib -mno-red-zone -Map=out.map -MMD -MP -MF"srcOriginal/main.d" -MT"srcOriginal/main.d" -o "srcOriginal/main.o" "../srcOriginal/
The link script is
Code: Select all
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Thanks!