0

I was writing an Operating System and testing it on an emulator in my primary computer (HP Z420), i tested it sometimes on that computer but i was always in a boot/shutdown loop that taked a long time. So i had an old pc (HP 620) Which has an old version of UEFI and nothing gets displayed when i run the O.S on it. So i founded that it has not GOP Support and Frame buffer address is always 0. I switched from gnu-efi to edk2 to give support to U.G.A, i succeeded and graphics worked, however when i exit boot services and call UgaProtocol->Blt from the kernel, the system triple faults but when i call it without exiting boot services, everything works fine.

  • I know that these functions are Boot Services and may use Boot Services so that maybe the cause of the triple fault

  • So how can i implement a permanent communication with U.G.A After exiting boot services (in G.O.P, we usually write to a frame buffer)

  • If i do not exit boot services, changing the gdt or the idt or any other thing causes a debug exception (Result on qemu & VBox) and halts on Real Hardware.

git_lk1
  • 76
  • 1
  • 8
  • Have you tried to use the framebuffer directly, without calling Blt(). – MiSimon Apr 09 '22 at 06:01
  • 2
    UEFI has "boot services" (which can't be used after you exit boot services) and "run-time services" (which can be used any time, but aren't useful for much). All of UGA and all of GOP are "boot services" (including UGA's "blit" function); and they aren't meant to work after you exit boot services, and you shouldn't try to use them after you exit boot services. You can use UGA or GOP to set up a framebuffer before exiting boot services and then continue using the framebuffer (with your own blit function) after you exit boot services. – Brendan Apr 09 '22 at 07:55
  • I used the frame buffer directly on G.O.P and it works after exitting boot services, but U.G.A does not provide a frame buffer – git_lk1 Apr 09 '22 at 10:18
  • So how can I setup a frame buffer for U.G.A. – git_lk1 Apr 09 '22 at 10:19
  • @Brendan How can i setup a frame buffer in UGA – git_lk1 Apr 10 '22 at 15:59
  • @git_lk1: Use the UGA protocol's GUID to ask the firmware for instances of the protocol (note: if you have 3 video cards then there can be 3 instances - you'll have to figure out whether you want one and which one, or all of them). This will get you a structure containing function pointers (for getting video mode info, setting a video mode, and blitting). As far as I know; there's no way to ask it which modes it supports (which is why GOP is better), so you just try to set video modes until something you ask for works. Once it works you can get the mode's (more detailed) information. – Brendan Apr 10 '22 at 19:04
  • @git_lk1: For complete details, you'll need to find an old copy of Intel's EFI 1.0 spec (from 2002, before the Unified EFI Forum standards body was created). UGA was replaced by GOP, and later versions of the UEFI spec don't mention UGA. – Brendan Apr 10 '22 at 19:12
  • How can I get usable protocol instances that work after exit boot services @Brendan . Thanks – git_lk1 Apr 12 '22 at 20:49
  • @git_lk1: You can't get usable protocol instances after you exit boot services. After you exit boot services all of that is removed from memory (freed); and you can only use run-time services, which is a several functions to tell UEFI about your virtual memory layout, get/set UEFI variables, get/set the time, and almost nothing else. An OS is supposed to have its own device drivers for things like video, and UEFI is mostly only intended to be used before an OS starts its own drivers (and before a boot loader exits boot services). – Brendan Apr 12 '22 at 22:24
  • @git_lk1: Mostly; you want to set up a frame buffer (using UGA or GOP on UEFI, or VBE on BIOS) in the boot loader; then exit boot services (for UEFI), then let the boot loader give the OS/kernel details for the frame buffer (where it is, what the pixel format is, resolution, bytes between lines) so that OS/kernel can continue using frame buffer (without caring if it came from UGA or GOP or VBE), and then (later, if possible) the OS would load a video driver that takes over (and OS "limps" with just frame buffer if it doesn't have its own video driver). – Brendan Apr 12 '22 at 22:34
  • Yes this is the problem, first im not a newbie and i started creating my OS a year ago, U.G.A Does not provide a frame buffer, i have a driver for VMWARE SVGA But the way to access the framebuffer is not the same on every GPU, for ex. my old pc has an "Intel express mobile 45 GPU", I think the gpu does not support GOP because the computer supports it but Gives 0 on frame buffer address & size. UEFI Version is 2.0. I'm trying to make the bootloader does not exit boot services on UGA until the kernel finds a GPU Driver and then exit it. But i will not be Able to Setup a GDT or an IDT. – git_lk1 Apr 13 '22 at 10:39
  • typedef struct UGA_DRAW_PROTOCOL{ GetVideoMode, SetVideoMode, Blt); No frame buffer address. – git_lk1 Apr 13 '22 at 10:42
  • I think I'll just display a message that the efi version is very old and the firmware or gpu does not support GOP. "Please consider booting in Legacy BIOS Mode". @Brendan – git_lk1 Apr 14 '22 at 22:14
  • @git_lk1: Ah - I see the problem now :). It'd be in `EFI_UGA_IO_PROTOCOL` (not `EFI_UGA_DRAW_PROTOCOL`, which is a simplified wrapper). Unfortunately most of `EFI_UGA_IO_PROTOCOL` isn't adequately described in the EFI 1.1 spec (it just says "`More information on the advanced capabilities of an EFI 1.10 UGA ROM can be found at www.microsoft.com/hwdev/uga.`") and the HTML link is a dead link. Not supporting UGA (and only supporting legacy/VBE and GOP) is a good alternative. – Brendan Apr 15 '22 at 00:31
  • Thanks, I appreciate your help @Brendan ! – git_lk1 Apr 15 '22 at 17:53

0 Answers0