qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Where is vga-rom mapped in guest system memory?


From: Laszlo Ersek
Subject: Re: [Qemu-devel] Where is vga-rom mapped in guest system memory?
Date: Wed, 14 May 2014 12:55:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 05/14/14 06:01, Jaeyong Yoo wrote:
>> -----Original Message-----
>> From: address@hidden [mailto:qemu-
>> address@hidden On Behalf Of Laszlo
>> Ersek
>> Sent: Tuesday, May 13, 2014 10:55 PM
>> To: address@hidden; address@hidden
>> Subject: Re: [Qemu-devel] Where is vga-rom mapped in guest system memory?
>>
>> On 05/13/14 14:58, Jaeyong Yoo wrote:
>>> Hello qemu!
>>>
>>>
>>>
>>> I am currently writing a vga device emulator and need to debug vga-bios.
>>>
>>> What I want is to set break-point on the entry of vga-bios and for
>>> this,
>>>
>>> I'm reading qemu source around pci device and rom-related memory
>>> regions
>>>
>>> to find out where should I set break point. And, sadly, got stuck.
>>>
>>>
>>>
>>> Could you give me any advice about the memory-mapped address of
>>> vga-rom or
>>>
>>> any pointers?
>>
>> Some.
>>
>> The vgabios binary is loaded from the file identified by the "romfile"
>> property of the VGA card that you select. For example,
>>
>>   -device qxl-vga,romfile=...
>>
>> or
>>
>>   -vga qxl \
>>   -global qxl-vga.romfile=...
>>
>> Of course the property has a default value for each VGA card. See the
>>
>>   k->romfile = ...
>>
>> assignments in:
>> - cirrus_vga_class_init() -- vgabios-cirrus.bin
>> - qxl_primary_class_init() -- vgabios-qxl.bin
>> - vga_class_init() -- vgabios-stdvga.bin
>>
>> I think the oprom is loaded in
>>
>> pci_qdev_init() [hw/pci/pci.c]
>>   pci_add_option_rom()
>>
>> The vgabios oprom is shadowed from ROM (pci address space) to RAM by the
>> SeaBIOS initialization code, and then POSTed:
>>
>> handle_post() [src/post.c]
>>   make_bios_writable() [src/fw/shadow.c]
>>     make_bios_writable_intel()
>>       __make_bios_writable_intel() -- shadows vgabios in C segment too
>>   dopost() [src/post.c]
>>     maininit()
>>       vgarom_setup() [src/optionroms.c]
>>         init_pcirom()
>>           init_optionrom()
>>             callrom()
>>               __callrom()
>>                 _rom_header_entry [vgasrc/vgaentry.S]
>>                   vga_post() [vgasrc/vgainit.c]
>>
>> You can instrument vga_post() in the SeaBIOS source [vgasrc/vgainit.c],
>> rebuild the vgabios binary, and load this binary with the video card's
>> romfile=... property on the qemu command line.
> 
> Thanks for the answer. It is the exact code-path that I was looking for :-)
> 
> I have one follow-up question.
> It looks like seabios (bios.bin) includes the vgabios (such as vga_post
> functions). And this bios.bin is not loaded as vgabios-stdvga.bin (the
> one that you mentioned in vga_class_init). I'm not clearly understanding
> the difference between vgabios inside bios.bin and vgabios-stdvga.bin.
> Could you tell me the difference?

bios.bin and vgabios.bin are separate build outputs of SeaBIOS. If you
run "make menuconfig" in the seabios directory and browse the options,
it should become clearer. (The build system should be discussed on the
seabios list, the maintainers can help you more than I can.)

I recommend to study the following SRPM:

https://www.kraxel.org/repos/jenkins/seabios/seabios.git-1.7.4-93.b113.g6ad7b5b.src.rpm

the SPEC file should help (see the do_build() function and the various
build config files).

> Additionally, currently, what I'm trying to do is to port the VirtualBox's
> graphics stack to qemu and I'm expecting to use VirtualBox's vgabios. In this
> case, do I have to modify something in seabios?

I wouldn't think so.

> I thought all I need to do is
> to set romfile as the path to the VirtualBox vgabios

I agree. If the virtualbox vgabios is a "well formed" PCI oprom,
matching the PCI IDs of the display device you are porting etc, then it
should "just work". SeaBIOS runs on physical hardware too, and (I
gather) it posts the oproms of the various (unknown in andvance)
physical cards too that it finds in the machine.

Laszlo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]