OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 9:06 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Text output to screen AFTER ExitBootServices()
PostPosted: Mon Jan 29, 2018 4:22 am 
Offline

Joined: Wed Sep 21, 2016 9:39 am
Posts: 24
I have scoured the internet for days looking for an example, (preferably in asm but I'll take C), of an OS outputting text to the screen AFTER ExitBootServices() has been called after a UEFI boot. Surely someone here has achieved this? In a couple of years time Intel will cease supporting BIOS and new computers will have no choice but to use a UEFI OS. So it seems like a good idea to start a new OS with UEFI in mind. But I am stuck on how to write to screen after saying goodbye to the UEFI loader.

Is there a way to set the video while in UEFI mode so that a screen buffer address is available after the OS starts? Has anyone created a UEFI booted OS up the point where it can write to the screen (but after exiting the UEFI)?


Top
 Profile  
 
 Post subject: Re: Text output to screen AFTER ExitBootServices()
PostPosted: Mon Jan 29, 2018 5:01 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

poby wrote:
I have scoured the internet for days looking for an example, (preferably in asm but I'll take C), of an OS outputting text to the screen AFTER ExitBootServices() has been called after a UEFI boot. Surely someone here has achieved this? In a couple of years time Intel will cease supporting BIOS and new computers will have no choice but to use a UEFI OS. So it seems like a good idea to start a new OS with UEFI in mind. But I am stuck on how to write to screen after saying goodbye to the UEFI loader.

Is there a way to set the video while in UEFI mode so that a screen buffer address is available after the OS starts? Has anyone created a UEFI booted OS up the point where it can write to the screen (but after exiting the UEFI)?


The steps are:
  • Prepare as much as you can (because if something goes wrong in the next steps you probably won't be able to tell the user what happened)
  • Use UEFI's GOP/Graphics Output Protocol or UEFI's UGA/Universal Graphics Adapter Protocol (or BIOS's VBE) to setup a graphical video mode and get the details (physical address, pixel format, bytes per scanline) of the frame buffer.
  • Get some sort of font data from somewhere and implement a suitable font renderer to convert characters/strings into bitmaps. This can be very simple (e.g. 1-bit per pixel, fixed size 8*16 fonts for ASCII only) or very fancy (e.g. "8-bit alpha" per pixel with anti-aliasing, variable sized/scalable font with full Unicode support).
  • Implement some sort of "layout manager", which can be very simple (e.g. just line wrap and nothing else) or very complex (e.g. markup or escape codes to control things like colour, left/right justification, font style, ...).
  • Ask "layout manager" to create strings that can be fed into the font renderer to get bitmaps; then blit the bitmaps to the framebuffer

For "everything as simple as possible" (equivalent to ugly old text mode) this can be implemented in as little as 2 days.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Text output to screen AFTER ExitBootServices()
PostPosted: Mon Jan 29, 2018 5:45 am 
Offline

Joined: Wed Sep 21, 2016 9:39 am
Posts: 24
I don't mind how complicated and time consuming it might be to implement, but I'm having trouble finding the exact information on how to do it. I hate reading specs as there's usually like 700 pages of stuff I don't wanna know but I need to read to find the 3 or 4 pages of stuff I want. That's why I was hoping someone might have coded this already and can give an example actual code on how to set up a graphical video mode with GOP.


Top
 Profile  
 
 Post subject: Re: Text output to screen AFTER ExitBootServices()
PostPosted: Mon Jan 29, 2018 6:49 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

poby wrote:
I don't mind how complicated and time consuming it might be to implement, but I'm having trouble finding the exact information on how to do it. I hate reading specs as there's usually like 700 pages of stuff I don't wanna know but I need to read to find the 3 or 4 pages of stuff I want.


The entire description of GOP (exact information on everything) is only 15 pages (and is trivial to find in the UEFI spec).

Note that if you did have someone else's code it's likely that you'll need to read the details in the UEFI spec just to understand exactly what their code actually does (and why their code is bad and/or buggy and/or incomplete and/or not what you want for your OS).


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Text output to screen AFTER ExitBootServices()
PostPosted: Mon Jan 29, 2018 7:16 am 
Offline

Joined: Wed Sep 21, 2016 9:39 am
Posts: 24
Yes I'm reading and rereading the GOP spec now. I also found an example of getting the graphics information from the UEFI. It's in chinese but the code is in C and at least it's a start. Having examples helps a lot in understanding the spec.

I prefer to code in assembly which makes it even more of a challenge so I'm thinking it will take me more like 2 months than 2 days but heck I got time. Will post a working example when I'm done.


Top
 Profile  
 
 Post subject: Re: Text output to screen AFTER ExitBootServices()
PostPosted: Mon Jan 29, 2018 6:08 pm 
Offline

Joined: Wed Sep 21, 2016 9:39 am
Posts: 24
After googling I found there is an OSDEV tutorial containing almost everything I need!

https://wiki.osdev.org/Uefi.inc

...and it's even in asm :) This (along with the spec) is exactly what I need to start learning UEFI OS development.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 288 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group