[vbox-dev] Simple PCI device for shared memory

Nev vbox at zavalon.com
Wed May 19 09:28:40 GMT 2010


Hi,

I have a simple Virtual PCI memory device working with VBox OSE, but
unable to get the Guest to use the hosts shared memory region.

I am testing with a windows driver and windows application that has been
lightly tested with a KVM implementation of a similar Virtual PCI
device.

The VBox PCI device is working except the memory is not shared, that is
the PCI configure registers are working and BAR0 is reporting a
reasonable physical address value, with the correct size. That is for
16Mbytes the reported physical address is 0xF100_0000.

My Host is 64 bit Ubuntu, Guest is Windows XP.

I have used the "VBox/Devices/Samples" as a starting point.

To get this device to load I modified the function "pdmR3DevLoadModules"
in VBox/VMM/PDMDevice.cpp, by duplicating the code that loads "VBoxDD".
Question: This function has a for loop that appear to be able to load
modules, but I was not able to find what needs to be configured to
enable this function. What is required to enable loading of device
module without modifying this function? Can this be done from the Front
End?

To cause the constructor to be called I added  
 rc = CFGMR3InsertNode(pDevices, "virtualPci",   &pDev);
 rc = CFGMR3InsertNode(pDev,     "0",            &pInst);
in function Console::configConstructor in "VBox/Main/ConsoleImpl2.cpp"
also added 
rc = CFGMR3InsertInteger(pInst, "Trusted", 1);
to the same file to enable trusted function to be called.

The basic outline of my constructor is
1. initialize the PCI config registers.
2. call PDMDevHlpPCIRegister - to register config registers
3. call shm_open and fstat - to open and get size of shared file
4. call PDMDevHlpMMIO2Register - to allocate Host R3 address space ?
5. call PDMDevHlpMMHyperMapMMIO2 - to allocate Guest address space ?
6. call mmap - to map shared file to Host R3 address
7. call PDMDevHlpPCIIORegionRegister - to set callback function

The callback function from 7. will call
1. PDMDevHlpMMIO2Map - to map Physical address to region.

Any hints, to what I am missing or have wrong, will be greatly
appreciated. I have attached the source, just in case it is useful.

Nev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PciSharedMemory.tar.gz
Type: application/x-compressed-tar
Size: 6211 bytes
Desc: not available
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20100519/3842fe45/attachment.bin>


More information about the vbox-dev mailing list