OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 3:40 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How do low level thigns without BIOS?
PostPosted: Sat Feb 01, 2020 2:13 pm 
Offline
User avatar

Joined: Sun Jan 05, 2020 5:51 pm
Posts: 15
Location: 0.0.0.0
Hello people! I'm new here.

I don't know if this question was answered before.

How can I directly access the hardware without any help from the BIOS and be able to do the things it does (print a character, read keyboard entries, restart the computer ...).

like this:
https://raw.githubusercontent.com/ciros ... lo_world.S

I never developed a driver, but I believe it is more or that way (correct me if I'm wrong).

Do you know any method? Any material, reference will be welcome!

_________________
Regards,
Growlnx.


Last edited by growlnx on Mon Feb 03, 2020 6:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How do low level thigns without BIOS?
PostPosted: Sun Feb 02, 2020 12:20 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1590
growlnx wrote:
I don't know if this question was answered before.
You would know if you used the search function.
growlnx wrote:
How can I directly access the hardware without any help from the BIOS and be able to do the things it does (print a character, read keyboard entries, restart the computer ...).
Each of those requires knowledge of their respective subsystems.

Printing a character: If you are working in VGA text mode, then there will be a buffer of 80x25 characters starting at linear address 0xb8000. Each character consists of two bytes: A data byte (containing the character) and an attribute byte (containing the text color). You print characters by writing them there. You have to keep track of the cursor yourself, and if you come across control characters, you have to act on them yourself. You will also have to scroll the screen yourself.

These days I would caution against just assuming VGA text mode. Easier to let GRUB handle it. It will then tell you the base address.

Read keyboard entries: Depends. PS/2 or USB? For PS/2, all you have to do is await a keyboard interrupt and then read the keyboard port. Provided the BIOS set everything up for you. We have a wiki article about initializing the keyboard controller, I'd ask that you refer to it. USB? Well, that is going to be complicated. Because for that you will first need a PCI driver, then a host controller driver for the host controller that you have, then a USB hub driver, and then you can deal with a USB keyboard driver.

Restarting the computer: In most cases, the easiest is to just tripple-fault the computer. Unfortunately, that is not guaranteed to reset everything. For more comprehensive restart support, you will have to look into APM or ACPI.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: How do low level thigns without BIOS?
PostPosted: Mon Feb 03, 2020 10:49 am 
Offline
User avatar

Joined: Sun Jan 05, 2020 5:51 pm
Posts: 15
Location: 0.0.0.0
nullplan wrote:
Printing a character: If you are working in VGA text mode, then there will be a buffer of 80x25 characters starting at linear address 0xb8000. Each character consists of two bytes: A data byte (containing the character) and an attribute byte (containing the text color). You print characters by writing them there. You have to keep track of the cursor yourself, and if you come across control characters, you have to act on them yourself. You will also have to scroll the screen yourself.


Is there anything watching that memory range and sending it to VGA output?

nullplan wrote:
These days I would caution against just assuming VGA text mode. Easier to let GRUB handle it. It will then tell you the base address.


Can the VGA text mode buffer change the base address?

_________________
Regards,
Growlnx.


Top
 Profile  
 
 Post subject: Re: How do low level thigns without BIOS?
PostPosted: Mon Feb 03, 2020 4:42 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
growlnx wrote:
Is there anything watching that memory range and sending it to VGA output?
Yes, that's the VGA hardware, the video card.
growlnx wrote:
Can the VGA text mode buffer change the base address?
Of course. You can change it too (within a range), see VGA registers. Furthermore, you can also change the actual VGA memory mapped at those addresses, search for "SVGA bank switching" (but that's manufacturer specific, banking was never standardized). A little bit more info here.

TBH, you won't find any VGA on modern machines. Modern video cards MAY provide backward compatibility in some cases, but that compatibility layer is fading pretty quickly. Most higher resolution modes does not support VGA registers about 20 years now. Virtual machines are likely to support it for its simplicity (and keeping backward compatibility), but on real hardware it is already obsoleted. UEFI machines without CSM won't emulate VGA text mode at all.

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: How do low level thigns without BIOS?
PostPosted: Tue Feb 04, 2020 4:14 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
> Furthermore, you can also change the actual VGA memory mapped at those addresses, search for "SVGA bank switching" (but that's manufacturer specific, banking was never standardized).

It was standardized - int 0x10, ah=0x4f02 - in the VESA display extensions. That worked pretty universally until about 2005...


Top
 Profile  
 
 Post subject: Re: How do low level thigns without BIOS?
PostPosted: Tue Feb 04, 2020 6:08 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
Candy wrote:
It was standardized - int 0x10, ah=0x4f02 - in the VESA display extensions. That worked pretty universally until about 2005...
The VGA registers were never standardized (unlike the VGA CRTC registers for example). The OP asked about "without BIOS", and just for the records nobody used that bank switching VBE routine either because many cards' ROM haven't implemented it, and if it was implemented then it was terribly slow anyway. Software from that era used direct port writes, first-hand experience. For the Cirrus cards for example the VGA registers were port 0x9 - port 0xB. For other manufacturer's port assignments, see XFree86's source, directory xc/programs/Xserver/hw/xfree86/vga*/drivers/.

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: How do low level thigns without BIOS?
PostPosted: Thu Feb 06, 2020 1:34 pm 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
Candy wrote:

It was standardized - int 0x10, ah=0x4f02 - in the VESA display extensions. That worked pretty universally until about 2005...


Minor correction: ax, not ah.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 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