CardMapWindow
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
);
Parameters
- hCardWindow
[in] Handle to a memory window returned by a call to the CardRequestWindow function. - uCardAddress
[in] Specifies a PC Card offset address. - uSize
[in] Specifies the number of bytes to map. - pGranularity
[in] Must be NULL.
Return Values
A PVOID pointer mapped to the requested region. Callers must use GetLastError to determine of the call was successful, because CardMapWindow will return 0x00 when mapping a PC Card offset address starting at memory address 0. GetLastError returns one of the following values:
- CERR_SUCCESS
The mapping operation completed successfully. - CERR_BAD_WINDOW
Indicates that the hWin window handle is not valid. - CERR_BAD_HANDLE
Indicates that an hCardWindow driver handle is not valid. - CERR_BAD_SIZE
Indicates that the value specified for uSize is not valid. - CERR_OUT_OF_RESOURCE
Indicates that card services is unable to set up a memory window to read the CIS. - CERR_IN_USE
Indicates that another driver owns the memory window as well. - CERR_BAD_BASE
Occurs on an x86 platform when an attempt is made to map an I/O window to address 0.
Remarks
If this function fails, a previous mapping of the window might not be valid.
The pointer returned by this function can be used to access the PC Card directly. Drivers should access the memory in a try and 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 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 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 implementation. 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.
CardGetParsedTuple will calculate and fill all default fields in CISTPL_CFTABLE_ENTRY structures and set the ContainsDefaults member to TRUE for every entry returned. Earlier versions of Windows CE returned the tuples exactly as represented in the card information structure. Use CardGetFirstTuple and CardGetNextTuple if you need to retrieve tuple data, as it is stored on the PC Card.
Requirements
OS Versions: Windows CE 1.0 and later.
Header: Cardserv.h.
Link Library: Cardserv.lib.
See Also
CARD_WINDOW_HANDLE | CardRequestWindow | VirtualAlloc | CardGetParsedTuple | CardGetNextTuple
Last updated on Tuesday, May 18, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.