ConvertPointer()from an event notification function for an event of type
EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGEor a GUIDed event of type
SetVirtualAddressMap()is called. Instead, this type of notification function typically uses
ConvertPointer()to convert pointers within data structures that are managed by the UEFI runtime driver from physical addresses to virtual addresses.
EfiRuntimeServicesData, those pointer values must be converted from physical addresses to virtual address using the virtual address ranges provided by the operating system when the operating system calls the UEFI Runtime Service
SetVirtualAddressMap(). If allocated buffers contain more pointers, then those pointer values must also be converted.
SetVirtualAddressMap()only executes in physical mode.
SetVirtualAddressMap(). There are two methods to create a
SetVirtualAddressMap()event. This example shows the preferred method that uses
CreateEventEx()to pass in the GUID of
gEfiEventVirtualAddressChangeGuid. The alternate method uses
CreateEventEx()with an event type of
EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. The created event is declared as a global variable. and makes the event available if the UEFI Runtime Driver needs to close the event if UEFI Runtime Driver is unloaded. The code fragments that follow this example show how
ConvertPointer()may be used from
NotifySetVirtualAddressMap(), the event notification function from this example.
ConvertPointer()is used to convert a global variable functioning as a pointer from a physical address to that with a virtual address.
ConvertPointer()to not perform a conversion if the physical address of the pointer is
NULL. This is useful if it is legal for some of the pointer values to be
NULLvalue needs to be preserved after the conversion. The only other legal value for this field is 0 The conversion should be performed unconditionally.
EfiConvertPointer()from the EDK II library
UefiRuntimeLibto call the UEFI Runtime Service
UefiRuntimeLibalso provides the function
EfiConvertFunctionPointer()to convert a function pointer from a physical address to a virtual address. On supported CPU architectures where there is no distinction between a data pointer and a function pointer,
EfiConvertFunctionPointer()are identical. On other CPU architectures such as IPF, where function calls are made through a
PLABEL, converting a function pointer is more complex. The EDK II library
UefiRuntimeLibhelps hide these CPU specific details so the UEFI Driver sources can be the same for all supported CPU architectures.
EfiConvertFunctionPointer()is required only if a UEFI Driver caches a function pointer in a global variable or an allocated buffer.
UefiRuntimeLibalso provides helper function call
EfiConvertList()to convert all the pointer values in a doubly linked list of type
LIST_ENTRY. All the nodes in the linked list are traversed and the forward and backward link in each node is converted from a physical address to a virtual address.