SVGA Bios call 0x10 in PIC and APIC

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.
User avatar
iman
Member
Member
Posts: 84
Joined: Wed Feb 06, 2019 10:41 am
Libera.chat IRC: ImAn

Re: SVGA Bios call 0x10 in PIC and APIC

Post by iman »

iansjack wrote:Yes. The x86BiosCall function used by those drivers does not call the BIOS interrupts, it emulates them. Again, you could write this yourself. But what's the point? If you know how to do that you could just write a protected mode driver without bothering with emulation.
That's completely true.
How else can I query the available modes, set a certain mode, etc. on SVGA in protected mode, without CPU being interrupted in real mode? As I said before, when my kernel (32 bit protected mode) needs some SVGA function, I switch to real mode with INT 10H. I wish I could emulate INT 10H.
What I have done so far: brought the protected mode to real mode switched BIOS calls before APIC being set up.
Iman Abdollahzadeh
Github
Codeberg
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: SVGA Bios call 0x10 in PIC and APIC

Post by nexos »

If you want to set SVGA modes in PMode, you have several options. Use V8086 mode, call SVGA BIOS from bootloader, or write your own graphics driver. That is nearly impossible for some cards.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Octocontrabass
Member
Member
Posts: 5572
Joined: Mon Mar 25, 2013 7:01 pm

Re: SVGA Bios call 0x10 in PIC and APIC

Post by Octocontrabass »

nexos wrote:I find that hard to believe, as the SVGA BIOS is un-standardized, so emulating it is impossible.
Emulating it is very easy. Just read the INT 0x10 entry point from the IVT and start interpreting x86 instructions, one at a time, until you IRET or RETF out of the VGA ROM. When the instruction is meant to access hardware, you can choose to either access the hardware on the instruction's behalf (for when the ROM is poking VGA registers) or emulate the hardware (for when the ROM tries to access timers or interrupt controllers or whatever else).
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: SVGA Bios call 0x10 in PIC and APIC

Post by nexos »

I thought iansjack was talking about emulating the functions themselves, not writing an emulator that steps through the BIOS. That makes sense.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: SVGA Bios call 0x10 in PIC and APIC

Post by PeterX »

Octocontrabass wrote:Emulating it is very easy. Just read the INT 0x10 entry point from the IVT and start interpreting x86 instructions, one at a time, until you IRET or RETF out of the VGA ROM. When the instruction is meant to access hardware, you can choose to either access the hardware on the instruction's behalf (for when the ROM is poking VGA registers) or emulate the hardware (for when the ROM tries to access timers or interrupt controllers or whatever else).
It seems to me that this is not as easy as you say. You have to interprete/decode the machine code instructions, or don't you? So you write a rather large interpreter...

Greetings
Peter
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: SVGA Bios call 0x10 in PIC and APIC

Post by bzt »

PeterX wrote:It seems to me that this is not as easy as you say. You have to interprete/decode the machine code instructions, or don't you? So you write a rather large interpreter...
Not really. You only have to emulate real mode, which is pretty easy (only 1M of memory, no GDT, no LDT, no IDT, no TSS, etc. lots of complicated protected mode stuff not needed at all).

Also others had already done this for you, you don't need to write one.
libx86emu - does exactly this, however it supports more than what you need (emulates protected mode too for example), but no fpu emulation
x86emu in XFree86 - this is a pretty small, few files-only emulator, specifically used to emulate VBE BIOSes. Real-mode only, but emulates fpu too.
iman wrote:I wish I could emulate INT 10H.
It worth mentioning that the code in XFree86 is well-tested and guaranteed to work with all SVGA cards you can find (Linux's X actually used that code to emulate INT 10H in the early days when native drivers were rare).

Just for the records, if you're looking for native Open Source SVGA drivers, then take a look at SVGAlib (on github). But to be honest, I seriously doubt you can find any Matrox, S3, Paradise or ATI Rage cards these days... SVGA is obsolete, everybody moved on. The best chance is that modern cards might have VESA ROM for backward compatibility, so back to x86 emulation.

Cheers,
bzt
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: SVGA Bios call 0x10 in PIC and APIC

Post by nexos »

bzt wrote:SVGA is obsolete, everybody moved on.
SVGA never really was. It started with IBM's XGA, then everyone else said "Wouldn't it be cool to make our own high-res graphics!" The end result was a million different standards, all losely combined under the name SVGA. What you define SuperVGA as is graphics resolutions starting at 800 * 600. From Wikipedia:
Super VGA (SVGA), is a broad term that covers a wide range of computer display standards that extended IBM's VGA specification.
When used as shorthand for a resolution, as VGA and XGA often are, SVGA refers to a resolution of 800x600.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: SVGA Bios call 0x10 in PIC and APIC

Post by bzt »

nexos wrote:
bzt wrote:SVGA is obsolete, everybody moved on.
SVGA never really was. It started with IBM's XGA, then everyone else said "Wouldn't it be cool to make our own high-res graphics!" The end result was a million different standards, all losely combined under the name SVGA. What you define SuperVGA as is graphics resolutions starting at 800 * 600. From Wikipedia:
Super VGA (SVGA), is a broad term that covers a wide range of computer display standards that extended IBM's VGA specification.
When used as shorthand for a resolution, as VGA and XGA often are, SVGA refers to a resolution of 800x600.
I did not mean resolution, but the pixel format. SVGA used palette buffers limited to 256 colors just like VGA. I meant everybody moved on to true-color (24 or 32 bits) packed pixel format. As the wiki states, SVGA was a wide range, some cards offered hi-color SVGA modes, but true-color was extremely rare, almost non-existent (mostly because video cards of that time didn't had enough RAM). It got widespread by the time when VESA was implemented in the ROMs (there's no direct relation here, it's just VESA ROMs and big enough video RAM happened about the same time). And direct-color 32 bits linear framebuffer is the de facto standard these days (not only for the PC, but for a wide range of platforms).

Cheers,
bzt
Post Reply