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


  

Memory Allocation and Deallocation

The Driver Services Library provides services to allocate and free system memory for device drivers. The PoolAllocateResident and PoolDeallocate functions allocate and deallocate resident memory. MemAllocatePhysicallyContiguous and MemDeallocatePhysicallyContiguous allocate and deallocate memory that is resident and physically unbroken. You should always use these services to obtain dynamic memory.

PCI drivers that allocate memory may need to increase the size of the system heap. They can do this by adding a 'sysz' resource to the driver resource file, thereby extending the system heap at startup. Typical code is shown in Listing 11-1.

Listing 11-1 Adding a 'sysz' resource to the system heap

type 'sysz' {
    longint;
};
resource 'sysz' (0, "256 Kb") {
    256 * 1024                      /* 1/4 MB of system heap */
};

Memory allocations can be performed only at noninterrupt execution level. Memory deallocations can be performed at task execution level. Execution levels are discussed in Driver Execution Contexts.

olAllocateResident

PoolDeallocate

MemDeallocatePhysicallyContiguous


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