/** @file
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Abstract:
IA32, X64 and IPF Specific relocation fixups
Revision History
--*/
#include <Common/UefiBaseTypes.h>
#include <IndustryStandard/PeImage.h>
#include "PeCoffLib.h"
#include "CommonLib.h"
#define IMM64_IMM7B_VAL_POS_X 0
#define IMM64_IMM41c_INST_WORD_POS_X 0
)
/*++
Routine Description:
Performs an IA-32 specific relocation fixup
Arguments:
Reloc - Pointer to the relocation record
Fixup - Pointer to the address to fix up
FixupData - Pointer to a buffer to log the fixups
Adjust - The offset to adjust the fixup
Returns:
EFI_UNSUPPORTED - Unsupported now
--*/
{
return RETURN_UNSUPPORTED;
}
)
/*++
Routine Description:
Performs an Itanium-based specific relocation fixup
Arguments:
Reloc - Pointer to the relocation record
Fixup - Pointer to the address to fix up
FixupData - Pointer to a buffer to log the fixups
Adjust - The offset to adjust the fixup
Returns:
Status code
--*/
{
switch ((*Reloc) >> 12) {
}
break;
//
// Align it to bundle address before fixing up the
// 64-bit immediate value of the movl instruction.
//
//
// Extract the lower 32 bits of IMM64 from bundle
//
);
);
);
);
);
//
// Update 64-bit address
//
//
// Insert IMM64 into bundle
//
);
);
);
);
);
);
);
);
}
break;
default:
return RETURN_UNSUPPORTED;
}
return RETURN_SUCCESS;
}
)
/**
Performs an x64 specific relocation fixup
@param Reloc Pointer to the relocation record
@param Fixup Pointer to the address to fix up
@param FixupData Pointer to a buffer to log the fixups
@param Adjust The offset to adjust the fixup
@retval RETURN_SUCCESS Success to perform relocation
@retval RETURN_UNSUPPORTED Unsupported.
**/
{
switch ((*Reloc) >> 12) {
}
break;
default:
return RETURN_UNSUPPORTED;
}
return RETURN_SUCCESS;
}
/**
Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and
return the immediate data encoded in the instruction
@param Instruction Pointer to ARM MOVT or MOVW immediate instruction
@return Immediate address encoded in the instruction
**/
)
{
// Thumb2 is two 16-bit instructions working together. Not a single 32-bit instruction
// Example MOVT R0, #0 is 0x0000f2c0 or 0xf2c0 0x0000
// imm16 = imm4:i:imm3:imm8
// imm4 -> Bit19:Bit16
// i -> Bit26
// imm3 -> Bit14:Bit12
// imm8 -> Bit7:Bit0
return Address;
}
/**
Update an ARM MOVT or MOVW immediate instruction immediate data.
@param Instruction Pointer to ARM MOVT or MOVW immediate instruction
@param Address New addres to patch into the instruction
**/
)
{
// First 16-bit chunk of instruciton
// Second 16-bit chunk of instruction
Instruction++;
}
/**
return the immediate data encoded in the two` instruction
@return Immediate address encoded in the instructions
**/
)
{
}
/**
@param Address New addres to patch into the instructions
**/
)
{
}
/**
Performs an ARM-based specific relocation fixup and is a no-op on other
instruction sets.
@param Reloc Pointer to the relocation record.
@param Fixup Pointer to the address to fix up.
@param FixupData Pointer to a buffer to log the fixups.
@param Adjust The offset to adjust the fixup.
@return Status code.
**/
)
{
switch ((**Reloc) >> 12) {
}
break;
// break omitted - ARM instruction encoding not implemented
default:
return RETURN_UNSUPPORTED;
}
return RETURN_SUCCESS;
}