Initial import.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
56
Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.c
Normal file
56
Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
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:
|
||||
|
||||
PeCoffLoaderEx.c
|
||||
|
||||
Abstract:
|
||||
|
||||
IA-32 Specific relocation fixups
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#include "TianoCommon.h"
|
||||
|
||||
EFI_STATUS
|
||||
PeCoffLoaderRelocateImageEx (
|
||||
IN UINT16 *Reloc,
|
||||
IN OUT CHAR8 *Fixup,
|
||||
IN OUT CHAR8 **FixupData,
|
||||
IN UINT64 Adjust
|
||||
)
|
||||
/*++
|
||||
|
||||
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 EFI_UNSUPPORTED;
|
||||
}
|
65
Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.h
Normal file
65
Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
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:
|
||||
|
||||
PeCoffLoaderEx.h
|
||||
|
||||
Abstract:
|
||||
|
||||
IA-32 Specific relocation fixups
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _PE_COFF_LOADER_EX_H_
|
||||
#define _PE_COFF_LOADER_EX_H_
|
||||
|
||||
//
|
||||
// Define macro to determine if the machine type is supported.
|
||||
// Returns 0 if the machine is not supported, Not 0 otherwise.
|
||||
//
|
||||
#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
|
||||
((Machine) == EFI_IMAGE_MACHINE_IA32 || \
|
||||
(Machine) == EFI_IMAGE_MACHINE_EBC)
|
||||
|
||||
EFI_STATUS
|
||||
PeCoffLoaderRelocateImageEx (
|
||||
IN UINT16 *Reloc,
|
||||
IN OUT CHAR8 *Fixup,
|
||||
IN OUT CHAR8 **FixupData,
|
||||
IN UINT64 Adjust
|
||||
)
|
||||
/*++
|
||||
|
||||
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
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif
|
@@ -0,0 +1,47 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
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:
|
||||
|
||||
PerformancePrimitives.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Support for Performance library
|
||||
|
||||
--*/
|
||||
|
||||
#include "TianoCommon.h"
|
||||
#include "CpuIA32.h"
|
||||
|
||||
EFI_STATUS
|
||||
GetTimerValue (
|
||||
OUT UINT64 *TimerValue
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Get timer value.
|
||||
|
||||
Arguments:
|
||||
|
||||
TimerValue - Pointer to the returned timer value
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Successfully got timer value
|
||||
|
||||
--*/
|
||||
{
|
||||
*TimerValue = EfiReadTsc ();
|
||||
return EFI_SUCCESS;
|
||||
}
|
140
Tools/Source/TianoTools/Common/PeiLib/ia32/Processor.c
Normal file
140
Tools/Source/TianoTools/Common/PeiLib/ia32/Processor.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2005, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
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:
|
||||
|
||||
Processor.c
|
||||
|
||||
Abstract:
|
||||
|
||||
--*/
|
||||
|
||||
#include "Tiano.h"
|
||||
#include "EfiJump.h"
|
||||
#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)
|
||||
#include EFI_GUID_DEFINITION (PeiTransferControl)
|
||||
|
||||
//
|
||||
// Prototypes
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TransferControlSetJump (
|
||||
IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
|
||||
IN EFI_JUMP_BUFFER *Jump
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TransferControlLongJump (
|
||||
IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
|
||||
IN EFI_JUMP_BUFFER *Jump
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FlushInstructionCacheFlush (
|
||||
IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS Start,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
//
|
||||
// Table declarations
|
||||
//
|
||||
EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = {
|
||||
TransferControlSetJump,
|
||||
TransferControlLongJump,
|
||||
sizeof (EFI_JUMP_BUFFER)
|
||||
};
|
||||
|
||||
EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = {
|
||||
FlushInstructionCacheFlush
|
||||
};
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
InstallEfiPeiTransferControl (
|
||||
IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Installs the pointer to the transfer control mechanism
|
||||
|
||||
Arguments:
|
||||
|
||||
This - Pointer to transfer control mechanism.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Successfully installed.
|
||||
|
||||
--*/
|
||||
{
|
||||
*This = &mTransferControl;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
InstallEfiPeiFlushInstructionCache (
|
||||
IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Installs the pointer to the flush instruction cache mechanism
|
||||
|
||||
Arguments:
|
||||
|
||||
This - Pointer to flush instruction cache mechanism.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Successfully installed
|
||||
|
||||
--*/
|
||||
{
|
||||
*This = &mFlushInstructionCache;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FlushInstructionCacheFlush (
|
||||
IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
|
||||
IN EFI_PHYSICAL_ADDRESS Start,
|
||||
IN UINT64 Length
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine would provide support for flushing the CPU instruction cache.
|
||||
In the case of IA32, this flushing is not necessary and is thus not implemented.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - Pointer to CPU Architectural Protocol interface
|
||||
Start - Start adddress in memory to flush
|
||||
Length - Length of memory to flush
|
||||
|
||||
Returns:
|
||||
|
||||
Status
|
||||
EFI_SUCCESS
|
||||
|
||||
--*/
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
223
Tools/Source/TianoTools/Common/PeiLib/ia32/ProcessorAsms.Asm
Normal file
223
Tools/Source/TianoTools/Common/PeiLib/ia32/ProcessorAsms.Asm
Normal file
@@ -0,0 +1,223 @@
|
||||
;
|
||||
; Copyright (c) 2004, Intel Corporation
|
||||
; All rights reserved. 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
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; 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:
|
||||
;
|
||||
; ProcessorAsms.Asm
|
||||
;
|
||||
; Abstract:
|
||||
; This is separated from processor.c to allow this functions to be built with /O1
|
||||
;
|
||||
; Notes:
|
||||
; - Masm uses "This", "ebx", etc as a directive.
|
||||
; - H2INC is still not embedded in our build process so I translated the struc manually.
|
||||
; - Unreferenced variables/arguments (This, NewBsp, NewStack) were causing compile errors and
|
||||
; did not know of "pragma" mechanism in MASM and I did not want to reduce the warning level.
|
||||
; Instead, I did a dummy referenced.
|
||||
;
|
||||
|
||||
.686P
|
||||
.MMX
|
||||
.MODEL SMALL
|
||||
.CODE
|
||||
|
||||
EFI_SUCCESS equ 0
|
||||
EFI_WARN_RETURN_FROM_LONG_JUMP equ 5
|
||||
|
||||
;
|
||||
; Generated by h2inc run manually
|
||||
;
|
||||
_EFI_JUMP_BUFFER STRUCT 2t
|
||||
_ebx DWORD ?
|
||||
_esi DWORD ?
|
||||
_edi DWORD ?
|
||||
_ebp DWORD ?
|
||||
_esp DWORD ?
|
||||
_eip DWORD ?
|
||||
_EFI_JUMP_BUFFER ENDS
|
||||
|
||||
EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
|
||||
|
||||
TransferControlSetJump PROTO C \
|
||||
_This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
|
||||
Jump:PTR EFI_JUMP_BUFFER
|
||||
|
||||
TransferControlLongJump PROTO C \
|
||||
_This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
|
||||
Jump:PTR EFI_JUMP_BUFFER
|
||||
|
||||
SwitchStacks PROTO C \
|
||||
EntryPoint:PTR DWORD, \
|
||||
Parameter:DWORD, \
|
||||
NewStack:PTR DWORD, \
|
||||
NewBsp:PTR DWORD
|
||||
|
||||
SwitchIplStacks PROTO C \
|
||||
EntryPoint:PTR DWORD, \
|
||||
Parameter1:DWORD, \
|
||||
Parameter2:DWORD, \
|
||||
NewStack:PTR DWORD, \
|
||||
NewBsp:PTR DWORD
|
||||
|
||||
;
|
||||
;Routine Description:
|
||||
;
|
||||
; This routine implements the IA32 variant of the SetJump call. Its
|
||||
; responsibility is to store system state information for a possible
|
||||
; subsequent LongJump.
|
||||
;
|
||||
;Arguments:
|
||||
;
|
||||
; Pointer to CPU context save buffer.
|
||||
;
|
||||
;Returns:
|
||||
;
|
||||
; EFI_SUCCESS
|
||||
;
|
||||
TransferControlSetJump PROC C \
|
||||
_This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
|
||||
Jump:PTR EFI_JUMP_BUFFER
|
||||
|
||||
mov eax, _This
|
||||
mov ecx, Jump
|
||||
mov (EFI_JUMP_BUFFER PTR [ecx])._ebx, ebx
|
||||
mov (EFI_JUMP_BUFFER PTR [ecx])._esi, esi
|
||||
mov (EFI_JUMP_BUFFER PTR [ecx])._edi, edi
|
||||
mov eax, [ebp]
|
||||
mov (EFI_JUMP_BUFFER PTR [ecx])._ebp, eax
|
||||
lea eax, [ebp+4]
|
||||
mov (EFI_JUMP_BUFFER PTR [ecx])._esp, eax
|
||||
mov eax, [ebp+4]
|
||||
mov (EFI_JUMP_BUFFER PTR [ecx])._eip, eax
|
||||
mov eax, EFI_SUCCESS
|
||||
|
||||
ret
|
||||
|
||||
TransferControlSetJump ENDP
|
||||
|
||||
;
|
||||
; Routine Description:
|
||||
;
|
||||
; This routine implements the IA32 variant of the LongJump call. Its
|
||||
; responsibility is restore the system state to the Context Buffer and
|
||||
; pass control back.
|
||||
;
|
||||
; Arguments:
|
||||
;
|
||||
; Pointer to CPU context save buffer.
|
||||
;
|
||||
; Returns:
|
||||
;
|
||||
; EFI_WARN_RETURN_FROM_LONG_JUMP
|
||||
;
|
||||
|
||||
TransferControlLongJump PROC C \
|
||||
_This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
|
||||
Jump:PTR EFI_JUMP_BUFFER
|
||||
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov eax, _This
|
||||
; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
|
||||
mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP
|
||||
mov ecx, Jump
|
||||
mov ebx, (EFI_JUMP_BUFFER PTR [ecx])._ebx
|
||||
mov esi, (EFI_JUMP_BUFFER PTR [ecx])._esi
|
||||
mov edi, (EFI_JUMP_BUFFER PTR [ecx])._edi
|
||||
mov ebp, (EFI_JUMP_BUFFER PTR [ecx])._ebp
|
||||
mov esp, (EFI_JUMP_BUFFER PTR [ecx])._esp
|
||||
add esp, 4 ;pop the eip
|
||||
jmp DWORD PTR (EFI_JUMP_BUFFER PTR [ecx])._eip
|
||||
mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
TransferControlLongJump ENDP
|
||||
|
||||
;
|
||||
; Routine Description:
|
||||
; This allows the caller to switch the stack and goes to the new entry point
|
||||
;
|
||||
; Arguments:
|
||||
; EntryPoint - Pointer to the location to enter
|
||||
; Parameter - Parameter to pass in
|
||||
; NewStack - New Location of the stack
|
||||
; NewBsp - New BSP
|
||||
;
|
||||
; Returns:
|
||||
;
|
||||
; Nothing. Goes to the Entry Point passing in the new parameters
|
||||
;
|
||||
SwitchStacks PROC C \
|
||||
EntryPoint:PTR DWORD, \
|
||||
Parameter:DWORD, \
|
||||
NewStack:PTR DWORD, \
|
||||
NewBsp:PTR DWORD
|
||||
|
||||
push ebx
|
||||
mov eax, NewBsp
|
||||
mov ebx, Parameter
|
||||
mov ecx, EntryPoint
|
||||
mov eax, NewStack
|
||||
mov esp, eax
|
||||
push ebx
|
||||
push 0
|
||||
jmp ecx
|
||||
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
SwitchStacks ENDP
|
||||
|
||||
;
|
||||
; Routine Description:
|
||||
; This allows the caller to switch the stack and goes to the new entry point
|
||||
;
|
||||
; Arguments:
|
||||
; EntryPoint - Pointer to the location to enter
|
||||
; Parameter1/Parameter2 - Parameter to pass in
|
||||
; NewStack - New Location of the stack
|
||||
; NewBsp - New BSP
|
||||
;
|
||||
; Returns:
|
||||
;
|
||||
; Nothing. Goes to the Entry Point passing in the new parameters
|
||||
;
|
||||
SwitchIplStacks PROC C \
|
||||
EntryPoint:PTR DWORD, \
|
||||
Parameter1:DWORD, \
|
||||
Parameter2:DWORD, \
|
||||
NewStack:PTR DWORD, \
|
||||
NewBsp:PTR DWORD
|
||||
|
||||
push ebx
|
||||
mov eax, NewBsp
|
||||
mov ebx, Parameter1
|
||||
mov edx, Parameter2
|
||||
mov ecx, EntryPoint
|
||||
mov eax, NewStack
|
||||
mov esp, eax
|
||||
|
||||
push edx
|
||||
push ebx
|
||||
call ecx
|
||||
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
SwitchIplStacks ENDP
|
||||
|
||||
END
|
||||
|
34
Tools/Source/TianoTools/Common/PeiLib/ia32/efijump.h
Normal file
34
Tools/Source/TianoTools/Common/PeiLib/ia32/efijump.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
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:
|
||||
|
||||
EfiJump.h
|
||||
|
||||
Abstract:
|
||||
|
||||
This is the Setjump/Longjump pair for an IA32 processor.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFI_JUMP_H_
|
||||
#define _EFI_JUMP_H_
|
||||
|
||||
typedef struct {
|
||||
UINT32 ebx;
|
||||
UINT32 esi;
|
||||
UINT32 edi;
|
||||
UINT32 ebp;
|
||||
UINT32 esp;
|
||||
UINT32 eip;
|
||||
} EFI_JUMP_BUFFER;
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user