qemu vga prrinting character problem in different .o file
Posted: Mon Apr 21, 2014 4:37 am
HI! All
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 from kmain it doesn't work sometimes when there is some function call inside scren_putcor when there is any assignment operation in some specific block . I couldn't figure out exactly what causes it not to work.
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
here If I just comment screen_cursor_update which is an empty function. it works in qemu and displays the character and stays there. but If I uncomment it displays the character once and then comes back
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
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