I came from application programming using C/C++ (never coded an OS kernel or bootloader or any such low level work before)
I was following the guide http://www.cs.bham.ac.uk/~exr/lectures/ ... os-dev.pdf
and http://www.osdever.net/bkerndev/Docs/title.htm and osdev.org for sure
The bootloader is working. Though I didn't understad why code and data segment starts fom the same address in GDT
I've a kmain function that is being called after it enters in 32 bit mode. from inside kmain I can print to video memory on 0xb8000 with no issues.
I made another .c for portio(port_byte_in, port_byte_out, port_word_in, port_word_out) and screen(screen_clear, screen_putc ....)
when I call these
Code: Select all
screen_putc
by doesn't work I mean the character is printed in 32 bit protected mode for once and again it goes back to the black screen of qemu. and shows what I've printed in 16 bit mode using BIOS interrupts
Code: Select all
void screen_cursor_update(unsigned char row, unsigned char col){
}
void screen_putc(unsigned char data, unsigned char color){
unsigned char* vmem = global_vga_mem;
if(0x08 == data){
--global_vga_cursor_x;
}else if(0x0d == data){
global_vga_cursor_x = 0;
}else if(0x0a == data){
global_vga_cursor_x = 0;
++global_vga_cursor_y;
}else{
*(vmem++) = data;
*(vmem++) = color;
++global_vga_cursor_x;
if(global_vga_cursor_x >= MAX_COLS){
++global_vga_cursor_y;
}
}
screen_cursor_update(global_vga_cursor_x, global_vga_cursor_y);
}
UPDATE
But If I move these functions to the same object file. e.g. If I just copy the contents of screen.c in kernel.c above kmain it works perfectly