Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I'm trying to build a simple linux hello world kernel that will boot with GRUB2. To this end I have isolated the files linux-5.10.1/arch/x86/boot/header.S linux-5.10.1/arch/x86/boot/main.c and linux-5.10.1/arch/x86/boot/setup.ld as a good starting point. After doing a complete make on the linux kernel source I removed header.o and main.o to see what make would do to remake and link these files. Here's what I got:
I managed to build a bootable linux image that boots with GRUB2. However, when I modify main.c to print a Hello linux world message I just get a blank screen for some reason. The good news is it seems to be booting both in legacy and UEFI mode just no output to screen.
On EFI, it is definitley booting into graphical mode. On BIOS, it may not, but your linux bootstrap code may be putting it in graphical mode. Personally, I would recommend following the Bare Bones tutorial on the Wiki, and using Multiboot 1, then changing to Multiboot 2 later.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
I thought I found the code that sets graphical mode. There is a function set_mode in video-mode.c which is called by set_video in video.c which is called by main in main.c. I commented out the call and I still get a blank screen.
I then commented out all the function calls in main (just in case) and put a while loop which prints out my message continuously. My new main function looks like this: