summaryrefslogtreecommitdiff
path: root/gnu-efi/lib/runtime/vm.c
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2021-03-23 23:49:46 +0000
committerSteve McIntyre <steve@einval.com>2021-03-23 23:49:46 +0000
commit1251a7ba86fc40a6aad8b4fecdbca2b61808d9fa (patch)
tree2125fda549aaca55cb49a48d54be77dec7fbf3df /gnu-efi/lib/runtime/vm.c
parent85b409232ce89b34626df9d72abedf5d4f5ccef6 (diff)
parent031e5cce385d3f96b1caa1d53495332a7eb03749 (diff)
downloadefi-boot-shim-debian/15.3-1.tar.gz
efi-boot-shim-debian/15.3-1.zip
Update upstream source from tag 'upstream/15.3'debian/15.3-1
Update to upstream version '15.3' with Debian dir 1b484f1c1ac270604a5a1451b34de4b0865c6211
Diffstat (limited to 'gnu-efi/lib/runtime/vm.c')
-rw-r--r--gnu-efi/lib/runtime/vm.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/gnu-efi/lib/runtime/vm.c b/gnu-efi/lib/runtime/vm.c
new file mode 100644
index 00000000..26e0c8e1
--- /dev/null
+++ b/gnu-efi/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);
+}