PATH 
ADC Home > Documentation > Hardware > Device Managers and Drivers > PCI Card Services > Designing PCI Cards and Drivers for Power Macintosh Computers


  

Private Calls and Virtual Memory

If your driver supports virtual memory (you can use the kdgVMOptions Driver Gestalt selector to indicate this), you must be careful to avoid fatal page faults when fielding private control calls. Specifically, your driver must not cause a page fault while it is fielding a queued (that is, synchronous or asynchronous) request.

The Virtual Memory Manager holds the entire ParamBlockRec passed to all queued _Read, _Write, _Control, and _Status calls. In addition, VM holds the I/O buffer (pointed to by ioBuffer, for length ioReqCount ). Therefore your driver can safely access this memory without causing a fatal page fault.

The problem comes when you define a private control call whose ParamBlockRec contains a pointer to another piece of memory. If your driver accesses that memory, it may cause a page fault. If your driver supports virtual memory, that page fault will be fatal (because a page fault while any paging device is busy is fatal).

There are a number of ways to avoid this problem.

  1. Always include all information inline in the parameter block. Remember that the parameter block is automatically held for you by the Virtual Memory Manager.
  2. If you must include pointers in your parameter block, define your private control call interface to be called immediate. Immediate calls to a driver do not mark the driver as busy, and hence any page faults they cause will not be fatal. However, your driver must be written to support immediate calls of this kind.
  3. If none of the above are suitable, you must require that your clients hold any buffers pointed to by the parameter block.

If you make a Control or Status call to a device driver which supports paging and the parameter block contains pointers to other data structures, you should hold those data structures, just to be sure.

For more background about how the Mac OS Virtual Memory Manager prevents fatal page faults, see DTS Technote 1094, "Virtual Memory Application Compatibility."


© 1999 Apple Computer, Inc. – (Last Updated 26 March 99)