0

I'm recently learning to write an operating system and I know that I can use the in/out instructions to manipulate the video memory to output content on the screen, but there are integrated and discrete video cards on the computer, and I want to know which video card's memory is being read and written by 0xb8000

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
golangboy
  • 29
  • 3
  • 4
    Whichever card is acting as the system's primary graphics card (check your BIOS options) is the one that has a VGA text framebuffer mapped at the physical address, if it's in text mode at all. Modern PCI devices can configure which addresses they "listen" for / respond to. Also note that `0xb8000` is device *memory*, not an IO address. You use normal stores to access it, not `in`/`out`. You'd only use `in` or `out` on VGA control registers at various IO addresses, thus different numbers in a different address-space. (https://wiki.osdev.org/VGA_Hardware) – Peter Cordes Jul 26 '22 at 01:26
  • thanks ,peter !! one last question, is the mapping of the graphics card's memory to 0xb8000 done by the BIOS? – golangboy Jul 26 '22 at 02:11
  • Yes, by the firmware that runs before booting either a UEFI application or setting up a legacy-BIOS 16-bit environment for a legacy MBR. (I think even in a UEFI boot, it would normally have the video hardware in a text mode.) Anyway, in case you were asking if there's a `int xx` BIOS call to change it, no, not the IBM-PC-compatible BIOS calls, or any VESA call. Those are all designed around systems with one VGA card, I think. – Peter Cordes Jul 26 '22 at 02:15

2 Answers2

1

Old computer only had one graphics card.

Modern computers pretend to have only one graphics card, until a real OS loads that can understand having several graphics cards. Since you're asking the question, your OS doesn't understand having several graphics cards, and it'll use the one that is pretending to be the only one.

The BIOS/UEFI sets this up. In your BIOS/UEFI settings you may find an option to control which graphics card is the "primary" or "default" or "boot" graphics card. There might also be an option to turn off the integrated graphics entirely.

user253751
  • 57,427
  • 7
  • 48
  • 90
1

Whichever card is acting as the system's primary graphics card (check your BIOS options) is the one that has a VGA text framebuffer mapped at the physical address, if it's in text mode at all.

The BIOS (or graphics card's own firmware) includes boot code that sets up whatever the hardware to respond as a legacy VGA device, at least for the framebuffer but perhaps emulating other VGA stuff via SMI traps. The BIOS will only do this for one video device, if there are multiple in the system. And doesn't provide a software API for legacy 16-bit code to select a different output.

Modern PCI devices can configure which addresses they "listen" for / respond to.

Also note that 0xb8000 is device memory, not an IO address. You use normal stores to access it, e.g. mov or memory-destination xor. You'd only use in or out on VGA control registers at various IO addresses, thus different numbers in a different address-space. (https://wiki.osdev.org/VGA_Hardware)

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847