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!
How do low level thigns without BIOS?
- growlnx
- Posts: 15
- Joined: Sun Jan 05, 2020 5:51 pm
- Libera.chat IRC: growlnx
- Location: 0.0.0.0
- Contact:
How do low level thigns without BIOS?
Last edited by growlnx on Mon Feb 03, 2020 6:52 am, edited 1 time in total.
Regards,
Growlnx.
Growlnx.
Re: How do low level thigns without BIOS?
You would know if you used the search function.growlnx wrote:I don't know if this question was answered before.
Each of those requires knowledge of their respective subsystems.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 ...).
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!
- growlnx
- Posts: 15
- Joined: Sun Jan 05, 2020 5:51 pm
- Libera.chat IRC: growlnx
- Location: 0.0.0.0
- Contact:
Re: How do low level thigns without BIOS?
Is there anything watching that memory range and sending it to VGA output?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.
Can the VGA text mode buffer change the base address?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.
Regards,
Growlnx.
Growlnx.
Re: How do low level thigns without BIOS?
Yes, that's the VGA hardware, the video card.growlnx wrote:Is there anything watching that memory range and sending it to VGA output?
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.growlnx wrote:Can the VGA text mode buffer change the base address?
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
Re: How do low level thigns without BIOS?
> 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...
It was standardized - int 0x10, ah=0x4f02 - in the VESA display extensions. That worked pretty universally until about 2005...
Re: How do low level thigns without BIOS?
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/.Candy wrote:It was standardized - int 0x10, ah=0x4f02 - in the VESA display extensions. That worked pretty universally until about 2005...
Cheers,
bzt
Re: How do low level thigns without BIOS?
Minor correction: ax, not ah.Candy wrote:
It was standardized - int 0x10, ah=0x4f02 - in the VESA display extensions. That worked pretty universally until about 2005...