Secondary VGA card booting
-
Curufir
Re:Secondary VGA card booting
Looked into this some more (The X code is a PITA to try and read. Comments...what comments?).
The sequence of events runs something like this.
X uses x86emu to provide a vm86 environment that looks (To the card) like a working BIOS. The video card's BIOS is copied into RAM , then initialised the same way it would be in POST (A jump). As part of its initialisation the video card's BIOS will fill in the int10 vectors in the emulated real mode. The nv driver doesn't actually use the interrupts for anything, everything gets done using IO ports.
The reason it needs the int10 code is to set up an emulated environment in which the card can initialise itself, and in which IO ports/device memory are given mappings which the device can use.
So to get your 2nd card up and running you're going to need to provide the same functionality (IMHO just use the same mechanisms X uses) to get the thing to boot and give your driver the correct mappings.
http://wiki.linuxbios.org/data/vgabios/ gives some good information.
If x86emu doesn't cut it then http://sourceforge.net/projects/lrmi/ might be an alternative (Haven't looked deeply at it so YMMV).
The sequence of events runs something like this.
X uses x86emu to provide a vm86 environment that looks (To the card) like a working BIOS. The video card's BIOS is copied into RAM , then initialised the same way it would be in POST (A jump). As part of its initialisation the video card's BIOS will fill in the int10 vectors in the emulated real mode. The nv driver doesn't actually use the interrupts for anything, everything gets done using IO ports.
The reason it needs the int10 code is to set up an emulated environment in which the card can initialise itself, and in which IO ports/device memory are given mappings which the device can use.
So to get your 2nd card up and running you're going to need to provide the same functionality (IMHO just use the same mechanisms X uses) to get the thing to boot and give your driver the correct mappings.
http://wiki.linuxbios.org/data/vgabios/ gives some good information.
If x86emu doesn't cut it then http://sourceforge.net/projects/lrmi/ might be an alternative (Haven't looked deeply at it so YMMV).
Re:Secondary VGA card booting
Hi,
The video card's ROM initialization code would use IO ports, etc to initialize the video card ready for use. This initialization code will not be present in X or in any other Linux software. The final product (the mobile phone) will not be able to run 80x86 opcodes (or the video card's ROM code), and therefore details of exactly what this ROM code does to initialize the video card will be needed for the end product.
While you could avoid the problem for now by using the video card's ROM code to initialize it, you're not solving the problem - all it would do is provide the temporary illusion of progress and leave you with the same problem when your finished with the test machine.
By avoiding the use of the video card's ROM code you will solve the initialization problem (and the hassles of trying to get the resource conflict/PCI initialization issues resolved).
IMHO this leaves you with 3 options - get information out of NVidea, pay NVidea to supply code, or reverse engineer the video card's BIOS code.
I assume your end product can't run 80x86 opcodes (otherwise you wouldn't need the FPGA and could use VBE 3 to initialize video modes, etc). I may have assumed something that isn't right, but I still think your screwed...
Cheers,
Brendan
The video card's ROM initialization code would use IO ports, etc to initialize the video card ready for use. This initialization code will not be present in X or in any other Linux software. The final product (the mobile phone) will not be able to run 80x86 opcodes (or the video card's ROM code), and therefore details of exactly what this ROM code does to initialize the video card will be needed for the end product.
While you could avoid the problem for now by using the video card's ROM code to initialize it, you're not solving the problem - all it would do is provide the temporary illusion of progress and leave you with the same problem when your finished with the test machine.
By avoiding the use of the video card's ROM code you will solve the initialization problem (and the hassles of trying to get the resource conflict/PCI initialization issues resolved).
IMHO this leaves you with 3 options - get information out of NVidea, pay NVidea to supply code, or reverse engineer the video card's BIOS code.
I assume your end product can't run 80x86 opcodes (otherwise you wouldn't need the FPGA and could use VBE 3 to initialize video modes, etc). I may have assumed something that isn't right, but I still think your screwed...
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.
-
LowRider
Re:Secondary VGA card booting
Uhu, I know, I think that's because it used to be copyrighted by Scitechsoft. Not?Curufir wrote: Looked into this some more (The X code is a PITA to try and read. Comments...what comments?).
Aha, a clue! So that's what x86emu does...Curufir wrote:The sequence of events runs something like this.
X uses x86emu to provide a vm86 environment that looks (To the card) like a working BIOS. The video card's BIOS is copied into RAM , then initialised the same way it would be in POST (A jump). As part of its initialisation the video card's BIOS will fill in the int10 vectors in the emulated real mode. The nv driver doesn't actually use the interrupts for anything, everything gets done using IO ports.
The reason it needs the int10 code is to set up an emulated environment in which the card can initialise itself, and in which IO ports/device memory are given mappings which the device can use.
So to get your 2nd card up and running you're going to need to provide the same functionality (IMHO just use the same mechanisms X uses) to get the thing to boot and give your driver the correct mappings.
http://wiki.linuxbios.org/data/vgabios/ gives some good information.
If x86emu doesn't cut it then http://sourceforge.net/projects/lrmi/ might be an alternative (Haven't looked deeply at it so YMMV).
Always wondered why they'd use it, I figured, hey I've got a x86, so why emulate it...
Well, very good explanation. Thanks for that. I'll certainly look into the x86emu stuff. Now all I have to do is convince the guys to let me use it (and not roll my own, argh...)
Concerning LRMI, I read that it doesn't support secondary VGA cards.
But now at least I'm starting to believe Brendan's wise words: I'm screwed
-
tom1000000
Re:Secondary VGA card booting
Hello,
Why don't you reverse engineer the video VGA BIOS????
Especially as it seems you are getting paid to do this, here is an opportunity to slightly uncover the veil of secrecy around nVidia / ATI hardware.
Work out what the video BIOS does - it must simply do a bunch of IO or memory writes. The VGA bios is limited in size so it can't be Einstein material (unless it is self encrypted or something ridiculous!).
If you do reverse engineer the BIOS please make your code or documentation public!
Why don't you reverse engineer the video VGA BIOS????
Especially as it seems you are getting paid to do this, here is an opportunity to slightly uncover the veil of secrecy around nVidia / ATI hardware.
Work out what the video BIOS does - it must simply do a bunch of IO or memory writes. The VGA bios is limited in size so it can't be Einstein material (unless it is self encrypted or something ridiculous!).
If you do reverse engineer the BIOS please make your code or documentation public!
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Secondary VGA card booting
i fear it will take him more than the 6 weeks ...
btw, tom, are you aware that the 'secrecy' about what the nvidia bios does is almost already unveiled by the BeOS/linux/freebe drivers ?
what remains a complete mystery is all the rest
btw, tom, are you aware that the 'secrecy' about what the nvidia bios does is almost already unveiled by the BeOS/linux/freebe drivers ?
what remains a complete mystery is all the rest
-
LowRider
Re:Secondary VGA card booting
Well, yes indeedy!! I've been studying the code of the `Haiku' nVidia driver (BeOS) and it contains a section to `soft-boot' the card. They call it a coldstart.Pype.Clicker wrote: btw, tom, are you aware that the 'secrecy' about what the nvidia bios does is almost already unveiled by the BeOS/linux/freebe drivers ?
Here's the link: http://bebits.com/app/3636#download
I've been trying to adapt the code (partially succesful) to my needs and I can hear the monitor click when I execute it. Problem now is this:
I'm using a VGA BIOS image I found somewhere on the internet. While I should be using the image stored on the card (it's an image for AGP and I have PCI)
So, any ideas how I can squeeze the ROM out of my adapter?
My PCI book tells me this:
- assign a base address to the register's Base Address field
- enable its decoder (by setting bit 0 in the register to 1)
- set the Memory Space bit in the function's Command register
- and then attempt to read the first two locations from the ROM
Question: what base address? Should I just pick one?
Does the ROM then just magically `appear' at that location?
Nicolas
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Secondary VGA card booting
No, just 'picking one' would defeat the whole purpose of plug-and-play and could harm other devices. If operating from a base PC, i suggest you let the base PC tell you what should be the base address (e.g. because it has knowledge of what other device picked and what's still available, etc).LowRider wrote: Question: what base address? Should I just pick one?
If your component needs to be completely standalone, i suggest you make the BIOS believe you need memory for your own needs and then use that memory as the ROM base address for the video card you control.
afaik, yes.Does the ROM then just magically `appear' at that location?
-
LowRider
Re:Secondary VGA card booting
And how exactly does one do this? Right now I have something like this:Pype.Clicker wrote: If your component needs to be completely standalone, i suggest you make the BIOS believe you need memory for your own needs and then use that memory as the ROM base address for the video card you control.
[tt]
unsigned char *rom=(unsigned char*)kmalloc(ROMSIZE);
pci_write_config_dword(dev,0x30,(int)rom);
[/tt]
So basically I'm allocating some memory (e.g. 0xE3CC0000) and I'm telling the PCI device to use that address.
But that doesn't seem to work. (you're probably pounding your head against the wall right now and screaming "DUH!!!")
coolafaik, yes.Does the ROM then just magically `appear' at that location?
Re:Secondary VGA card booting
Hi,
Secondly (AFAIK), you'll probably need to reprogram the PCI bridges to allow addresses within that range to pass through to the device. This would include the host bridge (the PCI/AGP controller) and any PCI to PCI bridges between it and the video card. Often they're setup to minimize redundant bus traffic...
Cheers,
Brendan
Firstly, the address you choose shouldn't conflict with addresses used by anything else (but you knew that).LowRider wrote: So basically I'm allocating some memory (e.g. 0xE3CC0000) and I'm telling the PCI device to use that address.
But that doesn't seem to work. (you're probably pounding your head against the wall right now and screaming "DUH!!!")
Secondly (AFAIK), you'll probably need to reprogram the PCI bridges to allow addresses within that range to pass through to the device. This would include the host bridge (the PCI/AGP controller) and any PCI to PCI bridges between it and the video card. Often they're setup to minimize redundant bus traffic...
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.
-
LowRider
Re:Secondary VGA card booting
Well, that sounds logic. I'll have a look (don't know how to do this) and let you know...Brendan wrote:Secondly (AFAIK), you'll probably need to reprogram the PCI bridges to allow addresses within that range to pass through to the device. This would include the host bridge (the PCI/AGP controller) and any PCI to PCI bridges between it and the video card. Often they're setup to minimize redundant bus traffic...
Thanks!
Nicolas
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Secondary VGA card booting
Not much surprising:LowRider wrote: Right now I have something like this:
[tt]
unsigned char *rom=(unsigned char*)kmalloc(ROMSIZE);
pci_write_config_dword(dev,0x30,(int)rom);
[/tt]
But that doesn't seem to work.
- kmalloc gets virtual memory while your base address should be a physical address.
- the physical memory returned by kmalloc is some "real" physical memory, so it is "owned" by the system RAM and cannot be safely used to access PCI devices.
For testing purposes, i'd suggest you get a look at "lspci" and check what addresses are already busy there. Then manually pick some 'known-to-be-free' physical address and use that.
Ideally, after you checked how much system ram the hosting Linux has (as you appear to be operating from the hosting linux), you should scan through the kernel-stored PCI devices and select some "not-yet-used" region for your ROM address.
-
LowRider
Re:Secondary VGA card booting
Great! Works beautifully!
I'm currently using 0xF9000000, ioremapped it and created a character device in /dev to talk to the ROM from outer space. (kernel-space, that is)
Now the darn program gives me Segmentation fault while coldstarting...
*sigh*
to be continued (I guess)...
I'm currently using 0xF9000000, ioremapped it and created a character device in /dev to talk to the ROM from outer space. (kernel-space, that is)
Now the darn program gives me Segmentation fault while coldstarting...
*sigh*
to be continued (I guess)...
-
LowRider
Re:Secondary VGA card booting
Well, as you might have guessed, the 0xf9000000 memory region isn't the best choice. I really need a way to get this address from the kernel.
Any ideas how to do this?
Secondly, I have a question about VBE3's `Protected Mode Entry Point'. The nVidia cores seem to support this. It's supposed to be a way to run some of the `int 10h' calls from protected mode by making a `far call' to the address at which the shadowed VGA BIOS resides.
Only problem I seem to have is that the addresses you have to fill in in the struct are 16bit. So I can't use 32bit addresses? How does this work? Do I have to put a "mem=" line in my GRUB loader and use the top memory? Or am I missing something? (with that whole `segmented memory' stuff, very confusing)
Any ideas how to do this?
Secondly, I have a question about VBE3's `Protected Mode Entry Point'. The nVidia cores seem to support this. It's supposed to be a way to run some of the `int 10h' calls from protected mode by making a `far call' to the address at which the shadowed VGA BIOS resides.
Only problem I seem to have is that the addresses you have to fill in in the struct are 16bit. So I can't use 32bit addresses? How does this work? Do I have to put a "mem=" line in my GRUB loader and use the top memory? Or am I missing something? (with that whole `segmented memory' stuff, very confusing)
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Secondary VGA card booting
the 'PM Bios VBE' thing is rather obscure. Among other things, it expects you to prepare two segments which will map what the bios could need to access. Thing is the selectors for those segments will be used instead of hard-coded 0xC000 and 0xB800, for instance.
Problem is there are various reports of "buggy implementation" of Pmode VBE bios by some vendors (sorry, i don't have more precise info).
Problem is there are various reports of "buggy implementation" of Pmode VBE bios by some vendors (sorry, i don't have more precise info).
-
LowRider
Re:Secondary VGA card booting
No problem, as long as I can quote you as a professional in my final report on the topicPype.Clicker wrote:Problem is there are various reports of "buggy implementation" of Pmode VBE bios by some vendors (sorry, i don't have more precise info).
Right now I'm trying to convince them to give up the nVidia board and go for something more `open'.
Any ideas which manufacturers have their info freely for download?