Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
uint8_t* vmem = 0xB8000;
vmem[0] = (uint8_t)'?';
vmem[1] = 0x07;
/*
* pros:
* more control
* higher level accessibility (no assembly)
* cons:
* manual management of cursor position and scrolling
* makes assumptions about memory
*/
The MMIO method requires more overhead in terms of code, e.g. cursor position and scrolling.
The BIOS method would require calling into assembly code or inline assembly.
Both methods are dependent on the x86{,-64} architecture.
Last edited by hwg on Tue Jul 12, 2016 8:37 am, edited 1 time in total.
Of course they depend on x86, because 0xB8000 is a VGA memory-mapped location, and the VGA was meant for PCs which use x86 CPUs.
The INT 0x10 functions are generally slow, and should be avoided as long as you're not in real mode. Accessing video memory directly is more code, but can be used in 32 and 64-bit modes.
BTW, accessing the video memory makes no assumptions about the memory, because you can configure the VGA planes and which memory is mapped where. But I think it's safe to say that 99.9% of color text modes map the memory at 0xB8000.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
hwg wrote:Ah, I thought as much. Once you have a video driver talking directly to the GPU, both of these methods become moot anyway, right?
GPU? I'm pretty sure no one needs GPU for text mode. The used memory is so little anyway that the GPU's acceleration features are useless, that is if any GPU even supports text mode acceleration.
EDIT: If you mean by GPU, graphics card, when you communicate directly with the VGA you can still use INT 0x10 and memory address 0xB8000.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
As written, there's a much simpler difference: the first piece works exclusively in real mode, the second works anywhere but real mode.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
i did very basic 3-bit video driver using the MMIO it was slow as hell. There are still some bugs.
Int 10h might be easier to use but MMIO should give you more control.
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
hwg wrote:Should I prefer the BIOS call or the MMIO method?
Later during boot you shouldn't depend anything the firmware provides, so that you can easily add support for UEFI (or coreboot, OpenFirmware, and/or something like "kexec()" or "OS in embedded system ROM" or whatever else) by changing your boot loader and not changing any other part of the OS.
Early during boot you shouldn't make too many assumptions, and should use the firmware's "console output" (e.g. int 0x10 if firmware is BIOS) in case it's been redirected over network or something strange; and so that you can reliable display error messages if something goes wrong (e.g. "ERROR: failed to obtain a frame buffer").
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.
not sure how you would do it not in assembly but if you mov [ds:si], al it works in real mode. ie: assign ds b800 si your offset up to 3999 and al your char or color...