3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Fixes IPF specific relocation types
26 #include "PeHotRelocateEx.h"
29 PeHotRelocateImageEx (
32 IN OUT CHAR8
**FixupData
,
39 Performs an IPF specific relocation fixup
43 Reloc - Pointer to the relocation record
45 Fixup - Pointer to the address to fix up
47 FixupData - Pointer to a buffer to log the fixups
49 Adjust - The offset to adjust the fixup
60 switch ((*Reloc
) >> 12) {
61 case EFI_IMAGE_REL_BASED_DIR64
:
62 F64
= (UINT64
*) Fixup
;
63 *FixupData
= ALIGN_POINTER (*FixupData
, sizeof (UINT64
));
64 if (*(UINT64
*) (*FixupData
) == *F64
) {
65 *F64
= *F64
+ (UINT64
) Adjust
;
68 *FixupData
= *FixupData
+ sizeof (UINT64
);
71 case EFI_IMAGE_REL_BASED_IA64_IMM64
:
72 F64
= (UINT64
*) Fixup
;
73 *FixupData
= ALIGN_POINTER (*FixupData
, sizeof (UINT64
));
74 if (*(UINT64
*) (*FixupData
) == *F64
) {
76 // Align it to bundle address before fixing up the
77 // 64-bit immediate value of the movl instruction.
80 Fixup
= (CHAR8
*) ((UINT64
) Fixup
& (UINT64
)~(15));
81 FixupVal
= (UINT64
) 0;
84 // Extract the lower 32 bits of IMM64 from bundle
88 (UINT32
*) Fixup
+ IMM64_IMM7B_INST_WORD_X
,
90 IMM64_IMM7B_INST_WORD_POS_X
,
96 (UINT32
*) Fixup
+ IMM64_IMM9D_INST_WORD_X
,
98 IMM64_IMM9D_INST_WORD_POS_X
,
104 (UINT32
*) Fixup
+ IMM64_IMM5C_INST_WORD_X
,
106 IMM64_IMM5C_INST_WORD_POS_X
,
107 IMM64_IMM5C_VAL_POS_X
112 (UINT32
*) Fixup
+ IMM64_IC_INST_WORD_X
,
114 IMM64_IC_INST_WORD_POS_X
,
120 (UINT32
*) Fixup
+ IMM64_IMM41a_INST_WORD_X
,
122 IMM64_IMM41a_INST_WORD_POS_X
,
123 IMM64_IMM41a_VAL_POS_X
127 // Update 64-bit address
132 // Insert IMM64 into bundle
136 ((UINT32
*) Fixup
+ IMM64_IMM7B_INST_WORD_X
),
138 IMM64_IMM7B_INST_WORD_POS_X
,
139 IMM64_IMM7B_VAL_POS_X
144 ((UINT32
*) Fixup
+ IMM64_IMM9D_INST_WORD_X
),
146 IMM64_IMM9D_INST_WORD_POS_X
,
147 IMM64_IMM9D_VAL_POS_X
152 ((UINT32
*) Fixup
+ IMM64_IMM5C_INST_WORD_X
),
154 IMM64_IMM5C_INST_WORD_POS_X
,
155 IMM64_IMM5C_VAL_POS_X
160 ((UINT32
*) Fixup
+ IMM64_IC_INST_WORD_X
),
162 IMM64_IC_INST_WORD_POS_X
,
168 ((UINT32
*) Fixup
+ IMM64_IMM41a_INST_WORD_X
),
170 IMM64_IMM41a_INST_WORD_POS_X
,
171 IMM64_IMM41a_VAL_POS_X
176 ((UINT32
*) Fixup
+ IMM64_IMM41b_INST_WORD_X
),
178 IMM64_IMM41b_INST_WORD_POS_X
,
179 IMM64_IMM41b_VAL_POS_X
184 ((UINT32
*) Fixup
+ IMM64_IMM41c_INST_WORD_X
),
186 IMM64_IMM41c_INST_WORD_POS_X
,
187 IMM64_IMM41c_VAL_POS_X
192 ((UINT32
*) Fixup
+ IMM64_SIGN_INST_WORD_X
),
194 IMM64_SIGN_INST_WORD_POS_X
,
198 *(UINT64
*) (*FixupData
) = *F64
;
201 *FixupData
= *FixupData
+ sizeof (UINT64
);
205 DEBUG ((EFI_D_ERROR
, "PeHotRelocateEx:unknown fixed type\n"));
206 return EFI_UNSUPPORTED
;
214 // Cache Flush Routine.
218 IN EFI_PHYSICAL_ADDRESS Start
,
225 Flush cache with specified range.
229 Start - Start address
230 Length - Length in bytes
236 EFI_SUCCESS - success
240 SalFlushCache (Start
, Length
);