This function maps an area in PC Card memory or I/O space to system memory and returns a pointer used to access the mapped region.
PVOID CardMapWindow( CARD_WINDOW_HANDLE hCardWindow UINT32 uCardAddress UINT32 uSize PUINT32 pGranularity );
A PVOID pointer mapped to the requested region indicates success. NULL indicates failure, and GetLastError returns one of the following values:
If this function fails, a previous mapping of the window might be invalid.
The offset from the returned mapped virtual address must be multiplied by the value pointed to by pGranularity.
The pointer returned by this function can be used to access the PC Card directly. Drivers should access the memory in a try/except routine to avoid faulting the system on card removal.
The pointer to the mapped PC Card memory that this function returns is to non-cached shared memory. This function calls the VirtualAlloc function with flags to allocate non-cached memory. This guarantees that a PC Card device and its driver detect the same information when they access the same memory location.
To provide reliable access to the mapped PC Card memory, driver code should declare the pointer to the PC Card memory with the volatile type qualifier.
Most Windows CE–based platforms use three fixed memory-mapped ranges to access the PC Card address spaces: attribute memory, I/O memory, and common memory. The address returned from this function is a virtual address mapped to the physical address corresponding to the caller’s request. This function prevents multiple drivers from allocating overlapping ranges within each address space, though multiple allocations are permitted within each space. A single driver is enabled to map a range that overlaps its own previously allocated ranges.
Designers of Windows CE–based platforms that support programmable windows through a standard PC Card socket controller can define a combination of fixed memory-mapped ranges and programmable ranges in their Pcmcia.pdd file. If the requested range cannot be mapped within one of the fixed regions, one of the programmable regions can be used. To avoid memory contention, Windows CE ensures that only one mapped range exists within a programmable range. The programmable ranges are not large, about 32 KB, but they can access any 32 KB range within the 64 MB PC Card address space.
PCMCIA
CARD_WINDOW_HANDLE, CardRequestWindow