0

I am new to OSDev, and I am currently trying to write my OS from bare bones, i.e. using GRUP as my bootloader, on x86 arch. I want my OS to support both BIOS and UEFI boot.

I am currently trying to write my own graphical interface. And I am kind of confused on how to do it so it would work on all platforms.

I observed that on UEFI 2.x I must use GOP, while on UEFI 1.x I should use UGA and on BIOS I must use either VESA or VGA.

Does it means that in order to implement a cross-firmware OS I would have to support all of them? And only choose one from the supported interfaces? How can I even tell from my OS if I was booted by UEFI? And what version of UEFI?

Should I just abandon the compatibility goal and simply pick one setting and implement my OS for that one?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
user6035109
  • 323
  • 2
  • 7
  • You might want to read [Operating Systems Design and Implementation](https://www.amazon.com/TANENBAUM-ANDREW-Operating-Implementation-12-2-2005/dp/B00HTJRO04) by Andrew Tannenbaum, which describes the Minix 3 microkernel OS. Best of luck. – Bob Jarvis - Слава Україні Dec 04 '21 at 18:05
  • 1
    The protocol that the boot loader uses to display test and graphics to the screen is only relevant to that boot loader and firmware. If you use UEFI and it uses GOP, as soon as that boot loader gives control to your code, just after the ExitBootServices() call, it is completely up to you how you access the video screen. However, at this point, the UEFI GOP is no longer accessible, you must write your own screen services. Most of the time you get the Linear Frame Buffer and screen size(s) from the firmware before you exit. Then you write directly to this frame buffer. – fysnet Dec 04 '21 at 18:49
  • @fysnet So in conclusion it's up to the bootloader to resolve the firmware settings and give me a unified interface to some buffer which would manage everything. Thank you very much!! – user6035109 Dec 04 '21 at 18:56
  • Close. Depending on the boot loader you use, GRUB for example will allow you to set a screen mode, then give you information about that mode that you can retrieve from your second stage. However, there is no "managing buffer" as you say. It is 100% your responsibility to take that information and create a working video driver. If you use the Linear Frame Buffer method, you simply write pixels to this memory address and the hardware will display it to the screen. You do need to know the size/type of these pixels and the bytes_per_scanline value along with other values. – fysnet Dec 04 '21 at 19:37
  • You might also read Andrew Tanenbaum's paper [Lessons Learned from 30 Years of MINIX](https://www.cs.vu.nl/~ast/Publications/Papers/cacm-2016.pdf). – Bob Jarvis - Слава Україні Dec 04 '21 at 19:41

0 Answers0