diff options
Diffstat (limited to 'gnu-efi/gnu-efi-3.0/lib/runtime/vm.c')
-rw-r--r-- | gnu-efi/gnu-efi-3.0/lib/runtime/vm.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/gnu-efi/gnu-efi-3.0/lib/runtime/vm.c b/gnu-efi/gnu-efi-3.0/lib/runtime/vm.c new file mode 100644 index 0000000..26e0c8e --- /dev/null +++ b/gnu-efi/gnu-efi-3.0/lib/runtime/vm.c @@ -0,0 +1,105 @@ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + vm.c + +Abstract: + + EFI Hell to remap runtime address into the new virual address space + that was registered by the OS for RT calls. + + So the code image needs to be relocated. All pointers need to be + manually fixed up since the address map changes. + + GOOD LUCK NOT HAVING BUGS IN YOUR CODE! PLEASE TEST A LOT. MAKE SURE + EXIT BOOTSERVICES OVER WRITES ALL BOOTSERVICE MEMORY & DATA SPACES WHEN + YOU TEST. + +Revision History + +--*/ + +#include "lib.h" + +#ifndef __GNUC__ +#pragma RUNTIME_CODE(RtLibEnableVirtualMappings) +#endif +VOID +RUNTIMEFUNCTION +RtLibEnableVirtualMappings ( + VOID + ) +{ + EFI_CONVERT_POINTER ConvertPointer; + + // + // If this copy of the lib is linked into the firmware, then + // do not update the pointers yet. + // + + if (!LibFwInstance) { + + // + // Different components are updating to the new virtual + // mappings at differnt times. The only function that + // is safe to call at this notification is ConvertAddress + // + + ConvertPointer = RT->ConvertPointer; + + // + // Fix any pointers that the lib created, that may be needed + // during runtime. + // + + ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&RT); + ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&LibRuntimeDebugOut); + + ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRaiseTPL); + ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRestoreTPL); + + // that was it :^) + } +} + + +#ifndef __GNUC__ +#pragma RUNTIME_CODE(RtConvertList) +#endif +VOID +RUNTIMEFUNCTION +RtConvertList ( + IN UINTN DebugDisposition, + IN OUT LIST_ENTRY *ListHead + ) +{ + LIST_ENTRY *Link; + LIST_ENTRY *NextLink; + EFI_CONVERT_POINTER ConvertPointer; + + ConvertPointer = RT->ConvertPointer; + + // + // Convert all the Flink & Blink pointers in the list + // + + Link = ListHead; + do { + NextLink = Link->Flink; + + ConvertPointer ( + Link->Flink == ListHead ? DebugDisposition : 0, + (VOID **)&Link->Flink + ); + + ConvertPointer ( + Link->Blink == ListHead ? DebugDisposition : 0, + (VOID **)&Link->Blink + ); + + Link = NextLink; + } while (Link != ListHead); +} |