Renamed remotely

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6024 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2008-09-27 05:35:54 +00:00
parent dd7881b21a
commit 82ed85bd1b
14 changed files with 0 additions and 0 deletions

View 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

View File

@@ -0,0 +1,93 @@
/*++
Copyright (c) 2004 - 2006, 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"
#include "EfiImage.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 - relocate unsupported
--*/
{
return EFI_UNSUPPORTED;
}
BOOLEAN
PeCoffLoaderImageFormatSupported (
IN UINT16 Machine
)
/*++
Routine Description:
Returns TRUE if the machine type of PE/COFF image is supported. Supported
does not mean the image can be executed it means the PE/COFF loader supports
loading and relocating of the image type. It's up to the caller to support
the entry point.
This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
& X64 images. Calling the entry point in a correct mannor is up to the
consumer of this library.
Arguments:
Machine - Machine type from the PE Header.
Returns:
TRUE - if this PE/COFF loader can load the image
FALSE - if this PE/COFF loader cannot load the image
--*/
{
if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) ||
(Machine == EFI_IMAGE_MACHINE_EBC)) {
return TRUE;
}
return FALSE;
}

View File

@@ -0,0 +1,85 @@
/*++
Copyright (c) 2004 - 2006, 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_
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 - relocate unsupported
--*/
;
BOOLEAN
PeCoffLoaderImageFormatSupported (
IN UINT16 Machine
)
/*++
Routine Description:
Returns TRUE if the machine type of PE/COFF image is supported. Supported
does not mean the image can be executed it means the PE/COFF loader supports
loading and relocating of the image type. It's up to the caller to support
the entry point.
This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
& X64 images. Calling the entry point in a correct mannor is up to the
consumer of this library.
Arguments:
Machine - Machine type from the PE Header.
Returns:
TRUE - if this PE/COFF loader can load the image
FALSE - if this PE/COFF loader cannot load the image
--*/
;
#endif

View File

@@ -0,0 +1,152 @@
/*++
Copyright (c) 2004 - 2007, 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:
PeiServicePointer.c
Abstract:
--*/
#include "Tiano.h"
#include "PeiApi.h"
#include "PeiLib.h"
#if (PI_SPECIFICATION_VERSION >= 0x00010000)
#ifdef EFI_NT_EMULATOR
EFI_PEI_SERVICES **gPeiServices;
#endif
VOID
SetPeiServicesTablePointer (
IN EFI_PEI_SERVICES **PeiServices
)
/*++
Routine Description:
Save PeiService pointer so that it can be retrieved anywhere.
Arguments:
PeiServices - The direct pointer to PeiServiceTable.
PhyscialAddress - The physcial address of variable PeiServices.
Returns:
NONE
--*/
{
#ifdef EFI_NT_EMULATOR
//
// For NT32, set EFI_PEI_SERVICES** to global variable.
//
gPeiServices = PeiServices;
#else
//
// For X86 processor,the EFI_PEI_SERVICES** is stored in the
// 4 bytes immediately preceding the Interrupt Descriptor Table.
//
UINTN IdtBaseAddress;
IdtBaseAddress = (UINTN)ReadIdtBase();
*(UINTN*)(IdtBaseAddress - 4) = (UINTN)PeiServices;
#endif
}
EFI_PEI_SERVICES **
GetPeiServicesTablePointer (
VOID
)
/*++
Routine Description:
Get PeiService pointer.
Arguments:
NONE.
Returns:
The direct pointer to PeiServiceTable.
--*/
{
EFI_PEI_SERVICES **PeiServices;
#ifdef EFI_NT_EMULATOR
//
// For NT32, set EFI_PEI_SERVICES** to global variable.
//
PeiServices = gPeiServices;
#else
//
// For X86 processor,the EFI_PEI_SERVICES** is stored in the
// 4 bytes immediately preceding the Interrupt Descriptor Table.
//
UINTN IdtBaseAddress;
IdtBaseAddress = (UINTN)ReadIdtBase();
PeiServices = (EFI_PEI_SERVICES **)(UINTN)(*(UINTN*)(IdtBaseAddress - 4));
#endif
return PeiServices;
}
VOID
MigrateIdtTable (
IN EFI_PEI_SERVICES **PeiServices
)
/*++
Routine Description:
Migrate IDT from CAR to real memory where preceded with 4 bytes for
storing PeiService pointer.
Arguments:
PeiServices - The direct pointer to PeiServiceTable.
Returns:
NONE.
--*/
{
#ifndef EFI_NT_EMULATOR
UINT16 IdtEntrySize;
UINTN OldIdtBase;
UINTN Size;
VOID *NewIdtBase;
EFI_STATUS Status;
IdtEntrySize = ReadIdtLimit();
OldIdtBase = ReadIdtBase();
Size = sizeof(PEI_IDT_TABLE) + (IdtEntrySize + 1);
Status = (*PeiServices)->AllocatePool (PeiServices, Size, &NewIdtBase);
ASSERT_PEI_ERROR (PeiServices, Status);
(*PeiServices)->CopyMem ((VOID*)((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), (VOID*)OldIdtBase, (IdtEntrySize + 1));
SetIdtBase(((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), IdtEntrySize);
SetPeiServicesTablePointer(PeiServices);
#endif
}
#endif

View File

@@ -0,0 +1,47 @@
/*++
Copyright 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:
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;
}

View File

@@ -0,0 +1,140 @@
/*++
Copyright (c) 2004 - 2008, 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 VOID *Jump
);
EFI_STATUS
EFIAPI
TransferControlLongJump (
IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
IN VOID *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;
}

View 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

View File

@@ -0,0 +1,207 @@
#
# 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
#
#
#
#include "EfiBind.h"
#------------------------------------------------------------------------------
.686P:
.MMX:
#.MODEL SMALL
.CODE:
#------------------------------------------------------------------------------
.globl ASM_PFX(TransferControlSetJump)
.globl ASM_PFX(TransferControlLongJump)
.globl ASM_PFX(SwitchStacks)
.globl ASM_PFX(SwitchIplStacks)
.equ EFI_SUCCESS, 0
.equ EFI_WARN_RETURN_FROM_LONG_JUMP, 5
#
# typedef struct {
# UINT32 ebx;
# UINT32 esi;
# UINT32 edi;
# UINT32 ebp;
# UINT32 esp;
# UINT32 eip;
#} EFI_JUMP_BUFFER;
#
#typedef
#EFI_STATUS
#(EFIAPI *EFI_PEI_TRANSFER_CONTROL_SET_JUMP) (
# IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
# OUT EFI_JUMP_BUFFER *Context
# );
#
#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
#
ASM_PFX(TransferControlSetJump):
push %ebp
mov %esp,%ebp
mov 0x8(%ebp),%eax
mov 0xc(%ebp),%ecx
mov %ebx,(%ecx)
mov %esi,0x4(%ecx)
mov %edi,0x8(%ecx)
mov 0x0(%ebp),%eax
mov %eax,0xc(%ecx)
lea 0x4(%ebp),%eax
mov %eax,0x10(%ecx)
mov 0x4(%ebp),%eax
mov %eax,0x14(%ecx)
mov $0x0,%eax
leave
ret
#typedef
#EFI_STATUS
#(EFIAPI *EFI_PEI_TRANSFER_CONTROL_LONG_JUMP) (
# IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
# IN EFI_JUMP_BUFFER *Context
# );
#
# 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
#
ASM_PFX(TransferControlLongJump):
push %ebp
mov %esp,%ebp
push %ebx
push %esi
push %edi
mov 0x8(%ebp),%eax
mov $0x5,%eax
mov 0xc(%ebp),%ecx
mov (%ecx),%ebx
mov 0x4(%ecx),%esi
mov 0x8(%ecx),%edi
mov 0xc(%ecx),%ebp
mov 0x10(%ecx),%esp
add $0x4,%esp
jmp *0x14(%ecx)
mov $0x5,%eax
pop %edi
pop %esi
pop %ebx
leave
ret
#
# 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
ASM_PFX(SwitchStacks):
push %ebp
mov %esp,%ebp
push %ebx
mov 0x14(%ebp),%eax
mov 0xc(%ebp),%ebx
mov 0x8(%ebp),%ecx
mov 0x10(%ebp),%eax
mov %eax,%esp
push %ebx
push $0x0
jmp *%ecx
pop %ebx
leave
ret
#
# 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
ASM_PFX(SwitchIplStacks):
push %ebp
mov %esp,%ebp
push %ebx
mov 0x18(%ebp),%eax
mov 0xc(%ebp),%ebx
mov 0x10(%ebp),%edx
mov 0x8(%ebp),%ecx
mov 0x14(%ebp),%eax
mov %eax,%esp
push %edx
push %ebx
call *%ecx
pop %ebx
leave
ret
#SwitchIplStacks ENDP

View File

@@ -0,0 +1,69 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, 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:
#
# ReadIdtBase.Asm
#
# Abstract:
#
# ReadIdtBase function
#
# Notes:
#
#include "EfiBind.h"
#------------------------------------------------------------------------------
.586:
#.MODEL flat,C
.code:
.globl ASM_PFX(ReadIdtBasea)
.globl ASM_PFX(ReadIdtLimita)
#------------------------------------------------------------------------------
# UINTN
# ReadIdtBase (
# void
# )
#
# Abstract: Returns physical address of IDTR
#
ASM_PFX(ReadIdtBasea):
push %ebp
mov %esp,%ebp
add $0xfffffff8,%esp
sidtl 0xfffffffa(%ebp)
mov 0xfffffffc(%ebp),%eax
leave
ret
#------------------------------------------------------------------------------
# UINT16
# ReadIdtLimit (
# void
# )
#
# Abstract: Returns Limit of IDTR
#
ASM_PFX(ReadIdtLimita):
push %ebp
mov %esp,%ebp
add $0xfffffff8,%esp
sidtl 0xfffffffa(%ebp)
mov 0xfffffffa(%ebp),%ax
leave
ret

View File

@@ -0,0 +1,60 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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:
;
; ReadIdtBase.Asm
;
; Abstract:
;
; ReadIdtBase function
;
; Notes:
;
;------------------------------------------------------------------------------
.586
.model flat,C
.mmx
.code
;------------------------------------------------------------------------------
; UINTN
; ReadIdtBase (
; void
; )
;
; Abstract: Returns physical address of IDTR
;
ReadIdtBase PROC C PUBLIC
LOCAL IdtrBuf:FWORD
sidt IdtrBuf
mov eax, DWORD PTR IdtrBuf + 2
ret
ReadIdtBase ENDP
;------------------------------------------------------------------------------
; UINT16
; ReadIdtLimit (
; void
; )
;
; Abstract: Returns Limit of IDTR
;
ReadIdtLimit PROC C PUBLIC
LOCAL IdtrBuf:FWORD
sidt IdtrBuf
mov ax, WORD PTR IdtrBuf
ret
ReadIdtLimit ENDP
END

View File

@@ -0,0 +1,71 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2008, 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:
#
# SupportItpDebug.asm
#
# Abstract:
#
# This is the code for debuging IA32, to add a break hook at loading every module
#
#------------------------------------------------------------------------------
#include <EfiBind.h>
# PROC:PRIVATE
.686P:
.MMX:
#.MODEL SMALL
.CODE:
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
.globl ASM_PFX(AsmEfiSetBreakSupport)
# VOID
# AsmEfiSetBreakSupport (
# IN UINTN LoadAddr
# )
#------------------------------------------------------------------------------
ASM_PFX(AsmEfiSetBreakSupport):
push %ebp
mov %esp, %ebp
mov 0x8(%ebp),%eax
movw $60000, %dx
outl %eax, %dx
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ret
#AsmEfiSetBreakSupport ENDP

View File

@@ -0,0 +1,69 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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:
;
; SupportItpDebug.asm
;
; Abstract:
;
; This is the code for debuging IA32, to add a break hook at loading every module
;
;------------------------------------------------------------------------------
; PROC:PRIVATE
.686P
.MMX
.MODEL SMALL
.CODE
AsmEfiSetBreakSupport PROTO C LoadAddr:DWORD
;------------------------------------------------------------------------------
; VOID
; AsmEfiSetBreakSupport (
; IN UINTN LoadAddr
; )
;------------------------------------------------------------------------------
AsmEfiSetBreakSupport PROC C LoadAddr:DWORD
mov eax, LoadAddr
mov dx, 60000
out dx, eax
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ret
AsmEfiSetBreakSupport ENDP
END

View File

@@ -0,0 +1,50 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, 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:
#
# WriteIdt.Asm
#
# Abstract:
#
# SetIdtBase function
#
# Notes:
#
#include "EfiBind.h"
#------------------------------------------------------------------------------
.586:
#.MODEL flat,C
.code:
#------------------------------------------------------------------------------
.globl ASM_PFX(SetIdtBase)
# void
# SetIdtBase (
# UINT32 IdtBase,
# UINT16 IdtLimit
# )
#
# Abstract: Set IDTR with the given physical address
#
ASM_PFX(SetIdtBase):
push %ebp
mov %esp,%ebp
add $0xfffffff8,%esp
mov 0x8(%ebp),%eax
mov 0xc(%ebp),%cx
mov %eax,0xfffffffc(%ebp)
mov %cx,0xfffffffa(%ebp)
lidtl 0xfffffffa(%ebp)
leave
ret

View File

@@ -0,0 +1,49 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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:
;
; WriteIdt.Asm
;
; Abstract:
;
; SetIdtBase function
;
; Notes:
;
;------------------------------------------------------------------------------
.586p
.model flat,C
.mmx
.code
;------------------------------------------------------------------------------
; void
; SetIdtBase (
; UINT32 IdtBase,
; UINT16 IdtLimit
; )
;
; Abstract: Set IDTR with the given physical address
;
SetIdtBase PROC C PUBLIC IdtBase:DWORD, IdtLimit:WORD
LOCAL IdtrBuf:FWORD
mov eax, IdtBase
mov cx, IdtLimit
mov DWORD PTR IdtrBuf + 2, eax ; write IDT base address
mov WORD PTR IdtrBuf, cx ; write ITD limit
lidt FWORD PTR IdtrBuf
ret
SetIdtBase ENDP
END