Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2726 | vana | 1 | /*++ |
| 2 | |||
| 3 | Copyright (c) 1998 Intel Corporation |
||
| 4 | |||
| 5 | Module Name: |
||
| 6 | |||
| 7 | vm.c |
||
| 8 | |||
| 9 | Abstract: |
||
| 10 | |||
| 11 | EFI Hell to remap runtime address into the new virual address space |
||
| 12 | that was registered by the OS for RT calls. |
||
| 13 | |||
| 14 | So the code image needs to be relocated. All pointers need to be |
||
| 15 | manually fixed up since the address map changes. |
||
| 16 | |||
| 17 | GOOD LUCK NOT HAVING BUGS IN YOUR CODE! PLEASE TEST A LOT. MAKE SURE |
||
| 18 | EXIT BOOTSERVICES OVER WRITES ALL BOOTSERVICE MEMORY & DATA SPACES WHEN |
||
| 19 | YOU TEST. |
||
| 20 | |||
| 21 | Revision History |
||
| 22 | |||
| 23 | --*/ |
||
| 24 | |||
| 25 | #include "lib.h" |
||
| 26 | |||
| 27 | #pragma RUNTIME_CODE(RtLibEnableVirtualMappings) |
||
| 28 | VOID |
||
| 29 | RUNTIMEFUNCTION |
||
| 30 | RtLibEnableVirtualMappings ( |
||
| 31 | VOID |
||
| 32 | ) |
||
| 33 | { |
||
| 34 | EFI_CONVERT_POINTER ConvertPointer; |
||
| 35 | |||
| 36 | // |
||
| 37 | // If this copy of the lib is linked into the firmware, then |
||
| 38 | // do not update the pointers yet. |
||
| 39 | // |
||
| 40 | |||
| 41 | if (!LibFwInstance) { |
||
| 42 | |||
| 43 | // |
||
| 44 | // Different components are updating to the new virtual |
||
| 45 | // mappings at differnt times. The only function that |
||
| 46 | // is safe to call at this notification is ConvertAddress |
||
| 47 | // |
||
| 48 | |||
| 49 | ConvertPointer = RT->ConvertPointer; |
||
| 50 | |||
| 51 | // |
||
| 52 | // Fix any pointers that the lib created, that may be needed |
||
| 53 | // during runtime. |
||
| 54 | // |
||
| 55 | |||
| 56 | ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&RT); |
||
| 57 | ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&LibRuntimeDebugOut); |
||
| 58 | |||
| 59 | ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRaiseTPL); |
||
| 60 | ConvertPointer (EFI_INTERNAL_PTR, (VOID **)&LibRuntimeRestoreTPL); |
||
| 61 | |||
| 62 | // that was it :^) |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | |||
| 67 | #pragma RUNTIME_CODE(RtConvertList) |
||
| 68 | VOID |
||
| 69 | RUNTIMEFUNCTION |
||
| 70 | RtConvertList ( |
||
| 71 | IN UINTN DebugDisposition, |
||
| 72 | IN OUT LIST_ENTRY *ListHead |
||
| 73 | ) |
||
| 74 | { |
||
| 75 | LIST_ENTRY *Link; |
||
| 76 | LIST_ENTRY *NextLink; |
||
| 77 | EFI_CONVERT_POINTER ConvertPointer; |
||
| 78 | |||
| 79 | ConvertPointer = RT->ConvertPointer; |
||
| 80 | |||
| 81 | // |
||
| 82 | // Convert all the Flink & Blink pointers in the list |
||
| 83 | // |
||
| 84 | |||
| 85 | Link = ListHead; |
||
| 86 | do { |
||
| 87 | NextLink = Link->Flink; |
||
| 88 | |||
| 89 | ConvertPointer ( |
||
| 90 | Link->Flink == ListHead ? DebugDisposition : 0, |
||
| 91 | (VOID **)&Link->Flink |
||
| 92 | ); |
||
| 93 | |||
| 94 | ConvertPointer ( |
||
| 95 | Link->Blink == ListHead ? DebugDisposition : 0, |
||
| 96 | (VOID **)&Link->Blink |
||
| 97 | ); |
||
| 98 | |||
| 99 | Link = NextLink; |
||
| 100 | } while (Link != ListHead); |
||
| 101 | } |