UnixPkg: Remove UnixPkg files (It is replaced by EmulatorPkg)

For now the UnixPkg/Deprecated.txt file is retained to indicate
that EmulatorPkg should be used instead.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14518 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Jordan Justen 2013-07-29 21:09:55 +00:00 committed by jljusten
parent bf6ee6c7c3
commit 5d71a30480
330 changed files with 0 additions and 54926 deletions

View File

@ -1,8 +0,0 @@
set confirm off
set output-radix 16
b SecGdbScriptBreak
command
silent
source SecMain.gdb
c
end

View File

@ -1,101 +0,0 @@
/**@file
Copyright (c) 2006 - 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
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:
BootMode.c
Abstract:
Tiano PEIM to provide the platform support functionality within Unix
**/
//
// The package level header files this module uses
//
#include <PiPei.h>
//
// The protocols, PPI and GUID defintions for this module
//
#include <Ppi/MasterBootMode.h>
#include <Ppi/BootInRecoveryMode.h>
//
// The Library classes this module consumes
//
#include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
//
// Module globals
//
EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiMasterBootModePpiGuid,
NULL
};
EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiBootInRecoveryModePpiGuid,
NULL
};
EFI_STATUS
EFIAPI
InitializeBootMode (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
)
/*++
Routine Description:
Peform the boot mode determination logic
Arguments:
PeiServices - General purpose services available to every PEIM.
Returns:
Status - EFI_SUCCESS if the boot mode could be set
--*/
// TODO: FfsHeader - add argument and description to function comment
{
EFI_STATUS Status;
UINTN BootMode;
DEBUG ((EFI_D_ERROR, "Unix Boot Mode PEIM Loaded\n"));
//
// Let's assume things are OK if not told otherwise
// Should we read an environment variable in order to easily change this?
//
BootMode = BOOT_WITH_FULL_CONFIGURATION;
Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
ASSERT_EFI_ERROR (Status);
Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
ASSERT_EFI_ERROR (Status);
if (BootMode == BOOT_IN_RECOVERY_MODE) {
Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
ASSERT_EFI_ERROR (Status);
}
return Status;
}

View File

@ -1,55 +0,0 @@
## @file
# Component description file for BootMode module
#
# This module provides platform specific function to detect boot mode.
# Copyright (c) 2006 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BootModePei
FILE_GUID = f3ff9aee-8985-11db-b133-0040d02b1835
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
ENTRY_POINT = InitializeBootMode
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
BootModePei.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
PeiServicesTablePointerLib
PeiServicesLib
BaseLib
PeimEntryPoint
DebugLib
[Ppis]
gEfiPeiMasterBootModePpiGuid # PPI ALWAYS_PRODUCED
gEfiPeiBootInRecoveryModePpiGuid # PPI SOMETIMES_PRODUCED
[Depex]
TRUE

View File

@ -1,188 +0,0 @@
======================
= Code Contributions =
======================
To make a contribution to a TianoCore project, follow these steps.
1. Create a change description in the format specified below to
use in the source control commit log.
2. Your commit message must include your "Signed-off-by" signature,
and "Contributed-under" message.
3. Your "Contributed-under" message explicitly states that the
contribution is made under the terms of the specified
contribution agreement. Your "Contributed-under" message
must include the name of contribution agreement and version.
For example: Contributed-under: TianoCore Contribution Agreement 1.0
The "TianoCore Contribution Agreement" is included below in
this document.
4. Submit your code to the TianoCore project using the process
that the project documents on its web page. If the process is
not documented, then submit the code on development email list
for the project.
=======================================
= Change Description / Commit Message =
=======================================
Your change description should use the standard format for a
commit message, and must include your "Signed-off-by" signature
and the "Contributed-under" message.
== Sample Change Description / Commit Message =
=== Definitions for sample change description ===
* "CodeModule" is a short idenfier for the affected code. For
example MdePkg, or MdeModulePkg UsbBusDxe.
* "Brief-single-line-summary" is a short summary of the change.
* The entire first line should be less than ~70 characters.
* "Full-commit-message" a verbose multiple line comment describing
the change. Each line should be less than ~70 characters.
* "Contributed-under" explicitely states that the contribution is
made under the terms of the contribtion agreement. This
agreement is included below in this document.
* "Signed-off-by" is the contributor's signature identifying them
by their real/legal name and their email address.
=== Start of sample change description / commit message ===
CodeModule: Brief-single-line-summary
Full-commit-message
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Contributor Name <contributor@email.server>
=== End of sample change description / commit message ===
========================================
= TianoCore Contribution Agreement 1.0 =
========================================
INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION,
INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE
PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE
TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE
TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR
REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE
CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS
OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS
AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT
USE THE CONTENT.
Unless otherwise indicated, all Content made available on the TianoCore
site is provided to you under the terms and conditions of the BSD
License ("BSD"). A copy of the BSD License is available at
http://opensource.org/licenses/bsd-license.php
or when applicable, in the associated License.txt file.
Certain other content may be made available under other licenses as
indicated in or with such Content. (For example, in a License.txt file.)
You accept and agree to the following terms and conditions for Your
present and future Contributions submitted to TianoCore site. Except
for the license granted to Intel hereunder, You reserve all right,
title, and interest in and to Your Contributions.
== SECTION 1: Definitions ==
* "You" or "Contributor" shall mean the copyright owner or legal
entity authorized by the copyright owner that is making a
Contribution hereunder. All other entities that control, are
controlled by, or are under common control with that entity are
considered to be a single Contributor. For the purposes of this
definition, "control" means (i) the power, direct or indirect, to
cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%)
or more of the outstanding shares, or (iii) beneficial ownership
of such entity.
* "Contribution" shall mean any original work of authorship,
including any modifications or additions to an existing work,
that is intentionally submitted by You to the TinaoCore site for
inclusion in, or documentation of, any of the Content. For the
purposes of this definition, "submitted" means any form of
electronic, verbal, or written communication sent to the
TianoCore site or its representatives, including but not limited
to communication on electronic mailing lists, source code
control systems, and issue tracking systems that are managed by,
or on behalf of, the TianoCore site for the purpose of
discussing and improving the Content, but excluding
communication that is conspicuously marked or otherwise
designated in writing by You as "Not a Contribution."
== SECTION 2: License for Contributions ==
* Contributor hereby agrees that redistribution and use of the
Contribution in source and binary forms, with or without
modification, are permitted provided that the following
conditions are met:
** Redistributions of source code must retain the Contributor's
copyright notice, this list of conditions and the following
disclaimer.
** Redistributions in binary form must reproduce the Contributor's
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Disclaimer. None of the names of Contributor, Intel, or the names
of their respective contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.
* Contributor grants a license (with the right to sublicense) under
claims of Contributor's patents that Contributor can license that
are infringed by the Contribution (as delivered by Contributor) to
make, use, distribute, sell, offer for sale, and import the
Contribution and derivative works thereof solely to the minimum
extent necessary for licensee to exercise the granted copyright
license; this patent license applies solely to those portions of
the Contribution that are unmodified. No hardware per se is
licensed.
* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE
CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
== SECTION 3: Representations ==
* You represent that You are legally entitled to grant the above
license. If your employer(s) has rights to intellectual property
that You create that includes Your Contributions, You represent
that You have received permission to make Contributions on behalf
of that employer, that Your employer has waived such rights for
Your Contributions.
* You represent that each of Your Contributions is Your original
creation (see Section 4 for submissions on behalf of others).
You represent that Your Contribution submissions include complete
details of any third-party license or other restriction
(including, but not limited to, related patents and trademarks)
of which You are personally aware and which are associated with
any part of Your Contributions.
== SECTION 4: Third Party Contributions ==
* Should You wish to submit work that is not Your original creation,
You may submit it to TianoCore site separately from any
Contribution, identifying the complete details of its source
and of any license or other restriction (including, but not
limited to, related patents, trademarks, and license agreements)
of which You are personally aware, and conspicuously marking the
work as "Submitted on behalf of a third-party: [named here]".
== SECTION 5: Miscellaneous ==
* Applicable Laws. Any claims arising under or relating to this
Agreement shall be governed by the internal substantive laws of
the State of Delaware or federal courts located in Delaware,
without regard to principles of conflict of laws.
* Language. This Agreement is in the English language only, which
language shall be controlling in all respects, and all versions
of this Agreement in any other language shall be for accommodation
only and shall not be binding. All communications and notices made
or given pursuant to this Agreement, and all documentation and
support to be provided, unless otherwise noted, shall be in the
English language.

View File

@ -1,556 +0,0 @@
/*++
Copyright (c) 2006 - 2011, 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
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:
Cpu.c
Abstract:
Unix Emulation Architectural Protocol Driver as defined in Tiano.
This CPU module abstracts the interrupt subsystem of a platform and
the CPU-specific setjump/long pair. Other services are not implemented
in this driver.
--*/
#include <FrameworkDxe.h>
#include <IndustryStandard/SmBios.h>
#include <Protocol/Cpu.h>
#include <Protocol/Smbios.h>
#include <Guid/DataHubRecords.h>
#include <Protocol/CpuIo2.h>
#include <Protocol/FrameworkHii.h>
#include <Protocol/UnixThunk.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/HiiLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UnixLib.h>
#include "CpuDriver.h"
#include "UnixDxe.h"
#include <Protocol/UnixIo.h>
#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
CPU_ARCH_PROT_PRIVATE_SIGNATURE,
NULL,
{
UnixFlushCpuDataCache,
UnixEnableInterrupt,
UnixDisableInterrupt,
UnixGetInterruptState,
UnixInit,
UnixRegisterInterruptHandler,
UnixGetTimerValue,
UnixSetMemoryAttributes,
0,
4
},
{
{
CpuMemoryServiceRead,
CpuMemoryServiceWrite
},
{
CpuIoServiceRead,
CpuIoServiceWrite
}
},
TRUE
};
//
// Service routines for the driver
//
EFI_STATUS
EFIAPI
UnixFlushCpuDataCache (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS Start,
IN UINT64 Length,
IN EFI_CPU_FLUSH_TYPE FlushType
)
/*++
Routine Description:
This routine would provide support for flushing the CPU data cache.
In the case of UNIX emulation environment, this flushing is not necessary and
is thus not implemented.
Arguments:
Pointer to CPU Architectural Protocol interface
Start adddress in memory to flush
Length of memory to flush
Flush type
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
// TODO: FlushType - add argument and description to function comment
// TODO: EFI_UNSUPPORTED - add return value to function comment
{
if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) {
//
// Only WB flush is supported. We actually need do nothing on UNIX emulator
// environment. Classify this to follow EFI spec
//
return EFI_SUCCESS;
}
//
// Other flush types are not supported by UNIX emulator
//
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixEnableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
)
/*++
Routine Description:
This routine provides support for emulation of the interrupt enable of the
the system. For our purposes, CPU enable is just a BOOLEAN that the Timer
Architectural Protocol observes in order to defer behaviour while in its
emulated interrupt, or timer tick.
Arguments:
Pointer to CPU Architectural Protocol interface
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = TRUE;
gUnix->EnableInterrupt ();
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixDisableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
)
/*++
Routine Description:
This routine provides support for emulation of the interrupt disable of the
the system. For our purposes, CPU enable is just a BOOLEAN that the Timer
Architectural Protocol observes in order to defer behaviour while in its
emulated interrupt, or timer tick.
Arguments:
Pointer to CPU Architectural Protocol interface
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = FALSE;
gUnix->DisableInterrupt ();
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixGetInterruptState (
IN EFI_CPU_ARCH_PROTOCOL *This,
OUT BOOLEAN *State
)
/*++
Routine Description:
This routine provides support for emulation of the interrupt disable of the
the system. For our purposes, CPU enable is just a BOOLEAN that the Timer
Architectural Protocol observes in order to defer behaviour while in its
emulated interrupt, or timer tick.
Arguments:
Pointer to CPU Architectural Protocol interface
Returns:
Status
EFI_SUCCESS
--*/
// TODO: This - add argument and description to function comment
// TODO: State - add argument and description to function comment
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
if (State == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
*State = Private->InterruptState;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixInit (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_CPU_INIT_TYPE InitType
)
/*++
Routine Description:
This routine would support generation of a CPU INIT. At
present, this code does not provide emulation.
Arguments:
Pointer to CPU Architectural Protocol interface
INIT Type
Returns:
Status
EFI_UNSUPPORTED - not yet implemented
--*/
// TODO: This - add argument and description to function comment
// TODO: InitType - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixRegisterInterruptHandler (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
)
/*++
Routine Description:
This routine would support registration of an interrupt handler. At
present, this code does not provide emulation.
Arguments:
Pointer to CPU Architectural Protocol interface
Pointer to interrupt handlers
Interrupt type
Returns:
Status
EFI_UNSUPPORTED - not yet implemented
--*/
// TODO: This - add argument and description to function comment
// TODO: InterruptType - add argument and description to function comment
// TODO: InterruptHandler - add argument and description to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
//
// Do parameter checking for EFI spec conformance
//
if (InterruptType < 0 || InterruptType > 0xff) {
return EFI_UNSUPPORTED;
}
//
// Do nothing for Nt32 emulation
//
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixGetTimerValue (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN UINT32 TimerIndex,
OUT UINT64 *TimerValue,
OUT UINT64 *TimerPeriod OPTIONAL
)
/*++
Routine Description:
This routine would support querying of an on-CPU timer. At present,
this code does not provide timer emulation.
Arguments:
This - Pointer to CPU Architectural Protocol interface
TimerIndex - Index of given CPU timer
TimerValue - Output of the timer
TimerPeriod - Output of the timer period
Returns:
EFI_UNSUPPORTED - not yet implemented
EFI_INVALID_PARAMETER - TimeValue is NULL
--*/
{
if (TimerValue == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// No timer supported
//
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
UnixSetMemoryAttributes (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN UINT64 Attributes
)
/*++
Routine Description:
This routine would support querying of an on-CPU timer. At present,
this code does not provide timer emulation.
Arguments:
Pointer to CPU Architectural Protocol interface
Start address of memory region
The size in bytes of the memory region
The bit mask of attributes to set for the memory region
Returns:
Status
EFI_UNSUPPORTED - not yet implemented
--*/
// TODO: This - add argument and description to function comment
// TODO: BaseAddress - add argument and description to function comment
// TODO: Length - add argument and description to function comment
// TODO: Attributes - add argument and description to function comment
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
{
CPU_ARCH_PROTOCOL_PRIVATE *Private;
//
// Check for invalid parameter for Spec conformance
//
if (Length == 0) {
return EFI_INVALID_PARAMETER;
}
//
// Do nothing for Nt32 emulation
//
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
/**
Logs SMBIOS record.
@param Smbios Pointer to SMBIOS protocol instance.
@param Buffer Pointer to the data buffer.
**/
VOID
LogSmbiosData (
IN EFI_SMBIOS_PROTOCOL *Smbios,
IN UINT8 *Buffer
)
{
EFI_STATUS Status;
EFI_SMBIOS_HANDLE SmbiosHandle;
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->Add (
Smbios,
NULL,
&SmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER*)Buffer
);
ASSERT_EFI_ERROR (Status);
}
VOID
CpuUpdateSmbios (
VOID
)
/*++
Routine Description:
This function will log processor version and frequency data to data hub.
Arguments:
Event - Event whose notification function is being invoked.
Context - Pointer to the notification function's context.
Returns:
None.
--*/
{
EFI_STATUS Status;
EFI_SMBIOS_PROTOCOL *Smbios;
UINT32 TotalSize;
EFI_HII_HANDLE HiiHandle;
STRING_REF Token;
UINTN CpuVerStrLen;
EFI_STRING CpuVerStr;
SMBIOS_TABLE_TYPE4 *SmbiosRecord;
CHAR8 *OptionalStrStart;
//
// Locate Smbios protocol.
//
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
if (EFI_ERROR (Status)) {
return;
}
//
// Initialize strings to HII database
//
HiiHandle = HiiAddPackages (
&gEfiCallerIdGuid,
NULL,
CpuStrings,
NULL
);
ASSERT (HiiHandle != NULL);
Token = STRING_TOKEN (STR_INTEL_GENUINE_PROCESSOR);
CpuVerStr = HiiGetPackageString(&gEfiCallerIdGuid, Token, NULL);
CpuVerStrLen = StrLen(CpuVerStr);
ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH);
TotalSize = sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1;
SmbiosRecord = AllocatePool(TotalSize);
ZeroMem(SmbiosRecord, TotalSize);
SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION;
SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE4);
//
// Make handle chosen by smbios protocol.add automatically.
//
SmbiosRecord->Hdr.Handle = 0;
//
// Processor version is the 1st string.
//
SmbiosRecord->ProcessorVersion = 1;
//
// Store CPU frequency data record to data hub - It's an emulator so make up a value
//
SmbiosRecord->CurrentSpeed = 1234;
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
UnicodeStrToAsciiStr(CpuVerStr, OptionalStrStart);
//
// Now we have got the full smbios record, call smbios protocol to add this record.
//
LogSmbiosData(Smbios, (UINT8 *) SmbiosRecord);
FreePool (SmbiosRecord);
}
EFI_STATUS
EFIAPI
InitializeCpu (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initialize the state information for the CPU Architectural Protocol
Arguments:
ImageHandle of the loaded driver
Pointer to the System Table
Returns:
Status
EFI_SUCCESS - protocol instance can be published
EFI_OUT_OF_RESOURCES - cannot allocate protocol data structure
EFI_DEVICE_ERROR - cannot create the thread
--*/
// TODO: SystemTable - add argument and description to function comment
{
EFI_STATUS Status;
CpuUpdateSmbios ();
Status = gBS->InstallMultipleProtocolInterfaces (
&mCpuTemplate.Handle,
&gEfiCpuArchProtocolGuid, &mCpuTemplate.Cpu,
&gEfiCpuIo2ProtocolGuid, &mCpuTemplate.CpuIo,
NULL
);
ASSERT_EFI_ERROR (Status);
DEBUG ((EFI_D_ERROR, "CPU Architectural Protocol Loaded\n"));
return Status;
}

View File

@ -1,65 +0,0 @@
## @file
# Component description file for Cpu module.
#
# This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair.
# Copyright (c) 2006 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = Cpu
FILE_GUID = f3794b60-8985-11db-8e53-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = InitializeCpu
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
CpuIo.c
Cpu.c
CpuDriver.h
Strings.uni
[Packages]
IntelFrameworkPkg/IntelFrameworkPkg.dec
UnixPkg/UnixPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
BaseMemoryLib
UefiDriverEntryPoint
UefiLib
HiiLib
DebugLib
BaseLib
UnixLib
[Protocols]
gEfiUnixIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED
gEfiSmbiosProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiHiiProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiCpuIo2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
[Depex]
gEfiSmbiosProtocolGuid

View File

@ -1,163 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
CpuDriver.h
Abstract:
UNIX Emulation Architectural Protocol Driver as defined in Tiano.
--*/
#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
extern UINT8 CpuStrings[];
//
// Internal Data Structures
//
#define CPU_ARCH_PROT_PRIVATE_SIGNATURE SIGNATURE_32 ('c', 'a', 'p', 'd')
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
EFI_CPU_ARCH_PROTOCOL Cpu;
EFI_CPU_IO2_PROTOCOL CpuIo;
//
// Local Data for CPU interface goes here
//
BOOLEAN InterruptState;
} CPU_ARCH_PROTOCOL_PRIVATE;
#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
CPU_ARCH_PROTOCOL_PRIVATE, \
Cpu, \
CPU_ARCH_PROT_PRIVATE_SIGNATURE \
)
EFI_STATUS
EFIAPI
CpuMemoryServiceRead (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
CpuMemoryServiceWrite (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
CpuIoServiceRead (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
);
EFI_STATUS
EFIAPI
CpuIoServiceWrite (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
);
EFI_STATUS
EFIAPI
InitializeCpu (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
EFI_STATUS
EFIAPI
UnixFlushCpuDataCache (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS Start,
IN UINT64 Length,
IN EFI_CPU_FLUSH_TYPE FlushType
);
EFI_STATUS
EFIAPI
UnixEnableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
);
EFI_STATUS
EFIAPI
UnixDisableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
);
EFI_STATUS
EFIAPI
UnixGetInterruptState (
IN EFI_CPU_ARCH_PROTOCOL *This,
OUT BOOLEAN *State
);
EFI_STATUS
EFIAPI
UnixInit (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_CPU_INIT_TYPE InitType
);
EFI_STATUS
EFIAPI
UnixRegisterInterruptHandler (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
);
EFI_STATUS
EFIAPI
UnixGetTimerValue (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN UINT32 TimerIndex,
OUT UINT64 *TimerValue,
OUT UINT64 *TimerPeriod OPTIONAL
);
EFI_STATUS
EFIAPI
UnixSetMemoryAttributes (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN UINT64 Attributes
);
#endif

View File

@ -1,347 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
CpuIo.c
Abstract:
This is the code that publishes the CPU I/O Protocol.
The intent herein is to have a single I/O service that can load
as early as possible, extend into runtime, and be layered upon by
the implementations of architectural protocols and the PCI Root
Bridge I/O Protocol.
--*/
#include <FrameworkDxe.h>
#include <Protocol/Cpu.h>
#include <Protocol/DataHub.h>
#include <Guid/DataHubRecords.h>
#include <Protocol/CpuIo2.h>
#include <Protocol/FrameworkHii.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/HiiLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <CpuDriver.h>
#define IA32_MAX_IO_ADDRESS 0xFFFF
#define IA32_MAX_MEM_ADDRESS 0xFFFFFFFF
EFI_STATUS
CpuIoCheckAddressRange (
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN VOID *Buffer,
IN UINT64 Limit
);
EFI_STATUS
EFIAPI
CpuMemoryServiceRead (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform the Memory Access Read service for the CPU I/O Protocol
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the Memory access
Count of the number of accesses to perform
Pointer to the buffer to read or write from memory
Returns:
Status
EFI_SUCCESS - The data was read from or written to the EFI
System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width,
and Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
{
EFI_STATUS Status;
if (!Buffer) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuMemoryServiceWrite (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform the Memory Access Read service for the CPU I/O Protocol
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the Memory access
Count of the number of accesses to perform
Pointer to the buffer to read or write from memory
Returns:
Status
EFI_SUCCESS - The data was read from or written to the EFI System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width, and
Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
{
EFI_STATUS Status;
if (!Buffer) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuIoServiceRead (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
/*++
Routine Description:
This is the service that implements the I/O read
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the I/O access
Count of the number of accesses to perform
Pointer to the buffer to read or write from I/O space
Returns:
Status
EFI_SUCCESS - The data was read from or written to the EFI System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width, and
Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
// TODO: UserAddress - add argument and description to function comment
// TODO: UserBuffer - add argument and description to function comment
{
UINTN Address;
EFI_STATUS Status;
if (!UserBuffer) {
return EFI_INVALID_PARAMETER;
}
Address = (UINTN) UserAddress;
if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CpuIoServiceWrite (
IN EFI_CPU_IO2_PROTOCOL *This,
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
/*++
Routine Description:
This is the service that implements the I/O Write
Arguments:
Pointer to an instance of the CPU I/O Protocol
Width of the Memory Access
Address of the I/O access
Count of the number of accesses to perform
Pointer to the buffer to read or write from I/O space
Returns:
Status
Status
EFI_SUCCESS - The data was read from or written to the EFI System.
EFI_INVALID_PARAMETER - Width is invalid for this EFI System.
EFI_INVALID_PARAMETER - Buffer is NULL.
EFI_UNSUPPORTED - The Buffer is not aligned for the given Width.
EFI_UNSUPPORTED - The address range specified by Address, Width, and
Count is not valid for this EFI System.
--*/
// TODO: This - add argument and description to function comment
// TODO: UserAddress - add argument and description to function comment
// TODO: UserBuffer - add argument and description to function comment
{
UINTN Address;
EFI_STATUS Status;
if (!UserBuffer) {
return EFI_INVALID_PARAMETER;
}
Address = (UINTN) UserAddress;
if (Width >= EfiCpuIoWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Do nothing for Nt32 version
//
return EFI_SUCCESS;
}
EFI_STATUS
CpuIoCheckAddressRange (
IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN VOID *Buffer,
IN UINT64 Limit
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Width - TODO: add argument description
Address - TODO: add argument description
Count - TODO: add argument description
Buffer - TODO: add argument description
Limit - TODO: add argument description
Returns:
EFI_UNSUPPORTED - TODO: Add description for return value
EFI_UNSUPPORTED - TODO: Add description for return value
EFI_UNSUPPORTED - TODO: Add description for return value
EFI_SUCCESS - TODO: Add description for return value
--*/
{
UINTN AlignMask;
if (Address > Limit) {
return EFI_UNSUPPORTED;
}
//
// For FiFo type, the target address won't increase during the access, so treat count as 1
//
if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {
Count = 1;
}
Width = Width & 0x03;
if (Address - 1 + (1 << Width) * Count > Limit) {
return EFI_UNSUPPORTED;
}
AlignMask = (1 << Width) - 1;
if ((UINTN) Buffer & AlignMask) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,156 +0,0 @@
/*++
Copyright (c) 2006 - 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
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:
FvbInfo.c
Abstract:
Defines data structure that is the volume header found.These data is intent
to decouple FVB driver with FV header.
--*/
#include "PiDxe.h"
#include <Guid/EventGroup.h>
#include <Protocol/FirmwareVolumeBlock.h>
#include <Protocol/DevicePath.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Library/DevicePathLib.h>
#include <Guid/FirmwareFileSystem2.h>
#include <Guid/SystemNvDataGuid.h>
typedef struct {
UINT64 FvLength;
EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
//
// EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
//
EFI_FV_BLOCK_MAP_ENTRY End[1];
} EFI_FVB_MEDIA_INFO;
EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
//
// Recovery BOIS FVB
//
{
FixedPcdGet32 (PcdUnixFlashFvRecoverySize),
{
{
0,
}, // ZeroVector[16]
EFI_FIRMWARE_FILE_SYSTEM2_GUID,
FixedPcdGet32 (PcdUnixFlashFvRecoverySize),
EFI_FVH_SIGNATURE,
EFI_FVB2_READ_ENABLED_CAP |
EFI_FVB2_READ_STATUS |
EFI_FVB2_WRITE_ENABLED_CAP |
EFI_FVB2_WRITE_STATUS |
EFI_FVB2_ERASE_POLARITY,
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
0, // CheckSum
0, // ExtHeaderOffset
{
0,
}, // Reserved[1]
2, // Revision
{
{
FixedPcdGet32 (PcdUnixFlashFvRecoverySize)/FixedPcdGet32 (PcdUnixFirmwareBlockSize),
FixedPcdGet32 (PcdUnixFirmwareBlockSize),
}
}
},
{
{
0,
0
}
}
},
//
// Systen NvStorage FVB
//
{
FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),
{
{
0,
}, // ZeroVector[16]
EFI_SYSTEM_NV_DATA_FV_GUID,
FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize),
EFI_FVH_SIGNATURE,
EFI_FVB2_READ_ENABLED_CAP |
EFI_FVB2_READ_STATUS |
EFI_FVB2_WRITE_ENABLED_CAP |
EFI_FVB2_WRITE_STATUS |
EFI_FVB2_ERASE_POLARITY,
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
0, // CheckSum
0, // ExtHeaderOffset
{
0,
}, // Reserved[1]
2, // Revision
{
{
(FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \
FixedPcdGet32 (PcdUnixFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdUnixFirmwareBlockSize),
FixedPcdGet32 (PcdUnixFirmwareBlockSize),
}
}
},
{
{
0,
0
}
}
}
};
EFI_STATUS
GetFvbInfo (
IN UINT64 FvLength,
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
)
{
UINTN Index;
for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {
if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
*FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}

View File

@ -1,225 +0,0 @@
/*++
Copyright (c) 2006 - 2009, 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
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:
FwBlockService.h
Abstract:
Firmware volume block driver for Intel Firmware Hub (FWH) device
--*/
#ifndef _FW_BLOCK_SERVICE_H
#define _FW_BLOCK_SERVICE_H
//
// BugBug: Add documentation here for data structure!!!!
//
#define FVB_PHYSICAL 0
#define FVB_VIRTUAL 1
typedef struct {
EFI_LOCK FvbDevLock;
UINTN FvBase[2];
UINTN NumOfBlocks;
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
} EFI_FW_VOL_INSTANCE;
typedef struct {
UINT32 NumFv;
EFI_FW_VOL_INSTANCE *FvInstance[2];
} ESAL_FWB_GLOBAL;
//
// Fvb Protocol instance data
//
#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)
#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N')
typedef struct {
MEMMAP_DEVICE_PATH MemMapDevPath;
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
} FV_DEVICE_PATH;
typedef struct {
UINTN Signature;
FV_DEVICE_PATH DevicePath;
UINTN Instance;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
} EFI_FW_VOL_BLOCK_DEVICE;
EFI_STATUS
GetFvbInfo (
IN UINT64 FvLength,
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
)
;
EFI_STATUS
FvbReadBlock (
IN UINTN Instance,
IN EFI_LBA Lba,
IN UINTN BlockOffset,
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbWriteBlock (
IN UINTN Instance,
IN EFI_LBA Lba,
IN UINTN BlockOffset,
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbEraseBlock (
IN UINTN Instance,
IN EFI_LBA Lba,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbSetVolumeAttributes (
IN UINTN Instance,
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbGetVolumeAttributes (
IN UINTN Instance,
OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
FvbGetPhysicalAddress (
IN UINTN Instance,
OUT EFI_PHYSICAL_ADDRESS *Address,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
EFI_STATUS
EFIAPI
FvbInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
;
VOID
EFIAPI
FvbClassAddressChangeEvent (
IN EFI_EVENT Event,
IN VOID *Context
)
;
EFI_STATUS
FvbGetLbaAddress (
IN UINTN Instance,
IN EFI_LBA Lba,
OUT UINTN *LbaAddress,
OUT UINTN *LbaLength,
OUT UINTN *NumOfBlocks,
IN ESAL_FWB_GLOBAL *Global,
IN BOOLEAN Virtual
)
;
//
// Protocol APIs
//
EFI_STATUS
EFIAPI
FvbProtocolGetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_FVB_ATTRIBUTES_2 *Attributes
)
;
EFI_STATUS
EFIAPI
FvbProtocolSetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
)
;
EFI_STATUS
EFIAPI
FvbProtocolGetPhysicalAddress (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_PHYSICAL_ADDRESS *Address
)
;
EFI_STATUS
EFIAPI
FvbProtocolGetBlockSize (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba,
OUT UINTN *BlockSize,
OUT UINTN *NumOfBlocks
)
;
EFI_STATUS
EFIAPI
FvbProtocolRead (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Offset,
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer
)
;
EFI_STATUS
EFIAPI
FvbProtocolWrite (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Offset,
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer
)
;
EFI_STATUS
EFIAPI
FvbProtocolEraseBlocks (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
...
)
;
#endif

View File

@ -1,79 +0,0 @@
## @file
# Component description file for Unix Fimware Volume Block DXE driver module.
#
# This DXE runtime driver implements and produces the Fimware Volue Block Protocol on
# Unix emulator.
# Copyright (c) 2008 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = FwBlockService
FILE_GUID = f42fd042-8985-11db-a7db-0040d02b1835
MODULE_TYPE = DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = FvbInitialize
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
FvbInfo.c
FWBlockService.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
BaseMemoryLib
HobLib
DebugLib
UefiRuntimeLib
DxeServicesTableLib
BaseLib
UefiDriverEntryPoint
UefiLib
DevicePathLib
[Guids]
gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED Create Event: EVENT_GROUP_GUID
[Protocols]
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiDevicePathProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
[FixedPcd]
gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareFdSize
gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareBlockSize
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoveryBase
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoverySize
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogBase
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogSize
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
[Depex]
TRUE

View File

@ -1,183 +0,0 @@
/*++
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2010, Apple Inc. 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
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:
UnixInclude.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_INCLUDE_H__
#define __UNIX_INCLUDE_H__
// #include <sys/poll.h>
// #include <dirent.h>
//
// Name mangle to prevent build errors. I.e conflicts between EFI and OS
//
#define NTOHL _UNIX_EFI_NAME_MANGLE_NTOHL_
#define HTONL _UNIX_EFI_NAME_MANGLE_HTONL_
#define NTOHS _UNIX_EFI_NAME_MANGLE_NTOHS_
#define HTONS _UNIX_EFI_NAME_MANGLE_HTOHS_
#define B0 _UNIX_EFI_NAME_MANGLE_B0_
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/termios.h>
#include <sys/time.h>
#if __CYGWIN__
#include <sys/dirent.h>
#else
#include <sys/dir.h>
#endif
#include <unistd.h>
#include <poll.h>
#include <fcntl.h>
#include <time.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <net/if.h>
#include <ifaddrs.h>
#ifdef __APPLE__
#include <net/if_dl.h>
#include <net/bpf.h>
#include <sys/param.h>
#include <sys/mount.h>
#define _XOPEN_SOURCE
#ifndef _Bool
#define _Bool char // for clang debug
#endif
#else
#include <termio.h>
#include <sys/vfs.h>
#endif
#include <utime.h>
#if __APPLE__
//
// EFI packing is not compatible witht he default OS packing for struct stat.
// st_size is 64-bit but starts on a 32-bit offset in the structure. The compiler
// flags used to produce compatible EFI images, break struct stat
//
#ifdef MDE_CPU_IA32
#pragma pack(4)
#endif
#if defined(__DARWIN_64_BIT_INO_T)
typedef struct {
UINTN tv_sec; /* seconds */
UINTN tv_nsec; /* and nanoseconds */
} EFI_timespec;
typedef struct stat_fix { \
dev_t st_dev; /* [XSI] ID of device containing file */
mode_t st_mode; /* [XSI] Mode of file (see below) */
nlink_t st_nlink; /* [XSI] Number of hard links */
__darwin_ino64_t st_ino; /* [XSI] File serial number */
uid_t st_uid; /* [XSI] User ID of the file */
gid_t st_gid; /* [XSI] Group ID of the file */
dev_t st_rdev; /* [XSI] Device ID */
// clang for X64 ABI follows Windows and a long is 32-bits
// this breaks system inlcude files so that is why we need
// to redefine timespec as EFI_timespec
EFI_timespec st_atimespec;
EFI_timespec st_mtimespec;
EFI_timespec st_ctimespec;
EFI_timespec st_birthtimespec;
off_t st_size; /* [XSI] file size, in bytes */
blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
__uint32_t st_flags; /* user defined flags for file */
__uint32_t st_gen; /* file generation number */
__int32_t st_lspare; /* RESERVED: DO NOT USE! */
__int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
} STAT_FIX;
#else /* !__DARWIN_64_BIT_INO_T */
typedef struct stat_fix {
dev_t st_dev; /* [XSI] ID of device containing file */
ino_t st_ino; /* [XSI] File serial number */
mode_t st_mode; /* [XSI] Mode of file (see below) */
nlink_t st_nlink; /* [XSI] Number of hard links */
uid_t st_uid; /* [XSI] User ID of the file */
gid_t st_gid; /* [XSI] Group ID of the file */
dev_t st_rdev; /* [XSI] Device ID */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last status change */
#else
time_t st_atime; /* [XSI] Time of last access */
long st_atimensec; /* nsec of last access */
time_t st_mtime; /* [XSI] Last data modification time */
long st_mtimensec; /* last data modification nsec */
time_t st_ctime; /* [XSI] Time of last status change */
long st_ctimensec; /* nsec of last status change */
#endif
off_t st_size; /* [XSI] file size, in bytes */
blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
__uint32_t st_flags; /* user defined flags for file */
__uint32_t st_gen; /* file generation number */
__int32_t st_lspare; /* RESERVED: DO NOT USE! */
__int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
} STAT_FIX;
#endif
#ifdef MDE_CPU_IA32
#pragma pack(4)
#endif
#else
typedef struct stat STAT_FIX;
#endif
//
// Undo name mangling
//
#undef NTOHL
#undef HTONL
#undef NTOHS
#undef HTONS
#undef B0
#endif

View File

@ -1,64 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
FlashLayout.h
Abstract:
Platform specific flash layout
BugBug: We need a better way
--*/
#ifndef __EFI_FLASH_LAYOUT__
#define __EFI_FLASH_LAYOUT__
//
// Firmware Volume Information for Nt32
// adding one working block before FFS FV,
// and another one for spare block behind FFS FV
//
//
// Note: When block number is changed in .dsc file,
// this value should be changed accordingly!!!
//
#define FIRMWARE_BLOCK_NUMBER 0x28
#define EFI_WINNT_FIRMWARE_OFFSET 0x0
#define EFI_WINNT_FIRMWARE_LENGTH (0x10000 * FIRMWARE_BLOCK_NUMBER)
#define EFI_WINNT_RUNTIME_UPDATABLE_OFFSET (EFI_WINNT_FIRMWARE_OFFSET + EFI_WINNT_FIRMWARE_LENGTH)
#define EFI_WINNT_RUNTIME_UPDATABLE_LENGTH 0x10000
#define EFI_WINNT_FTW_SPARE_BLOCK_OFFSET (EFI_WINNT_RUNTIME_UPDATABLE_OFFSET + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH)
#define EFI_WINNT_FTW_SPARE_BLOCK_LENGTH 0x10000
#define EFI_WINNT_RUNTIME_UPDATABLE_FV_HEADER_LENGTH 0x48
#define EFI_VARIABLE_STORE_OFFSET EFI_WINNT_RUNTIME_UPDATABLE_OFFSET
#define EFI_VARIABLE_STORE_LENGTH 0x00C000
#define EFI_EVENT_LOG_OFFSET (EFI_VARIABLE_STORE_OFFSET + EFI_VARIABLE_STORE_LENGTH)
#define EFI_EVENT_LOG_LENGTH 0x002000
#define EFI_FTW_WORKING_OFFSET (EFI_EVENT_LOG_OFFSET + EFI_EVENT_LOG_LENGTH)
#define EFI_FTW_WORKING_LENGTH 0x002000
#endif

View File

@ -1,36 +0,0 @@
/**@file
Setup Variable data structure for Unix platform.
Copyright (c) 2009, 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
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.
**/
#ifndef __UNIX_SYSTEM_CONFIGUE_H__
#define __UNIX_SYSTEM_CONFIGUE_H__
#define EFI_UXIX_SYSTEM_CONFIG_GUID \
{0x375ea976, 0x3ccd, 0x4e74, {0xa8, 0x45, 0x26, 0xb9, 0xb3, 0x24, 0xb1, 0x3c}}
#pragma pack(1)
typedef struct {
//
// Console output mode
//
UINT32 ConOutColumn;
UINT32 ConOutRow;
} UNIX_SYSTEM_CONFIGURATION;
#pragma pack()
extern EFI_GUID gEfiUnixSystemConfigGuid;
#endif

View File

@ -1,57 +0,0 @@
/** @file
Allows an override of the SEC SEC PPI Dispatch Table. This allows
customized PPIs to be passed into the PEI Core.
Copyright (c) 2008 - 2010, Apple Inc. 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
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.
**/
#ifndef __SEC_DISPATCH_TABLE_LIB_H__
#define __SEC_DISPATCH_TABLE_LIB_H__
/**
Return the number of bytes that OverrideDispatchTable() will append to
the dispatch table.
@return Size of table in bytes OverrideDispatchTable() will return
**/
UINTN
EFIAPI
OverrideDispatchTableExtraSize (
VOID
);
/**
Allow an override of the Sec PPI Dispatch Table. This table contains PPIs passed
up from SEC to PEI.
@param OriginalTable SECs default PPI dispatch table
@param OriginalTableSize Size of SECs default PPI dispatch table
@param NewTable New dispatch table
@param NewTableSize Size of of the NewTable in bytes
@return EFI_SUCCESS table was copied
**/
EFI_STATUS
EFIAPI
OverrideDispatchTable (
IN CONST EFI_PEI_PPI_DESCRIPTOR *OriginalTable,
IN UINTN OriginalTableSize,
IN OUT EFI_PEI_PPI_DESCRIPTOR *NewTable,
IN UINTN NewTableSize
);
#endif

View File

@ -1,27 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
UnixLib.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_LIB_H__
#define __UNIX_LIB_H__
extern EFI_UNIX_THUNK_PROTOCOL *gUnix;
#endif

View File

@ -1,66 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
UnixAutoscan.h
Abstract:
Unix Autoscan PPI
--*/
#ifndef __UNIX_PEI_AUTOSCAN_H__
#define __UNIX_PEI_AUTOSCAN_H__
#include <UnixDxe.h>
#define PEI_UNIX_AUTOSCAN_PPI_GUID \
{ \
0xf2ed3d14, 0x8985, 0x11db, {0xb0, 0x57, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
EFI_STATUS
(EFIAPI *PEI_UNIX_AUTOSCAN) (
IN UINTN Index,
OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
OUT UINT64 *MemorySize
);
/*++
Routine Description:
This service is called from Index == 0 until it returns EFI_UNSUPPORTED.
It allows discontiguous memory regions to be supported by the emulator.
It uses gSystemMemory[] and gSystemMemoryCount that were created by
parsing the host environment variable EFI_MEMORY_SIZE.
The size comes from the varaible and the address comes from the call to
WinNtOpenFile.
Arguments:
Index - Which memory region to use
MemoryBase - Return Base address of memory region
MemorySize - Return size in bytes of the memory region
Returns:
EFI_SUCCESS - If memory region was mapped
EFI_UNSUPPORTED - If Index is not supported
--*/
typedef struct {
PEI_UNIX_AUTOSCAN UnixAutoScan;
} PEI_UNIX_AUTOSCAN_PPI;
extern EFI_GUID gPeiUnixAutoScanPpiGuid;
#endif

View File

@ -1,64 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
UnixFwh.h
Abstract:
Unix FWH PPI as defined in Tiano
--*/
#ifndef __UNIX_PEI_FWH_H__
#define __UNIX_PEI_FWH_H__
#include <UnixDxe.h>
#define UNIX_FWH_PPI_GUID \
{ \
0xf2f0dc30, 0x8985, 0x11db, {0xa1, 0x5b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
EFI_STATUS
(EFIAPI *UNIX_FWH_INFORMATION) (
IN UINTN Index,
IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
IN OUT UINT64 *FdSize,
IN OUT EFI_PHYSICAL_ADDRESS *FixUp
);
/*++
Routine Description:
Return the FD Size and base address. Since the FD is loaded from a
file into host memory only the SEC will know it's address.
Arguments:
Index - Which FD, starts at zero.
FdSize - Size of the FD in bytes
FdBase - Start address of the FD. Assume it points to an FV Header
FixUp - Difference between actual FD address and build address
Returns:
EFI_SUCCESS - Return the Base address and size of the FV
EFI_UNSUPPORTED - Index does nto map to an FD in the system
--*/
typedef struct {
UNIX_FWH_INFORMATION UnixFwh;
} UNIX_FWH_PPI;
extern EFI_GUID gUnixFwhPpiGuid;
#endif

View File

@ -1,65 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
UnixPeiLoadFile.h
Abstract:
Unix Load File PPI.
When the PEI core is done it calls the DXE IPL via PPI
--*/
#ifndef __UNIX_PEI_LOAD_FILE_H__
#define __UNIX_PEI_LOAD_FILE_H__
#include <UnixDxe.h>
#define UNIX_PEI_LOAD_FILE_GUID \
{ \
0xf2f48768, 0x8985, 0x11db, {0xb8, 0xda, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
EFI_STATUS
(EFIAPI *UNIX_PEI_LOAD_FILE) (
VOID *Pe32Data,
EFI_PHYSICAL_ADDRESS *ImageAddress,
UINT64 *ImageSize,
EFI_PHYSICAL_ADDRESS *EntryPoint
);
/*++
Routine Description:
Loads and relocates a PE/COFF image into memory.
Arguments:
Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated
ImageAddress - The base address of the relocated PE/COFF image
ImageSize - The size of the relocated PE/COFF image
EntryPoint - The entry point of the relocated PE/COFF image
Returns:
EFI_SUCCESS - The file was loaded and relocated
EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file
--*/
typedef struct {
UNIX_PEI_LOAD_FILE PeiLoadFileService;
} UNIX_PEI_LOAD_FILE_PPI;
extern EFI_GUID gUnixPeiLoadFilePpiGuid;
#endif

View File

@ -1,56 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
UnixThunk.h
Abstract:
Unix Thunk interface PPI
--*/
#ifndef __UNIX_PEI_UNIX_THUNK_H__
#define __UNIX_PEI_UNIX_THUNK_H__
#include <UnixDxe.h>
#define PEI_UNIX_THUNK_PPI_GUID \
{ \
0xf2f830f2, 0x8985, 0x11db, {0x80, 0x6b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
VOID *
(EFIAPI *PEI_UNIX_THUNK_INTERFACE) (
VOID
);
/*++
Routine Description:
Export of EFI_UNIX_THUNK_PROTOCOL from the Unix SEC.
Arguments:
InterfaceBase - Address of the EFI_UNIX_THUNK_PROTOCOL
Returns:
EFI_SUCCESS - Data returned
--*/
typedef struct {
PEI_UNIX_THUNK_INTERFACE UnixThunk;
} PEI_UNIX_THUNK_PPI;
extern EFI_GUID gPeiUnixThunkPpiGuid;
#endif

View File

@ -1,154 +0,0 @@
/*++
Copyright (c) 2004 - 2006, 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
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:
UnixIo.h
Abstract:
--*/
#ifndef _UNIX_IO_H_
#define _UNIX_IO_H_
#include <Protocol/UnixThunk.h>
#define EFI_UNIX_IO_PROTOCOL_GUID \
{ \
0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef struct {
EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
EFI_GUID *TypeGuid;
UINT16 *EnvString;
UINT16 InstanceNumber;
} EFI_UNIX_IO_PROTOCOL;
extern EFI_GUID gEfiUnixIoProtocolGuid;
//
// The following GUIDs are used in EFI_UNIX_IO_PROTOCOL_GUID
// Device paths. They map 1:1 with UNIX envirnment variables. The variables
// define what virtual hardware the emulator/UnixBusDriver will produce.
//
//
// EFI_UNIX_VIRTUAL_DISKS
//
#define EFI_UNIX_VIRTUAL_DISKS_GUID \
{ \
0xf2ba331a, 0x8985, 0x11db, {0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixVirtualDisksGuid;
//
// EFI_UNIX_PHYSICAL_DISKS
//
#define EFI_UNIX_PHYSICAL_DISKS_GUID \
{ \
0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixPhysicalDisksGuid;
//
// EFI_UNIX_FILE_SYSTEM
//
#define EFI_UNIX_FILE_SYSTEM_GUID \
{ \
0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixFileSystemGuid;
//
// EFI_WIN_NT_SERIAL_PORT
//
#define EFI_UNIX_SERIAL_PORT_GUID \
{ \
0x6d3a727d, 0x66c8, 0x4d19, {0x87, 0xe6, 0x2, 0x15, 0x86, 0x14, 0x90, 0xf3} \
}
extern EFI_GUID gEfiUnixSerialPortGuid;
//
// EFI_UNIX_UGA
//
#define EFI_UNIX_UGA_GUID \
{ \
0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixUgaGuid;
//
// EFI_UNIX_GOP
//
#define EFI_UNIX_GOP_GUID \
{ \
0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixGopGuid;
//
// EFI_UNIX_CONSOLE
//
#define EFI_UNIX_CONSOLE_GUID \
{ \
0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixConsoleGuid;
//
// EFI_UNIX_MEMORY
//
#define EFI_UNIX_MEMORY_GUID \
{ \
0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixMemoryGuid;
//
// EFI_UNIX_CPU_MODEL
//
#define EFI_UNIX_CPU_MODEL_GUID \
{ \
0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixCPUModelGuid;
//
// EFI_UNIX_CPU_SPEED
//
#define EFI_UNIX_CPU_SPEED_GUID \
{ \
0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
extern EFI_GUID gEfiUnixCPUSpeedGuid;
//
// EFI_UNIX_NETWORK
//
#define EFI_UNIX_NETWORK_GUID \
{ \
0x081603B4, 0x0F1D, 0x4022, {0xB6, 0xFD, 0x4C, 0xE3, 0x5E, 0x09, 0xA1, 0xA6 } \
}
extern EFI_GUID gEfiUnixNetworkGuid;
#endif

View File

@ -1,346 +0,0 @@
/*++
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2010, Apple Inc. 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
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:
UnixThunk.h
Abstract:
This protocol allows an EFI driver in the Unix emulation environment
to make Posix calls.
NEVER make an Unix call directly, always make the call via this protocol.
There are no This pointers on the protocol member functions as they map
exactly into Unix system calls.
--*/
#ifndef _UNIX_THUNK_H_
#define _UNIX_THUNK_H_
#include <Common/UnixInclude.h>
#include <Base.h>
#include <Library/PeCoffLib.h>
#define EFI_UNIX_THUNK_PROTOCOL_GUID \
{ \
0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
}
typedef
VOID
(EFIAPI *UnixSleep) (
unsigned long Milliseconds
);
typedef
VOID
(EFIAPI *UnixExit) (
int status // exit code for all threads
);
typedef
VOID
(EFIAPI *UnixSetTimer) (
UINT64 PeriodMs,
VOID (EFIAPI *CallBack)(UINT64 DeltaMs)
);
typedef
VOID
(EFIAPI *UnixGetLocalTime) (
EFI_TIME *Time
);
typedef
struct tm *
(EFIAPI *UnixGmTime)(
const time_t *timep
);
typedef
long
(EFIAPI *UnixGetTimeZone)(
void
);
typedef
int
(EFIAPI *UnixGetDayLight)(
void
);
typedef
int
(EFIAPI *UnixPoll)(
struct pollfd *pfd,
unsigned int nfds,
int timeout
);
typedef
long
(EFIAPI *UnixRead) (
int fd,
void *buf,
int count
);
typedef
long
(EFIAPI *UnixWrite) (
int fd,
const void *buf,
int count
);
typedef
char *
(EFIAPI *UnixGetenv) (const char *var);
typedef
int
(EFIAPI *UnixOpen) (const char *name, int flags, int mode);
typedef
off_t
(EFIAPI *UnixSeek) (int fd, off_t off, int whence);
typedef
int
(EFIAPI *UnixFtruncate) (int fd, long int len);
typedef
int
(EFIAPI *UnixClose) (int fd);
typedef
int
(EFIAPI *UnixMkdir)(const char *pathname, mode_t mode);
typedef
int
(EFIAPI *UnixRmDir)(const char *pathname);
typedef
int
(EFIAPI *UnixUnLink)(const char *pathname);
typedef
int
(EFIAPI *UnixGetErrno)(VOID);
typedef
DIR *
(EFIAPI *UnixOpenDir)(const char *pathname);
typedef
void
(EFIAPI *UnixRewindDir)(DIR *dir);
typedef
struct dirent *
(EFIAPI *UnixReadDir)(DIR *dir);
typedef
int
(EFIAPI *UnixCloseDir)(DIR *dir);
typedef
int
(EFIAPI *UnixStat)(const char *path, STAT_FIX *buf);
typedef
int
(EFIAPI *UnixStatFs)(const char *path, struct statfs *buf);
typedef
int
(EFIAPI *UnixRename)(const char *oldpath, const char *newpath);
typedef
time_t
(EFIAPI *UnixMkTime)(struct tm *tm);
typedef
int
(EFIAPI *UnixFSync)(int fd);
typedef
int
(EFIAPI *UnixChmod)(const char *path, mode_t mode);
typedef
int
(EFIAPI *UnixUTime)(const char *filename, const struct utimbuf *buf);
struct _EFI_UNIX_UGA_IO_PROTOCOL;
typedef
EFI_STATUS
(EFIAPI *UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
CONST CHAR16 *Title);
typedef
int
(EFIAPI *UnixTcflush) (int fildes, int queue_selector);
typedef
void
(EFIAPI *UnixPerror) (__const char *__s);
typedef
int
#if __CYGWIN__
(EFIAPI *UnixIoCtl) (int fd, int __request, UINTN Arg);
#else
(EFIAPI *UnixIoCtl) (int fd, unsigned long int __request, void *Arg);
#endif
typedef
int
(EFIAPI *UnixFcntl) (int __fd, int __cmd, void *Arg);
typedef
int
(EFIAPI *UnixCfsetispeed) (struct termios *__termios_p, speed_t __speed);
typedef
int
(EFIAPI *UnixCfsetospeed) (struct termios *__termios_p, speed_t __speed);
typedef
int
(EFIAPI *UnixTcgetattr) (int __fd, struct termios *__termios_p);
typedef
int
(EFIAPI *UnixTcsetattr) (int __fd, int __optional_actions,
__const struct termios *__termios_p);
//
// Worker functions to enable source level debug in the emulator
//
typedef
RETURN_STATUS
(EFIAPI *UnixPeCoffGetEntryPoint) (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
);
typedef
VOID
(EFIAPI *UnixPeCoffRelocateImageExtraAction) (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
typedef
VOID
(EFIAPI *UnixPeCoffLoaderUnloadImageExtraAction) (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
typedef
int
(EFIAPI *UnixGetIfAddrs) (
struct ifaddrs **ifap
);
typedef
void
(EFIAPI *UnixFreeIfAddrs) (
struct ifaddrs *ifap
);
typedef
int
(EFIAPI *UnixSocket) (
int domain,
int type,
int protocol
);
typedef
void
(EFIAPI *UnixDisableInterruptEmulation) (void);
typedef
void
(EFIAPI *UnixEnableInterruptEmulation) (void);
#define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
typedef struct _EFI_UNIX_THUNK_PROTOCOL {
UINT64 Signature;
UnixSleep Sleep;
UnixExit Exit;
UnixSetTimer SetTimer;
UnixGetLocalTime GetLocalTime;
UnixGmTime GmTime;
UnixGetTimeZone GetTimeZone;
UnixGetDayLight GetDayLight;
UnixPoll Poll;
UnixRead Read;
UnixWrite Write;
UnixGetenv Getenv;
UnixOpen Open;
UnixSeek Lseek;
UnixFtruncate FTruncate;
UnixClose Close;
UnixMkdir MkDir;
UnixRmDir RmDir;
UnixUnLink UnLink;
UnixGetErrno GetErrno;
UnixOpenDir OpenDir;
UnixRewindDir RewindDir;
UnixReadDir ReadDir;
UnixCloseDir CloseDir;
UnixStat Stat;
UnixStatFs StatFs;
UnixRename Rename;
UnixMkTime MkTime;
UnixFSync FSync;
UnixChmod Chmod;
UnixUTime UTime;
UnixTcflush Tcflush;
UnixUgaCreate UgaCreate;
UnixPerror Perror;
UnixIoCtl IoCtl;
UnixFcntl Fcntl;
UnixCfsetispeed Cfsetispeed;
UnixCfsetospeed Cfsetospeed;
UnixTcgetattr Tcgetattr;
UnixTcsetattr Tcsetattr;
UnixPeCoffGetEntryPoint PeCoffGetEntryPoint;
UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction;
UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction;
UnixEnableInterruptEmulation EnableInterrupt;
UnixDisableInterruptEmulation DisableInterrupt;
UnixGetIfAddrs GetIfAddrs;
UnixFreeIfAddrs FreeIfAddrs;
UnixSocket Socket;
} EFI_UNIX_THUNK_PROTOCOL;
extern EFI_GUID gEfiUnixThunkProtocolGuid;
#endif

View File

@ -1,139 +0,0 @@
/*++
Copyright (c) 2006, Tristan Gingold. 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 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:
UnixUgaIo.h
Abstract:
--*/
#ifndef _UNIX_UGA_IO_H_
#define _UNIX_UGA_IO_H_
#include <Protocol/SimplePointer.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/UgaDraw.h>
#define EFI_UNIX_UGA_IO_PROTOCOL_GUID {0xf2e5e2c6, 0x8985, 0x11db, {0xa1, 0x91, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
typedef struct _EFI_UNIX_UGA_IO_PROTOCOL EFI_UNIX_UGA_IO_PROTOCOL;
typedef
EFI_STATUS
(EFIAPI *UGAClose)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *UGASize)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga,
UINT32 Width,
UINT32 Height
);
typedef
EFI_STATUS
(EFIAPI *UGACheckKey)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *UGAGetKey)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga,
EFI_KEY_DATA *key
);
typedef
EFI_STATUS
(EFIAPI *UGAKeySetState) (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
typedef
VOID
(EFIAPI *UGA_REGISTER_KEY_NOTIFY_CALLBACK) (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *UGARegisterKeyNotify) (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context
);
typedef struct {
UINTN SourceX;
UINTN SourceY;
UINTN DestinationX;
UINTN DestinationY;
UINTN Width;
UINTN Height;
UINTN Delta;
} UGA_BLT_ARGS;
typedef
EFI_STATUS
(EFIAPI *UGABlt)(
IN EFI_UNIX_UGA_IO_PROTOCOL *Uga,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation,
IN UGA_BLT_ARGS *Args
);
typedef
BOOLEAN
(EFIAPI *UGAIsKeyPressed) (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *UGACheckPointer)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *UGAGetPointerState)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga,
EFI_SIMPLE_POINTER_STATE *state
);
struct _EFI_UNIX_UGA_IO_PROTOCOL {
VOID *Private;
UGAClose UgaClose;
UGASize UgaSize;
UGACheckKey UgaCheckKey;
UGAKeySetState UgaKeySetState;
UGAGetKey UgaGetKey;
UGARegisterKeyNotify UgaRegisterKeyNotify;
UGABlt UgaBlt;
UGAIsKeyPressed UgaIsKeyPressed;
UGACheckPointer UgaCheckPointer;
UGAGetPointerState UgaGetPointerState;
};
extern EFI_GUID gEfiUnixUgaIoProtocolGuid;
#endif

View File

@ -1,36 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
UnixDxe.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_DXE_H__
#define __UNIX_DXE_H__
#include <Ppi/UnixPeiLoadFile.h>
#include <Ppi/UnixAutoScan.h>
#include <Ppi/UnixThunk.h>
#include <Ppi/UnixFwh.h>
//
// UnixIo.h depends on UnixThunk.h
//
#include <Common/UnixInclude.h>
#include <Protocol/UnixThunk.h>
#include <Protocol/UnixIo.h>
#endif

View File

@ -1,30 +0,0 @@
/*++
Copyright (c) 2006, 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
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:
UnixPeim.h
Abstract:
Public include file for the Unix Library
--*/
#ifndef __UNIX_PEIM_H__
#define __UNIX_PEIM_H__
#include <Ppi/UnixPeiLoadFile.h>
#include <Ppi/UnixAutoScan.h>
#include <Ppi/UnixThunk.h>
#include <Ppi/UnixFwh.h>
#include <Protocol/UnixThunk.h>
#endif

View File

@ -1,48 +0,0 @@
## @file
# A library to produce the global variable 'gUnix'
#
# This library contains a single global variable 'gUnix' along with a constructor to initialize that global.
# Copyright (c) 2006 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeUnixLib
FILE_GUID = f39efc84-8985-11db-ad67-0040d02b1835
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = UnixLib
CONSTRUCTOR = UnixLibConstructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
UnixLib.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
HobLib
DebugLib
[Protocols]
gEfiUnixThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED

View File

@ -1,52 +0,0 @@
/*++
Copyright (c) 2006 - 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
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:
UnixLib.c
Abstract:
Unix Library
--*/
#include "PiDxe.h"
#include "UnixDxe.h"
#include <Library/UnixLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
EFI_UNIX_THUNK_PROTOCOL *gUnix;
EFI_STATUS
EFIAPI
UnixLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Arguments:
Returns:
--*/
{
EFI_HOB_GUID_TYPE *GuidHob;
GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);
ASSERT (GuidHob != NULL);
gUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
ASSERT (gUnix != NULL);
return EFI_SUCCESS;
}

View File

@ -1,52 +0,0 @@
## @file
# Memory Status Code Library for UEFI drivers
#
# Lib to provide memory journal status code reporting Routines
#
# Copyright (c) 2009 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeUnixOemHookStatusCodeLib
FILE_GUID = 0BB6F68A-2FC5-4394-9375-2B43F1C34B59
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = OemHookStatusCodeLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources]
UnixOemHookStatusCodeLib.c
[Packages]
UnixPkg/UnixPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
ReportStatusCodeLib
BaseMemoryLib
PrintLib
HobLib
DebugLib
[Protocols]
gEfiUnixThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED

View File

@ -1,222 +0,0 @@
/** @file
OEM hook status code library functions with no library constructor/destructor
Copyright (c) 2006 - 2010, 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
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: UnixOemHookStatusCodeLib.c
**/
#include <Guid/StatusCodeDataTypeId.h>
#include <Guid/StatusCodeDataTypeDebug.h>
#include "UnixDxe.h"
#include <Library/OemHookStatusCodeLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/PrintLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/ReportStatusCodeLib.h>
//
// Cache of UnixThunk protocol
//
EFI_UNIX_THUNK_PROTOCOL *mUnix;
//
// Cache of standard output handle .
//
int mStdOut;
/**
Initialize OEM status code device .
@return Always return EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
OemHookStatusCodeInitialize (
VOID
)
{
EFI_HOB_GUID_TYPE *GuidHob;
//
// Retrieve UnixThunkProtocol from GUID'ed HOB
//
GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);
ASSERT (GuidHob != NULL);
mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
ASSERT (mUnix != NULL);
//
// Cache standard output handle.
//
mStdOut = 1;
return EFI_SUCCESS;
}
/**
Report status code to OEM device.
@param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
A system may contain multiple entities that match a class/subclass pairing.
The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
not meaningful, or not relevant. Valid instance numbers start with 1.
@param CallerId This optional parameter may be used to identify the caller.
This parameter allows the status code driver to apply different rules to different callers.
Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
@param Data This optional parameter may be used to pass additional data
@return The function always return EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
OemHookStatusCodeReport (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
IN EFI_GUID *CallerId, OPTIONAL
IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
CHAR8 *Filename;
CHAR8 *Description;
CHAR8 *Format;
CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
UINT32 ErrorLevel;
UINT32 LineNumber;
UINTN CharCount;
BASE_LIST Marker;
Buffer[0] = '\0';
if (Data != NULL &&
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
//
// Print ASSERT() information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"\n\rASSERT!: %a (%d): %a\n\r",
Filename,
LineNumber,
Description
);
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
} else if (Data != NULL &&
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
//
// Print DEBUG() information into output buffer.
//
CharCount = AsciiBSPrint (
Buffer,
sizeof (Buffer),
Format,
Marker
);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
//
// Print ERROR information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"ERROR: C%x:V%x I%x",
CodeType,
Value,
Instance
);
//
// Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
//
if (CallerId != NULL) {
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
" %g",
CallerId
);
}
if (Data != NULL) {
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
" %x",
Data
);
}
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
"\n\r"
);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"PROGRESS CODE: V%x I%x\n\r",
Value,
Instance
);
} else {
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"Undefined: C%x:V%x I%x\n\r",
CodeType,
Value,
Instance
);
}
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
}

View File

@ -1,113 +0,0 @@
/**@file
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. 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
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:
PeiUnixPeCoffExtraActionLib.c
Abstract:
Provides services to perform additional actions to relocate and unload
PE/Coff image for Unix environment specific purpose such as souce level debug.
This version only works for DXE phase
**/
#include <PiDxe.h>
#include <UnixDxe.h>
#include <Library/PeCoffLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PeCoffExtraActionLib.h>
//
// Cache of UnixThunk protocol
//
EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL;
/**
The constructor function gets the pointer of the WinNT thunk functions
It will ASSERT() if Unix thunk protocol is not installed.
@retval EFI_SUCCESS Unix thunk protocol is found and cached.
**/
EFI_STATUS
EFIAPI
DxeUnixPeCoffLibExtraActionConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_HOB_GUID_TYPE *GuidHob;
//
// Retrieve UnixThunkProtocol from GUID'ed HOB
//
GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);
ASSERT (GuidHob != NULL);
mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
ASSERT (mUnix != NULL);
return EFI_SUCCESS;
}
/**
Performs additional actions after a PE/COFF image has been loaded and relocated.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the
PE/COFF image that has already been loaded and relocated.
**/
VOID
EFIAPI
PeCoffLoaderRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mUnix != NULL) {
mUnix->PeCoffRelocateImageExtraAction (ImageContext);
}
}
/**
Performs additional actions just before a PE/COFF image is unloaded. Any resources
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the
PE/COFF image that is being unloaded.
**/
VOID
EFIAPI
PeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mUnix != NULL) {
mUnix->PeCoffUnloadImageExtraAction (ImageContext);
}
}

View File

@ -1,48 +0,0 @@
## @file
# PeCoff extra action libary for DXE phase that run Unix emulator.
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeUnixPeCoffExtraActionLib
FILE_GUID = C6F96971-39D2-49a5-93FC-5D42FB4D7DD2
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
CONSTRUCTOR = DxeUnixPeCoffLibExtraActionConstructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources]
DxeUnixPeCoffExtraActionLib.c
[Packages]
UnixPkg/UnixPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
DebugLib
HobLib
BaseMemoryLib
[Protocols]
gEfiUnixThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED

View File

@ -1,48 +0,0 @@
## @file
# Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.
#
# PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.
# Copyright (c) 2008 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = EdkUnixPeiPeCoffGetEntryPointLib
FILE_GUID = f3b702e8-8985-11db-9558-0040d02b1835
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
LIBRARY_CLASS = PeCoffGetEntryPointLib
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
PeCoffGetEntryPoint.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
PeiServicesLib
DebugLib
[Ppis]
gUnixPeiLoadFilePpiGuid # PPI ALWAYS_CONSUMED

View File

@ -1,305 +0,0 @@
/*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. 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
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:
PeCoffGetEntryPoint.c
Abstract:
Tiano PE/COFF loader
Revision History
--*/
#include "PiPei.h"
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/PeiServicesLib.h>
#include <Ppi/UnixPeiLoadFile.h>
#include <IndustryStandard/PeImage.h>
#include <Library/DebugLib.h>
RETURN_STATUS
EFIAPI
PeCoffLoaderGetEntryPoint (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
)
/*++
Routine Description:
Loads a PE/COFF image into memory, this is not follow the original purpose of
PeCoffGetEntryPoint library class. But it's ok that Unix package not run on a real
platform and this is for source level debug.
Arguments:
Pe32Data - Pointer to a PE/COFF Image
EntryPoint - Pointer to the entry point of the PE/COFF image
Returns:
EFI_SUCCESS if the EntryPoint was returned
EFI_INVALID_PARAMETER if the EntryPoint could not be found from Pe32Data
--*/
{
PEI_UNIX_THUNK_PPI *UnixThunkPpi;
EFI_STATUS Status;
EFI_UNIX_THUNK_PROTOCOL *Unix;
//
// Locate Unix ThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi (
&gPeiUnixThunkPpiGuid,
0,
NULL,
(VOID **) &UnixThunkPpi
);
ASSERT_EFI_ERROR (Status);
Unix = (EFI_UNIX_THUNK_PROTOCOL *)UnixThunkPpi->UnixThunk ();
return Unix->PeCoffGetEntryPoint (Pe32Data, EntryPoint);
}
/**
Returns the machine type of PE/COFF image.
This is copied from MDE BasePeCoffGetEntryPointLib, the code should be sync with it.
The reason is Unix package needs to load the image to memory to support source
level debug.
@param Pe32Data Pointer to a PE/COFF header
@return Machine type or zero if not a valid iamge
**/
UINT16
EFIAPI
PeCoffLoaderGetMachineType (
IN VOID *Pe32Data
)
{
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
EFI_IMAGE_DOS_HEADER *DosHdr;
ASSERT (Pe32Data != NULL);
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
} else {
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data);
}
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
return Hdr.Te->Machine;
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
return Hdr.Pe32->FileHeader.Machine;
}
return 0x0000;
}
/**
Returns a pointer to the PDB file name for a PE/COFF image that has been
loaded into system memory with the PE/COFF Loader Library functions.
Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
the PE/COFF image specified by Pe32Data is not a valid, then NULL is
returned. If the PE/COFF image specified by Pe32Data does not contain a
debug directory entry, then NULL is returned. If the debug directory entry
in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
then NULL is returned.
If Pe32Data is NULL, then ASSERT().
@param Pe32Data Pointer to the PE/COFF image that is loaded in system
memory.
@return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
if it cannot be retrieved.
**/
VOID *
EFIAPI
PeCoffLoaderGetPdbPointer (
IN VOID *Pe32Data
)
{
EFI_IMAGE_DOS_HEADER *DosHdr;
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
UINTN DirCount;
VOID *CodeViewEntryPointer;
INTN TEImageAdjust;
UINT32 NumberOfRvaAndSizes;
UINT16 Magic;
ASSERT (Pe32Data != NULL);
TEImageAdjust = 0;
DirectoryEntry = NULL;
DebugEntry = NULL;
NumberOfRvaAndSizes = 0;
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
//
// DOS image header is present, so read the PE header after the DOS image header.
//
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
} else {
//
// DOS image header is not present, so PE header is at the image base.
//
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
}
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +
Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
TEImageAdjust);
}
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
//
// NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
// It is due to backward-compatibility, for some system might
// generate PE32+ image with PE32 Magic.
//
switch (Hdr.Pe32->FileHeader.Machine) {
case EFI_IMAGE_MACHINE_IA32:
//
// Assume PE32 image with IA32 Machine field.
//
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
break;
case EFI_IMAGE_MACHINE_X64:
case EFI_IMAGE_MACHINE_IA64:
//
// Assume PE32+ image with X64 or IA64 Machine field
//
Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
break;
default:
//
// For unknow Machine field, use Magic in optional Header
//
Magic = Hdr.Pe32->OptionalHeader.Magic;
}
if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
//
// Use PE32 offset get Debug Directory Entry
//
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
} else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
//
// Use PE32+ offset get Debug Directory Entry
//
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
}
if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
DirectoryEntry = NULL;
DebugEntry = NULL;
}
} else {
return NULL;
}
if (DebugEntry == NULL || DirectoryEntry == NULL) {
return NULL;
}
for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {
if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
if (DebugEntry->SizeOfData > 0) {
CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
switch (* (UINT32 *) CodeViewEntryPointer) {
case CODEVIEW_SIGNATURE_NB10:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
case CODEVIEW_SIGNATURE_RSDS:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
case CODEVIEW_SIGNATURE_MTOC:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
default:
break;
}
}
}
}
return NULL;
}
/**
Returns the size of the PE/COFF headers
Returns the size of the PE/COFF header specified by Pe32Data.
If Pe32Data is NULL, then ASSERT().
@param Pe32Data Pointer to the PE/COFF image that is loaded in system
memory.
@return Size of PE/COFF header in bytes or zero if not a valid image.
**/
UINT32
EFIAPI
PeCoffGetSizeOfHeaders (
IN VOID *Pe32Data
)
{
EFI_IMAGE_DOS_HEADER *DosHdr;
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
UINTN SizeOfHeaders;
ASSERT (Pe32Data != NULL);
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
//
// DOS image header is present, so read the PE header after the DOS image header.
//
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
} else {
//
// DOS image header is not present, so PE header is at the image base.
//
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
}
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
} else {
SizeOfHeaders = 0;
}
return SizeOfHeaders;
}

View File

@ -1,51 +0,0 @@
## @file
# Memory Status Code Library for UEFI drivers
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2009 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PeiUnixOemHookStatusCodeLib
FILE_GUID = 23E378C1-B199-49ad-9F14-DAF5D3C7EC28
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
LIBRARY_CLASS = OemHookStatusCodeLib|PEIM
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources]
UnixOemHookStatusCodeLib.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
PeiServicesLib
ReportStatusCodeLib
BaseMemoryLib
PrintLib
DebugLib
[Ppis]
gPeiUnixThunkPpiGuid # PPI ALWAYS_CONSUMED

View File

@ -1,230 +0,0 @@
/** @file
OEM hook status code library functions with no library constructor/destructor
Copyright (c) 2006 - 2010, 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
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: UnixOemHookStatusCodeLib.c
**/
#include <Guid/StatusCodeDataTypeId.h>
#include <Guid/StatusCodeDataTypeDebug.h>
#include <Ppi/UnixThunk.h>
#include <Library/OemHookStatusCodeLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/PeiServicesLib.h>
//
// Cache of UnixThunk protocol
//
EFI_UNIX_THUNK_PROTOCOL *mUnix;
//
// Cache of standard output handle .
//
int mStdOut;
/**
Initialize OEM status code device .
@return Always return EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
OemHookStatusCodeInitialize (
VOID
)
{
PEI_UNIX_THUNK_PPI *UnixThunkPpi;
EFI_STATUS Status;
//
// Locate Unix ThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi (
&gPeiUnixThunkPpiGuid,
0,
NULL,
(VOID **) &UnixThunkPpi
);
ASSERT_EFI_ERROR (Status);
mUnix = (EFI_UNIX_THUNK_PROTOCOL *) UnixThunkPpi->UnixThunk ();
//
// Cache standard output handle.
//
mStdOut = 1;
return EFI_SUCCESS;
}
/**
Report status code to OEM device.
@param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
@param Instance The enumeration of a hardware or software entity within the system.
A system may contain multiple entities that match a class/subclass pairing.
The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
not meaningful, or not relevant. Valid instance numbers start with 1.
@param CallerId This optional parameter may be used to identify the caller.
This parameter allows the status code driver to apply different rules to different callers.
Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
@param Data This optional parameter may be used to pass additional data
@return The function always return EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
OemHookStatusCodeReport (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
IN EFI_GUID *CallerId, OPTIONAL
IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
CHAR8 *Filename;
CHAR8 *Description;
CHAR8 *Format;
CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
UINT32 ErrorLevel;
UINT32 LineNumber;
UINTN CharCount;
BASE_LIST Marker;
Buffer[0] = '\0';
if (Data != NULL &&
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
//
// Print ASSERT() information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"\n\rASSERT!: %a (%d): %a\n\r",
Filename,
LineNumber,
Description
);
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
} else if (Data != NULL &&
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
//
// Print DEBUG() information into output buffer.
//
CharCount = AsciiBSPrint (
Buffer,
sizeof (Buffer),
Format,
Marker
);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
//
// Print ERROR information into output buffer.
//
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"ERROR: C%x:V%x I%x",
CodeType,
Value,
Instance
);
//
// Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
//
if (CallerId != NULL) {
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
" %g",
CallerId
);
}
if (Data != NULL) {
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
" %x",
Data
);
}
CharCount += AsciiSPrint (
&Buffer[CharCount - 1],
(sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
"\n\r"
);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"PROGRESS CODE: V%x I%x\n\r",
Value,
Instance
);
} else {
CharCount = AsciiSPrint (
Buffer,
sizeof (Buffer),
"Undefined: C%x:V%x I%x\n\r",
CodeType,
Value,
Instance
);
}
//
// Callout to standard output.
//
mUnix->Write (
mStdOut,
Buffer,
CharCount
);
return EFI_SUCCESS;
}

View File

@ -1,114 +0,0 @@
/**@file
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. 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
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:
PeiUnixPeCoffExtraActionLib.c
Abstract:
Provides services to perform additional actions to relocate and unload
PE/Coff image for UNIX environment specific purpose such as souce level debug.
This version only works for PEI phase
**/
#include <PiPei.h>
#include <Ppi/UnixThunk.h>
#include <Library/PeCoffLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/PeCoffExtraActionLib.h>
//
// Cache of UnixThunk protocol
//
EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL;
/**
The function caches the pointer of the Unix thunk functions
It will ASSERT() if Unix thunk ppi is not installed.
@retval EFI_SUCCESS WinNT thunk protocol is found and cached.
**/
EFI_STATUS
EFIAPI
UnixPeCoffGetUnixThunkStucture (
)
{
PEI_UNIX_THUNK_PPI *UnixThunkPpi;
EFI_STATUS Status;
//
// Locate Unix ThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi (
&gPeiUnixThunkPpiGuid,
0,
NULL,
(VOID **) &UnixThunkPpi
);
ASSERT_EFI_ERROR (Status);
mUnix = (EFI_UNIX_THUNK_PROTOCOL *) UnixThunkPpi->UnixThunk ();
return EFI_SUCCESS;
}
/**
Performs additional actions after a PE/COFF image has been loaded and relocated.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the
PE/COFF image that has already been loaded and relocated.
**/
VOID
EFIAPI
PeCoffLoaderRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mUnix == NULL) {
UnixPeCoffGetUnixThunkStucture ();
}
mUnix->PeCoffRelocateImageExtraAction (ImageContext);
}
/**
Performs additional actions just before a PE/COFF image is unloaded. Any resources
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
If ImageContext is NULL, then ASSERT().
@param ImageContext Pointer to the image context structure that describes the
PE/COFF image that is being unloaded.
**/
VOID
EFIAPI
PeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
if (mUnix == NULL) {
UnixPeCoffGetUnixThunkStucture ();
}
mUnix->PeCoffUnloadImageExtraAction (ImageContext);
}

View File

@ -1,45 +0,0 @@
## @file
# PeCoff extra action libary for Pei phase that run UNIX emulator.
#
# Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PeiUnixPeCoffExtraActionLib
FILE_GUID = 1D0D29DE-A5EC-46aa-AE8A-1A5A1F71F202
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
LIBRARY_CLASS = PeCoffExtraActionLib|PEI_CORE PEIM
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32
#
[Sources]
PeiUnixPeCoffExtraActionLib.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
BaseLib
PeiServicesLib
DebugLib
[Ppis]
gPeiUnixThunkPpiGuid # PPI ALWAYS_CONSUMED

View File

@ -1,61 +0,0 @@
/** @file
Allows an override of the SEC SEC PPI Dispatch Table. This allows
customized PPIs to be passed into the PEI Core.
Copyright (c) 2008 - 2010, Apple Inc. 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
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.
--*/
#include <PiPei.h>
#include <Library/BaseMemoryLib.h>
#include <Library/SecDispatchTableLib.h>
/**
Return the number of bytes that OverrideDispatchTable() will append to
the dispatch table.
@return Size of table in bytes OverrideDispatchTable() will return
**/
UINTN
EFIAPI
OverrideDispatchTableExtraSize (
)
{
return 0;
}
/**
Allow an override of the Sec PPI Dispatch Table. This table contains PPIs passed
up from SEC to PEI.
@param OriginalTable SECs default PPI dispatch table
@param OriginalTableSize Size of SECs default PPI dispatch table
@param NewTable New dispatch table
@param NewTableSize Size of of the NewTable in bytes
@return EFI_SUCCESS table was copied
**/
EFI_STATUS
EFIAPI
OverrideDispatchTable (
IN CONST EFI_PEI_PPI_DESCRIPTOR *OriginalTable,
IN UINTN OriginalTableSize,
IN OUT EFI_PEI_PPI_DESCRIPTOR *NewTable,
IN UINTN NewTableSize
)
{
CopyMem (NewTable, OriginalTable, OriginalTableSize);
return EFI_SUCCESS;
}

View File

@ -1,43 +0,0 @@
## @file
# A library to produce the global variable 'gUnix'
#
# This library contains a single global variable 'gUnix' along with a constructor to initialize that global.
# Copyright (c) 2006 - 2010, 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = NullSecDispatchTableLib
FILE_GUID = D9F3D6F5-97C4-469A-848B-03F742FCCEA3
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = SecDispatchTableLib
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
SecDispatchTableLib.c
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib

View File

@ -1,41 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
with the original integer's bit 63. The shifted value is returned.
This function shifts the 64-bit value Operand to the right by Count bits. The
high Count bits are set to bit 63 of Operand. The shifted value is returned.
If Count is greater than 63, then ASSERT().
@param Operand The 64-bit operand to shift right.
@param Count The number of bits to shift right.
@return Operand >> Count
**/
UINT64
EFIAPI
ARShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
ASSERT (Count < 64);
return InternalMathARShiftU64 (Operand, Count);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,868 +0,0 @@
/** @file
Bit field functions of BaseLib.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Worker function that returns a bit field from Operand.
Returns the bitfield specified by the StartBit and the EndBit from Operand.
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
@param EndBit The ordinal of the most significant bit in the bit field.
@return The bit field read.
**/
UINTN
EFIAPI
InternalBaseLibBitFieldReadUint (
IN UINTN Operand,
IN UINTN StartBit,
IN UINTN EndBit
)
{
//
// ~((UINTN)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
// are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
//
return (Operand & ~((UINTN)-2 << EndBit)) >> StartBit;
}
/**
Worker function that reads a bit field from Operand, performs a bitwise OR,
and returns the result.
Performs a bitwise OR between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData. All other bits in Operand are
preserved. The new value is returned.
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
@param EndBit The ordinal of the most significant bit in the bit field.
@param OrData The value to OR with the read value from the value.
@return The new value.
**/
UINTN
EFIAPI
InternalBaseLibBitFieldOrUint (
IN UINTN Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINTN OrData
)
{
//
// ~((UINTN)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
// are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
//
return Operand | ((OrData << StartBit) & ~((UINTN) -2 << EndBit));
}
/**
Worker function that reads a bit field from Operand, performs a bitwise AND,
and returns the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData. All other bits in Operand are
preserved. The new value is returned.
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
@param EndBit The ordinal of the most significant bit in the bit field.
@param AndData The value to And with the read value from the value.
@return The new value.
**/
UINTN
EFIAPI
InternalBaseLibBitFieldAndUint (
IN UINTN Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINTN AndData
)
{
//
// ~((UINTN)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
// are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
//
return Operand & ~((~AndData << StartBit) & ~((UINTN)-2 << EndBit));
}
/**
Returns a bit field from an 8-bit value.
Returns the bitfield specified by the StartBit and the EndBit from Operand.
If 8-bit operations are not supported, then ASSERT().
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..7.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..7.
@return The bit field read.
**/
UINT8
EFIAPI
BitFieldRead8 (
IN UINT8 Operand,
IN UINTN StartBit,
IN UINTN EndBit
)
{
ASSERT (EndBit < 8);
ASSERT (StartBit <= EndBit);
return (UINT8)InternalBaseLibBitFieldReadUint (Operand, StartBit, EndBit);
}
/**
Writes a bit field to an 8-bit value, and returns the result.
Writes Value to the bit field specified by the StartBit and the EndBit in
Operand. All other bits in Operand are preserved. The new 8-bit value is
returned.
If 8-bit operations are not supported, then ASSERT().
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..7.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..7.
@param Value The new value of the bit field.
@return The new 8-bit value.
**/
UINT8
EFIAPI
BitFieldWrite8 (
IN UINT8 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 Value
)
{
ASSERT (EndBit < 8);
ASSERT (StartBit <= EndBit);
return BitFieldAndThenOr8 (Operand, StartBit, EndBit, 0, Value);
}
/**
Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
result.
Performs a bitwise OR between the bit field specified by StartBit
and EndBit in Operand and the value specified by OrData. All other bits in
Operand are preserved. The new 8-bit value is returned.
If 8-bit operations are not supported, then ASSERT().
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..7.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..7.
@param OrData The value to OR with the read value from the value.
@return The new 8-bit value.
**/
UINT8
EFIAPI
BitFieldOr8 (
IN UINT8 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 OrData
)
{
ASSERT (EndBit < 8);
ASSERT (StartBit <= EndBit);
return (UINT8)InternalBaseLibBitFieldOrUint (Operand, StartBit, EndBit, OrData);
}
/**
Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData. All other bits in Operand are
preserved. The new 8-bit value is returned.
If 8-bit operations are not supported, then ASSERT().
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..7.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..7.
@param AndData The value to AND with the read value from the value.
@return The new 8-bit value.
**/
UINT8
EFIAPI
BitFieldAnd8 (
IN UINT8 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 AndData
)
{
ASSERT (EndBit < 8);
ASSERT (StartBit <= EndBit);
return (UINT8)InternalBaseLibBitFieldAndUint (Operand, StartBit, EndBit, AndData);
}
/**
Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
bitwise OR, and returns the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData, followed by a bitwise
OR with value specified by OrData. All other bits in Operand are
preserved. The new 8-bit value is returned.
If 8-bit operations are not supported, then ASSERT().
If StartBit is greater than 7, then ASSERT().
If EndBit is greater than 7, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..7.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..7.
@param AndData The value to AND with the read value from the value.
@param OrData The value to OR with the result of the AND operation.
@return The new 8-bit value.
**/
UINT8
EFIAPI
BitFieldAndThenOr8 (
IN UINT8 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT8 AndData,
IN UINT8 OrData
)
{
ASSERT (EndBit < 8);
ASSERT (StartBit <= EndBit);
return BitFieldOr8 (
BitFieldAnd8 (Operand, StartBit, EndBit, AndData),
StartBit,
EndBit,
OrData
);
}
/**
Returns a bit field from a 16-bit value.
Returns the bitfield specified by the StartBit and the EndBit from Operand.
If 16-bit operations are not supported, then ASSERT().
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..15.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..15.
@return The bit field read.
**/
UINT16
EFIAPI
BitFieldRead16 (
IN UINT16 Operand,
IN UINTN StartBit,
IN UINTN EndBit
)
{
ASSERT (EndBit < 16);
ASSERT (StartBit <= EndBit);
return (UINT16)InternalBaseLibBitFieldReadUint (Operand, StartBit, EndBit);
}
/**
Writes a bit field to a 16-bit value, and returns the result.
Writes Value to the bit field specified by the StartBit and the EndBit in
Operand. All other bits in Operand are preserved. The new 16-bit value is
returned.
If 16-bit operations are not supported, then ASSERT().
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..15.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..15.
@param Value The new value of the bit field.
@return The new 16-bit value.
**/
UINT16
EFIAPI
BitFieldWrite16 (
IN UINT16 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 Value
)
{
ASSERT (EndBit < 16);
ASSERT (StartBit <= EndBit);
return BitFieldAndThenOr16 (Operand, StartBit, EndBit, 0, Value);
}
/**
Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
result.
Performs a bitwise OR between the bit field specified by StartBit
and EndBit in Operand and the value specified by OrData. All other bits in
Operand are preserved. The new 16-bit value is returned.
If 16-bit operations are not supported, then ASSERT().
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..15.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..15.
@param OrData The value to OR with the read value from the value.
@return The new 16-bit value.
**/
UINT16
EFIAPI
BitFieldOr16 (
IN UINT16 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 OrData
)
{
ASSERT (EndBit < 16);
ASSERT (StartBit <= EndBit);
return (UINT16)InternalBaseLibBitFieldOrUint (Operand, StartBit, EndBit, OrData);
}
/**
Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData. All other bits in Operand are
preserved. The new 16-bit value is returned.
If 16-bit operations are not supported, then ASSERT().
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..15.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..15.
@param AndData The value to AND with the read value from the value.
@return The new 16-bit value.
**/
UINT16
EFIAPI
BitFieldAnd16 (
IN UINT16 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 AndData
)
{
ASSERT (EndBit < 16);
ASSERT (StartBit <= EndBit);
return (UINT16)InternalBaseLibBitFieldAndUint (Operand, StartBit, EndBit, AndData);
}
/**
Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
bitwise OR, and returns the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData, followed by a bitwise
OR with value specified by OrData. All other bits in Operand are
preserved. The new 16-bit value is returned.
If 16-bit operations are not supported, then ASSERT().
If StartBit is greater than 15, then ASSERT().
If EndBit is greater than 15, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..15.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..15.
@param AndData The value to AND with the read value from the value.
@param OrData The value to OR with the result of the AND operation.
@return The new 16-bit value.
**/
UINT16
EFIAPI
BitFieldAndThenOr16 (
IN UINT16 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT16 AndData,
IN UINT16 OrData
)
{
ASSERT (EndBit < 16);
ASSERT (StartBit <= EndBit);
return BitFieldOr16 (
BitFieldAnd16 (Operand, StartBit, EndBit, AndData),
StartBit,
EndBit,
OrData
);
}
/**
Returns a bit field from a 32-bit value.
Returns the bitfield specified by the StartBit and the EndBit from Operand.
If 32-bit operations are not supported, then ASSERT().
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..31.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..31.
@return The bit field read.
**/
UINT32
EFIAPI
BitFieldRead32 (
IN UINT32 Operand,
IN UINTN StartBit,
IN UINTN EndBit
)
{
ASSERT (EndBit < 32);
ASSERT (StartBit <= EndBit);
return (UINT32)InternalBaseLibBitFieldReadUint (Operand, StartBit, EndBit);
}
/**
Writes a bit field to a 32-bit value, and returns the result.
Writes Value to the bit field specified by the StartBit and the EndBit in
Operand. All other bits in Operand are preserved. The new 32-bit value is
returned.
If 32-bit operations are not supported, then ASSERT().
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..31.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..31.
@param Value The new value of the bit field.
@return The new 32-bit value.
**/
UINT32
EFIAPI
BitFieldWrite32 (
IN UINT32 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 Value
)
{
ASSERT (EndBit < 32);
ASSERT (StartBit <= EndBit);
return BitFieldAndThenOr32 (Operand, StartBit, EndBit, 0, Value);
}
/**
Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
result.
Performs a bitwise OR between the bit field specified by StartBit
and EndBit in Operand and the value specified by OrData. All other bits in
Operand are preserved. The new 32-bit value is returned.
If 32-bit operations are not supported, then ASSERT().
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..31.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..31.
@param OrData The value to OR with the read value from the value.
@return The new 32-bit value.
**/
UINT32
EFIAPI
BitFieldOr32 (
IN UINT32 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 OrData
)
{
ASSERT (EndBit < 32);
ASSERT (StartBit <= EndBit);
return (UINT32)InternalBaseLibBitFieldOrUint (Operand, StartBit, EndBit, OrData);
}
/**
Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData. All other bits in Operand are
preserved. The new 32-bit value is returned.
If 32-bit operations are not supported, then ASSERT().
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..31.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..31.
@param AndData The value to AND with the read value from the value.
@return The new 32-bit value.
**/
UINT32
EFIAPI
BitFieldAnd32 (
IN UINT32 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 AndData
)
{
ASSERT (EndBit < 32);
ASSERT (StartBit <= EndBit);
return (UINT32)InternalBaseLibBitFieldAndUint (Operand, StartBit, EndBit, AndData);
}
/**
Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
bitwise OR, and returns the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData, followed by a bitwise
OR with value specified by OrData. All other bits in Operand are
preserved. The new 32-bit value is returned.
If 32-bit operations are not supported, then ASSERT().
If StartBit is greater than 31, then ASSERT().
If EndBit is greater than 31, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..31.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..31.
@param AndData The value to AND with the read value from the value.
@param OrData The value to OR with the result of the AND operation.
@return The new 32-bit value.
**/
UINT32
EFIAPI
BitFieldAndThenOr32 (
IN UINT32 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT32 AndData,
IN UINT32 OrData
)
{
ASSERT (EndBit < 32);
ASSERT (StartBit <= EndBit);
return BitFieldOr32 (
BitFieldAnd32 (Operand, StartBit, EndBit, AndData),
StartBit,
EndBit,
OrData
);
}
/**
Returns a bit field from a 64-bit value.
Returns the bitfield specified by the StartBit and the EndBit from Operand.
If 64-bit operations are not supported, then ASSERT().
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..63.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..63.
@return The bit field read.
**/
UINT64
EFIAPI
BitFieldRead64 (
IN UINT64 Operand,
IN UINTN StartBit,
IN UINTN EndBit
)
{
ASSERT (EndBit < 64);
ASSERT (StartBit <= EndBit);
return RShiftU64 (Operand & ~LShiftU64 ((UINT64)-2, EndBit), StartBit);
}
/**
Writes a bit field to a 64-bit value, and returns the result.
Writes Value to the bit field specified by the StartBit and the EndBit in
Operand. All other bits in Operand are preserved. The new 64-bit value is
returned.
If 64-bit operations are not supported, then ASSERT().
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..63.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..63.
@param Value The new value of the bit field.
@return The new 64-bit value.
**/
UINT64
EFIAPI
BitFieldWrite64 (
IN UINT64 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT64 Value
)
{
ASSERT (EndBit < 64);
ASSERT (StartBit <= EndBit);
return BitFieldAndThenOr64 (Operand, StartBit, EndBit, 0, Value);
}
/**
Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
result.
Performs a bitwise OR between the bit field specified by StartBit
and EndBit in Operand and the value specified by OrData. All other bits in
Operand are preserved. The new 64-bit value is returned.
If 64-bit operations are not supported, then ASSERT().
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..63.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..63.
@param OrData The value to OR with the read value from the value
@return The new 64-bit value.
**/
UINT64
EFIAPI
BitFieldOr64 (
IN UINT64 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT64 OrData
)
{
UINT64 Value1;
UINT64 Value2;
ASSERT (EndBit < 64);
ASSERT (StartBit <= EndBit);
Value1 = LShiftU64 (OrData, StartBit);
Value2 = LShiftU64 ((UINT64) - 2, EndBit);
return Operand | (Value1 & ~Value2);
}
/**
Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData. All other bits in Operand are
preserved. The new 64-bit value is returned.
If 64-bit operations are not supported, then ASSERT().
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..63.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..63.
@param AndData The value to AND with the read value from the value.
@return The new 64-bit value.
**/
UINT64
EFIAPI
BitFieldAnd64 (
IN UINT64 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT64 AndData
)
{
UINT64 Value1;
UINT64 Value2;
ASSERT (EndBit < 64);
ASSERT (StartBit <= EndBit);
Value1 = LShiftU64 (~AndData, StartBit);
Value2 = LShiftU64 ((UINT64)-2, EndBit);
return Operand & ~(Value1 & ~Value2);
}
/**
Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
bitwise OR, and returns the result.
Performs a bitwise AND between the bit field specified by StartBit and EndBit
in Operand and the value specified by AndData, followed by a bitwise
OR with value specified by OrData. All other bits in Operand are
preserved. The new 64-bit value is returned.
If 64-bit operations are not supported, then ASSERT().
If StartBit is greater than 63, then ASSERT().
If EndBit is greater than 63, then ASSERT().
If EndBit is less than StartBit, then ASSERT().
@param Operand Operand on which to perform the bitfield operation.
@param StartBit The ordinal of the least significant bit in the bit field.
Range 0..63.
@param EndBit The ordinal of the most significant bit in the bit field.
Range 0..63.
@param AndData The value to AND with the read value from the value.
@param OrData The value to OR with the result of the AND operation.
@return The new 64-bit value.
**/
UINT64
EFIAPI
BitFieldAndThenOr64 (
IN UINT64 Operand,
IN UINTN StartBit,
IN UINTN EndBit,
IN UINT64 AndData,
IN UINT64 OrData
)
{
ASSERT (EndBit < 64);
ASSERT (StartBit <= EndBit);
return BitFieldOr64 (
BitFieldAnd64 (Operand, StartBit, EndBit, AndData),
StartBit,
EndBit,
OrData
);
}

View File

@ -1,337 +0,0 @@
/** @file
Utility functions to generate checksum based on 2's complement
algorithm.
Copyright (c) 2007 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Returns the sum of all elements in a buffer in unit of UINT8.
During calculation, the carry bits are dropped.
This function calculates the sum of all elements in a buffer
in unit of UINT8. The carry bits in result of addition are dropped.
The result is returned as UINT8. If Length is Zero, then Zero is
returned.
If Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the sum operation.
@param Length The size, in bytes, of Buffer.
@return Sum The sum of Buffer with carry bits dropped during additions.
**/
UINT8
EFIAPI
CalculateSum8 (
IN CONST UINT8 *Buffer,
IN UINTN Length
)
{
UINT8 Sum;
UINTN Count;
ASSERT (Buffer != NULL);
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
for (Sum = 0, Count = 0; Count < Length; Count++) {
Sum = (UINT8) (Sum + *(Buffer + Count));
}
return Sum;
}
/**
Returns the two's complement checksum of all elements in a buffer
of 8-bit values.
This function first calculates the sum of the 8-bit values in the
buffer specified by Buffer and Length. The carry bits in the result
of addition are dropped. Then, the two's complement of the sum is
returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the checksum operation.
@param Length The size, in bytes, of Buffer.
@return Checksum The 2's complement checksum of Buffer.
**/
UINT8
EFIAPI
CalculateCheckSum8 (
IN CONST UINT8 *Buffer,
IN UINTN Length
)
{
UINT8 CheckSum;
CheckSum = CalculateSum8 (Buffer, Length);
//
// Return the checksum based on 2's complement.
//
return (UINT8) (0x100 - CheckSum);
}
/**
Returns the sum of all elements in a buffer of 16-bit values. During
calculation, the carry bits are dropped.
This function calculates the sum of the 16-bit values in the buffer
specified by Buffer and Length. The carry bits in result of addition are dropped.
The 16-bit result is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
If Length is not aligned on a 16-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the sum operation.
@param Length The size, in bytes, of Buffer.
@return Sum The sum of Buffer with carry bits dropped during additions.
**/
UINT16
EFIAPI
CalculateSum16 (
IN CONST UINT16 *Buffer,
IN UINTN Length
)
{
UINT16 Sum;
UINTN Count;
UINTN Total;
ASSERT (Buffer != NULL);
ASSERT (((UINTN) Buffer & 0x1) == 0);
ASSERT ((Length & 0x1) == 0);
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
Total = Length / sizeof (*Buffer);
for (Sum = 0, Count = 0; Count < Total; Count++) {
Sum = (UINT16) (Sum + *(Buffer + Count));
}
return Sum;
}
/**
Returns the two's complement checksum of all elements in a buffer of
16-bit values.
This function first calculates the sum of the 16-bit values in the buffer
specified by Buffer and Length. The carry bits in the result of addition
are dropped. Then, the two's complement of the sum is returned. If Length
is 0, then 0 is returned.
If Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
If Length is not aligned on a 16-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the checksum operation.
@param Length The size, in bytes, of Buffer.
@return Checksum The 2's complement checksum of Buffer.
**/
UINT16
EFIAPI
CalculateCheckSum16 (
IN CONST UINT16 *Buffer,
IN UINTN Length
)
{
UINT16 CheckSum;
CheckSum = CalculateSum16 (Buffer, Length);
//
// Return the checksum based on 2's complement.
//
return (UINT16) (0x10000 - CheckSum);
}
/**
Returns the sum of all elements in a buffer of 32-bit values. During
calculation, the carry bits are dropped.
This function calculates the sum of the 32-bit values in the buffer
specified by Buffer and Length. The carry bits in result of addition are dropped.
The 32-bit result is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
If Length is not aligned on a 32-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the sum operation.
@param Length The size, in bytes, of Buffer.
@return Sum The sum of Buffer with carry bits dropped during additions.
**/
UINT32
EFIAPI
CalculateSum32 (
IN CONST UINT32 *Buffer,
IN UINTN Length
)
{
UINT32 Sum;
UINTN Count;
UINTN Total;
ASSERT (Buffer != NULL);
ASSERT (((UINTN) Buffer & 0x3) == 0);
ASSERT ((Length & 0x3) == 0);
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
Total = Length / sizeof (*Buffer);
for (Sum = 0, Count = 0; Count < Total; Count++) {
Sum = Sum + *(Buffer + Count);
}
return Sum;
}
/**
Returns the two's complement checksum of all elements in a buffer of
32-bit values.
This function first calculates the sum of the 32-bit values in the buffer
specified by Buffer and Length. The carry bits in the result of addition
are dropped. Then, the two's complement of the sum is returned. If Length
is 0, then 0 is returned.
If Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
If Length is not aligned on a 32-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the checksum operation.
@param Length The size, in bytes, of Buffer.
@return Checksum The 2's complement checksum of Buffer.
**/
UINT32
EFIAPI
CalculateCheckSum32 (
IN CONST UINT32 *Buffer,
IN UINTN Length
)
{
UINT32 CheckSum;
CheckSum = CalculateSum32 (Buffer, Length);
//
// Return the checksum based on 2's complement.
//
return (UINT32) ((UINT32)(-1) - CheckSum + 1);
}
/**
Returns the sum of all elements in a buffer of 64-bit values. During
calculation, the carry bits are dropped.
This function calculates the sum of the 64-bit values in the buffer
specified by Buffer and Length. The carry bits in result of addition are dropped.
The 64-bit result is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
If Length is not aligned on a 64-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the sum operation.
@param Length The size, in bytes, of Buffer.
@return Sum The sum of Buffer with carry bits dropped during additions.
**/
UINT64
EFIAPI
CalculateSum64 (
IN CONST UINT64 *Buffer,
IN UINTN Length
)
{
UINT64 Sum;
UINTN Count;
UINTN Total;
ASSERT (Buffer != NULL);
ASSERT (((UINTN) Buffer & 0x7) == 0);
ASSERT ((Length & 0x7) == 0);
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
Total = Length / sizeof (*Buffer);
for (Sum = 0, Count = 0; Count < Total; Count++) {
Sum = Sum + *(Buffer + Count);
}
return Sum;
}
/**
Returns the two's complement checksum of all elements in a buffer of
64-bit values.
This function first calculates the sum of the 64-bit values in the buffer
specified by Buffer and Length. The carry bits in the result of addition
are dropped. Then, the two's complement of the sum is returned. If Length
is 0, then 0 is returned.
If Buffer is NULL, then ASSERT().
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
If Length is not aligned on a 64-bit boundary, then ASSERT().
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
@param Buffer The pointer to the buffer to carry out the checksum operation.
@param Length The size, in bytes, of Buffer.
@return Checksum The 2's complement checksum of Buffer.
**/
UINT64
EFIAPI
CalculateCheckSum64 (
IN CONST UINT64 *Buffer,
IN UINTN Length
)
{
UINT64 CheckSum;
CheckSum = CalculateSum64 (Buffer, Length);
//
// Return the checksum based on 2's complement.
//
return (UINT64) ((UINT64)(-1) - CheckSum + 1);
}

View File

@ -1,24 +0,0 @@
/** @file
Provides hack function for passng GCC build.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Hack function for passing GCC build.
**/
VOID
__chkstk()
{
}

View File

@ -1,65 +0,0 @@
/** @file
Base Library CPU Functions for all architectures.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Disables CPU interrupts and returns the interrupt state prior to the disable
operation.
@retval TRUE CPU interrupts were enabled on entry to this call.
@retval FALSE CPU interrupts were disabled on entry to this call.
**/
BOOLEAN
EFIAPI
SaveAndDisableInterrupts (
VOID
)
{
BOOLEAN InterruptState;
InterruptState = GetInterruptState ();
DisableInterrupts ();
return InterruptState;
}
/**
Set the current CPU interrupt state.
Sets the current CPU interrupt state to the state specified by
InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
InterruptState is FALSE, then interrupts are disabled. InterruptState is
returned.
@param InterruptState TRUE if interrupts should be enabled. FALSE if
interrupts should be disabled.
@return InterruptState
**/
BOOLEAN
EFIAPI
SetInterruptState (
IN BOOLEAN InterruptState
)
{
if (InterruptState) {
EnableInterrupts ();
} else {
DisableInterrupts ();
}
return InterruptState;
}

View File

@ -1,38 +0,0 @@
/** @file
Base Library CPU Functions for all architectures.
Copyright (c) 2006 - 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
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.
**/
#include <Base.h>
#include <Library/BaseLib.h>
/**
Executes an infinite loop.
Forces the CPU to execute an infinite loop. A debugger may be used to skip
past the loop and the code that follows the loop must execute properly. This
implies that the infinite loop must not cause the code that follow it to be
optimized away.
**/
VOID
EFIAPI
CpuDeadLoop (
VOID
)
{
volatile UINTN Index;
for (Index = 0; Index == 0;);
}

View File

@ -1,53 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Divides a 64-bit signed integer by a 64-bit signed integer and generates a
64-bit signed result and a optional 64-bit signed remainder.
This function divides the 64-bit signed value Dividend by the 64-bit signed
value Divisor and generates a 64-bit signed quotient. If Remainder is not
NULL, then the 64-bit signed remainder is returned in Remainder. This
function returns the 64-bit signed quotient.
It is the caller's responsibility to not call this function with a Divisor of 0.
If Divisor is 0, then the quotient and remainder should be assumed to be
the largest negative integer.
If Divisor is 0, then ASSERT().
@param Dividend A 64-bit signed value.
@param Divisor A 64-bit signed value.
@param Remainder A pointer to a 64-bit signed value. This parameter is
optional and may be NULL.
@return Dividend / Divisor
**/
INT64
EFIAPI
DivS64x64Remainder (
IN INT64 Dividend,
IN INT64 Divisor,
OUT INT64 *Remainder OPTIONAL
)
{
ASSERT (Divisor != 0);
return InternalMathDivRemS64x64 (Dividend, Divisor, Remainder);
}

View File

@ -1,45 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
a 64-bit unsigned result.
This function divides the 64-bit unsigned value Dividend by the 32-bit
unsigned value Divisor and generates a 64-bit unsigned quotient. This
function returns the 64-bit unsigned quotient.
If Divisor is 0, then ASSERT().
@param Dividend A 64-bit unsigned value.
@param Divisor A 32-bit unsigned value.
@return Dividend / Divisor
**/
UINT64
EFIAPI
DivU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor
)
{
ASSERT (Divisor != 0);
return InternalMathDivU64x32 (Dividend, Divisor);
}

View File

@ -1,49 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
a 64-bit unsigned result and an optional 32-bit unsigned remainder.
This function divides the 64-bit unsigned value Dividend by the 32-bit
unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
This function returns the 64-bit unsigned quotient.
If Divisor is 0, then ASSERT().
@param Dividend A 64-bit unsigned value.
@param Divisor A 32-bit unsigned value.
@param Remainder A pointer to a 32-bit unsigned value. This parameter is
optional and may be NULL.
@return Dividend / Divisor
**/
UINT64
EFIAPI
DivU64x32Remainder (
IN UINT64 Dividend,
IN UINT32 Divisor,
OUT UINT32 *Remainder OPTIONAL
)
{
ASSERT (Divisor != 0);
return InternalMathDivRemU64x32 (Dividend, Divisor, Remainder);
}

View File

@ -1,49 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
a 64-bit unsigned result and an optional 64-bit unsigned remainder.
This function divides the 64-bit unsigned value Dividend by the 64-bit
unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
This function returns the 64-bit unsigned quotient.
If Divisor is 0, then ASSERT().
@param Dividend A 64-bit unsigned value.
@param Divisor A 64-bit unsigned value.
@param Remainder A pointer to a 64-bit unsigned value. This parameter is
optional and may be NULL.
@return Dividend / Divisor
**/
UINT64
EFIAPI
DivU64x64Remainder (
IN UINT64 Dividend,
IN UINT64 Divisor,
OUT UINT64 *Remainder OPTIONAL
)
{
ASSERT (Divisor != 0);
return InternalMathDivRemU64x64 (Dividend, Divisor, Remainder);
}

View File

@ -1,44 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Returns the value of the highest bit set in a 32-bit value. Equivalent to
1 << log2(x).
This function computes the value of the highest bit set in the 32-bit value
specified by Operand. If Operand is zero, then zero is returned.
@param Operand The 32-bit operand to evaluate.
@return 1 << HighBitSet32(Operand)
@retval 0 Operand is zero.
**/
UINT32
EFIAPI
GetPowerOfTwo32 (
IN UINT32 Operand
)
{
if (0 == Operand) {
return 0;
}
return 1ul << HighBitSet32 (Operand);
}

View File

@ -1,44 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Returns the value of the highest bit set in a 64-bit value. Equivalent to
1 << log2(x).
This function computes the value of the highest bit set in the 64-bit value
specified by Operand. If Operand is zero, then zero is returned.
@param Operand The 64-bit operand to evaluate.
@return 1 << HighBitSet64(Operand)
@retval 0 Operand is zero.
**/
UINT64
EFIAPI
GetPowerOfTwo64 (
IN UINT64 Operand
)
{
if (Operand == 0) {
return 0;
}
return LShiftU64 (1, (UINTN) HighBitSet64 (Operand));
}

View File

@ -1,47 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Returns the bit position of the highest bit set in a 32-bit value. Equivalent
to log2(x).
This function computes the bit position of the highest bit set in the 32-bit
value specified by Operand. If Operand is zero, then -1 is returned.
Otherwise, a value between 0 and 31 is returned.
@param Operand The 32-bit operand to evaluate.
@retval 0..31 Position of the highest bit set in Operand if found.
@retval -1 Operand is zero.
**/
INTN
EFIAPI
HighBitSet32 (
IN UINT32 Operand
)
{
INTN BitIndex;
if (Operand == 0) {
return - 1;
}
for (BitIndex = 31; (INT32)Operand > 0; BitIndex--, Operand <<= 1);
return BitIndex;
}

View File

@ -1,55 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Returns the bit position of the highest bit set in a 64-bit value. Equivalent
to log2(x).
This function computes the bit position of the highest bit set in the 64-bit
value specified by Operand. If Operand is zero, then -1 is returned.
Otherwise, a value between 0 and 63 is returned.
@param Operand The 64-bit operand to evaluate.
@retval 0..63 Position of the highest bit set in Operand if found.
@retval -1 Operand is zero.
**/
INTN
EFIAPI
HighBitSet64 (
IN UINT64 Operand
)
{
if (Operand == (UINT32)Operand) {
//
// Operand is just a 32-bit integer
//
return HighBitSet32 ((UINT32)Operand);
}
//
// Operand is really a 64-bit integer
//
if (sizeof (UINTN) == sizeof (UINT32)) {
return HighBitSet32 (((UINT32*)&Operand)[1]) + 32;
} else {
return HighBitSet32 ((UINT32)RShiftU64 (Operand, 32)) + 32;
}
}

View File

@ -1,42 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
with the high bits that were rotated.
This function rotates the 32-bit value Operand to the left by Count bits. The
low Count bits are fill with the high Count bits of Operand. The rotated
value is returned.
If Count is greater than 31, then ASSERT().
@param Operand The 32-bit operand to rotate left.
@param Count The number of bits to rotate left.
@return Operand << Count
**/
UINT32
EFIAPI
LRotU32 (
IN UINT32 Operand,
IN UINTN Count
)
{
ASSERT (Count < 32);
return (Operand << Count) | (Operand >> (32 - Count));
}

View File

@ -1,42 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
with the high bits that were rotated.
This function rotates the 64-bit value Operand to the left by Count bits. The
low Count bits are fill with the high Count bits of Operand. The rotated
value is returned.
If Count is greater than 63, then ASSERT().
@param Operand The 64-bit operand to rotate left.
@param Count The number of bits to rotate left.
@return Operand << Count
**/
UINT64
EFIAPI
LRotU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
ASSERT (Count < 64);
return InternalMathLRotU64 (Operand, Count);
}

View File

@ -1,41 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
with zeros. The shifted value is returned.
This function shifts the 64-bit value Operand to the left by Count bits. The
low Count bits are set to zero. The shifted value is returned.
If Count is greater than 63, then ASSERT().
@param Operand The 64-bit operand to shift left.
@param Count The number of bits to shift left.
@return Operand << Count.
**/
UINT64
EFIAPI
LShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
ASSERT (Count < 64);
return InternalMathLShiftU64 (Operand, Count);
}

View File

@ -1,550 +0,0 @@
/** @file
Linked List Library Functions.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Worker function that locates the Node in the List.
By searching the List, finds the location of the Node in List. At the same time,
verifies the validity of this list.
If List is NULL, then ASSERT().
If List->ForwardLink is NULL, then ASSERT().
If List->backLink is NULL, then ASSERT().
If Node is NULL, then ASSERT().
If PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE and Node
is in not a member of List, then return FALSE
If PcdMaximumLinkedListLenth is not zero, and List contains more than
PcdMaximumLinkedListLenth nodes, then ASSERT().
@param List A pointer to a node in a linked list.
@param Node A pointer to a node in a linked list.
@param VerifyNodeInList TRUE if a check should be made to see if Node is a
member of List. FALSE if no membership test should
be performed.
@retval TRUE if PcdVerifyNodeInList is FALSE
@retval TRUE if DoMembershipCheck is FALSE
@retval TRUE if PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE
and Node is a member of List.
@retval FALSE if PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE
and Node is in not a member of List.
**/
BOOLEAN
EFIAPI
InternalBaseLibIsNodeInList (
IN CONST LIST_ENTRY *List,
IN CONST LIST_ENTRY *Node,
IN BOOLEAN VerifyNodeInList
)
{
UINTN Count;
CONST LIST_ENTRY *Ptr;
//
// Test the validity of List and Node
//
ASSERT (List != NULL);
ASSERT (List->ForwardLink != NULL);
ASSERT (List->BackLink != NULL);
ASSERT (Node != NULL);
Count = 0;
Ptr = List;
if (FeaturePcdGet (PcdVerifyNodeInList) && VerifyNodeInList) {
//
// Check to see if Node is a member of List.
// Exit early if the number of nodes in List >= PcdMaximumLinkedListLength
//
do {
Ptr = Ptr->ForwardLink;
if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {
Count++;
//
// ASSERT() if the linked list is too long
//
ASSERT (Count < PcdGet32 (PcdMaximumLinkedListLength));
//
// Return if the linked list is too long
//
if (Count >= PcdGet32 (PcdMaximumLinkedListLength)) {
return (BOOLEAN)(Ptr == Node);
}
}
} while ((Ptr != List) && (Ptr != Node));
if (Ptr != Node) {
return FALSE;
}
}
if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {
//
// Count the total number of nodes in List.
// Exit early if the number of nodes in List >= PcdMaximumLinkedListLength
//
do {
Ptr = Ptr->ForwardLink;
Count++;
} while ((Ptr != List) && (Count < PcdGet32 (PcdMaximumLinkedListLength)));
//
// ASSERT() if the linked list is too long
//
ASSERT (Count < PcdGet32 (PcdMaximumLinkedListLength));
}
return TRUE;
}
/**
Initializes the head node of a doubly-linked list, and returns the pointer to
the head node of the doubly-linked list.
Initializes the forward and backward links of a new linked list. After
initializing a linked list with this function, the other linked list
functions may be used to add and remove nodes from the linked list. It is up
to the caller of this function to allocate the memory for ListHead.
If ListHead is NULL, then ASSERT().
@param ListHead A pointer to the head node of a new doubly-linked list.
@return ListHead
**/
LIST_ENTRY *
EFIAPI
InitializeListHead (
IN OUT LIST_ENTRY *ListHead
)
{
ASSERT (ListHead != NULL);
ListHead->ForwardLink = ListHead;
ListHead->BackLink = ListHead;
return ListHead;
}
/**
Adds a node to the beginning of a doubly-linked list, and returns the pointer
to the head node of the doubly-linked list.
Adds the node Entry at the beginning of the doubly-linked list denoted by
ListHead, and returns ListHead.
If ListHead is NULL, then ASSERT().
If Entry is NULL, then ASSERT().
If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
InitializeListHead(), then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
of nodes in ListHead, including the ListHead node, is greater than or
equal to PcdMaximumLinkedListLength, then ASSERT().
@param ListHead A pointer to the head node of a doubly-linked list.
@param Entry A pointer to a node that is to be inserted at the beginning
of a doubly-linked list.
@return ListHead
**/
LIST_ENTRY *
EFIAPI
InsertHeadList (
IN OUT LIST_ENTRY *ListHead,
IN OUT LIST_ENTRY *Entry
)
{
//
// ASSERT List not too long and Entry is not one of the nodes of List
//
ASSERT (InternalBaseLibIsNodeInList (ListHead, Entry, FALSE));
Entry->ForwardLink = ListHead->ForwardLink;
Entry->BackLink = ListHead;
Entry->ForwardLink->BackLink = Entry;
ListHead->ForwardLink = Entry;
return ListHead;
}
/**
Adds a node to the end of a doubly-linked list, and returns the pointer to
the head node of the doubly-linked list.
Adds the node Entry to the end of the doubly-linked list denoted by ListHead,
and returns ListHead.
If ListHead is NULL, then ASSERT().
If Entry is NULL, then ASSERT().
If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
InitializeListHead(), then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
of nodes in ListHead, including the ListHead node, is greater than or
equal to PcdMaximumLinkedListLength, then ASSERT().
@param ListHead A pointer to the head node of a doubly-linked list.
@param Entry A pointer to a node that is to be added at the end of the
doubly-linked list.
@return ListHead
**/
LIST_ENTRY *
EFIAPI
InsertTailList (
IN OUT LIST_ENTRY *ListHead,
IN OUT LIST_ENTRY *Entry
)
{
//
// ASSERT List not too long and Entry is not one of the nodes of List
//
ASSERT (InternalBaseLibIsNodeInList (ListHead, Entry, FALSE));
Entry->ForwardLink = ListHead;
Entry->BackLink = ListHead->BackLink;
Entry->BackLink->ForwardLink = Entry;
ListHead->BackLink = Entry;
return ListHead;
}
/**
Retrieves the first node of a doubly-linked list.
Returns the first node of a doubly-linked list. List must have been
initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
If List is empty, then List is returned.
If List is NULL, then ASSERT().
If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
InitializeListHead(), then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and the number of nodes
in List, including the List node, is greater than or equal to
PcdMaximumLinkedListLength, then ASSERT().
@param List A pointer to the head node of a doubly-linked list.
@return The first node of a doubly-linked list.
@retval NULL The list is empty.
**/
LIST_ENTRY *
EFIAPI
GetFirstNode (
IN CONST LIST_ENTRY *List
)
{
//
// ASSERT List not too long
//
ASSERT (InternalBaseLibIsNodeInList (List, List, FALSE));
return List->ForwardLink;
}
/**
Retrieves the next node of a doubly-linked list.
Returns the node of a doubly-linked list that follows Node.
List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
or InitializeListHead(). If List is empty, then List is returned.
If List is NULL, then ASSERT().
If Node is NULL, then ASSERT().
If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
InitializeListHead(), then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and List contains more than
PcdMaximumLinkedListLenth nodes, then ASSERT().
If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
@param List A pointer to the head node of a doubly-linked list.
@param Node A pointer to a node in the doubly-linked list.
@return A pointer to the next node if one exists. Otherwise List is returned.
**/
LIST_ENTRY *
EFIAPI
GetNextNode (
IN CONST LIST_ENTRY *List,
IN CONST LIST_ENTRY *Node
)
{
//
// ASSERT List not too long and Node is one of the nodes of List
//
ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));
return Node->ForwardLink;
}
/**
Retrieves the previous node of a doubly-linked list.
Returns the node of a doubly-linked list that precedes Node.
List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
or InitializeListHead(). If List is empty, then List is returned.
If List is NULL, then ASSERT().
If Node is NULL, then ASSERT().
If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
InitializeListHead(), then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and List contains more than
PcdMaximumLinkedListLenth nodes, then ASSERT().
If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
@param List A pointer to the head node of a doubly-linked list.
@param Node A pointer to a node in the doubly-linked list.
@return A pointer to the previous node if one exists. Otherwise List is returned.
**/
LIST_ENTRY *
EFIAPI
GetPreviousNode (
IN CONST LIST_ENTRY *List,
IN CONST LIST_ENTRY *Node
)
{
//
// ASSERT List not too long and Node is one of the nodes of List
//
ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));
return Node->BackLink;
}
/**
Checks to see if a doubly-linked list is empty or not.
Checks to see if the doubly-linked list is empty. If the linked list contains
zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
If ListHead is NULL, then ASSERT().
If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
InitializeListHead(), then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and the number of nodes
in List, including the List node, is greater than or equal to
PcdMaximumLinkedListLength, then ASSERT().
@param ListHead A pointer to the head node of a doubly-linked list.
@retval TRUE The linked list is empty.
@retval FALSE The linked list is not empty.
**/
BOOLEAN
EFIAPI
IsListEmpty (
IN CONST LIST_ENTRY *ListHead
)
{
//
// ASSERT List not too long
//
ASSERT (InternalBaseLibIsNodeInList (ListHead, ListHead, FALSE));
return (BOOLEAN)(ListHead->ForwardLink == ListHead);
}
/**
Determines if a node in a doubly-linked list is the head node of a the same
doubly-linked list. This function is typically used to terminate a loop that
traverses all the nodes in a doubly-linked list starting with the head node.
Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
nodes in the doubly-linked list specified by List. List must have been
initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
If List is NULL, then ASSERT().
If Node is NULL, then ASSERT().
If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and the number of nodes
in List, including the List node, is greater than or equal to
PcdMaximumLinkedListLength, then ASSERT().
If PcdVerifyNodeInList is TRUE and Node is not a node in List and Node is not
equal to List, then ASSERT().
@param List A pointer to the head node of a doubly-linked list.
@param Node A pointer to a node in the doubly-linked list.
@retval TRUE Node is one of the nodes in the doubly-linked list.
@retval FALSE Node is not one of the nodes in the doubly-linked list.
**/
BOOLEAN
EFIAPI
IsNull (
IN CONST LIST_ENTRY *List,
IN CONST LIST_ENTRY *Node
)
{
//
// ASSERT List not too long and Node is one of the nodes of List
//
ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));
return (BOOLEAN)(Node == List);
}
/**
Determines if a node the last node in a doubly-linked list.
Returns TRUE if Node is the last node in the doubly-linked list specified by
List. Otherwise, FALSE is returned. List must have been initialized with
INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
If List is NULL, then ASSERT().
If Node is NULL, then ASSERT().
If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
InitializeListHead(), then ASSERT().
If PcdMaximumLinkedListLenth is not zero, and the number of nodes
in List, including the List node, is greater than or equal to
PcdMaximumLinkedListLength, then ASSERT().
If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
@param List A pointer to the head node of a doubly-linked list.
@param Node A pointer to a node in the doubly-linked list.
@retval TRUE Node is the last node in the linked list.
@retval FALSE Node is not the last node in the linked list.
**/
BOOLEAN
EFIAPI
IsNodeAtEnd (
IN CONST LIST_ENTRY *List,
IN CONST LIST_ENTRY *Node
)
{
//
// ASSERT List not too long and Node is one of the nodes of List
//
ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));
return (BOOLEAN)(!IsNull (List, Node) && List->BackLink == Node);
}
/**
Swaps the location of two nodes in a doubly-linked list, and returns the
first node after the swap.
If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
Otherwise, the location of the FirstEntry node is swapped with the location
of the SecondEntry node in a doubly-linked list. SecondEntry must be in the
same double linked list as FirstEntry and that double linked list must have
been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
SecondEntry is returned after the nodes are swapped.
If FirstEntry is NULL, then ASSERT().
If SecondEntry is NULL, then ASSERT().
If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
same linked list, then ASSERT().
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
linked list containing the FirstEntry and SecondEntry nodes, including
the FirstEntry and SecondEntry nodes, is greater than or equal to
PcdMaximumLinkedListLength, then ASSERT().
@param FirstEntry A pointer to a node in a linked list.
@param SecondEntry A pointer to another node in the same linked list.
@return SecondEntry.
**/
LIST_ENTRY *
EFIAPI
SwapListEntries (
IN OUT LIST_ENTRY *FirstEntry,
IN OUT LIST_ENTRY *SecondEntry
)
{
LIST_ENTRY *Ptr;
if (FirstEntry == SecondEntry) {
return SecondEntry;
}
//
// ASSERT Entry1 and Entry2 are in the same linked list
//
ASSERT (InternalBaseLibIsNodeInList (FirstEntry, SecondEntry, TRUE));
//
// Ptr is the node pointed to by FirstEntry->ForwardLink
//
Ptr = RemoveEntryList (FirstEntry);
//
// If FirstEntry immediately follows SecondEntry, FirstEntry will be placed
// immediately in front of SecondEntry
//
if (Ptr->BackLink == SecondEntry) {
return InsertTailList (SecondEntry, FirstEntry);
}
//
// Ptr == SecondEntry means SecondEntry immediately follows FirstEntry,
// then there are no further steps necessary
//
if (Ptr == InsertHeadList (SecondEntry, FirstEntry)) {
return Ptr;
}
//
// Move SecondEntry to the front of Ptr
//
RemoveEntryList (SecondEntry);
InsertTailList (Ptr, SecondEntry);
return SecondEntry;
}
/**
Removes a node from a doubly-linked list, and returns the node that follows
the removed node.
Removes the node Entry from a doubly-linked list. It is up to the caller of
this function to release the memory used by this node if that is required. On
exit, the node following Entry in the doubly-linked list is returned. If
Entry is the only node in the linked list, then the head node of the linked
list is returned.
If Entry is NULL, then ASSERT().
If Entry is the head node of an empty list, then ASSERT().
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
linked list containing Entry, including the Entry node, is greater than
or equal to PcdMaximumLinkedListLength, then ASSERT().
@param Entry A pointer to a node in a linked list.
@return Entry.
**/
LIST_ENTRY *
EFIAPI
RemoveEntryList (
IN CONST LIST_ENTRY *Entry
)
{
ASSERT (!IsListEmpty (Entry));
Entry->ForwardLink->BackLink = Entry->BackLink;
Entry->BackLink->ForwardLink = Entry->ForwardLink;
return Entry->ForwardLink;
}

View File

@ -1,47 +0,0 @@
/** @file
Long Jump functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Restores the CPU context that was saved with SetJump().
Restores the CPU context from the buffer specified by JumpBuffer. This
function never returns to the caller. Instead is resumes execution based on
the state of JumpBuffer.
If JumpBuffer is NULL, then ASSERT().
For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
If Value is 0, then ASSERT().
@param JumpBuffer A pointer to CPU context buffer.
@param Value The value to return when the SetJump() context is
restored and must be non-zero.
**/
VOID
EFIAPI
LongJump (
IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
IN UINTN Value
)
{
InternalAssertJumpBuffer (JumpBuffer);
ASSERT (Value != 0);
InternalLongJump (JumpBuffer, Value);
}

View File

@ -1,47 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Returns the bit position of the lowest bit set in a 32-bit value.
This function computes the bit position of the lowest bit set in the 32-bit
value specified by Operand. If Operand is zero, then -1 is returned.
Otherwise, a value between 0 and 31 is returned.
@param Operand The 32-bit operand to evaluate.
@retval 0..31 The lowest bit set in Operand was found.
@retval -1 Operand is zero.
**/
INTN
EFIAPI
LowBitSet32 (
IN UINT32 Operand
)
{
INTN BitIndex;
if (Operand == 0) {
return -1;
}
for (BitIndex = 0; 0 == (Operand & 1); BitIndex++, Operand >>= 1);
return BitIndex;
}

View File

@ -1,50 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Returns the bit position of the lowest bit set in a 64-bit value.
This function computes the bit position of the lowest bit set in the 64-bit
value specified by Operand. If Operand is zero, then -1 is returned.
Otherwise, a value between 0 and 63 is returned.
@param Operand The 64-bit operand to evaluate.
@retval 0..63 The lowest bit set in Operand was found.
@retval -1 Operand is zero.
**/
INTN
EFIAPI
LowBitSet64 (
IN UINT64 Operand
)
{
INTN BitIndex;
if (Operand == 0) {
return -1;
}
for (BitIndex = 0;
(Operand & 1) == 0;
BitIndex++, Operand = RShiftU64 (Operand, 1));
return BitIndex;
}

View File

@ -1,368 +0,0 @@
/** @file
Leaf math worker functions that require 64-bit arithmetic support from the
compiler.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Shifts a 64-bit integer left between 0 and 63 bits. The low bits
are filled with zeros. The shifted value is returned.
This function shifts the 64-bit value Operand to the left by Count bits. The
low Count bits are set to zero. The shifted value is returned.
@param Operand The 64-bit operand to shift left.
@param Count The number of bits to shift left.
@return Operand << Count.
**/
UINT64
EFIAPI
InternalMathLShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
return Operand << Count;
}
/**
Shifts a 64-bit integer right between 0 and 63 bits. This high bits
are filled with zeros. The shifted value is returned.
This function shifts the 64-bit value Operand to the right by Count bits. The
high Count bits are set to zero. The shifted value is returned.
@param Operand The 64-bit operand to shift right.
@param Count The number of bits to shift right.
@return Operand >> Count.
**/
UINT64
EFIAPI
InternalMathRShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
return Operand >> Count;
}
/**
Shifts a 64-bit integer right between 0 and 63 bits. The high bits
are filled with original integer's bit 63. The shifted value is returned.
This function shifts the 64-bit value Operand to the right by Count bits. The
high Count bits are set to bit 63 of Operand. The shifted value is returned.
@param Operand The 64-bit operand to shift right.
@param Count The number of bits to shift right.
@return Operand arithmetically shifted right by Count.
**/
UINT64
EFIAPI
InternalMathARShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
INTN TestValue;
//
// Test if this compiler supports arithmetic shift
//
TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1));
if (TestValue == -1) {
//
// Arithmetic shift is supported
//
return (UINT64)((INT64)Operand >> Count);
}
//
// Arithmetic is not supported
//
return (Operand >> Count) |
((INTN)Operand < 0 ? ~((UINTN)-1 >> Count) : 0);
}
/**
Rotates a 64-bit integer left between 0 and 63 bits, filling
the low bits with the high bits that were rotated.
This function rotates the 64-bit value Operand to the left by Count bits. The
low Count bits are fill with the high Count bits of Operand. The rotated
value is returned.
@param Operand The 64-bit operand to rotate left.
@param Count The number of bits to rotate left.
@return Operand <<< Count.
**/
UINT64
EFIAPI
InternalMathLRotU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
return (Operand << Count) | (Operand >> (64 - Count));
}
/**
Rotates a 64-bit integer right between 0 and 63 bits, filling
the high bits with the high low bits that were rotated.
This function rotates the 64-bit value Operand to the right by Count bits.
The high Count bits are fill with the low Count bits of Operand. The rotated
value is returned.
@param Operand The 64-bit operand to rotate right.
@param Count The number of bits to rotate right.
@return Operand >>> Count.
**/
UINT64
EFIAPI
InternalMathRRotU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
return (Operand >> Count) | (Operand << (64 - Count));
}
/**
Switches the endianess of a 64-bit integer.
This function swaps the bytes in a 64-bit unsigned value to switch the value
from little endian to big endian or vice versa. The byte swapped value is
returned.
@param Operand A 64-bit unsigned value.
@return The byte swapped Operand.
**/
UINT64
EFIAPI
InternalMathSwapBytes64 (
IN UINT64 Operand
)
{
UINT64 LowerBytes;
UINT64 HigherBytes;
LowerBytes = (UINT64) SwapBytes32 ((UINT32) Operand);
HigherBytes = (UINT64) SwapBytes32 ((UINT32) (Operand >> 32));
return (LowerBytes << 32 | HigherBytes);
}
/**
Multiplies a 64-bit unsigned integer by a 32-bit unsigned integer
and generates a 64-bit unsigned result.
This function multiplies the 64-bit unsigned value Multiplicand by the 32-bit
unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
bit unsigned result is returned.
@param Multiplicand A 64-bit unsigned value.
@param Multiplier A 32-bit unsigned value.
@return Multiplicand * Multiplier
**/
UINT64
EFIAPI
InternalMathMultU64x32 (
IN UINT64 Multiplicand,
IN UINT32 Multiplier
)
{
return Multiplicand * Multiplier;
}
/**
Multiplies a 64-bit unsigned integer by a 64-bit unsigned integer
and generates a 64-bit unsigned result.
This function multiplies the 64-bit unsigned value Multiplicand by the 64-bit
unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
bit unsigned result is returned.
@param Multiplicand A 64-bit unsigned value.
@param Multiplier A 64-bit unsigned value.
@return Multiplicand * Multiplier.
**/
UINT64
EFIAPI
InternalMathMultU64x64 (
IN UINT64 Multiplicand,
IN UINT64 Multiplier
)
{
return Multiplicand * Multiplier;
}
/**
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
generates a 64-bit unsigned result.
This function divides the 64-bit unsigned value Dividend by the 32-bit
unsigned value Divisor and generates a 64-bit unsigned quotient. This
function returns the 64-bit unsigned quotient.
@param Dividend A 64-bit unsigned value.
@param Divisor A 32-bit unsigned value.
@return Dividend / Divisor.
**/
UINT64
EFIAPI
InternalMathDivU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor
)
{
return Dividend / Divisor;
}
/**
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
generates a 32-bit unsigned remainder.
This function divides the 64-bit unsigned value Dividend by the 32-bit
unsigned value Divisor and generates a 32-bit remainder. This function
returns the 32-bit unsigned remainder.
@param Dividend A 64-bit unsigned value.
@param Divisor A 32-bit unsigned value.
@return Dividend % Divisor.
**/
UINT32
EFIAPI
InternalMathModU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor
)
{
return (UINT32)(Dividend % Divisor);
}
/**
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
This function divides the 64-bit unsigned value Dividend by the 32-bit
unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
This function returns the 64-bit unsigned quotient.
@param Dividend A 64-bit unsigned value.
@param Divisor A 32-bit unsigned value.
@param Remainder A pointer to a 32-bit unsigned value. This parameter is
optional and may be NULL.
@return Dividend / Divisor.
**/
UINT64
EFIAPI
InternalMathDivRemU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor,
OUT UINT32 *Remainder OPTIONAL
)
{
if (Remainder != NULL) {
*Remainder = (UINT32)(Dividend % Divisor);
}
return Dividend / Divisor;
}
/**
Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
This function divides the 64-bit unsigned value Dividend by the 64-bit
unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
This function returns the 64-bit unsigned quotient.
@param Dividend A 64-bit unsigned value.
@param Divisor A 64-bit unsigned value.
@param Remainder A pointer to a 64-bit unsigned value. This parameter is
optional and may be NULL.
@return Dividend / Divisor
**/
UINT64
EFIAPI
InternalMathDivRemU64x64 (
IN UINT64 Dividend,
IN UINT64 Divisor,
OUT UINT64 *Remainder OPTIONAL
)
{
if (Remainder != NULL) {
*Remainder = Dividend % Divisor;
}
return Dividend / Divisor;
}
/**
Divides a 64-bit signed integer by a 64-bit signed integer and
generates a 64-bit signed result and an optional 64-bit signed remainder.
This function divides the 64-bit signed value Dividend by the 64-bit
signed value Divisor and generates a 64-bit signed quotient. If Remainder
is not NULL, then the 64-bit signed remainder is returned in Remainder.
This function returns the 64-bit signed quotient.
@param Dividend A 64-bit signed value.
@param Divisor A 64-bit signed value.
@param Remainder A pointer to a 64-bit signed value. This parameter is
optional and may be NULL.
@return Dividend / Divisor.
**/
INT64
EFIAPI
InternalMathDivRemS64x64 (
IN INT64 Dividend,
IN INT64 Divisor,
OUT INT64 *Remainder OPTIONAL
)
{
if (Remainder != NULL) {
*Remainder = Dividend % Divisor;
}
return Dividend / Divisor;
}

View File

@ -1,45 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
a 32-bit unsigned remainder.
This function divides the 64-bit unsigned value Dividend by the 32-bit
unsigned value Divisor and generates a 32-bit remainder. This function
returns the 32-bit unsigned remainder.
If Divisor is 0, then ASSERT().
@param Dividend A 64-bit unsigned value.
@param Divisor A 32-bit unsigned value.
@return Dividend % Divisor.
**/
UINT32
EFIAPI
ModU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor
)
{
ASSERT (Divisor != 0);
return InternalMathModU64x32 (Dividend, Divisor);
}

View File

@ -1,42 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Multiplies a 64-bit signed integer by a 64-bit signed integer and generates a
64-bit signed result.
This function multiplies the 64-bit signed value Multiplicand by the 64-bit
signed value Multiplier and generates a 64-bit signed result. This 64-bit
signed result is returned.
@param Multiplicand A 64-bit signed value.
@param Multiplier A 64-bit signed value.
@return Multiplicand * Multiplier.
**/
INT64
EFIAPI
MultS64x64 (
IN INT64 Multiplicand,
IN INT64 Multiplier
)
{
return (INT64)MultU64x64 ((UINT64) Multiplicand, (UINT64) Multiplier);
}

View File

@ -1,46 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Multiplies a 64-bit unsigned integer by a 32-bit unsigned integer and
generates a 64-bit unsigned result.
This function multiplies the 64-bit unsigned value Multiplicand by the 32-bit
unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
bit unsigned result is returned.
@param Multiplicand A 64-bit unsigned value.
@param Multiplier A 32-bit unsigned value.
@return Multiplicand * Multiplier.
**/
UINT64
EFIAPI
MultU64x32 (
IN UINT64 Multiplicand,
IN UINT32 Multiplier
)
{
UINT64 Result;
Result = InternalMathMultU64x32 (Multiplicand, Multiplier);
return Result;
}

View File

@ -1,46 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Multiplies a 64-bit unsigned integer by a 64-bit unsigned integer and
generates a 64-bit unsigned result.
This function multiplies the 64-bit unsigned value Multiplicand by the 64-bit
unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
bit unsigned result is returned.
@param Multiplicand A 64-bit unsigned value.
@param Multiplier A 64-bit unsigned value.
@return Multiplicand * Multiplier.
**/
UINT64
EFIAPI
MultU64x64 (
IN UINT64 Multiplicand,
IN UINT64 Multiplier
)
{
UINT64 Result;
Result = InternalMathMultU64x64 (Multiplicand, Multiplier);
return Result;
}

View File

@ -1,42 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
with the low bits that were rotated.
This function rotates the 32-bit value Operand to the right by Count bits.
The high Count bits are fill with the low Count bits of Operand. The rotated
value is returned.
If Count is greater than 31, then ASSERT().
@param Operand The 32-bit operand to rotate right.
@param Count The number of bits to rotate right.
@return Operand >> Count.
**/
UINT32
EFIAPI
RRotU32 (
IN UINT32 Operand,
IN UINTN Count
)
{
ASSERT (Count < 32);
return (Operand >> Count) | (Operand << (32 - Count));
}

View File

@ -1,42 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
with the high low bits that were rotated.
This function rotates the 64-bit value Operand to the right by Count bits.
The high Count bits are fill with the low Count bits of Operand. The rotated
value is returned.
If Count is greater than 63, then ASSERT().
@param Operand The 64-bit operand to rotate right.
@param Count The number of bits to rotate right.
@return Operand >> Count.
**/
UINT64
EFIAPI
RRotU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
ASSERT (Count < 64);
return InternalMathRRotU64 (Operand, Count);
}

View File

@ -1,41 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
filled with zeros. The shifted value is returned.
This function shifts the 64-bit value Operand to the right by Count bits. The
high Count bits are set to zero. The shifted value is returned.
If Count is greater than 63, then ASSERT().
@param Operand The 64-bit operand to shift right.
@param Count The number of bits to shift right.
@return Operand >> Count.
**/
UINT64
EFIAPI
RShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
ASSERT (Count < 64);
return InternalMathRShiftU64 (Operand, Count);
}

View File

@ -1,40 +0,0 @@
/** @file
Internal ASSERT () functions for SetJump.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Worker function that checks ASSERT condition for JumpBuffer
Checks ASSERT condition for JumpBuffer.
If JumpBuffer is NULL, then ASSERT().
For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
@param JumpBuffer A pointer to CPU context buffer.
**/
VOID
EFIAPI
InternalAssertJumpBuffer (
IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
)
{
ASSERT (JumpBuffer != NULL);
ASSERT (((UINTN)JumpBuffer & (BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT - 1)) == 0);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Switches the endianess of a 16-bit integer.
This function swaps the bytes in a 16-bit unsigned value to switch the value
from little endian to big endian or vice versa. The byte swapped value is
returned.
@param Value A 16-bit unsigned value.
@return The byte swapped Value.
**/
UINT16
EFIAPI
SwapBytes16 (
IN UINT16 Value
)
{
return (UINT16) ((Value<< 8) | (Value>> 8));
}

View File

@ -1,45 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Switches the endianess of a 32-bit integer.
This function swaps the bytes in a 32-bit unsigned value to switch the value
from little endian to big endian or vice versa. The byte swapped value is
returned.
@param Value A 32-bit unsigned value.
@return The byte swapped Value.
**/
UINT32
EFIAPI
SwapBytes32 (
IN UINT32 Value
)
{
UINT32 LowerBytes;
UINT32 HigherBytes;
LowerBytes = (UINT32) SwapBytes16 ((UINT16) Value);
HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Value >> 16));
return (LowerBytes << 16 | HigherBytes);
}

View File

@ -1,39 +0,0 @@
/** @file
Math worker functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Switches the endianess of a 64-bit integer.
This function swaps the bytes in a 64-bit unsigned value to switch the value
from little endian to big endian or vice versa. The byte swapped value is
returned.
@param Value A 64-bit unsigned value.
@return The byte swapped Value.
**/
UINT64
EFIAPI
SwapBytes64 (
IN UINT64 Value
)
{
return InternalMathSwapBytes64 (Value);
}

View File

@ -1,76 +0,0 @@
/** @file
Switch Stack functions.
Copyright (c) 2006 - 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
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.
**/
#include "BaseLibInternals.h"
/**
Transfers control to a function starting with a new stack.
Transfers control to the function specified by EntryPoint using the
new stack specified by NewStack and passing in the parameters specified
by Context1 and Context2. Context1 and Context2 are optional and may
be NULL. The function EntryPoint must never return. This function
supports a variable number of arguments following the NewStack parameter.
These additional arguments are ignored on IA-32, x64, and EBC.
IPF CPUs expect one additional parameter of type VOID * that specifies
the new backing store pointer.
If EntryPoint is NULL, then ASSERT().
If NewStack is NULL, then ASSERT().
@param EntryPoint A pointer to function to call with the new stack.
@param Context1 A pointer to the context to pass into the EntryPoint
function.
@param Context2 A pointer to the context to pass into the EntryPoint
function.
@param NewStack A pointer to the new stack to use for the EntryPoint
function.
@param ... This variable argument list is ignored for IA32, x64, and EBC.
For IPF, this variable argument list is expected to contain
a single parameter of type VOID * that specifies the new backing
store pointer.
**/
VOID
EFIAPI
SwitchStack (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
IN VOID *Context1, OPTIONAL
IN VOID *Context2, OPTIONAL
IN VOID *NewStack,
...
)
{
VA_LIST Marker;
ASSERT (EntryPoint != NULL);
ASSERT (NewStack != NULL);
//
// New stack must be aligned with CPU_STACK_ALIGNMENT
//
ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
VA_START (Marker, NewStack);
InternalSwitchStack (EntryPoint, Context1, Context2, NewStack, Marker);
VA_END (Marker);
//
// InternalSwitchStack () will never return
//
ASSERT (FALSE);
}

View File

@ -1,222 +0,0 @@
/** @file
Unaligned access functions of BaseLib.
Copyright (c) 2006 - 2010, 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
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.
**/
#include "BaseLibInternals.h"
/**
Reads a 16-bit value from memory that may be unaligned.
This function returns the 16-bit value pointed to by Buffer. The function
guarantees that the read operation does not produce an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 16-bit value that may be unaligned.
@return The 16-bit value read from Buffer.
**/
UINT16
EFIAPI
ReadUnaligned16 (
IN CONST UINT16 *Buffer
)
{
ASSERT (Buffer != NULL);
return *Buffer;
}
/**
Writes a 16-bit value to memory that may be unaligned.
This function writes the 16-bit value specified by Value to Buffer. Value is
returned. The function guarantees that the write operation does not produce
an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 16-bit value that may be unaligned.
@param Value 16-bit value to write to Buffer.
@return The 16-bit value to write to Buffer.
**/
UINT16
EFIAPI
WriteUnaligned16 (
OUT UINT16 *Buffer,
IN UINT16 Value
)
{
ASSERT (Buffer != NULL);
return *Buffer = Value;
}
/**
Reads a 24-bit value from memory that may be unaligned.
This function returns the 24-bit value pointed to by Buffer. The function
guarantees that the read operation does not produce an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 24-bit value that may be unaligned.
@return The 24-bit value read from Buffer.
**/
UINT32
EFIAPI
ReadUnaligned24 (
IN CONST UINT32 *Buffer
)
{
ASSERT (Buffer != NULL);
return *Buffer & 0xffffff;
}
/**
Writes a 24-bit value to memory that may be unaligned.
This function writes the 24-bit value specified by Value to Buffer. Value is
returned. The function guarantees that the write operation does not produce
an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 24-bit value that may be unaligned.
@param Value 24-bit value to write to Buffer.
@return The 24-bit value to write to Buffer.
**/
UINT32
EFIAPI
WriteUnaligned24 (
OUT UINT32 *Buffer,
IN UINT32 Value
)
{
ASSERT (Buffer != NULL);
*Buffer = BitFieldWrite32 (*Buffer, 0, 23, Value);
return Value;
}
/**
Reads a 32-bit value from memory that may be unaligned.
This function returns the 32-bit value pointed to by Buffer. The function
guarantees that the read operation does not produce an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 32-bit value that may be unaligned.
@return The 32-bit value read from Buffer.
**/
UINT32
EFIAPI
ReadUnaligned32 (
IN CONST UINT32 *Buffer
)
{
ASSERT (Buffer != NULL);
return *Buffer;
}
/**
Writes a 32-bit value to memory that may be unaligned.
This function writes the 32-bit value specified by Value to Buffer. Value is
returned. The function guarantees that the write operation does not produce
an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 32-bit value that may be unaligned.
@param Value The 32-bit value to write to Buffer.
@return The 32-bit value to write to Buffer.
**/
UINT32
EFIAPI
WriteUnaligned32 (
OUT UINT32 *Buffer,
IN UINT32 Value
)
{
ASSERT (Buffer != NULL);
return *Buffer = Value;
}
/**
Reads a 64-bit value from memory that may be unaligned.
This function returns the 64-bit value pointed to by Buffer. The function
guarantees that the read operation does not produce an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 64-bit value that may be unaligned.
@return The 64-bit value read from Buffer.
**/
UINT64
EFIAPI
ReadUnaligned64 (
IN CONST UINT64 *Buffer
)
{
ASSERT (Buffer != NULL);
return *Buffer;
}
/**
Writes a 64-bit value to memory that may be unaligned.
This function writes the 64-bit value specified by Value to Buffer. Value is
returned. The function guarantees that the write operation does not produce
an alignment fault.
If the Buffer is NULL, then ASSERT().
@param Buffer A pointer to a 64-bit value that may be unaligned.
@param Value The 64-bit value to write to Buffer.
@return The 64-bit value to write to Buffer.
**/
UINT64
EFIAPI
WriteUnaligned64 (
OUT UINT64 *Buffer,
IN UINT64 Value
)
{
ASSERT (Buffer != NULL);
return *Buffer = Value;
}

View File

@ -1,201 +0,0 @@
## @file
# Base Library implementation for X64 UnixPkg. X64 code writes CR3 so to
# not change MdeModulePkg DxeIpl we need a UnixPkg copy of the BaseLib.
#
# Currently I'm debugging UnixPkg with SVR V ABI so there are some
# temp changes for that too.
#
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2009, Apple Inc. 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
# 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseLib
FILE_GUID = 25A41BF7-7718-4e9a-9A7E-50DC324929FD
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = BaseLib
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM
#
[Sources]
CheckSum.c
SwitchStack.c
SwapBytes64.c
SwapBytes32.c
SwapBytes16.c
LongJump.c
SetJump.c
RShiftU64.c
RRotU64.c
RRotU32.c
MultU64x64.c
MultU64x32.c
MultS64x64.c
ModU64x32.c
LShiftU64.c
LRotU64.c
LRotU32.c
LowBitSet64.c
LowBitSet32.c
HighBitSet64.c
HighBitSet32.c
GetPowerOfTwo64.c
GetPowerOfTwo32.c
DivU64x64Remainder.c
DivU64x32Remainder.c
DivU64x32.c
DivS64x64Remainder.c
ARShiftU64.c
BitField.c
CpuDeadLoop.c
Cpu.c
LinkedList.c
String.c
BaseLibInternals.h
[Sources.X64]
X64/Thunk16.asm
X64/CpuPause.asm
X64/EnableDisableInterrupts.asm
X64/DisableInterrupts.asm
X64/EnableInterrupts.asm
X64/FlushCacheLine.asm
X64/Invd.asm
X64/Wbinvd.asm
X64/DisablePaging64.asm
X64/Mwait.asm
X64/Monitor.asm
X64/ReadPmc.asm
X64/ReadTsc.asm
X64/WriteMm7.asm
X64/WriteMm6.asm
X64/WriteMm5.asm
X64/WriteMm4.asm
X64/WriteMm3.asm
X64/WriteMm2.asm
X64/WriteMm1.asm
X64/WriteMm0.asm
X64/ReadMm7.asm
X64/ReadMm6.asm
X64/ReadMm5.asm
X64/ReadMm4.asm
X64/ReadMm3.asm
X64/ReadMm2.asm
X64/ReadMm1.asm
X64/ReadMm0.asm
X64/FxRestore.asm
X64/FxSave.asm
X64/WriteLdtr.asm
X64/ReadLdtr.asm
X64/WriteIdtr.asm
X64/ReadIdtr.asm
X64/WriteGdtr.asm
X64/ReadGdtr.asm
X64/ReadTr.asm
X64/ReadSs.asm
X64/ReadGs.asm
X64/ReadFs.asm
X64/ReadEs.asm
X64/ReadDs.asm
X64/ReadCs.asm
X64/WriteDr7.asm
X64/WriteDr6.asm
X64/WriteDr5.asm
X64/WriteDr4.asm
X64/WriteDr3.asm
X64/WriteDr2.asm
X64/WriteDr1.asm
X64/WriteDr0.asm
X64/ReadDr7.asm
X64/ReadDr6.asm
X64/ReadDr5.asm
X64/ReadDr4.asm
X64/ReadDr3.asm
X64/ReadDr2.asm
X64/ReadDr1.asm
X64/ReadDr0.asm
X64/WriteCr4.asm
X64/WriteCr3.asm
X64/WriteCr2.asm
X64/WriteCr0.asm
X64/ReadCr4.asm
X64/ReadCr3.asm
X64/ReadCr2.asm
X64/ReadCr0.asm
X64/ReadEflags.asm
X64/CpuIdEx.asm
X64/CpuId.asm
X64/LongJump.asm
X64/SetJump.asm
X64/SwitchStack.asm
X64/EnableCache.asm
X64/DisableCache.asm
X64/CpuBreakpoint.c | MSFT
X64/WriteMsr64.c | MSFT
X64/ReadMsr64.c | MSFT
X64/CpuBreakpoint.asm | INTEL
X64/WriteMsr64.asm | INTEL
X64/ReadMsr64.asm | INTEL
X64/Non-existing.c
Math64.c
Unaligned.c
X86WriteIdtr.c
X86WriteGdtr.c
X86Thunk.c
X86ReadIdtr.c
X86ReadGdtr.c
X86Msr.c
X86MemoryFence.c | MSFT
X86MemoryFence.c | INTEL
X86GetInterruptState.c
X86FxSave.c
X86FxRestore.c
X86EnablePaging64.c
X86EnablePaging32.c
X86DisablePaging64.c
X86DisablePaging32.c
X64/GccInline.c | GCC
X64/Thunk16.S | GCC
X64/SwitchStack.S | GCC
X64/SetJump.S | GCC
X64/LongJump.S | GCC
X64/EnableDisableInterrupts.S | GCC
X64/DisablePaging64.S | GCC
X64/CpuId.S | GCC
X64/CpuIdEx.S | GCC
X64/EnableCache.S | GCC
X64/DisableCache.S | GCC
ChkStkGcc.c | GCC
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
PcdLib
DebugLib
BaseMemoryLib
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength
gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList

View File

@ -1,25 +0,0 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 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
# 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:
#
# CpuBreakpoint.S
#
# Abstract:
#
# Implementation of CpuBreakpoint() on x86_64
#
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(CpuBreakpoint)
ASM_PFX(CpuBreakpoint):
int $0x3
ret

View File

@ -1,37 +0,0 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2006, 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
; 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:
;
; CpuBreakpoint.Asm
;
; Abstract:
;
; CpuBreakpoint function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; CpuBreakpoint (
; VOID
; );
;------------------------------------------------------------------------------
CpuBreakpoint PROC
int 3
ret
CpuBreakpoint ENDP
END

View File

@ -1,39 +0,0 @@
/** @file
CpuBreakpoint function.
Copyright (c) 2006 - 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
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.
**/
/**
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
**/
void __debugbreak ();
#pragma intrinsic(__debugbreak)
/**
Generates a breakpoint on the CPU.
Generates a breakpoint on the CPU. The breakpoint must be implemented such
that code can resume normal execution after the breakpoint.
**/
VOID
EFIAPI
CpuBreakpoint (
VOID
)
{
__debugbreak ();
}

View File

@ -1,60 +0,0 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 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
# 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:
#
# CpuId.S
#
# Abstract:
#
# AsmCpuid function
#
# Notes:
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# AsmCpuid (
# IN UINT32 RegisterInEax,
# OUT UINT32 *RegisterOutEax OPTIONAL,
# OUT UINT32 *RegisterOutEbx OPTIONAL,
# OUT UINT32 *RegisterOutEcx OPTIONAL,
# OUT UINT32 *RegisterOutEdx OPTIONAL
# )
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(AsmCpuid)
ASM_PFX(AsmCpuid):
push %rbx
mov %ecx, %eax
push %rax # save Index on stack
push %rdx
cpuid
test %r9, %r9
jz L1
mov %ecx, (%r9)
L1:
pop %rcx
jrcxz L2
mov %eax, (%rcx)
L2:
mov %r8, %rcx
jrcxz L3
mov %ebx, (%rcx)
L3:
mov 0x38(%rsp), %rcx
jrcxz L4
mov %edx, (%rcx)
L4:
pop %rax # restore Index to rax as return value
pop %rbx
ret

View File

@ -1,62 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 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
; 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:
;
; CpuId.Asm
;
; Abstract:
;
; AsmCpuid function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmCpuid (
; IN UINT32 RegisterInEax,
; OUT UINT32 *RegisterOutEax OPTIONAL,
; OUT UINT32 *RegisterOutEbx OPTIONAL,
; OUT UINT32 *RegisterOutEcx OPTIONAL,
; OUT UINT32 *RegisterOutEdx OPTIONAL
; )
;------------------------------------------------------------------------------
AsmCpuid PROC USES rbx
mov eax, ecx
push rax ; save Index on stack
push rdx
cpuid
test r9, r9
jz @F
mov [r9], ecx
@@:
pop rcx
jrcxz @F
mov [rcx], eax
@@:
mov rcx, r8
jrcxz @F
mov [rcx], ebx
@@:
mov rcx, [rsp + 38h]
jrcxz @F
mov [rcx], edx
@@:
pop rax ; restore Index to rax as return value
ret
AsmCpuid ENDP
END

View File

@ -1,62 +0,0 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 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
# 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:
#
# CpuIdEx.S
#
# Abstract:
#
# AsmCpuidEx function
#
# Notes:
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# UINT32
# EFIAPI
# AsmCpuidEx (
# IN UINT32 RegisterInEax,
# IN UINT32 RegisterInEcx,
# OUT UINT32 *RegisterOutEax OPTIONAL,
# OUT UINT32 *RegisterOutEbx OPTIONAL,
# OUT UINT32 *RegisterOutEcx OPTIONAL,
# OUT UINT32 *RegisterOutEdx OPTIONAL
# )
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(AsmCpuidEx)
ASM_PFX(AsmCpuidEx):
push %rbx
movl %ecx,%eax
movl %edx,%ecx
push %rax # save Index on stack
cpuid
mov 0x38(%rsp), %r10
test %r10, %r10
jz L1
mov %ecx,(%r10)
L1:
mov %r8, %rcx
jrcxz L2
movl %eax,(%rcx)
L2:
mov %r9, %rcx
jrcxz L3
mov %ebx, (%rcx)
L3:
mov 0x40(%rsp), %rcx
jrcxz L4
mov %edx, (%rcx)
L4:
pop %rax # restore Index to rax as return value
pop %rbx
ret

View File

@ -1,64 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 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
; 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:
;
; CpuIdEx.Asm
;
; Abstract:
;
; AsmCpuidEx function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; AsmCpuidEx (
; IN UINT32 RegisterInEax,
; IN UINT32 RegisterInEcx,
; OUT UINT32 *RegisterOutEax OPTIONAL,
; OUT UINT32 *RegisterOutEbx OPTIONAL,
; OUT UINT32 *RegisterOutEcx OPTIONAL,
; OUT UINT32 *RegisterOutEdx OPTIONAL
; )
;------------------------------------------------------------------------------
AsmCpuidEx PROC USES rbx
mov eax, ecx
mov ecx, edx
push rax ; save Index on stack
cpuid
mov r10, [rsp + 38h]
test r10, r10
jz @F
mov [r10], ecx
@@:
mov rcx, r8
jrcxz @F
mov [rcx], eax
@@:
mov rcx, r9
jrcxz @F
mov [rcx], ebx
@@:
mov rcx, [rsp + 40h]
jrcxz @F
mov [rcx], edx
@@:
pop rax ; restore Index to rax as return value
ret
AsmCpuidEx ENDP
END

View File

@ -1,37 +0,0 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2006, 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
; 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:
;
; CpuPause.Asm
;
; Abstract:
;
; CpuPause function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; CpuPause (
; VOID
; );
;------------------------------------------------------------------------------
CpuPause PROC
pause
ret
CpuPause ENDP
END

View File

@ -1,39 +0,0 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 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
# 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:
#
# DisableCache.S
#
# Abstract:
#
# Set the CD bit of CR0 to 1, clear the NW bit of CR0 to 0, and flush all caches with a
# WBINVD instruction.
#
# Notes:
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# AsmDisableCache (
# VOID
# );
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(AsmDisableCache)
ASM_PFX(AsmDisableCache):
movq %cr0, %rax
btsq $30, %rax
btrq $29, %rax
movq %rax, %cr0
wbinvd
ret

View File

@ -1,43 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 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
; 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:
;
; DisableCache.Asm
;
; Abstract:
;
; Set the CD bit of CR0 to 1, clear the NW bit of CR0 to 0, and flush all caches with a
; WBINVD instruction.
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmDisableCache (
; VOID
; );
;------------------------------------------------------------------------------
AsmDisableCache PROC
mov rax, cr0
bts rax, 30
btr rax, 29
mov cr0, rax
wbinvd
ret
AsmDisableCache ENDP
END

View File

@ -1,38 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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
; 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:
;
; DisableInterrupts.Asm
;
; Abstract:
;
; DisableInterrupts function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; DisableInterrupts (
; VOID
; );
;------------------------------------------------------------------------------
DisableInterrupts PROC
cli
ret
DisableInterrupts ENDP
END

View File

@ -1,82 +0,0 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2009, 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
# 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:
#
# DisablePaging64.S
#
# Abstract:
#
# AsmDisablePaging64 function
#
# Notes:
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# InternalX86DisablePaging64 (
# IN UINT16 Cs,
# IN UINT32 EntryPoint,
# IN UINT32 Context1, OPTIONAL
# IN UINT32 Context2, OPTIONAL
# IN UINT32 NewStack
# );
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(InternalX86DisablePaging64)
ASM_PFX(InternalX86DisablePaging64):
cli
lea L1(%rip), %rsi # rsi <- The start address of transition code
mov 0x28(%rsp), %edi # rdi <- New stack
lea _mTransitionEnd(%rip), %rax # rax <- end of transition code
sub %rsi, %rax # rax <- The size of transition piece code
add $4, %rax # round rax up to the next 4 byte boundary
and $0xfc, %al
sub %rax, %rdi # rdi <- use stack to hold transition code
mov %edi, %r10d # r10 <- The start address of transicition code below 4G
push %rcx # save rcx to stack
mov %rax, %rcx # rcx <- The size of transition piece code
rep
movsb # copy transition code to (new stack - 64byte) below 4G
pop %rcx # restore rcx
mov %r8d, %esi
mov %r9d, %edi
mov %r10d, %eax
sub $4, %eax
push %rcx # push Cs to stack
push %r10 # push address of transition code on stack
.byte 0x48, 0xcb # retq: Use far return to load CS register from stack
# (Use raw byte code since some GNU assemblers generates incorrect code for "retq")
L1:
mov %eax,%esp # set up new stack
mov %cr0,%rax
btr $0x1f,%eax # clear CR0.PG
mov %rax,%cr0 # disable paging
mov %edx,%ebx # save EntryPoint to ebx, for rdmsr will overwrite edx
mov $0xc0000080,%ecx
rdmsr
and $0xfe,%ah # clear LME
wrmsr
mov %cr4,%rax
and $0xdf,%al # clear PAE
mov %rax,%cr4
push %rdi # push Context2
push %rsi # push Context1
callq *%rbx # transfer control to EntryPoint
jmp . # no one should get here
_mTransitionEnd :

View File

@ -1,84 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 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
; 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:
;
; DisablePaging64.Asm
;
; Abstract:
;
; AsmDisablePaging64 function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86DisablePaging64 (
; IN UINT16 Cs,
; IN UINT32 EntryPoint,
; IN UINT32 Context1, OPTIONAL
; IN UINT32 Context2, OPTIONAL
; IN UINT32 NewStack
; );
;------------------------------------------------------------------------------
InternalX86DisablePaging64 PROC
cli
lea rsi, @F ; rsi <- The start address of transition code
mov edi, [rsp + 28h] ; rdi <- New stack
lea rax, mTransitionEnd ; rax <- end of transition code
sub rax, rsi ; rax <- The size of transition piece code
add rax, 4 ; Round RAX up to the next 4 byte boundary
and al, 0fch
sub rdi, rax ; rdi <- Use stack to hold transition code
mov r10d, edi ; r10 <- The start address of transicition code below 4G
push rcx ; save rcx to stack
mov rcx, rax ; rcx <- The size of transition piece code
rep movsb ; copy transition code to top of new stack which must be below 4GB
pop rcx ; restore rcx
mov esi, r8d
mov edi, r9d
mov eax, r10d ; eax <- start of the transition code on the stack
sub eax, 4 ; eax <- One slot below transition code on the stack
push rcx ; push Cs to stack
push r10 ; push address of tansition code on stack
DB 48h ; prefix to composite "retq" with next "retf"
retf ; Use far return to load CS register from stack
; Start of transition code
@@:
mov esp, eax ; set up new stack
mov rax, cr0
btr eax, 31 ; Clear CR0.PG
mov cr0, rax ; disable paging and caches
mov ebx, edx ; save EntryPoint to rbx, for rdmsr will overwrite rdx
mov ecx, 0c0000080h
rdmsr
and ah, NOT 1 ; clear LME
wrmsr
mov rax, cr4
and al, NOT (1 SHL 5) ; clear PAE
mov cr4, rax
push rdi ; push Context2
push rsi ; push Context1
call rbx ; transfer control to EntryPoint
hlt ; no one should get here
InternalX86DisablePaging64 ENDP
mTransitionEnd LABEL BYTE
END

View File

@ -1,39 +0,0 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 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
# 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:
#
# EnableCache.S
#
# Abstract:
#
# Flush all caches with a WBINVD instruction, clear the CD bit of CR0 to 0, and clear
# the NW bit of CR0 to 0
#
# Notes:
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# AsmEnableCache (
# VOID
# );
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(AsmEnableCache)
ASM_PFX(AsmEnableCache):
wbinvd
movq %cr0, %rax
btrq $30, %rax
btrq $29, %rax
movq %rax, %cr0
ret

View File

@ -1,43 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 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
; 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:
;
; EnableCache.Asm
;
; Abstract:
;
; Flush all caches with a WBINVD instruction, clear the CD bit of CR0 to 0, and clear
; the NW bit of CR0 to 0
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmEnableCache (
; VOID
; );
;------------------------------------------------------------------------------
AsmEnableCache PROC
wbinvd
mov rax, cr0
btr rax, 29
btr rax, 30
mov cr0, rax
ret
AsmEnableCache ENDP
END

View File

@ -1,36 +0,0 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2009, 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
# 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:
#
# EnableDisableInterrupts.S
#
# Abstract:
#
# EnableDisableInterrupts function
#
# Notes:
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# EnableDisableInterrupts (
# VOID
# );
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(EnableDisableInterrupts)
ASM_PFX(EnableDisableInterrupts):
sti
cli
ret

View File

@ -1,39 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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
; 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:
;
; EnableDisableInterrupts.Asm
;
; Abstract:
;
; EnableDisableInterrupts function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; EnableDisableInterrupts (
; VOID
; );
;------------------------------------------------------------------------------
EnableDisableInterrupts PROC
sti
cli
ret
EnableDisableInterrupts ENDP
END

View File

@ -1,38 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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
; 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:
;
; EnableInterrupts.Asm
;
; Abstract:
;
; EnableInterrupts function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; EnableInterrupts (
; VOID
; );
;------------------------------------------------------------------------------
EnableInterrupts PROC
sti
ret
EnableInterrupts ENDP
END

View File

@ -1,39 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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
; 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:
;
; FlushCacheLine.Asm
;
; Abstract:
;
; AsmFlushCacheLine function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; EFIAPI
; AsmFlushCacheLine (
; IN VOID *LinearAddress
; );
;------------------------------------------------------------------------------
AsmFlushCacheLine PROC
clflush [rcx]
mov rax, rcx
ret
AsmFlushCacheLine ENDP
END

View File

@ -1,38 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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
; 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:
;
; FxRestore.Asm
;
; Abstract:
;
; AsmFxRestore function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86FxRestore (
; IN CONST IA32_FX_BUFFER *Buffer
; );
;------------------------------------------------------------------------------
InternalX86FxRestore PROC
fxrstor [rcx]
ret
InternalX86FxRestore ENDP
END

View File

@ -1,38 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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
; 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:
;
; FxSave.Asm
;
; Abstract:
;
; AsmFxSave function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86FxSave (
; OUT IA32_FX_BUFFER *Buffer
; );
;------------------------------------------------------------------------------
InternalX86FxSave PROC
fxsave [rcx]
ret
InternalX86FxSave ENDP
END

Some files were not shown because too many files have changed in this diff Show More