The two most common PrepareMemoryForIO operations are preparing logical or physical I/O when the client has specified a single, logically-addressed buffer. The following lists show how the driver would set up the IOPreparationTable for these cases. The only difference between the two cases is which mapping table is supplied. PrepareMemoryForIO infers whether the transfer will be physical (DMA) or logical (programmed I/O) based on whether the mapping table is physical or logical.
To perform logical I/O with single logical buffer, set IOPreparationTable as follows:
options | kIOLogicalRanges and either kIOIsInput or kIOIsOutput |
addressSpace | address parameter used in the DoDriverIO call addressSpace |
granularity | 0 |
firstPrepared | 0 |
mappingEntryCount | Number of pages in buffer |
logicalMapping | Address of table containing mappingEntryCount entries |
physicalMapping | nil |
range.base | Buffer address |
range.length | Buffer length |
For physical I/O with single logical buffer, set IOPreparationTable as follows: