ExitBootServices(), the UEFI Driver should not use the techniques described in this section. The best example of a runtime driver following the UEFI driver model is an UNDI driver providing services for a network interface controller (NIC).
ExitBootServices()has been called. UEFI Drivers of this category are much more difficult to implement and validate because they are required to execute in both the pre-boot environment, where the system firmware owns the platform, and in the post-boot environment, where an operating system owns the platform.
ExitBootServices()in order to be allocated from runtime memory.
ExitBootServices(). After this point, the UEFI driver is not allowed to use any of the UEFI boot services. The UEFI runtime services and services from other runtime drivers are still available.
SetVirtualAddressMap(). If this event is signaled, the OS loader or OS kernel requests that all runtime components be converted from their physical address mapping to the virtual address mappings that are then passed to
ConvertPointer()to convert all pointers in global variables and allocated runtime buffers from physical address to virtual addresses. This code may be complex and difficult to get correct because, at this time, no tools are available to help know when all the pointers have been converted. When not done correctly, the only symptom noticed may be that the OS crashes or hangs due to a condition in the middle of a call to a service produced by a runtime driver.
SetVirtualAddressMap()event executes in physical mode, so all linked list and structure traversals must be performed with the physical versions of the pointer values. Once a pointer value is converted from a physical address to a virtual address, that pointer value cannot be used again within the
SetVirtualAddressMap()event. The typical approach is to convert the pointers to the leaf structures first and work towards the root.
TRUE, allowing the code in other functions to know if the UEFI boot services are available or not. This global variable is initialized to
FALSEin its declaration. The notification function for the Set Virtual Address Map event converts one global pointer from a physical address to a virtual address as an example using a the
EfiConvertPointer()function from the EDK II library
UefiRuntimeLib. A real driver might have many more pointers to convert. In general, a UEFI Runtime Driver should be designed to reduce or eliminate pointers that need to be converted to minimize the likelihood of missing a pointer conversion.
LoadImage()to allocate memory for the code and data sections from runtime memory. In the EDK II this is done by setting
[Defines]section of the INF file to
DXE_RUNTIME_DRIVER. In addition, a
DXE_RUNTIME_DRIVERis required to have a
[Depex]section in the INF file. UEFI Runtime Driver must use the same
[Depex]section contents. The example below shows the INF file for a UEFI Runtime Driver with a
DXE_RUNTIME_DRIVERand the required
Unload()function must close the Exit Boot Services and Set Virtual Address Map events by calling the UEFI Boot Service
CloseEvent(). These events are typically declared as global variables so they can be easily accessed from the
Unload()function. The example below shows an unloadable runtime driver. It is the same as the previous example, except the entry point looks up the
EFI_LOADED_IMAGE_PROTOCOLassociated with ImageHandle and registers the Unload() function called
AbcUnload()closes the events that were created in the driver entry point using the UEFI Boot Service