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