ARM Packages: Fixed line endings
This large code change only modifies the line endings to be CRLF to be compliant with the EDK2 coding convention document. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14088 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,207 +1,207 @@
|
||||
/** @file
|
||||
Include file for basic command line parser for EBL (Embedded Boot Loader)
|
||||
|
||||
Copyright (c) 2007, 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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_H__
|
||||
#define __EBL_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/LoadFile.h>
|
||||
#include <Protocol/FirmwareVolumeBlock.h>
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/EblAddCommand.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
|
||||
#include <Guid/FileInfo.h>
|
||||
#include <Guid/DxeServices.h>
|
||||
#include <Guid/MemoryTypeInformation.h>
|
||||
#include <Guid/MemoryAllocationHob.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/EfiFileLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/EblCmdLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/EblNetworkLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
|
||||
#include <IndustryStandard/Pci.h>
|
||||
|
||||
//
|
||||
// Prompt for the command line
|
||||
//
|
||||
#define CMD_SEPARATOR ';'
|
||||
#define EBL_MAX_COMMAND_COUNT 0x100
|
||||
#define MAX_CMD_HISTORY 16
|
||||
#define MAX_CMD_LINE 256
|
||||
#define MAX_ARGS 32
|
||||
|
||||
#define EBL_CR 0x0a
|
||||
#define EBL_LF 0x0d
|
||||
|
||||
#define EFI_SET_TIMER_TO_SECOND 10000000
|
||||
|
||||
|
||||
|
||||
EBL_COMMAND_TABLE *
|
||||
EblGetCommand (
|
||||
IN CHAR8 *CommandName
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EblPathToDevice (
|
||||
IN CHAR8 *Path,
|
||||
OUT EFI_HANDLE *DeviceHandle,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **PathDevicePath,
|
||||
OUT VOID **Buffer,
|
||||
OUT UINTN *BufferSize
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
EblAnyKeyToContinueQtoQuit (
|
||||
IN UINTN *CurrentRow,
|
||||
IN BOOLEAN PrefixNewline
|
||||
);
|
||||
|
||||
VOID
|
||||
EblUpdateDeviceLists (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeCmdTable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblShutdownExternalCmdTable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblSetTextColor (
|
||||
UINTN Attribute
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EblGetCharKey (
|
||||
IN OUT EFI_INPUT_KEY *Key,
|
||||
IN UINTN TimoutInSec,
|
||||
IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL
|
||||
);
|
||||
|
||||
// BugBug: Move me to a library
|
||||
INTN
|
||||
EFIAPI
|
||||
AsciiStrniCmp (
|
||||
IN CONST CHAR8 *FirstString,
|
||||
IN CONST CHAR8 *SecondString,
|
||||
IN UINTN Length
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
EblInitializeDeviceCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializemdHwDebugCmds (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeDirCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeHobCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializemdHwIoDebugCmds (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeScriptCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeNetworkCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeVariableCmds (
|
||||
VOID
|
||||
);
|
||||
|
||||
CHAR8 *
|
||||
ParseArguments (
|
||||
IN CHAR8 *CmdLine,
|
||||
OUT UINTN *Argc,
|
||||
OUT CHAR8 **Argv
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
ProcessCmdLine (
|
||||
IN CHAR8 *CmdLine,
|
||||
IN UINTN MaxCmdLineSize
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
OutputData (
|
||||
IN UINT8 *Address,
|
||||
IN UINTN Length,
|
||||
IN UINTN Width,
|
||||
IN UINTN Offset
|
||||
);
|
||||
|
||||
UINTN
|
||||
WidthFromCommandName (
|
||||
IN CHAR8 *Argv,
|
||||
IN UINTN Default
|
||||
);
|
||||
|
||||
|
||||
extern UINTN gScreenColumns;
|
||||
extern UINTN gScreenRows;
|
||||
extern BOOLEAN gPageBreak;
|
||||
extern CHAR8 *gMemMapType[];
|
||||
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
Include file for basic command line parser for EBL (Embedded Boot Loader)
|
||||
|
||||
Copyright (c) 2007, 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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_H__
|
||||
#define __EBL_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/LoadFile.h>
|
||||
#include <Protocol/FirmwareVolumeBlock.h>
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/EblAddCommand.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
|
||||
#include <Guid/FileInfo.h>
|
||||
#include <Guid/DxeServices.h>
|
||||
#include <Guid/MemoryTypeInformation.h>
|
||||
#include <Guid/MemoryAllocationHob.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/EfiFileLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/EblCmdLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/EblNetworkLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
|
||||
#include <IndustryStandard/Pci.h>
|
||||
|
||||
//
|
||||
// Prompt for the command line
|
||||
//
|
||||
#define CMD_SEPARATOR ';'
|
||||
#define EBL_MAX_COMMAND_COUNT 0x100
|
||||
#define MAX_CMD_HISTORY 16
|
||||
#define MAX_CMD_LINE 256
|
||||
#define MAX_ARGS 32
|
||||
|
||||
#define EBL_CR 0x0a
|
||||
#define EBL_LF 0x0d
|
||||
|
||||
#define EFI_SET_TIMER_TO_SECOND 10000000
|
||||
|
||||
|
||||
|
||||
EBL_COMMAND_TABLE *
|
||||
EblGetCommand (
|
||||
IN CHAR8 *CommandName
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EblPathToDevice (
|
||||
IN CHAR8 *Path,
|
||||
OUT EFI_HANDLE *DeviceHandle,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **PathDevicePath,
|
||||
OUT VOID **Buffer,
|
||||
OUT UINTN *BufferSize
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
EblAnyKeyToContinueQtoQuit (
|
||||
IN UINTN *CurrentRow,
|
||||
IN BOOLEAN PrefixNewline
|
||||
);
|
||||
|
||||
VOID
|
||||
EblUpdateDeviceLists (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeCmdTable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblShutdownExternalCmdTable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblSetTextColor (
|
||||
UINTN Attribute
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EblGetCharKey (
|
||||
IN OUT EFI_INPUT_KEY *Key,
|
||||
IN UINTN TimoutInSec,
|
||||
IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL
|
||||
);
|
||||
|
||||
// BugBug: Move me to a library
|
||||
INTN
|
||||
EFIAPI
|
||||
AsciiStrniCmp (
|
||||
IN CONST CHAR8 *FirstString,
|
||||
IN CONST CHAR8 *SecondString,
|
||||
IN UINTN Length
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
EblInitializeDeviceCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializemdHwDebugCmds (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeDirCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeHobCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializemdHwIoDebugCmds (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeScriptCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeNetworkCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EblInitializeVariableCmds (
|
||||
VOID
|
||||
);
|
||||
|
||||
CHAR8 *
|
||||
ParseArguments (
|
||||
IN CHAR8 *CmdLine,
|
||||
OUT UINTN *Argc,
|
||||
OUT CHAR8 **Argv
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
ProcessCmdLine (
|
||||
IN CHAR8 *CmdLine,
|
||||
IN UINTN MaxCmdLineSize
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
OutputData (
|
||||
IN UINT8 *Address,
|
||||
IN UINTN Length,
|
||||
IN UINTN Width,
|
||||
IN UINTN Offset
|
||||
);
|
||||
|
||||
UINTN
|
||||
WidthFromCommandName (
|
||||
IN CHAR8 *Argv,
|
||||
IN UINTN Default
|
||||
);
|
||||
|
||||
|
||||
extern UINTN gScreenColumns;
|
||||
extern UINTN gScreenRows;
|
||||
extern BOOLEAN gPageBreak;
|
||||
extern CHAR8 *gMemMapType[];
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1,262 +1,262 @@
|
||||
#/** @file
|
||||
# Embedded Package
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2007, 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 Section - statements that will be processed to create a Makefile.
|
||||
#
|
||||
################################################################################
|
||||
[Defines]
|
||||
PLATFORM_NAME = Embedded
|
||||
PLATFORM_GUID = 8DBB580B-CF89-4D57-95C6-DFE96C44686E
|
||||
PLATFORM_VERSION = 0.1
|
||||
DSC_SPECIFICATION = 0x00010005
|
||||
OUTPUT_DIRECTORY = Build/Embedded
|
||||
SUPPORTED_ARCHITECTURES = IA32|X64|IPF|ARM
|
||||
BUILD_TARGETS = DEBUG|RELEASE
|
||||
SKUID_IDENTIFIER = DEFAULT
|
||||
FLASH_DEFINITION = EmbeddedPkg/EmbeddedPkg.fdf
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# SKU Identification section - list of all SKU IDs supported by this
|
||||
# Platform.
|
||||
#
|
||||
################################################################################
|
||||
[SkuIds]
|
||||
0|DEFAULT # The entry: 0|DEFAULT is reserved and always required.
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Library Class section - list of all Library Classes needed by this Platform.
|
||||
#
|
||||
################################################################################
|
||||
[LibraryClasses.common]
|
||||
# DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
|
||||
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
|
||||
|
||||
|
||||
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
|
||||
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
|
||||
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
|
||||
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
|
||||
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
|
||||
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
|
||||
EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
|
||||
|
||||
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
|
||||
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
|
||||
|
||||
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
|
||||
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
|
||||
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
|
||||
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
|
||||
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
|
||||
|
||||
SerialPortLib|EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf
|
||||
RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
|
||||
EfiResetSystemLib|EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf
|
||||
GdbSerialLib|EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf
|
||||
|
||||
|
||||
#
|
||||
# Need to change this for IPF
|
||||
#
|
||||
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||
|
||||
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
||||
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
|
||||
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
||||
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
|
||||
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
|
||||
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
|
||||
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
|
||||
|
||||
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
|
||||
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
|
||||
|
||||
|
||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||
EblCmdLib|EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf
|
||||
|
||||
EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
|
||||
|
||||
|
||||
[LibraryClasses.common.DXE_DRIVER]
|
||||
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
|
||||
|
||||
|
||||
[LibraryClasses.common.UEFI_APPLICATION]
|
||||
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
|
||||
|
||||
[LibraryClasses.common.UEFI_DRIVER]
|
||||
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
|
||||
|
||||
[LibraryClasses.common.SEC]
|
||||
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
|
||||
|
||||
[LibraryClasses.ARM]
|
||||
SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
|
||||
|
||||
[LibraryClasses.ARM]
|
||||
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Pcd Section - list of all PCD Entries defined by this Platform
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[PcdsFeatureFlag.common]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable|FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable|FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable|FALSE
|
||||
|
||||
#
|
||||
# Control what commands are supported from the UI
|
||||
# Turn these on and off to add features or save size
|
||||
#
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedDirCmd|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedHobCmd|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedHwDebugCmd|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedIoEnable|FALSE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd|FALSE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedPciDebugCmd|TRUE
|
||||
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE
|
||||
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|200000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|200000000
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand|L""|VOID*|2
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor|0x07
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize|0x10000
|
||||
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiHobBase|0
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiStackSize|0
|
||||
|
||||
#
|
||||
# Optinal feature to help prevent EFI memory map fragments
|
||||
# Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob
|
||||
# Values are in EFI Pages (4K). DXE Core will make sure that
|
||||
# at least this much of each type of memory can be allocated
|
||||
# from a single memory range. This way you only end up with
|
||||
# maximum of two fragements for each type in the memory map
|
||||
# (the memory used, and the free memory that was prereserved
|
||||
# but not used).
|
||||
#
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0
|
||||
|
||||
#
|
||||
# Timer config for this platform
|
||||
#
|
||||
gEmbeddedTokenSpaceGuid.PcdTimerBaseAddress|0x3c700000
|
||||
gEmbeddedTokenSpaceGuid.PcdTimerVector|7
|
||||
gEmbeddedTokenSpaceGuid.PcdTimerPeriod|100000
|
||||
|
||||
|
||||
[PcdsFixedAtBuild.ARM]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|32
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0
|
||||
|
||||
[PcdsFixedAtBuild.IA32]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|36
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16
|
||||
|
||||
[PcdsFixedAtBuild.X64]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|52
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16
|
||||
|
||||
|
||||
|
||||
[PcdsFixedAtBuild.IPF]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000
|
||||
|
||||
#
|
||||
# This makes it so you can source level debug with NT32. VC++ debugger limitiation!
|
||||
#
|
||||
#[BuildOptions]
|
||||
# DEBUG_*_IA32_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /ALIGN:4096 /SUBSYSTEM:CONSOLE
|
||||
# RELEASE_*_IA32_DLINK_FLAGS = /ALIGN:4096
|
||||
# *_*_IA32_CC_FLAGS = /D EFI_SPECIFICATION_VERSION=0x0002000A /D TIANO_RELEASE_VERSION=0x00080006
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Components Section - list of all Modules needed by this Platform
|
||||
#
|
||||
################################################################################
|
||||
[Components.common]
|
||||
EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf
|
||||
EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf
|
||||
EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
|
||||
EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf
|
||||
EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf
|
||||
EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
|
||||
EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
|
||||
EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf
|
||||
EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf
|
||||
EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
|
||||
EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf
|
||||
EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf
|
||||
|
||||
EmbeddedPkg/Ebl/Ebl.inf
|
||||
#### EmbeddedPkg/EblExternCmd/EblExternCmd.inf
|
||||
EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
|
||||
EmbeddedPkg/GdbStub/GdbStub.inf
|
||||
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
|
||||
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
|
||||
EmbeddedPkg/SerialDxe/SerialDxe.inf
|
||||
EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
|
||||
EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
|
||||
|
||||
EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
|
||||
|
||||
|
||||
|
||||
#/** @file
|
||||
# Embedded Package
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2007, 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 Section - statements that will be processed to create a Makefile.
|
||||
#
|
||||
################################################################################
|
||||
[Defines]
|
||||
PLATFORM_NAME = Embedded
|
||||
PLATFORM_GUID = 8DBB580B-CF89-4D57-95C6-DFE96C44686E
|
||||
PLATFORM_VERSION = 0.1
|
||||
DSC_SPECIFICATION = 0x00010005
|
||||
OUTPUT_DIRECTORY = Build/Embedded
|
||||
SUPPORTED_ARCHITECTURES = IA32|X64|IPF|ARM
|
||||
BUILD_TARGETS = DEBUG|RELEASE
|
||||
SKUID_IDENTIFIER = DEFAULT
|
||||
FLASH_DEFINITION = EmbeddedPkg/EmbeddedPkg.fdf
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# SKU Identification section - list of all SKU IDs supported by this
|
||||
# Platform.
|
||||
#
|
||||
################################################################################
|
||||
[SkuIds]
|
||||
0|DEFAULT # The entry: 0|DEFAULT is reserved and always required.
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Library Class section - list of all Library Classes needed by this Platform.
|
||||
#
|
||||
################################################################################
|
||||
[LibraryClasses.common]
|
||||
# DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
|
||||
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
|
||||
|
||||
|
||||
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
|
||||
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
|
||||
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
|
||||
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
|
||||
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
|
||||
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
|
||||
EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
|
||||
|
||||
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
|
||||
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
|
||||
|
||||
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
|
||||
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
|
||||
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
|
||||
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
|
||||
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
|
||||
|
||||
SerialPortLib|EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf
|
||||
RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
|
||||
EfiResetSystemLib|EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf
|
||||
GdbSerialLib|EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf
|
||||
|
||||
|
||||
#
|
||||
# Need to change this for IPF
|
||||
#
|
||||
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
|
||||
|
||||
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
||||
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
|
||||
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
||||
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
|
||||
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
|
||||
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
|
||||
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
|
||||
|
||||
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
|
||||
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
|
||||
|
||||
|
||||
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||
EblCmdLib|EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf
|
||||
|
||||
EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
|
||||
|
||||
|
||||
[LibraryClasses.common.DXE_DRIVER]
|
||||
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
|
||||
|
||||
|
||||
[LibraryClasses.common.UEFI_APPLICATION]
|
||||
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
|
||||
|
||||
[LibraryClasses.common.UEFI_DRIVER]
|
||||
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
|
||||
|
||||
[LibraryClasses.common.SEC]
|
||||
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
|
||||
|
||||
[LibraryClasses.ARM]
|
||||
SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
|
||||
|
||||
[LibraryClasses.ARM]
|
||||
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Pcd Section - list of all PCD Entries defined by this Platform
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[PcdsFeatureFlag.common]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable|FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable|FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable|FALSE
|
||||
|
||||
#
|
||||
# Control what commands are supported from the UI
|
||||
# Turn these on and off to add features or save size
|
||||
#
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedDirCmd|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedHobCmd|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedHwDebugCmd|TRUE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedIoEnable|FALSE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd|FALSE
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedPciDebugCmd|TRUE
|
||||
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE
|
||||
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|200000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
|
||||
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|200000000
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand|L""|VOID*|2
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor|0x07
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize|0x10000
|
||||
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiHobBase|0
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiStackSize|0
|
||||
|
||||
#
|
||||
# Optinal feature to help prevent EFI memory map fragments
|
||||
# Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob
|
||||
# Values are in EFI Pages (4K). DXE Core will make sure that
|
||||
# at least this much of each type of memory can be allocated
|
||||
# from a single memory range. This way you only end up with
|
||||
# maximum of two fragements for each type in the memory map
|
||||
# (the memory used, and the free memory that was prereserved
|
||||
# but not used).
|
||||
#
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|0
|
||||
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0
|
||||
|
||||
#
|
||||
# Timer config for this platform
|
||||
#
|
||||
gEmbeddedTokenSpaceGuid.PcdTimerBaseAddress|0x3c700000
|
||||
gEmbeddedTokenSpaceGuid.PcdTimerVector|7
|
||||
gEmbeddedTokenSpaceGuid.PcdTimerPeriod|100000
|
||||
|
||||
|
||||
[PcdsFixedAtBuild.ARM]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|32
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0
|
||||
|
||||
[PcdsFixedAtBuild.IA32]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|36
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16
|
||||
|
||||
[PcdsFixedAtBuild.X64]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|52
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16
|
||||
|
||||
|
||||
|
||||
[PcdsFixedAtBuild.IPF]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000
|
||||
|
||||
#
|
||||
# This makes it so you can source level debug with NT32. VC++ debugger limitiation!
|
||||
#
|
||||
#[BuildOptions]
|
||||
# DEBUG_*_IA32_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /ALIGN:4096 /SUBSYSTEM:CONSOLE
|
||||
# RELEASE_*_IA32_DLINK_FLAGS = /ALIGN:4096
|
||||
# *_*_IA32_CC_FLAGS = /D EFI_SPECIFICATION_VERSION=0x0002000A /D TIANO_RELEASE_VERSION=0x00080006
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Components Section - list of all Modules needed by this Platform
|
||||
#
|
||||
################################################################################
|
||||
[Components.common]
|
||||
EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf
|
||||
EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf
|
||||
EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
|
||||
EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf
|
||||
EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf
|
||||
EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
|
||||
EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
|
||||
EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.inf
|
||||
EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf
|
||||
EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
|
||||
EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf
|
||||
EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf
|
||||
|
||||
EmbeddedPkg/Ebl/Ebl.inf
|
||||
#### EmbeddedPkg/EblExternCmd/EblExternCmd.inf
|
||||
EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
|
||||
EmbeddedPkg/GdbStub/GdbStub.inf
|
||||
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
|
||||
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
|
||||
EmbeddedPkg/SerialDxe/SerialDxe.inf
|
||||
EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
|
||||
EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
|
||||
|
||||
EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -60,4 +60,4 @@ DebugAgentTimerEndOfInterrupt (
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@@ -1,45 +1,45 @@
|
||||
/** @file
|
||||
DMA abstraction library APIs. Based on UEFI PCI IO protocol DMA abstractions.
|
||||
At some point these functions will probably end up in a non PCI protocol
|
||||
for embedded systems.
|
||||
|
||||
/** @file
|
||||
DMA abstraction library APIs. Based on UEFI PCI IO protocol DMA abstractions.
|
||||
At some point these functions will probably end up in a non PCI protocol
|
||||
for embedded systems.
|
||||
|
||||
DMA Bus Master Read Operation:
|
||||
Call DmaMap() for MapOperationBusMasterRead.
|
||||
Program the DMA Bus Master with the DeviceAddress returned by DmaMap().
|
||||
Start the DMA Bus Master.
|
||||
Wait for DMA Bus Master to complete the read operation.
|
||||
Call DmaUnmap().
|
||||
|
||||
DMA Bus Master Write Operation:
|
||||
Call DmaMap() for MapOperationBusMasterRead.
|
||||
Program the DMA Bus Master with the DeviceAddress returned by DmaMap().
|
||||
Start the DMA Bus Master.
|
||||
Wait for DMA Bus Master to complete the read operation.
|
||||
Call DmaUnmap().
|
||||
|
||||
DMA Bus Master Write Operation:
|
||||
Call DmaMap() for MapOperationBusMasterWrite.
|
||||
Program the DMA Bus Master with the DeviceAddress returned by DmaMap().
|
||||
Start the DMA Bus Master.
|
||||
Wait for DMA Bus Master to complete the write operation.
|
||||
Call DmaUnmap().
|
||||
|
||||
DMA Bus Master Common Buffer Operation:
|
||||
Call DmaAllocateBuffer() to allocate a common buffer.
|
||||
Call DmaMap() for MapOperationBusMasterCommonBuffer.
|
||||
Program the DMA Bus Master with the DeviceAddress returned by DmaMap().
|
||||
The common buffer can now be accessed equally by the processor and the DMA bus master.
|
||||
Call DmaUnmap().
|
||||
Call DmaFreeBuffer().
|
||||
|
||||
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 __DMA_LIB_H__
|
||||
#define __DMA_LIB_H__
|
||||
|
||||
Call DmaUnmap().
|
||||
|
||||
DMA Bus Master Common Buffer Operation:
|
||||
Call DmaAllocateBuffer() to allocate a common buffer.
|
||||
Call DmaMap() for MapOperationBusMasterCommonBuffer.
|
||||
Program the DMA Bus Master with the DeviceAddress returned by DmaMap().
|
||||
The common buffer can now be accessed equally by the processor and the DMA bus master.
|
||||
Call DmaUnmap().
|
||||
Call DmaFreeBuffer().
|
||||
|
||||
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 __DMA_LIB_H__
|
||||
#define __DMA_LIB_H__
|
||||
|
||||
typedef enum {
|
||||
///
|
||||
/// A read operation from system memory by a bus master.
|
||||
@@ -56,10 +56,10 @@ typedef enum {
|
||||
MapOperationBusMasterCommonBuffer,
|
||||
MapOperationMaximum
|
||||
} DMA_MAP_OPERATION;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Provides the DMA controller-specific addresses needed to access system memory.
|
||||
|
||||
@@ -79,20 +79,20 @@ typedef enum {
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
||||
@retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaMap (
|
||||
IN DMA_MAP_OPERATION Operation,
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaMap (
|
||||
IN DMA_MAP_OPERATION Operation,
|
||||
IN VOID *HostAddress,
|
||||
IN OUT UINTN *NumberOfBytes,
|
||||
OUT PHYSICAL_ADDRESS *DeviceAddress,
|
||||
OUT VOID **Mapping
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Completes the DmaMapBusMasterRead, DmaMapBusMasterWrite, or DmaMapBusMasterCommonBuffer
|
||||
operation and releases any corresponding resources.
|
||||
@@ -102,14 +102,14 @@ DmaMap (
|
||||
@retval EFI_SUCCESS The range was unmapped.
|
||||
@retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaUnmap (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaUnmap (
|
||||
IN VOID *Mapping
|
||||
);
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer.
|
||||
mapping.
|
||||
@@ -126,16 +126,16 @@ DmaUnmap (
|
||||
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaAllocateBuffer (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaAllocateBuffer (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages,
|
||||
OUT VOID **HostAddress
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Frees memory that was allocated with DmaAllocateBuffer().
|
||||
|
||||
@@ -147,13 +147,13 @@ DmaAllocateBuffer (
|
||||
was not allocated with DmaAllocateBuffer().
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaFreeBuffer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DmaFreeBuffer (
|
||||
IN UINTN Pages,
|
||||
IN VOID *HostAddress
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1,122 +1,122 @@
|
||||
/** @file
|
||||
Include file for basic command line parser for EBL (Embedded Boot Loader)
|
||||
|
||||
Copyright (c) 2007, 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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_ADD_EXTERNAL_COMMAND_LIB_H__
|
||||
#define __EBL_ADD_EXTERNAL_COMMAND_LIB_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/EblAddCommand.h>
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblAddExternalCommands (
|
||||
IN const EBL_COMMAND_TABLE *EntryArray,
|
||||
IN UINTN ArrayCount
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Return a keypress or optionally timeout if a timeout value was passed in.
|
||||
|
||||
An optional callback function is called every second when waiting for a
|
||||
|
||||
timeout.
|
||||
|
||||
|
||||
|
||||
@param Key EFI Key information returned
|
||||
|
||||
@param TimeoutInSec Number of seconds to wait to timeout
|
||||
|
||||
@param CallBack Callback called every second during the timeout wait
|
||||
|
||||
|
||||
|
||||
@return EFI_SUCCESS Key was returned
|
||||
|
||||
@return EFI_TIMEOUT If the TimoutInSec expired
|
||||
|
||||
|
||||
|
||||
**/
|
||||
|
||||
EFI_STATUS
|
||||
|
||||
EFIAPI
|
||||
|
||||
EblGetCharKey (
|
||||
|
||||
IN OUT EFI_INPUT_KEY *Key,
|
||||
|
||||
IN UINTN TimeoutInSec,
|
||||
|
||||
IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
This routine is used prevent command output data from scrolling off the end
|
||||
|
||||
of the screen. The global gPageBreak is used to turn on or off this feature.
|
||||
|
||||
If the CurrentRow is near the end of the screen pause and print out a prompt
|
||||
|
||||
If the use hits Q to quit return TRUE else for any other key return FALSE.
|
||||
|
||||
PrefixNewline is used to figure out if a newline is needed before the prompt
|
||||
|
||||
string. This depends on the last print done before calling this function.
|
||||
|
||||
CurrentRow is updated by one on a call or set back to zero if a prompt is
|
||||
|
||||
needed.
|
||||
|
||||
|
||||
|
||||
@param CurrentRow Used to figure out if its the end of the page and updated
|
||||
|
||||
@param PrefixNewline Did previous print issue a newline
|
||||
|
||||
|
||||
|
||||
@return TRUE if Q was hit to quit, FALSE in all other cases.
|
||||
|
||||
|
||||
|
||||
**/
|
||||
|
||||
BOOLEAN
|
||||
|
||||
EFIAPI
|
||||
|
||||
EblAnyKeyToContinueQtoQuit (
|
||||
|
||||
IN UINTN *CurrentRow,
|
||||
|
||||
IN BOOLEAN PrefixNewline
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
Include file for basic command line parser for EBL (Embedded Boot Loader)
|
||||
|
||||
Copyright (c) 2007, 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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_ADD_EXTERNAL_COMMAND_LIB_H__
|
||||
#define __EBL_ADD_EXTERNAL_COMMAND_LIB_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/EblAddCommand.h>
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblAddExternalCommands (
|
||||
IN const EBL_COMMAND_TABLE *EntryArray,
|
||||
IN UINTN ArrayCount
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Return a keypress or optionally timeout if a timeout value was passed in.
|
||||
|
||||
An optional callback function is called every second when waiting for a
|
||||
|
||||
timeout.
|
||||
|
||||
|
||||
|
||||
@param Key EFI Key information returned
|
||||
|
||||
@param TimeoutInSec Number of seconds to wait to timeout
|
||||
|
||||
@param CallBack Callback called every second during the timeout wait
|
||||
|
||||
|
||||
|
||||
@return EFI_SUCCESS Key was returned
|
||||
|
||||
@return EFI_TIMEOUT If the TimoutInSec expired
|
||||
|
||||
|
||||
|
||||
**/
|
||||
|
||||
EFI_STATUS
|
||||
|
||||
EFIAPI
|
||||
|
||||
EblGetCharKey (
|
||||
|
||||
IN OUT EFI_INPUT_KEY *Key,
|
||||
|
||||
IN UINTN TimeoutInSec,
|
||||
|
||||
IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
This routine is used prevent command output data from scrolling off the end
|
||||
|
||||
of the screen. The global gPageBreak is used to turn on or off this feature.
|
||||
|
||||
If the CurrentRow is near the end of the screen pause and print out a prompt
|
||||
|
||||
If the use hits Q to quit return TRUE else for any other key return FALSE.
|
||||
|
||||
PrefixNewline is used to figure out if a newline is needed before the prompt
|
||||
|
||||
string. This depends on the last print done before calling this function.
|
||||
|
||||
CurrentRow is updated by one on a call or set back to zero if a prompt is
|
||||
|
||||
needed.
|
||||
|
||||
|
||||
|
||||
@param CurrentRow Used to figure out if its the end of the page and updated
|
||||
|
||||
@param PrefixNewline Did previous print issue a newline
|
||||
|
||||
|
||||
|
||||
@return TRUE if Q was hit to quit, FALSE in all other cases.
|
||||
|
||||
|
||||
|
||||
**/
|
||||
|
||||
BOOLEAN
|
||||
|
||||
EFIAPI
|
||||
|
||||
EblAnyKeyToContinueQtoQuit (
|
||||
|
||||
IN UINTN *CurrentRow,
|
||||
|
||||
IN BOOLEAN PrefixNewline
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1,48 +1,48 @@
|
||||
/** @file
|
||||
Include file for basic command line parser for EBL (Embedded Boot Loader)
|
||||
|
||||
Copyright (c) 2007, 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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_LIB_H__
|
||||
#define __EBL_LIB_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/EblAddCommand.h>
|
||||
|
||||
|
||||
VOID
|
||||
EblAddCommand (
|
||||
IN const EBL_COMMAND_TABLE *Entry
|
||||
);
|
||||
|
||||
VOID
|
||||
EblAddCommands (
|
||||
IN const EBL_COMMAND_TABLE *EntryArray,
|
||||
IN UINTN ArrayCount
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// LIbrary constructor called directly from Ebl Code.
|
||||
// This module calls EblAddCommand () or EblAddCommands () to register new commands
|
||||
//
|
||||
VOID
|
||||
EblInitializeExternalCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
Include file for basic command line parser for EBL (Embedded Boot Loader)
|
||||
|
||||
Copyright (c) 2007, 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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_LIB_H__
|
||||
#define __EBL_LIB_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/EblAddCommand.h>
|
||||
|
||||
|
||||
VOID
|
||||
EblAddCommand (
|
||||
IN const EBL_COMMAND_TABLE *Entry
|
||||
);
|
||||
|
||||
VOID
|
||||
EblAddCommands (
|
||||
IN const EBL_COMMAND_TABLE *EntryArray,
|
||||
IN UINTN ArrayCount
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// LIbrary constructor called directly from Ebl Code.
|
||||
// This module calls EblAddCommand () or EblAddCommands () to register new commands
|
||||
//
|
||||
VOID
|
||||
EblInitializeExternalCmd (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1,68 +1,68 @@
|
||||
/** @file
|
||||
Abstractions for Ebl network accesses.
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_NETWORK_LIB_H__
|
||||
#define __EBL_NETWORK_LIB_H__
|
||||
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentIpAddress (
|
||||
IN OUT EFI_IP_ADDRESS *Ip
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentMacAddress (
|
||||
IN OUT EFI_MAC_ADDRESS *Mac
|
||||
);
|
||||
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
EblLoadFileBootTypeString (
|
||||
IN EFI_HANDLE Handle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblPerformDHCP (
|
||||
IN BOOLEAN SortOffers
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblSetStationIp (
|
||||
IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblMtftp (
|
||||
IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
|
||||
IN OUT VOID *BufferPtr OPTIONAL,
|
||||
IN BOOLEAN Overwrite,
|
||||
IN OUT UINT64 *BufferSize,
|
||||
IN UINTN *BlockSize OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *ServerIp,
|
||||
IN UINT8 *Filename OPTIONAL,
|
||||
IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
|
||||
IN BOOLEAN DontUseBuffer
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
Abstractions for Ebl network accesses.
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EBL_NETWORK_LIB_H__
|
||||
#define __EBL_NETWORK_LIB_H__
|
||||
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentIpAddress (
|
||||
IN OUT EFI_IP_ADDRESS *Ip
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentMacAddress (
|
||||
IN OUT EFI_MAC_ADDRESS *Mac
|
||||
);
|
||||
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
EblLoadFileBootTypeString (
|
||||
IN EFI_HANDLE Handle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblPerformDHCP (
|
||||
IN BOOLEAN SortOffers
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblSetStationIp (
|
||||
IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblMtftp (
|
||||
IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
|
||||
IN OUT VOID *BufferPtr OPTIONAL,
|
||||
IN BOOLEAN Overwrite,
|
||||
IN OUT UINT64 *BufferSize,
|
||||
IN UINTN *BlockSize OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *ServerIp,
|
||||
IN UINT8 *Filename OPTIONAL,
|
||||
IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
|
||||
IN BOOLEAN DontUseBuffer
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1,107 +1,107 @@
|
||||
/** @file
|
||||
Basic serial IO abstaction for GDB
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __GDB_SERIAL_LIB_H__
|
||||
#define __GDB_SERIAL_LIB_H__
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
|
||||
data buts, and stop bits on a serial device. This call is optional as the serial
|
||||
port will be set up with defaults base on PCD values.
|
||||
|
||||
@param BaudRate The requested baud rate. A BaudRate value of 0 will use the the
|
||||
device's default interface speed.
|
||||
@param Parity The type of parity to use on this serial device. A Parity value of
|
||||
DefaultParity will use the device's default parity value.
|
||||
@param DataBits The number of data bits to use on the serial device. A DataBits
|
||||
vaule of 0 will use the device's default data bit setting.
|
||||
@param StopBits The number of stop bits to use on this serial device. A StopBits
|
||||
value of DefaultStopBits will use the device's default number of
|
||||
stop bits.
|
||||
|
||||
@retval EFI_SUCCESS The device was configured.
|
||||
@retval EFI_DEVICE_ERROR The serial device could not be coonfigured.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
GdbSerialInit (
|
||||
IN UINT64 BaudRate,
|
||||
IN UINT8 Parity,
|
||||
IN UINT8 DataBits,
|
||||
IN UINT8 StopBits
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Check to see if a character is available from GDB. Do not read the character as that is
|
||||
done via GdbGetChar().
|
||||
|
||||
@return TRUE - Character availible
|
||||
@return FALSE - Character not availible
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
GdbIsCharAvailable (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Get a character from GDB. This function must be able to run in interrupt context.
|
||||
|
||||
@return A character from GDB
|
||||
|
||||
**/
|
||||
CHAR8
|
||||
EFIAPI
|
||||
GdbGetChar (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Send a character to GDB. This function must be able to run in interrupt context.
|
||||
|
||||
|
||||
@param Char Send a character to GDB
|
||||
|
||||
**/
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbPutChar (
|
||||
IN CHAR8 Char
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Send an ASCII string to GDB. This function must be able to run in interrupt context.
|
||||
|
||||
|
||||
@param String Send a string to GDB
|
||||
|
||||
**/
|
||||
|
||||
VOID
|
||||
GdbPutString (
|
||||
IN CHAR8 *String
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
Basic serial IO abstaction for GDB
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __GDB_SERIAL_LIB_H__
|
||||
#define __GDB_SERIAL_LIB_H__
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
|
||||
data buts, and stop bits on a serial device. This call is optional as the serial
|
||||
port will be set up with defaults base on PCD values.
|
||||
|
||||
@param BaudRate The requested baud rate. A BaudRate value of 0 will use the the
|
||||
device's default interface speed.
|
||||
@param Parity The type of parity to use on this serial device. A Parity value of
|
||||
DefaultParity will use the device's default parity value.
|
||||
@param DataBits The number of data bits to use on the serial device. A DataBits
|
||||
vaule of 0 will use the device's default data bit setting.
|
||||
@param StopBits The number of stop bits to use on this serial device. A StopBits
|
||||
value of DefaultStopBits will use the device's default number of
|
||||
stop bits.
|
||||
|
||||
@retval EFI_SUCCESS The device was configured.
|
||||
@retval EFI_DEVICE_ERROR The serial device could not be coonfigured.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
GdbSerialInit (
|
||||
IN UINT64 BaudRate,
|
||||
IN UINT8 Parity,
|
||||
IN UINT8 DataBits,
|
||||
IN UINT8 StopBits
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Check to see if a character is available from GDB. Do not read the character as that is
|
||||
done via GdbGetChar().
|
||||
|
||||
@return TRUE - Character availible
|
||||
@return FALSE - Character not availible
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
GdbIsCharAvailable (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Get a character from GDB. This function must be able to run in interrupt context.
|
||||
|
||||
@return A character from GDB
|
||||
|
||||
**/
|
||||
CHAR8
|
||||
EFIAPI
|
||||
GdbGetChar (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Send a character to GDB. This function must be able to run in interrupt context.
|
||||
|
||||
|
||||
@param Char Send a character to GDB
|
||||
|
||||
**/
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbPutChar (
|
||||
IN CHAR8 Char
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Send an ASCII string to GDB. This function must be able to run in interrupt context.
|
||||
|
||||
|
||||
@param String Send a string to GDB
|
||||
|
||||
**/
|
||||
|
||||
VOID
|
||||
GdbPutString (
|
||||
IN CHAR8 *String
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,66 +1,66 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2012, ARM Ltd. All rights reserved.
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __SERIAL_PORT_EXT_LIB_H__
|
||||
#define __SERIAL_PORT_EXT_LIB_H__
|
||||
|
||||
#include <Uefi/UefiBaseType.h>
|
||||
#include <Protocol/SerialIo.h>
|
||||
|
||||
/**
|
||||
Set the serial device control bits.
|
||||
|
||||
@return Always return EFI_UNSUPPORTED.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortSetControl (
|
||||
IN UINT32 Control
|
||||
);
|
||||
|
||||
/**
|
||||
Get the serial device control bits.
|
||||
|
||||
@param Control Control signals read from the serial device.
|
||||
|
||||
@retval EFI_SUCCESS The control bits were read from the serial device.
|
||||
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortGetControl (
|
||||
OUT UINT32 *Control
|
||||
);
|
||||
|
||||
/**
|
||||
Set the serial device attributes.
|
||||
|
||||
@return Always return EFI_UNSUPPORTED.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortSetAttributes (
|
||||
IN UINT64 BaudRate,
|
||||
IN UINT32 ReceiveFifoDepth,
|
||||
IN UINT32 Timeout,
|
||||
IN EFI_PARITY_TYPE Parity,
|
||||
IN UINT8 DataBits,
|
||||
IN EFI_STOP_BITS_TYPE StopBits
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2012, ARM Ltd. All rights reserved.
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __SERIAL_PORT_EXT_LIB_H__
|
||||
#define __SERIAL_PORT_EXT_LIB_H__
|
||||
|
||||
#include <Uefi/UefiBaseType.h>
|
||||
#include <Protocol/SerialIo.h>
|
||||
|
||||
/**
|
||||
Set the serial device control bits.
|
||||
|
||||
@return Always return EFI_UNSUPPORTED.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortSetControl (
|
||||
IN UINT32 Control
|
||||
);
|
||||
|
||||
/**
|
||||
Get the serial device control bits.
|
||||
|
||||
@param Control Control signals read from the serial device.
|
||||
|
||||
@retval EFI_SUCCESS The control bits were read from the serial device.
|
||||
@retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortGetControl (
|
||||
OUT UINT32 *Control
|
||||
);
|
||||
|
||||
/**
|
||||
Set the serial device attributes.
|
||||
|
||||
@return Always return EFI_UNSUPPORTED.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortSetAttributes (
|
||||
IN UINT64 BaudRate,
|
||||
IN UINT32 ReceiveFifoDepth,
|
||||
IN UINT32 Timeout,
|
||||
IN EFI_PARITY_TYPE Parity,
|
||||
IN UINT8 DataBits,
|
||||
IN EFI_STOP_BITS_TYPE StopBits
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -73,11 +73,11 @@ VOID
|
||||
);
|
||||
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EBL_GET_CHAR_CALL_BACK) (
|
||||
IN UINTN ElapsedTime
|
||||
);
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *EBL_GET_CHAR_CALL_BACK) (
|
||||
IN UINTN ElapsedTime
|
||||
);
|
||||
|
||||
/**
|
||||
Return a keypress or optionally timeout if a timeout value was passed in.
|
||||
|
@@ -1,94 +1,94 @@
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EMBEDDED_EXTERNAL_DEVICE_H__
|
||||
#define __EMBEDDED_EXTERNAL_DEVICE_H__
|
||||
|
||||
//
|
||||
// Protocol GUID
|
||||
//
|
||||
#define EMBEDDED_EXTERNAL_DEVICE_PROTOCOL_GUID { 0x735F8C64, 0xD696, 0x44D0, { 0xBD, 0xF2, 0x44, 0x7F, 0xD0, 0x5A, 0x54, 0x06 }}
|
||||
|
||||
//
|
||||
// Protocol interface structure
|
||||
//
|
||||
typedef struct _EMBEDDED_EXTERNAL_DEVICE EMBEDDED_EXTERNAL_DEVICE;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_READ) (
|
||||
IN EMBEDDED_EXTERNAL_DEVICE *This,
|
||||
IN UINTN Register,
|
||||
IN UINTN Length,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Read a set of contiguous external device registers.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Offset - starting register number
|
||||
Length - number of bytes to read
|
||||
Buffer - destination buffer
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - registers read successfully
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_WRITE) (
|
||||
IN EMBEDDED_EXTERNAL_DEVICE *This,
|
||||
IN UINTN Register,
|
||||
IN UINTN Length,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Write to a set of contiguous external device registers.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Offset - starting register number
|
||||
Length - number of bytes to write
|
||||
Buffer - source buffer
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - registers written successfully
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
struct _EMBEDDED_EXTERNAL_DEVICE {
|
||||
EMBEDDED_EXTERNAL_DEVICE_READ Read;
|
||||
EMBEDDED_EXTERNAL_DEVICE_WRITE Write;
|
||||
};
|
||||
|
||||
extern EFI_GUID gEmbeddedExternalDeviceProtocolGuid;
|
||||
|
||||
#endif // __EMBEDDED_EXTERNAL_DEVICE_H__
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EMBEDDED_EXTERNAL_DEVICE_H__
|
||||
#define __EMBEDDED_EXTERNAL_DEVICE_H__
|
||||
|
||||
//
|
||||
// Protocol GUID
|
||||
//
|
||||
#define EMBEDDED_EXTERNAL_DEVICE_PROTOCOL_GUID { 0x735F8C64, 0xD696, 0x44D0, { 0xBD, 0xF2, 0x44, 0x7F, 0xD0, 0x5A, 0x54, 0x06 }}
|
||||
|
||||
//
|
||||
// Protocol interface structure
|
||||
//
|
||||
typedef struct _EMBEDDED_EXTERNAL_DEVICE EMBEDDED_EXTERNAL_DEVICE;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_READ) (
|
||||
IN EMBEDDED_EXTERNAL_DEVICE *This,
|
||||
IN UINTN Register,
|
||||
IN UINTN Length,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Read a set of contiguous external device registers.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Offset - starting register number
|
||||
Length - number of bytes to read
|
||||
Buffer - destination buffer
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - registers read successfully
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_WRITE) (
|
||||
IN EMBEDDED_EXTERNAL_DEVICE *This,
|
||||
IN UINTN Register,
|
||||
IN UINTN Length,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Write to a set of contiguous external device registers.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Offset - starting register number
|
||||
Length - number of bytes to write
|
||||
Buffer - source buffer
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - registers written successfully
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
struct _EMBEDDED_EXTERNAL_DEVICE {
|
||||
EMBEDDED_EXTERNAL_DEVICE_READ Read;
|
||||
EMBEDDED_EXTERNAL_DEVICE_WRITE Write;
|
||||
};
|
||||
|
||||
extern EFI_GUID gEmbeddedExternalDeviceProtocolGuid;
|
||||
|
||||
#endif // __EMBEDDED_EXTERNAL_DEVICE_H__
|
||||
|
@@ -1,167 +1,167 @@
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EMBEDDED_GPIO_H__
|
||||
#define __EMBEDDED_GPIO_H__
|
||||
|
||||
//
|
||||
// Protocol interface structure
|
||||
//
|
||||
typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO;
|
||||
|
||||
//
|
||||
// Data Types
|
||||
//
|
||||
typedef UINTN EMBEDDED_GPIO_PIN;
|
||||
|
||||
#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
|
||||
#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
|
||||
#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
|
||||
|
||||
typedef enum {
|
||||
GPIO_MODE_INPUT = 0x00,
|
||||
GPIO_MODE_OUTPUT_0 = 0x0E,
|
||||
GPIO_MODE_OUTPUT_1 = 0x0F,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
|
||||
} EMBEDDED_GPIO_MODE;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULL_NONE,
|
||||
GPIO_PULL_UP,
|
||||
GPIO_PULL_DOWN
|
||||
} EMBEDDED_GPIO_PULL;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_GET) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
OUT UINTN *Value
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Gets the state of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin to read
|
||||
Value - state of the pin
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - GPIO state returned in Value
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_SET) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
IN EMBEDDED_GPIO_MODE Mode
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Sets the state of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin to modify
|
||||
Mode - mode to set
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - GPIO set as requested
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_GET_MODE) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
OUT EMBEDDED_GPIO_MODE *Mode
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Gets the mode (function) of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin
|
||||
Mode - pointer to output mode value
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - mode value retrieved
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_SET_PULL) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
IN EMBEDDED_GPIO_PULL Direction
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Sets the pull-up / pull-down resistor of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin
|
||||
Direction - pull-up, pull-down, or none
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - pin was set
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
|
||||
struct _EMBEDDED_GPIO {
|
||||
EMBEDDED_GPIO_GET Get;
|
||||
EMBEDDED_GPIO_SET Set;
|
||||
EMBEDDED_GPIO_GET_MODE GetMode;
|
||||
EMBEDDED_GPIO_SET_PULL SetPull;
|
||||
};
|
||||
|
||||
extern EFI_GUID gEmbeddedGpioProtocolGuid;
|
||||
|
||||
#endif
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EMBEDDED_GPIO_H__
|
||||
#define __EMBEDDED_GPIO_H__
|
||||
|
||||
//
|
||||
// Protocol interface structure
|
||||
//
|
||||
typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO;
|
||||
|
||||
//
|
||||
// Data Types
|
||||
//
|
||||
typedef UINTN EMBEDDED_GPIO_PIN;
|
||||
|
||||
#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
|
||||
#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
|
||||
#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
|
||||
|
||||
typedef enum {
|
||||
GPIO_MODE_INPUT = 0x00,
|
||||
GPIO_MODE_OUTPUT_0 = 0x0E,
|
||||
GPIO_MODE_OUTPUT_1 = 0x0F,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
|
||||
GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
|
||||
} EMBEDDED_GPIO_MODE;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULL_NONE,
|
||||
GPIO_PULL_UP,
|
||||
GPIO_PULL_DOWN
|
||||
} EMBEDDED_GPIO_PULL;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_GET) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
OUT UINTN *Value
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Gets the state of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin to read
|
||||
Value - state of the pin
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - GPIO state returned in Value
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_SET) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
IN EMBEDDED_GPIO_MODE Mode
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Sets the state of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin to modify
|
||||
Mode - mode to set
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - GPIO set as requested
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_GET_MODE) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
OUT EMBEDDED_GPIO_MODE *Mode
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Gets the mode (function) of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin
|
||||
Mode - pointer to output mode value
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - mode value retrieved
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EMBEDDED_GPIO_SET_PULL) (
|
||||
IN EMBEDDED_GPIO *This,
|
||||
IN EMBEDDED_GPIO_PIN Gpio,
|
||||
IN EMBEDDED_GPIO_PULL Direction
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Sets the pull-up / pull-down resistor of a GPIO pin
|
||||
|
||||
Arguments:
|
||||
|
||||
This - pointer to protocol
|
||||
Gpio - which pin
|
||||
Direction - pull-up, pull-down, or none
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - pin was set
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
|
||||
struct _EMBEDDED_GPIO {
|
||||
EMBEDDED_GPIO_GET Get;
|
||||
EMBEDDED_GPIO_SET Set;
|
||||
EMBEDDED_GPIO_GET_MODE GetMode;
|
||||
EMBEDDED_GPIO_SET_PULL SetPull;
|
||||
};
|
||||
|
||||
extern EFI_GUID gEmbeddedGpioProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
@@ -1,74 +1,74 @@
|
||||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD License
|
||||
* which accompanies this distribution. The full text of the license may be found at
|
||||
* http://opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef _FDT_H
|
||||
#define _FDT_H
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
struct fdt_header {
|
||||
uint32_t magic; /* magic word FDT_MAGIC */
|
||||
uint32_t totalsize; /* total size of DT block */
|
||||
uint32_t off_dt_struct; /* offset to structure */
|
||||
uint32_t off_dt_strings; /* offset to strings */
|
||||
uint32_t off_mem_rsvmap; /* offset to memory reserve map */
|
||||
uint32_t version; /* format version */
|
||||
uint32_t last_comp_version; /* last compatible version */
|
||||
|
||||
/* version 2 fields below */
|
||||
uint32_t boot_cpuid_phys; /* Which physical CPU id we're
|
||||
booting on */
|
||||
/* version 3 fields below */
|
||||
uint32_t size_dt_strings; /* size of the strings block */
|
||||
|
||||
/* version 17 fields below */
|
||||
uint32_t size_dt_struct; /* size of the structure block */
|
||||
};
|
||||
|
||||
struct fdt_reserve_entry {
|
||||
uint64_t address;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
struct fdt_node_header {
|
||||
uint32_t tag;
|
||||
char name[0];
|
||||
};
|
||||
|
||||
struct fdt_property {
|
||||
uint32_t tag;
|
||||
uint32_t len;
|
||||
uint32_t nameoff;
|
||||
char data[0];
|
||||
};
|
||||
|
||||
#endif /* !__ASSEMBLY */
|
||||
|
||||
#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
|
||||
#define FDT_TAGSIZE sizeof(uint32_t)
|
||||
|
||||
#define FDT_BEGIN_NODE 0x1 /* Start node: full name */
|
||||
#define FDT_END_NODE 0x2 /* End node */
|
||||
#define FDT_PROP 0x3 /* Property: name off,
|
||||
size, content */
|
||||
#define FDT_NOP 0x4 /* nop */
|
||||
#define FDT_END 0x9
|
||||
|
||||
#define FDT_V1_SIZE (7*sizeof(uint32_t))
|
||||
#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(uint32_t))
|
||||
#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(uint32_t))
|
||||
#define FDT_V16_SIZE FDT_V3_SIZE
|
||||
#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(uint32_t))
|
||||
|
||||
#endif /* _FDT_H */
|
||||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD License
|
||||
* which accompanies this distribution. The full text of the license may be found at
|
||||
* http://opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef _FDT_H
|
||||
#define _FDT_H
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
struct fdt_header {
|
||||
uint32_t magic; /* magic word FDT_MAGIC */
|
||||
uint32_t totalsize; /* total size of DT block */
|
||||
uint32_t off_dt_struct; /* offset to structure */
|
||||
uint32_t off_dt_strings; /* offset to strings */
|
||||
uint32_t off_mem_rsvmap; /* offset to memory reserve map */
|
||||
uint32_t version; /* format version */
|
||||
uint32_t last_comp_version; /* last compatible version */
|
||||
|
||||
/* version 2 fields below */
|
||||
uint32_t boot_cpuid_phys; /* Which physical CPU id we're
|
||||
booting on */
|
||||
/* version 3 fields below */
|
||||
uint32_t size_dt_strings; /* size of the strings block */
|
||||
|
||||
/* version 17 fields below */
|
||||
uint32_t size_dt_struct; /* size of the structure block */
|
||||
};
|
||||
|
||||
struct fdt_reserve_entry {
|
||||
uint64_t address;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
struct fdt_node_header {
|
||||
uint32_t tag;
|
||||
char name[0];
|
||||
};
|
||||
|
||||
struct fdt_property {
|
||||
uint32_t tag;
|
||||
uint32_t len;
|
||||
uint32_t nameoff;
|
||||
char data[0];
|
||||
};
|
||||
|
||||
#endif /* !__ASSEMBLY */
|
||||
|
||||
#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
|
||||
#define FDT_TAGSIZE sizeof(uint32_t)
|
||||
|
||||
#define FDT_BEGIN_NODE 0x1 /* Start node: full name */
|
||||
#define FDT_END_NODE 0x2 /* End node */
|
||||
#define FDT_PROP 0x3 /* Property: name off,
|
||||
size, content */
|
||||
#define FDT_NOP 0x4 /* nop */
|
||||
#define FDT_END 0x9
|
||||
|
||||
#define FDT_V1_SIZE (7*sizeof(uint32_t))
|
||||
#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(uint32_t))
|
||||
#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(uint32_t))
|
||||
#define FDT_V16_SIZE FDT_V3_SIZE
|
||||
#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(uint32_t))
|
||||
|
||||
#endif /* _FDT_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,77 +1,77 @@
|
||||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD License
|
||||
* which accompanies this distribution. The full text of the license may be found at
|
||||
* http://opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef _LIBFDT_ENV_H
|
||||
#define _LIBFDT_ENV_H
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
typedef UINT8 uint8_t;
|
||||
typedef UINT16 uint16_t;
|
||||
typedef UINT32 uint32_t;
|
||||
typedef UINT64 uint64_t;
|
||||
typedef UINTN uintptr_t;
|
||||
typedef UINTN size_t;
|
||||
|
||||
static inline uint16_t fdt16_to_cpu(uint16_t x)
|
||||
{
|
||||
return SwapBytes16 (x);
|
||||
}
|
||||
#define cpu_to_fdt16(x) fdt16_to_cpu(x)
|
||||
|
||||
static inline uint32_t fdt32_to_cpu(uint32_t x)
|
||||
{
|
||||
return SwapBytes32 (x);
|
||||
}
|
||||
#define cpu_to_fdt32(x) fdt32_to_cpu(x)
|
||||
|
||||
static inline uint64_t fdt64_to_cpu(uint64_t x)
|
||||
{
|
||||
return SwapBytes64 (x);
|
||||
}
|
||||
#define cpu_to_fdt64(x) fdt64_to_cpu(x)
|
||||
|
||||
static inline void* memcpy(void* dest, const void* src, size_t len) {
|
||||
return CopyMem (dest, src, len);
|
||||
}
|
||||
|
||||
static inline void *memmove(void *dest, const void *src, size_t n) {
|
||||
return CopyMem (dest, src, n);
|
||||
}
|
||||
|
||||
static inline void *memset(void *s, int c, size_t n) {
|
||||
return SetMem (s, n, c);
|
||||
}
|
||||
|
||||
static inline int memcmp(const void* dest, const void* src, int len) {
|
||||
return CompareMem (dest, src, len);
|
||||
}
|
||||
|
||||
static inline void *memchr(const void *s, int c, size_t n) {
|
||||
return ScanMem8 (s, n, c);
|
||||
}
|
||||
|
||||
static inline size_t strlen (const char* str) {
|
||||
return AsciiStrLen (str);
|
||||
}
|
||||
|
||||
static inline char *strchr(const char *s, int c) {
|
||||
char pattern[2];
|
||||
pattern[0] = c;
|
||||
pattern[1] = 0;
|
||||
return AsciiStrStr (s, pattern);
|
||||
}
|
||||
|
||||
#endif /* _LIBFDT_ENV_H */
|
||||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD License
|
||||
* which accompanies this distribution. The full text of the license may be found at
|
||||
* http://opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef _LIBFDT_ENV_H
|
||||
#define _LIBFDT_ENV_H
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
typedef UINT8 uint8_t;
|
||||
typedef UINT16 uint16_t;
|
||||
typedef UINT32 uint32_t;
|
||||
typedef UINT64 uint64_t;
|
||||
typedef UINTN uintptr_t;
|
||||
typedef UINTN size_t;
|
||||
|
||||
static inline uint16_t fdt16_to_cpu(uint16_t x)
|
||||
{
|
||||
return SwapBytes16 (x);
|
||||
}
|
||||
#define cpu_to_fdt16(x) fdt16_to_cpu(x)
|
||||
|
||||
static inline uint32_t fdt32_to_cpu(uint32_t x)
|
||||
{
|
||||
return SwapBytes32 (x);
|
||||
}
|
||||
#define cpu_to_fdt32(x) fdt32_to_cpu(x)
|
||||
|
||||
static inline uint64_t fdt64_to_cpu(uint64_t x)
|
||||
{
|
||||
return SwapBytes64 (x);
|
||||
}
|
||||
#define cpu_to_fdt64(x) fdt64_to_cpu(x)
|
||||
|
||||
static inline void* memcpy(void* dest, const void* src, size_t len) {
|
||||
return CopyMem (dest, src, len);
|
||||
}
|
||||
|
||||
static inline void *memmove(void *dest, const void *src, size_t n) {
|
||||
return CopyMem (dest, src, n);
|
||||
}
|
||||
|
||||
static inline void *memset(void *s, int c, size_t n) {
|
||||
return SetMem (s, n, c);
|
||||
}
|
||||
|
||||
static inline int memcmp(const void* dest, const void* src, int len) {
|
||||
return CompareMem (dest, src, len);
|
||||
}
|
||||
|
||||
static inline void *memchr(const void *s, int c, size_t n) {
|
||||
return ScanMem8 (s, n, c);
|
||||
}
|
||||
|
||||
static inline size_t strlen (const char* str) {
|
||||
return AsciiStrLen (str);
|
||||
}
|
||||
|
||||
static inline char *strchr(const char *s, int c) {
|
||||
char pattern[2];
|
||||
pattern[0] = c;
|
||||
pattern[1] = 0;
|
||||
return AsciiStrStr (s, pattern);
|
||||
}
|
||||
|
||||
#endif /* _LIBFDT_ENV_H */
|
||||
|
@@ -61,4 +61,4 @@ DebugAgentTimerEndOfInterrupt (
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
@@ -45,4 +45,4 @@
|
||||
gEfiEblAddCommandProtocolGuid
|
||||
|
||||
[Guids]
|
||||
|
||||
|
@@ -41,4 +41,4 @@
|
||||
[Protocols]
|
||||
|
||||
[Guids]
|
||||
|
||||
|
@@ -1,173 +1,173 @@
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
|
||||
|
||||
BOOLEAN gUseIpv6 = FALSE;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentIpAddress (
|
||||
IN OUT EFI_IP_ADDRESS *Ip
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Start (Pxe, gUseIpv6);
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
CopyMem (Ip, &Pxe->Mode->StationIp, sizeof (EFI_IP_ADDRESS));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentMacAddress (
|
||||
IN OUT EFI_MAC_ADDRESS *Mac
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNet;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiSimpleNetworkProtocolGuid, NULL, (VOID **)&SimpleNet);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
CopyMem (Mac, SimpleNet->Mode->CurrentAddress.Addr, sizeof (EFI_MAC_ADDRESS));
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
EblLoadFileBootTypeString (
|
||||
IN EFI_HANDLE Handle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *NullPtr;
|
||||
|
||||
Status = gBS->HandleProtocol (Handle, &gEfiPxeBaseCodeProtocolGuid, &NullPtr);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return "EFI PXE Network Boot";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblPerformDHCP (
|
||||
IN BOOLEAN SortOffers
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Start (Pxe, gUseIpv6);
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Dhcp(Pxe, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblSetStationIp (
|
||||
IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Start (Pxe, gUseIpv6);
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->SetStationIp (Pxe, NewStationIp, NewSubnetMask);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblMtftp (
|
||||
IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
|
||||
IN OUT VOID *BufferPtr OPTIONAL,
|
||||
IN BOOLEAN Overwrite,
|
||||
IN OUT UINT64 *BufferSize,
|
||||
IN UINTN *BlockSize OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *ServerIp,
|
||||
IN UINT8 *Filename OPTIONAL,
|
||||
IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
|
||||
IN BOOLEAN DontUseBuffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Mtftp (
|
||||
Pxe,
|
||||
Operation,
|
||||
BufferPtr,
|
||||
Overwrite,
|
||||
BufferSize,
|
||||
BlockSize,
|
||||
ServerIp,
|
||||
Filename,
|
||||
Info,
|
||||
DontUseBuffer
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
|
||||
|
||||
BOOLEAN gUseIpv6 = FALSE;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentIpAddress (
|
||||
IN OUT EFI_IP_ADDRESS *Ip
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Start (Pxe, gUseIpv6);
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
CopyMem (Ip, &Pxe->Mode->StationIp, sizeof (EFI_IP_ADDRESS));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblGetCurrentMacAddress (
|
||||
IN OUT EFI_MAC_ADDRESS *Mac
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNet;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiSimpleNetworkProtocolGuid, NULL, (VOID **)&SimpleNet);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
CopyMem (Mac, SimpleNet->Mode->CurrentAddress.Addr, sizeof (EFI_MAC_ADDRESS));
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
EblLoadFileBootTypeString (
|
||||
IN EFI_HANDLE Handle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *NullPtr;
|
||||
|
||||
Status = gBS->HandleProtocol (Handle, &gEfiPxeBaseCodeProtocolGuid, &NullPtr);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return "EFI PXE Network Boot";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblPerformDHCP (
|
||||
IN BOOLEAN SortOffers
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Start (Pxe, gUseIpv6);
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Dhcp(Pxe, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblSetStationIp (
|
||||
IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL
|
||||
IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Start (Pxe, gUseIpv6);
|
||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->SetStationIp (Pxe, NewStationIp, NewSubnetMask);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EblMtftp (
|
||||
IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
|
||||
IN OUT VOID *BufferPtr OPTIONAL,
|
||||
IN BOOLEAN Overwrite,
|
||||
IN OUT UINT64 *BufferSize,
|
||||
IN UINTN *BlockSize OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *ServerIp,
|
||||
IN UINT8 *Filename OPTIONAL,
|
||||
IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
|
||||
IN BOOLEAN DontUseBuffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Pxe->Mtftp (
|
||||
Pxe,
|
||||
Operation,
|
||||
BufferPtr,
|
||||
Overwrite,
|
||||
BufferSize,
|
||||
BlockSize,
|
||||
ServerIp,
|
||||
Filename,
|
||||
Info,
|
||||
DontUseBuffer
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@@ -31,4 +31,4 @@
|
||||
gEfiPxeBaseCodeProtocolGuid
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
TRUE
|
File diff suppressed because it is too large
Load Diff
@@ -1,222 +1,222 @@
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
int fdt_check_header(const void *fdt)
|
||||
{
|
||||
if (fdt_magic(fdt) == FDT_MAGIC) {
|
||||
/* Complete tree */
|
||||
if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
|
||||
/* Unfinished sequential-write blob */
|
||||
if (fdt_size_dt_struct(fdt) == 0)
|
||||
return -FDT_ERR_BADSTATE;
|
||||
} else {
|
||||
return -FDT_ERR_BADMAGIC;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (fdt_version(fdt) >= 0x11)
|
||||
if (((offset + len) < offset)
|
||||
|| ((offset + len) > fdt_size_dt_struct(fdt)))
|
||||
return NULL;
|
||||
|
||||
p = _fdt_offset_ptr(fdt, offset);
|
||||
|
||||
if (p + len < p)
|
||||
return NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
|
||||
{
|
||||
const uint32_t *tagp, *lenp;
|
||||
uint32_t tag;
|
||||
int offset = startoffset;
|
||||
const char *p;
|
||||
|
||||
*nextoffset = -FDT_ERR_TRUNCATED;
|
||||
tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE);
|
||||
if (!tagp)
|
||||
return FDT_END; /* premature end */
|
||||
tag = fdt32_to_cpu(*tagp);
|
||||
offset += FDT_TAGSIZE;
|
||||
|
||||
*nextoffset = -FDT_ERR_BADSTRUCTURE;
|
||||
switch (tag) {
|
||||
case FDT_BEGIN_NODE:
|
||||
/* skip name */
|
||||
do {
|
||||
p = fdt_offset_ptr(fdt, offset++, 1);
|
||||
} while (p && (*p != '\0'));
|
||||
if (!p)
|
||||
return FDT_END; /* premature end */
|
||||
break;
|
||||
|
||||
case FDT_PROP:
|
||||
lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));
|
||||
if (!lenp)
|
||||
return FDT_END; /* premature end */
|
||||
/* skip-name offset, length and value */
|
||||
offset += sizeof(struct fdt_property) - FDT_TAGSIZE
|
||||
+ fdt32_to_cpu(*lenp);
|
||||
break;
|
||||
|
||||
case FDT_END:
|
||||
case FDT_END_NODE:
|
||||
case FDT_NOP:
|
||||
break;
|
||||
|
||||
default:
|
||||
return FDT_END;
|
||||
}
|
||||
|
||||
if (!fdt_offset_ptr(fdt, startoffset, offset - startoffset))
|
||||
return FDT_END; /* premature end */
|
||||
|
||||
*nextoffset = FDT_TAGALIGN(offset);
|
||||
return tag;
|
||||
}
|
||||
|
||||
int _fdt_check_node_offset(const void *fdt, int offset)
|
||||
{
|
||||
if ((offset < 0) || (offset % FDT_TAGSIZE)
|
||||
|| (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))
|
||||
return -FDT_ERR_BADOFFSET;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int _fdt_check_prop_offset(const void *fdt, int offset)
|
||||
{
|
||||
if ((offset < 0) || (offset % FDT_TAGSIZE)
|
||||
|| (fdt_next_tag(fdt, offset, &offset) != FDT_PROP))
|
||||
return -FDT_ERR_BADOFFSET;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_next_node(const void *fdt, int offset, int *depth)
|
||||
{
|
||||
int nextoffset = 0;
|
||||
uint32_t tag;
|
||||
|
||||
if (offset >= 0)
|
||||
if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0)
|
||||
return nextoffset;
|
||||
|
||||
do {
|
||||
offset = nextoffset;
|
||||
tag = fdt_next_tag(fdt, offset, &nextoffset);
|
||||
|
||||
switch (tag) {
|
||||
case FDT_PROP:
|
||||
case FDT_NOP:
|
||||
break;
|
||||
|
||||
case FDT_BEGIN_NODE:
|
||||
if (depth)
|
||||
(*depth)++;
|
||||
break;
|
||||
|
||||
case FDT_END_NODE:
|
||||
if (depth && ((--(*depth)) < 0))
|
||||
return nextoffset;
|
||||
break;
|
||||
|
||||
case FDT_END:
|
||||
if ((nextoffset >= 0)
|
||||
|| ((nextoffset == -FDT_ERR_TRUNCATED) && !depth))
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
else
|
||||
return nextoffset;
|
||||
}
|
||||
} while (tag != FDT_BEGIN_NODE);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
|
||||
{
|
||||
int len = strlen(s) + 1;
|
||||
const char *last = strtab + tabsize - len;
|
||||
const char *p;
|
||||
|
||||
for (p = strtab; p <= last; p++)
|
||||
if (memcmp(p, s, len) == 0)
|
||||
return p;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fdt_move(const void *fdt, void *buf, int bufsize)
|
||||
{
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_totalsize(fdt) > bufsize)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
memmove(buf, fdt, fdt_totalsize(fdt));
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
int fdt_check_header(const void *fdt)
|
||||
{
|
||||
if (fdt_magic(fdt) == FDT_MAGIC) {
|
||||
/* Complete tree */
|
||||
if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
|
||||
/* Unfinished sequential-write blob */
|
||||
if (fdt_size_dt_struct(fdt) == 0)
|
||||
return -FDT_ERR_BADSTATE;
|
||||
} else {
|
||||
return -FDT_ERR_BADMAGIC;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (fdt_version(fdt) >= 0x11)
|
||||
if (((offset + len) < offset)
|
||||
|| ((offset + len) > fdt_size_dt_struct(fdt)))
|
||||
return NULL;
|
||||
|
||||
p = _fdt_offset_ptr(fdt, offset);
|
||||
|
||||
if (p + len < p)
|
||||
return NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
|
||||
{
|
||||
const uint32_t *tagp, *lenp;
|
||||
uint32_t tag;
|
||||
int offset = startoffset;
|
||||
const char *p;
|
||||
|
||||
*nextoffset = -FDT_ERR_TRUNCATED;
|
||||
tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE);
|
||||
if (!tagp)
|
||||
return FDT_END; /* premature end */
|
||||
tag = fdt32_to_cpu(*tagp);
|
||||
offset += FDT_TAGSIZE;
|
||||
|
||||
*nextoffset = -FDT_ERR_BADSTRUCTURE;
|
||||
switch (tag) {
|
||||
case FDT_BEGIN_NODE:
|
||||
/* skip name */
|
||||
do {
|
||||
p = fdt_offset_ptr(fdt, offset++, 1);
|
||||
} while (p && (*p != '\0'));
|
||||
if (!p)
|
||||
return FDT_END; /* premature end */
|
||||
break;
|
||||
|
||||
case FDT_PROP:
|
||||
lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));
|
||||
if (!lenp)
|
||||
return FDT_END; /* premature end */
|
||||
/* skip-name offset, length and value */
|
||||
offset += sizeof(struct fdt_property) - FDT_TAGSIZE
|
||||
+ fdt32_to_cpu(*lenp);
|
||||
break;
|
||||
|
||||
case FDT_END:
|
||||
case FDT_END_NODE:
|
||||
case FDT_NOP:
|
||||
break;
|
||||
|
||||
default:
|
||||
return FDT_END;
|
||||
}
|
||||
|
||||
if (!fdt_offset_ptr(fdt, startoffset, offset - startoffset))
|
||||
return FDT_END; /* premature end */
|
||||
|
||||
*nextoffset = FDT_TAGALIGN(offset);
|
||||
return tag;
|
||||
}
|
||||
|
||||
int _fdt_check_node_offset(const void *fdt, int offset)
|
||||
{
|
||||
if ((offset < 0) || (offset % FDT_TAGSIZE)
|
||||
|| (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))
|
||||
return -FDT_ERR_BADOFFSET;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int _fdt_check_prop_offset(const void *fdt, int offset)
|
||||
{
|
||||
if ((offset < 0) || (offset % FDT_TAGSIZE)
|
||||
|| (fdt_next_tag(fdt, offset, &offset) != FDT_PROP))
|
||||
return -FDT_ERR_BADOFFSET;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_next_node(const void *fdt, int offset, int *depth)
|
||||
{
|
||||
int nextoffset = 0;
|
||||
uint32_t tag;
|
||||
|
||||
if (offset >= 0)
|
||||
if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0)
|
||||
return nextoffset;
|
||||
|
||||
do {
|
||||
offset = nextoffset;
|
||||
tag = fdt_next_tag(fdt, offset, &nextoffset);
|
||||
|
||||
switch (tag) {
|
||||
case FDT_PROP:
|
||||
case FDT_NOP:
|
||||
break;
|
||||
|
||||
case FDT_BEGIN_NODE:
|
||||
if (depth)
|
||||
(*depth)++;
|
||||
break;
|
||||
|
||||
case FDT_END_NODE:
|
||||
if (depth && ((--(*depth)) < 0))
|
||||
return nextoffset;
|
||||
break;
|
||||
|
||||
case FDT_END:
|
||||
if ((nextoffset >= 0)
|
||||
|| ((nextoffset == -FDT_ERR_TRUNCATED) && !depth))
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
else
|
||||
return nextoffset;
|
||||
}
|
||||
} while (tag != FDT_BEGIN_NODE);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
|
||||
{
|
||||
int len = strlen(s) + 1;
|
||||
const char *last = strtab + tabsize - len;
|
||||
const char *p;
|
||||
|
||||
for (p = strtab; p <= last; p++)
|
||||
if (memcmp(p, s, len) == 0)
|
||||
return p;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fdt_move(const void *fdt, void *buf, int bufsize)
|
||||
{
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_totalsize(fdt) > bufsize)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
memmove(buf, fdt, fdt_totalsize(fdt));
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,84 +1,84 @@
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2012 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
int fdt_create_empty_tree(void *buf, int bufsize)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = fdt_create(buf, bufsize);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_finish_reservemap(buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_begin_node(buf, "");
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_end_node(buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_finish(buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return fdt_open_into(buf, buf, bufsize);
|
||||
}
|
||||
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2012 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
int fdt_create_empty_tree(void *buf, int bufsize)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = fdt_create(buf, bufsize);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_finish_reservemap(buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_begin_node(buf, "");
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_end_node(buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = fdt_finish(buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return fdt_open_into(buf, buf, bufsize);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,495 +1,495 @@
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
static int _fdt_blocks_misordered(const void *fdt,
|
||||
int mem_rsv_size, int struct_size)
|
||||
{
|
||||
return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))
|
||||
|| (fdt_off_dt_struct(fdt) <
|
||||
(fdt_off_mem_rsvmap(fdt) + mem_rsv_size))
|
||||
|| (fdt_off_dt_strings(fdt) <
|
||||
(fdt_off_dt_struct(fdt) + struct_size))
|
||||
|| (fdt_totalsize(fdt) <
|
||||
(fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));
|
||||
}
|
||||
|
||||
static int _fdt_rw_check_header(void *fdt)
|
||||
{
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_version(fdt) < 17)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
if (_fdt_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
|
||||
fdt_size_dt_struct(fdt)))
|
||||
return -FDT_ERR_BADLAYOUT;
|
||||
if (fdt_version(fdt) > 17)
|
||||
fdt_set_version(fdt, 17);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_RW_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = _fdt_rw_check_header(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
static inline int _fdt_data_size(void *fdt)
|
||||
{
|
||||
return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
|
||||
}
|
||||
|
||||
static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
|
||||
{
|
||||
char *p = splicepoint;
|
||||
char *end = (char *)fdt + _fdt_data_size(fdt);
|
||||
|
||||
if (((p + oldlen) < p) || ((p + oldlen) > end))
|
||||
return -FDT_ERR_BADOFFSET;
|
||||
if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize(fdt)))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
memmove(p + newlen, p + oldlen, end - p - oldlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
|
||||
int oldn, int newn)
|
||||
{
|
||||
int delta = (newn - oldn) * sizeof(*p);
|
||||
int err;
|
||||
err = _fdt_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
|
||||
if (err)
|
||||
return err;
|
||||
fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);
|
||||
fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_splice_struct(void *fdt, void *p,
|
||||
int oldlen, int newlen)
|
||||
{
|
||||
int delta = newlen - oldlen;
|
||||
int err;
|
||||
|
||||
err = _fdt_splice(fdt, p, oldlen, newlen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
|
||||
fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_splice_string(void *fdt, int newlen)
|
||||
{
|
||||
void *p = (char *)fdt
|
||||
+ fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
|
||||
int err;
|
||||
|
||||
err = _fdt_splice(fdt, p, 0, newlen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_find_add_string(void *fdt, const char *s)
|
||||
{
|
||||
char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
|
||||
const char *p;
|
||||
char *new;
|
||||
int len = strlen(s) + 1;
|
||||
int err;
|
||||
|
||||
p = _fdt_find_string(strtab, fdt_size_dt_strings(fdt), s);
|
||||
if (p)
|
||||
/* found it */
|
||||
return (p - strtab);
|
||||
|
||||
new = strtab + fdt_size_dt_strings(fdt);
|
||||
err = _fdt_splice_string(fdt, len);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy(new, s, len);
|
||||
return (new - strtab);
|
||||
}
|
||||
|
||||
int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
|
||||
{
|
||||
struct fdt_reserve_entry *re;
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt));
|
||||
err = _fdt_splice_mem_rsv(fdt, re, 0, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
re->address = cpu_to_fdt64(address);
|
||||
re->size = cpu_to_fdt64(size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_del_mem_rsv(void *fdt, int n)
|
||||
{
|
||||
struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
if (n >= fdt_num_mem_rsv(fdt))
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
|
||||
err = _fdt_splice_mem_rsv(fdt, re, 1, 0);
|
||||
if (err)
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
|
||||
int len, struct fdt_property **prop)
|
||||
{
|
||||
int oldlen;
|
||||
int err;
|
||||
|
||||
*prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
|
||||
if (! (*prop))
|
||||
return oldlen;
|
||||
|
||||
err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
|
||||
FDT_TAGALIGN(len));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
(*prop)->len = cpu_to_fdt32(len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,
|
||||
int len, struct fdt_property **prop)
|
||||
{
|
||||
int proplen;
|
||||
int nextoffset;
|
||||
int namestroff;
|
||||
int err;
|
||||
|
||||
if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
|
||||
return nextoffset;
|
||||
|
||||
namestroff = _fdt_find_add_string(fdt, name);
|
||||
if (namestroff < 0)
|
||||
return namestroff;
|
||||
|
||||
*prop = _fdt_offset_ptr_w(fdt, nextoffset);
|
||||
proplen = sizeof(**prop) + FDT_TAGALIGN(len);
|
||||
|
||||
err = _fdt_splice_struct(fdt, *prop, 0, proplen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
(*prop)->tag = cpu_to_fdt32(FDT_PROP);
|
||||
(*prop)->nameoff = cpu_to_fdt32(namestroff);
|
||||
(*prop)->len = cpu_to_fdt32(len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_set_name(void *fdt, int nodeoffset, const char *name)
|
||||
{
|
||||
char *namep;
|
||||
int oldlen, newlen;
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
|
||||
if (!namep)
|
||||
return oldlen;
|
||||
|
||||
newlen = strlen(name);
|
||||
|
||||
err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1),
|
||||
FDT_TAGALIGN(newlen+1));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy(namep, name, newlen+1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_setprop(void *fdt, int nodeoffset, const char *name,
|
||||
const void *val, int len)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
err = _fdt_resize_property(fdt, nodeoffset, name, len, &prop);
|
||||
if (err == -FDT_ERR_NOTFOUND)
|
||||
err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy(prop->data, val, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
|
||||
const void *val, int len)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int err, oldlen, newlen;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
|
||||
if (prop) {
|
||||
newlen = len + oldlen;
|
||||
err = _fdt_splice_struct(fdt, prop->data,
|
||||
FDT_TAGALIGN(oldlen),
|
||||
FDT_TAGALIGN(newlen));
|
||||
if (err)
|
||||
return err;
|
||||
prop->len = cpu_to_fdt32(newlen);
|
||||
memcpy(prop->data + oldlen, val, len);
|
||||
} else {
|
||||
err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
|
||||
if (err)
|
||||
return err;
|
||||
memcpy(prop->data, val, len);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_delprop(void *fdt, int nodeoffset, const char *name)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int len, proplen;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
|
||||
if (! prop)
|
||||
return len;
|
||||
|
||||
proplen = sizeof(*prop) + FDT_TAGALIGN(len);
|
||||
return _fdt_splice_struct(fdt, prop, proplen, 0);
|
||||
}
|
||||
|
||||
int fdt_add_subnode_namelen(void *fdt, int parentoffset,
|
||||
const char *name, int namelen)
|
||||
{
|
||||
struct fdt_node_header *nh;
|
||||
int offset, nextoffset;
|
||||
int nodelen;
|
||||
int err;
|
||||
uint32_t tag;
|
||||
uint32_t *endtag;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);
|
||||
if (offset >= 0)
|
||||
return -FDT_ERR_EXISTS;
|
||||
else if (offset != -FDT_ERR_NOTFOUND)
|
||||
return offset;
|
||||
|
||||
/* Try to place the new node after the parent's properties */
|
||||
fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
|
||||
do {
|
||||
offset = nextoffset;
|
||||
tag = fdt_next_tag(fdt, offset, &nextoffset);
|
||||
} while ((tag == FDT_PROP) || (tag == FDT_NOP));
|
||||
|
||||
nh = _fdt_offset_ptr_w(fdt, offset);
|
||||
nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;
|
||||
|
||||
err = _fdt_splice_struct(fdt, nh, 0, nodelen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
|
||||
memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
|
||||
memcpy(nh->name, name, namelen);
|
||||
endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
|
||||
*endtag = cpu_to_fdt32(FDT_END_NODE);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_add_subnode(void *fdt, int parentoffset, const char *name)
|
||||
{
|
||||
return fdt_add_subnode_namelen(fdt, parentoffset, name, strlen(name));
|
||||
}
|
||||
|
||||
int fdt_del_node(void *fdt, int nodeoffset)
|
||||
{
|
||||
int endoffset;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
endoffset = _fdt_node_end_offset(fdt, nodeoffset);
|
||||
if (endoffset < 0)
|
||||
return endoffset;
|
||||
|
||||
return _fdt_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset),
|
||||
endoffset - nodeoffset, 0);
|
||||
}
|
||||
|
||||
static void _fdt_packblocks(const char *old, char *new,
|
||||
int mem_rsv_size, int struct_size)
|
||||
{
|
||||
int mem_rsv_off, struct_off, strings_off;
|
||||
|
||||
mem_rsv_off = FDT_ALIGN(sizeof(struct fdt_header), 8);
|
||||
struct_off = mem_rsv_off + mem_rsv_size;
|
||||
strings_off = struct_off + struct_size;
|
||||
|
||||
memmove(new + mem_rsv_off, old + fdt_off_mem_rsvmap(old), mem_rsv_size);
|
||||
fdt_set_off_mem_rsvmap(new, mem_rsv_off);
|
||||
|
||||
memmove(new + struct_off, old + fdt_off_dt_struct(old), struct_size);
|
||||
fdt_set_off_dt_struct(new, struct_off);
|
||||
fdt_set_size_dt_struct(new, struct_size);
|
||||
|
||||
memmove(new + strings_off, old + fdt_off_dt_strings(old),
|
||||
fdt_size_dt_strings(old));
|
||||
fdt_set_off_dt_strings(new, strings_off);
|
||||
fdt_set_size_dt_strings(new, fdt_size_dt_strings(old));
|
||||
}
|
||||
|
||||
int fdt_open_into(const void *fdt, void *buf, int bufsize)
|
||||
{
|
||||
int err;
|
||||
int mem_rsv_size, struct_size;
|
||||
int newsize;
|
||||
const char *fdtstart = fdt;
|
||||
const char *fdtend = fdtstart + fdt_totalsize(fdt);
|
||||
char *tmp;
|
||||
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
||||
* sizeof(struct fdt_reserve_entry);
|
||||
|
||||
if (fdt_version(fdt) >= 17) {
|
||||
struct_size = fdt_size_dt_struct(fdt);
|
||||
} else {
|
||||
struct_size = 0;
|
||||
while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END)
|
||||
;
|
||||
if (struct_size < 0)
|
||||
return struct_size;
|
||||
}
|
||||
|
||||
if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) {
|
||||
/* no further work necessary */
|
||||
err = fdt_move(fdt, buf, bufsize);
|
||||
if (err)
|
||||
return err;
|
||||
fdt_set_version(buf, 17);
|
||||
fdt_set_size_dt_struct(buf, struct_size);
|
||||
fdt_set_totalsize(buf, bufsize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Need to reorder */
|
||||
newsize = FDT_ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size
|
||||
+ struct_size + fdt_size_dt_strings(fdt);
|
||||
|
||||
if (bufsize < newsize)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
/* First attempt to build converted tree at beginning of buffer */
|
||||
tmp = buf;
|
||||
/* But if that overlaps with the old tree... */
|
||||
if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
|
||||
/* Try right after the old tree instead */
|
||||
tmp = (char *)(uintptr_t)fdtend;
|
||||
if ((tmp + newsize) > ((char *)buf + bufsize))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
}
|
||||
|
||||
_fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size);
|
||||
memmove(buf, tmp, newsize);
|
||||
|
||||
fdt_set_magic(buf, FDT_MAGIC);
|
||||
fdt_set_totalsize(buf, bufsize);
|
||||
fdt_set_version(buf, 17);
|
||||
fdt_set_last_comp_version(buf, 16);
|
||||
fdt_set_boot_cpuid_phys(buf, fdt_boot_cpuid_phys(fdt));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_pack(void *fdt)
|
||||
{
|
||||
int mem_rsv_size;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
||||
* sizeof(struct fdt_reserve_entry);
|
||||
_fdt_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
|
||||
fdt_set_totalsize(fdt, _fdt_data_size(fdt));
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
static int _fdt_blocks_misordered(const void *fdt,
|
||||
int mem_rsv_size, int struct_size)
|
||||
{
|
||||
return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))
|
||||
|| (fdt_off_dt_struct(fdt) <
|
||||
(fdt_off_mem_rsvmap(fdt) + mem_rsv_size))
|
||||
|| (fdt_off_dt_strings(fdt) <
|
||||
(fdt_off_dt_struct(fdt) + struct_size))
|
||||
|| (fdt_totalsize(fdt) <
|
||||
(fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));
|
||||
}
|
||||
|
||||
static int _fdt_rw_check_header(void *fdt)
|
||||
{
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_version(fdt) < 17)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
if (_fdt_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
|
||||
fdt_size_dt_struct(fdt)))
|
||||
return -FDT_ERR_BADLAYOUT;
|
||||
if (fdt_version(fdt) > 17)
|
||||
fdt_set_version(fdt, 17);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_RW_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = _fdt_rw_check_header(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
static inline int _fdt_data_size(void *fdt)
|
||||
{
|
||||
return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
|
||||
}
|
||||
|
||||
static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
|
||||
{
|
||||
char *p = splicepoint;
|
||||
char *end = (char *)fdt + _fdt_data_size(fdt);
|
||||
|
||||
if (((p + oldlen) < p) || ((p + oldlen) > end))
|
||||
return -FDT_ERR_BADOFFSET;
|
||||
if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize(fdt)))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
memmove(p + newlen, p + oldlen, end - p - oldlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
|
||||
int oldn, int newn)
|
||||
{
|
||||
int delta = (newn - oldn) * sizeof(*p);
|
||||
int err;
|
||||
err = _fdt_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
|
||||
if (err)
|
||||
return err;
|
||||
fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);
|
||||
fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_splice_struct(void *fdt, void *p,
|
||||
int oldlen, int newlen)
|
||||
{
|
||||
int delta = newlen - oldlen;
|
||||
int err;
|
||||
|
||||
err = _fdt_splice(fdt, p, oldlen, newlen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
|
||||
fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_splice_string(void *fdt, int newlen)
|
||||
{
|
||||
void *p = (char *)fdt
|
||||
+ fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
|
||||
int err;
|
||||
|
||||
err = _fdt_splice(fdt, p, 0, newlen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_find_add_string(void *fdt, const char *s)
|
||||
{
|
||||
char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
|
||||
const char *p;
|
||||
char *new;
|
||||
int len = strlen(s) + 1;
|
||||
int err;
|
||||
|
||||
p = _fdt_find_string(strtab, fdt_size_dt_strings(fdt), s);
|
||||
if (p)
|
||||
/* found it */
|
||||
return (p - strtab);
|
||||
|
||||
new = strtab + fdt_size_dt_strings(fdt);
|
||||
err = _fdt_splice_string(fdt, len);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy(new, s, len);
|
||||
return (new - strtab);
|
||||
}
|
||||
|
||||
int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
|
||||
{
|
||||
struct fdt_reserve_entry *re;
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt));
|
||||
err = _fdt_splice_mem_rsv(fdt, re, 0, 1);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
re->address = cpu_to_fdt64(address);
|
||||
re->size = cpu_to_fdt64(size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_del_mem_rsv(void *fdt, int n)
|
||||
{
|
||||
struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
if (n >= fdt_num_mem_rsv(fdt))
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
|
||||
err = _fdt_splice_mem_rsv(fdt, re, 1, 0);
|
||||
if (err)
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
|
||||
int len, struct fdt_property **prop)
|
||||
{
|
||||
int oldlen;
|
||||
int err;
|
||||
|
||||
*prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
|
||||
if (! (*prop))
|
||||
return oldlen;
|
||||
|
||||
err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
|
||||
FDT_TAGALIGN(len));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
(*prop)->len = cpu_to_fdt32(len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,
|
||||
int len, struct fdt_property **prop)
|
||||
{
|
||||
int proplen;
|
||||
int nextoffset;
|
||||
int namestroff;
|
||||
int err;
|
||||
|
||||
if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
|
||||
return nextoffset;
|
||||
|
||||
namestroff = _fdt_find_add_string(fdt, name);
|
||||
if (namestroff < 0)
|
||||
return namestroff;
|
||||
|
||||
*prop = _fdt_offset_ptr_w(fdt, nextoffset);
|
||||
proplen = sizeof(**prop) + FDT_TAGALIGN(len);
|
||||
|
||||
err = _fdt_splice_struct(fdt, *prop, 0, proplen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
(*prop)->tag = cpu_to_fdt32(FDT_PROP);
|
||||
(*prop)->nameoff = cpu_to_fdt32(namestroff);
|
||||
(*prop)->len = cpu_to_fdt32(len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_set_name(void *fdt, int nodeoffset, const char *name)
|
||||
{
|
||||
char *namep;
|
||||
int oldlen, newlen;
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
|
||||
if (!namep)
|
||||
return oldlen;
|
||||
|
||||
newlen = strlen(name);
|
||||
|
||||
err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1),
|
||||
FDT_TAGALIGN(newlen+1));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy(namep, name, newlen+1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_setprop(void *fdt, int nodeoffset, const char *name,
|
||||
const void *val, int len)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int err;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
err = _fdt_resize_property(fdt, nodeoffset, name, len, &prop);
|
||||
if (err == -FDT_ERR_NOTFOUND)
|
||||
err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy(prop->data, val, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
|
||||
const void *val, int len)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int err, oldlen, newlen;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
|
||||
if (prop) {
|
||||
newlen = len + oldlen;
|
||||
err = _fdt_splice_struct(fdt, prop->data,
|
||||
FDT_TAGALIGN(oldlen),
|
||||
FDT_TAGALIGN(newlen));
|
||||
if (err)
|
||||
return err;
|
||||
prop->len = cpu_to_fdt32(newlen);
|
||||
memcpy(prop->data + oldlen, val, len);
|
||||
} else {
|
||||
err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
|
||||
if (err)
|
||||
return err;
|
||||
memcpy(prop->data, val, len);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_delprop(void *fdt, int nodeoffset, const char *name)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int len, proplen;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
|
||||
if (! prop)
|
||||
return len;
|
||||
|
||||
proplen = sizeof(*prop) + FDT_TAGALIGN(len);
|
||||
return _fdt_splice_struct(fdt, prop, proplen, 0);
|
||||
}
|
||||
|
||||
int fdt_add_subnode_namelen(void *fdt, int parentoffset,
|
||||
const char *name, int namelen)
|
||||
{
|
||||
struct fdt_node_header *nh;
|
||||
int offset, nextoffset;
|
||||
int nodelen;
|
||||
int err;
|
||||
uint32_t tag;
|
||||
uint32_t *endtag;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);
|
||||
if (offset >= 0)
|
||||
return -FDT_ERR_EXISTS;
|
||||
else if (offset != -FDT_ERR_NOTFOUND)
|
||||
return offset;
|
||||
|
||||
/* Try to place the new node after the parent's properties */
|
||||
fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
|
||||
do {
|
||||
offset = nextoffset;
|
||||
tag = fdt_next_tag(fdt, offset, &nextoffset);
|
||||
} while ((tag == FDT_PROP) || (tag == FDT_NOP));
|
||||
|
||||
nh = _fdt_offset_ptr_w(fdt, offset);
|
||||
nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;
|
||||
|
||||
err = _fdt_splice_struct(fdt, nh, 0, nodelen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
|
||||
memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
|
||||
memcpy(nh->name, name, namelen);
|
||||
endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
|
||||
*endtag = cpu_to_fdt32(FDT_END_NODE);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_add_subnode(void *fdt, int parentoffset, const char *name)
|
||||
{
|
||||
return fdt_add_subnode_namelen(fdt, parentoffset, name, strlen(name));
|
||||
}
|
||||
|
||||
int fdt_del_node(void *fdt, int nodeoffset)
|
||||
{
|
||||
int endoffset;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
endoffset = _fdt_node_end_offset(fdt, nodeoffset);
|
||||
if (endoffset < 0)
|
||||
return endoffset;
|
||||
|
||||
return _fdt_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset),
|
||||
endoffset - nodeoffset, 0);
|
||||
}
|
||||
|
||||
static void _fdt_packblocks(const char *old, char *new,
|
||||
int mem_rsv_size, int struct_size)
|
||||
{
|
||||
int mem_rsv_off, struct_off, strings_off;
|
||||
|
||||
mem_rsv_off = FDT_ALIGN(sizeof(struct fdt_header), 8);
|
||||
struct_off = mem_rsv_off + mem_rsv_size;
|
||||
strings_off = struct_off + struct_size;
|
||||
|
||||
memmove(new + mem_rsv_off, old + fdt_off_mem_rsvmap(old), mem_rsv_size);
|
||||
fdt_set_off_mem_rsvmap(new, mem_rsv_off);
|
||||
|
||||
memmove(new + struct_off, old + fdt_off_dt_struct(old), struct_size);
|
||||
fdt_set_off_dt_struct(new, struct_off);
|
||||
fdt_set_size_dt_struct(new, struct_size);
|
||||
|
||||
memmove(new + strings_off, old + fdt_off_dt_strings(old),
|
||||
fdt_size_dt_strings(old));
|
||||
fdt_set_off_dt_strings(new, strings_off);
|
||||
fdt_set_size_dt_strings(new, fdt_size_dt_strings(old));
|
||||
}
|
||||
|
||||
int fdt_open_into(const void *fdt, void *buf, int bufsize)
|
||||
{
|
||||
int err;
|
||||
int mem_rsv_size, struct_size;
|
||||
int newsize;
|
||||
const char *fdtstart = fdt;
|
||||
const char *fdtend = fdtstart + fdt_totalsize(fdt);
|
||||
char *tmp;
|
||||
|
||||
FDT_CHECK_HEADER(fdt);
|
||||
|
||||
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
||||
* sizeof(struct fdt_reserve_entry);
|
||||
|
||||
if (fdt_version(fdt) >= 17) {
|
||||
struct_size = fdt_size_dt_struct(fdt);
|
||||
} else {
|
||||
struct_size = 0;
|
||||
while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END)
|
||||
;
|
||||
if (struct_size < 0)
|
||||
return struct_size;
|
||||
}
|
||||
|
||||
if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) {
|
||||
/* no further work necessary */
|
||||
err = fdt_move(fdt, buf, bufsize);
|
||||
if (err)
|
||||
return err;
|
||||
fdt_set_version(buf, 17);
|
||||
fdt_set_size_dt_struct(buf, struct_size);
|
||||
fdt_set_totalsize(buf, bufsize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Need to reorder */
|
||||
newsize = FDT_ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size
|
||||
+ struct_size + fdt_size_dt_strings(fdt);
|
||||
|
||||
if (bufsize < newsize)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
/* First attempt to build converted tree at beginning of buffer */
|
||||
tmp = buf;
|
||||
/* But if that overlaps with the old tree... */
|
||||
if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
|
||||
/* Try right after the old tree instead */
|
||||
tmp = (char *)(uintptr_t)fdtend;
|
||||
if ((tmp + newsize) > ((char *)buf + bufsize))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
}
|
||||
|
||||
_fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size);
|
||||
memmove(buf, tmp, newsize);
|
||||
|
||||
fdt_set_magic(buf, FDT_MAGIC);
|
||||
fdt_set_totalsize(buf, bufsize);
|
||||
fdt_set_version(buf, 17);
|
||||
fdt_set_last_comp_version(buf, 16);
|
||||
fdt_set_boot_cpuid_phys(buf, fdt_boot_cpuid_phys(fdt));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_pack(void *fdt)
|
||||
{
|
||||
int mem_rsv_size;
|
||||
|
||||
FDT_RW_CHECK_HEADER(fdt);
|
||||
|
||||
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
||||
* sizeof(struct fdt_reserve_entry);
|
||||
_fdt_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
|
||||
fdt_set_totalsize(fdt, _fdt_data_size(fdt));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,96 +1,96 @@
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
struct fdt_errtabent {
|
||||
const char *str;
|
||||
};
|
||||
|
||||
#define FDT_ERRTABENT(val) \
|
||||
[(val)] = { .str = #val, }
|
||||
|
||||
static struct fdt_errtabent fdt_errtable[] = {
|
||||
FDT_ERRTABENT(FDT_ERR_NOTFOUND),
|
||||
FDT_ERRTABENT(FDT_ERR_EXISTS),
|
||||
FDT_ERRTABENT(FDT_ERR_NOSPACE),
|
||||
|
||||
FDT_ERRTABENT(FDT_ERR_BADOFFSET),
|
||||
FDT_ERRTABENT(FDT_ERR_BADPATH),
|
||||
FDT_ERRTABENT(FDT_ERR_BADSTATE),
|
||||
|
||||
FDT_ERRTABENT(FDT_ERR_TRUNCATED),
|
||||
FDT_ERRTABENT(FDT_ERR_BADMAGIC),
|
||||
FDT_ERRTABENT(FDT_ERR_BADVERSION),
|
||||
FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
|
||||
FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
|
||||
};
|
||||
#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
|
||||
|
||||
const char *fdt_strerror(int errval)
|
||||
{
|
||||
if (errval > 0)
|
||||
return "<valid offset/length>";
|
||||
else if (errval == 0)
|
||||
return "<no error>";
|
||||
else if (errval > -FDT_ERRTABSIZE) {
|
||||
const char *s = fdt_errtable[-errval].str;
|
||||
|
||||
if (s)
|
||||
return s;
|
||||
}
|
||||
|
||||
return "<unknown error>";
|
||||
}
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
struct fdt_errtabent {
|
||||
const char *str;
|
||||
};
|
||||
|
||||
#define FDT_ERRTABENT(val) \
|
||||
[(val)] = { .str = #val, }
|
||||
|
||||
static struct fdt_errtabent fdt_errtable[] = {
|
||||
FDT_ERRTABENT(FDT_ERR_NOTFOUND),
|
||||
FDT_ERRTABENT(FDT_ERR_EXISTS),
|
||||
FDT_ERRTABENT(FDT_ERR_NOSPACE),
|
||||
|
||||
FDT_ERRTABENT(FDT_ERR_BADOFFSET),
|
||||
FDT_ERRTABENT(FDT_ERR_BADPATH),
|
||||
FDT_ERRTABENT(FDT_ERR_BADSTATE),
|
||||
|
||||
FDT_ERRTABENT(FDT_ERR_TRUNCATED),
|
||||
FDT_ERRTABENT(FDT_ERR_BADMAGIC),
|
||||
FDT_ERRTABENT(FDT_ERR_BADVERSION),
|
||||
FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
|
||||
FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
|
||||
};
|
||||
#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
|
||||
|
||||
const char *fdt_strerror(int errval)
|
||||
{
|
||||
if (errval > 0)
|
||||
return "<valid offset/length>";
|
||||
else if (errval == 0)
|
||||
return "<no error>";
|
||||
else if (errval > -FDT_ERRTABSIZE) {
|
||||
const char *s = fdt_errtable[-errval].str;
|
||||
|
||||
if (s)
|
||||
return s;
|
||||
}
|
||||
|
||||
return "<unknown error>";
|
||||
}
|
||||
|
@@ -1,256 +1,256 @@
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
static int _fdt_sw_check_header(void *fdt)
|
||||
{
|
||||
if (fdt_magic(fdt) != FDT_SW_MAGIC)
|
||||
return -FDT_ERR_BADMAGIC;
|
||||
/* FIXME: should check more details about the header state */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_SW_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = _fdt_sw_check_header(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
static void *_fdt_grab_space(void *fdt, size_t len)
|
||||
{
|
||||
int offset = fdt_size_dt_struct(fdt);
|
||||
int spaceleft;
|
||||
|
||||
spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt)
|
||||
- fdt_size_dt_strings(fdt);
|
||||
|
||||
if ((offset + len < offset) || (offset + len > spaceleft))
|
||||
return NULL;
|
||||
|
||||
fdt_set_size_dt_struct(fdt, offset + len);
|
||||
return _fdt_offset_ptr_w(fdt, offset);
|
||||
}
|
||||
|
||||
int fdt_create(void *buf, int bufsize)
|
||||
{
|
||||
void *fdt = buf;
|
||||
|
||||
if (bufsize < sizeof(struct fdt_header))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
memset(buf, 0, bufsize);
|
||||
|
||||
fdt_set_magic(fdt, FDT_SW_MAGIC);
|
||||
fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);
|
||||
fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
|
||||
fdt_set_totalsize(fdt, bufsize);
|
||||
|
||||
fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header),
|
||||
sizeof(struct fdt_reserve_entry)));
|
||||
fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));
|
||||
fdt_set_off_dt_strings(fdt, bufsize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
|
||||
{
|
||||
struct fdt_reserve_entry *re;
|
||||
int offset;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_size_dt_struct(fdt))
|
||||
return -FDT_ERR_BADSTATE;
|
||||
|
||||
offset = fdt_off_dt_struct(fdt);
|
||||
if ((offset + sizeof(*re)) > fdt_totalsize(fdt))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
re = (struct fdt_reserve_entry *)((char *)fdt + offset);
|
||||
re->address = cpu_to_fdt64(addr);
|
||||
re->size = cpu_to_fdt64(size);
|
||||
|
||||
fdt_set_off_dt_struct(fdt, offset + sizeof(*re));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_finish_reservemap(void *fdt)
|
||||
{
|
||||
return fdt_add_reservemap_entry(fdt, 0, 0);
|
||||
}
|
||||
|
||||
int fdt_begin_node(void *fdt, const char *name)
|
||||
{
|
||||
struct fdt_node_header *nh;
|
||||
int namelen = strlen(name) + 1;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
|
||||
if (! nh)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
|
||||
memcpy(nh->name, name, namelen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_end_node(void *fdt)
|
||||
{
|
||||
uint32_t *en;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
en = _fdt_grab_space(fdt, FDT_TAGSIZE);
|
||||
if (! en)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
*en = cpu_to_fdt32(FDT_END_NODE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_find_add_string(void *fdt, const char *s)
|
||||
{
|
||||
char *strtab = (char *)fdt + fdt_totalsize(fdt);
|
||||
const char *p;
|
||||
int strtabsize = fdt_size_dt_strings(fdt);
|
||||
int len = strlen(s) + 1;
|
||||
int struct_top, offset;
|
||||
|
||||
p = _fdt_find_string(strtab - strtabsize, strtabsize, s);
|
||||
if (p)
|
||||
return p - strtab;
|
||||
|
||||
/* Add it */
|
||||
offset = -strtabsize - len;
|
||||
struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
|
||||
if (fdt_totalsize(fdt) + offset < struct_top)
|
||||
return 0; /* no more room :( */
|
||||
|
||||
memcpy(strtab + offset, s, len);
|
||||
fdt_set_size_dt_strings(fdt, strtabsize + len);
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_property(void *fdt, const char *name, const void *val, int len)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int nameoff;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
nameoff = _fdt_find_add_string(fdt, name);
|
||||
if (nameoff == 0)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
|
||||
if (! prop)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
prop->tag = cpu_to_fdt32(FDT_PROP);
|
||||
prop->nameoff = cpu_to_fdt32(nameoff);
|
||||
prop->len = cpu_to_fdt32(len);
|
||||
memcpy(prop->data, val, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_finish(void *fdt)
|
||||
{
|
||||
char *p = (char *)fdt;
|
||||
uint32_t *end;
|
||||
int oldstroffset, newstroffset;
|
||||
uint32_t tag;
|
||||
int offset, nextoffset;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
/* Add terminator */
|
||||
end = _fdt_grab_space(fdt, sizeof(*end));
|
||||
if (! end)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
*end = cpu_to_fdt32(FDT_END);
|
||||
|
||||
/* Relocate the string table */
|
||||
oldstroffset = fdt_totalsize(fdt) - fdt_size_dt_strings(fdt);
|
||||
newstroffset = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
|
||||
memmove(p + newstroffset, p + oldstroffset, fdt_size_dt_strings(fdt));
|
||||
fdt_set_off_dt_strings(fdt, newstroffset);
|
||||
|
||||
/* Walk the structure, correcting string offsets */
|
||||
offset = 0;
|
||||
while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {
|
||||
if (tag == FDT_PROP) {
|
||||
struct fdt_property *prop =
|
||||
_fdt_offset_ptr_w(fdt, offset);
|
||||
int nameoff;
|
||||
|
||||
nameoff = fdt32_to_cpu(prop->nameoff);
|
||||
nameoff += fdt_size_dt_strings(fdt);
|
||||
prop->nameoff = cpu_to_fdt32(nameoff);
|
||||
}
|
||||
offset = nextoffset;
|
||||
}
|
||||
if (nextoffset < 0)
|
||||
return nextoffset;
|
||||
|
||||
/* Finally, adjust the header */
|
||||
fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));
|
||||
fdt_set_magic(fdt, FDT_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
static int _fdt_sw_check_header(void *fdt)
|
||||
{
|
||||
if (fdt_magic(fdt) != FDT_SW_MAGIC)
|
||||
return -FDT_ERR_BADMAGIC;
|
||||
/* FIXME: should check more details about the header state */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FDT_SW_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = _fdt_sw_check_header(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
static void *_fdt_grab_space(void *fdt, size_t len)
|
||||
{
|
||||
int offset = fdt_size_dt_struct(fdt);
|
||||
int spaceleft;
|
||||
|
||||
spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt)
|
||||
- fdt_size_dt_strings(fdt);
|
||||
|
||||
if ((offset + len < offset) || (offset + len > spaceleft))
|
||||
return NULL;
|
||||
|
||||
fdt_set_size_dt_struct(fdt, offset + len);
|
||||
return _fdt_offset_ptr_w(fdt, offset);
|
||||
}
|
||||
|
||||
int fdt_create(void *buf, int bufsize)
|
||||
{
|
||||
void *fdt = buf;
|
||||
|
||||
if (bufsize < sizeof(struct fdt_header))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
memset(buf, 0, bufsize);
|
||||
|
||||
fdt_set_magic(fdt, FDT_SW_MAGIC);
|
||||
fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);
|
||||
fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
|
||||
fdt_set_totalsize(fdt, bufsize);
|
||||
|
||||
fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header),
|
||||
sizeof(struct fdt_reserve_entry)));
|
||||
fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));
|
||||
fdt_set_off_dt_strings(fdt, bufsize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
|
||||
{
|
||||
struct fdt_reserve_entry *re;
|
||||
int offset;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
if (fdt_size_dt_struct(fdt))
|
||||
return -FDT_ERR_BADSTATE;
|
||||
|
||||
offset = fdt_off_dt_struct(fdt);
|
||||
if ((offset + sizeof(*re)) > fdt_totalsize(fdt))
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
re = (struct fdt_reserve_entry *)((char *)fdt + offset);
|
||||
re->address = cpu_to_fdt64(addr);
|
||||
re->size = cpu_to_fdt64(size);
|
||||
|
||||
fdt_set_off_dt_struct(fdt, offset + sizeof(*re));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_finish_reservemap(void *fdt)
|
||||
{
|
||||
return fdt_add_reservemap_entry(fdt, 0, 0);
|
||||
}
|
||||
|
||||
int fdt_begin_node(void *fdt, const char *name)
|
||||
{
|
||||
struct fdt_node_header *nh;
|
||||
int namelen = strlen(name) + 1;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
|
||||
if (! nh)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
|
||||
memcpy(nh->name, name, namelen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_end_node(void *fdt)
|
||||
{
|
||||
uint32_t *en;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
en = _fdt_grab_space(fdt, FDT_TAGSIZE);
|
||||
if (! en)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
*en = cpu_to_fdt32(FDT_END_NODE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _fdt_find_add_string(void *fdt, const char *s)
|
||||
{
|
||||
char *strtab = (char *)fdt + fdt_totalsize(fdt);
|
||||
const char *p;
|
||||
int strtabsize = fdt_size_dt_strings(fdt);
|
||||
int len = strlen(s) + 1;
|
||||
int struct_top, offset;
|
||||
|
||||
p = _fdt_find_string(strtab - strtabsize, strtabsize, s);
|
||||
if (p)
|
||||
return p - strtab;
|
||||
|
||||
/* Add it */
|
||||
offset = -strtabsize - len;
|
||||
struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
|
||||
if (fdt_totalsize(fdt) + offset < struct_top)
|
||||
return 0; /* no more room :( */
|
||||
|
||||
memcpy(strtab + offset, s, len);
|
||||
fdt_set_size_dt_strings(fdt, strtabsize + len);
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_property(void *fdt, const char *name, const void *val, int len)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int nameoff;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
nameoff = _fdt_find_add_string(fdt, name);
|
||||
if (nameoff == 0)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
|
||||
if (! prop)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
prop->tag = cpu_to_fdt32(FDT_PROP);
|
||||
prop->nameoff = cpu_to_fdt32(nameoff);
|
||||
prop->len = cpu_to_fdt32(len);
|
||||
memcpy(prop->data, val, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdt_finish(void *fdt)
|
||||
{
|
||||
char *p = (char *)fdt;
|
||||
uint32_t *end;
|
||||
int oldstroffset, newstroffset;
|
||||
uint32_t tag;
|
||||
int offset, nextoffset;
|
||||
|
||||
FDT_SW_CHECK_HEADER(fdt);
|
||||
|
||||
/* Add terminator */
|
||||
end = _fdt_grab_space(fdt, sizeof(*end));
|
||||
if (! end)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
*end = cpu_to_fdt32(FDT_END);
|
||||
|
||||
/* Relocate the string table */
|
||||
oldstroffset = fdt_totalsize(fdt) - fdt_size_dt_strings(fdt);
|
||||
newstroffset = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
|
||||
memmove(p + newstroffset, p + oldstroffset, fdt_size_dt_strings(fdt));
|
||||
fdt_set_off_dt_strings(fdt, newstroffset);
|
||||
|
||||
/* Walk the structure, correcting string offsets */
|
||||
offset = 0;
|
||||
while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {
|
||||
if (tag == FDT_PROP) {
|
||||
struct fdt_property *prop =
|
||||
_fdt_offset_ptr_w(fdt, offset);
|
||||
int nameoff;
|
||||
|
||||
nameoff = fdt32_to_cpu(prop->nameoff);
|
||||
nameoff += fdt_size_dt_strings(fdt);
|
||||
prop->nameoff = cpu_to_fdt32(nameoff);
|
||||
}
|
||||
offset = nextoffset;
|
||||
}
|
||||
if (nextoffset < 0)
|
||||
return nextoffset;
|
||||
|
||||
/* Finally, adjust the header */
|
||||
fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));
|
||||
fdt_set_magic(fdt, FDT_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,118 +1,118 @@
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
|
||||
const void *val, int len)
|
||||
{
|
||||
void *propval;
|
||||
int proplen;
|
||||
|
||||
propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
|
||||
if (! propval)
|
||||
return proplen;
|
||||
|
||||
if (proplen != len)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
memcpy(propval, val, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _fdt_nop_region(void *start, int len)
|
||||
{
|
||||
uint32_t *p;
|
||||
|
||||
for (p = start; (char *)p < ((char *)start + len); p++)
|
||||
*p = cpu_to_fdt32(FDT_NOP);
|
||||
}
|
||||
|
||||
int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int len;
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
|
||||
if (! prop)
|
||||
return len;
|
||||
|
||||
_fdt_nop_region(prop, len + sizeof(*prop));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _fdt_node_end_offset(void *fdt, int offset)
|
||||
{
|
||||
int depth = 0;
|
||||
|
||||
while ((offset >= 0) && (depth >= 0))
|
||||
offset = fdt_next_node(fdt, offset, &depth);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_nop_node(void *fdt, int nodeoffset)
|
||||
{
|
||||
int endoffset;
|
||||
|
||||
endoffset = _fdt_node_end_offset(fdt, nodeoffset);
|
||||
if (endoffset < 0)
|
||||
return endoffset;
|
||||
|
||||
_fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0),
|
||||
endoffset - nodeoffset);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "libfdt_env.h"
|
||||
|
||||
#include <fdt.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
|
||||
const void *val, int len)
|
||||
{
|
||||
void *propval;
|
||||
int proplen;
|
||||
|
||||
propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
|
||||
if (! propval)
|
||||
return proplen;
|
||||
|
||||
if (proplen != len)
|
||||
return -FDT_ERR_NOSPACE;
|
||||
|
||||
memcpy(propval, val, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _fdt_nop_region(void *start, int len)
|
||||
{
|
||||
uint32_t *p;
|
||||
|
||||
for (p = start; (char *)p < ((char *)start + len); p++)
|
||||
*p = cpu_to_fdt32(FDT_NOP);
|
||||
}
|
||||
|
||||
int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
|
||||
{
|
||||
struct fdt_property *prop;
|
||||
int len;
|
||||
|
||||
prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
|
||||
if (! prop)
|
||||
return len;
|
||||
|
||||
_fdt_nop_region(prop, len + sizeof(*prop));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _fdt_node_end_offset(void *fdt, int offset)
|
||||
{
|
||||
int depth = 0;
|
||||
|
||||
while ((offset >= 0) && (depth >= 0))
|
||||
offset = fdt_next_node(fdt, offset, &depth);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
int fdt_nop_node(void *fdt, int nodeoffset)
|
||||
{
|
||||
int endoffset;
|
||||
|
||||
endoffset = _fdt_node_end_offset(fdt, nodeoffset);
|
||||
if (endoffset < 0)
|
||||
return endoffset;
|
||||
|
||||
_fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0),
|
||||
endoffset - nodeoffset);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,95 +1,95 @@
|
||||
#ifndef _LIBFDT_INTERNAL_H
|
||||
#define _LIBFDT_INTERNAL_H
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <fdt.h>
|
||||
|
||||
#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
||||
#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
|
||||
|
||||
#define FDT_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = fdt_check_header(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
int _fdt_check_node_offset(const void *fdt, int offset);
|
||||
int _fdt_check_prop_offset(const void *fdt, int offset);
|
||||
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
|
||||
int _fdt_node_end_offset(void *fdt, int nodeoffset);
|
||||
|
||||
static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
|
||||
{
|
||||
return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
|
||||
}
|
||||
|
||||
static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
|
||||
{
|
||||
return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
|
||||
}
|
||||
|
||||
static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
|
||||
{
|
||||
const struct fdt_reserve_entry *rsv_table =
|
||||
(const struct fdt_reserve_entry *)
|
||||
((const char *)fdt + fdt_off_mem_rsvmap(fdt));
|
||||
|
||||
return rsv_table + n;
|
||||
}
|
||||
static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
|
||||
{
|
||||
return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
|
||||
}
|
||||
|
||||
#define FDT_SW_MAGIC (~FDT_MAGIC)
|
||||
|
||||
#endif /* _LIBFDT_INTERNAL_H */
|
||||
#ifndef _LIBFDT_INTERNAL_H
|
||||
#define _LIBFDT_INTERNAL_H
|
||||
/*
|
||||
* libfdt - Flat Device Tree manipulation
|
||||
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
||||
*
|
||||
* libfdt is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
*
|
||||
* a) This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* Alternatively,
|
||||
*
|
||||
* b) Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "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 COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS 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 THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <fdt.h>
|
||||
|
||||
#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
||||
#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
|
||||
|
||||
#define FDT_CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = fdt_check_header(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
int _fdt_check_node_offset(const void *fdt, int offset);
|
||||
int _fdt_check_prop_offset(const void *fdt, int offset);
|
||||
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
|
||||
int _fdt_node_end_offset(void *fdt, int nodeoffset);
|
||||
|
||||
static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
|
||||
{
|
||||
return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
|
||||
}
|
||||
|
||||
static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
|
||||
{
|
||||
return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
|
||||
}
|
||||
|
||||
static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
|
||||
{
|
||||
const struct fdt_reserve_entry *rsv_table =
|
||||
(const struct fdt_reserve_entry *)
|
||||
((const char *)fdt + fdt_off_mem_rsvmap(fdt));
|
||||
|
||||
return rsv_table + n;
|
||||
}
|
||||
static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
|
||||
{
|
||||
return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
|
||||
}
|
||||
|
||||
#define FDT_SW_MAGIC (~FDT_MAGIC)
|
||||
|
||||
#endif /* _LIBFDT_INTERNAL_H */
|
||||
|
@@ -1,258 +1,258 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Use ARMv6 instruction to operate on a single stack
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
|
||||
This is the stack constructed by the exception handler (low address to high address)
|
||||
# R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM
|
||||
Reg Offset
|
||||
=== ======
|
||||
R0 0x00 # stmfd SP!,{R0-R12}
|
||||
R1 0x04
|
||||
R2 0x08
|
||||
R3 0x0c
|
||||
R4 0x10
|
||||
R5 0x14
|
||||
R6 0x18
|
||||
R7 0x1c
|
||||
R8 0x20
|
||||
R9 0x24
|
||||
R10 0x28
|
||||
R11 0x2c
|
||||
R12 0x30
|
||||
SP 0x34 # reserved via adding 0x20 (32) to the SP
|
||||
LR 0x38
|
||||
PC 0x3c
|
||||
CPSR 0x40
|
||||
DFSR 0x44
|
||||
DFAR 0x48
|
||||
IFSR 0x4c
|
||||
IFAR 0x50
|
||||
|
||||
LR 0x54 # SVC Link register (we need to restore it)
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
*/
|
||||
|
||||
|
||||
GCC_ASM_EXPORT(ExceptionHandlersStart)
|
||||
GCC_ASM_EXPORT(ExceptionHandlersEnd)
|
||||
GCC_ASM_EXPORT(CommonExceptionEntry)
|
||||
GCC_ASM_EXPORT(AsmCommonExceptionEntry)
|
||||
GCC_ASM_EXPORT(GdbExceptionHandler)
|
||||
|
||||
.text
|
||||
.align 3
|
||||
|
||||
|
||||
//
|
||||
// This code gets copied to the ARM vector table
|
||||
// ExceptionHandlersStart - ExceptionHandlersEnd gets copied
|
||||
//
|
||||
ASM_PFX(ExceptionHandlersStart):
|
||||
|
||||
ASM_PFX(Reset):
|
||||
b ASM_PFX(Reset)
|
||||
|
||||
ASM_PFX(UndefinedInstruction):
|
||||
b ASM_PFX(UndefinedInstructionEntry)
|
||||
|
||||
ASM_PFX(SoftwareInterrupt):
|
||||
b ASM_PFX(SoftwareInterruptEntry)
|
||||
|
||||
ASM_PFX(PrefetchAbort):
|
||||
b ASM_PFX(PrefetchAbortEntry)
|
||||
|
||||
ASM_PFX(DataAbort):
|
||||
b ASM_PFX(DataAbortEntry)
|
||||
|
||||
ASM_PFX(ReservedException):
|
||||
b ASM_PFX(ReservedExceptionEntry)
|
||||
|
||||
ASM_PFX(Irq):
|
||||
b ASM_PFX(Irq)
|
||||
|
||||
ASM_PFX(Fiq):
|
||||
b ASM_PFX(FiqEntry)
|
||||
|
||||
|
||||
ASM_PFX(UndefinedInstructionEntry):
|
||||
sub LR, LR, #4 @ Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#1 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(SoftwareInterruptEntry):
|
||||
sub LR, LR, #4 @ Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f @ We are already in SVC mode
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#2 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(PrefetchAbortEntry):
|
||||
sub LR,LR,#4
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#3 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(DataAbortEntry):
|
||||
sub LR,LR,#8
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#4
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(ReservedExceptionEntry):
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#5
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(FiqEntry):
|
||||
sub LR,LR,#4
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cps #0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
@ Since we have already switch to SVC R8_fiq - R12_fiq
|
||||
@ never get used or saved
|
||||
mov R0,#7 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
//
|
||||
// This gets patched by the C code that patches in the vector table
|
||||
//
|
||||
ASM_PFX(CommonExceptionEntry):
|
||||
.byte 0x12
|
||||
.byte 0x34
|
||||
.byte 0x56
|
||||
.byte 0x78
|
||||
|
||||
ASM_PFX(ExceptionHandlersEnd):
|
||||
|
||||
//
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// CommonExceptionEntry.
|
||||
//
|
||||
ASM_PFX(AsmCommonExceptionEntry):
|
||||
mrc p15, 0, R1, c6, c0, 2 @ Read IFAR
|
||||
str R1, [SP, #0x50] @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 1 @ Read IFSR
|
||||
str R1, [SP, #0x4c] @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR
|
||||
|
||||
mrc p15, 0, R1, c6, c0, 0 @ Read DFAR
|
||||
str R1, [SP, #0x48] @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 0 @ Read DFSR
|
||||
str R1, [SP, #0x44] @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR
|
||||
|
||||
ldr R1, [SP, #0x5c] @ srsdb saved pre-exception CPSR on the stack
|
||||
str R1, [SP, #0x40] @ Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
|
||||
add R2, SP, #0x38 @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R3, R1, #0x1f @ Check CPSR to see if User or System Mode
|
||||
cmp R3, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1df))
|
||||
cmpne R3, #0x10 @
|
||||
stmeqed R2, {lr}^ @ save unbanked lr
|
||||
@ else
|
||||
stmneed R2, {lr} @ save SVC lr
|
||||
|
||||
|
||||
ldr R5, [SP, #0x58] @ PC is the LR pushed by srsfd
|
||||
@ Check to see if we have to adjust for Thumb entry
|
||||
sub r4, r0, #1 @ if (ExceptionType == 1 || ExceptionType ==2)) {
|
||||
cmp r4, #1 @ // UND & SVC have differnt LR adjust for Thumb
|
||||
bhi NoAdjustNeeded
|
||||
|
||||
tst r1, #0x20 @ if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
addne R5, R5, #2 @ PC += 2@
|
||||
str R5,[SP,#0x58] @ Update LR value pused by srsfd
|
||||
|
||||
NoAdjustNeeded:
|
||||
|
||||
str R5, [SP, #0x3c] @ Store it in EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
|
||||
sub R1, SP, #0x60 @ We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] @ Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
@ R0 is ExceptionType
|
||||
mov R1,SP @ R1 is SystemContext
|
||||
|
||||
/*
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType, R0
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext R1
|
||||
)
|
||||
|
||||
*/
|
||||
blx ASM_PFX(GdbExceptionHandler) @ Call exception handler
|
||||
|
||||
ldr R1,[SP,#0x3c] @ EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
str R1,[SP,#0x58] @ Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
ldr R1,[SP,#0x40] @ EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
str R1,[SP,#0x5c] @ Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
add R3, SP, #0x54 @ Make R3 point to SVC LR saved on entry
|
||||
add R2, SP, #0x38 @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R1, R1, #0x1f @ Check to see if User or System Mode
|
||||
cmp R1, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1f))
|
||||
cmpne R1, #0x10 @
|
||||
ldmeqed R2, {lr}^ @ restore unbanked lr
|
||||
@ else
|
||||
ldmneed R3, {lr} @ restore SVC lr, via ldmfd SP!, {LR}
|
||||
|
||||
ldmfd SP!,{R0-R12} @ Restore general purpose registers
|
||||
@ Exception handler can not change SP
|
||||
|
||||
add SP,SP,#0x20 @ Clear out the remaining stack space
|
||||
ldmfd SP!,{LR} @ restore the link register for this context
|
||||
rfefd SP! @ return from exception via srsfd stack slot
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Use ARMv6 instruction to operate on a single stack
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
|
||||
This is the stack constructed by the exception handler (low address to high address)
|
||||
# R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM
|
||||
Reg Offset
|
||||
=== ======
|
||||
R0 0x00 # stmfd SP!,{R0-R12}
|
||||
R1 0x04
|
||||
R2 0x08
|
||||
R3 0x0c
|
||||
R4 0x10
|
||||
R5 0x14
|
||||
R6 0x18
|
||||
R7 0x1c
|
||||
R8 0x20
|
||||
R9 0x24
|
||||
R10 0x28
|
||||
R11 0x2c
|
||||
R12 0x30
|
||||
SP 0x34 # reserved via adding 0x20 (32) to the SP
|
||||
LR 0x38
|
||||
PC 0x3c
|
||||
CPSR 0x40
|
||||
DFSR 0x44
|
||||
DFAR 0x48
|
||||
IFSR 0x4c
|
||||
IFAR 0x50
|
||||
|
||||
LR 0x54 # SVC Link register (we need to restore it)
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
*/
|
||||
|
||||
|
||||
GCC_ASM_EXPORT(ExceptionHandlersStart)
|
||||
GCC_ASM_EXPORT(ExceptionHandlersEnd)
|
||||
GCC_ASM_EXPORT(CommonExceptionEntry)
|
||||
GCC_ASM_EXPORT(AsmCommonExceptionEntry)
|
||||
GCC_ASM_EXPORT(GdbExceptionHandler)
|
||||
|
||||
.text
|
||||
.align 3
|
||||
|
||||
|
||||
//
|
||||
// This code gets copied to the ARM vector table
|
||||
// ExceptionHandlersStart - ExceptionHandlersEnd gets copied
|
||||
//
|
||||
ASM_PFX(ExceptionHandlersStart):
|
||||
|
||||
ASM_PFX(Reset):
|
||||
b ASM_PFX(Reset)
|
||||
|
||||
ASM_PFX(UndefinedInstruction):
|
||||
b ASM_PFX(UndefinedInstructionEntry)
|
||||
|
||||
ASM_PFX(SoftwareInterrupt):
|
||||
b ASM_PFX(SoftwareInterruptEntry)
|
||||
|
||||
ASM_PFX(PrefetchAbort):
|
||||
b ASM_PFX(PrefetchAbortEntry)
|
||||
|
||||
ASM_PFX(DataAbort):
|
||||
b ASM_PFX(DataAbortEntry)
|
||||
|
||||
ASM_PFX(ReservedException):
|
||||
b ASM_PFX(ReservedExceptionEntry)
|
||||
|
||||
ASM_PFX(Irq):
|
||||
b ASM_PFX(Irq)
|
||||
|
||||
ASM_PFX(Fiq):
|
||||
b ASM_PFX(FiqEntry)
|
||||
|
||||
|
||||
ASM_PFX(UndefinedInstructionEntry):
|
||||
sub LR, LR, #4 @ Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#1 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(SoftwareInterruptEntry):
|
||||
sub LR, LR, #4 @ Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f @ We are already in SVC mode
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#2 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(PrefetchAbortEntry):
|
||||
sub LR,LR,#4
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#3 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(DataAbortEntry):
|
||||
sub LR,LR,#8
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#4
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(ReservedExceptionEntry):
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cpsid f,#0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
|
||||
mov R0,#5
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
ASM_PFX(FiqEntry):
|
||||
sub LR,LR,#4
|
||||
srsdb #0x13! @ Store return state on SVC stack
|
||||
cps #0x13 @ Switch to SVC for common stack
|
||||
stmfd SP!,{LR} @ Store the link register for the current mode
|
||||
sub SP,SP,#0x20 @ Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} @ Store the register state
|
||||
@ Since we have already switch to SVC R8_fiq - R12_fiq
|
||||
@ never get used or saved
|
||||
mov R0,#7 @ ExceptionType
|
||||
ldr R1,ASM_PFX(CommonExceptionEntry)
|
||||
bx R1
|
||||
|
||||
//
|
||||
// This gets patched by the C code that patches in the vector table
|
||||
//
|
||||
ASM_PFX(CommonExceptionEntry):
|
||||
.byte 0x12
|
||||
.byte 0x34
|
||||
.byte 0x56
|
||||
.byte 0x78
|
||||
|
||||
ASM_PFX(ExceptionHandlersEnd):
|
||||
|
||||
//
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// CommonExceptionEntry.
|
||||
//
|
||||
ASM_PFX(AsmCommonExceptionEntry):
|
||||
mrc p15, 0, R1, c6, c0, 2 @ Read IFAR
|
||||
str R1, [SP, #0x50] @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 1 @ Read IFSR
|
||||
str R1, [SP, #0x4c] @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR
|
||||
|
||||
mrc p15, 0, R1, c6, c0, 0 @ Read DFAR
|
||||
str R1, [SP, #0x48] @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 0 @ Read DFSR
|
||||
str R1, [SP, #0x44] @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR
|
||||
|
||||
ldr R1, [SP, #0x5c] @ srsdb saved pre-exception CPSR on the stack
|
||||
str R1, [SP, #0x40] @ Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
|
||||
add R2, SP, #0x38 @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R3, R1, #0x1f @ Check CPSR to see if User or System Mode
|
||||
cmp R3, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1df))
|
||||
cmpne R3, #0x10 @
|
||||
stmeqed R2, {lr}^ @ save unbanked lr
|
||||
@ else
|
||||
stmneed R2, {lr} @ save SVC lr
|
||||
|
||||
|
||||
ldr R5, [SP, #0x58] @ PC is the LR pushed by srsfd
|
||||
@ Check to see if we have to adjust for Thumb entry
|
||||
sub r4, r0, #1 @ if (ExceptionType == 1 || ExceptionType ==2)) {
|
||||
cmp r4, #1 @ // UND & SVC have differnt LR adjust for Thumb
|
||||
bhi NoAdjustNeeded
|
||||
|
||||
tst r1, #0x20 @ if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
addne R5, R5, #2 @ PC += 2@
|
||||
str R5,[SP,#0x58] @ Update LR value pused by srsfd
|
||||
|
||||
NoAdjustNeeded:
|
||||
|
||||
str R5, [SP, #0x3c] @ Store it in EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
|
||||
sub R1, SP, #0x60 @ We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] @ Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
@ R0 is ExceptionType
|
||||
mov R1,SP @ R1 is SystemContext
|
||||
|
||||
/*
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType, R0
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext R1
|
||||
)
|
||||
|
||||
*/
|
||||
blx ASM_PFX(GdbExceptionHandler) @ Call exception handler
|
||||
|
||||
ldr R1,[SP,#0x3c] @ EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
str R1,[SP,#0x58] @ Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
ldr R1,[SP,#0x40] @ EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
str R1,[SP,#0x5c] @ Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
add R3, SP, #0x54 @ Make R3 point to SVC LR saved on entry
|
||||
add R2, SP, #0x38 @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R1, R1, #0x1f @ Check to see if User or System Mode
|
||||
cmp R1, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1f))
|
||||
cmpne R1, #0x10 @
|
||||
ldmeqed R2, {lr}^ @ restore unbanked lr
|
||||
@ else
|
||||
ldmneed R3, {lr} @ restore SVC lr, via ldmfd SP!, {LR}
|
||||
|
||||
ldmfd SP!,{R0-R12} @ Restore general purpose registers
|
||||
@ Exception handler can not change SP
|
||||
|
||||
add SP,SP,#0x20 @ Clear out the remaining stack space
|
||||
ldmfd SP!,{LR} @ restore the link register for this context
|
||||
rfefd SP! @ return from exception via srsfd stack slot
|
||||
|
||||
|
@@ -1,259 +1,259 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Use ARMv6 instruction to operate on a single stack
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
This is the stack constructed by the exception handler (low address to high address)
|
||||
# R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM
|
||||
Reg Offset
|
||||
=== ======
|
||||
R0 0x00 # stmfd SP!,{R0-R12}
|
||||
R1 0x04
|
||||
R2 0x08
|
||||
R3 0x0c
|
||||
R4 0x10
|
||||
R5 0x14
|
||||
R6 0x18
|
||||
R7 0x1c
|
||||
R8 0x20
|
||||
R9 0x24
|
||||
R10 0x28
|
||||
R11 0x2c
|
||||
R12 0x30
|
||||
SP 0x34 # reserved via adding 0x20 (32) to the SP
|
||||
LR 0x38
|
||||
PC 0x3c
|
||||
CPSR 0x40
|
||||
DFSR 0x44
|
||||
DFAR 0x48
|
||||
IFSR 0x4c
|
||||
IFAR 0x50
|
||||
|
||||
LR 0x54 # SVC Link register (we need to restore it)
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
*/
|
||||
|
||||
|
||||
EXPORT ExceptionHandlersStart
|
||||
EXPORT ExceptionHandlersEnd
|
||||
EXPORT CommonExceptionEntry
|
||||
EXPORT AsmCommonExceptionEntry
|
||||
IMPORT GdbExceptionHandler
|
||||
|
||||
PRESERVE8
|
||||
AREA DxeExceptionHandlers, CODE, READONLY
|
||||
|
||||
//
|
||||
// This code gets copied to the ARM vector table
|
||||
// ExceptionHandlersStart - ExceptionHandlersEnd gets copied
|
||||
//
|
||||
ExceptionHandlersStart
|
||||
|
||||
Reset
|
||||
b Reset
|
||||
|
||||
UndefinedInstruction
|
||||
b UndefinedInstructionEntry
|
||||
|
||||
SoftwareInterrupt
|
||||
b SoftwareInterruptEntry
|
||||
|
||||
PrefetchAbort
|
||||
b PrefetchAbortEntry
|
||||
|
||||
DataAbort
|
||||
b DataAbortEntry
|
||||
|
||||
ReservedException
|
||||
b ReservedExceptionEntry
|
||||
|
||||
Irq
|
||||
b Irq
|
||||
|
||||
Fiq
|
||||
b FiqEntry
|
||||
|
||||
|
||||
UndefinedInstructionEntry
|
||||
sub LR, LR, #4 ; Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#1 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry;
|
||||
bx R1
|
||||
|
||||
SoftwareInterruptEntry
|
||||
sub LR, LR, #4 ; Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f ; We are already in SVC mode
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#2 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
PrefetchAbortEntry
|
||||
sub LR,LR,#4
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#3 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
DataAbortEntry
|
||||
sub LR,LR,#8
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#4 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
ReservedExceptionEntry
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#5 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
FiqEntry
|
||||
sub LR,LR,#4
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cps #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
; Since we have already switch to SVC R8_fiq - R12_fiq
|
||||
; never get used or saved
|
||||
mov R0,#7 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
//
|
||||
// This gets patched by the C code that patches in the vector table
|
||||
//
|
||||
CommonExceptionEntry
|
||||
dcd 0x12345678
|
||||
|
||||
ExceptionHandlersEnd
|
||||
|
||||
//
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// CommonExceptionEntry.
|
||||
//
|
||||
AsmCommonExceptionEntry
|
||||
mrc p15, 0, R1, c6, c0, 2 ; Read IFAR
|
||||
str R1, [SP, #0x50] ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 1 ; Read IFSR
|
||||
str R1, [SP, #0x4c] ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR
|
||||
|
||||
mrc p15, 0, R1, c6, c0, 0 ; Read DFAR
|
||||
str R1, [SP, #0x48] ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 0 ; Read DFSR
|
||||
str R1, [SP, #0x44] ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR
|
||||
|
||||
ldr R1, [SP, #0x5c] ; srsfd saved pre-exception CPSR on the stack
|
||||
str R1, [SP, #0x40] ; Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
|
||||
add R2, SP, #0x38 ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R3, R1, #0x1f ; Check CPSR to see if User or System Mode
|
||||
cmp R3, #0x1f ; if ((CPSR == 0x10) || (CPSR == 0x1df))
|
||||
cmpne R3, #0x10 ;
|
||||
stmeqed R2, {lr}^ ; save unbanked lr
|
||||
; else
|
||||
stmneed R2, {lr} ; save SVC lr
|
||||
|
||||
|
||||
ldr R5, [SP, #0x58] ; PC is the LR pushed by srsfd
|
||||
; Check to see if we have to adjust for Thumb entry
|
||||
sub r4, r0, #1 ; if (ExceptionType == 1 || ExceptionType ==2)) {
|
||||
cmp r4, #1 ; // UND & SVC have differnt LR adjust for Thumb
|
||||
bhi NoAdjustNeeded
|
||||
|
||||
tst r1, #0x20 ; if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
addne R5, R5, #2 ; PC += 2;
|
||||
str R5,[SP,#0x58] ; Update LR value pused by srsfd
|
||||
|
||||
NoAdjustNeeded
|
||||
|
||||
str R5, [SP, #0x3c] ; Store it in EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
|
||||
sub R1, SP, #0x60 ; We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] ; Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
; R0 is ExceptionType
|
||||
mov R1,SP ; R1 is SystemContext
|
||||
|
||||
/*
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType, R0
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext R1
|
||||
)
|
||||
|
||||
*/
|
||||
blx GdbExceptionHandler ; Call exception handler
|
||||
|
||||
ldr R1,[SP,#0x3c] ; EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
str R1,[SP,#0x58] ; Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
ldr R1,[SP,#0x40] ; EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
str R1,[SP,#0x5c] ; Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
add R3, SP, #0x54 ; Make R3 point to SVC LR saved on entry
|
||||
add R2, SP, #0x38 ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R1, R1, #0x1f ; Check to see if User or System Mode
|
||||
cmp R1, #0x1f ; if ((CPSR == 0x10) || (CPSR == 0x1f))
|
||||
cmpne R1, #0x10 ;
|
||||
ldmeqed R2, {lr}^ ; restore unbanked lr
|
||||
; else
|
||||
ldmneed R3, {lr} ; restore SVC lr, via ldmfd SP!, {LR}
|
||||
|
||||
ldmfd SP!,{R0-R12} ; Restore general purpose registers
|
||||
; Exception handler can not change SP
|
||||
|
||||
add SP,SP,#0x20 ; Clear out the remaining stack space
|
||||
ldmfd SP!,{LR} ; restore the link register for this context
|
||||
rfefd SP! ; return from exception via srsfd stack slot
|
||||
|
||||
END
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Use ARMv6 instruction to operate on a single stack
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
This is the stack constructed by the exception handler (low address to high address)
|
||||
# R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM
|
||||
Reg Offset
|
||||
=== ======
|
||||
R0 0x00 # stmfd SP!,{R0-R12}
|
||||
R1 0x04
|
||||
R2 0x08
|
||||
R3 0x0c
|
||||
R4 0x10
|
||||
R5 0x14
|
||||
R6 0x18
|
||||
R7 0x1c
|
||||
R8 0x20
|
||||
R9 0x24
|
||||
R10 0x28
|
||||
R11 0x2c
|
||||
R12 0x30
|
||||
SP 0x34 # reserved via adding 0x20 (32) to the SP
|
||||
LR 0x38
|
||||
PC 0x3c
|
||||
CPSR 0x40
|
||||
DFSR 0x44
|
||||
DFAR 0x48
|
||||
IFSR 0x4c
|
||||
IFAR 0x50
|
||||
|
||||
LR 0x54 # SVC Link register (we need to restore it)
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
*/
|
||||
|
||||
|
||||
EXPORT ExceptionHandlersStart
|
||||
EXPORT ExceptionHandlersEnd
|
||||
EXPORT CommonExceptionEntry
|
||||
EXPORT AsmCommonExceptionEntry
|
||||
IMPORT GdbExceptionHandler
|
||||
|
||||
PRESERVE8
|
||||
AREA DxeExceptionHandlers, CODE, READONLY
|
||||
|
||||
//
|
||||
// This code gets copied to the ARM vector table
|
||||
// ExceptionHandlersStart - ExceptionHandlersEnd gets copied
|
||||
//
|
||||
ExceptionHandlersStart
|
||||
|
||||
Reset
|
||||
b Reset
|
||||
|
||||
UndefinedInstruction
|
||||
b UndefinedInstructionEntry
|
||||
|
||||
SoftwareInterrupt
|
||||
b SoftwareInterruptEntry
|
||||
|
||||
PrefetchAbort
|
||||
b PrefetchAbortEntry
|
||||
|
||||
DataAbort
|
||||
b DataAbortEntry
|
||||
|
||||
ReservedException
|
||||
b ReservedExceptionEntry
|
||||
|
||||
Irq
|
||||
b Irq
|
||||
|
||||
Fiq
|
||||
b FiqEntry
|
||||
|
||||
|
||||
UndefinedInstructionEntry
|
||||
sub LR, LR, #4 ; Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#1 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry;
|
||||
bx R1
|
||||
|
||||
SoftwareInterruptEntry
|
||||
sub LR, LR, #4 ; Only -2 for Thumb, adjust in CommonExceptionEntry
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f ; We are already in SVC mode
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#2 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
PrefetchAbortEntry
|
||||
sub LR,LR,#4
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#3 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
DataAbortEntry
|
||||
sub LR,LR,#8
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#4 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
ReservedExceptionEntry
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cpsid f, #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#5 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
FiqEntry
|
||||
sub LR,LR,#4
|
||||
srsfd #0x13! ; Store return state on SVC stack
|
||||
cps #0x13 ; Switch to SVC for common stack
|
||||
stmfd SP!,{LR} ; Store the link register for the current mode
|
||||
sub SP,SP,#0x20 ; Save space for SP, LR, PC, IFAR - CPSR
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
; Since we have already switch to SVC R8_fiq - R12_fiq
|
||||
; never get used or saved
|
||||
mov R0,#7 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry
|
||||
bx R1
|
||||
|
||||
//
|
||||
// This gets patched by the C code that patches in the vector table
|
||||
//
|
||||
CommonExceptionEntry
|
||||
dcd 0x12345678
|
||||
|
||||
ExceptionHandlersEnd
|
||||
|
||||
//
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// CommonExceptionEntry.
|
||||
//
|
||||
AsmCommonExceptionEntry
|
||||
mrc p15, 0, R1, c6, c0, 2 ; Read IFAR
|
||||
str R1, [SP, #0x50] ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 1 ; Read IFSR
|
||||
str R1, [SP, #0x4c] ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR
|
||||
|
||||
mrc p15, 0, R1, c6, c0, 0 ; Read DFAR
|
||||
str R1, [SP, #0x48] ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 0 ; Read DFSR
|
||||
str R1, [SP, #0x44] ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR
|
||||
|
||||
ldr R1, [SP, #0x5c] ; srsfd saved pre-exception CPSR on the stack
|
||||
str R1, [SP, #0x40] ; Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
|
||||
add R2, SP, #0x38 ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R3, R1, #0x1f ; Check CPSR to see if User or System Mode
|
||||
cmp R3, #0x1f ; if ((CPSR == 0x10) || (CPSR == 0x1df))
|
||||
cmpne R3, #0x10 ;
|
||||
stmeqed R2, {lr}^ ; save unbanked lr
|
||||
; else
|
||||
stmneed R2, {lr} ; save SVC lr
|
||||
|
||||
|
||||
ldr R5, [SP, #0x58] ; PC is the LR pushed by srsfd
|
||||
; Check to see if we have to adjust for Thumb entry
|
||||
sub r4, r0, #1 ; if (ExceptionType == 1 || ExceptionType ==2)) {
|
||||
cmp r4, #1 ; // UND & SVC have differnt LR adjust for Thumb
|
||||
bhi NoAdjustNeeded
|
||||
|
||||
tst r1, #0x20 ; if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
addne R5, R5, #2 ; PC += 2;
|
||||
str R5,[SP,#0x58] ; Update LR value pused by srsfd
|
||||
|
||||
NoAdjustNeeded
|
||||
|
||||
str R5, [SP, #0x3c] ; Store it in EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
|
||||
sub R1, SP, #0x60 ; We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] ; Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
; R0 is ExceptionType
|
||||
mov R1,SP ; R1 is SystemContext
|
||||
|
||||
/*
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType, R0
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext R1
|
||||
)
|
||||
|
||||
*/
|
||||
blx GdbExceptionHandler ; Call exception handler
|
||||
|
||||
ldr R1,[SP,#0x3c] ; EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
str R1,[SP,#0x58] ; Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
ldr R1,[SP,#0x40] ; EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
str R1,[SP,#0x5c] ; Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
add R3, SP, #0x54 ; Make R3 point to SVC LR saved on entry
|
||||
add R2, SP, #0x38 ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R1, R1, #0x1f ; Check to see if User or System Mode
|
||||
cmp R1, #0x1f ; if ((CPSR == 0x10) || (CPSR == 0x1f))
|
||||
cmpne R1, #0x10 ;
|
||||
ldmeqed R2, {lr}^ ; restore unbanked lr
|
||||
; else
|
||||
ldmneed R3, {lr} ; restore SVC lr, via ldmfd SP!, {LR}
|
||||
|
||||
ldmfd SP!,{R0-R12} ; Restore general purpose registers
|
||||
; Exception handler can not change SP
|
||||
|
||||
add SP,SP,#0x20 ; Clear out the remaining stack space
|
||||
ldmfd SP!,{LR} ; restore the link register for this context
|
||||
rfefd SP! ; return from exception via srsfd stack slot
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
@@ -447,23 +447,23 @@ RemoveBreakPoint (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send the T signal with the given exception type (in gdb order) and possibly
|
||||
with n:r pairs related to the watchpoints
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param GdbExceptionType GDB exception type
|
||||
**/
|
||||
VOID
|
||||
ProcessorSendTSignal (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINT8 GdbExceptionType,
|
||||
IN OUT CHAR8 *TSignalPtr,
|
||||
IN UINTN SizeOfBuffer
|
||||
)
|
||||
{
|
||||
*TSignalPtr = '\0';
|
||||
}
|
||||
/**
|
||||
Send the T signal with the given exception type (in gdb order) and possibly
|
||||
with n:r pairs related to the watchpoints
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param GdbExceptionType GDB exception type
|
||||
**/
|
||||
VOID
|
||||
ProcessorSendTSignal (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINT8 GdbExceptionType,
|
||||
IN OUT CHAR8 *TSignalPtr,
|
||||
IN UINTN SizeOfBuffer
|
||||
)
|
||||
{
|
||||
*TSignalPtr = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
FIQ state is only changed by FIQ exception. We don't want to take FIQ
|
||||
@@ -475,21 +475,21 @@ ProcessorSendTSignal (
|
||||
|
||||
@return TRUE We are in the GDB stub exception preamble
|
||||
@return FALSE We are not in GDB stub code
|
||||
**/
|
||||
BOOLEAN
|
||||
InFiqCrack (
|
||||
IN UINT32 PC
|
||||
)
|
||||
{
|
||||
UINT32 VectorBase = PcdGet32 (PcdCpuVectorBaseAddress);
|
||||
UINT32 Length = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart;
|
||||
|
||||
if ((PC >= VectorBase) && (PC <= (VectorBase + Length))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
**/
|
||||
BOOLEAN
|
||||
InFiqCrack (
|
||||
IN UINT32 PC
|
||||
)
|
||||
{
|
||||
UINT32 VectorBase = PcdGet32 (PcdCpuVectorBaseAddress);
|
||||
UINT32 Length = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart;
|
||||
|
||||
if ((PC >= VectorBase) && (PC <= (VectorBase + Length))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -526,24 +526,24 @@ ProcessorControlC (
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
if (!GdbIsCharAvailable ()) {
|
||||
//
|
||||
// No characters are pending so exit the loop
|
||||
//
|
||||
Return = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
Char = GdbGetChar ();
|
||||
if (Char == 0x03) {
|
||||
//
|
||||
// We have a ctrl-c so exit and process exception for ctrl-c
|
||||
//
|
||||
Return = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (TRUE) {
|
||||
if (!GdbIsCharAvailable ()) {
|
||||
//
|
||||
// No characters are pending so exit the loop
|
||||
//
|
||||
Return = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
Char = GdbGetChar ();
|
||||
if (Char == 0x03) {
|
||||
//
|
||||
// We have a ctrl-c so exit and process exception for ctrl-c
|
||||
//
|
||||
Return = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DebugAgentTimerEndOfInterrupt ();
|
||||
|
||||
@@ -622,13 +622,13 @@ InitializeDebugAgent (
|
||||
IN VOID *Context, OPTIONAL
|
||||
IN DEBUG_AGENT_CONTINUE Function OPTIONAL
|
||||
)
|
||||
{
|
||||
{
|
||||
UINTN Offset;
|
||||
UINTN Length;
|
||||
BOOLEAN IrqEnabled;
|
||||
UINT32 *VectorBase;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Disable interrupts
|
||||
//
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -38,4 +38,4 @@
|
||||
[Pcd]
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
TRUE
|
File diff suppressed because it is too large
Load Diff
@@ -17,11 +17,11 @@
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
//
|
||||
// Have to use build system to set the original value in case we are running
|
||||
// from FLASH and globals don't work. So if you do a GetHobList() and gHobList
|
||||
// and gHobList is NULL the PCD default values are used.
|
||||
//
|
||||
//
|
||||
// Have to use build system to set the original value in case we are running
|
||||
// from FLASH and globals don't work. So if you do a GetHobList() and gHobList
|
||||
// and gHobList is NULL the PCD default values are used.
|
||||
//
|
||||
VOID *gHobList = NULL;
|
||||
|
||||
|
||||
|
@@ -36,4 +36,4 @@
|
||||
|
||||
[FixedPcd.common]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiHobBase
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,46 +1,46 @@
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI (i.e. PEI part of SEC)
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PI_PEI_H_
|
||||
#define _PI_PEI_H_
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PrePiLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiDecompressLib.h>
|
||||
#include <Library/PeCoffLib.h>
|
||||
#include <Library/CacheMaintenanceLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
|
||||
#include <Guid/MemoryAllocationHob.h>
|
||||
|
||||
|
||||
#define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
|
||||
#define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
|
||||
#define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
|
||||
#define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_END_OF_HOB_LIST)
|
||||
|
||||
//
|
||||
// Get the data and data size field of GUID
|
||||
//
|
||||
#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
|
||||
#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
|
||||
|
||||
#endif
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI (i.e. PEI part of SEC)
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PI_PEI_H_
|
||||
#define _PI_PEI_H_
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PrePiLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiDecompressLib.h>
|
||||
#include <Library/PeCoffLib.h>
|
||||
#include <Library/CacheMaintenanceLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
|
||||
#include <Guid/MemoryAllocationHob.h>
|
||||
|
||||
|
||||
#define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
|
||||
#define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
|
||||
#define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
|
||||
#define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_END_OF_HOB_LIST)
|
||||
|
||||
//
|
||||
// Get the data and data size field of GUID
|
||||
//
|
||||
#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
|
||||
#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
|
||||
|
||||
#endif
|
||||
|
@@ -1,226 +1,226 @@
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
|
||||
//
|
||||
// Hack to work in NT32
|
||||
//
|
||||
EFI_STATUS
|
||||
|
||||
EFIAPI
|
||||
|
||||
SecWinNtPeiLoadFile (
|
||||
IN VOID *Pe32Data,
|
||||
IN EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
IN UINT64 *ImageSize,
|
||||
IN EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadPeCoffImage (
|
||||
IN VOID *PeCoffImage,
|
||||
OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
OUT UINT64 *ImageSize,
|
||||
OUT EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
||||
VOID *Buffer;
|
||||
|
||||
ZeroMem (&ImageContext, sizeof (ImageContext));
|
||||
|
||||
ImageContext.Handle = PeCoffImage;
|
||||
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
||||
|
||||
Status = PeCoffLoaderGetImageInfo (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
//
|
||||
// Allocate Memory for the image
|
||||
//
|
||||
Buffer = AllocatePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));
|
||||
ASSERT (Buffer != 0);
|
||||
|
||||
|
||||
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
|
||||
|
||||
//
|
||||
// Load the image to our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Relocate the image in our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
*ImageAddress = ImageContext.ImageAddress;
|
||||
*ImageSize = ImageContext.ImageSize;
|
||||
*EntryPoint = ImageContext.EntryPoint;
|
||||
|
||||
//
|
||||
// Flush not needed for all architectures. We could have a processor specific
|
||||
// function in this library that does the no-op if needed.
|
||||
//
|
||||
InvalidateInstructionCacheRange ((VOID *)(UINTN)*ImageAddress, (UINTN)*ImageSize);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *DXE_CORE_ENTRY_POINT) (
|
||||
IN VOID *HobStart
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFfsFile (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *PeCoffImage;
|
||||
EFI_PHYSICAL_ADDRESS ImageAddress;
|
||||
UINT64 ImageSize;
|
||||
EFI_PHYSICAL_ADDRESS EntryPoint;
|
||||
VOID *BaseOfStack;
|
||||
VOID *TopOfStack;
|
||||
VOID *Hob;
|
||||
EFI_FV_FILE_INFO FvFileInfo;
|
||||
|
||||
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
// For NT32 Debug Status = SecWinNtPeiLoadFile (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Extract the DxeCore GUID file name.
|
||||
//
|
||||
Status = FfsGetFileInfo (FileHandle, &FvFileInfo);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
BuildModuleHob (&FvFileInfo.FileName, (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, EntryPoint);
|
||||
|
||||
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DxeCore at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)EntryPoint));
|
||||
|
||||
Hob = GetHobList ();
|
||||
if (StackSize == 0) {
|
||||
// User the current stack
|
||||
|
||||
((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob);
|
||||
} else {
|
||||
|
||||
//
|
||||
// Allocate 128KB for the Stack
|
||||
//
|
||||
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (StackSize));
|
||||
ASSERT (BaseOfStack != NULL);
|
||||
|
||||
//
|
||||
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||
// for safety.
|
||||
//
|
||||
TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (StackSize) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||
|
||||
//
|
||||
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
|
||||
//
|
||||
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, StackSize);
|
||||
|
||||
SwitchStack (
|
||||
(SWITCH_STACK_ENTRY_POINT)(UINTN)EntryPoint,
|
||||
Hob,
|
||||
NULL,
|
||||
TopOfStack
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Should never get here as DXE Core does not return
|
||||
DEBUG ((EFI_D_ERROR, "DxeCore returned\n"));
|
||||
ASSERT (FALSE);
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFv (
|
||||
IN UINTN *FvInstance, OPTIONAL
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle = NULL;
|
||||
|
||||
if (FvInstance != NULL) {
|
||||
//
|
||||
// Caller passed in a specific FV to try, so only try that one
|
||||
//
|
||||
Status = FfsFindNextVolume (*FvInstance, &VolumeHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle);
|
||||
}
|
||||
} else {
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_DXE_CORE, &VolumeHandle, &FileHandle);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return LoadDxeCoreFromFfsFile (FileHandle, StackSize);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DecompressFirstFv (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle;
|
||||
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, &VolumeHandle, &FileHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsProcessFvFile (FileHandle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/** @file
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
|
||||
//
|
||||
// Hack to work in NT32
|
||||
//
|
||||
EFI_STATUS
|
||||
|
||||
EFIAPI
|
||||
|
||||
SecWinNtPeiLoadFile (
|
||||
IN VOID *Pe32Data,
|
||||
IN EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
IN UINT64 *ImageSize,
|
||||
IN EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadPeCoffImage (
|
||||
IN VOID *PeCoffImage,
|
||||
OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
OUT UINT64 *ImageSize,
|
||||
OUT EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
||||
VOID *Buffer;
|
||||
|
||||
ZeroMem (&ImageContext, sizeof (ImageContext));
|
||||
|
||||
ImageContext.Handle = PeCoffImage;
|
||||
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
||||
|
||||
Status = PeCoffLoaderGetImageInfo (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
//
|
||||
// Allocate Memory for the image
|
||||
//
|
||||
Buffer = AllocatePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));
|
||||
ASSERT (Buffer != 0);
|
||||
|
||||
|
||||
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
|
||||
|
||||
//
|
||||
// Load the image to our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Relocate the image in our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
*ImageAddress = ImageContext.ImageAddress;
|
||||
*ImageSize = ImageContext.ImageSize;
|
||||
*EntryPoint = ImageContext.EntryPoint;
|
||||
|
||||
//
|
||||
// Flush not needed for all architectures. We could have a processor specific
|
||||
// function in this library that does the no-op if needed.
|
||||
//
|
||||
InvalidateInstructionCacheRange ((VOID *)(UINTN)*ImageAddress, (UINTN)*ImageSize);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *DXE_CORE_ENTRY_POINT) (
|
||||
IN VOID *HobStart
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFfsFile (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *PeCoffImage;
|
||||
EFI_PHYSICAL_ADDRESS ImageAddress;
|
||||
UINT64 ImageSize;
|
||||
EFI_PHYSICAL_ADDRESS EntryPoint;
|
||||
VOID *BaseOfStack;
|
||||
VOID *TopOfStack;
|
||||
VOID *Hob;
|
||||
EFI_FV_FILE_INFO FvFileInfo;
|
||||
|
||||
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
// For NT32 Debug Status = SecWinNtPeiLoadFile (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Extract the DxeCore GUID file name.
|
||||
//
|
||||
Status = FfsGetFileInfo (FileHandle, &FvFileInfo);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
BuildModuleHob (&FvFileInfo.FileName, (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, EntryPoint);
|
||||
|
||||
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DxeCore at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)EntryPoint));
|
||||
|
||||
Hob = GetHobList ();
|
||||
if (StackSize == 0) {
|
||||
// User the current stack
|
||||
|
||||
((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob);
|
||||
} else {
|
||||
|
||||
//
|
||||
// Allocate 128KB for the Stack
|
||||
//
|
||||
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (StackSize));
|
||||
ASSERT (BaseOfStack != NULL);
|
||||
|
||||
//
|
||||
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||
// for safety.
|
||||
//
|
||||
TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (StackSize) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||
|
||||
//
|
||||
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
|
||||
//
|
||||
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, StackSize);
|
||||
|
||||
SwitchStack (
|
||||
(SWITCH_STACK_ENTRY_POINT)(UINTN)EntryPoint,
|
||||
Hob,
|
||||
NULL,
|
||||
TopOfStack
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Should never get here as DXE Core does not return
|
||||
DEBUG ((EFI_D_ERROR, "DxeCore returned\n"));
|
||||
ASSERT (FALSE);
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFv (
|
||||
IN UINTN *FvInstance, OPTIONAL
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle = NULL;
|
||||
|
||||
if (FvInstance != NULL) {
|
||||
//
|
||||
// Caller passed in a specific FV to try, so only try that one
|
||||
//
|
||||
Status = FfsFindNextVolume (*FvInstance, &VolumeHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle);
|
||||
}
|
||||
} else {
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_DXE_CORE, &VolumeHandle, &FileHandle);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return LoadDxeCoreFromFfsFile (FileHandle, StackSize);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DecompressFirstFv (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle;
|
||||
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, &VolumeHandle, &FileHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsProcessFvFile (FileHandle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,327 +1,327 @@
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
#include <Protocol/StatusCode.h>
|
||||
#include <Guid/StatusCodeDataTypeId.h>
|
||||
#include <Guid/StatusCodeDataTypeDebug.h>
|
||||
#include <FrameworkPei.h>
|
||||
|
||||
#define EFI_STATUS_CODE_DATA_MAX_SIZE 200
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS_CODE_PROTOCOL gStatusCode = {
|
||||
(EFI_REPORT_STATUS_CODE)SerialReportStatusCode
|
||||
};
|
||||
|
||||
/**
|
||||
Extracts ASSERT() information from a status code structure.
|
||||
|
||||
Converts the status code specified by CodeType, Value, and Data to the ASSERT()
|
||||
arguments specified by Filename, Description, and LineNumber. If CodeType is
|
||||
an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
|
||||
Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
|
||||
Filename, Description, and LineNumber from the optional data area of the
|
||||
status code buffer specified by Data. The optional data area of Data contains
|
||||
a Null-terminated ASCII string for the FileName, followed by a Null-terminated
|
||||
ASCII string for the Description, followed by a 32-bit LineNumber. If the
|
||||
ASSERT() information could be extracted from Data, then return TRUE.
|
||||
Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If Filename is NULL, then ASSERT().
|
||||
If Description is NULL, then ASSERT().
|
||||
If LineNumber is NULL, then ASSERT().
|
||||
|
||||
@param CodeType The type of status code being converted.
|
||||
@param Value The status code value being converted.
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param Filename Pointer to the source file name that generated the ASSERT().
|
||||
@param Description Pointer to the description of the ASSERT().
|
||||
@param LineNumber Pointer to source line number that generated the ASSERT().
|
||||
|
||||
@retval TRUE The status code specified by CodeType, Value, and Data was
|
||||
converted ASSERT() arguments specified by Filename, Description,
|
||||
and LineNumber.
|
||||
@retval FALSE The status code specified by CodeType, Value, and Data could
|
||||
not be converted to ASSERT() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractAssertInfo (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT CHAR8 **Filename,
|
||||
OUT CHAR8 **Description,
|
||||
OUT UINT32 *LineNumber
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_ASSERT_DATA *AssertData;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (Filename != NULL);
|
||||
ASSERT (Description != NULL);
|
||||
ASSERT (LineNumber != NULL);
|
||||
|
||||
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
|
||||
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
|
||||
((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
|
||||
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
|
||||
*Filename = (CHAR8 *)(AssertData + 1);
|
||||
*Description = *Filename + AsciiStrLen (*Filename) + 1;
|
||||
*LineNumber = AssertData->LineNumber;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extracts DEBUG() information from a status code structure.
|
||||
|
||||
Converts the status code specified by Data to the DEBUG() arguments specified
|
||||
by ErrorLevel, Marker, and Format. If type GUID in Data is
|
||||
EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
|
||||
Format from the optional data area of the status code buffer specified by Data.
|
||||
The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
|
||||
which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
|
||||
the Format. If the DEBUG() information could be extracted from Data, then
|
||||
return TRUE. Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If ErrorLevel is NULL, then ASSERT().
|
||||
If Marker is NULL, then ASSERT().
|
||||
If Format is NULL, then ASSERT().
|
||||
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param ErrorLevel Pointer to error level mask for a debug message.
|
||||
@param Marker Pointer to the variable argument list associated with Format.
|
||||
@param Format Pointer to a Null-terminated ASCII format string of a
|
||||
debug message.
|
||||
|
||||
@retval TRUE The status code specified by Data was converted DEBUG() arguments
|
||||
specified by ErrorLevel, Marker, and Format.
|
||||
@retval FALSE The status code specified by Data could not be converted to
|
||||
DEBUG() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractDebugInfo (
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT UINT32 *ErrorLevel,
|
||||
OUT BASE_LIST *Marker,
|
||||
OUT CHAR8 **Format
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (ErrorLevel != NULL);
|
||||
ASSERT (Marker != NULL);
|
||||
ASSERT (Format != NULL);
|
||||
|
||||
//
|
||||
// If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
|
||||
//
|
||||
if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the debug information from the status code record
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
|
||||
|
||||
*ErrorLevel = DebugInfo->ErrorLevel;
|
||||
|
||||
//
|
||||
// The first 12 * UINTN bytes of the string are really an
|
||||
// argument stack to support varargs on the Format string.
|
||||
//
|
||||
*Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST 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;
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
Buffer[0] = '\0';
|
||||
|
||||
|
||||
if (Data != NULL &&
|
||||
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
|
||||
|
||||
//
|
||||
// Print ASSERT() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"\n\rASSERT!: %a (%d): %a\n\r",
|
||||
Filename,
|
||||
LineNumber,
|
||||
Description
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Callout to standard output.
|
||||
//
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else if (Data != NULL &&
|
||||
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
|
||||
|
||||
//
|
||||
// Print DEBUG() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiBSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
Format,
|
||||
Marker
|
||||
);
|
||||
|
||||
} else if (Data != NULL &&
|
||||
CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
|
||||
(CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
|
||||
|
||||
//
|
||||
// Print specific data into output buffer.
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
|
||||
Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
Format = (CHAR8 *) (((UINT64 *) (DebugInfo + 1)) + 12);
|
||||
|
||||
CharCount = AsciiBSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
|
||||
//
|
||||
// Print ERROR information into output buffer.
|
||||
//
|
||||
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"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],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %g",
|
||||
CallerId
|
||||
);
|
||||
}
|
||||
|
||||
if (Data != NULL) {
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %x",
|
||||
Data
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
"\n\r"
|
||||
);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"PROGRESS CODE: V%x I%x\n\r",
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
} else {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"Undefined: C%x:V%x I%x\n\r",
|
||||
CodeType,
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
AddDxeCoreReportStatusCodeCallback (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BuildGuidDataHob (&gEfiStatusCodeRuntimeProtocolGuid, &gStatusCode, sizeof(VOID *));
|
||||
}
|
||||
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
#include <Protocol/StatusCode.h>
|
||||
#include <Guid/StatusCodeDataTypeId.h>
|
||||
#include <Guid/StatusCodeDataTypeDebug.h>
|
||||
#include <FrameworkPei.h>
|
||||
|
||||
#define EFI_STATUS_CODE_DATA_MAX_SIZE 200
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS_CODE_PROTOCOL gStatusCode = {
|
||||
(EFI_REPORT_STATUS_CODE)SerialReportStatusCode
|
||||
};
|
||||
|
||||
/**
|
||||
Extracts ASSERT() information from a status code structure.
|
||||
|
||||
Converts the status code specified by CodeType, Value, and Data to the ASSERT()
|
||||
arguments specified by Filename, Description, and LineNumber. If CodeType is
|
||||
an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
|
||||
Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
|
||||
Filename, Description, and LineNumber from the optional data area of the
|
||||
status code buffer specified by Data. The optional data area of Data contains
|
||||
a Null-terminated ASCII string for the FileName, followed by a Null-terminated
|
||||
ASCII string for the Description, followed by a 32-bit LineNumber. If the
|
||||
ASSERT() information could be extracted from Data, then return TRUE.
|
||||
Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If Filename is NULL, then ASSERT().
|
||||
If Description is NULL, then ASSERT().
|
||||
If LineNumber is NULL, then ASSERT().
|
||||
|
||||
@param CodeType The type of status code being converted.
|
||||
@param Value The status code value being converted.
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param Filename Pointer to the source file name that generated the ASSERT().
|
||||
@param Description Pointer to the description of the ASSERT().
|
||||
@param LineNumber Pointer to source line number that generated the ASSERT().
|
||||
|
||||
@retval TRUE The status code specified by CodeType, Value, and Data was
|
||||
converted ASSERT() arguments specified by Filename, Description,
|
||||
and LineNumber.
|
||||
@retval FALSE The status code specified by CodeType, Value, and Data could
|
||||
not be converted to ASSERT() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractAssertInfo (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT CHAR8 **Filename,
|
||||
OUT CHAR8 **Description,
|
||||
OUT UINT32 *LineNumber
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_ASSERT_DATA *AssertData;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (Filename != NULL);
|
||||
ASSERT (Description != NULL);
|
||||
ASSERT (LineNumber != NULL);
|
||||
|
||||
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
|
||||
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
|
||||
((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
|
||||
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
|
||||
*Filename = (CHAR8 *)(AssertData + 1);
|
||||
*Description = *Filename + AsciiStrLen (*Filename) + 1;
|
||||
*LineNumber = AssertData->LineNumber;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extracts DEBUG() information from a status code structure.
|
||||
|
||||
Converts the status code specified by Data to the DEBUG() arguments specified
|
||||
by ErrorLevel, Marker, and Format. If type GUID in Data is
|
||||
EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
|
||||
Format from the optional data area of the status code buffer specified by Data.
|
||||
The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
|
||||
which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
|
||||
the Format. If the DEBUG() information could be extracted from Data, then
|
||||
return TRUE. Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If ErrorLevel is NULL, then ASSERT().
|
||||
If Marker is NULL, then ASSERT().
|
||||
If Format is NULL, then ASSERT().
|
||||
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param ErrorLevel Pointer to error level mask for a debug message.
|
||||
@param Marker Pointer to the variable argument list associated with Format.
|
||||
@param Format Pointer to a Null-terminated ASCII format string of a
|
||||
debug message.
|
||||
|
||||
@retval TRUE The status code specified by Data was converted DEBUG() arguments
|
||||
specified by ErrorLevel, Marker, and Format.
|
||||
@retval FALSE The status code specified by Data could not be converted to
|
||||
DEBUG() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractDebugInfo (
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT UINT32 *ErrorLevel,
|
||||
OUT BASE_LIST *Marker,
|
||||
OUT CHAR8 **Format
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (ErrorLevel != NULL);
|
||||
ASSERT (Marker != NULL);
|
||||
ASSERT (Format != NULL);
|
||||
|
||||
//
|
||||
// If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
|
||||
//
|
||||
if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the debug information from the status code record
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
|
||||
|
||||
*ErrorLevel = DebugInfo->ErrorLevel;
|
||||
|
||||
//
|
||||
// The first 12 * UINTN bytes of the string are really an
|
||||
// argument stack to support varargs on the Format string.
|
||||
//
|
||||
*Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST 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;
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
Buffer[0] = '\0';
|
||||
|
||||
|
||||
if (Data != NULL &&
|
||||
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
|
||||
|
||||
//
|
||||
// Print ASSERT() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"\n\rASSERT!: %a (%d): %a\n\r",
|
||||
Filename,
|
||||
LineNumber,
|
||||
Description
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Callout to standard output.
|
||||
//
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else if (Data != NULL &&
|
||||
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
|
||||
|
||||
//
|
||||
// Print DEBUG() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiBSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
Format,
|
||||
Marker
|
||||
);
|
||||
|
||||
} else if (Data != NULL &&
|
||||
CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
|
||||
(CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
|
||||
|
||||
//
|
||||
// Print specific data into output buffer.
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
|
||||
Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
Format = (CHAR8 *) (((UINT64 *) (DebugInfo + 1)) + 12);
|
||||
|
||||
CharCount = AsciiBSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
|
||||
//
|
||||
// Print ERROR information into output buffer.
|
||||
//
|
||||
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"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],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %g",
|
||||
CallerId
|
||||
);
|
||||
}
|
||||
|
||||
if (Data != NULL) {
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %x",
|
||||
Data
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
"\n\r"
|
||||
);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"PROGRESS CODE: V%x I%x\n\r",
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
} else {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"Undefined: C%x:V%x I%x\n\r",
|
||||
CodeType,
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
AddDxeCoreReportStatusCodeCallback (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BuildGuidDataHob (&gEfiStatusCodeRuntimeProtocolGuid, &gStatusCode, sizeof(VOID *));
|
||||
}
|
||||
|
||||
|
@@ -34,4 +34,4 @@
|
||||
[LibraryClasses]
|
||||
IoLib
|
||||
DebugLib
|
||||
|
||||
|
@@ -32,4 +32,4 @@
|
||||
|
||||
[LibraryClasses]
|
||||
IoLib
|
||||
DebugLib
|
||||
DebugLib
|
@@ -1,65 +1,65 @@
|
||||
#/** @file
|
||||
#
|
||||
# Component description file for DxeIpl module
|
||||
#
|
||||
# The responsibility of this module is to load the DXE Core from a Firmware Volume. This implementation i used to load a 32-bit DXE Core.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = TemplateSec
|
||||
FILE_GUID = 1D6F730F-5A55-4078-869B-E0A18324BDC8
|
||||
MODULE_TYPE = SEC
|
||||
VERSION_STRING = 1.0
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 ARM
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
TemplateSec.c
|
||||
|
||||
[Sources.Ia32]
|
||||
# Ia32/ResetVector.asm | MSFT
|
||||
# Ia32/ResetVector.S | GCC
|
||||
|
||||
[Sources.X64]
|
||||
# X64/ResetVector.asm | MSFT
|
||||
# X64/ResetVector.S | GCC
|
||||
|
||||
[Sources.ARM]
|
||||
# Arm/ResetVector.asm | RVCT
|
||||
# Arm/ResetVector.S | GCC
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
UefiDecompressLib
|
||||
PeCoffLib
|
||||
CacheMaintenanceLib
|
||||
PrePiLib
|
||||
|
||||
[Pcd]
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize
|
||||
|
||||
#/** @file
|
||||
#
|
||||
# Component description file for DxeIpl module
|
||||
#
|
||||
# The responsibility of this module is to load the DXE Core from a Firmware Volume. This implementation i used to load a 32-bit DXE Core.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = TemplateSec
|
||||
FILE_GUID = 1D6F730F-5A55-4078-869B-E0A18324BDC8
|
||||
MODULE_TYPE = SEC
|
||||
VERSION_STRING = 1.0
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 ARM
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
TemplateSec.c
|
||||
|
||||
[Sources.Ia32]
|
||||
# Ia32/ResetVector.asm | MSFT
|
||||
# Ia32/ResetVector.S | GCC
|
||||
|
||||
[Sources.X64]
|
||||
# X64/ResetVector.asm | MSFT
|
||||
# X64/ResetVector.S | GCC
|
||||
|
||||
[Sources.ARM]
|
||||
# Arm/ResetVector.asm | RVCT
|
||||
# Arm/ResetVector.S | GCC
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
UefiDecompressLib
|
||||
PeCoffLib
|
||||
CacheMaintenanceLib
|
||||
PrePiLib
|
||||
|
||||
[Pcd]
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress
|
||||
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize
|
||||
|
||||
|
@@ -47,4 +47,4 @@
|
||||
gEfiDriverDiagnostics2ProtocolGuid
|
||||
|
||||
[Depex]
|
||||
TRUE
|
||||
TRUE
|
Reference in New Issue
Block a user