>
>Basically, from the docs, I believe that the PHYSICAL_ADDRESS
returned
>by any of the mapping functions in the DMA_ADAPTER is supposed to be
bus
PHYSICAL_ADDRESS is the “logical address”, which is the physical
address
passed via the mapping layer.
What is the “mapping layer” is defined by the DMA_ADAPTER implementor,
in
this case - by you.
So, you can give any value you want for PHYSICAL_ADDRESSes returned
by
your DMA adapter.
The only limitations which come to mind:
a) page granularity. If the 2 virtual addresses are in the same page -
then 2 PHYSICAL_ADDRESSes must also belong to the same page.
Well… that’s a fail then. Is that documented somewhere so I can read
more about it.
b) common buffers must be contiguous, not only from the virtual
address
side (this is obvious), but from PHYSICAL_ADDRESS side too.
That’s a fail too. Grant refs are simply a reference to a table, and the
table contains the PFN, and some other bits and pieces per pfn. The
grant refs are maintained on a freelist, so if I wanted to map a buffer
of pfn’s 0x6660, 0x6661, and 0x6662, they may get grant refs 16383,
16300, and 14001.
Bear in mind that Xen doesn’t care. What the virtual machine sees as
contiguous physical addresses probably actually aren’t. pfn’s 0x6660,
0x6661, and 0x6662 might in actual fact relate to mfn’s (pfn’s from
xen’s point of view) 0x1234, 0x5678, and 0xabcd. This is the reason why
you can’t just pass through a PCI device and make it work without a bit
of buffer translation.
You can, for instance, implement AllocateCommonBuffer as
ExAllocatePoolWithTag (even not MmAllocateContiguousMemory) followed
by
Xen grant of all these pages to consecutive Xen space.
In this case, the PHYSICAL_ADDRESSes as viewed by the client driver
are
actually “Xen space addresses”. The client driver can then submit
these
addresses to some Xen-defined facilities.
Also, in this case, MapTransfer and GetScatterGatherList should grant
each
of the MDL’s pages to Xen, and return these “Xen space addresses” as
PHYSICAL_ADDRESSes in the SGL.
That’s what I’ve done and it works for scsiport, which only does a
single AllocateCommonBuffer + lots of
BuildScatterGatherList+PutScatterGatherList.
Two more important things:
a) AGP440 sample in the DDKs is a sample of DMA_ADAPTER
implementation,
look at it about how it works with MDLs fed to it.
Thanks. I’ll look at that. I probably should have gone looking for a
sample earlier
b) Your “page granting” issues with NDIS are probably better solved
using
the DMA adapter object, not within the NDIS itself.
That’s the plan. I actually hope to have the function device drivers not
have any awareness of grant refs at all, which would make them much
simpler, much more like hardware devices, and much more likely to make
WHQL happy.
Thanks
James