On 10/07/2012 12:13 PM, Avi Kivity wrote:
> On 10/05/2012 06:24 PM, Blue Swirl wrote:
>> 
>> I'd suppose addressing devices in the bus could be implemented more
>> efficiently with better use of memory API, now some of it is
>> reimplemented. Maybe Avi can propose something?
> 
> Luckily the low-order bits are used for offsets, and the high-order bits
> are used for selecting the sub-device.
> 
> So you could easily have
> 
>  struct IPackDevice {
>      DeviceState qdev;
>      int32_t slot;
>      /* IRQ objects for the IndustryPack INT0# and INT1# */
>      qemu_irq *irq;
>      MemoryRegion io_space;
>      MemoryRegion id_space;
>      MemoryRegion int_space;
>      MemoryRegion mem8_space;  /* for las3 */
>      MemoryRegion mem16_space; /* for las2 */
>  };
> 
> The PCI device would then just map each space (with
> memory_region_add_subregion()) into las1/las2/las3 such that the high
> bits select the device/space.  The low bits would automatically become
> the offset into the space.

Note: you can easily verify that the mapping is correct with 'info
mtree'.  You should see something like:

pci:
...

   xxxxxxxx-xxxxxxxx las1
     xxxxxxxx-xxxxxxxxx ip0-io
     xxxxxxxx-xxxxxxxxx ip0-id
     xxxxxxxx-xxxxxxxxx ip0-int
     xxxxxxxx-xxxxxxxxx ip1-io
     xxxxxxxx-xxxxxxxxx ip1-id
     xxxxxxxx-xxxxxxxxx ip1-int
   xxxxxxxx-xxxxxxxx las2
     xxxxxxxx-xxxxxxxx ip0-mem16
     xxxxxxxx-xxxxxxxx ip1-mem16

with the addresses relative to the pci address space.

-- 
error compiling committee.c: too many arguments to function

Reply via email to