flat assembler
Message board for the users of flat assembler.

Index > Main > UEFI Programming

Thread Post new topic Reply to topic

Joined: 15 May 2021
Posts: 1
anaid165 16 May 2021, 07:07
Hello! I'm new to uefi progamming and I don't understand how to use the Graphics Output Protocol in order to draw something on the screen. Can anyone show me a basic example using this protocol? I need to do a project using this and I would really appreciate it if you could give me a hint.
Post 16 May 2021, 07:07
View user's profile Send private message Reply with quote

Joined: 09 Nov 2018
Posts: 77
bzt 09 Jul 2021, 16:16
It's not simple. First, you need an UEFI ABI wrapper. With that, you can call UEFI services. Then you get a handle for the GOP Protocol. Using that handle, you query a list of supported video modes. You pick one, and you use it's "mode code" to call SetMode method of the GOP protocol. After that you'll have a standard framebuffer, same as with VESA.

Here's some code that queries the list of video modes, sorts that and returns info in an array. The array consists of 32 bytes entries, and one looks like this:
;  8 bytes handle
;  8 bytes interface
;  2 bytes horizontal resolution
;  2 bytes vertical resolution
;  2 bytes scanline
;  2 bytes pixelformat
;  8 bytes mode number    
Using that last "mode number" you can set the resolution "vertical" x "horizontal".
To figure out the framebuffer's address and size, get the second field in an entry, then do
mov     rax, qword [gopinterface]
mov     rax, qword [rax + EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
mov     rbx, qword [rax + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferBase]    
which returns it in rbx.

As said, once you got the framebuffer's address, you can forget UEFI, and you can draw on that by simply using mov. Each line contains "scanline" bytes, so to draw in the 3rd row on screen for example, add 3 * scanline to the framebuffer's address.

Post 09 Jul 2021, 16:16
View user's profile Send private message Reply with quote

Joined: 31 Jul 2015
Posts: 24
dunkaist 15 Jul 2021, 20:03
You can take a look at uefi4kos -- a UEFI loader for KolibriOS.
It has both 32-bit and 64-bit versions, and it sets a video mode via GOP before jumping to the kernel.

It also uses a set of UEFI headers which are based on work by bzt.
Post 15 Jul 2021, 20:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.