gerarparra0 wrote:
I am trying to setup the example kernel provided by @bzt on the official documentation page but the kernel does not print anything to the screen.
Can you see the cross-hair? Or the R/G/B boxes? Is it only the string printing that's not working, or is it all blank? (All blank => framebuffer initialization error probably; cross-hair ok, but printing isn't => could be font linking issue, linker script misconfiguration and also many other things in your kernel.)
In lack of a framebuffer, the serial console is also initialized and configured to 115200 baud, 8 data bits, 1 stop bit, no parity, so you can print to the vm's console (for qemu, use "-serial stdio" command line argument, and you should see the text you send in your guest OS on the terminal in which you started qemu). With bochs, you can also use the "e9 hack" (when you enable that, then you can write characters to the bochs' terminal simply by using "out al, 0xe9").
This is what I use:
Code:
unsigned char chrtoprint = 'A';
asm volatile(
"xorl %%ebx, %%ebx; movb %0, %%bl;"
#ifdef BOCHS
// bochs e9 port hack
"movb %%bl, %%al;outb %%al, $0xe9;"
#endif
// print character on serial
"movl $10000,%%ecx;movw $0x3fd,%%dx;"
// transmit buffer ready?
"1:inb %%dx, %%al;"
"cmpb $0xff,%%al;je 2f;"
"dec %%ecx;jz 2f;"
"andb $0x20,%%al;jz 1b;"
// send out character
"subb $5,%%dl;movb %%bl, %%al;outb %%al, %%dx;2:"
::"r"(chrtoprint));
NOTE: On UEFI, the serial console is NOT initialized by default, you have to go to your UEFI manager's configuration and enable console (ConIn/ConOut) on serial feature manually. After that it will work in your kernel too. (You could also initialize the serial yourself,
inline assembly example).
gerarparra0 wrote:
I've been testing it by adding code by parts to see what is not working but seems like the framebuffer is not responding.
Which version are you using? And which boot mechanism (RPi/x86 BIOS/x86 UEFI/Multiboot/El Torito...etc.)? Did it work before you added your code parts?
gerarparra0 wrote:
Excuse my poor makefile skillz, I'm pretty new at this
In the
images folder you can find an example makefile to generate bootable disk images (along with a very simple mkimg.c image creator tool). First you should test your vm configuration with the sample disk images I provided.
I suggest to follow these steps to narrow down where the problem might be located:
1. run a provided image in your vm - this will test your execution environment. If this isn't okay, then check your vm's configuration.
2. try to create an image of your own with the example mykernel - this will test your build environment.
3. replace the example kernel and makefile with your own - if the error happens when you do so, then the problem is with your source.
Go to each step only when the previous steps are ok. If you can tell me at which step your problem appears, I'll be able to help more.
Cheers,
bzt