summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2016-12-22 18:20:23 +0800
committerGuo Mang <mang.guo@intel.com>2016-12-26 19:14:58 +0800
commit5dce0991864ec5a10add570dca2f8dd850ea29bf (patch)
tree6805ea3a43d604ca794cfe027a75cc9ddc367ff1
parent594e35c5a31f56580ef1e1df25ae491266ac9fac (diff)
downloadedk2-platforms-5dce0991864ec5a10add570dca2f8dd850ea29bf.tar.xz
EmbeddedPkg: Remove unused Package
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com>
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c90
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c524
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h42
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf61
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c149
-rw-r--r--EmbeddedPkg/Contributions.txt218
-rw-r--r--EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c688
-rw-r--r--EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcpDxe.inf54
-rw-r--r--EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c278
-rw-r--r--EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf46
-rw-r--r--EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c461
-rw-r--r--EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.h174
-rw-r--r--EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf64
-rw-r--r--EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.unibin9422 -> 0 bytes
-rw-r--r--EmbeddedPkg/Drivers/FdtPlatformDxe/README.txt72
-rw-r--r--EmbeddedPkg/Drivers/FdtPlatformDxe/ShellDumpFdt.c279
-rw-r--r--EmbeddedPkg/Drivers/FdtPlatformDxe/ShellSetFdt.c468
-rw-r--r--EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.c635
-rw-r--r--EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.h122
-rw-r--r--EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.inf43
-rw-r--r--EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.c1540
-rw-r--r--EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.h303
-rw-r--r--EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf56
-rw-r--r--EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeHw.h329
-rw-r--r--EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.c1005
-rw-r--r--EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.h265
-rw-r--r--EmbeddedPkg/Drivers/SataSiI3132Dxe/ComponentName.c178
-rw-r--r--EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c545
-rw-r--r--EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.h269
-rw-r--r--EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf48
-rw-r--r--EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c825
-rw-r--r--EmbeddedPkg/Ebl/CmdTemplate.c65
-rw-r--r--EmbeddedPkg/Ebl/Command.c916
-rw-r--r--EmbeddedPkg/Ebl/Dir.c353
-rw-r--r--EmbeddedPkg/Ebl/Ebl.h207
-rw-r--r--EmbeddedPkg/Ebl/Ebl.inf111
-rw-r--r--EmbeddedPkg/Ebl/EfiDevice.c1050
-rw-r--r--EmbeddedPkg/Ebl/Hob.c232
-rw-r--r--EmbeddedPkg/Ebl/HwDebug.c342
-rw-r--r--EmbeddedPkg/Ebl/HwIoDebug.c151
-rw-r--r--EmbeddedPkg/Ebl/Main.c674
-rw-r--r--EmbeddedPkg/Ebl/Network.c104
-rw-r--r--EmbeddedPkg/Ebl/Script.c126
-rw-r--r--EmbeddedPkg/Ebl/Variable.c213
-rw-r--r--EmbeddedPkg/EblExternCmd/EntryPointGlue.c154
-rw-r--r--EmbeddedPkg/EblExternCmd/Main.c53
-rw-r--r--EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c82
-rw-r--r--EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf41
-rw-r--r--EmbeddedPkg/EmbeddedPkg.dec184
-rw-r--r--EmbeddedPkg/EmbeddedPkg.dsc290
-rw-r--r--EmbeddedPkg/EmbeddedPkg.fdf141
-rw-r--r--EmbeddedPkg/GdbStub/Arm/Processor.c703
-rw-r--r--EmbeddedPkg/GdbStub/GdbStub.c1257
-rw-r--r--EmbeddedPkg/GdbStub/GdbStub.inf77
-rw-r--r--EmbeddedPkg/GdbStub/GdbStubInternal.h746
-rw-r--r--EmbeddedPkg/GdbStub/Ia32/Processor.c993
-rw-r--r--EmbeddedPkg/GdbStub/SerialIo.c553
-rw-r--r--EmbeddedPkg/GdbStub/X64/Processor.c963
-rw-r--r--EmbeddedPkg/Include/Guid/ExtractSection.h36
-rw-r--r--EmbeddedPkg/Include/Guid/Fdt.h28
-rw-r--r--EmbeddedPkg/Include/Guid/FdtHob.h26
-rw-r--r--EmbeddedPkg/Include/Library/AcpiLib.h113
-rwxr-xr-xEmbeddedPkg/Include/Library/DebugAgentTimerLib.h62
-rwxr-xr-xEmbeddedPkg/Include/Library/DmaLib.h159
-rw-r--r--EmbeddedPkg/Include/Library/EblAddExternalCommandLib.h122
-rw-r--r--EmbeddedPkg/Include/Library/EblCmdLib.h48
-rw-r--r--EmbeddedPkg/Include/Library/EblNetworkLib.h68
-rw-r--r--EmbeddedPkg/Include/Library/EfiFileLib.h350
-rw-r--r--EmbeddedPkg/Include/Library/EfiResetSystemLib.h58
-rw-r--r--EmbeddedPkg/Include/Library/FdtLoadLib.h48
-rw-r--r--EmbeddedPkg/Include/Library/GdbSerialLib.h107
-rw-r--r--EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h165
-rw-r--r--EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h44
-rw-r--r--EmbeddedPkg/Include/Library/PrePiLib.h789
-rw-r--r--EmbeddedPkg/Include/Library/RealTimeClockLib.h138
-rw-r--r--EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h145
-rw-r--r--EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h131
-rw-r--r--EmbeddedPkg/Include/Protocol/DebugSupportPeriodicCallback.h42
-rw-r--r--EmbeddedPkg/Include/Protocol/EblAddCommand.h142
-rw-r--r--EmbeddedPkg/Include/Protocol/EmbeddedDevice.h58
-rw-r--r--EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h94
-rw-r--r--EmbeddedPkg/Include/Protocol/EmbeddedGpio.h167
-rw-r--r--EmbeddedPkg/Include/Protocol/HardwareInterrupt.h170
-rw-r--r--EmbeddedPkg/Include/Protocol/MmcHost.h157
-rw-r--r--EmbeddedPkg/Include/Protocol/PeCoffLoader.h241
-rw-r--r--EmbeddedPkg/Include/Protocol/UsbDevice.h118
-rw-r--r--EmbeddedPkg/Include/fdt.h111
-rw-r--r--EmbeddedPkg/Include/libfdt.h1514
-rw-r--r--EmbeddedPkg/Include/libfdt_env.h81
-rw-r--r--EmbeddedPkg/Library/AcpiLib/AcpiLib.c178
-rw-r--r--EmbeddedPkg/Library/AcpiLib/AcpiLib.inf36
-rwxr-xr-xEmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c63
-rwxr-xr-xEmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf37
-rw-r--r--EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoff.c288
-rw-r--r--EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoffLib.inf44
-rw-r--r--EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.c155
-rw-r--r--EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf47
-rw-r--r--EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.c28
-rw-r--r--EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf43
-rw-r--r--EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c173
-rw-r--r--EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf34
-rw-r--r--EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c1779
-rw-r--r--EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf64
-rw-r--r--EmbeddedPkg/Library/FdtLib/FdtLib.inf38
-rw-r--r--EmbeddedPkg/Library/FdtLib/Makefile.libfdt10
-rwxr-xr-xEmbeddedPkg/Library/FdtLib/README.txt1
-rw-r--r--EmbeddedPkg/Library/FdtLib/TODO3
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt.c250
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c84
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_ro.c574
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_rw.c495
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_strerror.c96
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_sw.c256
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_wip.c118
-rw-r--r--EmbeddedPkg/Library/FdtLib/libfdt_internal.h95
-rw-r--r--EmbeddedPkg/Library/FdtLib/version.lds60
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.S258
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.asm259
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/Arm/Processor.c675
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.c815
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.h728
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf70
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/Ia32/Processor.c951
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/X64/Processor.c963
-rwxr-xr-xEmbeddedPkg/Library/GdbDebugAgent/gdbnotes.txt15
-rw-r--r--EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c187
-rw-r--r--EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf49
-rw-r--r--EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c262
-rw-r--r--EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf46
-rw-r--r--EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Capsule.c288
-rw-r--r--EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Mtc.c226
-rw-r--r--EmbeddedPkg/Library/HalRuntimeServicesExampleLib/ReportStatusCode.c198
-rw-r--r--EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Reset.c63
-rw-r--r--EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Rtc.c862
-rw-r--r--EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Variable.c306
-rw-r--r--EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.c50
-rw-r--r--EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf50
-rwxr-xr-xEmbeddedPkg/Library/NullDmaLib/NullDmaLib.c149
-rwxr-xr-xEmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf41
-rw-r--r--EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c247
-rw-r--r--EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf36
-rw-r--r--EmbeddedPkg/Library/PrePiHobLib/Hob.c852
-rw-r--r--EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf64
-rw-r--r--EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c69
-rw-r--r--EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf38
-rw-r--r--EmbeddedPkg/Library/PrePiLib/FwVol.c845
-rw-r--r--EmbeddedPkg/Library/PrePiLib/PrePi.h46
-rw-r--r--EmbeddedPkg/Library/PrePiLib/PrePiLib.c226
-rw-r--r--EmbeddedPkg/Library/PrePiLib/PrePiLib.inf85
-rw-r--r--EmbeddedPkg/Library/PrePiLib/ReportStatusCode.c325
-rw-r--r--EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c218
-rw-r--r--EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf39
-rw-r--r--EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c175
-rw-r--r--EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf36
-rw-r--r--EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c103
-rw-r--r--EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf35
-rwxr-xr-xEmbeddedPkg/License.txt26
-rw-r--r--EmbeddedPkg/MetronomeDxe/Metronome.c139
-rw-r--r--EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf50
-rw-r--r--EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c158
-rw-r--r--EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf44
-rw-r--r--EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf50
-rw-r--r--EmbeddedPkg/ResetRuntimeDxe/reset.c74
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EFI.CMM40
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm135
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm131
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm77
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm70
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/README.txt7
-rwxr-xr-xEmbeddedPkg/Scripts/LauterbachT32/T32.CMM65
-rw-r--r--EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c759
-rw-r--r--EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf62
-rw-r--r--EmbeddedPkg/TemplateSec/TemplateSec.c76
-rw-r--r--EmbeddedPkg/TemplateSec/TemplateSec.inf65
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/ComponentName.c162
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Diagnostics.c255
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Mmc.c454
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Mmc.h337
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c320
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcDebug.c168
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf51
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c453
182 files changed, 0 insertions, 46371 deletions
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
deleted file mode 100644
index bbca90fc08..0000000000
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/** @file
-
- Copyright (c) 2013-2014, ARM Ltd. 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 "AndroidFastbootApp.h"
-
-#define BOOT_MAGIC "ANDROID!"
-#define BOOT_MAGIC_LENGTH sizeof (BOOT_MAGIC) - 1
-
-// Check Val (unsigned) is a power of 2 (has only one bit set)
-#define IS_POWER_OF_2(Val) (Val != 0 && ((Val & (Val - 1)) == 0))
-
-// No documentation for this really - sizes of fields has been determined
-// empirically.
-#pragma pack(1)
-typedef struct {
- CHAR8 BootMagic[BOOT_MAGIC_LENGTH];
- UINT32 KernelSize;
- UINT32 KernelAddress;
- UINT32 RamdiskSize;
- UINT32 RamdiskAddress;
- UINT32 SecondStageBootloaderSize;
- UINT32 SecondStageBootloaderAddress;
- UINT32 KernelTaggsAddress;
- UINT32 PageSize;
- UINT32 Reserved[2];
- CHAR8 ProductName[16];
- CHAR8 KernelArgs[BOOTIMG_KERNEL_ARGS_SIZE];
- UINT32 Id[32];
-} ANDROID_BOOTIMG_HEADER;
-#pragma pack()
-
-// Find the kernel and ramdisk in an Android boot.img.
-// return EFI_INVALID_PARAMTER if the boot.img is invalid (i.e. doesn't have the
-// right magic value),
-// return EFI_NOT_FOUND if there was no kernel in the boot.img.
-// Note that the Ramdisk is optional - *Ramdisk won't be touched if it isn't
-// present, but RamdiskSize will be set to 0.
-EFI_STATUS
-ParseAndroidBootImg (
- IN VOID *BootImg,
- OUT VOID **Kernel,
- OUT UINTN *KernelSize,
- OUT VOID **Ramdisk,
- OUT UINTN *RamdiskSize,
- OUT CHAR8 *KernelArgs
- )
-{
- ANDROID_BOOTIMG_HEADER *Header;
- UINT8 *BootImgBytePtr;
-
- // Cast to UINT8 so we can do pointer arithmetic
- BootImgBytePtr = (UINT8 *) BootImg;
-
- Header = (ANDROID_BOOTIMG_HEADER *) BootImg;
-
- if (AsciiStrnCmp (Header->BootMagic, BOOT_MAGIC, BOOT_MAGIC_LENGTH) != 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Header->KernelSize == 0) {
- return EFI_NOT_FOUND;
- }
-
- ASSERT (IS_POWER_OF_2 (Header->PageSize));
-
- *KernelSize = Header->KernelSize;
- *Kernel = BootImgBytePtr + Header->PageSize;
- *RamdiskSize = Header->RamdiskSize;
-
- if (Header->RamdiskSize != 0) {
- *Ramdisk = (VOID *) (BootImgBytePtr
- + Header->PageSize
- + ALIGN_VALUE (Header->KernelSize, Header->PageSize));
- }
-
- AsciiStrnCpy (KernelArgs, Header->KernelArgs, BOOTIMG_KERNEL_ARGS_SIZE);
-
- return EFI_SUCCESS;
-}
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
deleted file mode 100644
index f380817040..0000000000
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/** @file
-
- Copyright (c) 2013-2014, ARM Ltd. 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 "AndroidFastbootApp.h"
-
-#include <Protocol/AndroidFastbootTransport.h>
-#include <Protocol/AndroidFastbootPlatform.h>
-#include <Protocol/SimpleTextOut.h>
-#include <Protocol/SimpleTextIn.h>
-
-#include <Library/PcdLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiApplicationEntryPoint.h>
-#include <Library/PrintLib.h>
-
-/*
- * UEFI Application using the FASTBOOT_TRANSPORT_PROTOCOL and
- * FASTBOOT_PLATFORM_PROTOCOL to implement the Android Fastboot protocol.
- */
-
-STATIC FASTBOOT_TRANSPORT_PROTOCOL *mTransport;
-STATIC FASTBOOT_PLATFORM_PROTOCOL *mPlatform;
-
-STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
-
-typedef enum {
- ExpectCmdState,
- ExpectDataState,
- FastbootStateMax
-} ANDROID_FASTBOOT_STATE;
-
-STATIC ANDROID_FASTBOOT_STATE mState = ExpectCmdState;
-
-// When in ExpectDataState, the number of bytes of data to expect:
-STATIC UINT32 mNumDataBytes;
-// .. and the number of bytes so far received this data phase
-STATIC UINT32 mBytesReceivedSoFar;
-// .. and the buffer to save data into
-STATIC UINT8 *mDataBuffer = NULL;
-
-// Event notify functions, from which gBS->Exit shouldn't be called, can signal
-// this event when the application should exit
-STATIC EFI_EVENT mFinishedEvent;
-
-STATIC EFI_EVENT mFatalSendErrorEvent;
-
-// This macro uses sizeof - only use it on arrays (i.e. string literals)
-#define SEND_LITERAL(Str) mTransport->Send ( \
- sizeof (Str) - 1, \
- Str, \
- &mFatalSendErrorEvent \
- )
-#define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1)
-
-#define IS_LOWERCASE_ASCII(Char) (Char >= 'a' && Char <= 'z')
-
-#define FASTBOOT_STRING_MAX_LENGTH 256
-#define FASTBOOT_COMMAND_MAX_LENGTH 64
-
-STATIC
-VOID
-HandleGetVar (
- IN CHAR8 *CmdArg
- )
-{
- CHAR8 Response[FASTBOOT_COMMAND_MAX_LENGTH + 1] = "OKAY";
- EFI_STATUS Status;
-
- // Respond to getvar:version with 0.4 (version of Fastboot protocol)
- if (!AsciiStrnCmp ("version", CmdArg, sizeof ("version") - 1 )) {
- SEND_LITERAL ("OKAY" ANDROID_FASTBOOT_VERSION);
- } else {
- // All other variables are assumed to be platform specific
- Status = mPlatform->GetVar (CmdArg, Response + 4);
- if (EFI_ERROR (Status)) {
- SEND_LITERAL ("FAILSomething went wrong when looking up the variable");
- } else {
- mTransport->Send (AsciiStrLen (Response), Response, &mFatalSendErrorEvent);
- }
- }
-}
-
-STATIC
-VOID
-HandleDownload (
- IN CHAR8 *NumBytesString
- )
-{
- CHAR8 Response[12] = "DATA";
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
-
- // Argument is 8-character ASCII string hex representation of number of bytes
- // that will be sent in the data phase.
- // Response is "DATA" + that same 8-character string.
-
- // Replace any previously downloaded data
- if (mDataBuffer != NULL) {
- FreePool (mDataBuffer);
- mDataBuffer = NULL;
- }
-
- // Parse out number of data bytes to expect
- mNumDataBytes = AsciiStrHexToUint64 (NumBytesString);
- if (mNumDataBytes == 0) {
- mTextOut->OutputString (mTextOut, L"ERROR: Fail to get the number of bytes to download.\r\n");
- SEND_LITERAL ("FAILFailed to get the number of bytes to download");
- return;
- }
-
- UnicodeSPrint (OutputString, sizeof (OutputString), L"Downloading %d bytes\r\n", mNumDataBytes);
- mTextOut->OutputString (mTextOut, OutputString);
-
- mDataBuffer = AllocatePool (mNumDataBytes);
- if (mDataBuffer == NULL) {
- SEND_LITERAL ("FAILNot enough memory");
- } else {
- AsciiStrnCpy (Response + 4, NumBytesString, 8);
- mTransport->Send (sizeof(Response), Response, &mFatalSendErrorEvent);
-
- mState = ExpectDataState;
- mBytesReceivedSoFar = 0;
- }
-}
-
-STATIC
-VOID
-HandleFlash (
- IN CHAR8 *PartitionName
- )
-{
- EFI_STATUS Status;
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
-
- // Build output string
- UnicodeSPrint (OutputString, sizeof (OutputString), L"Flashing partition %a\r\n", PartitionName);
- mTextOut->OutputString (mTextOut, OutputString);
-
- if (mDataBuffer == NULL) {
- // Doesn't look like we were sent any data
- SEND_LITERAL ("FAILNo data to flash");
- return;
- }
-
- Status = mPlatform->FlashPartition (
- PartitionName,
- mNumDataBytes,
- mDataBuffer
- );
- if (Status == EFI_NOT_FOUND) {
- SEND_LITERAL ("FAILNo such partition.");
- mTextOut->OutputString (mTextOut, L"No such partition.\r\n");
- } else if (EFI_ERROR (Status)) {
- SEND_LITERAL ("FAILError flashing partition.");
- mTextOut->OutputString (mTextOut, L"Error flashing partition.\r\n");
- DEBUG ((EFI_D_ERROR, "Couldn't flash image: %r\n", Status));
- } else {
- mTextOut->OutputString (mTextOut, L"Done.\r\n");
- SEND_LITERAL ("OKAY");
- }
-}
-
-STATIC
-VOID
-HandleErase (
- IN CHAR8 *PartitionName
- )
-{
- EFI_STATUS Status;
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
-
- // Build output string
- UnicodeSPrint (OutputString, sizeof (OutputString), L"Erasing partition %a\r\n", PartitionName);
- mTextOut->OutputString (mTextOut, OutputString);
-
- Status = mPlatform->ErasePartition (PartitionName);
- if (EFI_ERROR (Status)) {
- SEND_LITERAL ("FAILCheck device console.");
- DEBUG ((EFI_D_ERROR, "Couldn't erase image: %r\n", Status));
- } else {
- SEND_LITERAL ("OKAY");
- }
-}
-
-STATIC
-VOID
-HandleBoot (
- VOID
- )
-{
- EFI_STATUS Status;
-
- mTextOut->OutputString (mTextOut, L"Booting downloaded image\r\n");
-
- if (mDataBuffer == NULL) {
- // Doesn't look like we were sent any data
- SEND_LITERAL ("FAILNo image in memory");
- return;
- }
-
- // We don't really have any choice but to report success, because once we
- // boot we lose control of the system.
- SEND_LITERAL ("OKAY");
-
- Status = BootAndroidBootImg (mNumDataBytes, mDataBuffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Failed to boot downloaded image: %r\n", Status));
- }
- // We shouldn't get here
-}
-
-STATIC
-VOID
-HandleOemCommand (
- IN CHAR8 *Command
- )
-{
- EFI_STATUS Status;
-
- Status = mPlatform->DoOemCommand (Command);
- if (Status == EFI_NOT_FOUND) {
- SEND_LITERAL ("FAILOEM Command not recognised.");
- } else if (Status == EFI_DEVICE_ERROR) {
- SEND_LITERAL ("FAILError while executing command");
- } else if (EFI_ERROR (Status)) {
- SEND_LITERAL ("FAIL");
- } else {
- SEND_LITERAL ("OKAY");
- }
-}
-
-STATIC
-VOID
-AcceptCmd (
- IN UINTN Size,
- IN CONST CHAR8 *Data
- )
-{
- CHAR8 Command[FASTBOOT_COMMAND_MAX_LENGTH + 1];
-
- // Max command size is 64 bytes
- if (Size > FASTBOOT_COMMAND_MAX_LENGTH) {
- SEND_LITERAL ("FAILCommand too large");
- return;
- }
-
- // Commands aren't null-terminated. Let's get a null-terminated version.
- AsciiStrnCpy (Command, Data, Size);
- Command[Size] = '\0';
-
- // Parse command
- if (MATCH_CMD_LITERAL ("getvar", Command)) {
- HandleGetVar (Command + sizeof ("getvar"));
- } else if (MATCH_CMD_LITERAL ("download", Command)) {
- HandleDownload (Command + sizeof ("download"));
- } else if (MATCH_CMD_LITERAL ("verify", Command)) {
- SEND_LITERAL ("FAILNot supported");
- } else if (MATCH_CMD_LITERAL ("flash", Command)) {
- HandleFlash (Command + sizeof ("flash"));
- } else if (MATCH_CMD_LITERAL ("erase", Command)) {
- HandleErase (Command + sizeof ("erase"));
- } else if (MATCH_CMD_LITERAL ("boot", Command)) {
- HandleBoot ();
- } else if (MATCH_CMD_LITERAL ("continue", Command)) {
- SEND_LITERAL ("OKAY");
- mTextOut->OutputString (mTextOut, L"Received 'continue' command. Exiting Fastboot mode\r\n");
-
- gBS->SignalEvent (mFinishedEvent);
- } else if (MATCH_CMD_LITERAL ("reboot", Command)) {
- if (MATCH_CMD_LITERAL ("reboot-booloader", Command)) {
- // fastboot_protocol.txt:
- // "reboot-bootloader Reboot back into the bootloader."
- // I guess this means reboot back into fastboot mode to save the user
- // having to do whatever they did to get here again.
- // Here we just reboot normally.
- SEND_LITERAL ("INFOreboot-bootloader not supported, rebooting normally.");
- }
- SEND_LITERAL ("OKAY");
- gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
-
- // Shouldn't get here
- DEBUG ((EFI_D_ERROR, "Fastboot: gRT->ResetSystem didn't work\n"));
- } else if (MATCH_CMD_LITERAL ("powerdown", Command)) {
- SEND_LITERAL ("OKAY");
- gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
-
- // Shouldn't get here
- DEBUG ((EFI_D_ERROR, "Fastboot: gRT->ResetSystem didn't work\n"));
- } else if (MATCH_CMD_LITERAL ("oem", Command)) {
- // The "oem" command isn't in the specification, but it was observed in the
- // wild, followed by a space, followed by the actual command.
- HandleOemCommand (Command + sizeof ("oem"));
- } else if (IS_LOWERCASE_ASCII (Command[0])) {
- // Commands starting with lowercase ASCII characters are reserved for the
- // Fastboot protocol. If we don't recognise it, it's probably the future
- // and there are new commmands in the protocol.
- // (By the way, the "oem" command mentioned above makes this reservation
- // redundant, but we handle it here to be spec-compliant)
- SEND_LITERAL ("FAILCommand not recognised. Check Fastboot version.");
- } else {
- HandleOemCommand (Command);
- }
-}
-
-STATIC
-VOID
-AcceptData (
- IN UINTN Size,
- IN VOID *Data
- )
-{
- UINT32 RemainingBytes = mNumDataBytes - mBytesReceivedSoFar;
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
- STATIC UINTN Count = 0;
-
- // Protocol doesn't say anything about sending extra data so just ignore it.
- if (Size > RemainingBytes) {
- Size = RemainingBytes;
- }
-
- CopyMem (&mDataBuffer[mBytesReceivedSoFar], Data, Size);
-
- mBytesReceivedSoFar += Size;
-
- // Show download progress. Don't do it for every packet as outputting text
- // might be time consuming - do it on the last packet and on every 32nd packet
- if ((Count++ % 32) == 0 || Size == RemainingBytes) {
- // (Note no newline in format string - it will overwrite the line each time)
- UnicodeSPrint (
- OutputString,
- sizeof (OutputString),
- L"\r%8d / %8d bytes downloaded (%d%%)",
- mBytesReceivedSoFar,
- mNumDataBytes,
- (mBytesReceivedSoFar * 100) / mNumDataBytes // percentage
- );
- mTextOut->OutputString (mTextOut, OutputString);
- }
-
- if (mBytesReceivedSoFar == mNumDataBytes) {
- // Download finished.
-
- mTextOut->OutputString (mTextOut, L"\r\n");
- SEND_LITERAL ("OKAY");
- mState = ExpectCmdState;
- }
-}
-
-/*
- This is the NotifyFunction passed to CreateEvent in the FastbootAppEntryPoint
- It will be called by the UEFI event framework when the transport protocol
- implementation signals that data has been received from the Fastboot host.
- The parameters are ignored.
-*/
-STATIC
-VOID
-DataReady (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- UINTN Size;
- VOID *Data;
- EFI_STATUS Status;
-
- do {
- Status = mTransport->Receive (&Size, &Data);
- if (!EFI_ERROR (Status)) {
- if (mState == ExpectCmdState) {
- AcceptCmd (Size, (CHAR8 *) Data);
- } else if (mState == ExpectDataState) {
- AcceptData (Size, Data);
- } else {
- ASSERT (FALSE);
- }
- FreePool (Data);
- }
- } while (!EFI_ERROR (Status));
-
- // Quit if there was a fatal error
- if (Status != EFI_NOT_READY) {
- ASSERT (Status == EFI_DEVICE_ERROR);
- // (Put a newline at the beginning as we are probably in the data phase,
- // so the download progress line, with no '\n' is probably on the console)
- mTextOut->OutputString (mTextOut, L"\r\nFatal error receiving data. Exiting.\r\n");
- gBS->SignalEvent (mFinishedEvent);
- }
-}
-
-/*
- Event notify for a fatal error in transmission.
-*/
-STATIC
-VOID
-FatalErrorNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- mTextOut->OutputString (mTextOut, L"Fatal error sending command response. Exiting.\r\n");
- gBS->SignalEvent (mFinishedEvent);
-}
-
-EFI_STATUS
-EFIAPI
-FastbootAppEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_EVENT ReceiveEvent;
- EFI_EVENT WaitEventArray[2];
- UINTN EventIndex;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
-
- mDataBuffer = NULL;
-
- Status = gBS->LocateProtocol (
- &gAndroidFastbootTransportProtocolGuid,
- NULL,
- (VOID **) &mTransport
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Couldn't open Fastboot Transport Protocol: %r\n", Status));
- return Status;
- }
-
- Status = gBS->LocateProtocol (&gAndroidFastbootPlatformProtocolGuid, NULL, (VOID **) &mPlatform);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Couldn't open Fastboot Platform Protocol: %r\n", Status));
- return Status;
- }
-
- Status = mPlatform->Init ();
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Couldn't initialise Fastboot Platform Protocol: %r\n", Status));
- return Status;
- }
-
- Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **) &mTextOut);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR,
- "Fastboot: Couldn't open Text Output Protocol: %r\n", Status
- ));
- return Status;
- }
-
- Status = gBS->LocateProtocol (&gEfiSimpleTextInProtocolGuid, NULL, (VOID **) &TextIn);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Couldn't open Text Input Protocol: %r\n", Status));
- return Status;
- }
-
- // Disable watchdog
- Status = gBS->SetWatchdogTimer (0, 0x10000, 0, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Couldn't disable watchdog timer: %r\n", Status));
- }
-
- // Create event for receipt of data from the host
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- DataReady,
- NULL,
- &ReceiveEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- // Create event for exiting application when "continue" command is received
- Status = gBS->CreateEvent (0, TPL_CALLBACK, NULL, NULL, &mFinishedEvent);
- ASSERT_EFI_ERROR (Status);
-
- // Create event to pass to FASTBOOT_TRANSPORT_PROTOCOL.Send, signalling a
- // fatal error
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- FatalErrorNotify,
- NULL,
- &mFatalSendErrorEvent
- );
- ASSERT_EFI_ERROR (Status);
-
-
- // Start listening for data
- Status = mTransport->Start (
- ReceiveEvent
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Couldn't start transport: %r\n", Status));
- return Status;
- }
-
- // Talk to the user
- mTextOut->OutputString (mTextOut,
- L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press any key to quit.\r\n");
-
- // Quit when the user presses any key, or mFinishedEvent is signalled
- WaitEventArray[0] = mFinishedEvent;
- WaitEventArray[1] = TextIn->WaitForKey;
- gBS->WaitForEvent (2, WaitEventArray, &EventIndex);
-
- mTransport->Stop ();
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Warning: Fastboot Transport Stop: %r\n", Status));
- }
- mPlatform->UnInit ();
-
- return EFI_SUCCESS;
-}
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
deleted file mode 100644
index f62660feb7..0000000000
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/** @file
-
- Copyright (c) 2013-2014, ARM Ltd. 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 __ANDROID_FASTBOOT_APP_H__
-#define __ANDROID_FASTBOOT_APP_H__
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-#define BOOTIMG_KERNEL_ARGS_SIZE 512
-
-#define ANDROID_FASTBOOT_VERSION "0.4"
-
-EFI_STATUS
-BootAndroidBootImg (
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-EFI_STATUS
-ParseAndroidBootImg (
- IN VOID *BootImg,
- OUT VOID **Kernel,
- OUT UINTN *KernelSize,
- OUT VOID **Ramdisk,
- OUT UINTN *RamdiskSize,
- OUT CHAR8 *KernelArgs
- );
-
-#endif //ifdef __ANDROID_FASTBOOT_APP_H__
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
deleted file mode 100644
index ca17af8466..0000000000
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
+++ /dev/null
@@ -1,61 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2013-2015, ARM Ltd. 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 = AndroidFastbootApp
- FILE_GUID = 9588502a-5370-11e3-8631-d7c5951364c8
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- ENTRY_POINT = FastbootAppEntryPoint
-
-[Sources.common]
- AndroidFastbootApp.c
- AndroidBootImg.c
-
-[Sources.ARM, Sources.AARCH64]
- Arm/BootAndroidBootImg.c
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- BdsLib
- DebugLib
- DevicePathLib
- DxeServicesTableLib
- MemoryAllocationLib
- PcdLib
- PrintLib
- UefiApplicationEntryPoint
- UefiBootServicesTableLib
- UefiLib
- UefiRuntimeServicesTableLib
-
-[Protocols]
- gAndroidFastbootTransportProtocolGuid
- gAndroidFastbootPlatformProtocolGuid
- gEfiSimpleTextOutProtocolGuid
- gEfiSimpleTextInProtocolGuid
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[Packages.ARM, Packages.AARCH64]
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
-
-[Guids.ARM, Guids.AARCH64]
- gArmGlobalVariableGuid
diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
deleted file mode 100644
index 3053cf0687..0000000000
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/** @file
-
- Copyright (c) 2013-2015, ARM Ltd. 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 "AndroidFastbootApp.h"
-
-#include <Protocol/DevicePath.h>
-
-#include <Library/BdsLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-#include <Guid/ArmGlobalVariableHob.h>
-
-#define LINUX_LOADER_COMMAND_LINE L"%s -f %s -c %s"
-
-// This GUID is defined in the INGF file of ArmPkg/Application/LinuxLoader
-CONST EFI_GUID mLinuxLoaderAppGuid = { 0x701f54f2, 0x0d70, 0x4b89, { 0xbc, 0x0a, 0xd9, 0xca, 0x25, 0x37, 0x90, 0x59 }};
-
-// Device Path representing an image in memory
-#pragma pack(1)
-typedef struct {
- MEMMAP_DEVICE_PATH Node1;
- EFI_DEVICE_PATH_PROTOCOL End;
-} MEMORY_DEVICE_PATH;
-#pragma pack()
-
-STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
-{
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_MEMMAP_DP,
- {
- (UINT8)(sizeof (MEMMAP_DEVICE_PATH)),
- (UINT8)((sizeof (MEMMAP_DEVICE_PATH)) >> 8),
- },
- }, // Header
- 0, // StartingAddress (set at runtime)
- 0 // EndingAddress (set at runtime)
- }, // Node1
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
- } // End
-};
-
-EFI_STATUS
-BootAndroidBootImg (
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
- CHAR8 KernelArgs[BOOTIMG_KERNEL_ARGS_SIZE];
- VOID *Kernel;
- UINTN KernelSize;
- VOID *Ramdisk;
- UINTN RamdiskSize;
- MEMORY_DEVICE_PATH KernelDevicePath;
- MEMORY_DEVICE_PATH* RamdiskDevicePath;
- CHAR16* KernelDevicePathTxt;
- CHAR16* RamdiskDevicePathTxt;
- EFI_DEVICE_PATH* LinuxLoaderDevicePath;
- CHAR16* LoadOptions;
-
- Status = ParseAndroidBootImg (
- Buffer,
- &Kernel,
- &KernelSize,
- &Ramdisk,
- &RamdiskSize,
- KernelArgs
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- KernelDevicePath = MemoryDevicePathTemplate;
-
- // Have to cast to UINTN before casting to EFI_PHYSICAL_ADDRESS in order to
- // appease GCC.
- KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel;
- KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel + KernelSize;
-
- RamdiskDevicePath = NULL;
- if (RamdiskSize != 0) {
- RamdiskDevicePath = (MEMORY_DEVICE_PATH*)DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL*) &MemoryDevicePathTemplate);
-
- RamdiskDevicePath->Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk;
- RamdiskDevicePath->Node1.EndingAddress = ((EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk) + RamdiskSize;
- }
-
- //
- // Boot Linux using the Legacy Linux Loader
- //
-
- Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &LinuxLoaderDevicePath);
- if (EFI_ERROR (Status)) {
- Print (L"Couldn't Boot Linux: %d\n", Status);
- return EFI_DEVICE_ERROR;
- }
-
- KernelDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, FALSE, FALSE);
- if (KernelDevicePathTxt == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- RamdiskDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) RamdiskDevicePath, FALSE, FALSE);
- if (RamdiskDevicePathTxt == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- // Initialize Legacy Linux loader command line
- LoadOptions = CatSPrint (NULL, LINUX_LOADER_COMMAND_LINE, KernelDevicePathTxt, RamdiskDevicePathTxt, KernelArgs);
- if (LoadOptions == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = BdsStartEfiApplication (gImageHandle, LinuxLoaderDevicePath, StrSize (LoadOptions), LoadOptions);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Couldn't Boot Linux: %d\n", Status));
- return EFI_DEVICE_ERROR;
- }
-
- if (RamdiskDevicePath) {
- FreePool (RamdiskDevicePathTxt);
- FreePool (RamdiskDevicePath);
- }
-
- FreePool (KernelDevicePathTxt);
-
- // If we got here we do a confused face because BootLinuxFdt returned,
- // reporting success.
- DEBUG ((EFI_D_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n"));
- return EFI_SUCCESS;
-}
diff --git a/EmbeddedPkg/Contributions.txt b/EmbeddedPkg/Contributions.txt
deleted file mode 100644
index f87cbd73c6..0000000000
--- a/EmbeddedPkg/Contributions.txt
+++ /dev/null
@@ -1,218 +0,0 @@
-
-======================
-= Code Contributions =
-======================
-
-To make a contribution to a TianoCore project, follow these steps.
-1. Create a change description in the format specified below to
- use in the source control commit log.
-2. Your commit message must include your "Signed-off-by" signature,
- and "Contributed-under" message.
-3. Your "Contributed-under" message explicitly states that the
- contribution is made under the terms of the specified
- contribution agreement. Your "Contributed-under" message
- must include the name of contribution agreement and version.
- For example: Contributed-under: TianoCore Contribution Agreement 1.0
- The "TianoCore Contribution Agreement" is included below in
- this document.
-4. Submit your code to the TianoCore project using the process
- that the project documents on its web page. If the process is
- not documented, then submit the code on development email list
- for the project.
-5. It is preferred that contributions are submitted using the same
- copyright license as the base project. When that is not possible,
- then contributions using the following licenses can be accepted:
- * BSD (2-clause): http://opensource.org/licenses/BSD-2-Clause
- * BSD (3-clause): http://opensource.org/licenses/BSD-3-Clause
- * MIT: http://opensource.org/licenses/MIT
- * Python-2.0: http://opensource.org/licenses/Python-2.0
- * Zlib: http://opensource.org/licenses/Zlib
-
- Contributions of code put into the public domain can also be
- accepted.
-
- Contributions using other licenses might be accepted, but further
- review will be required.
-
-=====================================================
-= Change Description / Commit Message / Patch Email =
-=====================================================
-
-Your change description should use the standard format for a
-commit message, and must include your "Signed-off-by" signature
-and the "Contributed-under" message.
-
-== Sample Change Description / Commit Message =
-
-=== Start of sample patch email message ===
-
-From: Contributor Name <contributor@example.com>
-Subject: [PATCH] CodeModule: Brief-single-line-summary
-
-Full-commit-message
-
-Contributed-under: TianoCore Contribution Agreement 1.0
-Signed-off-by: Contributor Name <contributor@example.com>
----
-
-An extra message for the patch email which will not be considered part
-of the commit message can be added here.
-
-Patch content inline or attached
-
-=== End of sample patch email message ===
-
-=== Notes for sample patch email ===
-
-* The first line of commit message is taken from the email's subject
- line following [PATCH]. The remaining portion of the commit message
- is the email's content until the '---' line.
-* git format-patch is one way to create this format
-
-=== Definitions for sample patch email ===
-
-* "CodeModule" is a short idenfier for the affected code. For
- example MdePkg, or MdeModulePkg UsbBusDxe.
-* "Brief-single-line-summary" is a short summary of the change.
-* The entire first line should be less than ~70 characters.
-* "Full-commit-message" a verbose multiple line comment describing
- the change. Each line should be less than ~70 characters.
-* "Contributed-under" explicitely states that the contribution is
- made under the terms of the contribtion agreement. This
- agreement is included below in this document.
-* "Signed-off-by" is the contributor's signature identifying them
- by their real/legal name and their email address.
-
-========================================
-= TianoCore Contribution Agreement 1.0 =
-========================================
-
-INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION,
-INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE
-PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE
-TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE
-TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR
-REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE
-CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
-BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS
-AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
-AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT
-USE THE CONTENT.
-
-Unless otherwise indicated, all Content made available on the TianoCore
-site is provided to you under the terms and conditions of the BSD
-License ("BSD"). A copy of the BSD License is available at
-http://opensource.org/licenses/bsd-license.php
-or when applicable, in the associated License.txt file.
-
-Certain other content may be made available under other licenses as
-indicated in or with such Content. (For example, in a License.txt file.)
-
-You accept and agree to the following terms and conditions for Your
-present and future Contributions submitted to TianoCore site. Except
-for the license granted to Intel hereunder, You reserve all right,
-title, and interest in and to Your Contributions.
-
-== SECTION 1: Definitions ==
-* "You" or "Contributor" shall mean the copyright owner or legal
- entity authorized by the copyright owner that is making a
- Contribution hereunder. All other entities that control, are
- controlled by, or are under common control with that entity are
- considered to be a single Contributor. For the purposes of this
- definition, "control" means (i) the power, direct or indirect, to
- cause the direction or management of such entity, whether by
- contract or otherwise, or (ii) ownership of fifty percent (50%)
- or more of the outstanding shares, or (iii) beneficial ownership
- of such entity.
-* "Contribution" shall mean any original work of authorship,
- including any modifications or additions to an existing work,
- that is intentionally submitted by You to the TinaoCore site for
- inclusion in, or documentation of, any of the Content. For the
- purposes of this definition, "submitted" means any form of
- electronic, verbal, or written communication sent to the
- TianoCore site or its representatives, including but not limited
- to communication on electronic mailing lists, source code
- control systems, and issue tracking systems that are managed by,
- or on behalf of, the TianoCore site for the purpose of
- discussing and improving the Content, but excluding
- communication that is conspicuously marked or otherwise
- designated in writing by You as "Not a Contribution."
-
-== SECTION 2: License for Contributions ==
-* Contributor hereby agrees that redistribution and use of the
- Contribution in source and binary forms, with or without
- modification, are permitted provided that the following
- conditions are met:
-** Redistributions of source code must retain the Contributor's
- copyright notice, this list of conditions and the following
- disclaimer.
-** Redistributions in binary form must reproduce the Contributor's
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-* Disclaimer. None of the names of Contributor, Intel, or the names
- of their respective contributors may be used to endorse or
- promote products derived from this software without specific
- prior written permission.
-* Contributor grants a license (with the right to sublicense) under
- claims of Contributor's patents that Contributor can license that
- are infringed by the Contribution (as delivered by Contributor) to
- make, use, distribute, sell, offer for sale, and import the
- Contribution and derivative works thereof solely to the minimum
- extent necessary for licensee to exercise the granted copyright
- license; this patent license applies solely to those portions of
- the Contribution that are unmodified. No hardware per se is
- licensed.
-* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE
- CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
- CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
-
-== SECTION 3: Representations ==
-* You represent that You are legally entitled to grant the above
- license. If your employer(s) has rights to intellectual property
- that You create that includes Your Contributions, You represent
- that You have received permission to make Contributions on behalf
- of that employer, that Your employer has waived such rights for
- Your Contributions.
-* You represent that each of Your Contributions is Your original
- creation (see Section 4 for submissions on behalf of others).
- You represent that Your Contribution submissions include complete
- details of any third-party license or other restriction
- (including, but not limited to, related patents and trademarks)
- of which You are personally aware and which are associated with
- any part of Your Contributions.
-
-== SECTION 4: Third Party Contributions ==
-* Should You wish to submit work that is not Your original creation,
- You may submit it to TianoCore site separately from any
- Contribution, identifying the complete details of its source
- and of any license or other restriction (including, but not
- limited to, related patents, trademarks, and license agreements)
- of which You are personally aware, and conspicuously marking the
- work as "Submitted on behalf of a third-party: [named here]".
-
-== SECTION 5: Miscellaneous ==
-* Applicable Laws. Any claims arising under or relating to this
- Agreement shall be governed by the internal substantive laws of
- the State of Delaware or federal courts located in Delaware,
- without regard to principles of conflict of laws.
-* Language. This Agreement is in the English language only, which
- language shall be controlling in all respects, and all versions
- of this Agreement in any other language shall be for accommodation
- only and shall not be binding. All communications and notices made
- or given pursuant to this Agreement, and all documentation and
- support to be provided, unless otherwise noted, shall be in the
- English language.
-
diff --git a/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c b/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c
deleted file mode 100644
index 8ec78aeb53..0000000000
--- a/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c
+++ /dev/null
@@ -1,688 +0,0 @@
-/** @file
-#
-# Copyright (c) 2014, ARM Ltd. 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 <Protocol/AndroidFastbootTransport.h>
-#include <Protocol/Dhcp4.h>
-#include <Protocol/Tcp4.h>
-#include <Protocol/ServiceBinding.h>
-#include <Protocol/SimpleTextOut.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PrintLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-#include <Guid/Hostname.h>
-
-#define IP4_ADDR_TO_STRING(IpAddr, IpAddrString) UnicodeSPrint ( \
- IpAddrString, \
- 16 * 2, \
- L"%d.%d.%d.%d", \
- IpAddr.Addr[0], \
- IpAddr.Addr[1], \
- IpAddr.Addr[2], \
- IpAddr.Addr[3] \
- );
-
-// Fastboot says max packet size is 512, but FASTBOOT_TRANSPORT_PROTOCOL
-// doesn't place a limit on the size of buffers returned by Receive.
-// (This isn't actually a packet size - it's just the size of the buffers we
-// pass to the TCP driver to fill with received data.)
-// We can achieve much better performance by doing this in larger chunks.
-#define RX_FRAGMENT_SIZE 2048
-
-STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
-
-STATIC EFI_TCP4_PROTOCOL *mTcpConnection;
-STATIC EFI_TCP4_PROTOCOL *mTcpListener;
-
-STATIC EFI_EVENT mReceiveEvent;
-
-STATIC EFI_SERVICE_BINDING_PROTOCOL *mTcpServiceBinding;
-STATIC EFI_HANDLE mTcpHandle = NULL;
-
-// We only ever use one IO token for receive and one for transmit. To save
-// repeatedly allocating and freeing, just allocate statically and re-use.
-#define NUM_RX_TOKENS 16
-#define TOKEN_NEXT(Index) (((Index) + 1) % NUM_RX_TOKENS)
-
-STATIC UINTN mNextSubmitIndex;
-STATIC UINTN mNextReceiveIndex;
-STATIC EFI_TCP4_IO_TOKEN mReceiveToken[NUM_RX_TOKENS];
-STATIC EFI_TCP4_RECEIVE_DATA mRxData[NUM_RX_TOKENS];
-STATIC EFI_TCP4_IO_TOKEN mTransmitToken;
-STATIC EFI_TCP4_TRANSMIT_DATA mTxData;
-// We also reuse the accept token
-STATIC EFI_TCP4_LISTEN_TOKEN mAcceptToken;
-// .. and the close token
-STATIC EFI_TCP4_CLOSE_TOKEN mCloseToken;
-
-// List type for queued received packets
-typedef struct _FASTBOOT_TCP_PACKET_LIST {
- LIST_ENTRY Link;
- VOID *Buffer;
- UINTN BufferSize;
-} FASTBOOT_TCP_PACKET_LIST;
-
-STATIC LIST_ENTRY mPacketListHead;
-
-STATIC
-VOID
-EFIAPI
-DataReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/*
- Helper function to set up a receive IO token and call Tcp->Receive
-*/
-STATIC
-EFI_STATUS
-SubmitRecieveToken (
- VOID
- )
-{
- EFI_STATUS Status;
- VOID *FragmentBuffer;
-
- Status = EFI_SUCCESS;
-
- FragmentBuffer = AllocatePool (RX_FRAGMENT_SIZE);
- ASSERT (FragmentBuffer != NULL);
- if (FragmentBuffer == NULL) {
- DEBUG ((EFI_D_ERROR, "TCP Fastboot out of resources"));
- return EFI_OUT_OF_RESOURCES;
- }
-
- mRxData[mNextSubmitIndex].DataLength = RX_FRAGMENT_SIZE;
- mRxData[mNextSubmitIndex].FragmentTable[0].FragmentLength = RX_FRAGMENT_SIZE;
- mRxData[mNextSubmitIndex].FragmentTable[0].FragmentBuffer = FragmentBuffer;
-
- Status = mTcpConnection->Receive (mTcpConnection, &mReceiveToken[mNextSubmitIndex]);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP Receive: %r\n", Status));
- FreePool (FragmentBuffer);
- }
-
- mNextSubmitIndex = TOKEN_NEXT (mNextSubmitIndex);
- return Status;
-}
-
-/*
- Event notify function for when we have closed our TCP connection.
- We can now start listening for another connection.
-*/
-STATIC
-VOID
-ConnectionClosed (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
-
- // Possible bug in EDK2 TCP4 driver: closing a connection doesn't remove its
- // PCB from the list of live connections. Subsequent attempts to Configure()
- // a TCP instance with the same local port will fail with INVALID_PARAMETER.
- // Calling Configure with NULL is a workaround for this issue.
- Status = mTcpConnection->Configure (mTcpConnection, NULL);
-
- mTcpConnection = NULL;
-
- Status = mTcpListener->Accept (mTcpListener, &mAcceptToken);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP Accept: %r\n", Status));
- }
-}
-
-STATIC
-VOID
-CloseReceiveEvents (
- VOID
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
- gBS->CloseEvent (mReceiveToken[Index].CompletionToken.Event);
- }
-}
-
-/*
- Event notify function to be called when we receive TCP data.
-*/
-STATIC
-VOID
-EFIAPI
-DataReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- FASTBOOT_TCP_PACKET_LIST *NewEntry;
- EFI_TCP4_IO_TOKEN *ReceiveToken;
-
- ReceiveToken = &mReceiveToken[mNextReceiveIndex];
-
- Status = ReceiveToken->CompletionToken.Status;
-
- if (Status == EFI_CONNECTION_FIN) {
- //
- // Remote host closed connection. Close our end.
- //
-
- CloseReceiveEvents ();
-
- Status = mTcpConnection->Close (mTcpConnection, &mCloseToken);
- ASSERT_EFI_ERROR (Status);
-
- return;
- }
-
- //
- // Add an element to the receive queue
- //
-
- NewEntry = AllocatePool (sizeof (FASTBOOT_TCP_PACKET_LIST));
- if (NewEntry == NULL) {
- DEBUG ((EFI_D_ERROR, "TCP Fastboot: Out of resources\n"));
- return;
- }
-
- mNextReceiveIndex = TOKEN_NEXT (mNextReceiveIndex);
-
- if (!EFI_ERROR (Status)) {
- NewEntry->Buffer
- = ReceiveToken->Packet.RxData->FragmentTable[0].FragmentBuffer;
- NewEntry->BufferSize
- = ReceiveToken->Packet.RxData->FragmentTable[0].FragmentLength;
-
- // Prepare to receive more data
- SubmitRecieveToken();
- } else {
- // Fatal receive error. Put an entry with NULL in the queue, signifying
- // to return EFI_DEVICE_ERROR from TcpFastbootTransportReceive.
- NewEntry->Buffer = NULL;
- NewEntry->BufferSize = 0;
-
- DEBUG ((EFI_D_ERROR, "\nTCP Fastboot Receive error: %r\n", Status));
- }
-
- InsertTailList (&mPacketListHead, &NewEntry->Link);
-
- Status = gBS->SignalEvent (mReceiveEvent);
- ASSERT_EFI_ERROR (Status);
-}
-
-
-/*
- Event notify function to be called when we accept an incoming TCP connection.
-*/
-STATIC
-VOID
-EFIAPI
-ConnectionAccepted (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_TCP4_LISTEN_TOKEN *AcceptToken;
- EFI_STATUS Status;
- UINTN Index;
-
- AcceptToken = (EFI_TCP4_LISTEN_TOKEN *) Context;
- Status = AcceptToken->CompletionToken.Status;
-
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP Fastboot: Connection Error: %r\n", Status));
- return;
- }
- DEBUG ((EFI_D_ERROR, "TCP Fastboot: Connection Received.\n"));
-
- //
- // Accepting a new TCP connection creates a new instance of the TCP protocol.
- // Open it and prepare to receive on it.
- //
-
- Status = gBS->OpenProtocol (
- AcceptToken->NewChildHandle,
- &gEfiTcp4ProtocolGuid,
- (VOID **) &mTcpConnection,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Open TCP Connection: %r\n", Status));
- return;
- }
-
- mNextSubmitIndex = 0;
- mNextReceiveIndex = 0;
-
- for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- DataReceived,
- NULL,
- &(mReceiveToken[Index].CompletionToken.Event)
- );
- ASSERT_EFI_ERROR (Status);
- }
-
- for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
- SubmitRecieveToken();
- }
-}
-
-/*
- Set up TCP Fastboot transport: Configure the network device via DHCP then
- start waiting for a TCP connection on the Fastboot port.
-*/
-EFI_STATUS
-TcpFastbootTransportStart (
- EFI_EVENT ReceiveEvent
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE NetDeviceHandle;
- EFI_HANDLE *HandleBuffer;
- EFI_IP4_MODE_DATA Ip4ModeData;
- UINTN NumHandles;
- UINTN HostnameSize = 256;
- CHAR8 Hostname[256];
- CHAR16 HostnameUnicode[256] = L"<no hostname>";
- CHAR16 IpAddrString[16];
- UINTN Index;
-
- EFI_TCP4_CONFIG_DATA TcpConfigData = {
- 0x00, // IPv4 Type of Service
- 255, // IPv4 Time to Live
- { // AccessPoint:
- TRUE, // Use default address
- { {0, 0, 0, 0} }, // IP Address (ignored - use default)
- { {0, 0, 0, 0} }, // Subnet mask (ignored - use default)
- FixedPcdGet32 (PcdAndroidFastbootTcpPort), // Station port
- { {0, 0, 0, 0} }, // Remote address: accept any
- 0, // Remote Port: accept any
- FALSE // ActiveFlag: be a "server"
- },
- NULL // Default advanced TCP options
- };
-
- mReceiveEvent = ReceiveEvent;
- InitializeListHead (&mPacketListHead);
-
- mTextOut->OutputString (mTextOut, L"Initialising TCP Fastboot transport...\r\n");
-
- //
- // Open a passive TCP instance
- //
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiTcp4ServiceBindingProtocolGuid,
- NULL,
- &NumHandles,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Find TCP Service Binding: %r\n", Status));
- return Status;
- }
-
- // We just use the first network device
- NetDeviceHandle = HandleBuffer[0];
-
- Status = gBS->OpenProtocol (
- NetDeviceHandle,
- &gEfiTcp4ServiceBindingProtocolGuid,
- (VOID **) &mTcpServiceBinding,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Open TCP Service Binding: %r\n", Status));
- return Status;
- }
-
- Status = mTcpServiceBinding->CreateChild (mTcpServiceBinding, &mTcpHandle);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP ServiceBinding Create: %r\n", Status));
- return Status;
- }
-
- Status = gBS->OpenProtocol (
- mTcpHandle,
- &gEfiTcp4ProtocolGuid,
- (VOID **) &mTcpListener,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Open TCP Protocol: %r\n", Status));
- }
-
- //
- // Set up re-usable tokens
- //
-
- for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
- mRxData[Index].UrgentFlag = FALSE;
- mRxData[Index].FragmentCount = 1;
- mReceiveToken[Index].Packet.RxData = &mRxData[Index];
- }
-
- mTxData.Push = TRUE;
- mTxData.Urgent = FALSE;
- mTxData.FragmentCount = 1;
- mTransmitToken.Packet.TxData = &mTxData;
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- ConnectionAccepted,
- &mAcceptToken,
- &mAcceptToken.CompletionToken.Event
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- ConnectionClosed,
- &mCloseToken,
- &mCloseToken.CompletionToken.Event
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Configure the TCP instance
- //
-
- Status = mTcpListener->Configure (mTcpListener, &TcpConfigData);
- if (Status == EFI_NO_MAPPING) {
- // Wait until the IP configuration process (probably DHCP) has finished
- do {
- Status = mTcpListener->GetModeData (mTcpListener,
- NULL, NULL,
- &Ip4ModeData,
- NULL, NULL
- );
- ASSERT_EFI_ERROR (Status);
- } while (!Ip4ModeData.IsConfigured);
- Status = mTcpListener->Configure (mTcpListener, &TcpConfigData);
- } else if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP Configure: %r\n", Status));
- return Status;
- }
-
- //
- // Tell the user our address and hostname
- //
- IP4_ADDR_TO_STRING (Ip4ModeData.ConfigData.StationAddress, IpAddrString);
-
- // Look up hostname
- Status = gRT->GetVariable (
- L"Hostname",
- &gEfiHostnameVariableGuid,
- NULL,
- &HostnameSize,
- &Hostname
- );
- if (!EFI_ERROR (Status) && HostnameSize != 0) {
- AsciiStrToUnicodeStr (Hostname, HostnameUnicode);
- }
-
- // Hostname variable is not null-terminated.
- Hostname[HostnameSize] = L'\0';
-
- mTextOut->OutputString (mTextOut, L"TCP Fastboot transport configured.");
- mTextOut->OutputString (mTextOut, L"\r\nIP address: ");
- mTextOut->OutputString (mTextOut ,IpAddrString);
- mTextOut->OutputString (mTextOut, L"\r\n");
- mTextOut->OutputString (mTextOut, L"\r\nhostname: ");
- mTextOut->OutputString (mTextOut, HostnameUnicode);
- mTextOut->OutputString (mTextOut, L"\r\n");
-
- //
- // Start listening for a connection
- //
-
- Status = mTcpListener->Accept (mTcpListener, &mAcceptToken);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP Accept: %r\n", Status));
- return Status;
- }
-
- mTextOut->OutputString (mTextOut, L"TCP Fastboot transport initialised.\r\n");
-
- FreePool (HandleBuffer);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-TcpFastbootTransportStop (
- VOID
- )
-{
- EFI_TCP4_CLOSE_TOKEN CloseToken;
- EFI_STATUS Status;
- UINTN EventIndex;
- FASTBOOT_TCP_PACKET_LIST *Entry;
- FASTBOOT_TCP_PACKET_LIST *NextEntry;
-
- // Close any existing TCP connection, blocking until it's done.
- if (mTcpConnection != NULL) {
- CloseReceiveEvents ();
-
- CloseToken.AbortOnClose = FALSE;
-
- Status = gBS->CreateEvent (0, 0, NULL, NULL, &CloseToken.CompletionToken.Event);
- ASSERT_EFI_ERROR (Status);
-
- Status = mTcpConnection->Close (mTcpConnection, &CloseToken);
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->WaitForEvent (
- 1,
- &CloseToken.CompletionToken.Event,
- &EventIndex
- );
- ASSERT_EFI_ERROR (Status);
-
- ASSERT_EFI_ERROR (CloseToken.CompletionToken.Status);
-
- // Possible bug in EDK2 TCP4 driver: closing a connection doesn't remove its
- // PCB from the list of live connections. Subsequent attempts to Configure()
- // a TCP instance with the same local port will fail with INVALID_PARAMETER.
- // Calling Configure with NULL is a workaround for this issue.
- Status = mTcpConnection->Configure (mTcpConnection, NULL);
- ASSERT_EFI_ERROR (Status);
- }
-
-
- gBS->CloseEvent (mAcceptToken.CompletionToken.Event);
-
- // Stop listening for connections.
- // Ideally we would do this with Cancel, but it isn't implemented by EDK2.
- // So we just "reset this TCPv4 instance brutally".
- Status = mTcpListener->Configure (mTcpListener, NULL);
- ASSERT_EFI_ERROR (Status);
-
- Status = mTcpServiceBinding->DestroyChild (mTcpServiceBinding, &mTcpHandle);
-
- // Free any data the user didn't pick up
- Entry = (FASTBOOT_TCP_PACKET_LIST *) GetFirstNode (&mPacketListHead);
- while (!IsNull (&mPacketListHead, &Entry->Link)) {
- NextEntry = (FASTBOOT_TCP_PACKET_LIST *) GetNextNode (&mPacketListHead, &Entry->Link);
-
- RemoveEntryList (&Entry->Link);
- if (Entry->Buffer) {
- FreePool (Entry->Buffer);
- }
- FreePool (Entry);
-
- Entry = NextEntry;
- }
-
- return EFI_SUCCESS;
-}
-
-/*
- Event notify function for when data has been sent. Free resources and report
- errors.
- Context should point to the transmit IO token passed to
- TcpConnection->Transmit.
-*/
-STATIC
-VOID
-DataSent (
- EFI_EVENT Event,
- VOID *Context
- )
-{
- EFI_STATUS Status;
-
- Status = mTransmitToken.CompletionToken.Status;
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP Fastboot transmit result: %r\n", Status));
- gBS->SignalEvent (*(EFI_EVENT *) Context);
- }
-
- FreePool (mTransmitToken.Packet.TxData->FragmentTable[0].FragmentBuffer);
-}
-
-EFI_STATUS
-TcpFastbootTransportSend (
- IN UINTN BufferSize,
- IN CONST VOID *Buffer,
- IN EFI_EVENT *FatalErrorEvent
- )
-{
- EFI_STATUS Status;
-
- if (BufferSize > 512) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Build transmit IO token
- //
-
- // Create an event so we are notified when a transmission is complete.
- // We use this to free resources and report errors.
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- DataSent,
- FatalErrorEvent,
- &mTransmitToken.CompletionToken.Event
- );
- ASSERT_EFI_ERROR (Status);
-
- mTxData.DataLength = BufferSize;
-
- mTxData.FragmentTable[0].FragmentLength = BufferSize;
- mTxData.FragmentTable[0].FragmentBuffer = AllocateCopyPool (
- BufferSize,
- Buffer
- );
-
- Status = mTcpConnection->Transmit (mTcpConnection, &mTransmitToken);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "TCP Transmit: %r\n", Status));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-TcpFastbootTransportReceive (
- OUT UINTN *BufferSize,
- OUT VOID **Buffer
- )
-{
- FASTBOOT_TCP_PACKET_LIST *Entry;
-
- if (IsListEmpty (&mPacketListHead)) {
- return EFI_NOT_READY;
- }
-
- Entry = (FASTBOOT_TCP_PACKET_LIST *) GetFirstNode (&mPacketListHead);
-
- if (Entry->Buffer == NULL) {
- // There was an error receiving this packet.
- return EFI_DEVICE_ERROR;
- }
-
- *Buffer = Entry->Buffer;
- *BufferSize = Entry->BufferSize;
-
- RemoveEntryList (&Entry->Link);
- FreePool (Entry);
-
- return EFI_SUCCESS;
-}
-
-FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
- TcpFastbootTransportStart,
- TcpFastbootTransportStop,
- TcpFastbootTransportSend,
- TcpFastbootTransportReceive
-};
-
-EFI_STATUS
-TcpFastbootTransportEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
-
- Status = gBS->LocateProtocol(
- &gEfiSimpleTextOutProtocolGuid,
- NULL,
- (VOID **) &mTextOut
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Open Text Output Protocol: %r\n", Status));
- return Status;
- }
-
- Status = gBS->InstallProtocolInterface (
- &ImageHandle,
- &gAndroidFastbootTransportProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mTransportProtocol
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Fastboot: Install transport Protocol: %r\n", Status));
- }
-
- return Status;
-}
diff --git a/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcpDxe.inf b/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcpDxe.inf
deleted file mode 100644
index 4d777934e5..0000000000
--- a/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcpDxe.inf
+++ /dev/null
@@ -1,54 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2014, ARM Ltd. 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 = TcpFastbootTransportDxe
- FILE_GUID = 86787704-8fed-11e3-b3ff-f33b73acfec2
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = TcpFastbootTransportEntryPoint
-
-[Sources.common]
- FastbootTransportTcp.c
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- MemoryAllocationLib
- PrintLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- UefiRuntimeServicesTableLib
-
-[Protocols]
- gAndroidFastbootTransportProtocolGuid
- gEfiDhcp4ProtocolGuid
- gEfiDhcp4ServiceBindingProtocolGuid
- gEfiTcp4ServiceBindingProtocolGuid
- gEfiSimpleTextOutProtocolGuid
- gEfiTcp4ProtocolGuid
- gEfiSimpleTextOutProtocolGuid
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[Guids]
- gEfiHostnameVariableGuid
-
-[FixedPcd]
- gEmbeddedTokenSpaceGuid.PcdAndroidFastbootTcpPort
diff --git a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c b/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c
deleted file mode 100644
index e7da1fa5fc..0000000000
--- a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/** @file
-
- Copyright (c) 2014, ARM Ltd. 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.
-
-**/
-
-/*
- * Implementation of the FASTBOOT_TRANSPORT_PROTOCOL using the USB_DEVICE_PROTOCOL
- */
-
-#include <Protocol/UsbDevice.h>
-#include <Protocol/AndroidFastbootTransport.h>
-#include <Protocol/SimpleTextOut.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-
-STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
-
-// Configuration attributes:
-// bit 7 reserved and must be 1, bit 6 means self-powered.
-#define CONFIG_DESC_ATTRIBUTES (BIT7 | BIT6)
-
-#define MAX_PACKET_SIZE_BULK 512
-
-STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
-STATIC EFI_EVENT mReceiveEvent = NULL;
-STATIC LIST_ENTRY mPacketList;
-
-// List type for queued received packets
-typedef struct _FASTBOOT_USB_PACKET_LIST {
- LIST_ENTRY Link;
- VOID *Buffer;
- UINTN BufferSize;
-} FASTBOOT_USB_PACKET_LIST;
-
-
-/*
- No string descriptors - all string descriptor members are set to 0
-*/
-
-STATIC USB_DEVICE_DESCRIPTOR mDeviceDescriptor = {
- sizeof (USB_DEVICE_DESCRIPTOR), //Length
- USB_DESC_TYPE_DEVICE, //DescriptorType
- 0x0200, //BcdUSB
- 0xFF, //DeviceClass
- 0, //DeviceSubClass
- 0, //DeviceProtocol
- 64, //MaxPacketSize0
- FixedPcdGet32 (PcdAndroidFastbootUsbVendorId), //IdVendor
- FixedPcdGet32 (PcdAndroidFastbootUsbProductId), //IdProduct
- 0, //BcdDevice
- 0, //StrManufacturer
- 0, //StrProduct
- 0, //StrSerialNumber
- 1 //NumConfigurations
-};
-
-/*
- We have one configuration, one interface, and two endpoints (one IN, one OUT)
-*/
-
-// Lazy (compile-time) way to concatenate descriptors to pass to the USB device
-// protocol
-
-#pragma pack(1)
-typedef struct {
- USB_CONFIG_DESCRIPTOR ConfigDescriptor;
- USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- USB_ENDPOINT_DESCRIPTOR EndpointDescriptor1;
- USB_ENDPOINT_DESCRIPTOR EndpointDescriptor2;
-} GET_CONFIG_DESCRIPTOR_RESPONSE;
-#pragma pack()
-
-STATIC GET_CONFIG_DESCRIPTOR_RESPONSE mGetConfigDescriptorResponse = {
- { // USB_CONFIG_DESCRIPTOR
- sizeof (USB_CONFIG_DESCRIPTOR), //Length;
- USB_DESC_TYPE_CONFIG, //DescriptorType;
- sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE), //TotalLength;
- 1, //NumInterfaces;
- 1, //ConfigurationValue;
- 0, //Configuration;
- CONFIG_DESC_ATTRIBUTES, //Attributes;
- 0 //MaxPower;
- },
- { // USB_INTERFACE_DESCRIPTOR
- sizeof (USB_INTERFACE_DESCRIPTOR), //Length;
- USB_DESC_TYPE_INTERFACE, //DescriptorType;
- 0, //InterfaceNumber;
- 0, //AlternateSetting;
- 2, //NumEndpoints;
- 0xFF, //InterfaceClass;
- // Vendor specific interface subclass and protocol codes.
- // I found these values in the Fastboot code
- // (in match_fastboot_with_serial in fastboot.c).
- 0x42, //InterfaceSubClass;
- 0x03, //InterfaceProtocol;
- 0 //Interface;
- },
- { // USB_ENDPOINT_DESCRIPTOR (In Endpoint)
- sizeof (USB_ENDPOINT_DESCRIPTOR), //Length;
- USB_DESC_TYPE_ENDPOINT, //DescriptorType;
- 1 | BIT7, //EndpointAddress;
- 0x2, //Attributes;
- MAX_PACKET_SIZE_BULK, //MaxPacketSize;
- 16 //Interval;
- },
- { // STATIC USB_ENDPOINT_DESCRIPTOR (Out Endpoint)
- sizeof (USB_ENDPOINT_DESCRIPTOR), //Length;
- USB_DESC_TYPE_ENDPOINT, //DescriptorType;
- 1, //EndpointAddress;
- 0x2, //Attributes;
- MAX_PACKET_SIZE_BULK, //MaxPacketSize;
- 16 //Interval;
- }
-};
-
-STATIC
-VOID
-DataReceived (
- IN UINTN Size,
- IN VOID *Buffer
- )
-{
- FASTBOOT_USB_PACKET_LIST *NewEntry;
-
- NewEntry = AllocatePool (sizeof (*NewEntry));
- ASSERT (NewEntry != NULL);
-
- NewEntry->Buffer = Buffer;
- NewEntry->BufferSize = Size;
-
- InsertTailList (&mPacketList, &NewEntry->Link);
-
- if (mReceiveEvent) {
- gBS->SignalEvent (mReceiveEvent);
- }
-}
-
-STATIC
-VOID
-DataSent (
- IN UINT8 EndpointIndex
- )
-{
- // Don't care.
-}
-
-/*
- Set up the transport system for use by Fastboot.
- e.g. For USB this probably means making the device enumerable.
-*/
-EFI_STATUS
-FastbootTransportUsbStart (
- EFI_EVENT ReceiveEvent
- )
-{
- GET_CONFIG_DESCRIPTOR_RESPONSE *Responses;
-
- mReceiveEvent = ReceiveEvent;
-
- mGetConfigDescriptorResponse.ConfigDescriptor.TotalLength = sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE);
- Responses = &mGetConfigDescriptorResponse;
-
- InitializeListHead (&mPacketList);
-
- return mUsbDevice->Start (&mDeviceDescriptor, (VOID **) &Responses, DataReceived, DataSent);
-}
-
-/*
- Function to be called when all Fastboot transactions are finished, to
- de-initialise the transport system.
- e.g. A USB OTG system might want to get out of peripheral mode so it can be
- a USB host.
-*/
-EFI_STATUS
-FastbootTransportUsbStop (
- VOID
- )
-{
- // not yet implemented in USB
- return EFI_SUCCESS;
-}
-
-/*
- Send data. This function can be used both for command responses like "OKAY"
- and for the data phase (the protocol doesn't describe any situation when the
- latter might be necessary, but does allow it)
- */
-EFI_STATUS
-FastbootTransportUsbSend (
- IN UINTN BufferSize,
- IN CONST VOID *Buffer,
- IN EFI_EVENT *FatalErrorEvent
- )
-{
- // Current USB protocol is blocking, so ignore FatalErrorEvent
- return mUsbDevice->Send(1, BufferSize, Buffer);
-}
-
-/*
- When the event has been Signalled to say data is available from the host,
- this function is used to get data. In order to handle the case where several
- packets are received before ReceiveEvent's notify function is called, packets
- received are queued, and each call to this function returns the next packet in
- the queue. It should therefore be called in a loop, the exit condition being a
- return of EFI_NOT_READY.
-
- Parameters:
- Buffer - The buffer in which to place data
- BufferSize - The size of Buffer in bytes
-
- Return EFI_NOT_READY if there is no data available
-*/
-EFI_STATUS
-FastbootTransportUsbReceive (
- OUT UINTN *BufferSize,
- OUT VOID **Buffer
- )
-{
- FASTBOOT_USB_PACKET_LIST *Entry;
-
- if (IsListEmpty (&mPacketList)) {
- return EFI_NOT_READY;
- }
-
- Entry = (FASTBOOT_USB_PACKET_LIST *) GetFirstNode (&mPacketList);
-
- *BufferSize = Entry->BufferSize;
- *Buffer = Entry->Buffer;
-
- RemoveEntryList (&Entry->Link);
- FreePool (Entry);
-
- return EFI_SUCCESS;
-}
-
-STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
- FastbootTransportUsbStart,
- FastbootTransportUsbStop,
- FastbootTransportUsbSend,
- FastbootTransportUsbReceive
-};
-
-EFI_STATUS
-FastbootTransportUsbEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- // Assume there's only one USB peripheral controller.
- Status = gBS->LocateProtocol (&gUsbDeviceProtocolGuid, NULL, (VOID **) &mUsbDevice);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->InstallProtocolInterface (
- &ImageHandle,
- &gAndroidFastbootTransportProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mTransportProtocol
- );
- return Status;
-}
diff --git a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf b/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf
deleted file mode 100644
index c5ada1a0be..0000000000
--- a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf
+++ /dev/null
@@ -1,46 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2013-2014, ARM Ltd. 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 = FastbootTransportUsbDxe
- FILE_GUID = f6bec3fe-88fb-11e3-ae84-e73b77561c35
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = FastbootTransportUsbEntryPoint
-
-[Sources.common]
- FastbootTransportUsb.c
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- MemoryAllocationLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
-
-[Protocols]
- gEfiDriverBindingProtocolGuid
- gUsbDeviceProtocolGuid
- gAndroidFastbootTransportProtocolGuid
- gEfiSimpleTextOutProtocolGuid
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[FixedPcd]
- gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbVendorId
- gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbProductId
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c b/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c
deleted file mode 100644
index b4be2a0789..0000000000
--- a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/** @file
-
- Copyright (c) 2015, ARM Ltd. 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 "FdtPlatform.h"
-
-#include <Library/PcdLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/BdsLib.h>
-
-#include <Protocol/DevicePath.h>
-
-//
-// Internal variables
-//
-
-STATIC CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolSetFdt = {
- L"setfdt", // Name of the command
- ShellDynCmdSetFdtHandler, // Handler
- ShellDynCmdSetFdtGetHelp // GetHelp
-};
-
-STATIC CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolDumpFdt = {
- L"dumpfdt", // Name of the command
- ShellDynCmdDumpFdtHandler, // Handler
- ShellDynCmdDumpFdtGetHelp // GetHelp
-};
-
-STATIC CONST EFI_GUID mFdtPlatformDxeHiiGuid = {
- 0x8afa7610, 0x62b1, 0x46aa,
- {0xb5, 0x34, 0xc3, 0xde, 0xff, 0x39, 0x77, 0x8c}
- };
-
-EFI_HANDLE mFdtPlatformDxeHiiHandle;
-
-/**
- Install the FDT specified by its device path in text form.
-
- @param[in] TextDevicePath Device path of the FDT to install in text form
-
- @retval EFI_SUCCESS The FDT was installed.
- @retval EFI_NOT_FOUND Failed to locate a protocol or a file.
- @retval EFI_INVALID_PARAMETER Invalid device path.
- @retval EFI_UNSUPPORTED Device path not supported.
- @retval EFI_OUT_OF_RESOURCES An allocation failed.
-**/
-STATIC
-EFI_STATUS
-InstallFdt (
- IN CONST CHAR16* TextDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;
- EFI_DEVICE_PATH *DevicePath;
- EFI_PHYSICAL_ADDRESS FdtBlobBase;
- UINTN FdtBlobSize;
- UINTN NumPages;
- EFI_PHYSICAL_ADDRESS FdtConfigurationTableBase;
-
- Status = gBS->LocateProtocol (
- &gEfiDevicePathFromTextProtocolGuid,
- NULL,
- (VOID **)&EfiDevicePathFromTextProtocol
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "InstallFdt() - Failed to locate EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol\n"));
- return Status;
- }
-
- DevicePath = (EFI_DEVICE_PATH*)EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (TextDevicePath);
- if (DevicePath == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Load the FDT given its device path.
- // This operation may fail if the device path is not supported.
- //
- FdtBlobBase = 0;
- NumPages = 0;
- Status = BdsLoadImage (DevicePath, AllocateAnyPages, &FdtBlobBase, &FdtBlobSize);
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- //
- // Ensure that the FDT header is valid and that the Size of the Device Tree
- // is smaller than the size of the read file
- //
- if (fdt_check_header ((VOID*)(UINTN)FdtBlobBase) != 0 ||
- (UINTN)fdt_totalsize ((VOID*)(UINTN)FdtBlobBase) > FdtBlobSize) {
- DEBUG ((EFI_D_ERROR, "InstallFdt() - loaded FDT binary image seems corrupt\n"));
- Status = EFI_LOAD_ERROR;
- goto Error;
- }
-
- //
- // Store the FDT as Runtime Service Data to prevent the Kernel from
- // overwritting its data.
- //
- NumPages = EFI_SIZE_TO_PAGES (FdtBlobSize);
- Status = gBS->AllocatePages (
- AllocateAnyPages, EfiRuntimeServicesData,
- NumPages, &FdtConfigurationTableBase
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
- CopyMem (
- (VOID*)(UINTN)FdtConfigurationTableBase,
- (VOID*)(UINTN)FdtBlobBase,
- FdtBlobSize
- );
-
- //
- // Install the FDT into the Configuration Table
- //
- Status = gBS->InstallConfigurationTable (
- &gFdtTableGuid,
- (VOID*)(UINTN)FdtConfigurationTableBase
- );
- if (EFI_ERROR (Status)) {
- gBS->FreePages (FdtConfigurationTableBase, NumPages);
- }
-
-Error:
- if (FdtBlobBase != 0) {
- gBS->FreePages (FdtBlobBase, NumPages);
- }
- FreePool (DevicePath);
-
- return Status;
-}
-
-/**
- Main entry point of the FDT platform driver.
-
- @param[in] ImageHandle The firmware allocated handle for the present driver
- UEFI image.
- @param[in] *SystemTable A pointer to the EFI System table.
-
- @retval EFI_SUCCESS The driver was initialized.
- @retval EFI_OUT_OF_RESOURCES The "End of DXE" event could not be allocated or
- there was not enough memory in pool to install
- the Shell Dynamic Command protocol.
- @retval EFI_LOAD_ERROR Unable to add the HII package.
-
-**/
-EFI_STATUS
-FdtPlatformEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
-
- //
- // Install the Device Tree from its expected location
- //
- Status = RunFdtInstallation (NULL);
-
- if (FeaturePcdGet (PcdOverridePlatformFdt) || FeaturePcdGet (PcdDumpFdtShellCommand)) {
- //
- // Register the strings for the user interface in the HII Database.
- // This shows the way to the multi-language support, even if
- // only the English language is actually supported. The strings to register
- // are stored in the "ShellSetFdtStrings[]" array. This array is
- // built by the building process from the "*.uni" file associated to
- // the present driver (cf. FdtPlatfromDxe.inf). Examine your Build
- // folder under your package's DEBUG folder and you will find the array
- // defined in a xxxStrDefs.h file.
- //
- mFdtPlatformDxeHiiHandle = HiiAddPackages (
- &mFdtPlatformDxeHiiGuid,
- ImageHandle,
- FdtPlatformDxeStrings,
- NULL
- );
- }
-
- //
- // If the development features are enabled, install the dynamic shell
- // command "setfdt" to be able to define a device path for the FDT
- // that has precedence over the device paths defined by
- // "PcdFdtDevicePaths".
- //
-
- if (FeaturePcdGet (PcdOverridePlatformFdt)) {
- if (mFdtPlatformDxeHiiHandle != NULL) {
- // We install dynamic EFI command on separate handles as we cannot register
- // more than one protocol of the same protocol interface on the same handle.
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiShellDynamicCommandProtocolGuid,
- &mShellDynCmdProtocolSetFdt,
- NULL
- );
- if (EFI_ERROR (Status)) {
- HiiRemovePackages (mFdtPlatformDxeHiiHandle);
- }
- } else {
- Status = EFI_LOAD_ERROR;
- }
- if (EFI_ERROR (Status)) {
- DEBUG ((
- EFI_D_WARN,
- "Unable to install \"setfdt\" EFI Shell command - %r \n",
- Status
- ));
- }
- }
-
- if (FeaturePcdGet (PcdDumpFdtShellCommand)) {
- if (mFdtPlatformDxeHiiHandle != NULL) {
- // We install dynamic EFI command on separate handles as we cannot register
- // more than one protocol of the same protocol interface on the same handle.
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiShellDynamicCommandProtocolGuid,
- &mShellDynCmdProtocolDumpFdt,
- NULL
- );
- if (EFI_ERROR (Status)) {
- HiiRemovePackages (mFdtPlatformDxeHiiHandle);
- }
- } else {
- Status = EFI_LOAD_ERROR;
- }
- if (EFI_ERROR (Status)) {
- DEBUG ((
- EFI_D_WARN,
- "Unable to install \"dumpfdt\" EFI Shell command - %r \n",
- Status
- ));
- }
- }
-
- return Status;
-}
-
-/**
- Run the FDT installation process.
-
- Loop in priority order over the device paths from which the FDT has
- been asked to be retrieved for. For each device path, try to install
- the FDT. Stop as soon as an installation succeeds.
-
- @param[in] SuccessfullDevicePath If not NULL, address where to store the
- pointer to the text device path from
- which the FDT was successfully retrieved.
- Not used if the FDT installation failed.
- The returned address is the address of
- an allocated buffer that has to be
- freed by the caller.
-
- @retval EFI_SUCCESS The FDT was installed.
- @retval EFI_NOT_FOUND Failed to locate a protocol or a file.
- @retval EFI_INVALID_PARAMETER Invalid device path.
- @retval EFI_UNSUPPORTED Device path not supported.
- @retval EFI_OUT_OF_RESOURCES An allocation failed.
-
-**/
-EFI_STATUS
-RunFdtInstallation (
- OUT CHAR16 **SuccessfullDevicePath
- )
-{
- EFI_STATUS Status;
- UINTN DataSize;
- CHAR16 *TextDevicePath;
- CHAR16 *TextDevicePathStart;
- CHAR16 *TextDevicePathSeparator;
- UINTN TextDevicePathLen;
-
- TextDevicePath = NULL;
- //
- // For development purpose, if enabled through the "PcdOverridePlatformFdt"
- // feature PCD, try first to install the FDT specified by the device path in
- // text form stored in the "Fdt" UEFI variable.
- //
- if (FeaturePcdGet (PcdOverridePlatformFdt)) {
- DataSize = 0;
- Status = gRT->GetVariable (
- L"Fdt",
- &gFdtVariableGuid,
- NULL,
- &DataSize,
- NULL
- );
-
- //
- // Keep going only if the "Fdt" variable is defined.
- //
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- TextDevicePath = AllocatePool (DataSize);
- if (TextDevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Error;
- }
-
- Status = gRT->GetVariable (
- L"Fdt",
- &gFdtVariableGuid,
- NULL,
- &DataSize,
- TextDevicePath
- );
- if (EFI_ERROR (Status)) {
- FreePool (TextDevicePath);
- goto Error;
- }
-
- Status = InstallFdt (TextDevicePath);
- if (!EFI_ERROR (Status)) {
- DEBUG ((
- EFI_D_WARN,
- "Installation of the FDT using the device path <%s> completed.\n",
- TextDevicePath
- ));
- goto Done;
- }
- DEBUG ((
- EFI_D_ERROR,
- "Installation of the FDT specified by the \"Fdt\" UEFI variable failed - %r\n",
- Status
- ));
- FreePool (TextDevicePath);
- }
- }
-
- //
- // Loop over the device path list provided by "PcdFdtDevicePaths". The device
- // paths are in text form and separated by a semi-colon.
- //
-
- Status = EFI_NOT_FOUND;
- for (TextDevicePathStart = (CHAR16*)PcdGetPtr (PcdFdtDevicePaths);
- *TextDevicePathStart != L'\0' ; ) {
- TextDevicePathSeparator = StrStr (TextDevicePathStart, L";");
-
- //
- // Last device path of the list
- //
- if (TextDevicePathSeparator == NULL) {
- TextDevicePathLen = StrLen (TextDevicePathStart);
- } else {
- TextDevicePathLen = (UINTN)(TextDevicePathSeparator - TextDevicePathStart);
- }
-
- TextDevicePath = AllocateCopyPool (
- (TextDevicePathLen + 1) * sizeof (CHAR16),
- TextDevicePathStart
- );
- if (TextDevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Error;
- }
- TextDevicePath[TextDevicePathLen] = L'\0';
-
- Status = InstallFdt (TextDevicePath);
- if (!EFI_ERROR (Status)) {
- DEBUG ((EFI_D_WARN, "Installation of the FDT using the device path <%s> completed.\n",
- TextDevicePath
- ));
- goto Done;
- }
-
- DEBUG ((EFI_D_WARN, "Installation of the FDT using the device path <%s> failed - %r.\n",
- TextDevicePath, Status
- ));
- FreePool (TextDevicePath);
-
- if (TextDevicePathSeparator == NULL) {
- goto Error;
- }
- TextDevicePathStart = TextDevicePathSeparator + 1;
- }
-
-Error:
-Done:
-
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Failed to install the FDT - %r.\n", Status));
- return Status;
- }
-
- if (SuccessfullDevicePath != NULL) {
- *SuccessfullDevicePath = TextDevicePath;
- } else {
- FreePool (TextDevicePath);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Transcode one of the EFI return code used by the model into an EFI Shell return code.
-
- @param[in] Status EFI return code.
-
- @return Transcoded EFI Shell return code.
-
-**/
-SHELL_STATUS
-EfiCodeToShellCode (
- IN EFI_STATUS Status
- )
-{
- SHELL_STATUS ShellStatus;
-
- switch (Status) {
- case EFI_SUCCESS :
- ShellStatus = SHELL_SUCCESS;
- break;
-
- case EFI_INVALID_PARAMETER :
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
-
- case EFI_UNSUPPORTED :
- ShellStatus = SHELL_UNSUPPORTED;
- break;
-
- case EFI_DEVICE_ERROR :
- ShellStatus = SHELL_DEVICE_ERROR;
- break;
-
- case EFI_WRITE_PROTECTED :
- case EFI_SECURITY_VIOLATION :
- ShellStatus = SHELL_ACCESS_DENIED;
- break;
-
- case EFI_OUT_OF_RESOURCES :
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- break;
-
- case EFI_NOT_FOUND :
- ShellStatus = SHELL_NOT_FOUND;
- break;
-
- default :
- ShellStatus = SHELL_ABORTED;
- }
-
- return ShellStatus;
-}
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.h b/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.h
deleted file mode 100644
index d49dd42c00..0000000000
--- a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/** @file
-
- Copyright (c) 2015, ARM Ltd. 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 __FDT_PLATFORM_DXE_H__
-#define __FDT_PLATFORM_DXE_H__
-
-#include <Uefi.h>
-
-#include <Protocol/DevicePathToText.h>
-#include <Protocol/DevicePathFromText.h>
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellDynamicCommand.h>
-
-#include <Library/DebugLib.h>
-#include <Library/HiiLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/ShellLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-#include <Guid/Fdt.h>
-
-#include <libfdt.h>
-
-extern EFI_HANDLE mFdtPlatformDxeHiiHandle;
-
-/**
- Transcode one of the EFI return code used by the model into an EFI Shell return code.
-
- @param[in] Status EFI return code.
-
- @return Transcoded EFI Shell return code.
-
-**/
-SHELL_STATUS
-EfiCodeToShellCode (
- IN EFI_STATUS Status
- );
-
-/**
- Run the FDT installation process.
-
- Loop in priority order over the device paths from which the FDT has
- been asked to be retrieved for. For each device path, try to install
- the FDT. Stop as soon as an installation succeeds.
-
- @param[in] SuccessfullDevicePath If not NULL, address where to store the
- pointer to the text device path from
- which the FDT was successfully retrieved.
- Not used if the FDT installation failed.
- The returned address is the address of
- an allocated buffer that has to be
- freed by the caller.
-
- @retval EFI_SUCCESS The FDT was installed.
- @retval EFI_NOT_FOUND Failed to locate a protocol or a file.
- @retval EFI_INVALID_PARAMETER Invalid device path.
- @retval EFI_UNSUPPORTED Device path not supported.
- @retval EFI_OUT_OF_RESOURCES An allocation failed.
-
-**/
-EFI_STATUS
-RunFdtInstallation (
- OUT CHAR16 **SuccessfullDevicePath
- );
-
-/**
- This is the shell command "setfdt" handler function. This function handles
- the command when it is invoked in the shell.
-
- @param[in] This The instance of the
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] SystemTable The pointer to the UEFI system table.
- @param[in] ShellParameters The parameters associated with the command.
- @param[in] Shell The instance of the shell protocol used in the
- context of processing this command.
-
- @return SHELL_SUCCESS The operation was successful.
- @return SHELL_ABORTED Operation aborted due to internal error.
- @return SHELL_INVALID_PARAMETER The parameters of the command are not valid.
- @return SHELL_INVALID_PARAMETER The EFI Shell file path is not valid.
- @return SHELL_NOT_FOUND Failed to locate a protocol or a file.
- @return SHELL_UNSUPPORTED Device path not supported.
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.
- @return SHELL_DEVICE_ERROR The "Fdt" variable could not be saved due to a hardware failure.
- @return SHELL_ACCESS_DENIED The "Fdt" variable is read-only.
- @return SHELL_ACCESS_DENIED The "Fdt" variable cannot be deleted.
- @return SHELL_ACCESS_DENIED The "Fdt" variable could not be written due to security violation.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellDynCmdSetFdtHandler (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
- IN EFI_SHELL_PROTOCOL *Shell
- );
-
-/**
- This is the shell command "setfdt" help handler function. This
- function returns the formatted help for the "setfdt" command.
- The format matchs that in Appendix B of the revision 2.1 of the
- UEFI Shell Specification.
-
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] Language The pointer to the language string to use.
-
- @return CHAR16* Pool allocated help string, must be freed by caller.
-**/
-CHAR16*
-EFIAPI
-ShellDynCmdSetFdtGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
- );
-
-/**
- This is the shell command "dumpfdt" handler function. This function handles
- the command when it is invoked in the shell.
-
- @param[in] This The instance of the
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] SystemTable The pointer to the UEFI system table.
- @param[in] ShellParameters The parameters associated with the command.
- @param[in] Shell The instance of the shell protocol used in the
- context of processing this command.
-
- @return SHELL_SUCCESS The operation was successful.
- @return SHELL_ABORTED Operation aborted due to internal error.
- @return SHELL_NOT_FOUND Failed to locate the Device Tree into the EFI Configuration Table
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellDynCmdDumpFdtHandler (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
- IN EFI_SHELL_PROTOCOL *Shell
- );
-
-/**
- This is the shell command "dumpfdt" help handler function. This
- function returns the formatted help for the "dumpfdt" command.
- The format matchs that in Appendix B of the revision 2.1 of the
- UEFI Shell Specification.
-
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] Language The pointer to the language string to use.
-
- @return CHAR16* Pool allocated help string, must be freed by caller.
-**/
-CHAR16*
-EFIAPI
-ShellDynCmdDumpFdtGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
- );
-
-#endif /* __FDT_PLATFORM_DXE_H__ */
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf b/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf
deleted file mode 100644
index f743585331..0000000000
--- a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf
+++ /dev/null
@@ -1,64 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2015, ARM Ltd. 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 = 0x00010006
- BASE_NAME = FdtPlatformDxe
- MODULE_UNI_FILE = FdtPlatformDxe.uni
- FILE_GUID = 6e9a4c69-57c6-4fcd-b083-4f2c3bdb6051
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 0.1
- ENTRY_POINT = FdtPlatformEntryPoint
-
-[Sources.common]
- FdtPlatform.c
- FdtPlatformDxe.uni
- ShellDumpFdt.c
- ShellSetFdt.c
-
-[Packages]
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ShellPkg/ShellPkg.dec
-
-[LibraryClasses]
- UefiDriverEntryPoint
- BdsLib
- DxeServicesTableLib
- BaseMemoryLib
- DebugLib
- FdtLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- HiiLib
- ShellLib
-
-[Protocols]
- gEfiDevicePathToTextProtocolGuid
- gEfiDevicePathFromTextProtocolGuid
- gEfiShellDynamicCommandProtocolGuid
-
-[Guids]
- gEfiEndOfDxeEventGroupGuid
- gFdtTableGuid
- gFdtVariableGuid
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdOverridePlatformFdt
- gEmbeddedTokenSpaceGuid.PcdDumpFdtShellCommand
-
-[Pcd]
- gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.uni b/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.uni
deleted file mode 100644
index 876c6c04ac..0000000000
--- a/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.uni
+++ /dev/null
Binary files differ
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/README.txt b/EmbeddedPkg/Drivers/FdtPlatformDxe/README.txt
deleted file mode 100644
index a87e7db28d..0000000000
--- a/EmbeddedPkg/Drivers/FdtPlatformDxe/README.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-/** @file
-
- Copyright (c) 2015, ARM Ltd. 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.
-
-**/
-
-The purpose of the FdtPlatformDxe UEFI driver is to install the Flat Device
-Tree (FDT) of the platform the UEFI frimware is running on into the UEFI
-Configuration Table. The FDT is identified within the UEFI Configuration
-Table by the "gFdtTableGuid" GUID defined in "EmbeddedPkg.dec".
-
-Once installed, an UEFI application or OS boot loader can get from the UEFI
-Configuration Table the FDT of the platform from the "gFdtTableGuid" GUID.
-
-The installation is done after each boot at the end of the DXE phase,
-just before the BDS phase. It is done at the end of the DXE phase to be sure
-that all drivers have been dispatched. That way, all UEFI protocols that may
-be needed to retrieve the FDT can be made available. It is done before the BDS
-phase to be able to provide the FDT during that phase.
-
-The present driver tries to retrieve the FDT from the device paths defined in the
-"gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths" PCD. The "PcdFdtDevicePaths" PCD
-contains a list a device paths. The device paths are in the text form and
-separated by semi-colons. The present driver tries the device paths in the order
-it finds them in the "PcdFdtDevicePaths" PCD as long as he did not install
-succesfully a FDT.
-
-The "PcdFdtDevicePaths" PCD is a dynamic PCD that can be modified during the
-DXE phase. This allows for exemple to select the right FDT when a binary is
-intended to run on several platforms and/or variants of a platform.
-
-If the driver manages to download a FDT from one of the device paths mentioned
-above then it installs it in the UEFI Configuration table and the run over the
-device paths is stopped.
-
-For development purposes only, if the feature PCD "gEmbeddedTokenSpaceGuid.
-PcdOverridePlatformFdt" is equal to TRUE, then before to try to install the
-FDT from the device paths listed in the "PcdFdtDevicePaths" PCD, the present
-driver tries to install it using the device path defined by the UEFI variable
-"Fdt". If the variable does not exist or the installation using the device path
-defined by the UEFI variable fails then the installation proceeds as described
-above.
-
-Furthermore and again for development purposes only, if the feature PCD
-"PcdOverridePlatformFdt" is equal to TRUE, the current driver provides the EFI
-Shell command "setfdt" to define the location of the FDT by the mean of an EFI
-Shell file path (like "fs2:\boot\fdt.dtb") or a device path.
-
-If the path passed in to the command is a valid EFI Shell file path, the
-command translates it into the corresponding device path and stores that
-device path in the "Fdt" UEFI variable asking for the variable to be non
-volatile.
-
-If the path passed in to the command is not recognised as a valid EFI
-Shell device path, the command handles it as device path and stored
-in the "Fdt" UEFI variable as it is.
-
-Finally, the "-i" option of the "setfdt" command allows to trigger the FDT
-installation process. The installation process is completed when the command
-returns. The command can be invoked with the "-i" option only and in that
-case the "Fdt" UEFI variable is not updated and the command just runs the
-FDT installation process. If the command is invoked with the "-i" option and
-an EFI Shell file path then first the "Fdt" UEFI variable is updated accordingly
-and then the FDT installation process is run.
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellDumpFdt.c b/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellDumpFdt.c
deleted file mode 100644
index c7dc898568..0000000000
--- a/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellDumpFdt.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/** @file
-
- Copyright (c) 2015, ARM Ltd. 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 "FdtPlatform.h"
-
-#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
-#define PALIGN(p, a) ((void *)(ALIGN ((unsigned long)(p), (a))))
-#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4)))
-
-STATIC
-UINTN
-IsPrintableString (
- IN CONST VOID* data,
- IN UINTN len
- )
-{
- CONST CHAR8 *s = data;
- CONST CHAR8 *ss;
-
- // Zero length is not
- if (len == 0) {
- return 0;
- }
-
- // Must terminate with zero
- if (s[len - 1] != '\0') {
- return 0;
- }
-
- ss = s;
- while (*s/* && isprint (*s)*/) {
- s++;
- }
-
- // Not zero, or not done yet
- if (*s != '\0' || (s + 1 - ss) < len) {
- return 0;
- }
-
- return 1;
-}
-
-STATIC
-VOID
-PrintData (
- IN CONST CHAR8* data,
- IN UINTN len
- )
-{
- UINTN i;
- CONST CHAR8 *p = data;
-
- // No data, don't print
- if (len == 0)
- return;
-
- if (IsPrintableString (data, len)) {
- Print (L" = \"%a\"", (const char *)data);
- } else if ((len % 4) == 0) {
- Print (L" = <");
- for (i = 0; i < len; i += 4) {
- Print (L"0x%08x%a", fdt32_to_cpu (GET_CELL (p)), i < (len - 4) ? " " : "");
- }
- Print (L">");
- } else {
- Print (L" = [");
- for (i = 0; i < len; i++)
- Print (L"%02x%a", *p++, i < len - 1 ? " " : "");
- Print (L"]");
- }
-}
-
-STATIC
-VOID
-DumpFdt (
- IN VOID* FdtBlob
- )
-{
- struct fdt_header *bph;
- UINT32 off_dt;
- UINT32 off_str;
- CONST CHAR8* p_struct;
- CONST CHAR8* p_strings;
- CONST CHAR8* p;
- CONST CHAR8* s;
- CONST CHAR8* t;
- UINT32 tag;
- UINTN sz;
- UINTN depth;
- UINTN shift;
- UINT32 version;
-
- {
- // Can 'memreserve' be printed by below code?
- INTN num = fdt_num_mem_rsv (FdtBlob);
- INTN i, err;
- UINT64 addr = 0, size = 0;
-
- for (i = 0; i < num; i++) {
- err = fdt_get_mem_rsv (FdtBlob, i, &addr, &size);
- if (err) {
- DEBUG ((EFI_D_ERROR, "Error (%d) : Cannot get memreserve section (%d)\n", err, i));
- }
- else {
- Print (L"/memreserve/ \t0x%lx \t0x%lx;\n", addr, size);
- }
- }
- }
-
- depth = 0;
- shift = 4;
-
- bph = FdtBlob;
- off_dt = fdt32_to_cpu (bph->off_dt_struct);
- off_str = fdt32_to_cpu (bph->off_dt_strings);
- p_struct = (CONST CHAR8*)FdtBlob + off_dt;
- p_strings = (CONST CHAR8*)FdtBlob + off_str;
- version = fdt32_to_cpu (bph->version);
-
- p = p_struct;
- while ((tag = fdt32_to_cpu (GET_CELL (p))) != FDT_END) {
- if (tag == FDT_BEGIN_NODE) {
- s = p;
- p = PALIGN (p + AsciiStrLen (s) + 1, 4);
-
- if (*s == '\0')
- s = "/";
-
- Print (L"%*s%a {\n", depth * shift, L" ", s);
-
- depth++;
- continue;
- }
-
- if (tag == FDT_END_NODE) {
- depth--;
-
- Print (L"%*s};\n", depth * shift, L" ");
- continue;
- }
-
- if (tag == FDT_NOP) {
- Print (L"%*s// [NOP]\n", depth * shift, L" ");
- continue;
- }
-
- if (tag != FDT_PROP) {
- Print (L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag);
- break;
- }
- sz = fdt32_to_cpu (GET_CELL (p));
- s = p_strings + fdt32_to_cpu (GET_CELL (p));
- if (version < 16 && sz >= 8)
- p = PALIGN (p, 8);
- t = p;
-
- p = PALIGN (p + sz, 4);
-
- Print (L"%*s%a", depth * shift, L" ", s);
- PrintData (t, sz);
- Print (L";\n");
- }
-}
-
-/**
- This is the shell command "dumpfdt" handler function. This function handles
- the command when it is invoked in the shell.
-
- @param[in] This The instance of the
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] SystemTable The pointer to the UEFI system table.
- @param[in] ShellParameters The parameters associated with the command.
- @param[in] Shell The instance of the shell protocol used in the
- context of processing this command.
-
- @return SHELL_SUCCESS The operation was successful.
- @return SHELL_ABORTED Operation aborted due to internal error.
- @return SHELL_NOT_FOUND Failed to locate the Device Tree into the EFI Configuration Table
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellDynCmdDumpFdtHandler (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
- IN EFI_SHELL_PROTOCOL *Shell
- )
-{
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- VOID *FdtBlob;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // Install the Shell and Shell Parameters Protocols on the driver
- // image. This is necessary for the initialisation of the Shell
- // Library to succeed in the next step.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &gImageHandle,
- &gEfiShellProtocolGuid, Shell,
- &gEfiShellParametersProtocolGuid, ShellParameters,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return SHELL_ABORTED;
- }
-
- //
- // Initialise the Shell Library as we are going to use it.
- // Assert that the return code is EFI_SUCCESS as it should.
- // To anticipate any change is the codes returned by
- // ShellInitialize(), leave in case of error.
- //
- Status = ShellInitialize ();
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return SHELL_ABORTED;
- }
-
- Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &FdtBlob);
- if (EFI_ERROR (Status)) {
- Print (L"ERROR: Did not find the Fdt Blob.\n");
- return EfiCodeToShellCode (Status);
- }
-
- DumpFdt (FdtBlob);
-
- gBS->UninstallMultipleProtocolInterfaces (
- gImageHandle,
- &gEfiShellProtocolGuid, Shell,
- &gEfiShellParametersProtocolGuid, ShellParameters,
- NULL
- );
-
- return ShellStatus;
-}
-
-/**
- This is the shell command "dumpfdt" help handler function. This
- function returns the formatted help for the "dumpfdt" command.
- The format matchs that in Appendix B of the revision 2.1 of the
- UEFI Shell Specification.
-
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] Language The pointer to the language string to use.
-
- @return CHAR16* Pool allocated help string, must be freed by caller.
-**/
-CHAR16*
-EFIAPI
-ShellDynCmdDumpFdtGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
- )
-{
- //
- // This allocates memory. The caller has to free the allocated memory.
- //
- return HiiGetString (
- mFdtPlatformDxeHiiHandle,
- STRING_TOKEN (STR_GET_HELP_DUMPFDT),
- Language
- );
-}
diff --git a/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellSetFdt.c b/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellSetFdt.c
deleted file mode 100644
index 9be23c8455..0000000000
--- a/EmbeddedPkg/Drivers/FdtPlatformDxe/ShellSetFdt.c
+++ /dev/null
@@ -1,468 +0,0 @@
-/** @file
-
- Copyright (c) 2015, ARM Ltd. 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 "FdtPlatform.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-i", TypeFlag },
- {NULL , TypeMax }
-};
-
-/**
- Display FDT device paths.
-
- Display in text form the device paths used to install the FDT from the
- highest to the lowest priority.
-
-**/
-STATIC
-VOID
-DisplayFdtDevicePaths (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN DataSize;
- CHAR16 *TextDevicePath;
- CHAR16 *TextDevicePaths;
- CHAR16 *TextDevicePathSeparator;
-
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_DEVICE_PATH_LIST),
- mFdtPlatformDxeHiiHandle
- );
-
- if (FeaturePcdGet (PcdOverridePlatformFdt)) {
- DataSize = 0;
- Status = gRT->GetVariable (
- L"Fdt",
- &gFdtVariableGuid,
- NULL,
- &DataSize,
- NULL
- );
-
- //
- // Keep going only if the "Fdt" variable is defined.
- //
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- TextDevicePath = AllocatePool (DataSize);
- if (TextDevicePath == NULL) {
- return;
- }
-
- Status = gRT->GetVariable (
- L"Fdt",
- &gFdtVariableGuid,
- NULL,
- &DataSize,
- TextDevicePath
- );
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_DEVICE_PATH),
- mFdtPlatformDxeHiiHandle,
- TextDevicePath
- );
- }
-
- FreePool (TextDevicePath);
- }
- }
-
- //
- // Loop over the device path list provided by "PcdFdtDevicePaths". The device
- // paths are in text form and separated by a semi-colon.
- //
-
- TextDevicePaths = AllocateCopyPool (
- StrSize ((CHAR16*)PcdGetPtr (PcdFdtDevicePaths)),
- (CHAR16*)PcdGetPtr (PcdFdtDevicePaths)
- );
- if (TextDevicePaths == NULL) {
- return;
- }
-
- for (TextDevicePath = TextDevicePaths;
- *TextDevicePath != L'\0' ; ) {
- TextDevicePathSeparator = StrStr (TextDevicePath, L";");
-
- if (TextDevicePathSeparator != NULL) {
- *TextDevicePathSeparator = L'\0';
- }
-
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_DEVICE_PATH),
- mFdtPlatformDxeHiiHandle,
- TextDevicePath
- );
-
- if (TextDevicePathSeparator == NULL) {
- break;
- }
- TextDevicePath = TextDevicePathSeparator + 1;
- }
-
- FreePool (TextDevicePaths);
-}
-
-/**
- Update the text device path stored in the "Fdt" UEFI variable given
- an EFI Shell file path or a text device path.
-
- This function is a subroutine of the ShellDynCmdSetFdtHandler() function
- to make its code easier to read.
-
- @param[in] Shell The instance of the shell protocol used in the
- context of processing the "setfdt" command.
- @param[in] FilePath EFI Shell path or the device path to the FDT file.
-
- @return SHELL_SUCCESS The text device path was succesfully updated.
- @return SHELL_INVALID_PARAMETER The Shell file path is not valid.
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.
- @return SHELL_DEVICE_ERROR The "Fdt" variable could not be saved due to a hardware failure.
- @return SHELL_ACCESS_DENIED The "Fdt" variable is read-only.
- @return SHELL_ACCESS_DENIED The "Fdt" variable cannot be deleted.
- @return SHELL_ACCESS_DENIED The "Fdt" variable could not be written due to security violation.
- @return SHELL_NOT_FOUND Device path to text protocol not found.
- @return SHELL_ABORTED Operation aborted.
-
-**/
-STATIC
-SHELL_STATUS
-UpdateFdtTextDevicePath (
- IN EFI_SHELL_PROTOCOL *Shell,
- IN CONST CHAR16 *FilePath
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH *DevicePath;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *EfiDevicePathToTextProtocol;
- CHAR16 *TextDevicePath;
- CHAR16 *FdtVariableValue;
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;
- SHELL_STATUS ShellStatus;
-
- ASSERT (FilePath != NULL);
- DevicePath = NULL;
- TextDevicePath = NULL;
- FdtVariableValue = NULL;
-
- if (*FilePath != L'\0') {
- DevicePath = Shell->GetDevicePathFromFilePath (FilePath);
- if (DevicePath != NULL) {
- Status = gBS->LocateProtocol (
- &gEfiDevicePathToTextProtocolGuid,
- NULL,
- (VOID **)&EfiDevicePathToTextProtocol
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- TextDevicePath = EfiDevicePathToTextProtocol->ConvertDevicePathToText (
- DevicePath,
- FALSE,
- FALSE
- );
- if (TextDevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Error;
- }
- FdtVariableValue = TextDevicePath;
- } else {
- //
- // Try to convert back the EFI Device Path String into a EFI device Path
- // to ensure the format is valid
- //
- Status = gBS->LocateProtocol (
- &gEfiDevicePathFromTextProtocolGuid,
- NULL,
- (VOID **)&EfiDevicePathFromTextProtocol
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- DevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (
- FilePath
- );
- if (DevicePath == NULL) {
- Status = EFI_INVALID_PARAMETER;
- goto Error;
- }
- FdtVariableValue = (CHAR16*)FilePath;
- }
- }
-
- Status = gRT->SetVariable (
- (CHAR16*)L"Fdt",
- &gFdtVariableGuid,
- EFI_VARIABLE_RUNTIME_ACCESS |
- EFI_VARIABLE_NON_VOLATILE |
- EFI_VARIABLE_BOOTSERVICE_ACCESS ,
- (FdtVariableValue != NULL) ?
- StrSize (FdtVariableValue) : 0,
- FdtVariableValue
- );
-
-Error:
- ShellStatus = EfiCodeToShellCode (Status);
- if (!EFI_ERROR (Status)) {
- if (FdtVariableValue != NULL) {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_UPDATE_SUCCEEDED),
- mFdtPlatformDxeHiiHandle,
- FdtVariableValue
- );
- } else {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_UPDATE_DELETED),
- mFdtPlatformDxeHiiHandle
- );
- }
- } else {
- if (Status == EFI_INVALID_PARAMETER) {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_INVALID_PATH),
- mFdtPlatformDxeHiiHandle,
- FilePath
- );
- } else {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_ERROR),
- mFdtPlatformDxeHiiHandle,
- Status
- );
- }
- }
-
- if (DevicePath != NULL) {
- FreePool (DevicePath);
- }
- if (TextDevicePath != NULL) {
- FreePool (TextDevicePath);
- }
-
- return ShellStatus;
-}
-
-/**
- This is the shell command "setfdt" handler function. This function handles
- the command when it is invoked in the shell.
-
- @param[in] This The instance of the
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] SystemTable The pointer to the UEFI system table.
- @param[in] ShellParameters The parameters associated with the command.
- @param[in] Shell The instance of the shell protocol used in the
- context of processing this command.
-
- @return SHELL_SUCCESS The operation was successful.
- @return SHELL_ABORTED Operation aborted due to internal error.
- @return SHELL_INVALID_PARAMETER The parameters of the command are not valid.
- @return SHELL_INVALID_PARAMETER The EFI Shell file path is not valid.
- @return SHELL_NOT_FOUND Failed to locate a protocol or a file.
- @return SHELL_UNSUPPORTED Device path not supported.
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.
- @return SHELL_DEVICE_ERROR The "Fdt" variable could not be saved due to a hardware failure.
- @return SHELL_ACCESS_DENIED The "Fdt" variable is read-only.
- @return SHELL_ACCESS_DENIED The "Fdt" variable cannot be deleted.
- @return SHELL_ACCESS_DENIED The "Fdt" variable could not be written due to security violation.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellDynCmdSetFdtHandler (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
- IN EFI_SHELL_PROTOCOL *Shell
- )
-{
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- LIST_ENTRY *ParamPackage;
- BOOLEAN FilePath;
- CONST CHAR16 *ValueStr;
- CHAR16 *TextDevicePath;
-
- ShellStatus = SHELL_SUCCESS;
- ParamPackage = NULL;
- FilePath = FALSE;
-
- //
- // Install the Shell and Shell Parameters Protocols on the driver
- // image. This is necessary for the initialisation of the Shell
- // Library to succeed in the next step.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &gImageHandle,
- &gEfiShellProtocolGuid, Shell,
- &gEfiShellParametersProtocolGuid, ShellParameters,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return SHELL_ABORTED;
- }
-
- //
- // Initialise the Shell Library as we are going to use it.
- // Assert that the return code is EFI_SUCCESS as it should.
- // To anticipate any change is the codes returned by
- // ShellInitialize(), leave in case of error.
- //
- Status = ShellInitialize ();
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return SHELL_ABORTED;
- }
-
- Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
- if (!EFI_ERROR (Status)) {
- switch (ShellCommandLineGetCount (ParamPackage)) {
- case 1:
- //
- // Case "setfdt" or "setfdt -i"
- //
- if (!ShellCommandLineGetFlag (ParamPackage, L"-i")) {
- DisplayFdtDevicePaths ();
- }
- break;
-
- case 2:
- //
- // Case "setfdt file_path" or
- // "setfdt -i file_path" or
- // "setfdt file_path -i"
- //
- FilePath = TRUE;
- break;
-
- default:
- Status = EFI_INVALID_PARAMETER;
- }
- }
- if (EFI_ERROR (Status)) {
- ShellStatus = EfiCodeToShellCode (Status);
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_ERROR),
- mFdtPlatformDxeHiiHandle,
- Status
- );
- goto Error;
- }
-
- //
- // Update the preferred device path for the FDT if asked for.
- //
- if (FilePath) {
- ValueStr = ShellCommandLineGetRawValue (ParamPackage, 1);
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_UPDATING),
- mFdtPlatformDxeHiiHandle
- );
- ShellStatus = UpdateFdtTextDevicePath (Shell, ValueStr);
- if (ShellStatus != SHELL_SUCCESS) {
- goto Error;
- }
- }
-
- //
- // Run the FDT installation process if asked for.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-i")) {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_INSTALLING),
- mFdtPlatformDxeHiiHandle
- );
- Status = RunFdtInstallation (&TextDevicePath);
- ShellStatus = EfiCodeToShellCode (Status);
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_INSTALL_SUCCEEDED),
- mFdtPlatformDxeHiiHandle,
- TextDevicePath
- );
- FreePool (TextDevicePath);
- } else {
- if (Status == EFI_INVALID_PARAMETER) {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_INVALID_DEVICE_PATH),
- mFdtPlatformDxeHiiHandle
- );
- } else {
- ShellPrintHiiEx (
- -1, -1, NULL,
- STRING_TOKEN (STR_SETFDT_ERROR),
- mFdtPlatformDxeHiiHandle,
- Status
- );
- }
- DisplayFdtDevicePaths ();
- }
- }
-
-Error:
- gBS->UninstallMultipleProtocolInterfaces (
- gImageHandle,
- &gEfiShellProtocolGuid, Shell,
- &gEfiShellParametersProtocolGuid, ShellParameters,
- NULL
- );
- ShellCommandLineFreeVarList (ParamPackage);
-
- return ShellStatus;
-}
-
-/**
- This is the shell command "setfdt" help handler function. This
- function returns the formatted help for the "setfdt" command.
- The format matchs that in Appendix B of the revision 2.1 of the
- UEFI Shell Specification.
-
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
- @param[in] Language The pointer to the language string to use.
-
- @return CHAR16* Pool allocated help string, must be freed by caller.
-**/
-CHAR16*
-EFIAPI
-ShellDynCmdSetFdtGetHelp (
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
- IN CONST CHAR8 *Language
- )
-{
- //
- // This allocates memory. The caller has to free the allocated memory.
- //
- return HiiGetString (
- mFdtPlatformDxeHiiHandle,
- STRING_TOKEN (STR_GET_HELP_SETFDT),
- Language
- );
-}
diff --git a/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.c b/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.c
deleted file mode 100644
index dfc3786297..0000000000
--- a/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.c
+++ /dev/null
@@ -1,635 +0,0 @@
-/** @file
-
- Copyright (c) 2013-2015, ARM Ltd. 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 <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-#include <IndustryStandard/Usb.h>
-
-#include <Protocol/UsbDevice.h>
-
-#include "Isp1761UsbDxe.h"
-
-/*
- Driver for using the NXP ISP1761 as a USB Peripheral controller.
- Doesn't use USB OTG - just sets it in Pure Peripheral mode.
-
- The ISP1582 datasheet has a little more info on the Peripheral controller
- registers than the ISP1761 datasheet
-
- We don't do string descriptors. They're optional.
- We currently assume the device has one configuration, one interface, one IN
- endpoint, and one OUT endpoint (plus the default control endpoint).
-
- In fact, this driver is the minimum required to implement fastboot.
-*/
-
-// TODO Make sure the controller isn't sending empty packets when it shouldn't
-// (check behaviour in cases when Buffer Length isn't explcitly set)
-
-// ISP1582 Datasheet:
-// "Data transfers preceding the status stage must first be fully
-// completed before the STATUS bit can be set."
-// This variable stores whether some control data has been pended in the EP0TX
-// Tx buffer, so that when an EP0TX interrupt is received we can set the STATUS
-// bit to go to the Status stage of the control transfer.
-STATIC BOOLEAN mControlTxPending = FALSE;
-
-STATIC USB_DEVICE_DESCRIPTOR *mDeviceDescriptor;
-
-// The config descriptor, interface descriptor, and endpoint descriptors in a
-// buffer (in that order)
-STATIC VOID *mDescriptors;
-// Convenience pointers to those descriptors inside the buffer:
-STATIC USB_INTERFACE_DESCRIPTOR *mInterfaceDescriptor;
-STATIC USB_CONFIG_DESCRIPTOR *mConfigDescriptor;
-STATIC USB_ENDPOINT_DESCRIPTOR *mEndpointDescriptors;
-
-STATIC USB_DEVICE_RX_CALLBACK mDataReceivedCallback;
-STATIC USB_DEVICE_TX_CALLBACK mDataSentCallback;
-
-// The time between interrupt polls, in units of 100 nanoseconds
-// 10 Microseconds
-#define ISP1761_INTERRUPT_POLL_PERIOD 10000
-
-STATIC
-VOID
-SelectEndpoint (
- IN UINT8 Endpoint
- )
-{
- // The DMA Endpoint Index must not point to the same as the
- // Endpoint Index Register.
- WRITE_REG32 (ISP1761_DMA_ENDPOINT_INDEX, ((Endpoint + 2) % ISP1761_NUM_ENDPOINTS));
- WRITE_REG32 (ISP1761_ENDPOINT_INDEX, Endpoint);
-}
-
-// Enable going to the Data stage of a control transfer
-STATIC
-VOID
-DataStageEnable (
- IN UINT8 Endpoint
- )
-{
- SelectEndpoint (Endpoint);
- WRITE_REG32 (ISP1761_CTRL_FUNCTION, ISP1761_CTRL_FUNCTION_DSEN);
-}
-
-// Go to the Status stage of a successful control transfer
-STATIC
-VOID
-StatusAcknowledge (
- IN UINT8 Endpoint
-)
-{
- SelectEndpoint (Endpoint);
- WRITE_REG32 (ISP1761_CTRL_FUNCTION, ISP1761_CTRL_FUNCTION_STATUS);
-}
-
-// Read the FIFO for the endpoint indexed by Endpoint, into the buffer pointed
-// at by Buffer, whose size is *Size bytes.
-//
-// If *Size is less than the number of bytes in the FIFO, return EFI_BUFFER_TOO_SMALL
-//
-// Update *Size with the number of bytes of data in the FIFO.
-STATIC
-EFI_STATUS
-ReadEndpointBuffer (
- IN UINT8 Endpoint,
- IN OUT UINTN *Size,
- IN OUT VOID *Buffer
- )
-{
- UINT16 NumBytesAvailable;
- UINT32 Val32;
- UINTN Index;
- UINTN NumBytesRead;
-
- SelectEndpoint (Endpoint);
-
- NumBytesAvailable = READ_REG16 (ISP1761_BUFFER_LENGTH);
-
- if (NumBytesAvailable > *Size) {
- *Size = NumBytesAvailable;
- return EFI_BUFFER_TOO_SMALL;
- }
- *Size = NumBytesAvailable;
-
- /* -- NB! --
- The datasheet says the Data Port is 16 bits but it actually appears to
- be 32 bits.
- */
-
- // Read 32-bit chunks
- for (Index = 0; Index < NumBytesAvailable / 4; Index++) {
- ((UINT32 *) Buffer)[Index] = READ_REG32 (ISP1761_DATA_PORT);
- }
-
- // Read remaining bytes
-
- // Round NumBytesAvailable down to nearest power of 4
- NumBytesRead = NumBytesAvailable & (~0x3);
- if (NumBytesRead != NumBytesAvailable) {
- Val32 = READ_REG32 (ISP1761_DATA_PORT);
- // Copy each required byte of 32-bit word into buffer
- for (Index = 0; Index < NumBytesAvailable % 4; Index++) {
- ((UINT8 *) Buffer)[NumBytesRead + Index] = Val32 >> (Index * 8);
- }
- }
- return EFI_SUCCESS;
-}
-
-/*
- Write an endpoint buffer. Parameters:
- Endpoint Endpoint index (see Endpoint Index Register in datasheet)
- MaxPacketSize The MaxPacketSize this endpoint is configured for
- Size The size of the Buffer
- Buffer The data
-
- Assumes MaxPacketSize is a multiple of 4.
- (It seems that all valid values for MaxPacketSize _are_ multiples of 4)
-*/
-STATIC
-EFI_STATUS
-WriteEndpointBuffer (
- IN UINT8 Endpoint,
- IN UINTN MaxPacketSize,
- IN UINTN Size,
- IN CONST VOID *Buffer
- )
-{
- UINTN Index;
- UINT32 *DwordBuffer;
-
- DwordBuffer = (UINT32 *) Buffer;
- SelectEndpoint (Endpoint);
-
- /* -- NB! --
- The datasheet says the Data Port is 16 bits but it actually appears to
- be 32 bits.
- */
-
- // Write packets of size MaxPacketSize
- while (Size > MaxPacketSize) {
- for (Index = 0; Index < MaxPacketSize / 4; Index++) {
- WRITE_REG32 (ISP1761_DATA_PORT, DwordBuffer[Index]);
- }
- Size -= MaxPacketSize;
- DwordBuffer += (MaxPacketSize / sizeof (UINT32));
- }
-
- // Write remaining data
-
- if (Size > 0) {
- WRITE_REG32 (ISP1761_BUFFER_LENGTH, Size);
-
- while (Size > 4) {
- WRITE_REG32 (ISP1761_DATA_PORT, DwordBuffer[0]);
- Size -= 4;
- DwordBuffer++;
- }
-
- if (Size > 0) {
- WRITE_REG32 (ISP1761_DATA_PORT, DwordBuffer[0]);
- }
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-HandleGetDescriptor (
- IN USB_DEVICE_REQUEST *Request
- )
-{
- EFI_STATUS Status;
- UINT8 DescriptorType;
- UINTN ResponseSize;
- VOID *ResponseData;
-
- ResponseSize = 0;
- ResponseData = NULL;
- Status = EFI_SUCCESS;
-
- // Pretty confused if bmRequestType is anything but this:
- ASSERT (Request->RequestType == USB_DEV_GET_DESCRIPTOR_REQ_TYPE);
-
- // Choose the response
- DescriptorType = Request->Value >> 8;
- switch (DescriptorType) {
- case USB_DESC_TYPE_DEVICE:
- DEBUG ((EFI_D_INFO, "USB: Got a request for device descriptor\n"));
- ResponseSize = sizeof (USB_DEVICE_DESCRIPTOR);
- ResponseData = mDeviceDescriptor;
- break;
- case USB_DESC_TYPE_CONFIG:
- DEBUG ((EFI_D_INFO, "USB: Got a request for config descriptor\n"));
- ResponseSize = mConfigDescriptor->TotalLength;
- ResponseData = mDescriptors;
- break;
- case USB_DESC_TYPE_STRING:
- DEBUG ((EFI_D_INFO, "USB: Got a request for String descriptor %d\n", Request->Value & 0xFF));
- break;
- default:
- DEBUG ((EFI_D_INFO, "USB: Didn't understand request for descriptor 0x%04x\n", Request->Value));
- Status = EFI_NOT_FOUND;
- break;
- }
-
- // Send the response
- if (ResponseData) {
- ASSERT (ResponseSize != 0);
-
- if (Request->Length < ResponseSize) {
- // Truncate response
- ResponseSize = Request->Length;
- } else if (Request->Length > ResponseSize) {
- DEBUG ((EFI_D_INFO, "USB: Info: ResponseSize < wLength\n"));
- }
-
- DataStageEnable (ISP1761_EP0TX);
- Status = WriteEndpointBuffer (
- ISP1761_EP0TX,
- MAX_PACKET_SIZE_CONTROL,
- ResponseSize,
- ResponseData
- );
- if (!EFI_ERROR (Status)) {
- // Setting this value should cause us to go to the Status stage on the
- // next EP0TX interrupt
- mControlTxPending = TRUE;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-HandleSetAddress (
- IN USB_DEVICE_REQUEST *Request
- )
-{
- // Pretty confused if bmRequestType is anything but this:
- ASSERT (Request->RequestType == USB_DEV_SET_ADDRESS_REQ_TYPE);
- // USB Spec: "The USB device does not change its device address until after
- // the Status stage of this request is completed successfully."
- // ISP1582 datasheet: "The new device address is activated when the
- // device receives an acknowledgment from the host for the empty packet
- // token". (StatusAcknowledge causes an empty packet to be sent).
- // So, we write the Address register _before_ acking the SET_ADDRESS.
- DEBUG ((EFI_D_INFO, "USB: Setting address to %d\n", Request->Value));
- WRITE_REG32 (ISP1761_ADDRESS, Request->Value | ISP1761_ADDRESS_DEVEN);
- StatusAcknowledge (ISP1761_EP0TX);
-
- return EFI_SUCCESS;
-}
-
-// Move the device to the Configured state.
-// (This code only supports one configuration for a device, so the configuration
-// index is ignored)
-STATIC
-EFI_STATUS
-HandleSetConfiguration (
- IN USB_DEVICE_REQUEST *Request
- )
-{
- USB_ENDPOINT_DESCRIPTOR *EPDesc;
- UINTN Index;
- UINT8 EndpointIndex;
-
- ASSERT (Request->RequestType == USB_DEV_SET_CONFIGURATION_REQ_TYPE);
- DEBUG ((EFI_D_INFO, "USB: Setting configuration.\n"));
-
- // Configure endpoints
- for (Index = 0; Index < mInterfaceDescriptor->NumEndpoints; Index++) {
- EPDesc = &mEndpointDescriptors[Index];
-
- // To simplify for now, assume endpoints aren't "sparse", and are in order.
- ASSERT ((EPDesc->EndpointAddress & 0xF) == ((Index / 2) + 1));
-
- // Convert from USB endpoint index to ISP1761 endpoint Index
- // USB: Endpoint number is bits [3:0], IN/OUT is bit [7]
- // ISP1761: Endpoint number is bits [4:1], IN/OUT is bit [0]
- EndpointIndex = ((EPDesc->EndpointAddress & 0xF) << 1) |
- ((EPDesc->EndpointAddress & BIT7) >> 7);
- SelectEndpoint (EndpointIndex);
- // Set endpoint type (Bulk/Isochronous/Interrupt)
- WRITE_REG32 (ISP1761_ENDPOINT_MAX_PACKET_SIZE, EPDesc->MaxPacketSize);
- // Hardware foible (bug?): Although the datasheet seems to suggest it should
- // automatically be set to MaxPacketSize, the Buffer Length register appears
- // to be reset to 0, which causes an empty packet to be sent in response to
- // the first IN token of the session. The NOEMPKT field of the Endpoint Type
- // register sounds like it might fix this problem, but it doesn't
- // (it's "applicable only in the DMA mode").
- WRITE_REG32 (ISP1761_BUFFER_LENGTH, EPDesc->MaxPacketSize);
- WRITE_REG32 (ISP1761_ENDPOINT_TYPE, (EPDesc->Attributes & 0x3) |
- ISP1761_ENDPOINT_TYPE_ENABLE);
- }
-
- StatusAcknowledge (ISP1761_EP0TX);
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-HandleDeviceRequest (
- IN USB_DEVICE_REQUEST *Request
- )
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- switch (Request->Request) {
- case USB_DEV_GET_DESCRIPTOR:
- Status = HandleGetDescriptor (Request);
- break;
- case USB_DEV_SET_ADDRESS:
- Status = HandleSetAddress (Request);
- break;
- case USB_DEV_SET_CONFIGURATION:
- Status = HandleSetConfiguration (Request);
- break;
- default:
- DEBUG ((EFI_D_ERROR,
- "Didn't understand RequestType 0x%x Request 0x%x\n",
- Request->RequestType, Request->Request));
- Status = EFI_INVALID_PARAMETER;
- break;
- }
-
- return Status;
-}
-
-// Instead of actually registering interrupt handlers, we poll the controller's
-// interrupt source register in this function.
-STATIC
-VOID
-CheckInterrupts (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- UINT32 DcInterrupts;
- UINTN NumBytes;
- UINTN MoreBytes;
- UINT8 Packet[512];
- VOID *DataPacket;
- UINT32 HandledInterrupts;
- UINT32 UnhandledInterrupts;
- EFI_STATUS Status;
-
- // Set bits in HandledInterrupts to mark the interrupt source handled.
- HandledInterrupts = 0;
-
- WRITE_REG32 (ISP1761_DEVICE_UNLOCK, ISP1761_DEVICE_UNLOCK_MAGIC);
-
- DcInterrupts = READ_REG32 (ISP1761_DC_INTERRUPT);
- if (DcInterrupts & ISP1761_DC_INTERRUPT_SUSP) {
- DEBUG ((EFI_D_INFO, "USB: Suspend\n"));
- HandledInterrupts |= ISP1761_DC_INTERRUPT_SUSP;
- }
- if (DcInterrupts & ISP1761_DC_INTERRUPT_RESUME) {
- DEBUG ((EFI_D_INFO, "USB: Resume\n"));
- HandledInterrupts |= ISP1761_DC_INTERRUPT_RESUME;
- }
- if (DcInterrupts & ISP1761_DC_INTERRUPT_EP0SETUP) {
- NumBytes = 512;
- ReadEndpointBuffer (0x20, &NumBytes, &Packet);
- ASSERT (NumBytes == 8);
- HandleDeviceRequest ((USB_DEVICE_REQUEST *) Packet);
- HandledInterrupts |= ISP1761_DC_INTERRUPT_EP0SETUP;
- }
- if (DcInterrupts & ISP1761_DC_INTERRUPT_EP0RX) {
- HandledInterrupts |= ISP1761_DC_INTERRUPT_EP0RX;
- }
- if (DcInterrupts & ISP1761_DC_INTERRUPT_EP0TX) {
- if (mControlTxPending) {
- // We previously put some data in the Control Endpoint's IN (Tx) FIFO.
- // We assume that that data has now been sent in response to the IN token
- // that triggered this interrupt. We can therefore go to the Status stage
- // of the control transfer.
- StatusAcknowledge (ISP1761_EP0TX);
- mControlTxPending = FALSE;
- }
- HandledInterrupts |= ISP1761_DC_INTERRUPT_EP0TX;
- }
- if (DcInterrupts & ISP1761_DC_INTERRUPT_EP1RX) {
- NumBytes = 512;
- DataPacket = AllocatePool (NumBytes);
- Status = ReadEndpointBuffer (ISP1761_EP1RX, &NumBytes, DataPacket);
- if (EFI_ERROR (Status) || NumBytes == 0) {
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Couldn't read EP1RX data: %r\n", Status));
- }
- FreePool (DataPacket);
- } else {
- // Signal this event again so we poll again ASAP
- gBS->SignalEvent (Event);
- mDataReceivedCallback (NumBytes, DataPacket);
- }
- HandledInterrupts |= ISP1761_DC_INTERRUPT_EP1RX;
- }
- if (DcInterrupts & ISP1761_DC_INTERRUPT_EP1TX) {
- mDataSentCallback (1);
- HandledInterrupts |= ISP1761_DC_INTERRUPT_EP1TX;
- }
- if (DcInterrupts & (ISP1761_DC_INTERRUPT_SOF | ISP1761_DC_INTERRUPT_PSOF)) {
- // Don't care about SOFs or pseudo-SOFs
- HandledInterrupts |= (ISP1761_DC_INTERRUPT_SOF | ISP1761_DC_INTERRUPT_PSOF);
- }
- if (ISP1761_DC_INTERRUPT_BRESET) {
- HandledInterrupts |= ISP1761_DC_INTERRUPT_BRESET;
- }
- if (ISP1761_DC_INTERRUPT_HS_STAT) {
- HandledInterrupts |= ISP1761_DC_INTERRUPT_HS_STAT;
- }
- if (ISP1761_DC_INTERRUPT_VBUS) {
- HandledInterrupts |= ISP1761_DC_INTERRUPT_VBUS;
- }
-
- UnhandledInterrupts = DcInterrupts & (~HandledInterrupts) & ISP1761_DC_INTERRUPT_MASK;
- if (UnhandledInterrupts) {
- DEBUG ((EFI_D_ERROR, "USB: Unhandled DC Interrupts: 0x%08x\n",
- UnhandledInterrupts));
- }
-
- // Check if we received any more data while we were handling the interrupt.
- SelectEndpoint (ISP1761_EP1RX);
- MoreBytes = READ_REG16 (ISP1761_BUFFER_LENGTH);
- if (MoreBytes) {
- HandledInterrupts &= ~ISP1761_DC_INTERRUPT_EP1RX;
- }
-
- WRITE_REG32 (ISP1761_DC_INTERRUPT, HandledInterrupts);
-}
-
-EFI_STATUS
-Isp1761PeriphSend (
- IN UINT8 EndpointIndex,
- IN UINTN Size,
- IN CONST VOID *Buffer
- )
-{
- return WriteEndpointBuffer (
- (EndpointIndex << 1) | 0x1, //Convert to ISP1761 endpoint index, Tx
- MAX_PACKET_SIZE_BULK,
- Size,
- Buffer
- );
-}
-
-EFI_STATUS
-EFIAPI
-Isp1761PeriphStart (
- IN USB_DEVICE_DESCRIPTOR *DeviceDescriptor,
- IN VOID **Descriptors,
- IN USB_DEVICE_RX_CALLBACK RxCallback,
- IN USB_DEVICE_TX_CALLBACK TxCallback
- )
-{
- UINT16 OtgStatus;
- UINT8 *Ptr;
- EFI_STATUS Status;
- EFI_EVENT TimerEvent;
-
- ASSERT (DeviceDescriptor != NULL);
- ASSERT (Descriptors[0] != NULL);
- ASSERT (RxCallback != NULL);
- ASSERT (TxCallback != NULL);
-
- WRITE_REG32 (ISP1761_DEVICE_UNLOCK, ISP1761_DEVICE_UNLOCK_MAGIC);
-
- WRITE_REG32 (ISP1761_SW_RESET_REG, ISP1761_SW_RESET_ALL);
- while (READ_REG32 (ISP1761_SW_RESET_REG) & ISP1761_SW_RESET_ALL) {
- //busy wait
- }
- WRITE_REG32 (ISP1761_MODE, ISP1761_MODE_SFRESET);
- while (READ_REG32 (ISP1761_MODE) & ISP1761_MODE_SFRESET) {
- //busy wait
- }
- DEBUG ((EFI_D_INFO, "USB: Software reset done\n"));
-
- WRITE_REG32 (ISP1761_DC_INTERRUPT_ENABLE, 0x03FFFFFF);
- WRITE_REG32 (ISP1761_OTG_INTERRUPT_ENABLE_RISE, 0x07FF);
-
- WRITE_REG8 (ISP1761_ADDRESS, ISP1761_ADDRESS_DEVEN);
- WRITE_REG8 (ISP1761_MODE, ISP1761_MODE_WKUPCS | ISP1761_MODE_CLKAON);
-
- // Use port 1 as peripheral controller (magic - disagrees with datasheet)
- WRITE_REG32 (ISP1761_OTG_CTRL_SET, 0xffff0000);
- WRITE_REG32 (ISP1761_OTG_CTRL_SET, 0x000014d1);
-
- OtgStatus = READ_REG16 (ISP1761_OTG_STATUS);
- if ((OtgStatus & ISP1761_OTG_STATUS_B_SESS_END) != 0) {
- DEBUG ((EFI_D_ERROR, "USB: Vbus not powered.\n"));
- }
- if ((OtgStatus & ISP1761_OTG_STATUS_A_B_SESS_VLD) == 0) {
- DEBUG ((EFI_D_ERROR, "USB: Session not valid.\n"));
- }
-
- // Configure Control endpoints
- SelectEndpoint (0x20);
- WRITE_REG32 (ISP1761_ENDPOINT_MAX_PACKET_SIZE, MAX_PACKET_SIZE_CONTROL);
- WRITE_REG32 (ISP1761_ENDPOINT_TYPE, ISP1761_ENDPOINT_TYPE_ENABLE);
- SelectEndpoint (0x0);
- WRITE_REG32 (ISP1761_ENDPOINT_MAX_PACKET_SIZE, MAX_PACKET_SIZE_CONTROL);
- WRITE_REG32 (ISP1761_ENDPOINT_TYPE, ISP1761_ENDPOINT_TYPE_ENABLE);
- SelectEndpoint (0x1);
- WRITE_REG32 (ISP1761_ENDPOINT_MAX_PACKET_SIZE, MAX_PACKET_SIZE_CONTROL);
- WRITE_REG32 (ISP1761_ENDPOINT_TYPE, ISP1761_ENDPOINT_TYPE_ENABLE);
-
- // Interrupt on all ACK and NAK
- WRITE_REG32 (ISP1761_INTERRUPT_CONFIG, ISP1761_INTERRUPT_CONFIG_ACK_ONLY);
-
- mDeviceDescriptor = DeviceDescriptor;
- mDescriptors = Descriptors[0];
-
- // Right now we just support one configuration
- ASSERT (mDeviceDescriptor->NumConfigurations == 1);
- // ... and one interface
- mConfigDescriptor = (USB_CONFIG_DESCRIPTOR *)mDescriptors;
- ASSERT (mConfigDescriptor->NumInterfaces == 1);
-
- Ptr = ((UINT8 *) mDescriptors) + sizeof (USB_CONFIG_DESCRIPTOR);
- mInterfaceDescriptor = (USB_INTERFACE_DESCRIPTOR *) Ptr;
- Ptr += sizeof (USB_INTERFACE_DESCRIPTOR);
-
- mEndpointDescriptors = (USB_ENDPOINT_DESCRIPTOR *) Ptr;
-
- mDataReceivedCallback = RxCallback;
- mDataSentCallback = TxCallback;
-
- // Register a timer event so CheckInterupts gets called periodically
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- CheckInterrupts,
- NULL,
- &TimerEvent
- );
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->SetTimer (
- TimerEvent,
- TimerPeriodic,
- ISP1761_INTERRUPT_POLL_PERIOD
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
-USB_DEVICE_PROTOCOL mUsbDevice = {
- Isp1761PeriphStart,
- Isp1761PeriphSend
-};
-
-
-EFI_STATUS
-EFIAPI
-Isp1761PeriphEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- UINT32 DeviceId;
- EFI_HANDLE Handle;
-
- DeviceId = READ_REG32 (ISP1761_DEVICE_ID);
-
- if (DeviceId != ISP1761_DEVICE_ID_VAL) {
- DEBUG ((EFI_D_ERROR,
- "ERROR: Read incorrect device ID for ISP1761: 0x%08x, expected 0x%08x\n",
- DeviceId , ISP1761_DEVICE_ID_VAL
- ));
- return EFI_DEVICE_ERROR;
- }
-
- Handle = NULL;
- return gBS->InstallProtocolInterface (
- &Handle,
- &gUsbDeviceProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mUsbDevice
- );
-}
diff --git a/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.h b/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.h
deleted file mode 100644
index 9e60e155d7..0000000000
--- a/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/** @file
-
- Copyright (c) 2013-2014, ARM Ltd. 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 __ISP1761_USB_DXE_H__
-#define __ISP1761_USB_DXE_H__
-
-#define ISP1761_USB_BASE FixedPcdGet32 (PcdIsp1761BaseAddress)
-
-#define READ_REG32(Offset) MmioRead32 (ISP1761_USB_BASE + Offset)
-#define READ_REG16(Offset) (UINT16) READ_REG32 (Offset)
-#define WRITE_REG32(Offset, Val) MmioWrite32 (ISP1761_USB_BASE + Offset, Val)
-#define WRITE_REG16(Offset, Val) MmioWrite32 (ISP1761_USB_BASE + Offset, (UINT32) Val)
-#define WRITE_REG8(Offset, Val) MmioWrite32 (ISP1761_USB_BASE + Offset, (UINT32) Val)
-
-// Max packet size in bytes (For Full Speed USB 64 is the only valid value)
-#define MAX_PACKET_SIZE_CONTROL 64
-
-#define MAX_PACKET_SIZE_BULK 512
-
-// 8 Endpoints, in and out. Don't count the Endpoint 0 setup buffer
-#define ISP1761_NUM_ENDPOINTS 16
-
-// Endpoint Indexes
-#define ISP1761_EP0SETUP 0x20
-#define ISP1761_EP0RX 0x00
-#define ISP1761_EP0TX 0x01
-#define ISP1761_EP1RX 0x02
-#define ISP1761_EP1TX 0x03
-
-// DcInterrupt bits
-#define ISP1761_DC_INTERRUPT_BRESET BIT0
-#define ISP1761_DC_INTERRUPT_SOF BIT1
-#define ISP1761_DC_INTERRUPT_PSOF BIT2
-#define ISP1761_DC_INTERRUPT_SUSP BIT3
-#define ISP1761_DC_INTERRUPT_RESUME BIT4
-#define ISP1761_DC_INTERRUPT_HS_STAT BIT5
-#define ISP1761_DC_INTERRUPT_DMA BIT6
-#define ISP1761_DC_INTERRUPT_VBUS BIT7
-#define ISP1761_DC_INTERRUPT_EP0SETUP BIT8
-#define ISP1761_DC_INTERRUPT_EP0RX BIT10
-#define ISP1761_DC_INTERRUPT_EP0TX BIT11
-#define ISP1761_DC_INTERRUPT_EP1RX BIT12
-#define ISP1761_DC_INTERRUPT_EP1TX BIT13
-// All valid peripheral controller interrupts
-#define ISP1761_DC_INTERRUPT_MASK 0x003FFFDFF
-
-#define ISP1761_ADDRESS 0x200
-#define ISP1761_ADDRESS_DEVEN BIT7
-
-#define ISP1761_MODE 0x20C
-#define ISP1761_MODE_DATA_BUS_WIDTH BIT8
-#define ISP1761_MODE_CLKAON BIT7
-#define ISP1761_MODE_SFRESET BIT4
-#define ISP1761_MODE_WKUPCS BIT2
-
-#define ISP1761_ENDPOINT_MAX_PACKET_SIZE 0x204
-
-#define ISP1761_ENDPOINT_TYPE 0x208
-#define ISP1761_ENDPOINT_TYPE_NOEMPKT BIT4
-#define ISP1761_ENDPOINT_TYPE_ENABLE BIT3
-
-#define ISP1761_INTERRUPT_CONFIG 0x210
-// Interrupt config value to only interrupt on ACK of IN and OUT tokens
-#define ISP1761_INTERRUPT_CONFIG_ACK_ONLY BIT2 | BIT5 | BIT6
-
-#define ISP1761_DC_INTERRUPT 0x218
-#define ISP1761_DC_INTERRUPT_ENABLE 0x214
-
-#define ISP1761_CTRL_FUNCTION 0x228
-#define ISP1761_CTRL_FUNCTION_VENDP BIT3
-#define ISP1761_CTRL_FUNCTION_DSEN BIT2
-#define ISP1761_CTRL_FUNCTION_STATUS BIT1
-
-#define ISP1761_DEVICE_UNLOCK 0x27C
-#define ISP1761_DEVICE_UNLOCK_MAGIC 0xAA37
-
-#define ISP1761_SW_RESET_REG 0x30C
-#define ISP1761_SW_RESET_ALL BIT0
-
-#define ISP1761_DEVICE_ID 0x370
-
-#define ISP1761_OTG_CTRL_SET 0x374
-#define ISP1761_OTG_CTRL_CLR OTG_CTRL_SET + 2
-#define ISP1761_OTG_CTRL_OTG_DISABLE BIT10
-#define ISP1761_OTG_CTRL_VBUS_CHRG BIT6
-#define ISP1761_OTG_CTRL_VBUS_DISCHRG BIT5
-#define ISP1761_OTG_CTRL_DM_PULLDOWN BIT2
-#define ISP1761_OTG_CTRL_DP_PULLDOWN BIT1
-#define ISP1761_OTG_CTRL_DP_PULLUP BIT0
-
-#define ISP1761_OTG_STATUS 0x378
-#define ISP1761_OTG_STATUS_B_SESS_END BIT7
-#define ISP1761_OTG_STATUS_A_B_SESS_VLD BIT1
-
-#define ISP1761_OTG_INTERRUPT_LATCH_SET 0x37C
-#define ISP1761_OTG_INTERRUPT_LATCH_CLR 0x37E
-#define ISP1761_OTG_INTERRUPT_ENABLE_RISE 0x384
-
-#define ISP1761_DMA_ENDPOINT_INDEX 0x258
-
-#define ISP1761_ENDPOINT_INDEX 0x22c
-#define ISP1761_DATA_PORT 0x220
-#define ISP1761_BUFFER_LENGTH 0x21c
-
-// Device ID Values
-#define PHILLIPS_VENDOR_ID_VAL 0x04cc
-#define ISP1761_PRODUCT_ID_VAL 0x1761
-#define ISP1761_DEVICE_ID_VAL ((ISP1761_PRODUCT_ID_VAL << 16) |\
- PHILLIPS_VENDOR_ID_VAL)
-
-#endif //ifndef __ISP1761_USB_DXE_H__
diff --git a/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.inf b/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.inf
deleted file mode 100644
index 52ebc11c7f..0000000000
--- a/EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.inf
+++ /dev/null
@@ -1,43 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2013-2015, ARM Ltd. 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 = Isp1761PeriphDxe
- FILE_GUID = 72d78ea6-4dee-11e3-8100-f3842a48d0a0
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = Isp1761PeriphEntryPoint
-
-[Sources.common]
- Isp1761UsbDxe.c
-
-[LibraryClasses]
- DebugLib
- IoLib
- MemoryAllocationLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
-
-[Protocols]
- gEfiDriverBindingProtocolGuid
- gUsbDeviceProtocolGuid
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[Pcd]
- gEmbeddedTokenSpaceGuid.PcdIsp1761BaseAddress
diff --git a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.c b/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.c
deleted file mode 100644
index 4de5204899..0000000000
--- a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.c
+++ /dev/null
@@ -1,1540 +0,0 @@
-/** @file
-*
-* Copyright (c) 2012-2014, 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.
-*
-**/
-
-#include "Lan9118Dxe.h"
-
-typedef struct {
- MAC_ADDR_DEVICE_PATH Lan9118;
- EFI_DEVICE_PATH_PROTOCOL End;
-} LAN9118_DEVICE_PATH;
-
-LAN9118_DEVICE_PATH Lan9118PathTemplate = {
- {
- {
- MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP,
- { (UINT8) (sizeof(MAC_ADDR_DEVICE_PATH)), (UINT8) ((sizeof(MAC_ADDR_DEVICE_PATH)) >> 8) }
- },
- { { 0 } },
- 0
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof(EFI_DEVICE_PATH_PROTOCOL), 0 }
- }
-};
-
-/*
-** Entry point for the LAN9118 driver
-**
-*/
-EFI_STATUS
-Lan9118DxeEntry (
- IN EFI_HANDLE Handle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LAN9118_DRIVER *LanDriver;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- EFI_SIMPLE_NETWORK_MODE *SnpMode;
- LAN9118_DEVICE_PATH *Lan9118Path;
- EFI_HANDLE ControllerHandle;
-
- // The PcdLan9118DxeBaseAddress PCD must be defined
- ASSERT (PcdGet32 (PcdLan9118DxeBaseAddress) != 0);
-
- // Allocate Resources
- LanDriver = AllocateZeroPool (sizeof (LAN9118_DRIVER));
- if (LanDriver == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- Lan9118Path = (LAN9118_DEVICE_PATH*)AllocateCopyPool (sizeof (LAN9118_DEVICE_PATH), &Lan9118PathTemplate);
- if (Lan9118Path == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- // Initialize pointers
- Snp = &(LanDriver->Snp);
- SnpMode = &(LanDriver->SnpMode);
- Snp->Mode = SnpMode;
-
- // Set the signature of the LAN Driver structure
- LanDriver->Signature = LAN9118_SIGNATURE;
-
- // Assign fields and func pointers
- Snp->Revision = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION;
- Snp->WaitForPacket = NULL;
- Snp->Initialize = SnpInitialize;
- Snp->Start = SnpStart;
- Snp->Stop = SnpStop;
- Snp->Reset = SnpReset;
- Snp->Shutdown = SnpShutdown;
- Snp->ReceiveFilters = SnpReceiveFilters;
- Snp->StationAddress = SnpStationAddress;
- Snp->Statistics = SnpStatistics;
- Snp->MCastIpToMac = SnpMcastIptoMac;
- Snp->NvData = SnpNvData;
- Snp->GetStatus = SnpGetStatus;
- Snp->Transmit = SnpTransmit;
- Snp->Receive = SnpReceive;
-
- // Start completing simple network mode structure
- SnpMode->State = EfiSimpleNetworkStopped;
- SnpMode->HwAddressSize = NET_ETHER_ADDR_LEN; // HW address is 6 bytes
- SnpMode->MediaHeaderSize = sizeof(ETHER_HEAD); // Not sure of this
- SnpMode->MaxPacketSize = EFI_PAGE_SIZE; // Preamble + SOF + Ether Frame (with VLAN tag +4bytes)
- SnpMode->NvRamSize = 0; // No NVRAM with this device
- SnpMode->NvRamAccessSize = 0; // No NVRAM with this device
-
- //
- // Claim that all receive filter settings are supported, though the MULTICAST mode
- // is not completely supported. The LAN9118 Ethernet controller is only able to
- // do a "hash filtering" and not a perfect filtering on multicast addresses. The
- // controller does not filter the multicast addresses directly but a hash value
- // of them. The hash value of a multicast address is derived from its CRC and
- // ranges from 0 to 63 included.
- // We claim that the perfect MULTICAST filtering mode is supported because
- // we do not want the user to switch directly to the PROMISCOUS_MULTICAST mode
- // and thus not being able to take advantage of the hash filtering.
- //
- SnpMode->ReceiveFilterMask = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
- EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |
- EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |
- EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS |
- EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;
-
- // We do not intend to receive anything for the time being.
- SnpMode->ReceiveFilterSetting = 0;
-
- // LAN9118 has 64bit hash table, can filter 64 MCast MAC Addresses
- SnpMode->MaxMCastFilterCount = MAX_MCAST_FILTER_CNT;
- SnpMode->MCastFilterCount = 0;
- ZeroMem (&SnpMode->MCastFilter, MAX_MCAST_FILTER_CNT * sizeof(EFI_MAC_ADDRESS));
-
- // Set the interface type (1: Ethernet or 6: IEEE 802 Networks)
- SnpMode->IfType = NET_IFTYPE_ETHERNET;
-
- // Mac address is changeable as it is loaded from erasable memory
- SnpMode->MacAddressChangeable = TRUE;
-
- // Can only transmit one packet at a time
- SnpMode->MultipleTxSupported = FALSE;
-
- // MediaPresent checks for cable connection and partner link
- SnpMode->MediaPresentSupported = TRUE;
- SnpMode->MediaPresent = FALSE;
-
- // Set broadcast address
- SetMem (&SnpMode->BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF);
-
- // Power up the device so we can find the MAC address
- Status = Lan9118Initialize (Snp);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Lan9118: Error initialising hardware\n"));
- return EFI_DEVICE_ERROR;
- }
-
- // Assign fields for device path
- CopyMem (&Lan9118Path->Lan9118.MacAddress, &Snp->Mode->CurrentAddress, NET_ETHER_ADDR_LEN);
- Lan9118Path->Lan9118.IfType = Snp->Mode->IfType;
-
- // Initialise the protocol
- ControllerHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ControllerHandle,
- &gEfiSimpleNetworkProtocolGuid, Snp,
- &gEfiDevicePathProtocolGuid, Lan9118Path,
- NULL
- );
- // Say what the status of loading the protocol structure is
- if (EFI_ERROR(Status)) {
- FreePool (LanDriver);
- } else {
- LanDriver->ControllerHandle = ControllerHandle;
- }
-
- return Status;
-}
-
-/*
- * UEFI Start() function
- *
- * Parameters:
- *
- * @param Snp: A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
- *
- * Description:
- *
- * This function starts a network interface. If the network interface successfully starts, then
- * EFI_SUCCESS will be returned.
- */
-EFI_STATUS
-EFIAPI
-SnpStart (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- // Check Snp instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check state
- if ((Snp->Mode->State == EfiSimpleNetworkStarted) ||
- (Snp->Mode->State == EfiSimpleNetworkInitialized) ) {
- return EFI_ALREADY_STARTED;
- }
-
- // Change state
- Snp->Mode->State = EfiSimpleNetworkStarted;
- return EFI_SUCCESS;
-}
-
-/*
- * UEFI Stop() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpStop (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
- )
-{
- // Check Snp Instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check state of the driver
- if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- return EFI_NOT_STARTED;
- }
-
- // Stop the Tx and Rx
- StopTx (STOP_TX_CFG | STOP_TX_MAC, Snp);
- StopRx (0, Snp);
-
- // Change the state
- switch (Snp->Mode->State) {
- case EfiSimpleNetworkStarted:
- case EfiSimpleNetworkInitialized:
- Snp->Mode->State = EfiSimpleNetworkStopped;
- break;
- default:
- return EFI_DEVICE_ERROR;
- }
-
- // Put the device into a power saving mode ?
- return EFI_SUCCESS;
-}
-
-
-// Allocated receive and transmit buffers
-STATIC UINT32 gTxBuffer = 0;
-
-/*
- * UEFI Initialize() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpInitialize (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN UINTN RxBufferSize OPTIONAL,
- IN UINTN TxBufferSize OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINT32 PmConf;
- INT32 AllocResult;
- UINT32 RxStatusSize;
- UINT32 TxStatusSize;
-
- // Initialize variables
- // Global variables to hold tx and rx FIFO allocation
- gTxBuffer = 0;
-
- // Check Snp Instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // First check that driver has not already been initialized
- if (Snp->Mode->State == EfiSimpleNetworkInitialized) {
- DEBUG ((EFI_D_WARN, "LAN9118 Driver already initialized\n"));
- return EFI_SUCCESS;
- } else
- if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "LAN9118 Driver not started\n"));
- return EFI_NOT_STARTED;
- }
-
- // Initiate a PHY reset
- Status = PhySoftReset (PHY_RESET_PMT, Snp);
- if (EFI_ERROR (Status)) {
- Snp->Mode->State = EfiSimpleNetworkStopped;
- DEBUG ((EFI_D_WARN, "Warning: Link not ready after TimeOut. Check ethernet cable\n"));
- return EFI_NOT_STARTED;
- }
-
- // Initiate a software reset
- Status = SoftReset (0, Snp);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_WARN, "Soft Reset Failed: Hardware Error\n"));
- return EFI_DEVICE_ERROR;
- }
-
- // Read the PM register
- PmConf = MmioRead32 (LAN9118_PMT_CTRL);
-
- // MPTCTRL_WOL_EN: Allow Wake-On-Lan to detect wake up frames or magic packets
- // MPTCTRL_ED_EN: Allow energy detection to allow lowest power consumption mode
- // MPTCTRL_PME_EN: Allow Power Management Events
- PmConf = 0;
- PmConf |= (MPTCTRL_WOL_EN | MPTCTRL_ED_EN | MPTCTRL_PME_EN);
-
- // Write the current configuration to the register
- MmioWrite32 (LAN9118_PMT_CTRL, PmConf);
- gBS->Stall (LAN9118_STALL);
- gBS->Stall (LAN9118_STALL);
-
- // Configure GPIO and HW
- Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- // Assign the transmitter buffer size (default values)
- TxStatusSize = LAN9118_TX_STATUS_SIZE;
- RxStatusSize = LAN9118_RX_STATUS_SIZE;
-
- // Check that a buff size was specified
- if (TxBufferSize > 0) {
- if (RxBufferSize == 0) {
- RxBufferSize = LAN9118_RX_DATA_SIZE;
- }
-
- AllocResult = ChangeFifoAllocation (
- ALLOC_USE_FIFOS,
- &TxBufferSize,
- &RxBufferSize,
- &TxStatusSize,
- &RxStatusSize,
- Snp
- );
-
- if (AllocResult < 0) {
- return EFI_OUT_OF_RESOURCES;
- }
- }
-
- // Do auto-negotiation if supported
- Status = AutoNegotiate (AUTO_NEGOTIATE_ADVERTISE_ALL, Snp);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_WARN, "Lan9118: Auto Negociation not supported.\n"));
- }
-
- // Configure flow control depending on speed capabilities
- Status = ConfigureFlow (0, 0, 0, 0, Snp);
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- // Enable the transmitter
- Status = StartTx (START_TX_MAC | START_TX_CFG, Snp);
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- // Now acknowledge all interrupts
- MmioWrite32 (LAN9118_INT_STS, ~0);
-
- // Declare the driver as initialized
- Snp->Mode->State = EfiSimpleNetworkInitialized;
-
- return Status;
-}
-
-/*
- * UEFI Reset () function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpReset (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN Verification
- )
-{
- UINT32 PmConf;
- UINT32 HwConf;
- UINT32 ResetFlags;
- EFI_STATUS Status;
-
- PmConf = 0;
- HwConf = 0;
- ResetFlags = 0;
-
- // Check Snp Instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // First check that driver has not already been initialized
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not yet initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not started\n"));
- return EFI_NOT_STARTED;
- }
-
- // Initiate a PHY reset
- Status = PhySoftReset (PHY_RESET_PMT, Snp);
- if (EFI_ERROR (Status)) {
- Snp->Mode->State = EfiSimpleNetworkStopped;
- return EFI_NOT_STARTED;
- }
-
- // Initiate a software reset
- ResetFlags |= SOFT_RESET_CHECK_MAC_ADDR_LOAD | SOFT_RESET_CLEAR_INT;
-
- if (Verification) {
- ResetFlags |= SOFT_RESET_SELF_TEST;
- }
-
- Status = SoftReset (ResetFlags, Snp);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_WARN, "Warning: Soft Reset Failed: Hardware Error\n"));
- return EFI_DEVICE_ERROR;
- }
-
- // Read the PM register
- PmConf = MmioRead32 (LAN9118_PMT_CTRL);
-
- // MPTCTRL_WOL_EN: Allow Wake-On-Lan to detect wake up frames or magic packets
- // MPTCTRL_ED_EN: Allow energy detection to allow lowest power consumption mode
- // MPTCTRL_PME_EN: Allow Power Management Events
- PmConf |= (MPTCTRL_WOL_EN | MPTCTRL_ED_EN | MPTCTRL_PME_EN);
-
- // Write the current configuration to the register
- MmioWrite32 (LAN9118_PMT_CTRL, PmConf);
- gBS->Stall (LAN9118_STALL);
-
- // Reactivate the LEDs
- Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Check that a buffer size was specified in SnpInitialize
- if (gTxBuffer != 0) {
- HwConf = MmioRead32 (LAN9118_HW_CFG); // Read the HW register
- HwConf &= ~HW_CFG_TX_FIFO_SIZE_MASK; // Clear buffer bits first
- HwConf |= HW_CFG_TX_FIFO_SIZE(gTxBuffer); // assign size chosen in SnpInitialize
-
- MmioWrite32 (LAN9118_HW_CFG, HwConf); // Write the conf
- gBS->Stall (LAN9118_STALL);
- }
-
- // Enable the receiver and transmitter and clear their contents
- StartRx (START_RX_CLEAR, Snp);
- StartTx (START_TX_MAC | START_TX_CFG | START_TX_CLEAR, Snp);
-
- // Now acknowledge all interrupts
- MmioWrite32 (LAN9118_INT_STS, ~0);
-
- return EFI_SUCCESS;
-}
-
-/*
- * UEFI Shutdown () function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpShutdown (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
- )
-{
- EFI_STATUS Status;
-
- // Check Snp Instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // First check that driver has not already been initialized
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not yet initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not started\n"));
- return EFI_NOT_STARTED;
- }
-
- // Initiate a PHY reset
- Status = PhySoftReset (PHY_RESET_PMT, Snp);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Initiate a software reset
- Status = SoftReset (0, Snp);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_WARN, "Warning: Soft Reset Failed: Hardware Error\n"));
- return Status;
- }
-
- // Back to the started and thus not initialized state
- Snp->Mode->State = EfiSimpleNetworkStarted;
-
- return EFI_SUCCESS;
-}
-
-/**
- Enable and/or disable the receive filters of the LAN9118
-
- Please refer to the UEFI specification for the precedence rules among the
- Enable, Disable and ResetMCastFilter parameters.
-
- @param[in] Snp A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL
- instance.
- @param[in] Enable A bit mask of receive filters to enable.
- @param[in] Disable A bit mask of receive filters to disable.
- @param[in] ResetMCastFilter Set to TRUE to reset the contents of the multicast
- receive filters on the network interface to
- their default values.
- @param[in] MCastFilterCnt Number of multicast HW MAC addresses in the new
- MCastFilter list. This value must be less than or
- equal to the MCastFilterCnt field of
- EFI_SIMPLE_NETWORK_MODE. This field is optional if
- ResetMCastFilter is TRUE.
- @param[in] MCastFilter A pointer to a list of new multicast receive
- filter HW MAC addresses. This list will replace
- any existing multicast HW MAC address list. This
- field is optional if ResetMCastFilter is TRUE.
-
- @retval EFI_SUCCESS The receive filters of the LAN9118 were updated.
- @retval EFI_NOT_STARTED The LAN9118 has not been started.
- @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE :
- . This is NULL
- . Multicast is being enabled (the
- EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit is set in
- Enable, it is not set in Disable, and ResetMCastFilter
- is FALSE) and MCastFilterCount is zero.
- . Multicast is being enabled and MCastFilterCount is
- greater than Snp->Mode->MaxMCastFilterCount.
- . Multicast is being enabled and MCastFilter is NULL
- . Multicast is being enabled and one or more of the
- addresses in the MCastFilter list are not valid
- multicast MAC addresses.
- @retval EFI_DEVICE_ERROR The LAN9118 has been started but not initialized.
-
-**/
-EFI_STATUS
-EFIAPI
-SnpReceiveFilters (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
- IN UINT32 Enable,
- IN UINT32 Disable,
- IN BOOLEAN ResetMCastFilter,
- IN UINTN MCastFilterCnt OPTIONAL,
- IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
- )
-{
- EFI_SIMPLE_NETWORK_MODE *Mode;
- UINT32 MultHashTableHigh;
- UINT32 MultHashTableLow;
- UINT32 Count;
- UINT32 Crc;
- UINT8 HashValue;
- UINT32 MacCSRValue;
- UINT32 ReceiveFilterSetting;
- EFI_MAC_ADDRESS *Mac;
- EFI_MAC_ADDRESS ZeroMac;
-
- // Check Snp Instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- Mode = Snp->Mode;
-
- // Check that driver was started and initialised
- if (Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver in stopped state\n"));
- return EFI_NOT_STARTED;
- }
-
- if ((Enable & (~Mode->ReceiveFilterMask)) ||
- (Disable & (~Mode->ReceiveFilterMask)) ) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Check the validity of the multicast setting and compute the
- // hash values of the multicast mac addresses to listen to.
- //
-
- MultHashTableHigh = 0;
- MultHashTableLow = 0;
- if ((!ResetMCastFilter) &&
- ((Disable & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) == 0) &&
- ((Enable & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) ) {
- if ((MCastFilterCnt == 0) ||
- (MCastFilterCnt > Mode->MaxMCastFilterCount) ||
- (MCastFilter == NULL) ) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Check the validity of all multicast addresses before to change
- // anything.
- //
- for (Count = 0; Count < MCastFilterCnt; Count++) {
- if ((MCastFilter[Count].Addr[0] & 1) == 0) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- //
- // Go through each filter address and set appropriate bits on hash table
- //
- for (Count = 0; Count < MCastFilterCnt; Count++) {
- Mac = &(MCastFilter[Count]);
- CopyMem (&Mode->MCastFilter[Count], Mac, sizeof(EFI_MAC_ADDRESS));
-
- Crc = GenEtherCrc32 (Mac, NET_ETHER_ADDR_LEN);
- //gBS->CalculateCrc32 ((VOID*)&Mfilter[Count],6,&Crc); <-- doesn't work as desired
-
- //
- // The most significant 6 bits of the MAC address CRC constitute the hash
- // value of the MAC address.
- //
- HashValue = (Crc >> 26) & 0x3F;
-
- // Select hashlow register if MSB is not set
- if ((HashValue & 0x20) == 0) {
- MultHashTableLow |= (1 << HashValue);
- } else {
- MultHashTableHigh |= (1 << (HashValue & 0x1F));
- }
- }
- Mode->MCastFilterCount = MCastFilterCnt;
- } else if (ResetMCastFilter) {
- Mode->MCastFilterCount = 0;
- } else {
- MultHashTableLow = IndirectMACRead32 (INDIRECT_MAC_INDEX_HASHL);
- MultHashTableHigh = IndirectMACRead32 (INDIRECT_MAC_INDEX_HASHH);
- }
-
- //
- // Before to change anything, stop and reset the reception of
- // packets.
- //
- StopRx (STOP_RX_CLEAR, Snp);
-
- //
- // Write the mask of the selected hash values for the multicast filtering.
- // The two masks are set to zero if the multicast filtering is not enabled.
- //
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_HASHL, MultHashTableLow);
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_HASHH, MultHashTableHigh);
-
- ReceiveFilterSetting = (Mode->ReceiveFilterSetting | Enable) & (~Disable);
-
- //
- // Read MAC controller
- //
- MacCSRValue = IndirectMACRead32 (INDIRECT_MAC_INDEX_CR);
- MacCSRValue &= ~(MACCR_HPFILT | MACCR_BCAST | MACCR_PRMS | MACCR_MCPAS);
-
- if (ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_UNICAST) {
- Lan9118SetMacAddress (&Mode->CurrentAddress, Snp);
- DEBUG ((DEBUG_NET, "Allowing Unicast Frame Reception\n"));
- } else {
- //
- // The Unicast packets do not have to be listen to, set the MAC
- // address of the LAN9118 to be the "not configured" all zeroes
- // ethernet MAC address.
- //
- ZeroMem (&ZeroMac, NET_ETHER_ADDR_LEN);
- Lan9118SetMacAddress (&ZeroMac, Snp);
- }
-
- if (ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) {
- MacCSRValue |= MACCR_HPFILT;
- DEBUG ((DEBUG_NET, "Allowing Multicast Frame Reception\n"));
- }
-
- if (ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) {
- MacCSRValue |= MACCR_MCPAS;
- DEBUG ((DEBUG_NET, "Enabling Promiscuous Multicast Mode\n"));
- }
-
- if ((ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST) == 0) {
- MacCSRValue |= MACCR_BCAST;
- } else {
- DEBUG ((DEBUG_NET, "Allowing Broadcast Frame Reception\n"));
- }
-
- if (ReceiveFilterSetting & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) {
- MacCSRValue |= MACCR_PRMS;
- DEBUG ((DEBUG_NET, "Enabling Promiscuous Mode\n"));
- }
-
- //
- // Write the options to the MAC_CSR
- //
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_CR, MacCSRValue);
- gBS->Stall (LAN9118_STALL);
-
- //
- // If we have to retrieve something, start packet reception.
- //
- Mode->ReceiveFilterSetting = ReceiveFilterSetting;
- if (ReceiveFilterSetting != 0) {
- StartRx (0, Snp);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Modify of reset the current station address
-
- @param[in] Snp A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL
- instance.
- @param[in] Reset Flag used to reset the station address to the
- LAN9118's permanent address.
- @param[in] New New station address to be used for the network interface.
-
- @retval EFI_SUCCESS The LAN9118's station address was updated.
- @retval EFI_NOT_STARTED The LAN9118 has not been started.
- @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE :
- . The "New" station address is invalid.
- . "Reset" is FALSE and "New" is NULL.
- @retval EFI_DEVICE_ERROR The LAN9118 has been started but not initialized.
-
-**/
-EFI_STATUS
-EFIAPI
-SnpStationAddress (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *New
-)
-{
- UINT32 Count;
- UINT8 PermAddr[NET_ETHER_ADDR_LEN];
-
- DEBUG ((DEBUG_NET, "SnpStationAddress()\n"));
-
- // Check Snp instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check that driver was started and initialised
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver in stopped state\n"));
- return EFI_NOT_STARTED;
- }
-
- // Get the Permanent MAC address if need reset
- if (Reset) {
- // Try using EEPROM first. Read the first byte of data from EEPROM at the address 0x0
- if ((IndirectEEPROMRead32 (0) & 0xFF) == EEPROM_EXTERNAL_SERIAL_EEPROM) {
- for (Count = 0; Count < NET_ETHER_ADDR_LEN; Count++) {
- PermAddr[Count] = IndirectEEPROMRead32 (Count + 1);
- }
- New = (EFI_MAC_ADDRESS *) PermAddr;
- Lan9118SetMacAddress ((EFI_MAC_ADDRESS *) PermAddr, Snp);
- } else {
- DEBUG ((EFI_D_ERROR, "Lan9118: Warning: No valid MAC address in EEPROM, using fallback\n"));
- New = (EFI_MAC_ADDRESS*) (FixedPcdGet64 (PcdLan9118DefaultMacAddress));
- }
- } else {
- // Otherwise use the specified new MAC address
- if (New == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // If it is a multicast address, it is not valid.
- //
- if (New->Addr[0] & 0x01) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- CopyMem (&Snp->Mode->CurrentAddress, New, NET_ETHER_ADDR_LEN);
-
- //
- // If packet reception is currently activated, stop and reset it,
- // set the new ethernet address and restart the packet reception.
- // Otherwise, nothing to do, the MAC address will be updated in
- // SnpReceiveFilters() when the UNICAST packet reception will be
- // activated.
- //
- if (Snp->Mode->ReceiveFilterSetting != 0) {
- StopRx (STOP_RX_CLEAR, Snp);
- Lan9118SetMacAddress (New, Snp);
- StartRx (0, Snp);
- }
-
- return EFI_SUCCESS;
-}
-
-/*
- * UEFI Statistics() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpStatistics (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatSize,
- OUT EFI_NETWORK_STATISTICS *Statistics
- )
-{
- LAN9118_DRIVER *LanDriver;
- EFI_STATUS Status;
-
- LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
-
- DEBUG ((DEBUG_NET, "SnpStatistics()\n"));
-
- // Check Snp instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check that driver was started and initialised
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver in stopped state\n"));
- return EFI_NOT_STARTED;
- }
-
- //
- // Do a reset if required. It is not clearly stated in the UEFI specification
- // whether the reset has to be done before to copy the statistics in "Statictics"
- // or after. It is a bit strange to do it before but that is what is expected by
- // the SCT test on Statistics() with reset : "0x3de76704,0x4bf5,0x42cd,0x8c,0x89,
- // 0x54,0x7e,0x4f,0xad,0x4f,0x24".
- //
- if (Reset) {
- ZeroMem (&LanDriver->Stats, sizeof(EFI_NETWORK_STATISTICS));
- }
-
- Status = EFI_SUCCESS;
- if (StatSize == NULL) {
- if (Statistics != NULL) {
- return EFI_INVALID_PARAMETER;
- }
- } else {
- if (Statistics == NULL) {
- Status = EFI_BUFFER_TOO_SMALL;
- } else {
- // Fill in the statistics
- CopyMem (
- Statistics, &LanDriver->Stats,
- MIN (*StatSize, sizeof (EFI_NETWORK_STATISTICS))
- );
- if (*StatSize < sizeof (EFI_NETWORK_STATISTICS)) {
- Status = EFI_BUFFER_TOO_SMALL;
- }
- }
- *StatSize = sizeof (EFI_NETWORK_STATISTICS);
- }
-
- return Status;
-}
-
-/*
- * UEFI MCastIPtoMAC() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpMcastIptoMac (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN IsIpv6,
- IN EFI_IP_ADDRESS *Ip,
- OUT EFI_MAC_ADDRESS *McastMac
- )
-{
- DEBUG ((DEBUG_NET, "SnpMcastIptoMac()\n"));
-
- // Check Snp instance
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check that driver was started and initialised
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver in stopped state\n"));
- return EFI_NOT_STARTED;
- }
-
- // Check parameters
- if ((McastMac == NULL) || (Ip == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Make sure MAC address is empty
- ZeroMem (McastMac, sizeof(EFI_MAC_ADDRESS));
-
- // If we need ipv4 address
- if (!IsIpv6) {
- // Most significant 25 bits of a multicast HW address are set.
- // 01-00-5E is the IPv4 Ethernet Multicast Address (see RFC 1112)
- McastMac->Addr[0] = 0x01;
- McastMac->Addr[1] = 0x00;
- McastMac->Addr[2] = 0x5E;
-
- // Lower 23 bits from ipv4 address
- McastMac->Addr[3] = (Ip->v4.Addr[1] & 0x7F); // Clear the most significant bit (25th bit of MAC must be 0)
- McastMac->Addr[4] = Ip->v4.Addr[2];
- McastMac->Addr[5] = Ip->v4.Addr[3];
- } else {
- // Most significant 16 bits of multicast v6 HW address are set
- // 33-33 is the IPv6 Ethernet Multicast Address (see RFC 2464)
- McastMac->Addr[0] = 0x33;
- McastMac->Addr[1] = 0x33;
-
- // lower four octets are taken from ipv6 address
- McastMac->Addr[2] = Ip->v6.Addr[8];
- McastMac->Addr[3] = Ip->v6.Addr[9];
- McastMac->Addr[4] = Ip->v6.Addr[10];
- McastMac->Addr[5] = Ip->v6.Addr[11];
- }
-
- return EFI_SUCCESS;
-}
-
-/*
- * UEFI NvData() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpNvData (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* pobj,
- IN BOOLEAN read_write,
- IN UINTN offset,
- IN UINTN buff_size,
- IN OUT VOID *data
- )
-{
- DEBUG ((DEBUG_NET, "SnpNvData()\n"));
-
- return EFI_UNSUPPORTED;
-}
-
-
-/*
- * UEFI GetStatus () function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpGetStatus (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
- OUT UINT32 *IrqStat OPTIONAL,
- OUT VOID **TxBuff OPTIONAL
- )
-{
- UINT32 FifoInt;
- EFI_STATUS Status;
- UINTN NumTxStatusEntries;
- UINT32 TxStatus;
- UINT16 PacketTag;
- UINT32 Interrupts;
- LAN9118_DRIVER *LanDriver;
-
- LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
-
- // Check preliminaries
- if (Snp == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check that driver was started and initialised
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver in stopped state\n"));
- return EFI_NOT_STARTED;
- }
-
- // Check and acknowledge TX Status interrupt (this will happen if the
- // consumer of SNP does not call GetStatus.)
- // TODO will we lose TxStatuses if this happens? Maybe in SnpTransmit we
- // should check for it and dump the TX Status FIFO.
- FifoInt = MmioRead32 (LAN9118_FIFO_INT);
-
- // Clear the TX Status FIFO Overflow
- if ((FifoInt & INSTS_TXSO) == 0) {
- FifoInt |= INSTS_TXSO;
- MmioWrite32 (LAN9118_FIFO_INT, FifoInt);
- }
-
- // Read interrupt status if IrqStat is not NULL
- if (IrqStat != NULL) {
- *IrqStat = 0;
-
- // Check for receive interrupt
- if (MmioRead32 (LAN9118_INT_STS) & INSTS_RSFL) { // Data moved from rx FIFO
- *IrqStat |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;
- MmioWrite32 (LAN9118_INT_STS,INSTS_RSFL);
- }
-
- // Check for transmit interrupt
- if (MmioRead32 (LAN9118_INT_STS) & INSTS_TSFL) {
- *IrqStat |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
- MmioWrite32 (LAN9118_INT_STS,INSTS_TSFL);
- }
-
- // Check for software interrupt
- if (MmioRead32 (LAN9118_INT_STS) & INSTS_SW_INT) {
- *IrqStat |= EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT;
- MmioWrite32 (LAN9118_INT_STS,INSTS_SW_INT);
- }
- }
-
- // Check Status of transmitted packets
- // (We ignore TXSTATUS_NO_CA has it might happen in Full Duplex)
-
- NumTxStatusEntries = MmioRead32(LAN9118_TX_FIFO_INF) & TXFIFOINF_TXSUSED_MASK;
- if (NumTxStatusEntries > 0) {
- TxStatus = MmioRead32 (LAN9118_TX_STATUS);
- PacketTag = TxStatus >> 16;
- TxStatus = TxStatus & 0xFFFF;
- if ((TxStatus & TXSTATUS_ES) && (TxStatus != (TXSTATUS_ES | TXSTATUS_NO_CA))) {
- DEBUG ((EFI_D_ERROR, "LAN9118: There was an error transmitting. TxStatus=0x%08x:", TxStatus));
- if (TxStatus & TXSTATUS_NO_CA) {
- DEBUG ((EFI_D_ERROR, "- No carrier\n"));
- }
- if (TxStatus & TXSTATUS_DEF) {
- DEBUG ((EFI_D_ERROR, "- Packet tx was deferred\n"));
- }
- if (TxStatus & TXSTATUS_EDEF) {
- DEBUG ((EFI_D_ERROR, "- Tx ended because of excessive deferral\n"));
- }
- if (TxStatus & TXSTATUS_ECOLL) {
- DEBUG ((EFI_D_ERROR, "- Tx ended because of Excessive Collisions\n"));
- }
- if (TxStatus & TXSTATUS_LCOLL) {
- DEBUG ((EFI_D_ERROR, "- Packet Tx aborted after coll window of 64 bytes\n"));
- }
- if (TxStatus & TXSTATUS_LOST_CA) {
- DEBUG ((EFI_D_ERROR, "- Lost carrier during Tx\n"));
- }
- return EFI_DEVICE_ERROR;
- } else if (TxBuff != NULL) {
- LanDriver->Stats.TxTotalFrames += 1;
- *TxBuff = LanDriver->TxRing[PacketTag % LAN9118_TX_RING_NUM_ENTRIES];
- }
- }
-
- // Check for a TX Error interrupt
- Interrupts = MmioRead32 (LAN9118_INT_STS);
- if (Interrupts & INSTS_TXE) {
- DEBUG ((EFI_D_ERROR, "LAN9118: Transmitter error. Restarting..."));
-
- // Software reset, the TXE interrupt is cleared by the reset.
- Status = SoftReset (0, Snp);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "\n\tSoft Reset Failed: Hardware Error\n"));
- return EFI_DEVICE_ERROR;
- }
-
- // Reactivate the LEDs
- Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Restart the transmitter and if necessary the receiver.
- // Do not ask for FIFO reset as it has already been done
- // by SoftReset().
- //
- StartTx (START_TX_MAC | START_TX_CFG, Snp);
- if (Snp->Mode->ReceiveFilterSetting != 0) {
- StartRx (0, Snp);
- }
- }
-
- // Update the media status
- Status = CheckLinkStatus (0, Snp);
- if (EFI_ERROR(Status)) {
- Snp->Mode->MediaPresent = FALSE;
- } else {
- Snp->Mode->MediaPresent = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/*
- * UEFI Transmit() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpTransmit (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp,
- IN UINTN HdrSize,
- IN UINTN BuffSize,
- IN VOID* Data,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DstAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
- )
-{
- LAN9118_DRIVER *LanDriver;
- UINT32 TxFreeSpace;
- UINT32 TxStatusSpace;
- INT32 Count;
- UINT32 CommandA;
- UINT32 CommandB;
- UINT16 LocalProtocol;
- UINT32 *LocalData;
- UINT16 PacketTag;
-
-#if defined(EVAL_PERFORMANCE)
- UINT64 Perf;
- UINT64 StartClock;
- UINT64 EndClock;
-
- Perf = GetPerformanceCounterProperties (NULL, NULL);
- StartClock = GetPerformanceCounter ();
-#endif
-
- LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
-
- // Check preliminaries
- if ((Snp == NULL) || (Data == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check that driver was started and initialised
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver in stopped state\n"));
- return EFI_NOT_STARTED;
- }
-
- // Ensure header is correct size if non-zero
- if (HdrSize) {
- if (HdrSize != Snp->Mode->MediaHeaderSize) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DstAddr == NULL) || (Protocol == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- //
- // Check validity of BufferSize
- //
- if (BuffSize < Snp->Mode->MediaHeaderSize) {
- return EFI_BUFFER_TOO_SMALL;
- }
-
- // Before transmitting check the link status
- /*if (CheckLinkStatus (0, Snp) < 0) {
- return EFI_NOT_READY;
- }*/
-
- // Get DATA FIFO free space in bytes
- TxFreeSpace = TxDataFreeSpace (0, Snp);
- if (TxFreeSpace < BuffSize) {
- return EFI_NOT_READY;
- }
-
- // Get STATUS FIFO used space in bytes
- TxStatusSpace = TxStatusUsedSpace (0, Snp);
- if (TxStatusSpace > 500) {
- return EFI_NOT_READY;
- }
-
- // If DstAddr is not provided, get it from Buffer (we trust that the caller
- // has provided a well-formed frame).
- if (DstAddr == NULL) {
- DstAddr = (EFI_MAC_ADDRESS *) Data;
- }
-
- // Check for the nature of the frame
- if ((DstAddr->Addr[0] & 0x1) == 1) {
- LanDriver->Stats.TxMulticastFrames += 1;
- } else {
- LanDriver->Stats.TxUnicastFrames += 1;
- }
-
- // Check if broadcast
- if (DstAddr->Addr[0] == 0xFF) {
- LanDriver->Stats.TxBroadcastFrames += 1;
- }
-
- PacketTag = LanDriver->NextPacketTag;
- LanDriver->NextPacketTag++;
-
- if (HdrSize) {
-
- // Format pointer
- LocalData = (UINT32*) Data;
- LocalProtocol = *Protocol;
-
- // Create first buffer to pass to controller (for the header)
- CommandA = TX_CMD_A_FIRST_SEGMENT | TX_CMD_A_BUFF_SIZE (HdrSize);
- CommandB = TX_CMD_B_PACKET_TAG (PacketTag) | TX_CMD_B_PACKET_LENGTH (BuffSize);
-
- // Write the commands first
- MmioWrite32 (LAN9118_TX_DATA, CommandA);
- MmioWrite32 (LAN9118_TX_DATA, CommandB);
-
- // Write the destination address
- MmioWrite32 (LAN9118_TX_DATA,
- (DstAddr->Addr[0]) |
- (DstAddr->Addr[1] << 8) |
- (DstAddr->Addr[2] << 16) |
- (DstAddr->Addr[3] << 24)
- );
-
- MmioWrite32 (LAN9118_TX_DATA,
- (DstAddr->Addr[4]) |
- (DstAddr->Addr[5] << 8) |
- (SrcAddr->Addr[0] << 16) | // Write the Source Address
- (SrcAddr->Addr[1] << 24)
- );
-
- MmioWrite32 (LAN9118_TX_DATA,
- (SrcAddr->Addr[2]) |
- (SrcAddr->Addr[3] << 8) |
- (SrcAddr->Addr[4] << 16) |
- (SrcAddr->Addr[5] << 24)
- );
-
- // Write the Protocol
- MmioWrite32 (LAN9118_TX_DATA, (UINT32)(HTONS (LocalProtocol)));
-
- // Next buffer is the payload
- CommandA = TX_CMD_A_LAST_SEGMENT | TX_CMD_A_BUFF_SIZE (BuffSize - HdrSize) | TX_CMD_A_COMPLETION_INT | TX_CMD_A_DATA_START_OFFSET (2); // 2 bytes beginning offset
-
- // Write the commands
- MmioWrite32 (LAN9118_TX_DATA, CommandA);
- MmioWrite32 (LAN9118_TX_DATA, CommandB);
-
- // Write the payload
- for (Count = 0; Count < ((BuffSize + 3) >> 2) - 3; Count++) {
- MmioWrite32 (LAN9118_TX_DATA, LocalData[Count + 3]);
- }
- } else {
- // Format pointer
- LocalData = (UINT32*) Data;
-
- // Create a buffer to pass to controller
- CommandA = TX_CMD_A_FIRST_SEGMENT | TX_CMD_A_LAST_SEGMENT | TX_CMD_A_BUFF_SIZE (BuffSize) | TX_CMD_A_COMPLETION_INT;
- CommandB = TX_CMD_B_PACKET_TAG (PacketTag) | TX_CMD_B_PACKET_LENGTH (BuffSize);
-
- // Write the commands first
- MmioWrite32 (LAN9118_TX_DATA, CommandA);
- MmioWrite32 (LAN9118_TX_DATA, CommandB);
-
- // Write all the data
- for (Count = 0; Count < ((BuffSize + 3) >> 2); Count++) {
- MmioWrite32 (LAN9118_TX_DATA, LocalData[Count]);
- }
- }
-
- // Save the address of the submitted packet so we can notify the consumer that
- // it has been sent in GetStatus. When the packet tag appears in the Tx Status
- // Fifo, we will return Buffer in the TxBuff parameter of GetStatus.
- LanDriver->TxRing[PacketTag % LAN9118_TX_RING_NUM_ENTRIES] = Data;
-
-#if defined(EVAL_PERFORMANCE)
- EndClock = GetPerformanceCounter ();
- DEBUG ((EFI_D_ERROR, "Time processing: %d counts @ %d Hz\n", StartClock - EndClock,Perf));
-#endif
-
- LanDriver->Stats.TxGoodFrames += 1;
-
- return EFI_SUCCESS;
-}
-
-
-/*
- * UEFI Receive() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpReceive (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- OUT UINTN *HdrSize OPTIONAL,
- IN OUT UINTN *BuffSize,
- OUT VOID *Data,
- OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DstAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
- )
-{
- LAN9118_DRIVER *LanDriver;
- UINT32 IntSts;
- UINT32 RxFifoStatus;
- UINT32 NumPackets;
- UINT32 RxCfgValue;
- UINT32 PLength; // Packet length
- UINT32 ReadLimit;
- UINT32 Count;
- UINT32 Padding;
- UINT32 *RawData;
- EFI_MAC_ADDRESS Dst;
- EFI_MAC_ADDRESS Src;
- UINTN DroppedFrames;
- EFI_STATUS Status;
-
- LanDriver = INSTANCE_FROM_SNP_THIS (Snp);
-
-#if defined(EVAL_PERFORMANCE)
- UINT64 Perf = GetPerformanceCounterProperties (NULL, NULL);
- UINT64 StartClock = GetPerformanceCounter ();
-#endif
-
- // Check preliminaries
- if ((Snp == NULL) || (Data == NULL) || (BuffSize == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check that driver was started and initialised
- if (Snp->Mode->State == EfiSimpleNetworkStarted) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver not initialized\n"));
- return EFI_DEVICE_ERROR;
- } else if (Snp->Mode->State == EfiSimpleNetworkStopped) {
- DEBUG ((EFI_D_WARN, "Warning: LAN9118 Driver in stopped state\n"));
- return EFI_NOT_STARTED;
- }
-
- //
- // If the receiver raised the RXE error bit, check if the receiver status
- // FIFO is full and if not just acknowledge the error. The two other
- // conditions to get a RXE error are :
- // . the RX data FIFO is read whereas being empty.
- // . the RX status FIFO is read whereas being empty.
- // The RX data and status FIFO are read by this driver only in the following
- // code of this function. After the readings, the RXE error bit is checked
- // and if raised, the controller is reset. Thus, at this point, we consider
- // that the only valid reason to get an RXE error is the receiver status
- // FIFO being full. And if this is not the case, we consider that this is
- // a spurious error and we just get rid of it. We experienced such 'spurious'
- // errors when running the driver on an A57 on Juno. No valid reason to
- // explain those errors has been found so far and everything seems to
- // work perfectly when they are just ignored.
- //
- IntSts = MmioRead32 (LAN9118_INT_STS);
- if ((IntSts & INSTS_RXE) && (!(IntSts & INSTS_RSFF))) {
- MmioWrite32 (LAN9118_INT_STS, INSTS_RXE);
- }
-
- // Count dropped frames
- DroppedFrames = MmioRead32 (LAN9118_RX_DROP);
- LanDriver->Stats.RxDroppedFrames += DroppedFrames;
-
- NumPackets = RxStatusUsedSpace (0, Snp) / 4;
- if (!NumPackets) {
- return EFI_NOT_READY;
- }
-
- // Read Rx Status (only if not empty)
- RxFifoStatus = MmioRead32 (LAN9118_RX_STATUS);
- LanDriver->Stats.RxTotalFrames += 1;
-
- // First check for errors
- if ((RxFifoStatus & RXSTATUS_MII_ERROR) ||
- (RxFifoStatus & RXSTATUS_RXW_TO) ||
- (RxFifoStatus & RXSTATUS_FTL) ||
- (RxFifoStatus & RXSTATUS_LCOLL) ||
- (RxFifoStatus & RXSTATUS_LE) ||
- (RxFifoStatus & RXSTATUS_DB))
- {
- DEBUG ((EFI_D_WARN, "Warning: There was an error on frame reception.\n"));
- return EFI_DEVICE_ERROR;
- }
-
- // Check if we got a CRC error
- if (RxFifoStatus & RXSTATUS_CRC_ERROR) {
- DEBUG ((EFI_D_WARN, "Warning: Crc Error\n"));
- LanDriver->Stats.RxCrcErrorFrames += 1;
- LanDriver->Stats.RxDroppedFrames += 1;
- return EFI_DEVICE_ERROR;
- }
-
- // Check if we got a runt frame
- if (RxFifoStatus & RXSTATUS_RUNT) {
- DEBUG ((EFI_D_WARN, "Warning: Runt Frame\n"));
- LanDriver->Stats.RxUndersizeFrames += 1;
- LanDriver->Stats.RxDroppedFrames += 1;
- return EFI_DEVICE_ERROR;
- }
-
- // Check filtering status for this packet
- if (RxFifoStatus & RXSTATUS_FILT_FAIL) {
- DEBUG ((EFI_D_WARN, "Warning: Frame Failed Filtering\n"));
- // fast forward?
- }
-
- // Check if we got a broadcast frame
- if (RxFifoStatus & RXSTATUS_BCF) {
- LanDriver->Stats.RxBroadcastFrames += 1;
- }
-
- // Check if we got a multicast frame
- if (RxFifoStatus & RXSTATUS_MCF) {
- LanDriver->Stats.RxMulticastFrames += 1;
- }
-
- // Check if we got a unicast frame
- if ((RxFifoStatus & RXSTATUS_BCF) && ((RxFifoStatus & RXSTATUS_MCF) == 0)) {
- LanDriver->Stats.RxUnicastFrames += 1;
- }
-
- // Get the received packet length
- PLength = GET_RXSTATUS_PACKET_LENGTH(RxFifoStatus);
- LanDriver->Stats.RxTotalBytes += (PLength - 4);
-
- // If padding is applied, read more DWORDs
- if (PLength % 4) {
- Padding = 4 - (PLength % 4);
- ReadLimit = (PLength + Padding)/4;
- } else {
- ReadLimit = PLength/4;
- Padding = 0;
- }
-
- // Check buffer size
- if (*BuffSize < (PLength + Padding)) {
- *BuffSize = PLength + Padding;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- // Set the amount of data to be transfered out of FIFO for THIS packet
- // This can be used to trigger an interrupt, and status can be checked
- RxCfgValue = MmioRead32 (LAN9118_RX_CFG);
- RxCfgValue &= ~(RXCFG_RX_DMA_CNT_MASK);
- RxCfgValue |= RXCFG_RX_DMA_CNT (ReadLimit);
-
- // Set end alignment to 4-bytes
- RxCfgValue &= ~(RXCFG_RX_END_ALIGN_MASK);
- MmioWrite32 (LAN9118_RX_CFG, RxCfgValue);
-
- // Update buffer size
- *BuffSize = PLength; // -4 bytes may be needed: Received in buffer as
- // 4 bytes longer than packet actually is, unless
- // packet is < 64 bytes
-
- if (HdrSize != NULL)
- *HdrSize = Snp->Mode->MediaHeaderSize;
-
- // Format the pointer
- RawData = (UINT32*)Data;
-
- // Read Rx Packet
- for (Count = 0; Count < ReadLimit; Count++) {
- RawData[Count] = MmioRead32 (LAN9118_RX_DATA);
- }
-
- // Get the destination address
- if (DstAddr != NULL) {
- Dst.Addr[0] = (RawData[0] & 0xFF);
- Dst.Addr[1] = (RawData[0] & 0xFF00) >> 8;
- Dst.Addr[2] = (RawData[0] & 0xFF0000) >> 16;
- Dst.Addr[3] = (RawData[0] & 0xFF000000) >> 24;
- Dst.Addr[4] = (RawData[1] & 0xFF);
- Dst.Addr[5] = (RawData[1] & 0xFF00) >> 8;
- CopyMem (DstAddr, &Dst, NET_ETHER_ADDR_LEN);
- }
-
- // Get the source address
- if (SrcAddr != NULL) {
- Src.Addr[0] = (RawData[1] & 0xFF0000) >> 16;
- Src.Addr[1] = (RawData[1] & 0xFF000000) >> 24;
- Src.Addr[2] = (RawData[2] & 0xFF);
- Src.Addr[3] = (RawData[2] & 0xFF00) >> 8;
- Src.Addr[4] = (RawData[2] & 0xFF0000) >> 16;
- Src.Addr[5] = (RawData[2] & 0xFF000000) >> 24;
- CopyMem (SrcAddr, &Src, NET_ETHER_ADDR_LEN);
- }
-
- // Get the protocol
- if (Protocol != NULL) {
- *Protocol = NTOHS (RawData[3] & 0xFFFF);
- }
-
- // Check for Rx errors (worst possible error)
- if (MmioRead32 (LAN9118_INT_STS) & INSTS_RXE) {
- DEBUG ((EFI_D_WARN, "Warning: Receiver Error. Restarting...\n"));
-
- // Software reset, the RXE interrupt is cleared by the reset.
- Status = SoftReset (0, Snp);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Error: Soft Reset Failed: Hardware Error.\n"));
- return EFI_DEVICE_ERROR;
- }
-
- // Reactivate the LEDs
- Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Restart the receiver and the transmitter without reseting the FIFOs
- // as it has been done by SoftReset().
- //
- StartRx (0, Snp);
- StartTx (START_TX_MAC | START_TX_CFG, Snp);
-
- // Say that command could not be sent
- return EFI_DEVICE_ERROR;
- }
-
-#if defined(EVAL_PERFORMANCE)
- UINT64 EndClock = GetPerformanceCounter ();
- DEBUG ((EFI_D_ERROR, "Receive Time processing: %d counts @ %d Hz\n", StartClock - EndClock,Perf));
-#endif
-
- LanDriver->Stats.RxGoodFrames += 1;
-
- return EFI_SUCCESS;
-}
diff --git a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.h b/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.h
deleted file mode 100644
index cc883e8079..0000000000
--- a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/** @file
-*
-* Copyright (c) 2012-2014, 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 __LAN9118_DXE_H__
-#define __LAN9118_DXE_H__
-
-#include <Uefi.h>
-#include <Uefi/UefiSpec.h>
-#include <Base.h>
-
-// Protocols used by this driver
-#include <Protocol/SimpleNetwork.h>
-#include <Protocol/ComponentName2.h>
-#include <Protocol/PxeBaseCode.h>
-#include <Protocol/DevicePath.h>
-
-// Libraries used by this driver
-#include <Library/UefiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/NetLib.h>
-#include <Library/DevicePathLib.h>
-
-#include "Lan9118DxeUtil.h"
-#include "Lan9118DxeHw.h"
-
-#define LAN9118_STALL 2
-
-#define LAN9118_DEFAULT_MAC_ADDRL 0x00F70200
-#define LAN9118_DEFAULT_MAC_ADDRH 0x00009040
-
-#define LAN9118_TX_DATA_SIZE 4608
-#define LAN9118_TX_STATUS_SIZE 512
-#define LAN9118_RX_DATA_SIZE 10560
-#define LAN9118_RX_STATUS_SIZE 704
-
-#define LAN9118_TX_RING_NUM_ENTRIES 32
-
-/*------------------------------------------------------------------------------
- LAN9118 Information Structure
-------------------------------------------------------------------------------*/
-
-typedef struct {
- // Driver signature
- UINT32 Signature;
- EFI_HANDLE ControllerHandle;
-
- // EFI SNP protocol instances
- EFI_SIMPLE_NETWORK_PROTOCOL Snp;
- EFI_SIMPLE_NETWORK_MODE SnpMode;
-
- // EFI Snp statistics instance
- EFI_NETWORK_STATISTICS Stats;
-
- // Saved transmitted buffers so we can notify consumers when packets have been sent.
- UINT16 NextPacketTag;
- VOID *TxRing[LAN9118_TX_RING_NUM_ENTRIES];
-} LAN9118_DRIVER;
-
-#define LAN9118_SIGNATURE SIGNATURE_32('l', 'a', 'n', '9')
-#define INSTANCE_FROM_SNP_THIS(a) CR(a, LAN9118_DRIVER, Snp, LAN9118_SIGNATURE)
-
-
-/*---------------------------------------------------------------------------------------------------------------------
-
- UEFI-Compliant functions for EFI_SIMPLE_NETWORK_PROTOCOL
-
- Refer to the Simple Network Protocol section (21.1) in the UEFI 2.3.1 Specification for related definitions
-
----------------------------------------------------------------------------------------------------------------------*/
-
-
-/*
- * UEFI Start() function
- *
- * Parameters:
- *
- * @param pobj: A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
- *
- * Description:
- *
- * This function starts a network interface. If the network interface successfully starts, then
- * EFI_SUCCESS will be returned.
- */
-EFI_STATUS
-EFIAPI
-SnpStart (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
- );
-
-/*
- * UEFI Stop() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpStop (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
- );
-
-/*
- * UEFI Initialize() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpInitialize (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN UINTN rx_buff_size,
- IN UINTN tx_buff_size
- );
-
-/*
- * UEFI Reset() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpReset (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN ext_ver
- );
-
-/*
- * UEFI Shutdown() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpShutdown (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp
- );
-
-/*
- * UEFI ReceiveFilters() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpReceiveFilters (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN UINT32 enable,
- IN UINT32 disable,
- IN BOOLEAN reset_mfilter,
- IN UINTN num_mfilter,
- IN EFI_MAC_ADDRESS *mfilter
- );
-
-/*
- * UEFI StationAddress() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpStationAddress (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN reset,
- IN EFI_MAC_ADDRESS *new_maddr
- );
-
-/*
- * UEFI Statistics() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpStatistics (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN reset,
- IN OUT UINTN *stat_size,
- OUT EFI_NETWORK_STATISTICS *stat_table
- );
-
-/*
- * UEFI MCastIPtoMAC() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpMcastIptoMac (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN use_ipv6,
- IN EFI_IP_ADDRESS *ip_addr,
- OUT EFI_MAC_ADDRESS *mac_addr
- );
-
-/*
- * UEFI NvData() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpNvData (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN BOOLEAN read_write,
- IN UINTN offset,
- IN UINTN buff_size,
- IN OUT VOID *data
- );
-
-/*
- * UEFI GetStatus() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpGetStatus (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- OUT UINT32 *irq_stat OPTIONAL,
- OUT VOID **tx_buff OPTIONAL
- );
-
-/*
- * UEFI Transmit() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpTransmit (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- IN UINTN hdr_size,
- IN UINTN buff_size,
- IN VOID *data,
- IN EFI_MAC_ADDRESS *src_addr OPTIONAL,
- IN EFI_MAC_ADDRESS *dest_addr OPTIONAL,
- IN UINT16 *protocol OPTIONAL
- );
-
-/*
- * UEFI Receive() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpReceive (
- IN EFI_SIMPLE_NETWORK_PROTOCOL* Snp,
- OUT UINTN *hdr_size OPTIONAL,
- IN OUT UINTN *buff_size,
- OUT VOID *data,
- OUT EFI_MAC_ADDRESS *src_addr OPTIONAL,
- OUT EFI_MAC_ADDRESS *dest_addr OPTIONAL,
- OUT UINT16 *protocol OPTIONAL
- );
-
-
-/*---------------------------------------------------------------------------------------------------------------------
-
- UEFI-Compliant functions for EFI_COMPONENT_NAME2_PROTOCOL
-
- Refer to the Component Name Protocol section (10.5) in the UEFI 2.3.1 Specification for related definitions
-
----------------------------------------------------------------------------------------------------------------------*/
-
-/*
- * UEFI GetDriverName() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpGetDriverName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *Snp,
- IN CHAR8 *Lang,
- OUT CHAR16 **DriverName
- );
-
-/*
- * UEFI GetControllerName() function
- *
- */
-EFI_STATUS
-EFIAPI
-SnpGetControllerName (
- IN EFI_COMPONENT_NAME2_PROTOCOL *Cnp,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Lang,
- OUT CHAR16 **ControllerName
- );
-
-/*------------------------------------------------------------------------------
- Utility functions
-------------------------------------------------------------------------------*/
-
-EFI_MAC_ADDRESS
-GetCurrentMacAddress (
- VOID
- );
-
-#endif // __LAN9118_DXE_H__
diff --git a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf b/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf
deleted file mode 100644
index 9e5f98b4bd..0000000000
--- a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf
+++ /dev/null
@@ -1,56 +0,0 @@
-#/** @file
-# INF file for the LAN9118 Network Controller Driver.
-#
-# Copyright (c) 2012-2015, 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = Lan9118Dxe
- FILE_GUID = 4356b162-d0b2-11e1-8952-4437e6a60ea5
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 0.1
- ENTRY_POINT = Lan9118DxeEntry
-
-[Sources.common]
- Lan9118Dxe.c
- Lan9118DxeUtil.c
- Lan9118Dxe.h
-
-[Packages]
- EmbeddedPkg/EmbeddedPkg.dec
- NetworkPkg/NetworkPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- BaseLib
- UefiLib
- NetLib
- UefiDriverEntryPoint
- BaseMemoryLib
- ArmLib
- IoLib
- DevicePathLib
-
-[Protocols]
- gEfiSimpleNetworkProtocolGuid
- gEfiMetronomeArchProtocolGuid
- gEfiPxeBaseCodeProtocolGuid
- gEfiDevicePathProtocolGuid
-
-[FixedPcd]
- gEmbeddedTokenSpaceGuid.PcdLan9118DxeBaseAddress
- gEmbeddedTokenSpaceGuid.PcdLan9118DefaultMacAddress
-
-[Depex]
- TRUE
diff --git a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeHw.h b/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeHw.h
deleted file mode 100644
index 9e89d27459..0000000000
--- a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeHw.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/** @file
-*
-* Copyright (c) 2012-2014, 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 __LAN9118_DXE_HW_H__
-#define __LAN9118_DXE_HW_H__
-
-/*------------------------------------------------------------------------------
- LAN9118 SMCS Registers
-------------------------------------------------------------------------------*/
-
-// Base address as on the VE board
-#define LAN9118_BA ((UINT32) PcdGet32(PcdLan9118DxeBaseAddress))
-
-/* ------------- Tx and Rx Data and Status Memory Locations ------------------*/
-#define LAN9118_RX_DATA (0x00000000 + LAN9118_BA)
-#define LAN9118_RX_STATUS (0x00000040 + LAN9118_BA)
-#define LAN9118_RX_STATUS_PEEK (0x00000044 + LAN9118_BA)
-#define LAN9118_TX_DATA (0x00000020 + LAN9118_BA)
-#define LAN9118_TX_STATUS (0x00000048 + LAN9118_BA)
-#define LAN9118_TX_STATUS_PEEK (0x0000004C + LAN9118_BA)
-
-/* ------------- System Control and Status Registers -------------------------*/
-#define LAN9118_ID_REV (0x00000050 + LAN9118_BA) // Chip ID and Revision
-#define LAN9118_IRQ_CFG (0x00000054 + LAN9118_BA) // Interrupt Configuration
-#define LAN9118_INT_STS (0x00000058 + LAN9118_BA) // Interrupt Status
-#define LAN9118_INT_EN (0x0000005C + LAN9118_BA) // Interrupt Enable
-//#define LAN9118_RESERVED (0x00000060)
-#define LAN9118_BYTE_TEST (0x00000064 + LAN9118_BA) // Byte Order Test
-#define LAN9118_FIFO_INT (0x00000068 + LAN9118_BA) // FIFO Level Interrupts
-#define LAN9118_RX_CFG (0x0000006C + LAN9118_BA) // Receive Configuration
-#define LAN9118_TX_CFG (0x00000070 + LAN9118_BA) // Transmit Configuration
-#define LAN9118_HW_CFG (0x00000074 + LAN9118_BA) // Hardware Configuration
-#define LAN9118_RX_DP_CTL (0x00000078 + LAN9118_BA) // Receive Data-Path Configuration
-#define LAN9118_RX_FIFO_INF (0x0000007C + LAN9118_BA) // Receive FIFO Information
-#define LAN9118_TX_FIFO_INF (0x00000080 + LAN9118_BA) // Transmit FIFO Information
-#define LAN9118_PMT_CTRL (0x00000084 + LAN9118_BA) // Power Management Control
-#define LAN9118_GPIO_CFG (0x00000088 + LAN9118_BA) // General Purpose IO Configuration
-#define LAN9118_GPT_CFG (0x0000008C + LAN9118_BA) // General Purpose Timer Configuration
-#define LAN9118_GPT_CNT (0x00000090 + LAN9118_BA) // General Purpose Timer Current Count
-#define LAN9118_WORD_SWAP (0x00000098 + LAN9118_BA) // Word Swap Control
-#define LAN9118_FREE_RUN (0x0000009C + LAN9118_BA) // Free-Run 25MHz Counter
-#define LAN9118_RX_DROP (0x000000A0 + LAN9118_BA) // Receiver Dropped Frames Counter
-#define LAN9118_MAC_CSR_CMD (0x000000A4 + LAN9118_BA) // MAC CSR Synchronizer Command
-#define LAN9118_MAC_CSR_DATA (0x000000A8 + LAN9118_BA) // MAC CSR Synchronizer Data
-#define LAN9118_AFC_CFG (0x000000AC + LAN9118_BA) // Automatic Flow Control Configuration
-#define LAN9118_E2P_CMD (0x000000B0 + LAN9118_BA) // EEPROM Command
-#define LAN9118_E2P_DATA (0x000000B4 + LAN9118_BA) // EEPROM Data
-
-
-// Receiver Status bits
-#define RXSTATUS_CRC_ERROR BIT1 // Cyclic Redundancy Check Error
-#define RXSTATUS_DB BIT2 // Dribbling bit: Frame had non-integer multiple of 8bits
-#define RXSTATUS_MII_ERROR BIT3 // Receive error during interception
-#define RXSTATUS_RXW_TO BIT4 // Incomming frame larger than 2kb
-#define RXSTATUS_FT BIT5 // 1: Ether type / 0: 802.3 type frame
-#define RXSTATUS_LCOLL BIT6 // Late collision detected
-#define RXSTATUS_FTL BIT7 // Frame longer than Ether type
-#define RXSTATUS_MCF BIT10 // Frame has Multicast Address
-#define RXSTATUS_RUNT BIT11 // Bad frame
-#define RXSTATUS_LE BIT12 // Actual length of frame different than it claims
-#define RXSTATUS_BCF BIT13 // Frame has Broadcast Address
-#define RXSTATUS_ES BIT15 // Reports any error from bits 1,6,7 and 11
-#define RXSTATUS_PL_MASK (0x3FFF0000) // Packet length bit mask
-#define GET_RXSTATUS_PACKET_LENGTH(RxStatus) (((RxStatus) >> 16) & 0x3FFF) // Packet length bit mask
-#define RXSTATUS_FILT_FAIL BIT30 // The frame failed filtering test
-
-// Transmitter Status bits
-#define TXSTATUS_DEF BIT0 // Packet tx was deferred
-#define TXSTATUS_EDEF BIT2 // Tx ended because of excessive deferral (> 24288 bit times)
-#define TXSTATUS_CC_MASK (0x00000078) // Collision Count (before Tx) bit mask
-#define TXSTATUS_ECOLL BIT8 // Tx ended because of Excessive Collisions (makes CC_MASK invalid after 16 collisions)
-#define TXSTATUS_LCOLL BIT9 // Packet Tx aborted after coll window of 64 bytes
-#define TXSTATUS_NO_CA BIT10 // Carrier signal not present during Tx (bad?)
-#define TXSTATUS_LOST_CA BIT11 // Lost carrier during Tx
-#define TXSTATUS_ES BIT15 // Reports any errors from bits 1,2,8,9,10 and 11
-#define TXSTATUS_PTAG_MASK (0xFFFF0000) // Mask for Unique ID of packets (So we know who the packets are for)
-
-// ID_REV register bits
-#define IDREV_ID ((MmioRead32(LAN9118_ID_REV) & 0xFFFF0000) >> 16)
-#define IDREV_REV (MmioRead32(LAN9118_ID_REV) & 0x0000FFFF)
-
-// Interrupt Config Register bits
-#define IRQCFG_IRQ_TYPE BIT0 // IRQ Buffer type
-#define IRQCFG_IRQ_POL BIT4 // IRQ Polarity
-#define IRQCFG_IRQ_EN BIT8 // Enable external interrupt
-#define IRQCFG_IRQ_INT BIT12 // State of internal interrupts line
-#define IRQCFG_INT_DEAS_STS BIT13 // State of deassertion interval
-#define IRQCFG_INT_DEAS_CLR BIT14 // Clear the deassertion counter
-#define IRQCFG_INT_DEAS_MASK (0xFF000000) // Interrupt deassertion interval value mask
-
-// Interrupt Status Register bits
-#define INSTS_GPIO_MASK (0x7) // GPIO interrupts mask
-#define INSTS_RSFL (0x8) // Rx Status FIFO Level reached
-#define INSTS_RSFF BIT4 // Rx Status FIFO full
-#define INSTS_RXDF_INT BIT6 // Rx Frame dropped
-#define INSTS_TSFL BIT7 // Tx Status FIFO Level reached
-#define INSTS_TSFF BIT8 // Tx Status FIFO full
-#define INSTS_TDFA BIT9 // Tx Data FIFO Level exceeded
-#define INSTS_TDFO BIT10 // Tx Data FIFO full
-#define INSTS_TXE BIT13 // Transmitter Error
-#define INSTS_RXE BIT14 // Receiver Error
-#define INSTS_RWT BIT15 // Packet > 2048 bytes received
-#define INSTS_TXSO BIT16 // Tx Status FIFO Overflow
-#define INSTS_PME_INT BIT17 // PME Signal detected
-#define INSTS_PHY_INT BIT18 // Indicates PHY Interrupt
-#define INSTS_GPT_INT BIT19 // GP Timer wrapped past 0xFFFF
-#define INSTS_RXD_INT BIT20 // Indicates that amount of data written to RX_CFG was cleared
-#define INSTS_TX_IOC BIT21 // Finished loading IOC flagged buffer to Tx FIFO
-#define INSTS_RXDFH_INT BIT23 // Rx Dropped frames went past 0x7FFFFFFF
-#define INSTS_RXSTOP_INT BIT24 // Rx was stopped
-#define INSTS_TXSTOP_INT BIT25 // Tx was stopped
-#define INSTS_SW_INT BIT31 // Software Interrupt occurred
-
-// Interrupt Enable Register bits
-
-
-// Hardware Config Register bits
-#define HWCFG_SRST BIT0 // Software Reset bit (SC)
-#define HWCFG_SRST_TO BIT1 // Software Reset Timeout bit (RO)
-#define HWCFG_BMODE BIT2 // 32/16 bit Mode bit (RO)
-#define HWCFG_TX_FIFO_SIZE_MASK (~ (UINT32)0xF0000) // Mask to Clear FIFO Size
-#define HWCFG_MBO BIT20 // Must Be One bit
-
-// Power Management Control Register
-#define MPTCTRL_READY BIT0 // Device ready indicator
-#define MPTCTRL_PME_EN BIT1 // Enable external PME signals
-#define MPTCTRL_PME_POL BIT2 // Set polarity of PME signals
-#define MPTCTRL_PME_IND BIT3 // Signal type of PME (refer to Spec)
-#define MPTCTRL_WUPS_MASK (0x18) // Wake up status indicator mask
-#define MPTCTRL_PME_TYPE BIT6 // PME Buffer type (Open Drain or Push-Pull)
-#define MPTCTRL_ED_EN BIT8 // Energy-detect enable
-#define MPTCTRL_WOL_EN BIT9 // Enable wake-on-lan
-#define MPTCTRL_PHY_RST BIT10 // Reset the PHY
-#define MPTCTRL_PM_MODE_MASK (BIT12 | BIT13) // Set the power mode
-
-// PHY control register bits
-#define PHYCR_COLL_TEST BIT7 // Collision test enable
-#define PHYCR_DUPLEX_MODE BIT8 // Set Duplex Mode
-#define PHYCR_RST_AUTO BIT9 // Restart Auto-Negotiation of Link abilities
-#define PHYCR_PD BIT11 // Power-Down switch
-#define PHYCR_AUTO_EN BIT12 // Auto-Negotiation Enable
-#define PHYCR_SPEED_SEL BIT13 // Link Speed Selection
-#define PHYCR_LOOPBK BIT14 // Set loopback mode
-#define PHYCR_RESET BIT15 // Do a PHY reset
-
-// PHY status register bits
-#define PHYSTS_EXT_CAP BIT0 // Extended Capabilities Register capability
-#define PHYSTS_JABBER BIT1 // Jabber condition detected
-#define PHYSTS_LINK_STS BIT2 // Link Status
-#define PHYSTS_AUTO_CAP BIT3 // Auto-Negotiation Capability
-#define PHYSTS_REMOTE_FAULT BIT4 // Remote fault detected
-#define PHYSTS_AUTO_COMP BIT5 // Auto-Negotiation Completed
-#define PHYSTS_10BASET_HDPLX BIT11 // 10Mbps Half-Duplex ability
-#define PHYSTS_10BASET_FDPLX BIT12 // 10Mbps Full-Duplex ability
-#define PHYSTS_100BASETX_HDPLX BIT13 // 100Mbps Half-Duplex ability
-#define PHYSTS_100BASETX_FDPLX BIT14 // 100Mbps Full-Duplex ability
-#define PHYSTS_100BASE_T4 BIT15 // Base T4 ability
-
-// PHY Auto-Negotiation advertisement
-#define PHYANA_SEL_MASK ((UINT32)0x1F) // Link type selector
-#define PHYANA_10BASET BIT5 // Advertise 10BASET capability
-#define PHYANA_10BASETFD BIT6 // Advertise 10BASET Full duplex capability
-#define PHYANA_100BASETX BIT7 // Advertise 100BASETX capability
-#define PHYANA_100BASETXFD BIT8 // Advertise 100 BASETX Full duplex capability
-#define PHYANA_PAUSE_OP_MASK (3 << 10) // Advertise PAUSE frame capability
-#define PHYANA_REMOTE_FAULT BIT13 // Remote fault detected
-
-
-// PHY Auto-Negotiation Link Partner Ability
-
-// PHY Auto-Negotiation Expansion
-
-// PHY Mode control/status
-
-// PHY Special Modes
-
-// PHY Special control/status
-
-// PHY Interrupt Source Flags
-
-// PHY Interrupt Mask
-
-// PHY Super Special control/status
-#define PHYSSCS_HCDSPEED_MASK (7 << 2) // Speed indication
-#define PHYSSCS_AUTODONE BIT12 // Auto-Negotiation Done
-
-
-// MAC control register bits
-#define MACCR_RX_EN BIT2 // Enable Receiver bit
-#define MACCR_TX_EN BIT3 // Enable Transmitter bit
-#define MACCR_DFCHK BIT5 // Deferral Check bit
-#define MACCR_PADSTR BIT8 // Automatic Pad Stripping bit
-#define MACCR_BOLMT_MASK (0xC0) // Back-Off limit mask
-#define MACCR_DISRTY BIT10 // Disable Transmit Retry bit
-#define MACCR_BCAST BIT11 // Disable Broadcast Frames bit
-#define MACCR_LCOLL BIT12 // Late Collision Control bit
-#define MACCR_HPFILT BIT13 // Hash/Perfect Filtering Mode bit
-#define MACCR_HO BIT15 // Hash Only Filtering Mode
-#define MACCR_PASSBAD BIT16 // Receive all frames that passed filter bit
-#define MACCR_INVFILT BIT17 // Enable Inverse Filtering bit
-#define MACCR_PRMS BIT18 // Promiscuous Mode bit
-#define MACCR_MCPAS BIT19 // Pass all Multicast packets bit
-#define MACCR_FDPX BIT20 // Full Duplex Mode bit
-#define MACCR_LOOPBK BIT21 // Loopback operation mode bit
-#define MACCR_RCVOWN BIT23 // Disable Receive Own frames bit
-#define MACCR_RX_ALL BIT31 // Receive all Packets and route to Filter
-
-// Wake-Up Control and Status Register
-#define WUCSR_MPEN BIT1 // Magic Packet enable (allow wake from Magic P)
-#define WUCSR_WUEN BIT2 // Allow remote wake up using Wake-Up Frames
-#define WUCSR_MPR_MASK (0x10) // Received Magic Packet
-#define WUCSR_WUFR_MASK (0x20) // Received Wake-Up Frame
-#define WUCSR_GUE BIT9 // Enable wake on global unicast frames
-
-// RX Configuration Register bits
-#define RXCFG_RXDOFF_MASK (0x1F00) // Rx Data Offset in Bytes
-#define RXCFG_RX_DUMP BIT15 // Clear Rx data and status FIFOs
-#define RXCFG_RX_DMA_CNT_MASK (0x0FFF0000) // Amount of data to be read from Rx FIFO
-#define RXCFG_RX_DMA_CNT(cnt) (((cnt) & 0xFFF) << 16) // Amount of data to be read from Rx FIFO
-#define RXCFG_RX_END_ALIGN_MASK (0xC0000000) // Alignment to preserve
-
-// TX Configuration Register bits
-#define TXCFG_STOP_TX BIT0 // Stop the transmitter
-#define TXCFG_TX_ON BIT1 // Start the transmitter
-#define TXCFG_TXSAO BIT2 // Tx Status FIFO full
-#define TXCFG_TXD_DUMP BIT14 // Clear Tx Data FIFO
-#define TXCFG_TXS_DUMP BIT15 // Clear Tx Status FIFO
-
-// Rx FIFO Information Register bits
-#define RXFIFOINF_RXDUSED_MASK (0xFFFF) // Rx Data FIFO Used Space
-#define RXFIFOINF_RXSUSED_MASK (0xFF0000) // Rx Status FIFO Used Space
-
-// Tx FIFO Information Register bits
-#define TXFIFOINF_TDFREE_MASK (0xFFFF) // Tx Data FIFO Free Space
-#define TXFIFOINF_TXSUSED_MASK (0xFF0000) // Tx Status FIFO Used Space
-
-// E2P Register
-#define E2P_EPC_BUSY BIT31
-#define E2P_EPC_CMD_READ (0)
-#define E2P_EPC_TIMEOUT BIT9
-#define E2P_EPC_MAC_ADDRESS_LOADED BIT8
-#define E2P_EPC_ADDRESS(address) ((address) & 0xFFFF)
-
-// GPIO Configuration register
-#define GPIO_GPIO0_PUSH_PULL BIT16
-#define GPIO_GPIO1_PUSH_PULL BIT17
-#define GPIO_GPIO2_PUSH_PULL BIT18
-#define GPIO_LED1_ENABLE BIT28
-#define GPIO_LED2_ENABLE BIT29
-#define GPIO_LED3_ENABLE BIT30
-
-// MII_ACC bits
-#define MII_ACC_MII_BUSY BIT0
-#define MII_ACC_MII_WRITE BIT1
-#define MII_ACC_MII_READ 0
-
-#define MII_ACC_PHY_VALUE BIT11
-#define MII_ACC_MII_REG_INDEX(index) (((index) & 0x1F) << 6)
-
-//
-// PHY Control Indexes
-//
-#define PHY_INDEX_BASIC_CTRL 0
-#define PHY_INDEX_BASIC_STATUS 1
-#define PHY_INDEX_ID1 2
-#define PHY_INDEX_ID2 3
-#define PHY_INDEX_AUTO_NEG_ADVERT 4
-#define PHY_INDEX_AUTO_NEG_LINK_ABILITY 5
-#define PHY_INDEX_AUTO_NEG_EXP 6
-#define PHY_INDEX_MODE 17
-#define PHY_INDEX_SPECIAL_MODES 18
-#define PHY_INDEX_SPECIAL_CTLR 27
-#define PHY_INDEX_INT_SRC 29
-#define PHY_INDEX_INT_MASK 30
-#define PHY_INDEX_SPECIAL_PHY_CTLR 31
-
-// Indirect MAC Indexes
-#define INDIRECT_MAC_INDEX_CR 1
-#define INDIRECT_MAC_INDEX_ADDRH 2
-#define INDIRECT_MAC_INDEX_ADDRL 3
-#define INDIRECT_MAC_INDEX_HASHH 4
-#define INDIRECT_MAC_INDEX_HASHL 5
-#define INDIRECT_MAC_INDEX_MII_ACC 6
-#define INDIRECT_MAC_INDEX_MII_DATA 7
-
-//
-// MAC CSR Synchronizer Command register
-//
-#define MAC_CSR_BUSY BIT31
-#define MAC_CSR_READ BIT30
-#define MAC_CSR_WRITE 0
-#define MAC_CSR_ADDR(Addr) ((Addr) & 0xFF)
-
-//
-// TX Packet Format
-//
-#define TX_CMD_A_COMPLETION_INT BIT31
-#define TX_CMD_A_FIRST_SEGMENT BIT13
-#define TX_CMD_A_LAST_SEGMENT BIT12
-#define TX_CMD_A_BUFF_SIZE(size) ((size) & 0x000003FF)
-#define TX_CMD_A_DATA_START_OFFSET(offset) (((offset) & 0x1F) << 16)
-#define TX_CMD_B_PACKET_LENGTH(size) ((size) & 0x000003FF)
-#define TX_CMD_B_PACKET_TAG(tag) (((tag) & 0x3FF) << 16)
-
-// Hardware Configuration Register
-#define HW_CFG_TX_FIFO_SIZE_MASK (0xF << 16)
-#define HW_CFG_TX_FIFO_SIZE(size) (((size) & 0xF) << 16)
-
-// EEPROM Definition
-#define EEPROM_EXTERNAL_SERIAL_EEPROM 0xA5
-
-//
-// Conditional compilation flags
-//
-//#define EVAL_PERFORMANCE
-
-
-#endif /* __LAN9118_DXE_HDR_H__ */
diff --git a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.c b/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.c
deleted file mode 100644
index 9531b0ba2a..0000000000
--- a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.c
+++ /dev/null
@@ -1,1005 +0,0 @@
-/** @file
-*
-* Copyright (c) 2012-2014, 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.
-*
-**/
-
-#include "Lan9118Dxe.h"
-
-STATIC EFI_MAC_ADDRESS mZeroMac = { { 0 } };
-
-/**
- This internal function reverses bits for 32bit data.
-
- @param Value The data to be reversed.
-
- @return Data reversed.
-
-**/
-UINT32
-ReverseBits (
- UINT32 Value
- )
-{
- UINTN Index;
- UINT32 NewValue;
-
- NewValue = 0;
- for (Index = 0; Index < 32; Index++) {
- if ((Value & (1 << Index)) != 0) {
- NewValue = NewValue | (1 << (31 - Index));
- }
- }
-
- return NewValue;
-}
-
-/*
-** Create Ethernet CRC
-**
-** INFO USED:
-** 1: http://en.wikipedia.org/wiki/Cyclic_redundancy_check
-**
-** 2: http://www.erg.abdn.ac.uk/~gorry/eg3567/dl-pages/crc.html
-**
-** 3: http://en.wikipedia.org/wiki/Computation_of_CRC
-*/
-UINT32
-GenEtherCrc32 (
- IN EFI_MAC_ADDRESS *Mac,
- IN UINT32 AddrLen
- )
-{
- INT32 Iter;
- UINT32 Remainder;
- UINT8 *Ptr;
-
- Iter = 0;
- Remainder = 0xFFFFFFFF; // 0xFFFFFFFF is standard seed for Ethernet
-
- // Convert Mac Address to array of bytes
- Ptr = (UINT8*)Mac;
-
- // Generate the Crc bit-by-bit (LSB first)
- while (AddrLen--) {
- Remainder ^= *Ptr++;
- for (Iter = 0;Iter < 8;Iter++) {
- // Check if exponent is set
- if (Remainder & 1) {
- Remainder = (Remainder >> 1) ^ CRC_POLYNOMIAL;
- } else {
- Remainder = (Remainder >> 1) ^ 0;
- }
- }
- }
-
- // Reverse the bits before returning (to Big Endian)
- //TODO: Need to be reviewed. Do we want to do a bit reverse or a byte reverse (in this case use SwapBytes32())
- return ReverseBits (Remainder);
-}
-
-// Function to read from MAC indirect registers
-UINT32
-IndirectMACRead32 (
- UINT32 Index
- )
-{
- UINT32 MacCSR;
-
- // Check index is in the range
- ASSERT(Index <= 12);
-
- // Wait until CSR busy bit is cleared
- while ((MmioRead32 (LAN9118_MAC_CSR_CMD) & MAC_CSR_BUSY) == MAC_CSR_BUSY);
-
- // Set CSR busy bit to ensure read will occur
- // Set the R/W bit to indicate we are reading
- // Set the index of CSR Address to access desired register
- MacCSR = MAC_CSR_BUSY | MAC_CSR_READ | MAC_CSR_ADDR(Index);
-
- // Write to the register
- MmioWrite32 (LAN9118_MAC_CSR_CMD, MacCSR);
-
- // Wait until CSR busy bit is cleared
- while ((MmioRead32 (LAN9118_MAC_CSR_CMD) & MAC_CSR_BUSY) == MAC_CSR_BUSY);
-
- // Now read from data register to get read value
- return MmioRead32 (LAN9118_MAC_CSR_DATA);
-}
-
-// Function to write to MAC indirect registers
-UINT32
-IndirectMACWrite32 (
- UINT32 Index,
- UINT32 Value
- )
-{
- UINT32 ValueWritten;
- UINT32 MacCSR;
-
- // Check index is in the range
- ASSERT(Index <= 12);
-
- // Wait until CSR busy bit is cleared
- while ((MmioRead32 (LAN9118_MAC_CSR_CMD) & MAC_CSR_BUSY) == MAC_CSR_BUSY);
-
- // Set CSR busy bit to ensure read will occur
- // Set the R/W bit to indicate we are writing
- // Set the index of CSR Address to access desired register
- MacCSR = MAC_CSR_BUSY | MAC_CSR_WRITE | MAC_CSR_ADDR(Index);
-
- // Now write the value to the register before issuing the write command
- ValueWritten = MmioWrite32 (LAN9118_MAC_CSR_DATA, Value);
-
- // Write the config to the register
- MmioWrite32 (LAN9118_MAC_CSR_CMD, MacCSR);
-
- // Wait until CSR busy bit is cleared
- while ((MmioRead32 (LAN9118_MAC_CSR_CMD) & MAC_CSR_BUSY) == MAC_CSR_BUSY);
-
- return ValueWritten;
-}
-
-// Function to read from MII register (PHY Access)
-UINT32
-IndirectPHYRead32 (
- UINT32 Index
- )
-{
- UINT32 ValueRead;
- UINT32 MiiAcc;
-
- // Check it is a valid index
- ASSERT(Index < 31);
-
- // Wait for busy bit to clear
- while ((IndirectMACRead32 (INDIRECT_MAC_INDEX_MII_ACC) & MII_ACC_MII_BUSY) == MII_ACC_MII_BUSY);
-
- // Clear the R/W bit to indicate we are reading
- // Set the index of the MII register
- // Set the PHY Address
- // Set the MII busy bit to allow read
- MiiAcc = MII_ACC_MII_READ | MII_ACC_MII_REG_INDEX(Index) | MII_ACC_PHY_VALUE | MII_ACC_MII_BUSY;
-
- // Now write this config to register
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_MII_ACC, MiiAcc & 0xFFFF);
-
- // Wait for busy bit to clear
- while ((IndirectMACRead32 (INDIRECT_MAC_INDEX_MII_ACC) & MII_ACC_MII_BUSY) == MII_ACC_MII_BUSY);
-
- // Now read the value of the register
- ValueRead = (IndirectMACRead32 (INDIRECT_MAC_INDEX_MII_DATA) & 0xFFFF); // only lower 16 bits are valid for any PHY register
-
- return ValueRead;
-}
-
-
-// Function to write to the MII register (PHY Access)
-UINT32
-IndirectPHYWrite32 (
- UINT32 Index,
- UINT32 Value
- )
-{
- UINT32 MiiAcc;
- UINT32 ValueWritten;
-
- // Check it is a valid index
- ASSERT(Index < 31);
-
- // Wait for busy bit to clear
- while ((IndirectMACRead32 (INDIRECT_MAC_INDEX_MII_ACC) & MII_ACC_MII_BUSY) == MII_ACC_MII_BUSY);
-
- // Clear the R/W bit to indicate we are reading
- // Set the index of the MII register
- // Set the PHY Address
- // Set the MII busy bit to allow read
- MiiAcc = MII_ACC_MII_WRITE | MII_ACC_MII_REG_INDEX(Index) | MII_ACC_PHY_VALUE | MII_ACC_MII_BUSY;
-
- // Write the desired value to the register first
- ValueWritten = IndirectMACWrite32 (INDIRECT_MAC_INDEX_MII_DATA, (Value & 0xFFFF));
-
- // Now write the config to register
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_MII_ACC, MiiAcc & 0xFFFF);
-
- // Wait for operation to terminate
- while ((IndirectMACRead32 (INDIRECT_MAC_INDEX_MII_ACC) & MII_ACC_MII_BUSY) == MII_ACC_MII_BUSY);
-
- return ValueWritten;
-}
-
-
-/* ---------------- EEPROM Operations ------------------ */
-
-
-// Function to read from EEPROM memory
-UINT32
-IndirectEEPROMRead32 (
- UINT32 Index
- )
-{
- UINT32 EepromCmd;
-
- // Set the busy bit to ensure read will occur
- EepromCmd = E2P_EPC_BUSY | E2P_EPC_CMD_READ;
-
- // Set the index to access desired EEPROM memory location
- EepromCmd |= E2P_EPC_ADDRESS(Index);
-
- // Write to Eeprom command register
- MmioWrite32 (LAN9118_E2P_CMD, EepromCmd);
- gBS->Stall (LAN9118_STALL);
-
- // Wait until operation has completed
- while (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_BUSY);
-
- // Check that operation didn't time out
- if (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_TIMEOUT) {
- DEBUG ((EFI_D_ERROR, "EEPROM Operation Timed out: Read command on index %x\n",Index));
- return 0;
- }
-
- // Wait until operation has completed
- while (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_BUSY);
-
- // Finally read the value
- return MmioRead32 (LAN9118_E2P_DATA);
-}
-
-// Function to write to EEPROM memory
-UINT32
-IndirectEEPROMWrite32 (
- UINT32 Index,
- UINT32 Value
- )
-{
- UINT32 ValueWritten;
- UINT32 EepromCmd;
-
- ValueWritten = 0;
-
- // Read the EEPROM Command register
- EepromCmd = MmioRead32 (LAN9118_E2P_CMD);
-
- // Set the busy bit to ensure read will occur
- EepromCmd |= ((UINT32)1 << 31);
-
- // Set the EEPROM command to write(0b011)
- EepromCmd &= ~(7 << 28); // Clear the command first
- EepromCmd |= (3 << 28); // Write 011
-
- // Set the index to access desired EEPROM memory location
- EepromCmd |= (Index & 0xF);
-
- // Write the value to the data register first
- ValueWritten = MmioWrite32 (LAN9118_E2P_DATA, Value);
-
- // Write to Eeprom command register
- MmioWrite32 (LAN9118_E2P_CMD, EepromCmd);
- gBS->Stall (LAN9118_STALL);
-
- // Wait until operation has completed
- while (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_BUSY);
-
- // Check that operation didn't time out
- if (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_TIMEOUT) {
- DEBUG ((EFI_D_ERROR, "EEPROM Operation Timed out: Write command at memloc 0x%x, with value 0x%x\n",Index, Value));
- return 0;
- }
-
- // Wait until operation has completed
- while (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_BUSY);
-
- return ValueWritten;
-}
-
-/* ---------------- General Operations ----------------- */
-
-VOID
-Lan9118SetMacAddress (
- EFI_MAC_ADDRESS *Mac,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_ADDRL,
- (Mac->Addr[0] & 0xFF) |
- ((Mac->Addr[1] & 0xFF) << 8) |
- ((Mac->Addr[2] & 0xFF) << 16) |
- ((Mac->Addr[3] & 0xFF) << 24)
- );
-
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_ADDRH,
- (UINT32)(Mac->Addr[4] & 0xFF) |
- ((Mac->Addr[5] & 0xFF) << 8)
- );
-}
-
-VOID
-Lan9118ReadMacAddress (
- OUT EFI_MAC_ADDRESS *MacAddress
- )
-{
- UINT32 MacAddrHighValue;
- UINT32 MacAddrLowValue;
-
- // Read the Mac Addr high register
- MacAddrHighValue = (IndirectMACRead32 (INDIRECT_MAC_INDEX_ADDRH) & 0xFFFF);
- // Read the Mac Addr low register
- MacAddrLowValue = IndirectMACRead32 (INDIRECT_MAC_INDEX_ADDRL);
-
- SetMem (MacAddress, sizeof(*MacAddress), 0);
- MacAddress->Addr[0] = (MacAddrLowValue & 0xFF);
- MacAddress->Addr[1] = (MacAddrLowValue & 0xFF00) >> 8;
- MacAddress->Addr[2] = (MacAddrLowValue & 0xFF0000) >> 16;
- MacAddress->Addr[3] = (MacAddrLowValue & 0xFF000000) >> 24;
- MacAddress->Addr[4] = (MacAddrHighValue & 0xFF);
- MacAddress->Addr[5] = (MacAddrHighValue & 0xFF00) >> 8;
-}
-
-/*
- * Power up the 9118 and find its MAC address.
- *
- * This operation can be carried out when the LAN9118 is in any power state
- *
- */
-EFI_STATUS
-Lan9118Initialize (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINTN Timeout;
- UINT64 DefaultMacAddress;
-
- // Attempt to wake-up the device if it is in a lower power state
- if (((MmioRead32 (LAN9118_PMT_CTRL) & MPTCTRL_PM_MODE_MASK) >> 12) != 0) {
- DEBUG ((DEBUG_NET, "Waking from reduced power state.\n"));
- MmioWrite32 (LAN9118_BYTE_TEST, 0xFFFFFFFF);
- gBS->Stall (LAN9118_STALL);
- }
-
- // Check that device is active
- Timeout = 20;
- while ((MmioRead32 (LAN9118_PMT_CTRL) & MPTCTRL_READY) == 0 && --Timeout) {
- gBS->Stall (LAN9118_STALL);
- }
- if (!Timeout) {
- return EFI_TIMEOUT;
- }
-
- // Check that EEPROM isn't active
- Timeout = 20;
- while ((MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_BUSY) && --Timeout){
- gBS->Stall (LAN9118_STALL);
- }
- if (!Timeout) {
- return EFI_TIMEOUT;
- }
-
- // Check if a MAC address was loaded from EEPROM, and if it was, set it as the
- // current address.
- if ((MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_MAC_ADDRESS_LOADED) == 0) {
- DEBUG ((EFI_D_ERROR, "Warning: There was an error detecting EEPROM or loading the MAC Address.\n"));
-
- // If we had an address before (set by StationAddess), continue to use it
- if (CompareMem (&Snp->Mode->CurrentAddress, &mZeroMac, NET_ETHER_ADDR_LEN)) {
- Lan9118SetMacAddress (&Snp->Mode->CurrentAddress, Snp);
- } else {
- // If there are no cached addresses, then fall back to a default
- DEBUG ((EFI_D_WARN, "Warning: using driver-default MAC address\n"));
- DefaultMacAddress = FixedPcdGet64 (PcdLan9118DefaultMacAddress);
- Lan9118SetMacAddress((EFI_MAC_ADDRESS *) &DefaultMacAddress, Snp);
- CopyMem (&Snp->Mode->CurrentAddress, &DefaultMacAddress, NET_ETHER_ADDR_LEN);
- }
- } else {
- // Store the MAC address that was loaded from EEPROM
- Lan9118ReadMacAddress (&Snp->Mode->CurrentAddress);
- CopyMem (&Snp->Mode->PermanentAddress, &Snp->Mode->CurrentAddress, NET_ETHER_ADDR_LEN);
- }
-
- // Clear and acknowledge interrupts
- MmioWrite32 (LAN9118_INT_EN, 0);
- MmioWrite32 (LAN9118_IRQ_CFG, 0);
- MmioWrite32 (LAN9118_INT_STS, 0xFFFFFFFF);
-
- // Do self tests here?
-
- return EFI_SUCCESS;
-}
-
-
-// Perform software reset on the LAN9118
-// Return 0 on success, -1 on error
-EFI_STATUS
-SoftReset (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 HwConf;
- UINT32 ResetTime;
-
- // Initialize variable
- ResetTime = 0;
-
- // Stop Rx and Tx
- StopTx (STOP_TX_MAC | STOP_TX_CFG | STOP_TX_CLEAR, Snp);
- StopRx (STOP_RX_CLEAR, Snp); // Clear receiver FIFO
-
- // Issue the reset
- HwConf = MmioRead32 (LAN9118_HW_CFG);
- HwConf |= 1;
-
- // Set the Must Be One (MBO) bit
- if (((HwConf & HWCFG_MBO) >> 20) == 0) {
- HwConf |= HWCFG_MBO;
- }
-
- // Check that EEPROM isn't active
- while (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_BUSY);
-
- // Write the configuration
- MmioWrite32 (LAN9118_HW_CFG, HwConf);
- gBS->Stall (LAN9118_STALL);
-
- // Wait for reset to complete
- while (MmioRead32 (LAN9118_HW_CFG) & HWCFG_SRST) {
-
- gBS->Stall (LAN9118_STALL);
- ResetTime += 1;
-
- // If time taken exceeds 100us, then there was an error condition
- if (ResetTime > 1000) {
- Snp->Mode->State = EfiSimpleNetworkStopped;
- return EFI_TIMEOUT;
- }
- }
-
- // Check that EEPROM isn't active
- while (MmioRead32 (LAN9118_E2P_CMD) & E2P_EPC_BUSY);
-
- // TODO we probably need to re-set the mac address here.
-
- // Clear and acknowledge all interrupts
- if (Flags & SOFT_RESET_CLEAR_INT) {
- MmioWrite32 (LAN9118_INT_EN, 0);
- MmioWrite32 (LAN9118_IRQ_CFG, 0);
- MmioWrite32 (LAN9118_INT_STS, 0xFFFFFFFF);
- }
-
- // Do self tests here?
- if (Flags & SOFT_RESET_SELF_TEST) {
-
- }
-
- return EFI_SUCCESS;
-}
-
-
-// Perform PHY software reset
-EFI_STATUS
-PhySoftReset (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 PmtCtrl = 0;
-
- // PMT PHY reset takes precedence over BCR
- if (Flags & PHY_RESET_PMT) {
- PmtCtrl = MmioRead32 (LAN9118_PMT_CTRL);
- PmtCtrl |= MPTCTRL_PHY_RST;
- MmioWrite32 (LAN9118_PMT_CTRL,PmtCtrl);
-
- // Wait for completion
- while (MmioRead32 (LAN9118_PMT_CTRL) & MPTCTRL_PHY_RST) {
- gBS->Stall (LAN9118_STALL);
- }
- // PHY Basic Control Register reset
- } else if (Flags & PHY_RESET_BCR) {
- IndirectPHYWrite32 (PHY_INDEX_BASIC_CTRL, PHYCR_RESET);
-
- // Wait for completion
- while (IndirectPHYRead32 (PHY_INDEX_BASIC_CTRL) & PHYCR_RESET) {
- gBS->Stall (LAN9118_STALL);
- }
- }
-
- // Clear and acknowledge all interrupts
- if (Flags & PHY_SOFT_RESET_CLEAR_INT) {
- MmioWrite32 (LAN9118_INT_EN, 0);
- MmioWrite32 (LAN9118_IRQ_CFG, 0);
- MmioWrite32 (LAN9118_INT_STS, 0xFFFFFFFF);
- }
-
- return EFI_SUCCESS;
-}
-
-
-// Configure hardware for LAN9118
-EFI_STATUS
-ConfigureHardware (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 GpioConf;
-
- // Check if we want to use LEDs on GPIO
- if (Flags & HW_CONF_USE_LEDS) {
- GpioConf = MmioRead32 (LAN9118_GPIO_CFG);
-
- // Enable GPIO as LEDs and Config as Push-Pull driver
- GpioConf |= GPIO_GPIO0_PUSH_PULL | GPIO_GPIO1_PUSH_PULL | GPIO_GPIO2_PUSH_PULL |
- GPIO_LED1_ENABLE | GPIO_LED2_ENABLE | GPIO_LED3_ENABLE;
-
- // Write the configuration
- MmioWrite32 (LAN9118_GPIO_CFG, GpioConf);
- gBS->Stall (LAN9118_STALL);
- }
-
- return EFI_SUCCESS;
-}
-
-// Configure flow control
-EFI_STATUS
-ConfigureFlow (
- UINT32 Flags,
- UINT32 HighTrig,
- UINT32 LowTrig,
- UINT32 BPDuration,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- return EFI_SUCCESS;
-}
-
-// Do auto-negotiation
-EFI_STATUS
-AutoNegotiate (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 PhyControl;
- UINT32 PhyStatus;
- UINT32 Features;
- UINT32 TimeOut;
-
- // First check that auto-negotiation is supported
- PhyStatus = IndirectPHYRead32 (PHY_INDEX_BASIC_STATUS);
- if ((PhyStatus & PHYSTS_AUTO_CAP) == 0) {
- DEBUG ((EFI_D_ERROR, "Auto-negotiation not supported.\n"));
- return EFI_DEVICE_ERROR;
- }
-
- // Check that link is up first
- if ((PhyStatus & PHYSTS_LINK_STS) == 0) {
- // Wait until it is up or until Time Out
- TimeOut = 2000;
- while ((IndirectPHYRead32 (PHY_INDEX_BASIC_STATUS) & PHYSTS_LINK_STS) == 0) {
- gBS->Stall (LAN9118_STALL);
- TimeOut--;
- if (!TimeOut) {
- DEBUG ((EFI_D_ERROR, "Link timeout in auto-negotiation.\n"));
- return EFI_TIMEOUT;
- }
- }
- }
-
- // Configure features to advertise
- Features = IndirectPHYRead32 (PHY_INDEX_AUTO_NEG_ADVERT);
-
- if ((Flags & AUTO_NEGOTIATE_ADVERTISE_ALL) > 0) {
- // Link speed capabilities
- Features |= (PHYANA_10BASET | PHYANA_10BASETFD | PHYANA_100BASETX | PHYANA_100BASETXFD);
-
- // Pause frame capabilities
- Features &= ~(PHYANA_PAUSE_OP_MASK);
- Features |= 3 << 10;
- }
-
- // Write the features
- IndirectPHYWrite32 (PHY_INDEX_AUTO_NEG_ADVERT, Features);
-
- // Read control register
- PhyControl = IndirectPHYRead32 (PHY_INDEX_BASIC_CTRL);
-
- // Enable Auto-Negotiation
- if ((PhyControl & PHYCR_AUTO_EN) == 0) {
- PhyControl |= PHYCR_AUTO_EN;
- }
-
- // Restart auto-negotiation
- PhyControl |= PHYCR_RST_AUTO;
-
- // Enable collision test if required to do so
- if (Flags & AUTO_NEGOTIATE_COLLISION_TEST) {
- PhyControl |= PHYCR_COLL_TEST;
- } else {
- PhyControl &= ~ PHYCR_COLL_TEST;
- }
-
- // Write this configuration
- IndirectPHYWrite32 (PHY_INDEX_BASIC_CTRL, PhyControl);
-
- // Wait until process has completed
- while ((IndirectPHYRead32 (PHY_INDEX_BASIC_STATUS) & PHYSTS_AUTO_COMP) == 0);
-
- return EFI_SUCCESS;
-}
-
-// Check the Link Status and take appropriate action
-EFI_STATUS
-CheckLinkStatus (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- // Get the PHY Status
- UINT32 PhyBStatus = IndirectPHYRead32 (PHY_INDEX_BASIC_STATUS);
-
- if (PhyBStatus & PHYSTS_LINK_STS) {
- return EFI_SUCCESS;
- } else {
- return EFI_DEVICE_ERROR;
- }
-}
-
-// Stop the transmitter
-EFI_STATUS
-StopTx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 MacCsr;
- UINT32 TxCfg;
-
- MacCsr = 0;
- TxCfg = 0;
-
- // Check if we want to clear tx
- if (Flags & STOP_TX_CLEAR) {
- TxCfg = MmioRead32 (LAN9118_TX_CFG);
- TxCfg |= TXCFG_TXS_DUMP | TXCFG_TXD_DUMP;
- MmioWrite32 (LAN9118_TX_CFG, TxCfg);
- gBS->Stall (LAN9118_STALL);
- }
-
- // Check if already stopped
- if (Flags & STOP_TX_MAC) {
- MacCsr = IndirectMACRead32 (INDIRECT_MAC_INDEX_CR);
-
- if (MacCsr & MACCR_TX_EN) {
- MacCsr &= ~MACCR_TX_EN;
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_CR, MacCsr);
- }
- }
-
- if (Flags & STOP_TX_CFG) {
- TxCfg = MmioRead32 (LAN9118_TX_CFG);
-
- if (TxCfg & TXCFG_TX_ON) {
- TxCfg |= TXCFG_STOP_TX;
- MmioWrite32 (LAN9118_TX_CFG, TxCfg);
- gBS->Stall (LAN9118_STALL);
-
- // Wait for Tx to finish transmitting
- while (MmioRead32 (LAN9118_TX_CFG) & TXCFG_STOP_TX);
- }
- }
-
- return EFI_SUCCESS;
-}
-
-// Stop the receiver
-EFI_STATUS
-StopRx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 MacCsr;
- UINT32 RxCfg;
-
- RxCfg = 0;
-
- // Check if already stopped
- MacCsr = IndirectMACRead32 (INDIRECT_MAC_INDEX_CR);
-
- if (MacCsr & MACCR_RX_EN) {
- MacCsr &= ~ MACCR_RX_EN;
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_CR, MacCsr);
- }
-
- // Check if we want to clear receiver FIFOs
- if (Flags & STOP_RX_CLEAR) {
- RxCfg = MmioRead32 (LAN9118_RX_CFG);
- RxCfg |= RXCFG_RX_DUMP;
- MmioWrite32 (LAN9118_RX_CFG, RxCfg);
- gBS->Stall (LAN9118_STALL);
-
- while (MmioRead32 (LAN9118_RX_CFG) & RXCFG_RX_DUMP);
- }
-
- return EFI_SUCCESS;
-}
-
-// Start the transmitter
-EFI_STATUS
-StartTx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 MacCsr;
- UINT32 TxCfg;
-
- MacCsr = 0;
- TxCfg = 0;
-
- // Check if we want to clear tx
- if (Flags & START_TX_CLEAR) {
- TxCfg = MmioRead32 (LAN9118_TX_CFG);
- TxCfg |= TXCFG_TXS_DUMP | TXCFG_TXD_DUMP;
- MmioWrite32 (LAN9118_TX_CFG, TxCfg);
- gBS->Stall (LAN9118_STALL);
- }
-
- // Check if tx was started from MAC and enable if not
- if (Flags & START_TX_MAC) {
- MacCsr = IndirectMACRead32 (INDIRECT_MAC_INDEX_CR);
- gBS->Stall (LAN9118_STALL);
- if ((MacCsr & MACCR_TX_EN) == 0) {
- MacCsr |= MACCR_TX_EN;
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_CR, MacCsr);
- gBS->Stall (LAN9118_STALL);
- }
- }
-
- // Check if tx was started from TX_CFG and enable if not
- if (Flags & START_TX_CFG) {
- TxCfg = MmioRead32 (LAN9118_TX_CFG);
- gBS->Stall (LAN9118_STALL);
- if ((TxCfg & TXCFG_TX_ON) == 0) {
- TxCfg |= TXCFG_TX_ON;
- MmioWrite32 (LAN9118_TX_CFG, TxCfg);
- gBS->Stall (LAN9118_STALL);
- }
- }
-
- // Set the tx data trigger level
-
- return EFI_SUCCESS;
-}
-
-// Start the receiver
-EFI_STATUS
-StartRx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 MacCsr;
- UINT32 RxCfg;
-
- RxCfg = 0;
-
- // Check if already started
- MacCsr = IndirectMACRead32 (INDIRECT_MAC_INDEX_CR);
-
- if ((MacCsr & MACCR_RX_EN) == 0) {
- // Check if we want to clear receiver FIFOs before starting
- if (Flags & START_RX_CLEAR) {
- RxCfg = MmioRead32 (LAN9118_RX_CFG);
- RxCfg |= RXCFG_RX_DUMP;
- MmioWrite32 (LAN9118_RX_CFG, RxCfg);
- gBS->Stall (LAN9118_STALL);
-
- while (MmioRead32 (LAN9118_RX_CFG) & RXCFG_RX_DUMP);
- }
-
- MacCsr |= MACCR_RX_EN;
- IndirectMACWrite32 (INDIRECT_MAC_INDEX_CR, MacCsr);
- gBS->Stall (LAN9118_STALL);
- }
-
- return EFI_SUCCESS;
-}
-
-// Check Tx Data available space
-UINT32
-TxDataFreeSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 TxInf;
- UINT32 FreeSpace;
-
- // Get the amount of free space from information register
- TxInf = MmioRead32 (LAN9118_TX_FIFO_INF);
- FreeSpace = (TxInf & TXFIFOINF_TDFREE_MASK);
-
- return FreeSpace; // Value in bytes
-}
-
-// Check Tx Status used space
-UINT32
-TxStatusUsedSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 TxInf;
- UINT32 UsedSpace;
-
- // Get the amount of used space from information register
- TxInf = MmioRead32 (LAN9118_TX_FIFO_INF);
- UsedSpace = (TxInf & TXFIFOINF_TXSUSED_MASK) >> 16;
-
- return UsedSpace << 2; // Value in bytes
-}
-
-// Check Rx Data used space
-UINT32
-RxDataUsedSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 RxInf;
- UINT32 UsedSpace;
-
- // Get the amount of used space from information register
- RxInf = MmioRead32 (LAN9118_RX_FIFO_INF);
- UsedSpace = (RxInf & RXFIFOINF_RXDUSED_MASK);
-
- return UsedSpace; // Value in bytes (rounded up to nearest DWORD)
-}
-
-// Check Rx Status used space
-UINT32
-RxStatusUsedSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 RxInf;
- UINT32 UsedSpace;
-
- // Get the amount of used space from information register
- RxInf = MmioRead32 (LAN9118_RX_FIFO_INF);
- UsedSpace = (RxInf & RXFIFOINF_RXSUSED_MASK) >> 16;
-
- return UsedSpace << 2; // Value in bytes
-}
-
-
-// Change the allocation of FIFOs
-EFI_STATUS
-ChangeFifoAllocation (
- IN UINT32 Flags,
- IN OUT UINTN *TxDataSize OPTIONAL,
- IN OUT UINTN *RxDataSize OPTIONAL,
- IN OUT UINT32 *TxStatusSize OPTIONAL,
- IN OUT UINT32 *RxStatusSize OPTIONAL,
- IN OUT EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- )
-{
- UINT32 HwConf;
- UINT32 TxFifoOption;
-
- // Check that desired sizes don't exceed limits
- if (*TxDataSize > TX_FIFO_MAX_SIZE)
- return EFI_INVALID_PARAMETER;
-
-#if defined(RX_FIFO_MIN_SIZE) && defined(RX_FIFO_MAX_SIZE)
- if (*RxDataSize > RX_FIFO_MAX_SIZE) {
- return EFI_INVALID_PARAMETER;
- }
-#endif
-
- if (Flags & ALLOC_USE_DEFAULT) {
- return EFI_SUCCESS;
- }
-
- // If we use the FIFOs (always use this first)
- if (Flags & ALLOC_USE_FIFOS) {
- // Read the current value of allocation
- HwConf = MmioRead32 (LAN9118_HW_CFG);
- TxFifoOption = (HwConf >> 16) & 0xF;
-
- // Choose the correct size (always use larger than requested if possible)
- if (*TxDataSize < TX_FIFO_MIN_SIZE) {
- *TxDataSize = TX_FIFO_MIN_SIZE;
- *RxDataSize = 13440;
- *RxStatusSize = 896;
- TxFifoOption = 2;
- } else if ((*TxDataSize > TX_FIFO_MIN_SIZE) && (*TxDataSize <= 2560)) {
- *TxDataSize = 2560;
- *RxDataSize = 12480;
- *RxStatusSize = 832;
- TxFifoOption = 3;
- } else if ((*TxDataSize > 2560) && (*TxDataSize <= 3584)) {
- *TxDataSize = 3584;
- *RxDataSize = 11520;
- *RxStatusSize = 768;
- TxFifoOption = 4;
- } else if ((*TxDataSize > 3584) && (*TxDataSize <= 4608)) { // default option
- *TxDataSize = 4608;
- *RxDataSize = 10560;
- *RxStatusSize = 704;
- TxFifoOption = 5;
- } else if ((*TxDataSize > 4608) && (*TxDataSize <= 5632)) {
- *TxDataSize = 5632;
- *RxDataSize = 9600;
- *RxStatusSize = 640;
- TxFifoOption = 6;
- } else if ((*TxDataSize > 5632) && (*TxDataSize <= 6656)) {
- *TxDataSize = 6656;
- *RxDataSize = 8640;
- *RxStatusSize = 576;
- TxFifoOption = 7;
- } else if ((*TxDataSize > 6656) && (*TxDataSize <= 7680)) {
- *TxDataSize = 7680;
- *RxDataSize = 7680;
- *RxStatusSize = 512;
- TxFifoOption = 8;
- } else if ((*TxDataSize > 7680) && (*TxDataSize <= 8704)) {
- *TxDataSize = 8704;
- *RxDataSize = 6720;
- *RxStatusSize = 448;
- TxFifoOption = 9;
- } else if ((*TxDataSize > 8704) && (*TxDataSize <= 9728)) {
- *TxDataSize = 9728;
- *RxDataSize = 5760;
- *RxStatusSize = 384;
- TxFifoOption = 10;
- } else if ((*TxDataSize > 9728) && (*TxDataSize <= 10752)) {
- *TxDataSize = 10752;
- *RxDataSize = 4800;
- *RxStatusSize = 320;
- TxFifoOption = 11;
- } else if ((*TxDataSize > 10752) && (*TxDataSize <= 11776)) {
- *TxDataSize = 11776;
- *RxDataSize = 3840;
- *RxStatusSize = 256;
- TxFifoOption = 12;
- } else if ((*TxDataSize > 11776) && (*TxDataSize <= 12800)) {
- *TxDataSize = 12800;
- *RxDataSize = 2880;
- *RxStatusSize = 192;
- TxFifoOption = 13;
- } else if ((*TxDataSize > 12800) && (*TxDataSize <= 13824)) {
- *TxDataSize = 13824;
- *RxDataSize = 1920;
- *RxStatusSize = 128;
- TxFifoOption = 14;
- }
- } else {
- ASSERT(0); // Untested code path
- HwConf = 0;
- TxFifoOption = 0;
- }
-
- // Do we need DMA?
- if (Flags & ALLOC_USE_DMA) {
- return EFI_UNSUPPORTED; // Unsupported as of now
- }
- // Clear and assign the new size option
- HwConf &= ~(0xF0000);
- HwConf |= ((TxFifoOption & 0xF) << 16);
- MmioWrite32 (LAN9118_HW_CFG, HwConf);
- gBS->Stall (LAN9118_STALL);
-
- return EFI_SUCCESS;
-}
diff --git a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.h b/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.h
deleted file mode 100644
index 424bdc5a85..0000000000
--- a/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118DxeUtil.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/** @file
-*
-* Copyright (c) 2012-2014, 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 __LAN9118_DXE_UTIL_H__
-#define __LAN9118_DXE_UTIL_H__
-
-// Most common CRC32 Polynomial for little endian machines
-#define CRC_POLYNOMIAL 0xEDB88320
-
-/**
- This internal function reverses bits for 32bit data.
-
- @param Value The data to be reversed.
-
- @return Data reversed.
-
-**/
-UINT32
-ReverseBits (
- UINT32 Value
- );
-
-// Create an Ethernet CRC
-UINT32
-GenEtherCrc32 (
- IN EFI_MAC_ADDRESS *Mac,
- IN UINT32 AddrLen
- );
-
-/* ------------------ MAC CSR Access ------------------- */
-
-// Read from MAC indirect registers
-UINT32
-IndirectMACRead32 (
- UINT32 Index
- );
-
-
-// Write to indirect registers
-UINT32
-IndirectMACWrite32 (
- UINT32 Index,
- UINT32 Value
- );
-
-
-/* --------------- PHY Registers Access ---------------- */
-
-// Read from MII register (PHY Access)
-UINT32
-IndirectPHYRead32(
- UINT32 Index
- );
-
-
-// Write to the MII register (PHY Access)
-UINT32
-IndirectPHYWrite32(
- UINT32 Index,
- UINT32 Value
- );
-
-/* ---------------- EEPROM Operations ------------------ */
-
-// Read from EEPROM memory
-UINT32
-IndirectEEPROMRead32 (
- UINT32 Index
- );
-
-// Write to EEPROM memory
-UINT32
-IndirectEEPROMWrite32 (
- UINT32 Index,
- UINT32 Value
- );
-
-/* ---------------- General Operations ----------------- */
-
-VOID
-Lan9118SetMacAddress (
- EFI_MAC_ADDRESS *Mac,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Initialise the LAN9118
-EFI_STATUS
-Lan9118Initialize (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Flags for software reset
-#define SOFT_RESET_CHECK_MAC_ADDR_LOAD BIT0
-#define SOFT_RESET_CLEAR_INT BIT1
-#define SOFT_RESET_SELF_TEST BIT2
-
-// Perform software reset on the LAN9118
-EFI_STATUS
-SoftReset (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Flags for PHY reset
-#define PHY_RESET_PMT BIT0
-#define PHY_RESET_BCR BIT1
-#define PHY_SOFT_RESET_CLEAR_INT BIT2
-
-// Perform PHY software reset
-EFI_STATUS
-PhySoftReset (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Flags for Hardware configuration
-#define HW_CONF_USE_LEDS BIT0
-
-// Configure hardware for LAN9118
-EFI_STATUS
-ConfigureHardware (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Configure flow control
-EFI_STATUS
-ConfigureFlow (
- UINT32 Flags,
- UINT32 HighTrig,
- UINT32 LowTrig,
- UINT32 BPDuration,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Flags for auto negotiation
-#define AUTO_NEGOTIATE_COLLISION_TEST BIT0
-#define AUTO_NEGOTIATE_ADVERTISE_ALL BIT1
-
-// Do auto-negotiation
-EFI_STATUS
-AutoNegotiate (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Check the Link Status and take appropriate action
-EFI_STATUS
-CheckLinkStatus (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Stop transmitter flags
-#define STOP_TX_MAC BIT0
-#define STOP_TX_CFG BIT1
-#define STOP_TX_CLEAR BIT2
-
-// Stop the transmitter
-EFI_STATUS
-StopTx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Stop receiver flags
-#define STOP_RX_CLEAR BIT0
-
-// Stop the receiver
-EFI_STATUS
-StopRx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Start transmitter flags
-#define START_TX_MAC BIT0
-#define START_TX_CFG BIT1
-#define START_TX_CLEAR BIT2
-
-// Start the transmitter
-EFI_STATUS
-StartTx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Stop receiver flags
-#define START_RX_CLEAR BIT0
-
-// Start the receiver
-EFI_STATUS
-StartRx (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Check Tx Data available space
-UINT32
-TxDataFreeSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Check Tx Status used space
-UINT32
-TxStatusUsedSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Check Rx Data used space
-UINT32
-RxDataUsedSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-// Check Rx Status used space
-UINT32
-RxStatusUsedSpace (
- UINT32 Flags,
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-
-// Flags for FIFO allocation
-#define ALLOC_USE_DEFAULT BIT0
-#define ALLOC_USE_FIFOS BIT1
-#define ALLOC_USE_DMA BIT2
-
-// FIFO min and max sizes
-#define TX_FIFO_MIN_SIZE 0x00000600
-#define TX_FIFO_MAX_SIZE 0x00003600
-//#define RX_FIFO_MIN_SIZE
-//#define RX_FIFO_MAX_SIZE
-
-// Change the allocation of FIFOs
-EFI_STATUS
-ChangeFifoAllocation (
- IN UINT32 Flags,
- IN OUT UINTN *TxDataSize OPTIONAL,
- IN OUT UINTN *RxDataSize OPTIONAL,
- IN OUT UINT32 *TxStatusSize OPTIONAL,
- IN OUT UINT32 *RxStatusSize OPTIONAL,
- IN OUT EFI_SIMPLE_NETWORK_PROTOCOL *Snp
- );
-
-VOID
-Lan9118ReadMacAddress (
- OUT EFI_MAC_ADDRESS *Mac
- );
-
-#endif // __LAN9118_DXE_UTIL_H__
diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/ComponentName.c b/EmbeddedPkg/Drivers/SataSiI3132Dxe/ComponentName.c
deleted file mode 100644
index 18e750a373..0000000000
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/ComponentName.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/** @file
- UEFI Component Name(2) protocol implementation for Silicon Image I3132 SATA controller
-
-* Copyright (c) 2011-2015, 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.
-*
-**/
-
-#include "SataSiI3132.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSataSiI3132ComponentName = {
- SataSiI3132ComponentNameGetDriverName,
- SataSiI3132ComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSataSiI3132ComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SataSiI3132ComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SataSiI3132ComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataSiI3132DriverNameTable[] = {
- { "eng;en", L"Pci SATA Silicon Image 3132 Driver" },
- { NULL , NULL }
-};
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-SataSiI3132ComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mSataSiI3132DriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gSataSiI3132ComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-SataSiI3132ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c
deleted file mode 100644
index 5a5526c0df..0000000000
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/** @file
-* PCIe Sata support for the Silicon Image I3132
-*
-* Copyright (c) 2011-2015, 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.
-*
-**/
-
-#include "SataSiI3132.h"
-
-#include <IndustryStandard/Acpi10.h>
-
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/BaseLib.h>
-
-#define ACPI_SPECFLAG_PREFETCHABLE 0x06
-
-EFI_DRIVER_BINDING_PROTOCOL
-gSataSiI3132DriverBinding = {
- SataSiI3132DriverBindingSupported,
- SataSiI3132DriverBindingStart,
- SataSiI3132DriverBindingStop,
- 0x30,
- NULL,
- NULL
-};
-
-EFI_STATUS
-SataSiI3132PortConstructor (
- IN SATA_SI3132_INSTANCE *SataSiI3132Instance,
- IN UINTN Index
- )
-{
- EFI_STATUS Status;
- SATA_SI3132_PORT *Port;
- VOID *HostPRB;
- EFI_PHYSICAL_ADDRESS PhysAddrHostPRB;
- VOID *PciAllocMappingPRB;
- UINTN NumberOfBytes;
-
- Port = &(SataSiI3132Instance->Ports[Index]);
-
- Port->Index = Index;
- Port->RegBase = Index * 0x2000;
- Port->Instance = SataSiI3132Instance;
- InitializeListHead (&(Port->Devices));
-
- NumberOfBytes = sizeof (SATA_SI3132_PRB);
- Status = SataSiI3132Instance->PciIo->AllocateBuffer (
- SataSiI3132Instance->PciIo, AllocateAnyPages, EfiBootServicesData,
- EFI_SIZE_TO_PAGES (NumberOfBytes), &HostPRB, 0
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Check the alignment of the PCI Buffer
- ASSERT (((UINTN)HostPRB & (0x1000 - 1)) == 0);
- Status = SataSiI3132Instance->PciIo->Map (
- SataSiI3132Instance->PciIo, EfiPciIoOperationBusMasterCommonBuffer, HostPRB,
- &NumberOfBytes, &PhysAddrHostPRB, &PciAllocMappingPRB
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Port->HostPRB = HostPRB;
- Port->PhysAddrHostPRB = PhysAddrHostPRB;
- Port->PciAllocMappingPRB = PciAllocMappingPRB;
-
- return Status;
-}
-
-STATIC
-EFI_STATUS
-SataSiI3132Constructor (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- OUT SATA_SI3132_INSTANCE** SataSiI3132Instance
- )
-{
- SATA_SI3132_INSTANCE *Instance;
- EFI_ATA_PASS_THRU_MODE *AtaPassThruMode;
-
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- Instance = (SATA_SI3132_INSTANCE*)AllocateZeroPool (sizeof (SATA_SI3132_INSTANCE));
- if (Instance == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Instance->Signature = SATA_SII3132_SIGNATURE;
- Instance->PciIo = PciIo;
-
- AtaPassThruMode = (EFI_ATA_PASS_THRU_MODE*)AllocatePool (sizeof (EFI_ATA_PASS_THRU_MODE));
- AtaPassThruMode->Attributes = EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL;
- AtaPassThruMode->IoAlign = 0x1000;
-
- // Initialize SiI3132 ports
- SataSiI3132PortConstructor (Instance, 0);
- SataSiI3132PortConstructor (Instance, 1);
-
- // Set ATA Pass Thru Protocol
- Instance->AtaPassThruProtocol.Mode = AtaPassThruMode;
- Instance->AtaPassThruProtocol.PassThru = SiI3132AtaPassThru;
- Instance->AtaPassThruProtocol.GetNextPort = SiI3132GetNextPort;
- Instance->AtaPassThruProtocol.GetNextDevice = SiI3132GetNextDevice;
- Instance->AtaPassThruProtocol.BuildDevicePath = SiI3132BuildDevicePath;
- Instance->AtaPassThruProtocol.GetDevice = SiI3132GetDevice;
- Instance->AtaPassThruProtocol.ResetPort = SiI3132ResetPort;
- Instance->AtaPassThruProtocol.ResetDevice = SiI3132ResetDevice;
-
- *SataSiI3132Instance = Instance;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-SiI3132SoftResetCommand (
- IN SATA_SI3132_PORT *Port,
- OUT UINT32* Signature
- )
-{
- EFI_STATUS Status;
- EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
- EFI_ATA_STATUS_BLOCK Asb;
- EFI_ATA_COMMAND_BLOCK Acb;
- CONST UINT16 PortMultiplierPort = 0;
-
- ZeroMem (&Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
-
- Acb.Reserved1[1] = 0;
-
- Packet.Asb = &Asb;
- Packet.Acb = &Acb;
- Packet.Timeout = 100000;
- Packet.Protocol = EFI_ATA_PASS_THRU_PROTOCOL_ATA_SOFTWARE_RESET;
-
- Status = SiI3132AtaPassThruCommand (Port->Instance, Port, PortMultiplierPort, &Packet, 0);
-
- if (Status == EFI_SUCCESS) {
- *Signature = (Asb.AtaCylinderHigh << 24) | (Asb.AtaCylinderLow << 16) |
- (Asb.AtaSectorNumber << 8 ) | (Asb.AtaSectorCount);
- }
- return Status;
-}
-
-EFI_STATUS
-SataSiI3132PortInitialization (
- IN SATA_SI3132_PORT *Port
- )
-{
- UINT32 Value32;
- SATA_SI3132_DEVICE* Device;
- UINT32 Signature;
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL* PciIo;
-
- Status = SiI3132HwResetPort (Port);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- PciIo = Port->Instance->PciIo;
-
- // Is a device is present ?
- Status = SATA_PORT_READ32 (Port->RegBase + SII3132_PORT_SSTATUS_REG, &Value32);
- if (!EFI_ERROR (Status) && (Value32 & 0x3)) {
- // Do a soft reset to see if it is a port multiplier
- SATA_TRACE ("SataSiI3132PortInitialization: soft reset - it is a port multiplier\n");
- Status = SiI3132SoftResetCommand (Port, &Signature);
- if (!EFI_ERROR (Status)) {
- if (Signature == SII3132_PORT_SIGNATURE_PMP) {
- SATA_TRACE ("SataSiI3132PortInitialization(): a Port Multiplier is present");
- if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
- ASSERT (0); // Not supported yet
- } else {
- return EFI_UNSUPPORTED;
- }
- } else if (Signature == SII3132_PORT_SIGNATURE_ATAPI) {
- ASSERT (0); // Not supported yet
- SATA_TRACE ("SataSiI3132PortInitialization(): an ATAPI device is present");
- return EFI_UNSUPPORTED;
- } else if (Signature == SII3132_PORT_SIGNATURE_ATA) {
- SATA_TRACE ("SataSiI3132PortInitialization(): an ATA device is present");
- } else {
- SATA_TRACE ("SataSiI3132PortInitialization(): Present device unknown!");
- ASSERT (0); // Not supported
- return EFI_UNSUPPORTED;
- }
-
- // Create Device
- Device = (SATA_SI3132_DEVICE*)AllocatePool (sizeof (SATA_SI3132_DEVICE));
- Device->Index = Port->Index; //TODO: Could need to be fixed when SATA Port Multiplier support
- Device->Port = Port;
- Device->BlockSize = 0;
-
- // Attached the device to the Sata Port
- InsertTailList (&Port->Devices, &Device->Link);
-
- SATA_TRACE ("SataSiI3132PortInitialization(): Port Ready");
- }
- }
- return Status;
-}
-
-EFI_STATUS
-SataSiI3132Initialization (
- IN SATA_SI3132_INSTANCE* SataSiI3132Instance
- )
-{
- UINTN Index;
- EFI_PCI_IO_PROTOCOL* PciIo;
-
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- PciIo = SataSiI3132Instance->PciIo;
-
- // Turn Off GPIO
- SATA_GLOBAL_WRITE32 (SII3132_GLOBAL_FLASHADDR_REG, 0x0);
-
- // Clear Global Control Register
- SATA_GLOBAL_WRITE32 (SII3132_GLOBAL_CONTROL_REG, 0x0);
-
- for (Index = 0; Index < SATA_SII3132_MAXPORT; Index++) {
- SataSiI3132PortInitialization (&(SataSiI3132Instance->Ports[Index]));
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Test to see if this driver supports ControllerHandle.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to test.
- @param RemainingDevicePath Not used.
-
- @return EFI_SUCCESS This driver supports this device.
- @return EFI_UNSUPPORTED This driver does not support this device.
-
-**/
-EFI_STATUS
-EFIAPI
-SataSiI3132DriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT32 PciID;
-
- //
- // Test whether there is PCI IO Protocol attached on the controller handle.
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- PCI_VENDOR_ID_OFFSET,
- 1,
- &PciID
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_UNSUPPORTED;
- goto ON_EXIT;
- }
-
- //
- // Test whether the controller belongs to SATA Mass Storage type
- //
- if (PciID != ((SATA_SII3132_DEVICE_ID << 16) | SATA_SII3132_VENDOR_ID)) {
- Status = EFI_UNSUPPORTED;
- }
-
-ON_EXIT:
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-BOOLEAN mbStarted = FALSE;
-
-/**
- Starting the Pci SATA Driver.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to test.
- @param RemainingDevicePath Not used.
-
- @return EFI_SUCCESS supports this device.
- @return EFI_UNSUPPORTED do not support this device.
- @return EFI_DEVICE_ERROR cannot be started due to device Error.
- @return EFI_OUT_OF_RESOURCES cannot allocate resources.
-
-**/
-EFI_STATUS
-EFIAPI
-SataSiI3132DriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT64 Supports;
- UINT64 OriginalPciAttributes;
- BOOLEAN PciAttributesSaved;
- UINT32 PciID;
- SATA_SI3132_INSTANCE *SataSiI3132Instance = NULL;
-
- SATA_TRACE ("SataSiI3132DriverBindingStart()");
-
- //TODO: Find a nicer way to do it !
- if (mbStarted) {
- return EFI_SUCCESS; // Don't restart me !
- }
-
- //
- // Open the PciIo Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- PciAttributesSaved = FALSE;
- //
- // Save original PCI attributes
- //
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationGet,
- 0,
- &OriginalPciAttributes
- );
- if (EFI_ERROR (Status)) {
- goto CLOSE_PCIIO;
- }
- PciAttributesSaved = TRUE;
-
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
- );
- if (!EFI_ERROR (Status)) {
- Supports &= EFI_PCI_DEVICE_ENABLE;
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- Supports,
- NULL
- );
- }
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "SataSiI3132DriverBindingStart: failed to enable controller\n"));
- goto CLOSE_PCIIO;
- }
-
- //
- // Get the Pci device class code.
- //
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- PCI_VENDOR_ID_OFFSET,
- 1,
- &PciID
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_UNSUPPORTED;
- goto CLOSE_PCIIO;
- }
-
- //
- // Test whether the controller belongs to SATA Mass Storage type
- //
- if (PciID != ((SATA_SII3132_DEVICE_ID << 16) | SATA_SII3132_VENDOR_ID)) {
- Status = EFI_UNSUPPORTED;
- goto CLOSE_PCIIO;
- }
-
- // Create SiI3132 Sata Instance
- Status = SataSiI3132Constructor (PciIo, &SataSiI3132Instance);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Initialize SiI3132 Sata Controller
- Status = SataSiI3132Initialization (SataSiI3132Instance);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Install Ata Pass Thru Protocol
- Status = gBS->InstallProtocolInterface (
- &Controller,
- &gEfiAtaPassThruProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &(SataSiI3132Instance->AtaPassThruProtocol)
- );
- if (EFI_ERROR (Status)) {
- goto FREE_POOL;
- }
-
-/* //
- // Create event to stop the HC when exit boot service.
- //
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- EhcExitBootService,
- Ehc,
- &gEfiEventExitBootServicesGuid,
- &Ehc->ExitBootServiceEvent
- );
- if (EFI_ERROR (Status)) {
- goto UNINSTALL_USBHC;
- }*/
-
- mbStarted = TRUE;
-
- SATA_TRACE ("SataSiI3132DriverBindingStart() Success!");
- return EFI_SUCCESS;
-
-FREE_POOL:
- //TODO: Free SATA Instance
-
-CLOSE_PCIIO:
- if (PciAttributesSaved) {
- //
- // Restore original PCI attributes
- //
- PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSet,
- OriginalPciAttributes,
- NULL
- );
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle. Support stoping any child handles
- created by this driver.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to stop driver on.
- @param NumberOfChildren Number of Children in the ChildHandleBuffer.
- @param ChildHandleBuffer List of handles for the children we need to stop.
-
- @return EFI_SUCCESS Success.
- @return EFI_DEVICE_ERROR Fail.
-
-**/
-EFI_STATUS
-EFIAPI
-SataSiI3132DriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- SATA_TRACE ("SataSiI3132DriverBindingStop()");
- return EFI_UNSUPPORTED;
-}
-
-/**
- Entry point of this driver
-
- @param ImageHandle Handle of driver image
- @param SystemTable Point to EFI_SYSTEM_TABLE
-
- @retval EFI_OUT_OF_RESOURCES Can not allocate memory resource
- @retval EFI_DEVICE_ERROR Can not install the protocol instance
- @retval EFI_SUCCESS Success to initialize the Pci host bridge.
-**/
-EFI_STATUS
-EFIAPI
-InitializeSataSiI3132 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- SATA_TRACE ("InitializeSataSiI3132 ()");
-
- return EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gSataSiI3132DriverBinding,
- ImageHandle,
- &gSataSiI3132ComponentName,
- &gSataSiI3132ComponentName2
- );
-}
diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.h b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.h
deleted file mode 100644
index a7bc956b19..0000000000
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/** @file
-* Header containing the structure specific to the Silicon Image I3132 Sata PCI card
-*
-* Copyright (c) 2011-2015, 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 __SATASII3132_H
-#define __SATASII3132_H
-
-#include <PiDxe.h>
-
-#include <Protocol/AtaPassThru.h>
-#include <Protocol/PciIo.h>
-
-#include <Library/UefiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include <IndustryStandard/Pci.h>
-
-#define SATA_SII3132_DEVICE_ID 0x3132
-#define SATA_SII3132_VENDOR_ID 0x1095
-
-#define SII3132_PORT_SIGNATURE_PMP 0x96690101
-#define SII3132_PORT_SIGNATURE_ATAPI 0xEB140101
-#define SII3132_PORT_SIGNATURE_ATA 0x00000101
-
-/*
- * Silicon Image SiI3132 Registers
- */
-#define SII3132_GLOBAL_CONTROL_REG 0x40
-#define SII3132_GLOBAL_FLASHADDR_REG 0x70
-
-#define SII3132_PORT_STATUS_REG 0x1000
-#define SII3132_PORT_CONTROLSET_REG 0x1000
-#define SII3132_PORT_CONTROLCLEAR_REG 0x1004
-#define SII3132_PORT_INTSTATUS_REG 0x1008
-#define SII3132_PORT_ENABLEINT_REG 0x1010
-#define SII3132_PORT_INTCLEAR_REG 0x1014
-#define SII3132_PORT_32BITACTIVADDR_REG 0x101C
-#define SII3132_PORT_CMDEXECFIFO_REG 0x1020
-#define SII3132_PORT_CMDERROR_REG 0x1024
-#define SII3132_PORT_ERRCOUNTDECODE 0x1040
-#define SII3132_PORT_ERRCOUNTCRC 0x1044
-#define SII3132_PORT_ERRCOUNTHANDSHAKE 0x1048
-#define SII3132_PORT_SLOTSTATUS_REG 0x1800
-#define SII3132_PORT_CMDACTIV_REG 0x1C00
-#define SII3132_PORT_SSTATUS_REG 0x1F04
-
-#define SII3132_PORT_CONTROL_RESET (1 << 0)
-#define SII3132_PORT_DEVICE_RESET (1 << 1)
-#define SII3132_PORT_CONTROL_INT (1 << 2)
-#define SII3132_PORT_CONTROL_32BITACTIVATION (1 << 10)
-
-#define SII3132_PORT_STATUS_PORTREADY 0x80000000
-
-#define SII3132_PORT_INT_CMDCOMPL (1 << 0)
-#define SII3132_PORT_INT_CMDERR (1 << 1)
-#define SII3132_PORT_INT_PORTRDY (1 << 2)
-
-#define SATA_SII3132_MAXPORT 2
-
-#define PRB_CTRL_ATA 0x0
-#define PRB_CTRL_PROT_OVERRIDE 0x1
-#define PRB_CTRL_RESTRANSMIT 0x2
-#define PRB_CTRL_EXT_CMD 0x4
-#define PRB_CTRL_RCV 0x8
-#define PRB_CTRL_PKT_READ 0x10
-#define PRB_CTRL_PKT_WRITE 0x20
-#define PRB_CTRL_INT_MASK 0x40
-#define PRB_CTRL_SRST 0x80
-
-#define PRB_PROT_PACKET 0x01
-#define PRB_PROT_LEGACY_QUEUE 0x02
-#define PRB_PROT_NATIVE_QUEUE 0x04
-#define PRB_PROT_READ 0x08
-#define PRB_PROT_WRITE 0x10
-#define PRB_PROT_TRANSPARENT 0x20
-
-#define SGE_XCF (1 << 28)
-#define SGE_DRD (1 << 29)
-#define SGE_LNK (1 << 30)
-#define SGE_TRM 0x80000000
-
-typedef struct _SATA_SI3132_SGE {
- UINT32 DataAddressLow;
- UINT32 DataAddressHigh;
- UINT32 DataCount;
- UINT32 Attributes;
-} SATA_SI3132_SGE;
-
-typedef struct _SATA_SI3132_FIS {
- UINT8 FisType;
- UINT8 Control;
- UINT8 Command;
- UINT8 Features;
- UINT8 Fis[5 * 4];
-} SATA_SI3132_FIS;
-
-typedef struct _SATA_SI3132_PRB {
- UINT16 Control;
- UINT16 ProtocolOverride;
- UINT32 RecTransCount;
- SATA_SI3132_FIS Fis;
- SATA_SI3132_SGE Sge[2];
-} SATA_SI3132_PRB;
-
-typedef struct _SATA_SI3132_DEVICE {
- LIST_ENTRY Link; // This attribute must be the first entry of this structure (to avoid pointer computation)
- UINTN Index;
- struct _SATA_SI3132_PORT *Port; //Parent Port
- UINT32 BlockSize;
-} SATA_SI3132_DEVICE;
-
-typedef struct _SATA_SI3132_PORT {
- UINTN Index;
- UINTN RegBase;
- struct _SATA_SI3132_INSTANCE *Instance;
-
- //TODO: Support Port multiplier
- LIST_ENTRY Devices;
-
- SATA_SI3132_PRB* HostPRB;
- EFI_PHYSICAL_ADDRESS PhysAddrHostPRB;
- VOID* PciAllocMappingPRB;
-} SATA_SI3132_PORT;
-
-typedef struct _SATA_SI3132_INSTANCE {
- UINTN Signature;
-
- SATA_SI3132_PORT Ports[SATA_SII3132_MAXPORT];
-
- EFI_ATA_PASS_THRU_PROTOCOL AtaPassThruProtocol;
-
- EFI_PCI_IO_PROTOCOL *PciIo;
-} SATA_SI3132_INSTANCE;
-
-#define SATA_SII3132_SIGNATURE SIGNATURE_32('s', 'i', '3', '2')
-#define INSTANCE_FROM_ATAPASSTHRU_THIS(a) CR(a, SATA_SI3132_INSTANCE, AtaPassThruProtocol, SATA_SII3132_SIGNATURE)
-
-#define SATA_GLOBAL_READ32(Offset, Value) PciIo->Mem.Read (PciIo, EfiPciIoWidthUint32, 0, Offset, 1, Value)
-#define SATA_GLOBAL_WRITE32(Offset, Value) { UINT32 Value32 = Value; PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 0, Offset, 1, &Value32); }
-
-#define SATA_PORT_READ32(Offset, Value) PciIo->Mem.Read (PciIo, EfiPciIoWidthUint32, 1, Offset, 1, Value)
-#define SATA_PORT_WRITE32(Offset, Value) { UINT32 Value32 = Value; PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 1, Offset, 1, &Value32); }
-
-#define SATA_TRACE(txt) DEBUG((EFI_D_VERBOSE, "ARM_SATA: " txt "\n"))
-
-extern EFI_COMPONENT_NAME_PROTOCOL gSataSiI3132ComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gSataSiI3132ComponentName2;
-
-/*
- * Component Name Protocol Functions
- */
-EFI_STATUS
-EFIAPI
-SataSiI3132ComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-EFI_STATUS
-EFIAPI
-SataSiI3132ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-EFI_STATUS SiI3132HwResetPort (SATA_SI3132_PORT *Port);
-
-/*
- * Driver Binding Protocol Functions
- */
-EFI_STATUS
-EFIAPI
-SataSiI3132DriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-EFI_STATUS
-EFIAPI
-SataSiI3132DriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-EFI_STATUS
-EFIAPI
-SataSiI3132DriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-EFI_STATUS SiI3132AtaPassThruCommand (
- IN SATA_SI3132_INSTANCE *pSataSiI3132Instance,
- IN SATA_SI3132_PORT *pSataPort,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
- );
-
-/**
- * EFI ATA Pass Thru Protocol
- */
-EFI_STATUS SiI3132AtaPassThru (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
- );
-
-EFI_STATUS SiI3132GetNextPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN OUT UINT16 *Port
- );
-
-EFI_STATUS SiI3132GetNextDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN OUT UINT16 *PortMultiplierPort
- );
-
-EFI_STATUS SiI3132BuildDevicePath (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
- );
-
-EFI_STATUS SiI3132GetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT16 *Port,
- OUT UINT16 *PortMultiplierPort
- );
-
-EFI_STATUS SiI3132ResetPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port
- );
-
-EFI_STATUS SiI3132ResetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort
- );
-
-#endif
diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
deleted file mode 100644
index 69aaab3785..0000000000
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
+++ /dev/null
@@ -1,48 +0,0 @@
-#/** @file
-# INF file for the Silicon Image I3132 SATA controller
-#
-# Copyright (c) 2011-2015, 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SataSiI3132
- FILE_GUID = 1df18da0-a18b-11df-8c3a-0002a5d5c51b
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = InitializeSataSiI3132
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- UefiLib
- UefiDriverEntryPoint
- MemoryAllocationLib
-
-[Sources]
- SataSiI3132.c
- ComponentName.c
- SiI3132AtaPassThru.c
-
-[Protocols]
- gEfiPciIoProtocolGuid # Consumed
- gEfiAtaPassThruProtocolGuid # Produced
-
-[Pcd]
- gEmbeddedTokenSpaceGuid.PcdSataSiI3132FeaturePMPSupport
- gEmbeddedTokenSpaceGuid.PcdSataSiI3132FeatureDirectCommandIssuing
-
-[Depex]
- TRUE
diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
deleted file mode 100644
index 2fb5fd68db..0000000000
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
+++ /dev/null
@@ -1,825 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2015, 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.
-*
-**/
-
-#include "SataSiI3132.h"
-
-#include <IndustryStandard/Atapi.h>
-#include <Library/DevicePathLib.h>
-
-SATA_SI3132_DEVICE*
-GetSataDevice (
- IN SATA_SI3132_INSTANCE* SataInstance,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort
-) {
- LIST_ENTRY *List;
- SATA_SI3132_PORT *SataPort;
- SATA_SI3132_DEVICE *SataDevice;
-
- if (Port >= SATA_SII3132_MAXPORT) {
- return NULL;
- }
-
- SataPort = &(SataInstance->Ports[Port]);
- List = SataPort->Devices.ForwardLink;
-
- while (List != &SataPort->Devices) {
- SataDevice = (SATA_SI3132_DEVICE*)List;
- if (SataDevice->Index == PortMultiplierPort) {
- return SataDevice;
- }
- List = List->ForwardLink;
- }
- return NULL;
-}
-
-EFI_STATUS
-SiI3132AtaPassThruCommand (
- IN SATA_SI3132_INSTANCE *SataSiI3132Instance,
- IN SATA_SI3132_PORT *SataPort,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
- )
-{
- SATA_SI3132_DEVICE *SataDevice;
- EFI_PHYSICAL_ADDRESS PhysInDataBuffer;
- UINTN InDataBufferLength = 0;
- EFI_PHYSICAL_ADDRESS PhysOutDataBuffer;
- UINTN OutDataBufferLength;
- CONST UINTN EmptySlot = 0;
- UINTN Control = PRB_CTRL_ATA;
- UINTN Protocol = 0;
- UINT32 Value32, Error, Timeout = 0;
- CONST UINT32 IrqMask = (SII3132_PORT_INT_CMDCOMPL | SII3132_PORT_INT_CMDERR) << 16;
- EFI_STATUS Status;
- VOID* PciAllocMapping = NULL;
- EFI_PCI_IO_PROTOCOL *PciIo;
-
- PciIo = SataSiI3132Instance->PciIo;
- ZeroMem (SataPort->HostPRB, sizeof (SATA_SI3132_PRB));
-
- // Construct Si3132 PRB
- switch (Packet->Protocol) {
- case EFI_ATA_PASS_THRU_PROTOCOL_ATA_HARDWARE_RESET:
- ASSERT (0); //TODO: Implement me!
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_ATA_SOFTWARE_RESET:
- SATA_TRACE ("SiI3132AtaPassThru() EFI_ATA_PASS_THRU_PROTOCOL_ATA_SOFTWARE_RESET");
- Control = PRB_CTRL_SRST;
-
- if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
- SataPort->HostPRB->Fis.Control = 0x0F;
- }
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
- ASSERT (0); //TODO: Implement me!
- break;
-
- // There is no difference for SiI3132 between PIO and DMA invokation
- case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_IN:
- case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN:
- // Fixup the size for block transfer. Following UEFI Specification, 'InTransferLength' should
- // be in number of bytes. But for most data transfer commands, the value is in number of blocks
- if (Packet->Acb->AtaCommand == ATA_CMD_IDENTIFY_DRIVE) {
- InDataBufferLength = Packet->InTransferLength;
- } else {
- SataDevice = GetSataDevice (SataSiI3132Instance, SataPort->Index, PortMultiplierPort);
- if (!SataDevice || (SataDevice->BlockSize == 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- InDataBufferLength = Packet->InTransferLength * SataDevice->BlockSize;
- }
-
- Status = PciIo->Map (
- PciIo, EfiPciIoOperationBusMasterRead,
- Packet->InDataBuffer, &InDataBufferLength, &PhysInDataBuffer, &PciAllocMapping
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Construct SGEs (32-bit system)
- SataPort->HostPRB->Sge[0].DataAddressLow = (UINT32)PhysInDataBuffer;
- SataPort->HostPRB->Sge[0].DataAddressHigh = (UINT32)(PhysInDataBuffer >> 32);
- SataPort->HostPRB->Sge[0].Attributes = SGE_TRM; // Only one SGE
- SataPort->HostPRB->Sge[0].DataCount = InDataBufferLength;
-
- // Copy the Ata Command Block
- CopyMem (&SataPort->HostPRB->Fis, Packet->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
-
- // Fixup the FIS
- SataPort->HostPRB->Fis.FisType = 0x27; // Register - Host to Device FIS
- SataPort->HostPRB->Fis.Control = 1 << 7; // Is a command
- if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
- SataPort->HostPRB->Fis.Control |= PortMultiplierPort & 0xFF;
- }
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_OUT:
- case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT:
- SataDevice = GetSataDevice (SataSiI3132Instance, SataPort->Index, PortMultiplierPort);
- if (!SataDevice || (SataDevice->BlockSize == 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Fixup the size for block transfer. Following UEFI Specification, 'InTransferLength' should
- // be in number of bytes. But for most data transfer commands, the value is in number of blocks
- OutDataBufferLength = Packet->OutTransferLength * SataDevice->BlockSize;
-
- Status = PciIo->Map (
- PciIo, EfiPciIoOperationBusMasterWrite,
- Packet->OutDataBuffer, &OutDataBufferLength, &PhysOutDataBuffer, &PciAllocMapping
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Construct SGEs (32-bit system)
- SataPort->HostPRB->Sge[0].DataAddressLow = (UINT32)PhysOutDataBuffer;
- SataPort->HostPRB->Sge[0].DataAddressHigh = (UINT32)(PhysOutDataBuffer >> 32);
- SataPort->HostPRB->Sge[0].Attributes = SGE_TRM; // Only one SGE
- SataPort->HostPRB->Sge[0].DataCount = OutDataBufferLength;
-
- // Copy the Ata Command Block
- CopyMem (&SataPort->HostPRB->Fis, Packet->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
-
- // Fixup the FIS
- SataPort->HostPRB->Fis.FisType = 0x27; // Register - Host to Device FIS
- SataPort->HostPRB->Fis.Control = 1 << 7; // Is a command
- if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
- SataPort->HostPRB->Fis.Control |= PortMultiplierPort & 0xFF;
- }
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_DMA:
- ASSERT (0); //TODO: Implement me!
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_DMA_QUEUED:
- ASSERT (0); //TODO: Implement me!
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_DEVICE_DIAGNOSTIC:
- ASSERT (0); //TODO: Implement me!
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_DEVICE_RESET:
- ASSERT (0); //TODO: Implement me!
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_FPDMA:
- ASSERT (0); //TODO: Implement me!
- break;
- case EFI_ATA_PASS_THRU_PROTOCOL_RETURN_RESPONSE:
- ASSERT (0); //TODO: Implement me!
- break;
- default:
- ASSERT (0);
- break;
- }
-
- SataPort->HostPRB->Control = Control;
- SataPort->HostPRB->ProtocolOverride = Protocol;
-
- // Clear IRQ
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, IrqMask);
-
- if (!FeaturePcdGet (PcdSataSiI3132FeatureDirectCommandIssuing)) {
- // Indirect Command Issuance
-
- //TODO: Find which slot is free (maybe use the Cmd FIFO)
- //SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_CMDEXECFIFO_REG, &EmptySlot);
-
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CMDACTIV_REG + (EmptySlot * 8),
- (UINT32)(SataPort->PhysAddrHostPRB & 0xFFFFFFFF));
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CMDACTIV_REG + (EmptySlot * 8) + 4,
- (UINT32)((SataPort->PhysAddrHostPRB >> 32) & 0xFFFFFFFF));
- } else {
- // Direct Command Issuance
- Status = PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 1, // Bar 1
- SataPort->RegBase + (EmptySlot * 0x80),
- sizeof (SATA_SI3132_PRB) / 4,
- SataPort->HostPRB);
- ASSERT_EFI_ERROR (Status);
-
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CMDEXECFIFO_REG, EmptySlot);
- }
-
-#if 0
- // Could need to be implemented if we run multiple command in parallel to know which slot has been completed
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_SLOTSTATUS_REG, &Value32);
- Timeout = Packet->Timeout;
- while (!Timeout && !Value32) {
- gBS->Stall (1);
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_SLOTSTATUS_REG, &Value32);
- Timeout--;
- }
-#else
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, &Value32);
- if (!Packet->Timeout) {
- while (!(Value32 & IrqMask)) {
- gBS->Stall (1);
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, &Value32);
- }
- } else {
- Timeout = Packet->Timeout;
- while (Timeout && !(Value32 & IrqMask)) {
- gBS->Stall (1);
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, &Value32);
- Timeout--;
- }
- }
-#endif
- // Fill Packet Ata Status Block
- Status = PciIo->Mem.Read (PciIo, EfiPciIoWidthUint32, 1, // Bar 1
- SataPort->RegBase + 0x08,
- sizeof (EFI_ATA_STATUS_BLOCK) / 4,
- Packet->Asb);
- ASSERT_EFI_ERROR (Status);
-
-
- if ((Packet->Timeout != 0) && (Timeout == 0)) {
- DEBUG ((EFI_D_ERROR, "SiI3132AtaPassThru() Err:Timeout\n"));
- //ASSERT (0);
- return EFI_TIMEOUT;
- } else if (Value32 & (SII3132_PORT_INT_CMDERR << 16)) {
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_CMDERROR_REG, &Error);
- DEBUG ((EFI_D_ERROR, "SiI3132AtaPassThru() CmdErr:0x%X (SiI3132 Err:0x%X)\n", Value32, Error));
- ASSERT (0);
- return EFI_DEVICE_ERROR;
- } else if (Value32 & (SII3132_PORT_INT_CMDCOMPL << 16)) {
- // Clear Command Complete
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, SII3132_PORT_INT_CMDCOMPL << 16);
-
- if (PciAllocMapping) {
- Status = PciIo->Unmap (PciIo, PciAllocMapping);
- ASSERT (!EFI_ERROR (Status));
- }
-
- // If the command was ATA_CMD_IDENTIFY_DRIVE then we need to update the BlockSize
- if (Packet->Acb->AtaCommand == ATA_CMD_IDENTIFY_DRIVE) {
- ATA_IDENTIFY_DATA *IdentifyData = (ATA_IDENTIFY_DATA*)Packet->InDataBuffer;
-
- // Get the corresponding Block Device
- SataDevice = GetSataDevice (SataSiI3132Instance, SataPort->Index, PortMultiplierPort);
-
- // Check logical block size
- if ((IdentifyData->phy_logic_sector_support & BIT12) != 0) {
- ASSERT (SataDevice != NULL);
- SataDevice->BlockSize = (UINT32) (((IdentifyData->logic_sector_size_hi << 16) |
- IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
- } else {
- SataDevice->BlockSize = 0x200;
- }
- }
- return EFI_SUCCESS;
- } else {
- ASSERT (0);
- return EFI_DEVICE_ERROR;
- }
-}
-
-/**
- Sends an ATA command to an ATA device that is attached to the ATA controller. This function
- supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,
- and the non-blocking I/O functionality is optional.
-
- @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
- @param[in] Port The port number of the ATA device to send the command.
- @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
- If there is no port multiplier, then specify 0.
- @param[in,out] Packet A pointer to the ATA command to send to the ATA device specified by Port
- and PortMultiplierPort.
- @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking
- I/O is performed. If Event is NULL, then blocking I/O is performed. If
- Event is not NULL and non blocking I/O is supported, then non-blocking
- I/O is performed, and Event will be signaled when the ATA command completes.
-
- @retval EFI_SUCCESS The ATA command was sent by the host. For bi-directional commands,
- InTransferLength bytes were transferred from InDataBuffer. For write and
- bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer.
- @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number of bytes that could be transferred
- is returned in InTransferLength. For write and bi-directional commands,
- OutTransferLength bytes were transferred by OutDataBuffer.
- @retval EFI_NOT_READY The ATA command could not be sent because there are too many ATA commands
- already queued. The caller may retry again later.
- @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the ATA command.
- @retval EFI_INVALID_PARAMETER Port, PortMultiplierPort, or the contents of Acb are invalid. The ATA
- command was not sent, so no additional status information is available.
-
-**/
-EFI_STATUS
-SiI3132AtaPassThru (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
- )
-{
- SATA_SI3132_INSTANCE *SataSiI3132Instance;
- SATA_SI3132_DEVICE *SataDevice;
- SATA_SI3132_PORT *SataPort;
-
- SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- SataDevice = GetSataDevice (SataSiI3132Instance, Port, PortMultiplierPort);
- if (!SataDevice) {
- return EFI_INVALID_PARAMETER;
- }
- SataPort = SataDevice->Port;
-
- DEBUG ((EFI_D_INFO, "SiI3132AtaPassThru(%d,%d) : AtaCmd:0x%X Prot:%d\n", Port, PortMultiplierPort,
- Packet->Acb->AtaCommand, Packet->Protocol));
-
- return SiI3132AtaPassThruCommand (SataSiI3132Instance, SataPort, PortMultiplierPort, Packet, Event);
-}
-
-/**
- Used to retrieve the list of legal port numbers for ATA devices on an ATA controller.
- These can either be the list of ports where ATA devices are actually present or the
- list of legal port numbers for the ATA controller. Regardless, the caller of this
- function must probe the port number returned to see if an ATA device is actually
- present at that location on the ATA controller.
-
- The GetNextPort() function retrieves the port number on an ATA controller. If on input
- Port is 0xFFFF, then the port number of the first port on the ATA controller is returned
- in Port and EFI_SUCCESS is returned.
-
- If Port is a port number that was returned on a previous call to GetNextPort(), then the
- port number of the next port on the ATA controller is returned in Port, and EFI_SUCCESS
- is returned. If Port is not 0xFFFF and Port was not returned on a previous call to
- GetNextPort(), then EFI_INVALID_PARAMETER is returned.
-
- If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND is
- returned.
-
- @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
- @param[in,out] Port On input, a pointer to the port number on the ATA controller.
- On output, a pointer to the next port number on the ATA
- controller. An input value of 0xFFFF retrieves the first port
- number on the ATA controller.
-
- @retval EFI_SUCCESS The next port number on the ATA controller was returned in Port.
- @retval EFI_NOT_FOUND There are no more ports on this ATA controller.
- @retval EFI_INVALID_PARAMETER Port is not 0xFFFF and Port was not returned on a previous call
- to GetNextPort().
-
-**/
-EFI_STATUS
-SiI3132GetNextPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN OUT UINT16 *Port
- )
-{
- SATA_SI3132_INSTANCE *SataSiI3132Instance;
- UINTN PrevPort;
- EFI_STATUS Status = EFI_SUCCESS;
-
- SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- PrevPort = *Port;
-
- if (PrevPort == 0xFFFF) {
- *Port = 0;
- } else {
- if (PrevPort < SATA_SII3132_MAXPORT) {
- *Port = PrevPort + 1;
- } else {
- Status = EFI_NOT_FOUND;
- }
- }
- return Status;
-}
-
-/**
- Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA
- controller. These can either be the list of port multiplier ports where ATA devices are actually
- present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this
- function must probe the port number and port multiplier port number returned to see if an ATA
- device is actually present.
-
- The GetNextDevice() function retrieves the port multiplier port number of an ATA device
- present on a port of an ATA controller.
-
- If PortMultiplierPort points to a port multiplier port number value that was returned on a
- previous call to GetNextDevice(), then the port multiplier port number of the next ATA device
- on the port of the ATA controller is returned in PortMultiplierPort, and EFI_SUCCESS is
- returned.
-
- If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first
- ATA device on port of the ATA controller is returned in PortMultiplierPort and
- EFI_SUCCESS is returned.
-
- If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort
- was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER
- is returned.
-
- If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of
- the ATA controller, then EFI_NOT_FOUND is returned.
-
- @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
- @param[in] Port The port number present on the ATA controller.
- @param[in,out] PortMultiplierPort On input, a pointer to the port multiplier port number of an
- ATA device present on the ATA controller.
- If on input a PortMultiplierPort of 0xFFFF is specified,
- then the port multiplier port number of the first ATA device
- is returned. On output, a pointer to the port multiplier port
- number of the next ATA device present on an ATA controller.
-
- @retval EFI_SUCCESS The port multiplier port number of the next ATA device on the port
- of the ATA controller was returned in PortMultiplierPort.
- @retval EFI_NOT_FOUND There are no more ATA devices on this port of the ATA controller.
- @retval EFI_INVALID_PARAMETER PortMultiplierPort is not 0xFFFF, and PortMultiplierPort was not
- returned on a previous call to GetNextDevice().
-
-**/
-EFI_STATUS
-SiI3132GetNextDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN OUT UINT16 *PortMultiplierPort
- )
-{
- SATA_SI3132_INSTANCE *SataSiI3132Instance;
- SATA_SI3132_PORT *SataPort;
- SATA_SI3132_DEVICE *SataDevice;
- LIST_ENTRY *List;
- EFI_STATUS Status = EFI_SUCCESS;
-
- SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Port >= SATA_SII3132_MAXPORT) {
- return EFI_INVALID_PARAMETER;
- }
-
- SataPort = &(SataSiI3132Instance->Ports[Port]);
-
- if (*PortMultiplierPort == 0xFFFF) {
- List = SataPort->Devices.ForwardLink;
- if (List != &SataPort->Devices) {
- // The list is not empty, return the first device
- *PortMultiplierPort = ((SATA_SI3132_DEVICE*)List)->Index;
- } else {
- Status = EFI_NOT_FOUND;
- }
- } else {
- SataDevice = GetSataDevice (SataSiI3132Instance, Port, *PortMultiplierPort);
- if (SataDevice != NULL) {
- // We have found the previous port multiplier, return the next one
- List = SataDevice->Link.ForwardLink;
- if (List != &SataPort->Devices) {
- *PortMultiplierPort = ((SATA_SI3132_DEVICE*)List)->Index;
- } else {
- Status = EFI_NOT_FOUND;
- }
- } else {
- Status = EFI_NOT_FOUND;
- }
- }
- return Status;
-}
-
-/**
- Used to allocate and build a device path node for an ATA device on an ATA controller.
-
- The BuildDevicePath() function allocates and builds a single device node for the ATA
- device specified by Port and PortMultiplierPort. If the ATA device specified by Port and
- PortMultiplierPort is not present on the ATA controller, then EFI_NOT_FOUND is returned.
- If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. If there are not enough
- resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
-
- Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of
- DevicePath are initialized to describe the ATA device specified by Port and PortMultiplierPort,
- and EFI_SUCCESS is returned.
-
- @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
- @param[in] Port Port specifies the port number of the ATA device for which a
- device path node is to be allocated and built.
- @param[in] PortMultiplierPort The port multiplier port number of the ATA device for which a
- device path node is to be allocated and built. If there is no
- port multiplier, then specify 0.
- @param[in,out] DevicePath A pointer to a single device path node that describes the ATA
- device specified by Port and PortMultiplierPort. This function
- is responsible for allocating the buffer DevicePath with the
- boot service AllocatePool(). It is the caller's responsibility
- to free DevicePath when the caller is finished with DevicePath.
- @retval EFI_SUCCESS The device path node that describes the ATA device specified by
- Port and PortMultiplierPort was allocated and returned in DevicePath.
- @retval EFI_NOT_FOUND The ATA device specified by Port and PortMultiplierPort does not
- exist on the ATA controller.
- @retval EFI_INVALID_PARAMETER DevicePath is NULL.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
-
-**/
-EFI_STATUS
-SiI3132BuildDevicePath (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
- )
-{
- SATA_SI3132_INSTANCE *SataSiI3132Instance;
- SATA_SI3132_DEVICE *SataDevice;
- EFI_DEVICE_PATH_PROTOCOL *SiI3132DevicePath;
-
- SATA_TRACE ("SiI3132BuildDevicePath()");
-
- SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- SataDevice = GetSataDevice (SataSiI3132Instance, Port, PortMultiplierPort);
- if (SataDevice == NULL) {
- return EFI_NOT_FOUND;
- }
-
- SiI3132DevicePath = CreateDeviceNode (MESSAGING_DEVICE_PATH, MSG_SATA_DP, sizeof (SATA_DEVICE_PATH));
- if (SiI3132DevicePath == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- ((SATA_DEVICE_PATH*)SiI3132DevicePath)->HBAPortNumber = Port;
- if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
- ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = PortMultiplierPort;
- } else {
- //Temp:((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = SATA_HBA_DIRECT_CONNECT_FLAG;
- ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = 0;
- }
- ((SATA_DEVICE_PATH*)SiI3132DevicePath)->Lun = Port; //TODO: Search information how to define properly LUN (Logical Unit Number)
-
- *DevicePath = SiI3132DevicePath;
- return EFI_SUCCESS;
-}
-
-/**
- Used to translate a device path node to a port number and port multiplier port number.
-
- The GetDevice() function determines the port and port multiplier port number associated with
- the ATA device described by DevicePath. If DevicePath is a device path node type that the
- ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents
- DevicePath into a port number and port multiplier port number.
-
- If this translation is successful, then that port number and port multiplier port number are returned
- in Port and PortMultiplierPort, and EFI_SUCCESS is returned.
-
- If DevicePath, Port, or PortMultiplierPort are NULL, then EFI_INVALID_PARAMETER is returned.
-
- If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then
- EFI_UNSUPPORTED is returned.
-
- If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not
- a valid translation from DevicePath to a port number and port multiplier port number, then
- EFI_NOT_FOUND is returned.
-
- @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
- @param[in] DevicePath A pointer to the device path node that describes an ATA device on the
- ATA controller.
- @param[out] Port On return, points to the port number of an ATA device on the ATA controller.
- @param[out] PortMultiplierPort On return, points to the port multiplier port number of an ATA device
- on the ATA controller.
-
- @retval EFI_SUCCESS DevicePath was successfully translated to a port number and port multiplier
- port number, and they were returned in Port and PortMultiplierPort.
- @retval EFI_INVALID_PARAMETER DevicePath is NULL.
- @retval EFI_INVALID_PARAMETER Port is NULL.
- @retval EFI_INVALID_PARAMETER PortMultiplierPort is NULL.
- @retval EFI_UNSUPPORTED This driver does not support the device path node type in DevicePath.
- @retval EFI_NOT_FOUND A valid translation from DevicePath to a port number and port multiplier
- port number does not exist.
-**/
-EFI_STATUS
-SiI3132GetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT16 *Port,
- OUT UINT16 *PortMultiplierPort
- )
-{
- SATA_SI3132_INSTANCE *SataSiI3132Instance;
-
- SATA_TRACE ("SiI3132GetDevice()");
-
- if (!DevicePath || !Port || !PortMultiplierPort) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DevicePath->Type != MESSAGING_DEVICE_PATH) || (DevicePath->SubType != MSG_SATA_DP)) {
- return EFI_UNSUPPORTED;
- }
-
- SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (((SATA_DEVICE_PATH*)DevicePath)->Lun >= SATA_SII3132_MAXPORT) {
- return EFI_NOT_FOUND;
- }
-
- if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
- ASSERT (0); //TODO: Implement me!
- return EFI_UNSUPPORTED;
- } else {
- *Port = ((SATA_DEVICE_PATH*)DevicePath)->Lun;
- // Return the first Sata Sevice as there should be only one directly connected
- *PortMultiplierPort = ((SATA_SI3132_DEVICE*)SataSiI3132Instance->Ports[*Port].Devices.ForwardLink)->Index;
- return EFI_SUCCESS;
- }
-}
-
-EFI_STATUS
-SiI3132HwResetPort (
- IN SATA_SI3132_PORT *SataPort
- )
-{
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT32 Value32;
- UINTN Timeout;
-
- SATA_TRACE ("SiI3132HwResetPort()");
-
- PciIo = SataPort->Instance->PciIo;
-
- // Clear Port Reset
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CONTROLCLEAR_REG, SII3132_PORT_CONTROL_RESET);
-
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_STATUS_REG, &Value32);
- ASSERT (!(Value32 & SII3132_PORT_CONTROL_RESET));
-
- // Initialize error counters
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_ERRCOUNTDECODE, 0);
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_ERRCOUNTCRC, 0);
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_ERRCOUNTHANDSHAKE, 0);
-
- // Enable interrupts for command completion and command errors
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_ENABLEINT_REG, SII3132_PORT_INT_CMDCOMPL | SII3132_PORT_INT_CMDERR);
-
- // Clear IRQ
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_ENABLEINT_REG, SII3132_PORT_INT_CMDCOMPL | SII3132_PORT_INT_CMDERR | SII3132_PORT_INT_PORTRDY | (1 << 3));
-
- // Wait until Port Ready
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, &Value32);
- Timeout = 1000;
- while ((Timeout > 0) && ((Value32 & SII3132_PORT_INT_PORTRDY) == 0)) {
- gBS->Stall (1);
- Timeout--;
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, &Value32);
- }
- // Clear IRQ
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, SII3132_PORT_INT_PORTRDY);
-
- if (Timeout == 0) {
- SATA_TRACE ("SiI3132HwResetPort(): Timeout");
- return EFI_TIMEOUT;
- } else if ((Value32 & SII3132_PORT_INT_PORTRDY) == 0) {
- SATA_TRACE ("SiI3132HwResetPort(): Port Not Ready");
- return EFI_DEVICE_ERROR;
- } else {
- return EFI_SUCCESS;
- }
-}
-
-/**
- Resets a specific port on the ATA controller. This operation also resets all the ATA devices
- connected to the port.
-
- The ResetChannel() function resets an a specific port on an ATA controller. This operation
- resets all the ATA devices connected to that port. If this ATA controller does not support
- a reset port operation, then EFI_UNSUPPORTED is returned.
-
- If a device error occurs while executing that port reset operation, then EFI_DEVICE_ERROR is
- returned.
-
- If a timeout occurs during the execution of the port reset operation, then EFI_TIMEOUT is returned.
-
- If the port reset operation is completed, then EFI_SUCCESS is returned.
-
- @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
- @param[in] Port The port number on the ATA controller.
-
- @retval EFI_SUCCESS The ATA controller port was reset.
- @retval EFI_UNSUPPORTED The ATA controller does not support a port reset operation.
- @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA port.
- @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA port.
-
-**/
-EFI_STATUS
-SiI3132ResetPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port
- )
-{
- SATA_SI3132_INSTANCE *SataSiI3132Instance;
- SATA_SI3132_PORT *SataPort;
-
- SATA_TRACE ("SiI3132ResetPort()");
-
- SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Port >= SATA_SII3132_MAXPORT) {
- return EFI_UNSUPPORTED;
- }
-
- SataPort = &(SataSiI3132Instance->Ports[Port]);
- return SiI3132HwResetPort (SataPort);
-}
-
-/**
- Resets an ATA device that is connected to an ATA controller.
-
- The ResetDevice() function resets the ATA device specified by Port and PortMultiplierPort.
- If this ATA controller does not support a device reset operation, then EFI_UNSUPPORTED is
- returned.
-
- If Port or PortMultiplierPort are not in a valid range for this ATA controller, then
- EFI_INVALID_PARAMETER is returned.
-
- If a device error occurs while executing that device reset operation, then EFI_DEVICE_ERROR
- is returned.
-
- If a timeout occurs during the execution of the device reset operation, then EFI_TIMEOUT is
- returned.
-
- If the device reset operation is completed, then EFI_SUCCESS is returned.
-
- @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
- @param[in] Port Port represents the port number of the ATA device to be reset.
- @param[in] PortMultiplierPort The port multiplier port number of the ATA device to reset.
- If there is no port multiplier, then specify 0.
- @retval EFI_SUCCESS The ATA device specified by Port and PortMultiplierPort was reset.
- @retval EFI_UNSUPPORTED The ATA controller does not support a device reset operation.
- @retval EFI_INVALID_PARAMETER Port or PortMultiplierPort are invalid.
- @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA device
- specified by Port and PortMultiplierPort.
- @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA device
- specified by Port and PortMultiplierPort.
-
-**/
-EFI_STATUS
-SiI3132ResetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort
- )
-{
- EFI_PCI_IO_PROTOCOL *PciIo;
- SATA_SI3132_INSTANCE *SataSiI3132Instance;
- SATA_SI3132_PORT *SataPort;
- SATA_SI3132_DEVICE *SataDevice;
- UINTN Timeout;
- UINT32 Value32;
-
- SATA_TRACE ("SiI3132ResetDevice()");
-
- SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
- if (!SataSiI3132Instance) {
- return EFI_INVALID_PARAMETER;
- }
-
- PciIo = SataSiI3132Instance->PciIo;
-
- SataDevice = GetSataDevice (SataSiI3132Instance, Port, PortMultiplierPort);
- if (!SataDevice) {
- return EFI_INVALID_PARAMETER;
- }
- SataPort = SataDevice->Port;
-
- SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CONTROLSET_REG, SII3132_PORT_DEVICE_RESET);
-
- Timeout = 100;
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_STATUS_REG, &Value32);
- while ((Timeout > 0) && ((Value32 & SII3132_PORT_DEVICE_RESET) != 0)) {
- gBS->Stall (1);
- SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_STATUS_REG, &Value32);
- Timeout--;
- }
-
- if (Timeout == 0) {
- SATA_TRACE ("SiI3132ResetDevice(): Timeout");
- return EFI_TIMEOUT;
- } else {
- return EFI_SUCCESS;
- }
-}
diff --git a/EmbeddedPkg/Ebl/CmdTemplate.c b/EmbeddedPkg/Ebl/CmdTemplate.c
deleted file mode 100644
index 2c291fcaea..0000000000
--- a/EmbeddedPkg/Ebl/CmdTemplate.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/** @file
- %CommandName% for EBL (Embedded Boot Loader)
-
- 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.
-
- Module Name: CmdTemplate.c
-
- Search/Replace %CommandName% with the name of your new command
-
-**/
-
-#include "Ebl.h"
-
-
-/**
- Fill Me In
-
- Argv[0] - "%CommandName%"
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-Ebl%CommandName%Cmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- return EFI_SUCCESS;
-}
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmd%CommandName%Template[] =
-{
- {
- "%CommandName%",
- " [show args] ; explain args and command",
- NULL,
- Ebl%CommandName%Cmd
- }
-};
-
-
-/**
- Initialize the commands in this file
-**/
-VOID
-EblInitialize%CommandName%Cmd (
- VOID
- )
-{
- EblAddCommands (mCmd%CommandName%Template, sizeof (mCmd%CommandName%Template)/sizeof (EBL_COMMAND_TABLE));
-}
-
diff --git a/EmbeddedPkg/Ebl/Command.c b/EmbeddedPkg/Ebl/Command.c
deleted file mode 100644
index 04ea79464f..0000000000
--- a/EmbeddedPkg/Ebl/Command.c
+++ /dev/null
@@ -1,916 +0,0 @@
-/** @file
- Basic commands and command processing infrastructure for EBL
-
- 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.
-
-**/
-
-#include "Ebl.h"
-#include <Protocol/DiskIo.h>
-#include <Protocol/BlockIo.h>
-
-UINTN mCmdTableMaxIndex = EBL_MAX_COMMAND_COUNT;
-UINTN mCmdTableNextFreeIndex = 0;
-EBL_COMMAND_TABLE *mCmdTable[EBL_MAX_COMMAND_COUNT];
-
-/**
- Converts a lowercase Ascii character to upper one
-
- If Chr is lowercase Ascii character, then converts it to upper one.
-
- If Value >= 0xA0, then ASSERT().
- If (Value & 0x0F) >= 0x0A, then ASSERT().
-
- @param chr one Ascii character
-
- @return The uppercase value of Ascii character
-
-**/
-STATIC
-CHAR8
-AsciiToUpper (
- IN CHAR8 Chr
- )
-{
- return (UINT8) ((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr);
-}
-
-
-/**
- Case insensitive comparison of two Null-terminated Unicode strings with maximum
- lengths, and returns the difference between the first mismatched Unicode
- characters.
- This function compares the Null-terminated Unicode string FirstString to the
- Null-terminated Unicode string SecondString. At most, Length Unicode
- characters will be compared. If Length is 0, then 0 is returned. If
- FirstString is identical to SecondString, then 0 is returned. Otherwise, the
- value returned is the first mismatched Unicode character in SecondString
- subtracted from the first mismatched Unicode character in FirstString.
-
- @param FirstString Pointer to a Null-terminated ASCII string.
- @param SecondString Pointer to a Null-terminated ASCII string.
- @param Length Max length to compare.
-
- @retval 0 FirstString is identical to SecondString using case insensitive
- comparisons.
- @retval !=0 FirstString is not identical to SecondString using case
- insensitive comparisons.
-
-**/
-INTN
-EFIAPI
-AsciiStrniCmp (
- IN CONST CHAR8 *FirstString,
- IN CONST CHAR8 *SecondString,
- IN UINTN Length
- )
-{
- if (Length == 0) {
- return 0;
- }
-
- while ((AsciiToUpper (*FirstString) != '\0') &&
- (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString)) &&
- (Length > 1)) {
- FirstString++;
- SecondString++;
- Length--;
- }
-
- return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);
-}
-
-
-
-/**
- Add a command to the mCmdTable. If there is no free space in the command
- table ASSERT. The mCmdTable is maintained in alphabetical order and the
- new entry is inserted into its sorted position.
-
- @param Entry Command Entry to add to the CmdTable
-
-**/
-VOID
-EFIAPI
-EblAddCommand (
- IN const EBL_COMMAND_TABLE *Entry
- )
-{
- UINTN Count;
-
- if (mCmdTableNextFreeIndex == EBL_MAX_COMMAND_COUNT) {
- //
- // Ran out of space to store commands. Increase EBL_MAX_COMMAND_COUNT
- //
- ASSERT (FALSE);
- return;
- }
-
- //
- // Add command and Insertion sort array in the process
- //
- mCmdTable[mCmdTableNextFreeIndex] = (EBL_COMMAND_TABLE *)Entry;
- if (mCmdTableNextFreeIndex != 0) {
- for (Count = mCmdTableNextFreeIndex; Count > 0; Count--) {
- if (AsciiStriCmp (mCmdTable[Count - 1]->Name, Entry->Name) <= 0) {
- break;
- }
-
- mCmdTable[Count] = mCmdTable[Count - 1];
- }
- mCmdTable[Count] = (EBL_COMMAND_TABLE *)Entry;
- }
-
- mCmdTableNextFreeIndex++;
-}
-
-
-/**
- Add an set of commands to the command table. Most commonly used on static
- array of commands.
-
- @param EntryArray Pointer to array of command entries
- @param ArrayCount Number of command entries to add
-
-**/
-VOID
-EFIAPI
-EblAddCommands (
- IN const EBL_COMMAND_TABLE *EntryArray,
- IN UINTN ArrayCount
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < ArrayCount; Index++) {
- EblAddCommand (&EntryArray[Index]);
- }
-}
-
-
-EBL_ADD_COMMAND_PROTOCOL gEblAddCommand = {
- EblAddCommand,
- EblAddCommands,
- EblGetCharKey,
- EblAnyKeyToContinueQtoQuit
-};
-
-
-
-/**
- Return the best matching command for the passed in command name. The match
- does not have to be exact, it just needs to be unique. This enables commands
- to be shortened to the smallest set of starting characters that is unique.
-
- @param CommandName Name of command to search for
-
- @return NULL CommandName did not match or was not unique
- Other Pointer to EBL_COMMAND_TABLE entry for CommandName
-
-**/
-EBL_COMMAND_TABLE *
-EblGetCommand (
- IN CHAR8 *CommandName
- )
-{
- UINTN Index;
- UINTN BestMatchCount;
- UINTN Length;
- EBL_COMMAND_TABLE *Match;
- CHAR8 *Str;
-
- Length = AsciiStrLen (CommandName);
- Str = AsciiStrStr (CommandName, ".");
- if (Str != NULL) {
- // If the command includes a trailing . command extension skip it for the match.
- // Example: hexdump.4
- Length = (UINTN)(Str - CommandName);
- }
-
- for (Index = 0, BestMatchCount = 0, Match = NULL; Index < mCmdTableNextFreeIndex; Index++) {
- if (AsciiStriCmp (mCmdTable[Index]->Name, CommandName) == 0) {
- // match a command exactly
- return mCmdTable[Index];
- }
-
- if (AsciiStrniCmp (CommandName, mCmdTable[Index]->Name, Length) == 0) {
- // partial match, so keep looking to make sure there is only one partial match
- BestMatchCount++;
- Match = mCmdTable[Index];
- }
- }
-
- if (BestMatchCount == 1) {
- return Match;
- }
-
- //
- // We had no matches or too many matches
- //
- return NULL;
-}
-
-
-UINTN
-CountNewLines (
- IN CHAR8 *Str
- )
-{
- UINTN Count;
-
- if (Str == NULL) {
- return 0;
- }
-
- for (Count = 0; *Str != '\0'; Str++) {
- if (Str[Count] == '\n') {
- Count++;
- }
- }
-
- return Count;
-}
-
-
-/**
- List out help information on all the commands or print extended information
- about a specific passed in command.
-
- Argv[0] - "help"
- Argv[1] - Command to display help about
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblHelpCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Index;
- CHAR8 *Ptr;
- UINTN CurrentRow = 0;
-
- if (Argc == 1) {
- // Print all the commands
- AsciiPrint ("Embedded Boot Loader (EBL) commands (help command for more info):\n");
- CurrentRow++;
- for (Index = 0; Index < mCmdTableNextFreeIndex; Index++) {
- EblSetTextColor (EFI_YELLOW);
- AsciiPrint (" %a", mCmdTable[Index]->Name);
- EblSetTextColor (0);
- AsciiPrint ("%a\n", mCmdTable[Index]->HelpSummary);
- // Handle multi line help summaries
- CurrentRow += CountNewLines (mCmdTable[Index]->HelpSummary);
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- break;
- }
- }
- } else if (Argv[1] != NULL) {
- // Print specific help
- for (Index = 0, CurrentRow = 0; Index < mCmdTableNextFreeIndex; Index++) {
- if (AsciiStriCmp (Argv[1], mCmdTable[Index]->Name) == 0) {
- Ptr = (mCmdTable[Index]->Help == NULL) ? mCmdTable[Index]->HelpSummary : mCmdTable[Index]->Help;
- AsciiPrint ("%a%a\n", Argv[1], Ptr);
- // Handle multi line help summaries
- CurrentRow += CountNewLines (Ptr);
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- break;
- }
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Exit the EBL. If the command processor sees EFI_ABORTED return status it will
- exit the EBL.
-
- Argv[0] - "exit"
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_ABORTED
-
-**/
-EFI_STATUS
-EblExitCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- UINTN MemoryMapSize;
- EFI_MEMORY_DESCRIPTOR *MemoryMap;
- UINTN MapKey;
- UINTN DescriptorSize;
- UINT32 DescriptorVersion;
- UINTN Pages;
-
- if (Argc > 1) {
- if (AsciiStriCmp (Argv[1], "efi") != 0) {
- return EFI_ABORTED;
- }
- } else if (Argc == 1) {
- return EFI_ABORTED;
- }
-
- MemoryMap = NULL;
- MemoryMapSize = 0;
- do {
- Status = gBS->GetMemoryMap (
- &MemoryMapSize,
- MemoryMap,
- &MapKey,
- &DescriptorSize,
- &DescriptorVersion
- );
- if (Status == EFI_BUFFER_TOO_SMALL) {
-
- Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
- MemoryMap = AllocatePages (Pages);
-
- //
- // Get System MemoryMap
- //
- Status = gBS->GetMemoryMap (
- &MemoryMapSize,
- MemoryMap,
- &MapKey,
- &DescriptorSize,
- &DescriptorVersion
- );
- // Don't do anything between the GetMemoryMap() and ExitBootServices()
- if (!EFI_ERROR (Status)) {
- Status = gBS->ExitBootServices (gImageHandle, MapKey);
- if (EFI_ERROR (Status)) {
- FreePages (MemoryMap, Pages);
- MemoryMap = NULL;
- MemoryMapSize = 0;
- }
- }
- }
- } while (EFI_ERROR (Status));
-
- //
- // At this point it is very dangerous to do things EFI as most of EFI is now gone.
- // This command is useful if you are working with a debugger as it will shutdown
- // DMA and other things that could break a soft resets.
- //
- CpuDeadLoop ();
-
- // Should never get here, but makes the compiler happy
- return EFI_ABORTED;
-}
-
-
-/**
- Update the screen by decrementing the timeout value.
- This AsciiPrint has to match the AsciiPrint in
- EblPauseCmd.
-
- @param ElaspedTime Current timeout value remaining
-
-**/
-VOID
-EFIAPI
-EblPauseCallback (
- IN UINTN ElapsedTime
- )
-{
- AsciiPrint ("\b\b\b\b\b\b\b\b\b\b\b\b \b\b%3d seconds", ElapsedTime);
-}
-
-/**
- Pause until a key is pressed and abort the remaining commands on the command
- line. If no key is pressed continue processing the command line. This command
- allows the user to stop an operation from happening and return control to the
- command prompt.
-
- Argv[0] - "pause"
- Argv[1] - timeout value is decimal seconds
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS Timeout expired with no input
- @return EFI_TIMEOUT Stop processing other commands on the same command line
-
-**/
-EFI_STATUS
-EblPauseCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- UINTN Delay;
- EFI_INPUT_KEY Key;
-
- Delay = (Argc == 1)? 10 : AsciiStrDecimalToUintn (Argv[1]);
-
- AsciiPrint ("Hit any key to break. You have %3d seconds", Delay);
- Status = EblGetCharKey (&Key, Delay, EblPauseCallback);
- AsciiPrint ("\n");
-
- // If we timeout then the pause succeeded thus return success
- // If we get a key return timeout to stop other command on this cmd line
- return (Status == EFI_SUCCESS) ? EFI_TIMEOUT : EFI_SUCCESS;;
-}
-
-
-/**
- On a debug build issue a software breakpoint to enter the debugger
-
- Argv[0] - "break"
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblBreakPointCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- CpuBreakpoint ();
- return EFI_SUCCESS;
-}
-
-
-/**
- Reset the system. If no Argument do a Cold reset. If argument use that reset type
- (W)arm = Warm Reset
- (S)hutdown = Shutdown Reset
-
- Argv[0] - "reset"
- Argv[1] - warm or shutdown reset type
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblResetCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_RESET_TYPE ResetType;
-
- ResetType = EfiResetCold;
- if (Argc > 1) {
- switch (*Argv[1]) {
- case 'W':
- case 'w':
- ResetType = EfiResetWarm;
- break;
- case 'S':
- case 's':
- ResetType = EfiResetShutdown;
- }
- }
-
- gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);
- return EFI_SUCCESS;
-}
-
-
-/**
- Toggle page break global. This turns on and off prompting to Quit or hit any
- key to continue when a command is about to scroll the screen with its output
-
- Argv[0] - "page"
- Argv[1] - on or off
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblPageCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- if (Argc <= 1) {
- // toggle setting
- gPageBreak = (gPageBreak) ? FALSE : TRUE;
- } else {
- // use argv to set the value
- if ((Argv[1][0] == 'o') || (Argv[1][0] == 'O')) {
- if ((Argv[1][1] == 'n') || (Argv[1][1] == 'N')) {
- gPageBreak = TRUE;
- } else if ((Argv[1][1] == 'f') || (Argv[1][1] == 'F')) {
- gPageBreak = FALSE;
- } else {
- return EFI_INVALID_PARAMETER;
- }
- }
- }
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EblSleepCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Delay;
-
- Delay = (Argc == 1)? 10 : AsciiStrDecimalToUintn (Argv[1]);
-
- gBS->Stall (Delay * 1000000);
-
- return EFI_SUCCESS;
-}
-
-CHAR8
-ConvertToTextLine (
- IN CHAR8 Character
- )
-{
- if (Character < ' ' || Character > '~') {
- return '.';
- } else {
- return Character;
- }
-}
-
-UINTN
-GetBytes (
- IN UINT8 *Address,
- IN UINTN Bytes
- )
-{
- UINTN Result = 0;
-
- if (Bytes >= 1) {
- Result = *Address++;
- }
- if (Bytes >= 2) {
- Result = (Result << 8) + *Address++;
- }
- if (Bytes >= 3) {
- Result = (Result << 8) + *Address++;
- }
- return Result;
-}
-
-CHAR8 mBlanks[] = " ";
-
-EFI_STATUS
-OutputData (
- IN UINT8 *Address,
- IN UINTN Length,
- IN UINTN Width,
- IN UINTN Offset
- )
-{
- UINT8 *EndAddress;
- UINTN Line;
- CHAR8 TextLine[0x11];
- UINTN CurrentRow = 0;
- UINTN Bytes;
- UINTN Spaces = 0;
- CHAR8 Blanks[80];
-
- AsciiStrCpy (Blanks, mBlanks);
- for (EndAddress = Address + Length; Address < EndAddress; Offset += Line) {
- AsciiPrint ("%08x: ", Offset);
- for (Line = 0; (Line < 0x10) && (Address < EndAddress);) {
- Bytes = EndAddress - Address;
-
- switch (Width) {
- case 4:
- if (Bytes >= 4) {
- AsciiPrint ("%08x ", *((UINT32 *)Address));
- TextLine[Line++] = ConvertToTextLine(*Address++);
- TextLine[Line++] = ConvertToTextLine(*Address++);
- TextLine[Line++] = ConvertToTextLine(*Address++);
- TextLine[Line++] = ConvertToTextLine(*Address++);
- } else {
- AsciiPrint ("%08x ", GetBytes(Address, Bytes));
- Address += Bytes;
- Line += Bytes;
- }
- break;
-
- case 2:
- if (Bytes >= 2) {
- AsciiPrint ("%04x ", *((UINT16 *)Address));
- TextLine[Line++] = ConvertToTextLine(*Address++);
- TextLine[Line++] = ConvertToTextLine(*Address++);
- } else {
- AsciiPrint ("%04x ", GetBytes(Address, Bytes));
- Address += Bytes;
- Line += Bytes;
- }
- break;
-
- case 1:
- AsciiPrint ("%02x ", *((UINT8 *)Address));
- TextLine[Line++] = ConvertToTextLine(*Address++);
- break;
-
- default:
- AsciiPrint ("Width must be 1, 2, or 4!\n");
- return EFI_INVALID_PARAMETER;
- }
- }
-
- // Pad spaces
- if (Line < 0x10) {
- switch (Width) {
- case 4:
- Spaces = 9 * ((0x10 - Line)/4);
- break;
- case 2:
- Spaces = 5 * ((0x10 - Line)/2);
- break;
- case 1:
- Spaces = 3 * (0x10 - Line);
- break;
- }
-
- Blanks[Spaces] = '\0';
-
- AsciiPrint(Blanks);
-
- Blanks[Spaces] = ' ';
- }
-
- TextLine[Line] = 0;
- AsciiPrint ("|%a|\n", TextLine);
-
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- return EFI_END_OF_FILE;
- }
- }
-
- if (Length % Width != 0) {
- AsciiPrint ("%08x\n", Offset);
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- See if command contains .# where # is a number. Return # as the Width
- or 1 as the default Width for commands.
-
- Example hexdump.4 returns a width of 4.
-
- @param Argv Argv[0] is the command name
-
- @return Width of command
-
-**/
-UINTN
-WidthFromCommandName (
- IN CHAR8 *Argv,
- IN UINTN Default
- )
-{
- CHAR8 *Str;
- UINTN Width;
-
- //Hexdump.2 HexDump.4 mean use a different width
- Str = AsciiStrStr (Argv, ".");
- if (Str != NULL) {
- Width = AsciiStrDecimalToUintn (Str + 1);
- if (Width == 0) {
- Width = Default;
- }
- } else {
- // Default answer
- return Default;
- }
-
- return Width;
-}
-
-#define HEXDUMP_CHUNK 1024
-
-/**
- Toggle page break global. This turns on and off prompting to Quit or hit any
- key to continue when a command is about to scroll the screen with its output
-
- Argv[0] - "hexdump"[.#] # is optional 1,2, or 4 for width
- Argv[1] - Device or File to dump.
- Argv[2] - Optional offset to start dumping
- Argv[3] - Optional number of bytes to dump
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblHexdumpCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_OPEN_FILE *File;
- VOID *Location;
- UINTN Size;
- UINTN Width;
- UINTN Offset = 0;
- EFI_STATUS Status;
- UINTN Chunk = HEXDUMP_CHUNK;
-
- if ((Argc < 2) || (Argc > 4)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Width = WidthFromCommandName (Argv[0], 1);
- if ((Width != 1) && (Width != 2) && (Width != 4)) {
- return EFI_INVALID_PARAMETER;
- }
-
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);
- if (File == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Location = AllocatePool (Chunk);
- Size = (Argc > 3) ? AsciiStrHexToUintn (Argv[3]) : EfiTell (File, NULL);
-
- Offset = 0;
- if (Argc > 2) {
- Offset = AsciiStrHexToUintn (Argv[2]);
- if (Offset > 0) {
- // Make sure size includes the part of the file we have skipped
- Size += Offset;
- }
- }
-
- Status = EfiSeek (File, Offset, EfiSeekStart);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- for (; Offset + HEXDUMP_CHUNK <= Size; Offset += Chunk) {
- Chunk = HEXDUMP_CHUNK;
- Status = EfiRead (File, Location, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint ("Error reading file content\n");
- goto Exit;
- }
-
- Status = OutputData (Location, Chunk, Width, File->BaseOffset + Offset);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_END_OF_FILE) {
- Status = EFI_SUCCESS;
- }
- goto Exit;
- }
- }
-
- // Any left over?
- if (Offset < Size) {
- Chunk = Size - Offset;
- Status = EfiRead (File, Location, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint ("Error reading file content\n");
- goto Exit;
- }
-
- Status = OutputData (Location, Chunk, Width, File->BaseOffset + Offset);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_END_OF_FILE) {
- Status = EFI_SUCCESS;
- }
- goto Exit;
- }
- }
-
-Exit:
- EfiClose (File);
-
- FreePool (Location);
-
- return EFI_SUCCESS;
-}
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdTemplate[] =
-{
- {
- "reset",
- " [type]; Reset system. type = [warm] [shutdown] default is cold reset",
- NULL,
- EblResetCmd
- },
- {
- "exit",
- "; Exit EBL",
- NULL,
- EblExitCmd
- },
- {
- "help",
- " [cmd]; Help on cmd or a list of all commands if cmd is ommited",
- NULL,
- EblHelpCmd
- },
- {
- "break",
- "; Generate debugging breakpoint",
- NULL,
- EblBreakPointCmd
- },
- {
- "page",
- " [on|off]]; toggle promting on command output larger than screen",
- NULL,
- EblPageCmd
- },
- {
- "pause",
- " [sec]; Pause for sec[10] seconds. ",
- NULL,
- EblPauseCmd
- },
- {
- "sleep",
- " [sec]; Sleep for sec[10] seconds. ",
- NULL,
- EblSleepCmd
- },
- {
- "hexdump",
- "[.{1|2|4}] filename [Offset] [Size]; dump a file as hex .width",
- NULL,
- EblHexdumpCmd
- }
-};
-
-
-EFI_HANDLE gExternalCmdHandle = NULL;
-
-/**
- Initialize the commands in this in this file
-**/
-VOID
-EblInitializeCmdTable (
- VOID
- )
-{
-
- EblAddCommands (mCmdTemplate, sizeof (mCmdTemplate)/sizeof (EBL_COMMAND_TABLE));
-
- gBS->InstallProtocolInterface (
- &gExternalCmdHandle,
- &gEfiEblAddCommandProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &gEblAddCommand
- );
-
-}
-
-
-VOID
-EblShutdownExternalCmdTable (
- VOID
- )
-{
- gBS->UninstallProtocolInterface (gExternalCmdHandle, &gEfiEblAddCommandProtocolGuid, &gEblAddCommand);
-}
-
-
diff --git a/EmbeddedPkg/Ebl/Dir.c b/EmbeddedPkg/Ebl/Dir.c
deleted file mode 100644
index c45f67b95b..0000000000
--- a/EmbeddedPkg/Ebl/Dir.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/** @file
- Dir 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.
-
- Module Name: CmdTemplate.c
-
- Search/Replace Dir with the name of your new command
-
-**/
-
-#include "Ebl.h"
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gFvFileType[] = {
- "All",
- "Bin",
- "section",
- "SEC",
- "PeiCore",
- "DxeCore",
- "PEIM",
- "Driver",
- "Combo",
- "App",
- "NULL",
- "FV"
-};
-
-
-/**
- Perform a dir on a device. The device must support Simple File System Protocol
- or the FV protocol.
-
- Argv[0] - "dir"
- Argv[1] - Device Name:path. Path is optional
- Argv[2] - Optional filename to match on. A leading * means match substring
- Argv[3] - Optional FV file type
-
- dir fs1:\efi ; perform a dir on fs1: device in the efi directory
- dir fs1:\efi *.efi; perform a dir on fs1: device in the efi directory but
- only print out files that contain the string *.efi
- dir fv1:\ ; perform a dir on fv1: device in the efi directory
- NOTE: fv devices do not contain subdirs
- dir fv1:\ * PEIM ; will match all files of type PEIM
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblDirCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_OPEN_FILE *File;
- EFI_FILE_INFO *DirInfo;
- UINTN ReadSize;
- UINTN CurrentRow;
- CHAR16 *MatchSubString;
- EFI_STATUS GetNextFileStatus;
- UINTN Key;
- EFI_FV_FILETYPE SearchType;
- EFI_FV_FILETYPE Type;
- EFI_FV_FILE_ATTRIBUTES Attributes;
- UINTN Size;
- EFI_GUID NameGuid;
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
- UINT32 AuthenticationStatus;
- VOID *Section;
- UINTN SectionSize;
- EFI_FV_FILETYPE Index;
- UINTN Length;
- UINTN BestMatchCount;
- CHAR16 UnicodeFileName[MAX_CMD_LINE];
- CHAR8 *Path;
- CHAR8 *TypeStr;
- UINTN TotalSize;
-
-
- if (Argc <= 1) {
- Path = EfiGetCwd ();
- if (Path == NULL) {
- return EFI_SUCCESS;
- }
- } else {
- Path = Argv[1];
- }
-
- File = EfiOpen (Path, EFI_FILE_MODE_READ, 0);
- if (File == NULL) {
- return EFI_SUCCESS;
- }
-
- if (File->Type == EfiOpenFirmwareVolume) {
- // FV Dir
-
- SearchType = EFI_FV_FILETYPE_ALL;
- UnicodeFileName[0] = '\0';
- MatchSubString = &UnicodeFileName[0];
- if (Argc > 2) {
- AsciiStrToUnicodeStr (Argv[2], UnicodeFileName);
- if (UnicodeFileName[0] == '*') {
- // Handle *Name substring matching
- MatchSubString = &UnicodeFileName[1];
- }
-
- // Handle file type matchs
- if (Argc > 3) {
- // match a specific file type, always last argument
- Length = AsciiStrLen (Argv[3]);
- for (Index = 1, BestMatchCount = 0; Index < sizeof (gFvFileType)/sizeof (CHAR8 *); Index++) {
- if (AsciiStriCmp (gFvFileType[Index], Argv[3]) == 0) {
- // exact match
- SearchType = Index;
- break;
- }
-
- if (AsciiStrniCmp (Argv[3], gFvFileType[Index], Length) == 0) {
- // partial match, so keep looking to make sure there is only one partial match
- BestMatchCount++;
- SearchType = Index;
- }
- }
-
- if (BestMatchCount > 1) {
- SearchType = EFI_FV_FILETYPE_ALL;
- }
- }
- }
-
- TotalSize = 0;
- Fv = File->Fv;
- Key = 0;
- CurrentRow = 0;
- do {
- Type = SearchType;
- GetNextFileStatus = Fv->GetNextFile (
- Fv,
- &Key,
- &Type,
- &NameGuid,
- &Attributes,
- &Size
- );
- if (!EFI_ERROR (GetNextFileStatus)) {
- TotalSize += Size;
- // Calculate size of entire file
- Section = NULL;
- Size = 0;
- Status = Fv->ReadFile (
- Fv,
- &NameGuid,
- Section,
- &Size,
- &Type,
- &Attributes,
- &AuthenticationStatus
- );
- if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) {
- // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid
- Size = 0;
- }
-
- TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN";
-
- // read the UI seciton to do a name match.
- Section = NULL;
- Status = Fv->ReadSection (
- Fv,
- &NameGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- &Section,
- &SectionSize,
- &AuthenticationStatus
- );
- if (!EFI_ERROR (Status)) {
- if (StrStr (Section, MatchSubString) != NULL) {
- AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- break;
- }
- }
- FreePool (Section);
- } else {
- if (*MatchSubString == '\0') {
- AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid);
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- break;
- }
- }
- }
- }
- } while (!EFI_ERROR (GetNextFileStatus));
-
- if (SearchType == EFI_FV_FILETYPE_ALL) {
- AsciiPrint ("%,20d bytes in files %,d bytes free\n", TotalSize, File->FvSize - File->FvHeaderSize - TotalSize);
- }
-
-
- } else if ((File->Type == EfiOpenFileSystem) || (File->Type == EfiOpenBlockIo)) {
- // Simple File System DIR
-
- if (File->FsFileInfo == NULL) {
- return EFI_SUCCESS;
- }
-
- if (!(File->FsFileInfo->Attribute & EFI_FILE_DIRECTORY)) {
- return EFI_SUCCESS;
- }
-
- // Handle *Name substring matching
- MatchSubString = NULL;
- UnicodeFileName[0] = '\0';
- if (Argc > 2) {
- AsciiStrToUnicodeStr (Argv[2], UnicodeFileName);
- if (UnicodeFileName[0] == '*') {
- MatchSubString = &UnicodeFileName[1];
- }
- }
-
- File->FsFileHandle->SetPosition (File->FsFileHandle, 0);
- for (CurrentRow = 0;;) {
- // First read gets the size
- DirInfo = NULL;
- ReadSize = 0;
- Status = File->FsFileHandle->Read (File->FsFileHandle, &ReadSize, DirInfo);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- // Allocate the buffer for the real read
- DirInfo = AllocatePool (ReadSize);
- if (DirInfo == NULL) {
- goto Done;
- }
-
- // Read the data
- Status = File->FsFileHandle->Read (File->FsFileHandle, &ReadSize, DirInfo);
- if ((EFI_ERROR (Status)) || (ReadSize == 0)) {
- break;
- }
- } else {
- break;
- }
-
- if (MatchSubString != NULL) {
- if (StrStr (&DirInfo->FileName[0], MatchSubString) == NULL) {
- // does not match *name argument, so skip
- continue;
- }
- } else if (UnicodeFileName[0] != '\0') {
- // is not an exact match for name argument, so skip
- if (StrCmp (&DirInfo->FileName[0], UnicodeFileName) != 0) {
- continue;
- }
- }
-
- if (DirInfo->Attribute & EFI_FILE_DIRECTORY) {
- AsciiPrint (" <DIR> %s\n", &DirInfo->FileName[0]);
- } else {
- AsciiPrint ("%,14ld %s\n", DirInfo->FileSize, &DirInfo->FileName[0]);
- }
-
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- break;
- }
-
- FreePool (DirInfo);
- }
-
-Done:
- if (DirInfo != NULL) {
- FreePool (DirInfo);
- }
- }
-
- EfiClose (File);
-
- return EFI_SUCCESS;
-}
-
-/**
- Change the Current Working Directory
-
- Argv[0] - "cd"
- Argv[1] - Device Name:path. Path is optional
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblCdCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- if (Argc <= 1) {
- return EFI_SUCCESS;
- }
-
- return EfiSetCwd (Argv[1]);
-}
-
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDirTemplate[] =
-{
- {
- "dir",
- " dirdev [*match]; directory listing of dirdev. opt match a substring",
- NULL,
- EblDirCmd
- },
- {
- "cd",
- " device - set the current working directory",
- NULL,
- EblCdCmd
- }
-};
-
-
-/**
- Initialize the commands in this in this file
-**/
-VOID
-EblInitializeDirCmd (
- VOID
- )
-{
- if (FeaturePcdGet (PcdEmbeddedDirCmd)) {
- EblAddCommands (mCmdDirTemplate, sizeof (mCmdDirTemplate)/sizeof (EBL_COMMAND_TABLE));
- }
-}
-
diff --git a/EmbeddedPkg/Ebl/Ebl.h b/EmbeddedPkg/Ebl/Ebl.h
deleted file mode 100644
index c2242df9e0..0000000000
--- a/EmbeddedPkg/Ebl/Ebl.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/** @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
-
diff --git a/EmbeddedPkg/Ebl/Ebl.inf b/EmbeddedPkg/Ebl/Ebl.inf
deleted file mode 100644
index 91a82d9f8c..0000000000
--- a/EmbeddedPkg/Ebl/Ebl.inf
+++ /dev/null
@@ -1,111 +0,0 @@
-#/** @file
-# EBL Applicaiton
-#
-# This is a shell application that will display Hello World.
-# 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]
- INF_VERSION = 0x00010005
- BASE_NAME = Ebl
- FILE_GUID = 3CEF354A-3B7A-4519-AD70-72A134698311
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- ENTRY_POINT = EdkBootLoaderEntry
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-[Sources.common]
- Main.c
- Command.c
- EfiDevice.c
- HwDebug.c
- HwIoDebug.c
- Dir.c
- Hob.c
- Script.c
- Ebl.h
- Network.c
- Variable.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- DebugLib
- UefiLib
- UefiApplicationEntryPoint
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- BaseMemoryLib
- MemoryAllocationLib
- DevicePathLib
- IoLib
- PrintLib
- PcdLib
- EfiFileLib
- HobLib
- BaseLib
- EblCmdLib
- EblNetworkLib
-
-[LibraryClasses.ARM]
- SemihostLib
-
-[Protocols.common]
- gEfiFirmwareVolume2ProtocolGuid
- gEfiFirmwareVolumeBlockProtocolGuid
- gEfiBlockIoProtocolGuid
- gEfiSimpleFileSystemProtocolGuid
- gEfiLoadFileProtocolGuid
- gEfiLoadedImageProtocolGuid
- gEfiPxeBaseCodeProtocolGuid
- gEfiEblAddCommandProtocolGuid
- gEfiDiskIoProtocolGuid
- gEfiPciIoProtocolGuid
- gEfiSimpleNetworkProtocolGuid
-
-[Guids.common]
- gEfiDxeServicesTableGuid
- gEfiFileInfoGuid
- gEfiHobMemoryAllocModuleGuid
- gEfiMemoryTypeInformationGuid
-
-[FeaturePcd.common]
- gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot
- gEmbeddedTokenSpaceGuid.PcdEmbeddedDirCmd
- gEmbeddedTokenSpaceGuid.PcdEmbeddedHobCmd
- gEmbeddedTokenSpaceGuid.PcdEmbeddedHwDebugCmd
- gEmbeddedTokenSpaceGuid.PcdEmbeddedIoEnable
- gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPciDebugCmd
- gEmbeddedTokenSpaceGuid.PcdEmbeddedProbeRemovable
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand
- gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor
- gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize
- gEmbeddedTokenSpaceGuid.PcdEmbeddedShellCharacterEcho
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt
-
diff --git a/EmbeddedPkg/Ebl/EfiDevice.c b/EmbeddedPkg/Ebl/EfiDevice.c
deleted file mode 100644
index 7d2060936d..0000000000
--- a/EmbeddedPkg/Ebl/EfiDevice.c
+++ /dev/null
@@ -1,1050 +0,0 @@
-/** @file
- EBL commands for EFI and PI Devices
-
- 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.
-
-**/
-
-#include "Ebl.h"
-
-
-EFI_DXE_SERVICES *gDS = NULL;
-
-
-/**
- Print information about the File System device.
-
- @param File Open File for the device
-
-**/
-VOID
-EblPrintFsInfo (
- IN EFI_OPEN_FILE *File
- )
-{
- CHAR16 *Str;
-
- if (File == NULL) {
- return;
- }
-
- AsciiPrint (" %a: ", File->DeviceName);
- if (File->FsInfo != NULL) {
- for (Str = File->FsInfo->VolumeLabel; *Str != '\0'; Str++) {
- if (*Str == ' ') {
- // UI makes you enter _ for space, so make the printout match that
- *Str = '_';
- }
- AsciiPrint ("%c", *Str);
- }
- AsciiPrint (":");
- if (File->FsInfo->ReadOnly) {
- AsciiPrint ("ReadOnly");
- }
- }
-
- AsciiPrint ("\n");
- EfiClose (File);
-}
-
-
-/**
- Print information about the FV devices.
-
- @param File Open File for the device
-
-**/
-VOID
-EblPrintFvbInfo (
- IN EFI_OPEN_FILE *File
- )
-{
- if (File == NULL) {
- return;
- }
-
- AsciiPrint (" %a: 0x%08lx - 0x%08lx : 0x%08x\n", File->DeviceName, File->FvStart, File->FvStart + File->FvSize - 1, File->FvSize);
- EfiClose (File);
-}
-
-
-/**
- Print information about the Blk IO devices.
- If the device supports PXE dump out extra information
-
- @param File Open File for the device
-
-**/
-VOID
-EblPrintBlkIoInfo (
- IN EFI_OPEN_FILE *File
- )
-{
- UINT64 DeviceSize;
- UINTN Index;
- UINTN Max;
- EFI_OPEN_FILE *FsFile;
-
- if (File == NULL) {
- return;
- }
-
- AsciiPrint (" %a: ", File->DeviceName);
-
- // print out name of file system, if any, on this block device
- Max = EfiGetDeviceCounts (EfiOpenFileSystem);
- if (Max != 0) {
- for (Index = 0; Index < Max; Index++) {
- FsFile = EfiDeviceOpenByType (EfiOpenFileSystem, Index);
- if (FsFile != NULL) {
- if (FsFile->EfiHandle == File->EfiHandle) {
- AsciiPrint ("fs%d: ", Index);
- EfiClose (FsFile);
- break;
- }
- EfiClose (FsFile);
- }
- }
- }
-
- // Print out useful Block IO media properties
- if (File->FsBlockIoMedia->RemovableMedia) {
- AsciiPrint ("Removable ");
- }
- if (!File->FsBlockIoMedia->MediaPresent) {
- AsciiPrint ("No Media\n");
- } else {
- if (File->FsBlockIoMedia->LogicalPartition) {
- AsciiPrint ("Partition ");
- }
- DeviceSize = MultU64x32 (File->FsBlockIoMedia->LastBlock + 1, File->FsBlockIoMedia->BlockSize);
- AsciiPrint ("Size = 0x%lX\n", DeviceSize);
- }
- EfiClose (File);
-}
-
- /**
- Print information about the Load File devices.
- If the device supports PXE dump out extra information
-
- @param File Open File for the device
-
-**/
-VOID
-EblPrintLoadFileInfo (
- IN EFI_OPEN_FILE *File
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
- MAC_ADDR_DEVICE_PATH *MacAddr;
- UINTN HwAddressSize;
- UINTN Index;
-
- if (File == NULL) {
- return;
- }
-
- AsciiPrint (" %a: %a ", File->DeviceName, EblLoadFileBootTypeString (File->EfiHandle));
-
- if (File->DevicePath != NULL) {
- // Try to print out the MAC address
- for (DevicePathNode = File->DevicePath;
- !IsDevicePathEnd (DevicePathNode);
- DevicePathNode = NextDevicePathNode (DevicePathNode)) {
-
- if ((DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (DevicePathNode) == MSG_MAC_ADDR_DP)) {
- MacAddr = (MAC_ADDR_DEVICE_PATH *)DevicePathNode;
-
- HwAddressSize = sizeof (EFI_MAC_ADDRESS);
- if (MacAddr->IfType == 0x01 || MacAddr->IfType == 0x00) {
- HwAddressSize = 6;
- }
-
- AsciiPrint ("MAC ");
- for (Index = 0; Index < HwAddressSize; Index++) {
- AsciiPrint ("%02x", MacAddr->MacAddress.Addr[Index] & 0xff);
- }
- }
- }
- }
-
- AsciiPrint ("\n");
- EfiClose (File);
- return;
-}
-
-
-
-/**
- Dump information about devices in the system.
-
- fv: PI Firmware Volume
- fs: EFI Simple File System
- blk: EFI Block IO
- LoadFile: EFI Load File Protocol (commonly PXE network boot)
-
- Argv[0] - "device"
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblDeviceCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Index;
- UINTN CurrentRow;
- UINTN Max;
-
- CurrentRow = 0;
-
- // Need to call here to make sure Device Counts are valid
- EblUpdateDeviceLists ();
-
- // Now we can print out the info...
- Max = EfiGetDeviceCounts (EfiOpenFirmwareVolume);
- if (Max != 0) {
- AsciiPrint ("Firmware Volume Devices:\n");
- for (Index = 0; Index < Max; Index++) {
- EblPrintFvbInfo (EfiDeviceOpenByType (EfiOpenFirmwareVolume, Index));
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {
- break;
- }
- }
- }
-
- Max = EfiGetDeviceCounts (EfiOpenFileSystem);
- if (Max != 0) {
- AsciiPrint ("File System Devices:\n");
- for (Index = 0; Index < Max; Index++) {
- EblPrintFsInfo (EfiDeviceOpenByType (EfiOpenFileSystem, Index));
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {
- break;
- }
- }
- }
-
- Max = EfiGetDeviceCounts (EfiOpenBlockIo);
- if (Max != 0) {
- AsciiPrint ("Block IO Devices:\n");
- for (Index = 0; Index < Max; Index++) {
- EblPrintBlkIoInfo (EfiDeviceOpenByType (EfiOpenBlockIo, Index));
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {
- break;
- }
- }
- }
-
- Max = EfiGetDeviceCounts (EfiOpenLoadFile);
- if (Max != 0) {
- AsciiPrint ("LoadFile Devices: (usually network)\n");
- for (Index = 0; Index < Max; Index++) {
- EblPrintLoadFileInfo (EfiDeviceOpenByType (EfiOpenLoadFile, Index));
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {
- break;
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Start an EFI image (PE32+ with EFI defined entry point).
-
- Argv[0] - "start"
- Argv[1] - device name and path
- Argv[2] - "" string to pass into image being started
-
- start fs1:\Temp\Fv.Fv "arg to pass" ; load an FV from the disk and pass the
- ; ascii string arg to pass to the image
- start fv0:\FV ; load an FV from an FV (not common)
- start LoadFile0: ; load an FV via a PXE boot
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblStartCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_OPEN_FILE *File;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE ImageHandle;
- UINTN ExitDataSize;
- CHAR16 *ExitData;
- VOID *Buffer;
- UINTN BufferSize;
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
-
- ImageHandle = NULL;
-
- if (Argc < 2) {
- return EFI_INVALID_PARAMETER;
- }
-
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);
- if (File == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- DevicePath = File->DevicePath;
- if (DevicePath != NULL) {
- // check for device path form: blk, fv, fs, and loadfile
- Status = gBS->LoadImage (FALSE, gImageHandle, DevicePath, NULL, 0, &ImageHandle);
- } else {
- // Check for buffer form: A0x12345678:0x1234 syntax.
- // Means load using buffer starting at 0x12345678 of size 0x1234.
-
- Status = EfiReadAllocatePool (File, &Buffer, &BufferSize);
- if (EFI_ERROR (Status)) {
- EfiClose (File);
- return Status;
- }
- Status = gBS->LoadImage (FALSE, gImageHandle, DevicePath, Buffer, BufferSize, &ImageHandle);
-
- FreePool (Buffer);
- }
-
- EfiClose (File);
-
- if (!EFI_ERROR (Status)) {
- if (Argc >= 3) {
- // Argv[2] is a "" string that we pass directly to the EFI application without the ""
- // We don't pass Argv[0] to the EFI Application (it's name) just the args
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);
- ASSERT_EFI_ERROR (Status);
-
- ImageInfo->LoadOptionsSize = (UINT32)AsciiStrSize (Argv[2]);
- ImageInfo->LoadOptions = AllocatePool (ImageInfo->LoadOptionsSize);
- AsciiStrCpy (ImageInfo->LoadOptions, Argv[2]);
- }
-
- // Transfer control to the EFI image we loaded with LoadImage()
- Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);
- }
-
- return Status;
-}
-
-
-/**
- Load a Firmware Volume (FV) into memory from a device. This causes drivers in
- the FV to be dispatched if the dependencies of the drivers are met.
-
- Argv[0] - "loadfv"
- Argv[1] - device name and path
-
- loadfv fs1:\Temp\Fv.Fv ; load an FV from the disk
- loadfv fv0:\FV ; load an FV from an FV (not common)
- loadfv LoadFile0: ; load an FV via a PXE boot
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblLoadFvCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_OPEN_FILE *File;
- VOID *FvStart;
- UINTN FvSize;
- EFI_HANDLE FvHandle;
-
-
- if (Argc < 2) {
- return EFI_INVALID_PARAMETER;
- }
-
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);
- if (File == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (File->Type == EfiOpenMemoryBuffer) {
- // If it is a address just use it.
- Status = gDS->ProcessFirmwareVolume (File->Buffer, File->Size, &FvHandle);
- } else {
- // If it is a file read it into memory and use it
- Status = EfiReadAllocatePool (File, &FvStart, &FvSize);
- EfiClose (File);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gDS->ProcessFirmwareVolume (FvStart, FvSize, &FvHandle);
- if (EFI_ERROR (Status)) {
- FreePool (FvStart);
- }
- }
- return Status;
-}
-
-
-/**
- Perform an EFI connect to connect devices that follow the EFI driver model.
- If it is a PI system also call the dispatcher in case a new FV was made
- available by one of the connect EFI drivers (this is not a common case).
-
- Argv[0] - "connect"
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblConnectCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- BOOLEAN Dispatch;
- EFI_OPEN_FILE *File;
-
-
- if (Argc > 1) {
- if ((*Argv[1] == 'd') || (*Argv[1] == 'D')) {
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (Index = 0; Index < HandleCount; Index++) {
- gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
- }
-
- //
- // Given we disconnect our console we should go and do a connect now
- //
- } else {
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);
- if (File != NULL) {
- AsciiPrint ("Connecting %a\n", Argv[1]);
- gBS->ConnectController (File->EfiHandle, NULL, NULL, TRUE);
- EfiClose (File);
- return EFI_SUCCESS;
- }
- }
- }
-
- Dispatch = FALSE;
- do {
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (Index = 0; Index < HandleCount; Index++) {
- gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
- }
-
- FreePool (HandleBuffer);
-
- //
- // Check to see if it's possible to dispatch an more DXE drivers.
- // The BdsLibConnectAllEfi () may have made new DXE drivers show up.
- // If anything is Dispatched Status == EFI_SUCCESS and we will try
- // the connect again.
- //
- if (gDS == NULL) {
- Status = EFI_NOT_FOUND;
- } else {
- Status = gDS->Dispatch ();
- if (!EFI_ERROR (Status)) {
- Dispatch = TRUE;
- }
- }
-
- } while (!EFI_ERROR (Status));
-
- if (Dispatch) {
- AsciiPrint ("Connected and dispatched\n");
- } else {
- AsciiPrint ("Connect\n");
- }
-
- return EFI_SUCCESS;
-}
-
-
-
-CHAR8 *gMemMapType[] = {
- "reserved ",
- "LoaderCode",
- "LoaderData",
- "BS_code ",
- "BS_data ",
- "RT_code ",
- "RT_data ",
- "available ",
- "Unusable ",
- "ACPI_recl ",
- "ACPI_NVS ",
- "MemMapIO ",
- "MemPortIO ",
- "PAL_code "
-};
-
-
-/**
- Dump out the EFI memory map
-
- Argv[0] - "memmap"
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblMemMapCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_MEMORY_DESCRIPTOR *MemMap;
- EFI_MEMORY_DESCRIPTOR *OrigMemMap;
- UINTN MemMapSize;
- UINTN MapKey;
- UINTN DescriptorSize;
- UINT32 DescriptorVersion;
- UINT64 PageCount[EfiMaxMemoryType];
- UINTN Index;
- UINT64 EntrySize;
- UINTN CurrentRow;
- UINT64 TotalMemory;
-
- ZeroMem (PageCount, sizeof (PageCount));
-
- AsciiPrint ("EFI Memory Map\n");
-
- // First call is to figure out how big the buffer needs to be
- MemMapSize = 0;
- MemMap = NULL;
- Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- // In case the AllocatPool changes the memory map we added in some extra descriptors
- MemMapSize += (DescriptorSize * 0x100);
- OrigMemMap = MemMap = AllocatePool (MemMapSize);
- if (OrigMemMap != NULL) {
- // 2nd time we get the data
- Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion);
- if (!EFI_ERROR (Status)) {
- for (Index = 0, CurrentRow = 0; Index < MemMapSize/DescriptorSize; Index++) {
- EntrySize = LShiftU64 (MemMap->NumberOfPages, 12);
- AsciiPrint ("\n%a %016lx - %016lx: # %08lx %016lx", gMemMapType[MemMap->Type % EfiMaxMemoryType], MemMap->PhysicalStart, MemMap->PhysicalStart + EntrySize -1, MemMap->NumberOfPages, MemMap->Attribute);
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {
- break;
- }
-
- PageCount[MemMap->Type % EfiMaxMemoryType] += MemMap->NumberOfPages;
- MemMap = NEXT_MEMORY_DESCRIPTOR (MemMap, DescriptorSize);
- }
- }
-
- for (Index = 0, TotalMemory = 0; Index < EfiMaxMemoryType; Index++) {
- if (PageCount[Index] != 0) {
- AsciiPrint ("\n %a %,7ld Pages (%,14ld)", gMemMapType[Index], PageCount[Index], LShiftU64 (PageCount[Index], 12));
- if (Index == EfiLoaderCode ||
- Index == EfiLoaderData ||
- Index == EfiBootServicesCode ||
- Index == EfiBootServicesData ||
- Index == EfiRuntimeServicesCode ||
- Index == EfiRuntimeServicesData ||
- Index == EfiConventionalMemory ||
- Index == EfiACPIReclaimMemory ||
- Index == EfiACPIMemoryNVS ||
- Index == EfiPalCode
- ) {
- // Count total memory
- TotalMemory += PageCount[Index];
- }
- }
- }
-
- AsciiPrint ("\nTotal Memory: %,ld MB (%,ld bytes)\n", RShiftU64 (TotalMemory, 8), LShiftU64 (TotalMemory, 12));
-
- FreePool (OrigMemMap);
-
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-
-
-/**
- Load a file into memory and optionally jump to it. A load address can be
- specified or automatically allocated. A quoted command line can optionally
- be passed into the image.
-
- Argv[0] - "go"
- Argv[1] - Device Name:path for the file to load
- Argv[2] - Address to load to or '*' if the load address will be allocated
- Argv[3] - Optional Entry point to the image. Image will be called if present
- Argv[4] - "" string that will be passed as Argc & Argv to EntryPoint. Needs
- to include the command name
-
- go fv1:\EblCmdX 0x10000 0x10010 "EblCmdX Arg2 Arg3 Arg4"; - load EblCmdX
- from FV1 to location 0x10000 and call the entry point at 0x10010 passing
- in "EblCmdX Arg2 Arg3 Arg4" as the arguments.
-
- go fv0:\EblCmdX * 0x10 "EblCmdX Arg2 Arg3 Arg4"; - load EblCmdX from FS0
- to location allocated by this command and call the entry point at offset 0x10
- passing in "EblCmdX Arg2 Arg3 Arg4" as the arguments.
-
- go fv1:\EblCmdX 0x10000; Load EblCmdX to address 0x10000 and return
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblGoCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_OPEN_FILE *File;
- VOID *Address;
- UINTN Size;
- EBL_COMMMAND EntryPoint;
- UINTN EntryPointArgc;
- CHAR8 *EntryPointArgv[MAX_ARGS];
-
-
- if (Argc <= 2) {
- // device name and laod address are required
- return EFI_SUCCESS;
- }
-
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);
- if (File == NULL) {
- AsciiPrint (" %a is not a valid path\n", Argv[1]);
- return EFI_SUCCESS;
- }
-
- EntryPoint = (EBL_COMMMAND)((Argc > 3) ? (UINTN)AsciiStrHexToUintn (Argv[3]) : (UINTN)NULL);
- if (Argv[2][0] == '*') {
- // * Means allocate the buffer
- Status = EfiReadAllocatePool (File, &Address, &Size);
-
- // EntryPoint is relative to the start of the image
- EntryPoint = (EBL_COMMMAND)((UINTN)EntryPoint + (UINTN)Address);
-
- } else {
- Address = (VOID *)AsciiStrHexToUintn (Argv[2]);
- Size = File->Size;
-
- // File->Size for LoadFile is lazy so we need to use the tell to figure it out
- EfiTell (File, NULL);
- Status = EfiRead (File, Address, &Size);
- }
-
- if (!EFI_ERROR (Status)) {
- AsciiPrint ("Loaded %,d bytes to 0x%08x\n", Size, Address);
-
- if (Argc > 3) {
- if (Argc > 4) {
- ParseArguments (Argv[4], &EntryPointArgc, EntryPointArgv);
- } else {
- EntryPointArgc = 1;
- EntryPointArgv[0] = File->FileName;
- }
-
- Status = EntryPoint (EntryPointArgc, EntryPointArgv);
- }
- }
-
- EfiClose (File);
- return Status;
-}
-
-#define FILE_COPY_CHUNK 0x20000
-
-EFI_STATUS
-EblFileCopyCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_OPEN_FILE *Source = NULL;
- EFI_OPEN_FILE *Destination = NULL;
- EFI_STATUS Status = EFI_SUCCESS;
- VOID *Buffer = NULL;
- UINTN Size;
- UINTN Offset;
- UINTN Chunk = FILE_COPY_CHUNK;
- UINTN FileNameLen;
- CHAR8* DestFileName;
- CHAR8* SrcFileName;
- CHAR8* SrcPtr;
-
- if (Argc < 3) {
- return EFI_INVALID_PARAMETER;
- }
-
- DestFileName = Argv[2];
- FileNameLen = AsciiStrLen (DestFileName);
-
- // Check if the destination file name looks like a directory
- if ((DestFileName[FileNameLen-1] == '\\') || (DestFileName[FileNameLen-1] == ':')) {
- // Set the pointer after the source drive (eg: after fs1:)
- SrcPtr = AsciiStrStr (Argv[1], ":");
- if (SrcPtr == NULL) {
- SrcPtr = Argv[1];
- } else {
- SrcPtr++;
- if (*SrcPtr == '\\') {
- SrcPtr++;
- }
- }
-
- if (*SrcPtr == '\0') {
- AsciiPrint("Source file incorrect.\n");
- }
-
- // Skip the Source Directories
- while (1) {
- SrcFileName = SrcPtr;
- SrcPtr = AsciiStrStr (SrcPtr,"\\");
- if (SrcPtr != NULL) {
- SrcPtr++;
- } else {
- break;
- }
- }
-
- if (*SrcFileName == '\0') {
- AsciiPrint("Source file incorrect (Error 2).\n");
- }
-
- // Construct the destination filepath
- DestFileName = (CHAR8*)AllocatePool (FileNameLen + AsciiStrLen (SrcFileName) + 1);
- AsciiStrCpy (DestFileName, Argv[2]);
- AsciiStrCat (DestFileName, SrcFileName);
- }
-
- Source = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);
- if (Source == NULL) {
- AsciiPrint("Source file open error.\n");
- return EFI_NOT_FOUND;
- }
-
- Destination = EfiOpen(DestFileName, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
- if (Destination == NULL) {
- AsciiPrint("Destination file open error.\n");
- return EFI_NOT_FOUND;
- }
-
- Buffer = AllocatePool(FILE_COPY_CHUNK);
- if (Buffer == NULL) {
- goto Exit;
- }
-
- Size = EfiTell(Source, NULL);
-
- for (Offset = 0; Offset + FILE_COPY_CHUNK <= Size; Offset += Chunk) {
- Chunk = FILE_COPY_CHUNK;
-
- Status = EfiRead(Source, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Read file error %r\n", Status);
- goto Exit;
- }
-
- Status = EfiWrite(Destination, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Write file error %r\n", Status);
- goto Exit;
- }
- }
-
- // Any left over?
- if (Offset < Size) {
- Chunk = Size - Offset;
-
- Status = EfiRead(Source, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Read file error %r\n", Status);
- goto Exit;
- }
-
- Status = EfiWrite(Destination, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Write file error %r\n", Status);
- goto Exit;
- }
- }
-
-
-Exit:
- if (Source != NULL) {
- Status = EfiClose(Source);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Source close error %r\n", Status);
- }
- }
- if (Destination != NULL) {
- Status = EfiClose(Destination);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Destination close error %r\n", Status);
- }
-
- // Case when we have concated the filename to the destination directory
- if (DestFileName != Argv[2]) {
- FreePool (DestFileName);
- }
- }
-
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EblFileDiffCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_OPEN_FILE *File1 = NULL;
- EFI_OPEN_FILE *File2 = NULL;
- EFI_STATUS Status = EFI_SUCCESS;
- VOID *Buffer1 = NULL;
- VOID *Buffer2 = NULL;
- UINTN Size1;
- UINTN Size2;
- UINTN Offset;
- UINTN Chunk = FILE_COPY_CHUNK;
-
- if (Argc != 3) {
- return EFI_INVALID_PARAMETER;
- }
-
- File1 = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);
- if (File1 == NULL) {
- AsciiPrint("File 1 open error.\n");
- return EFI_NOT_FOUND;
- }
-
- File2 = EfiOpen(Argv[2], EFI_FILE_MODE_READ, 0);
- if (File2 == NULL) {
- AsciiPrint("File 2 open error.\n");
- return EFI_NOT_FOUND;
- }
-
- Size1 = EfiTell(File1, NULL);
- Size2 = EfiTell(File2, NULL);
-
- if (Size1 != Size2) {
- AsciiPrint("Files differ.\n");
- goto Exit;
- }
-
- Buffer1 = AllocatePool(FILE_COPY_CHUNK);
- if (Buffer1 == NULL) {
- goto Exit;
- }
-
- Buffer2 = AllocatePool(FILE_COPY_CHUNK);
- if (Buffer2 == NULL) {
- goto Exit;
- }
-
- for (Offset = 0; Offset + FILE_COPY_CHUNK <= Size1; Offset += Chunk) {
- Chunk = FILE_COPY_CHUNK;
-
- Status = EfiRead(File1, Buffer1, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("File 1 read error\n");
- goto Exit;
- }
-
- Status = EfiRead(File2, Buffer2, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("File 2 read error\n");
- goto Exit;
- }
-
- if (CompareMem(Buffer1, Buffer2, Chunk) != 0) {
- AsciiPrint("Files differ.\n");
- goto Exit;
- };
- }
-
- // Any left over?
- if (Offset < Size1) {
- Chunk = Size1 - Offset;
-
- Status = EfiRead(File1, Buffer1, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("File 1 read error\n");
- goto Exit;
- }
-
- Status = EfiRead(File2, Buffer2, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("File 2 read error\n");
- goto Exit;
- }
- }
-
- if (CompareMem(Buffer1, Buffer2, Chunk) != 0) {
- AsciiPrint("Files differ.\n");
- } else {
- AsciiPrint("Files are identical.\n");
- }
-
-Exit:
- if (File1 != NULL) {
- Status = EfiClose(File1);
- if (EFI_ERROR(Status)) {
- AsciiPrint("File 1 close error %r\n", Status);
- }
- }
-
- if (File2 != NULL) {
- Status = EfiClose(File2);
- if (EFI_ERROR(Status)) {
- AsciiPrint("File 2 close error %r\n", Status);
- }
- }
-
- if (Buffer1 != NULL) {
- FreePool(Buffer1);
- }
-
- if (Buffer2 != NULL) {
- FreePool(Buffer2);
- }
-
- return Status;
-}
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDeviceTemplate[] =
-{
- {
- "connect",
- "[d]; Connect all EFI devices. d means disconnect",
- NULL,
- EblConnectCmd
- },
- {
- "device",
- "; Show information about boot devices",
- NULL,
- EblDeviceCmd
- },
- {
- "go",
- " dev:path loadaddress entrypoint args; load to given address and jump in",
- NULL,
- EblGoCmd
- },
- {
- "loadfv",
- " devname; Load PI FV from device",
- NULL,
- EblLoadFvCmd
- },
- {
- "start",
- " path; EFI Boot Device:filepath. fs1:\\EFI\\BOOT.EFI",
- NULL,
- EblStartCmd
- },
- {
- "memmap",
- "; dump EFI memory map",
- NULL,
- EblMemMapCmd
- },
- {
- "cp",
- " file1 file2; copy file only.",
- NULL,
- EblFileCopyCmd
- },
- {
- "diff",
- " file1 file2; compare files",
- NULL,
- EblFileDiffCmd
- }
-};
-
-
-/**
- Initialize the commands in this in this file
-**/
-
-VOID
-EblInitializeDeviceCmd (
- VOID
- )
-{
- EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
- EblAddCommands (mCmdDeviceTemplate, sizeof (mCmdDeviceTemplate)/sizeof (EBL_COMMAND_TABLE));
-}
-
diff --git a/EmbeddedPkg/Ebl/Hob.c b/EmbeddedPkg/Ebl/Hob.c
deleted file mode 100644
index 8b7a52e139..0000000000
--- a/EmbeddedPkg/Ebl/Hob.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/** @file
- Hob command 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.
-
- Module Name: Hob.c
-
- Search/Replace Dir with the name of your new command
-
- Boot Mode:
- ==========
- BOOT_WITH_FULL_CONFIGURATION 0x00
- BOOT_WITH_MINIMAL_CONFIGURATION 0x01
- BOOT_ASSUMING_NO_CONFIGURATION_CHANGES 0x02
- BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03
- BOOT_WITH_DEFAULT_SETTINGS 0x04
- BOOT_ON_S4_RESUME 0x05
- BOOT_ON_S5_RESUME 0x06
- BOOT_ON_S2_RESUME 0x10
- BOOT_ON_S3_RESUME 0x11
- BOOT_ON_FLASH_UPDATE 0x12
- BOOT_IN_RECOVERY_MODE 0x20
- BOOT_IN_RECOVERY_MODE_MASK 0x40
- BOOT_SPECIAL_MASK 0x80
-
- Mem Alloc HOB Type:
- ===================
- typedef enum {
- EfiReservedMemoryType = 0x00
- EfiLoaderCode = 0x01
- EfiLoaderData = 0x02
- EfiBootServicesCode = 0x03
- EfiBootServicesData = 0x04
- EfiRuntimeServicesCode = 0x05
- EfiRuntimeServicesData = 0x06
- EfiConventionalMemory = 0x07
- EfiUnusableMemory = 0x08
- EfiACPIReclaimMemory = 0x09
- EfiACPIMemoryNVS = 0x0a
- EfiMemoryMappedIO = 0x0b
- EfiMemoryMappedIOPortSpace = 0x0c
- EfiPalCode = 0x0d
- EfiMaxMemoryType = 0x0e
- } EFI_MEMORY_TYPE;
-
- Resource Hob Tye:
- =================
- EFI_RESOURCE_SYSTEM_MEMORY 0
- EFI_RESOURCE_MEMORY_MAPPED_IO 1
- EFI_RESOURCE_IO 2
- EFI_RESOURCE_FIRMWARE_DEVICE 3
- EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 4
- EFI_RESOURCE_MEMORY_RESERVED 5
- EFI_RESOURCE_IO_RESERVED 6
- EFI_RESOURCE_MAX_MEMORY_TYPE 7
-
- Resource Hob Attribute (last thing printed):
- ============================================
- EFI_RESOURCE_ATTRIBUTE_PRESENT 0x00000001
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED 0x00000002
- EFI_RESOURCE_ATTRIBUTE_TESTED 0x00000004
- EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC 0x00000008
- EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC 0x00000010
- EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_1 0x00000020
- EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_2 0x00000040
- EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED 0x00000080
- EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED 0x00000100
- EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED 0x00000200
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE 0x00000400
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE 0x00000800
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE 0x00001000
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE 0x00002000
- EFI_RESOURCE_ATTRIBUTE_16_BIT_IO 0x00004000
- EFI_RESOURCE_ATTRIBUTE_32_BIT_IO 0x00008000
- EFI_RESOURCE_ATTRIBUTE_64_BIT_IO 0x00010000
- EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED 0x00020000
-
-**/
-
-#include "Ebl.h"
-// BugBug: Autogen does not allow this to be included currently
-//#include <EdkModulePkg/Include/EdkDxe.h>
-
-GLOBAL_REMOVE_IF_UNREFERENCED char *mHobResourceType[] = {
- "Memory ",
- "MMIO ",
- "IO ",
- "Firmware ",
- "MMIO Port ",
- "Reserved ",
- "IO Reserved",
- "Illegal "
-};
-
-
-/**
- Dump out the HOBs in the system. HOBs are defined in the PI specification
- and they are used to hand off information from PEI to DXE.
-
- Argv[0] - "hob"
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblHobCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN CurrentRow;
- EFI_PEI_HOB_POINTERS Hob;
- EFI_MEMORY_TYPE_INFORMATION *EfiMemoryTypeInformation;
- UINTN Index;
-
- CurrentRow = 0;
- for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
- if (Hob.Header->HobType == EFI_HOB_TYPE_HANDOFF) {
- AsciiPrint ("PHIT HOB Ver %x Boot Mode %02x Top %lx Bottom %lx\n",
- Hob.HandoffInformationTable->Version,
- Hob.HandoffInformationTable->BootMode,
- Hob.HandoffInformationTable->EfiMemoryTop,
- Hob.HandoffInformationTable->EfiMemoryBottom
- );
-
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- return EFI_SUCCESS;
- }
-
- AsciiPrint (" Free Top %lx Free Bottom %lx End Of HOB %lx\n",
- Hob.HandoffInformationTable->EfiFreeMemoryTop,
- Hob.HandoffInformationTable->EfiFreeMemoryBottom,
- Hob.HandoffInformationTable->EfiEndOfHobList
- );
-
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
- // mod(%) on array index is just to prevent buffer overrun
- AsciiPrint ("Mem Alloc HOB %a %g %08lx:%lx\n",
- (Hob.MemoryAllocation->AllocDescriptor.MemoryType < EfiMaxMemoryType) ? gMemMapType[Hob.MemoryAllocation->AllocDescriptor.MemoryType] : "ILLEGAL TYPE",
- &Hob.MemoryAllocation->AllocDescriptor.Name,
- Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress,
- Hob.MemoryAllocation->AllocDescriptor.MemoryLength
- );
- if (CompareGuid (&gEfiHobMemoryAllocModuleGuid, &Hob.MemoryAllocation->AllocDescriptor.Name)) {
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- return EFI_SUCCESS;
- }
- AsciiPrint (" Module Name %g EntryPoint %lx\n", &Hob.MemoryAllocationModule->ModuleName, Hob.MemoryAllocationModule->EntryPoint);
- }
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
- AsciiPrint ("Resource HOB %a %g %08lx:%lx\n Attributes: %08x\n",
- (Hob.ResourceDescriptor->ResourceType < EFI_RESOURCE_MAX_MEMORY_TYPE) ? mHobResourceType[Hob.ResourceDescriptor->ResourceType] : mHobResourceType[EFI_RESOURCE_MAX_MEMORY_TYPE],
- &Hob.ResourceDescriptor->Owner,
- Hob.ResourceDescriptor->PhysicalStart,
- Hob.ResourceDescriptor->ResourceLength,
- Hob.ResourceDescriptor->ResourceAttribute
- );
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- return EFI_SUCCESS;
- }
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
- AsciiPrint ("GUID HOB %g\n", &Hob.Guid->Name);
- if (CompareGuid (&gEfiMemoryTypeInformationGuid, &Hob.Guid->Name)) {
- EfiMemoryTypeInformation = GET_GUID_HOB_DATA (Hob.Guid);
- for (Index = 0; Index < (GET_GUID_HOB_DATA_SIZE (Hob.Guid)/sizeof (EFI_MEMORY_TYPE_INFORMATION)); Index++, EfiMemoryTypeInformation++) {
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- return EFI_SUCCESS;
- }
- AsciiPrint (" %a 0x%08x\n",
- (EfiMemoryTypeInformation->Type < EfiMaxMemoryType) ? gMemMapType[EfiMemoryTypeInformation->Type] : "END ",
- EfiMemoryTypeInformation->NumberOfPages
- );
- }
- }
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_FV) {
- AsciiPrint ("FV HOB %08lx:%08lx\n", Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->Length);
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_CPU) {
- AsciiPrint ("CPU HOB: Mem %x IO %x\n", Hob.Cpu->SizeOfMemorySpace, Hob.Cpu->SizeOfIoSpace);
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_POOL) {
- AsciiPrint ("Mem Pool HOB:\n");
-/* Not in PI
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_CV) {
- AsciiPrint ("CV HOB: %08lx:%08lx\n", Hob.CapsuleVolume->BaseAddress, Hob.CapsuleVolume->Length);
- */
- }
-
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
- break;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHobTemplate[] =
-{
- {
- "hob",
- "; dump HOBs",
- NULL,
- EblHobCmd
- }
-};
-
-
-/**
- Initialize the commands in this in this file
-**/
-VOID
-EblInitializeHobCmd (
- VOID
- )
-{
- if (FeaturePcdGet (PcdEmbeddedHobCmd)) {
- EblAddCommands (mCmdHobTemplate, sizeof (mCmdHobTemplate)/sizeof (EBL_COMMAND_TABLE));
- }
-}
-
diff --git a/EmbeddedPkg/Ebl/HwDebug.c b/EmbeddedPkg/Ebl/HwDebug.c
deleted file mode 100644
index 226b24500a..0000000000
--- a/EmbeddedPkg/Ebl/HwDebug.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/** @file
- 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.
-
- Module Name: HwDebug.c
-
- Commands useful for debugging hardware.
-
-**/
-
-#include "Ebl.h"
-
-
-/**
- Dump memory
-
- Argv[0] - "md"[.#] # is optional width 1, 2, 4, or 8. Default 1
- Argv[1] - Hex Address to dump
- Argv[2] - Number of hex bytes to dump (0x20 is default)
-
- md.4 0x123445678 50 ; Dump 0x50 4 byte quantities starting at 0x123445678
- md 0x123445678 40 ; Dump 0x40 1 byte quantities starting at 0x123445678
- md 0x123445678 ; Dump 0x20 1 byte quantities starting at 0x123445678
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblMdCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- STATIC UINT8 *Address = NULL;
- STATIC UINTN Length = 0x20;
- STATIC UINTN Width;
-
- Width = WidthFromCommandName (Argv[0], 1);
-
- switch (Argc) {
- case 3:
- Length = AsciiStrHexToUintn(Argv[2]);
- case 2:
- Address = (UINT8 *)AsciiStrHexToUintn (Argv[1]);
- default:
- break;
- }
-
- OutputData (Address, Length, Width, (UINTN)Address);
-
- Address += Length;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Fill Memory with data
-
- Argv[0] - "mfill"[.#] # is optional width 1, 2, 4, or 8. Default 4
- Argv[1] - Hex Address to fill
- Argv[2] - Data to write (0x00 is default)
- Argv[3] - Number of units to dump.
-
- mf.1 0x123445678 aa 100 ; Start at 0x123445678 and write aa (1 byte) to the next 100 bytes
- mf.4 0x123445678 aa 100 ; Start at 0x123445678 and write aa (4 byte) to the next 400 bytes
- mf 0x123445678 aa ; Start at 0x123445678 and write aa (4 byte) to the next 1 byte
- mf 0x123445678 ; Start at 0x123445678 and write 00 (4 byte) to the next 1 byte
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblMfillCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Address;
- UINTN EndAddress;
- UINT32 Data;
- UINTN Length;
- UINTN Width;
-
- if (Argc < 2) {
- return EFI_INVALID_PARAMETER;
- }
-
- Width = WidthFromCommandName (Argv[0], 4);
-
- Address = AsciiStrHexToUintn (Argv[1]);
- Data = (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 0;
- Length = (Argc > 3) ? AsciiStrHexToUintn (Argv[3]) : 1;
-
- for (EndAddress = Address + (Length * Width); Address < EndAddress; Address += Width) {
- if (Width == 4) {
- MmioWrite32 (Address, Data);
- } else if (Width == 2) {
- MmioWrite16 (Address, (UINT16)Data);
- } else {
- MmioWrite8 (Address, (UINT8)Data);
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-//
-// Strings for PCI Class code [2]
-//
-CHAR8 *gPciDevClass[] = {
- "Old Device ",
- "Mass storage ",
- "Network ",
- "Display ",
- "Multimedia ",
- "Memory controller ",
- "Bridge device ",
- "simple communications ",
- "base system peripherals",
- "Input devices ",
- "Docking stations ",
- "Processors ",
- "serial bus ",
-};
-
-
-CHAR8 *gPciSerialClassCodes[] = {
- "Mass storage ",
- "Firewire ",
- "ACCESS bus ",
- "SSA ",
- "USB "
-};
-
-
-/**
- PCI Dump
-
- Argv[0] - "pci"
- Argv[1] - bus
- Argv[2] - dev
- Argv[3] - func
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblPciCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *Pci;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Seg;
- UINTN Bus;
- UINTN Dev;
- UINTN Func;
- UINTN BusArg;
- UINTN DevArg;
- UINTN FuncArg;
- UINTN Index;
- UINTN Count;
- PCI_TYPE_GENERIC PciHeader;
- PCI_TYPE_GENERIC *Header;
- PCI_BRIDGE_CONTROL_REGISTER *Bridge;
- PCI_DEVICE_HEADER_TYPE_REGION *Device;
- PCI_DEVICE_INDEPENDENT_REGION *Hdr;
- CHAR8 *Str;
- UINTN ThisBus;
-
-
- BusArg = (Argc > 1) ? AsciiStrDecimalToUintn (Argv[1]) : 0;
- DevArg = (Argc > 2) ? AsciiStrDecimalToUintn (Argv[2]) : 0;
- FuncArg = (Argc > 3) ? AsciiStrDecimalToUintn (Argv[3]) : 0;
-
- Header = &PciHeader;
-
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid, NULL, &HandleCount, &HandleBuffer);
- if (EFI_ERROR (Status)) {
- AsciiPrint ("No PCI devices found in the system\n");
- return EFI_SUCCESS;
- }
-
- if (Argc == 1) {
- // Dump all PCI devices
- AsciiPrint ("BusDevFun VendorId DeviceId Device Class Sub-Class\n");
- AsciiPrint ("_____________________________________________________________");
- for (ThisBus = 0; ThisBus <= PCI_MAX_BUS; ThisBus++) {
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **)&Pci);
- if (!EFI_ERROR (Status)) {
- Pci->GetLocation (Pci, &Seg, &Bus, &Dev, &Func);
- if (ThisBus != Bus) {
- continue;
- }
- AsciiPrint ("\n%03d.%02d.%02d", Bus, Dev, Func);
- Status = Pci->Pci.Read (Pci, EfiPciIoWidthUint32, 0, sizeof (PciHeader)/sizeof (UINT32), &PciHeader);
- if (!EFI_ERROR (Status)) {
- Hdr = &PciHeader.Bridge.Hdr;
-
- if (Hdr->ClassCode[2] < sizeof (gPciDevClass)/sizeof (VOID *)) {
- Str = gPciDevClass[Hdr->ClassCode[2]];
- if (Hdr->ClassCode[2] == PCI_CLASS_SERIAL) {
- if (Hdr->ClassCode[1] < sizeof (gPciSerialClassCodes)/sizeof (VOID *)) {
- // print out Firewire or USB inplace of Serial Bus controllers
- Str = gPciSerialClassCodes[Hdr->ClassCode[1]];
- }
- }
- } else {
- Str = "Unknown device ";
- }
- AsciiPrint (" 0x%04x 0x%04x %a 0x%02x", Hdr->VendorId, Hdr->DeviceId, Str, Hdr->ClassCode[1]);
- }
- if (Seg != 0) {
- // Only print Segment if it is non zero. If you only have one PCI segment it is
- // redundent to print it out
- AsciiPrint (" Seg:%d", Seg);
- }
- }
- }
- }
- AsciiPrint ("\n");
- } else {
- // Dump specific PCI device
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **)&Pci);
- if (!EFI_ERROR (Status)) {
- Pci->GetLocation (Pci, &Seg, &Bus, &Dev, &Func);
- if ((Bus == BusArg) && (Dev == DevArg) && (Func == FuncArg)) {
- // Only print Segment if it is non zero. If you only have one PCI segment it is
- // redundant to print it out
- if (Seg != 0) {
- AsciiPrint ("Seg:%d ", Seg);
- }
- AsciiPrint ("Bus:%d Dev:%d Func:%d ", Bus, Dev, Func);
-
- Status = Pci->Pci.Read (Pci, EfiPciIoWidthUint32, 0, sizeof (PciHeader)/sizeof (UINT32), Header);
- if (!EFI_ERROR (Status)) {
- Hdr = &PciHeader.Bridge.Hdr;
- if (IS_PCI_BRIDGE (&PciHeader.Bridge)) {
- Bridge = &PciHeader.Bridge.Bridge;
- AsciiPrint (
- "PCI Bridge. Bus Primary %d Secondary %d Subordinate %d\n",
- Bridge->PrimaryBus, Bridge->SecondaryBus, Bridge->SubordinateBus
- );
- AsciiPrint (" Bar 0: 0x%08x Bar 1: 0x%08x\n", Bridge->Bar[0], Bridge->Bar[1]);
- } else {
- Device = &PciHeader.Device.Device;
- AsciiPrint (
- "VendorId: 0x%04x DeviceId: 0x%04x SubSusVendorId: 0x%04x SubSysDeviceId: 0x%04x\n",
- Hdr->VendorId, Hdr->DeviceId, Device->SubsystemVendorID, Device->SubsystemID
- );
- AsciiPrint (" Class Code: 0x%02x 0x%02x 0x%02x\n", Hdr->ClassCode[2], Hdr->ClassCode[1], Hdr->ClassCode[0]);
- for (Count = 0; Count < 6; Count++) {
- AsciiPrint (" Bar %d: 0x%08x\n", Count, Device->Bar[Count]);
- }
- }
- }
-
- AsciiPrint ("\n");
- break;
- }
- }
- }
- }
-
- FreePool (HandleBuffer);
- return EFI_SUCCESS;
-}
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdPciDebugTemplate[] = {
- {
- "pci",
- " [bus] [dev] [func]; Dump PCI",
- NULL,
- EblPciCmd
- }
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwDebugTemplate[] =
-{
- {
- "md",
- "[.{1|2|4}] [Addr] [Len] [1|2|4]; Memory Dump from Addr Len bytes",
- NULL,
- EblMdCmd
- },
- {
- "mfill",
- "[.{1|2|4}] Addr Len [data]; Memory Fill Addr Len*(1|2|4) bytes of data(0)",
- NULL,
- EblMfillCmd
- },
-};
-
-
-
-/**
- Initialize the commands in this in this file
-**/
-VOID
-EblInitializemdHwDebugCmds (
- VOID
- )
-{
- if (FeaturePcdGet (PcdEmbeddedHwDebugCmd)) {
- EblAddCommands (mCmdHwDebugTemplate, sizeof (mCmdHwDebugTemplate)/sizeof (EBL_COMMAND_TABLE));
- }
- if (FeaturePcdGet (PcdEmbeddedPciDebugCmd)) {
- EblAddCommands (mCmdPciDebugTemplate, sizeof (mCmdPciDebugTemplate)/sizeof (EBL_COMMAND_TABLE));
- }
-}
-
diff --git a/EmbeddedPkg/Ebl/HwIoDebug.c b/EmbeddedPkg/Ebl/HwIoDebug.c
deleted file mode 100644
index c9144fe43e..0000000000
--- a/EmbeddedPkg/Ebl/HwIoDebug.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/** @file
- Hardware IO based debug commands
-
- 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.
-
- Commands useful for debugging hardware. IO commands separated out as not all
- processor architectures support the IO command.
-
-**/
-
-#include "Ebl.h"
-
-
-
-/**
- Read from IO space
-
- Argv[0] - "ioread"[.#] # is optional width 1, 2, or 4. Default 1
- Argv[1] - Hex IO address
-
- ior.4 0x3f8 ;Do a 32-bit IO Read from 0x3f8
- ior 0x3f8 ;Do a 8-bit IO Read from 0x3f8
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblIoReadCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Width;
- UINTN Port;
- UINTN Data;
-
- if (Argc < 2) {
- return EFI_INVALID_PARAMETER;
- }
-
- Port = AsciiStrHexToUintn (Argv[1]);
- Width = WidthFromCommandName (Argv[0], 1);
-
- if (Width == 1) {
- Data = IoRead8 (Port);
- } else if (Width == 2) {
- Data = IoRead16 (Port);
- } else if (Width == 4) {
- Data = IoRead32 (Port);
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- AsciiPrint ("0x%04x = 0x%x", Port, Data);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Write to IO space
-
- Argv[0] - "iowrite"[.#] # is optional width 1, 2, or 4. Default 1
- Argv[1] - Hex IO address
- Argv[2] - Hex data to write
-
- iow.4 0x3f8 af ;Do a 32-bit IO write of af to 0x3f8
- iow 0x3f8 af ;Do an 8-bit IO write of af to 0x3f8
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblIoWriteCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Width;
- UINTN Port;
- UINTN Data;
-
- if (Argc < 3) {
- return EFI_INVALID_PARAMETER;
- }
-
- Port = AsciiStrHexToUintn (Argv[1]);
- Data = AsciiStrHexToUintn (Argv[2]);
- Width = WidthFromCommandName (Argv[0], 1);
-
- if (Width == 1) {
- IoWrite8 (Port, (UINT8)Data);
- } else if (Width == 2) {
- IoWrite16 (Port, (UINT16)Data);
- } else if (Width == 4) {
- IoWrite32 (Port, (UINT32)Data);
- } else {
- return EFI_INVALID_PARAMETER;
- }
- return EFI_SUCCESS;
-}
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwIoDebugTemplate[] =
-{
- {
- "ioread",
- "[.{1|2|4}] Port ; IO read of width byte(s) from Port",
- NULL,
- EblIoReadCmd
- },
- {
- "iowrite",
- "[.{1|2|4}] Port Data ; IO write Data of width byte(s) to Port",
- NULL,
- EblIoWriteCmd
- }
-};
-
-
-
-/**
- Initialize the commands in this in this file
-**/
-VOID
-EblInitializemdHwIoDebugCmds (
- VOID
- )
-{
- if (FeaturePcdGet (PcdEmbeddedIoEnable)) {
- EblAddCommands (mCmdHwIoDebugTemplate, sizeof (mCmdHwIoDebugTemplate)/sizeof (EBL_COMMAND_TABLE));
- }
-}
-
diff --git a/EmbeddedPkg/Ebl/Main.c b/EmbeddedPkg/Ebl/Main.c
deleted file mode 100644
index dc17d26c71..0000000000
--- a/EmbeddedPkg/Ebl/Main.c
+++ /dev/null
@@ -1,674 +0,0 @@
-/** @file
- 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.
-
-
-**/
-
-#include "Ebl.h"
-
-// Globals for command history processing
-INTN mCmdHistoryEnd = -1;
-INTN mCmdHistoryStart = -1;
-INTN mCmdHistoryCurrent = -1;
-CHAR8 mCmdHistory[MAX_CMD_HISTORY][MAX_CMD_LINE];
-CHAR8 *mCmdBlank = "";
-
-// Globals to remember current screen geometry
-UINTN gScreenColumns;
-UINTN gScreenRows;
-
-// Global to turn on/off breaking commands with prompts before they scroll the screen
-BOOLEAN gPageBreak = TRUE;
-
-VOID
-RingBufferIncrement (
- IN INTN *Value
- )
-{
- *Value = *Value + 1;
-
- if (*Value >= MAX_CMD_HISTORY) {
- *Value = 0;
- }
-}
-
-VOID
-RingBufferDecrement (
- IN INTN *Value
- )
-{
- *Value = *Value - 1;
-
- if (*Value < 0) {
- *Value = MAX_CMD_HISTORY - 1;
- }
-}
-
-/**
- Save this command in the circular history buffer. Older commands are
- overwritten with newer commands.
-
- @param Cmd Command line to archive the history of.
-
- @return None
-
-**/
-VOID
-SetCmdHistory (
- IN CHAR8 *Cmd
- )
-{
- // Don't bother adding empty commands to the list
- if (AsciiStrLen(Cmd) != 0) {
-
- // First entry
- if (mCmdHistoryStart == -1) {
- mCmdHistoryStart = 0;
- mCmdHistoryEnd = 0;
- } else {
- // Record the new command at the next index
- RingBufferIncrement(&mCmdHistoryStart);
-
- // If the next index runs into the end index, shuffle end back by one
- if (mCmdHistoryStart == mCmdHistoryEnd) {
- RingBufferIncrement(&mCmdHistoryEnd);
- }
- }
-
- // Copy the new command line into the ring buffer
- AsciiStrnCpy(&mCmdHistory[mCmdHistoryStart][0], Cmd, MAX_CMD_LINE);
- }
-
- // Reset the command history for the next up arrow press
- mCmdHistoryCurrent = mCmdHistoryStart;
-}
-
-
-/**
- Retreave data from the Command History buffer. Direction maps into up arrow
- an down arrow on the command line
-
- @param Direction Command forward or back
-
- @return The Command history based on the Direction
-
-**/
-CHAR8 *
-GetCmdHistory (
- IN UINT16 Direction
- )
-{
- CHAR8 *HistoricalCommand = NULL;
-
- // No history yet?
- if (mCmdHistoryCurrent == -1) {
- HistoricalCommand = mCmdBlank;
- goto Exit;
- }
-
- if (Direction == SCAN_UP) {
- HistoricalCommand = &mCmdHistory[mCmdHistoryCurrent][0];
-
- // if we just echoed the last command, hang out there, don't wrap around
- if (mCmdHistoryCurrent == mCmdHistoryEnd) {
- goto Exit;
- }
-
- // otherwise, back up by one
- RingBufferDecrement(&mCmdHistoryCurrent);
-
- } else if (Direction == SCAN_DOWN) {
-
- // if we last echoed the start command, put a blank prompt out
- if (mCmdHistoryCurrent == mCmdHistoryStart) {
- HistoricalCommand = mCmdBlank;
- goto Exit;
- }
-
- // otherwise increment the current pointer and return that command
- RingBufferIncrement(&mCmdHistoryCurrent);
- RingBufferIncrement(&mCmdHistoryCurrent);
-
- HistoricalCommand = &mCmdHistory[mCmdHistoryCurrent][0];
- RingBufferDecrement(&mCmdHistoryCurrent);
- }
-
-Exit:
- return HistoricalCommand;
-}
-
-
-/**
- Parse the CmdLine and break it up into Argc (arg count) and Argv (array of
- pointers to each argument). The Cmd buffer is altered and separators are
- converted to string terminators. This allows Argv to point into CmdLine.
- A CmdLine can support multiple commands. The next command in the command line
- is returned if it exists.
-
- @param CmdLine String to parse for a set of commands
- @param Argc Returns the number of arguments in the CmdLine current command
- @param Argv Argc pointers to each string in CmdLine
-
- @return Next Command in the command line or NULL if non exists
-**/
-CHAR8 *
-ParseArguments (
- IN CHAR8 *CmdLine,
- OUT UINTN *Argc,
- OUT CHAR8 **Argv
- )
-{
- UINTN Arg;
- CHAR8 *Char;
- BOOLEAN LookingForArg;
- BOOLEAN InQuote;
-
- *Argc = 0;
- if (AsciiStrLen (CmdLine) == 0) {
- return NULL;
- }
-
- // Walk a single command line. A CMD_SEPARATOR allows multiple commands on a single line
- InQuote = FALSE;
- LookingForArg = TRUE;
- for (Char = CmdLine, Arg = 0; *Char != '\0'; Char++) {
- if (!InQuote && *Char == CMD_SEPARATOR) {
- break;
- }
-
- // Perform any text conversion here
- if (*Char == '\t') {
- // TAB to space
- *Char = ' ';
- }
-
- if (LookingForArg) {
- // Look for the beginning of an Argv[] entry
- if (*Char == '"') {
- Argv[Arg++] = ++Char;
- LookingForArg = FALSE;
- InQuote = TRUE;
- } else if (*Char != ' ') {
- Argv[Arg++] = Char;
- LookingForArg = FALSE;
- }
- } else {
- // Looking for the terminator of an Argv[] entry
- if (!InQuote && (*Char == ' ')) {
- *Char = '\0';
- LookingForArg = TRUE;
- } else if (!InQuote && (*Char == '"') && (*(Char-1) != '\\')) {
- InQuote = TRUE;
- } else if (InQuote && (*Char == '"') && (*(Char-1) != '\\')) {
- *Char = '\0';
- InQuote = FALSE;
- }
- }
- }
-
- *Argc = Arg;
-
- if (*Char == CMD_SEPARATOR) {
- // Replace the command delimiter with null and return pointer to next command line
- *Char = '\0';
- return ++Char;
- }
-
- return NULL;
-}
-
-
-/**
- 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
-EblGetCharKey (
- IN OUT EFI_INPUT_KEY *Key,
- IN UINTN TimeoutInSec,
- IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINTN WaitCount;
- UINTN WaitIndex;
- EFI_EVENT WaitList[2];
-
- WaitCount = 1;
- WaitList[0] = gST->ConIn->WaitForKey;
- if (TimeoutInSec != 0) {
- // Create a time event for 1 sec duration if we have a timeout
- gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &WaitList[1]);
- gBS->SetTimer (WaitList[1], TimerPeriodic, EFI_SET_TIMER_TO_SECOND);
- WaitCount++;
- }
-
- for (;;) {
- Status = gBS->WaitForEvent (WaitCount, WaitList, &WaitIndex);
- ASSERT_EFI_ERROR (Status);
-
- switch (WaitIndex) {
- case 0:
- // Key event signaled
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);
- if (!EFI_ERROR (Status)) {
- if (WaitCount == 2) {
- gBS->CloseEvent (WaitList[1]);
- }
- return EFI_SUCCESS;
- }
- break;
-
- case 1:
- // Periodic 1 sec timer signaled
- TimeoutInSec--;
- if (CallBack != NULL) {
- // Call the users callback function if registered
- CallBack (TimeoutInSec);
- }
- if (TimeoutInSec == 0) {
- gBS->CloseEvent (WaitList[1]);
- return EFI_TIMEOUT;
- }
- break;
- default:
- ASSERT (FALSE);
- }
- }
-}
-
-
-/**
- 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
-EblAnyKeyToContinueQtoQuit (
- IN UINTN *CurrentRow,
- IN BOOLEAN PrefixNewline
- )
-{
- EFI_INPUT_KEY InputKey;
-
- if (!gPageBreak) {
- // global disable for this feature
- return FALSE;
- }
-
- if (*CurrentRow >= (gScreenRows - 2)) {
- if (PrefixNewline) {
- AsciiPrint ("\n");
- }
- AsciiPrint ("Any key to continue (Q to quit): ");
- EblGetCharKey (&InputKey, 0, NULL);
- AsciiPrint ("\n");
-
- // Time to promt to stop the screen. We have to leave space for the prompt string
- *CurrentRow = 0;
- if (InputKey.UnicodeChar == 'Q' || InputKey.UnicodeChar == 'q') {
- return TRUE;
- }
- } else {
- *CurrentRow += 1;
- }
-
- return FALSE;
-}
-
-
-/**
- Set the text color of the EFI Console. If a zero is passed in reset to
- default text/background color.
-
- @param Attribute For text and background color
-
-**/
-VOID
-EblSetTextColor (
- UINTN Attribute
- )
-{
- if (Attribute == 0) {
- // Set the text color back to default
- Attribute = (UINTN)PcdGet32 (PcdEmbeddedDefaultTextColor);
- }
-
- gST->ConOut->SetAttribute (gST->ConOut, Attribute);
-}
-
-
-/**
- Collect the keyboard input for a cmd line. Carriage Return, New Line, or ESC
- terminates the command line. You can edit the command line via left arrow,
- delete and backspace and they all back up and erase the command line.
- No edit of command line is possible without deletion at this time!
- The up arrow and down arrow fill Cmd with information from the history
- buffer.
-
- @param Cmd Command line to return
- @param CmdMaxSize Maximum size of Cmd
-
- @return The Status of EblGetCharKey()
-
-**/
-EFI_STATUS
-GetCmd (
- IN OUT CHAR8 *Cmd,
- IN UINTN CmdMaxSize
- )
-{
- EFI_STATUS Status;
- UINTN Index;
- UINTN Index2;
- CHAR8 Char;
- CHAR8 *History;
- EFI_INPUT_KEY Key;
-
- for (Index = 0; Index < CmdMaxSize - 1;) {
- Status = EblGetCharKey (&Key, 0, NULL);
- if (EFI_ERROR (Status)) {
- Cmd[Index] = '\0';
- AsciiPrint ("\n");
- return Status;
- }
-
- Char = (CHAR8)Key.UnicodeChar;
- if ((Char == '\n') || (Char == '\r') || (Char == 0x7f)) {
- Cmd[Index] = '\0';
- if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) == TRUE) {
- AsciiPrint ("\n\r");
- }
- return EFI_SUCCESS;
- } else if ((Char == '\b') || (Key.ScanCode == SCAN_LEFT) || (Key.ScanCode == SCAN_DELETE)){
- if (Index != 0) {
- Index--;
- //
- // Update the display
- //
- AsciiPrint ("\b \b");
- }
- } else if ((Key.ScanCode == SCAN_UP) || Key.ScanCode == SCAN_DOWN) {
- History = GetCmdHistory (Key.ScanCode);
- //
- // Clear display line
- //
- for (Index2 = 0; Index2 < Index; Index2++) {
- AsciiPrint ("\b \b");
- }
- AsciiPrint (History);
- Index = AsciiStrLen (History);
- AsciiStrnCpy (Cmd, History, CmdMaxSize);
- } else {
- Cmd[Index++] = Char;
- if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) == TRUE) {
- AsciiPrint ("%c", Char);
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Print the boot up banner for the EBL.
-**/
-VOID
-EblPrintStartupBanner (
- VOID
- )
-{
- AsciiPrint ("Embedded Boot Loader (");
- EblSetTextColor (EFI_YELLOW);
- AsciiPrint ("EBL");
- EblSetTextColor (0);
- AsciiPrint (") prototype. Built at %a on %a\n",__TIME__, __DATE__);
- AsciiPrint ("THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN 'AS IS' BASIS,\nWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\n");
- AsciiPrint ("Please send feedback to edk2-devel@lists.sourceforge.net\n");
-}
-
-
-/**
- Send null requests to all removable media block IO devices so the a media add/remove/change
- can be detected in real before we execute a command.
-
- This is mainly due to the fact that the FAT driver does not do this today so you can get stale
- dir commands after an SD Card has been removed.
-**/
-VOID
-EblProbeRemovableMedia (
- VOID
- )
-{
- UINTN Index;
- UINTN Max;
- EFI_OPEN_FILE *File;
-
- //
- // Probe for media insertion/removal in removable media devices
- //
- Max = EfiGetDeviceCounts (EfiOpenBlockIo);
- if (Max != 0) {
- for (Index = 0; Index < Max; Index++) {
- File = EfiDeviceOpenByType (EfiOpenBlockIo, Index);
- if (File != NULL) {
- if (File->FsBlockIoMedia->RemovableMedia) {
- // Probe to see if media is present (or not) or media changed
- // this causes the ReinstallProtocolInterface() to fire in the
- // block io driver to update the system about media change events
- File->FsBlockIo->ReadBlocks (File->FsBlockIo, File->FsBlockIo->Media->MediaId, (EFI_LBA)0, 0, NULL);
- }
- EfiClose (File);
- }
- }
- }
-}
-
-
-
-
-/**
- Print the prompt for the EBL.
-**/
-VOID
-EblPrompt (
- VOID
- )
-{
- EblSetTextColor (EFI_YELLOW);
- AsciiPrint ("%a %a",(CHAR8 *)PcdGetPtr (PcdEmbeddedPrompt), EfiGetCwd ());
- EblSetTextColor (0);
- AsciiPrint ("%a", ">");
-}
-
-
-
-/**
- Parse a command line and execute the commands. The ; separator allows
- multiple commands for each command line. Stop processing if one of the
- commands returns an error.
-
- @param CmdLine Command Line to process.
- @param MaxCmdLineSize MaxSize of the Command line
-
- @return EFI status of the Command
-
-**/
-EFI_STATUS
-ProcessCmdLine (
- IN CHAR8 *CmdLine,
- IN UINTN MaxCmdLineSize
- )
-{
- EFI_STATUS Status;
- EBL_COMMAND_TABLE *Cmd;
- CHAR8 *Ptr;
- UINTN Argc;
- CHAR8 *Argv[MAX_ARGS];
-
- // Parse the command line. The loop processes commands separated by ;
- for (Ptr = CmdLine, Status = EFI_SUCCESS; Ptr != NULL;) {
- Ptr = ParseArguments (Ptr, &Argc, Argv);
- if (Argc != 0) {
- Cmd = EblGetCommand (Argv[0]);
- if (Cmd != NULL) {
- // Execute the Command!
- Status = Cmd->Command (Argc, Argv);
- if (Status == EFI_ABORTED) {
- // exit command so lets exit
- break;
- } else if (Status == EFI_TIMEOUT) {
- // pause command got input so don't process any more cmd on this cmd line
- break;
- } else if (EFI_ERROR (Status)) {
- AsciiPrint ("%a returned %r error\n", Cmd->Name, Status);
- // if any command fails stop processing CmdLine
- break;
- }
- } else {
- AsciiPrint ("The command '%a' is not supported.\n", Argv[0]);
- }
- }
- }
-
- return Status;
-}
-
-
-
-/**
- Embedded Boot Loader (EBL) - A simple EFI command line application for embedded
- devices. PcdEmbeddedAutomaticBootCommand is a complied in command line that
- gets executed automatically. The ; separator allows multiple commands
- for each command line.
-
- @param ImageHandle EFI ImageHandle for this application.
- @param SystemTable EFI system table
-
- @return EFI status of the application
-
-**/
-EFI_STATUS
-EFIAPI
-EdkBootLoaderEntry (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- CHAR8 CmdLine[MAX_CMD_LINE];
- CHAR16 *CommandLineVariable = NULL;
- CHAR16 *CommandLineVariableName = L"default-cmdline";
- UINTN CommandLineVariableSize = 0;
- EFI_GUID VendorGuid;
-
- // Initialize tables of commands
- EblInitializeCmdTable ();
- EblInitializeDeviceCmd ();
- EblInitializemdHwDebugCmds ();
- EblInitializemdHwIoDebugCmds ();
- EblInitializeDirCmd ();
- EblInitializeHobCmd ();
- EblInitializeScriptCmd ();
- EblInitializeExternalCmd ();
- EblInitializeNetworkCmd();
- EblInitializeVariableCmds ();
-
- if (gST->ConOut == NULL) {
- DEBUG((EFI_D_ERROR,"Error: No Console Output\n"));
- return EFI_NOT_READY;
- }
-
- // Disable the 5 minute EFI watchdog time so we don't get automatically reset
- gBS->SetWatchdogTimer (0, 0, 0, NULL);
-
- if (FeaturePcdGet (PcdEmbeddedMacBoot)) {
- // A MAC will boot in graphics mode, so turn it back to text here
- // This protocol was removed from edk2. It is only an edk thing. We need to make our own copy.
- // DisableQuietBoot ();
-
- // Enable the biggest output screen size possible
- gST->ConOut->SetMode (gST->ConOut, (UINTN)gST->ConOut->Mode->MaxMode - 1);
-
- }
-
- // Save current screen mode
- gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &gScreenColumns, &gScreenRows);
-
- EblPrintStartupBanner ();
-
- // Parse command line and handle commands separated by ;
- // The loop prints the prompt gets user input and saves history
-
- // Look for a variable with a default command line, otherwise use the Pcd
- ZeroMem(&VendorGuid, sizeof(EFI_GUID));
-
- Status = gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL, &CommandLineVariableSize, CommandLineVariable);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- CommandLineVariable = AllocatePool(CommandLineVariableSize);
-
- Status = gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL, &CommandLineVariableSize, CommandLineVariable);
- if (!EFI_ERROR(Status)) {
- UnicodeStrToAsciiStr(CommandLineVariable, CmdLine);
- }
-
- FreePool(CommandLineVariable);
- }
-
- if (EFI_ERROR(Status)) {
- AsciiStrCpy (CmdLine, (CHAR8 *)PcdGetPtr (PcdEmbeddedAutomaticBootCommand));
- }
-
- for (;;) {
- Status = ProcessCmdLine (CmdLine, MAX_CMD_LINE);
- if (Status == EFI_ABORTED) {
- // if a command returns EFI_ABORTED then exit the EBL
- EblShutdownExternalCmdTable ();
- return EFI_SUCCESS;
- }
-
- // get the command line from the user
- EblPrompt ();
- GetCmd (CmdLine, MAX_CMD_LINE);
- SetCmdHistory (CmdLine);
-
- if (FeaturePcdGet (PcdEmbeddedProbeRemovable)) {
- // Probe removable media devices to see if media has been inserted or removed.
- EblProbeRemovableMedia ();
- }
- }
-}
-
-
diff --git a/EmbeddedPkg/Ebl/Network.c b/EmbeddedPkg/Ebl/Network.c
deleted file mode 100644
index c0055d5bb7..0000000000
--- a/EmbeddedPkg/Ebl/Network.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/** @file
- EBL commands for Network Devices
-
- 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 "Ebl.h"
-
-EFI_STATUS
-ParseIp (
- IN CHAR8 *String,
- OUT EFI_IP_ADDRESS *Address
- )
-{
- Address->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (String);
- String = AsciiStrStr(String, ".") + 1;
- Address->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (String);
- String = AsciiStrStr(String, ".") + 1;
- Address->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (String);
- String = AsciiStrStr(String, ".") + 1;
- Address->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (String);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EblIpCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status = EFI_INVALID_PARAMETER;
- EFI_MAC_ADDRESS Mac;
- EFI_IP_ADDRESS Ip;
-
- if (Argc == 1) {
- // Get current IP/MAC
-
- // Get current MAC address
- Status = EblGetCurrentMacAddress (&Mac);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- AsciiPrint ("MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n", Mac.Addr[0], Mac.Addr[1], Mac.Addr[2], Mac.Addr[3], Mac.Addr[4], Mac.Addr[5]);
-
- // Get current IP address
- Status = EblGetCurrentIpAddress (&Ip);
- if (EFI_ERROR(Status)) {
- AsciiPrint("IP Address is not configured.\n");
- Status = EFI_SUCCESS;
- goto Exit;
- }
-
- AsciiPrint("IP Address: %d.%d.%d.%d\n", Ip.v4.Addr[0], Ip.v4.Addr[1],Ip.v4.Addr[2], Ip.v4.Addr[3]);
-
- } else if ((Argv[1][0] == 'r') && (Argc == 2)) {
- // Get new address via dhcp
- Status = EblPerformDHCP (TRUE);
- } else if ((Argv[1][0] == 's') && (Argc == 3)) {
- // Set static IP
- Status = ParseIp (Argv[2], &Ip);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = EblSetStationIp (&Ip, NULL);
- }
-
-Exit:
- return Status;
-}
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdNetworkTemplate[] =
-{
- {
- "ip",
- " ; print current ip address\n\r [r]; request DHCP address\n\r [s] ipaddr; set static IP address",
- NULL,
- EblIpCmd
- }
-};
-
-
-/**
- Initialize the commands in this in this file
-**/
-VOID
-EblInitializeNetworkCmd (
- VOID
- )
-{
- EblAddCommands (mCmdNetworkTemplate, sizeof (mCmdNetworkTemplate)/sizeof (EBL_COMMAND_TABLE));
-}
-
diff --git a/EmbeddedPkg/Ebl/Script.c b/EmbeddedPkg/Ebl/Script.c
deleted file mode 100644
index a739e37dd9..0000000000
--- a/EmbeddedPkg/Ebl/Script.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/** @file
- Script command allows the execution of commands from a text file
-
- 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.
-
- Module Name: EfiDevice.c
-
-**/
-
-#include "Ebl.h"
-
-
-/**
- Execute the passed in file like a series of commands. The ; can be used on
- a single line to indicate multiple commands per line. The Ascii text file
- can contain any number of lines. The following line termination forms are
- supported:
- LF : Unix, Mac OS X*, BeOS
- CR+LF: MS-DOS*, Microsoft Windows*
- CR : Commodore, Apple II, and really Mac OS
- LF+CR: for simplicity and completeness
-
- Argv[0] - "script"
- Argv[1] - Device Name:path for the file to load
-
- script fv1:\script.txt
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblScriptCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_OPEN_FILE *File;
- VOID *Address;
- UINTN Size;
- CHAR8 *Ptr;
- CHAR8 *ScanPtr;
- UINTN CmdLineSize;
-
-
-
- if (Argc < 2) {
- // file name required
- return EFI_SUCCESS;
- }
-
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);
- if (File == NULL) {
- AsciiPrint (" %a is not a valid path\n", Argv[1]);
- return EFI_SUCCESS;
- }
-
- Status = EfiReadAllocatePool (File, &Address, &Size);
- if (!EFI_ERROR (Status)) {
- // Loop through each line in the text file
- for (Ptr = (CHAR8 *)Address; (Ptr < (((CHAR8 *)Address) + Size)) && !EFI_ERROR (Status); Ptr += CmdLineSize) {
- for (CmdLineSize = 0, ScanPtr = Ptr; ; CmdLineSize++, ScanPtr++) {
- // look for the end of the line
- if ((*ScanPtr == EBL_CR) || (*ScanPtr == EBL_LF)) {
- // convert to NULL as this is what input routine would do
- *ScanPtr = 0;
- if ((*(ScanPtr + 1) == EBL_CR) || (*(ScanPtr + 1) == EBL_LF)) {
- // if its a set get the 2nd EOL char
- CmdLineSize++;
- *(ScanPtr + 1) = 0;
- }
- CmdLineSize++;
- break;
- }
-
- }
-
- Status = ProcessCmdLine (Ptr, CmdLineSize);
- }
-
- FreePool (Address);
- }
-
- EfiClose (File);
- return Status;
-}
-
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mScriptTemplate[] = {
- {
- "script",
- " device:path; load an ascii file and execute it like commands",
- NULL,
- EblScriptCmd
- }
-};
-
-
-/**
- Initialize the commands in this in this file
-**/
-
-VOID
-EblInitializeScriptCmd (
- VOID
- )
-{
- if (FeaturePcdGet (PcdEmbeddedScriptCmd)) {
- EblAddCommands (mScriptTemplate, sizeof (mScriptTemplate)/sizeof (EBL_COMMAND_TABLE));
- }
-}
-
diff --git a/EmbeddedPkg/Ebl/Variable.c b/EmbeddedPkg/Ebl/Variable.c
deleted file mode 100644
index f7627a8def..0000000000
--- a/EmbeddedPkg/Ebl/Variable.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011, 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.
-*
-**/
-
-#include "Ebl.h"
-
-#include <Guid/GlobalVariable.h>
-
-EFI_STATUS
-EblGetCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status = EFI_INVALID_PARAMETER;
- UINTN Size;
- VOID* Value;
- CHAR8* AsciiVariableName = NULL;
- CHAR16* VariableName;
- UINT32 Index;
-
- if (Argc == 1) {
- AsciiPrint("Variable name is missing.\n");
- return Status;
- }
-
- for (Index = 1; Index < Argc; Index++) {
- if (Argv[Index][0] == '-') {
- AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]);
- } else {
- AsciiVariableName = Argv[Index];
- }
- }
-
- if (AsciiVariableName == NULL) {
- AsciiPrint("Variable name is missing.\n");
- return Status;
- } else {
- VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));
- AsciiStrToUnicodeStr (AsciiVariableName,VariableName);
- }
-
- // Try to get the variable size.
- Value = NULL;
- Size = 0;
- Status = gRT->GetVariable (VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);
- if (Status == EFI_NOT_FOUND) {
- AsciiPrint("Variable name '%s' not found.\n",VariableName);
- } else if (Status == EFI_BUFFER_TOO_SMALL) {
- // Get the environment variable value
- Value = AllocatePool (Size);
- if (Value == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = gRT->GetVariable ((CHAR16 *)VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);
- if (EFI_ERROR (Status)) {
- AsciiPrint("Error: '%r'\n",Status);
- } else {
- AsciiPrint("%a=%a\n",AsciiVariableName,Value);
- }
- FreePool(Value);
- } else {
- AsciiPrint("Error: '%r'\n",Status);
- }
-
- FreePool(VariableName);
- return Status;
-}
-
-EFI_STATUS
-EblSetCmd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status = EFI_INVALID_PARAMETER;
- CHAR8* AsciiVariableSetting = NULL;
- CHAR8* AsciiVariableName;
- CHAR8* AsciiValue;
- UINT32 AsciiValueLength;
- CHAR16* VariableName;
- UINT32 Index;
- UINT32 EscapedQuotes = 0;
- BOOLEAN Volatile = FALSE;
-
- if (Argc == 1) {
- AsciiPrint("Variable name is missing.\n");
- return Status;
- }
-
- for (Index = 1; Index < Argc; Index++) {
- if (AsciiStrCmp(Argv[Index],"-v") == 0) {
- Volatile = 0;
- } else if (Argv[Index][0] == '-') {
- AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]);
- } else {
- AsciiVariableSetting = Argv[Index];
- }
- }
-
- if (AsciiVariableSetting == NULL) {
- AsciiPrint("Variable name is missing.\n");
- return Status;
- }
-
- // Check if it is a valid variable setting
- AsciiValue = AsciiStrStr (AsciiVariableSetting,"=");
- if (AsciiValue == NULL) {
- //
- // There is no value. It means this variable will be deleted
- //
-
- // Convert VariableName into Unicode
- VariableName = AllocatePool((AsciiStrLen (AsciiVariableSetting) + 1) * sizeof (CHAR16));
- AsciiStrToUnicodeStr (AsciiVariableSetting,VariableName);
-
- Status = gRT->SetVariable (
- VariableName,
- &gEfiGlobalVariableGuid,
- ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- 0,
- NULL
- );
- if (!EFI_ERROR(Status)) {
- AsciiPrint("Variable '%s' deleted\n",VariableName);
- } else {
- AsciiPrint("Variable setting is incorrect. It should be VariableName=Value\n");
- }
- return Status;
- }
-
- AsciiValue[0] = '\0';
- AsciiVariableName = AsciiVariableSetting;
- AsciiValue++;
-
- // Clean AsciiValue from quote
- if (AsciiValue[0] == '"') {
- AsciiValue++;
- }
- AsciiValueLength = AsciiStrLen (AsciiValue);
- if ((AsciiValue[AsciiValueLength-2] != '\\') && (AsciiValue[AsciiValueLength-1] == '"')) {
- AsciiValue[AsciiValueLength-1] = '\0';
- }
-
- // Clean AsciiValue from escaped quotes
- for (Index = 0; Index < AsciiValueLength; Index++) {
- if ((Index > 0) && (AsciiValue[Index-1] == '\\') && (AsciiValue[Index] == '"')) {
- EscapedQuotes++;
- }
- AsciiValue[Index-EscapedQuotes] = AsciiValue[Index];
- }
- // Fill the end of the value with '\0'
- for (Index = 0; Index < EscapedQuotes; Index++) {
- AsciiValue[AsciiValueLength-1-Index] = '\0';
- }
-
- // Convert VariableName into Unicode
- VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));
- AsciiStrToUnicodeStr (AsciiVariableName,VariableName);
-
- Status = gRT->SetVariable (
- VariableName,
- &gEfiGlobalVariableGuid,
- ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- AsciiStrLen (AsciiValue)+1,
- AsciiValue
- );
- if (!EFI_ERROR(Status)) {
- AsciiPrint("'%a'='%a'\n",AsciiVariableName,AsciiValue);
- }
-
- return Status;
-}
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdVariableTemplate[] =
-{
- {
- "get",
- " ; get UEFI variable\n\r [v]; verbose",
- NULL,
- EblGetCmd
- },
- {
- "set",
- " ; set UEFI variable\n\r [v]; create volatile variable",
- NULL,
- EblSetCmd
- }
-};
-
-/**
- Initialize the commands in this in this file
-**/
-VOID
-EblInitializeVariableCmds (
- VOID
- )
-{
- EblAddCommands (mCmdVariableTemplate, sizeof (mCmdVariableTemplate)/sizeof (EBL_COMMAND_TABLE));
-}
diff --git a/EmbeddedPkg/EblExternCmd/EntryPointGlue.c b/EmbeddedPkg/EblExternCmd/EntryPointGlue.c
deleted file mode 100644
index d0e549bdc1..0000000000
--- a/EmbeddedPkg/EblExternCmd/EntryPointGlue.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/** @file
- Glue code that contains the EFI entry point and converts it to an EBL
- ASCII Argc, Argv sytle entry point
-
-
- 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.
-
-
-**/
-
-#include "Ebl.h"
-
-#define CMD_SEPARATOR ';'
-#define MAX_ARGS 32
-
-EFI_STATUS
-EblMain (
- IN UINTN Argc,
- IN CHAR8 **Argv
- );
-
-
-///
-/// EdkExternCmdEntry() & ParseArguments() convert the standard EFI entry point
-/// into Argc, Argv form that calls EblMain().
-///
-
-
-/**
- Parse the CmdLine and break it up into Argc (arg count) and Argv (array of
- pointers to each argument). The Cmd buffer is altered and separators are
- converted to string terminators. This allows Argv to point into CmdLine.
- A CmdLine can support multiple commands. The next command in the command line
- is returned if it exists.
-
- @param CmdLine String to parse for a set of commands
- @param CmdLineSize Size of CmdLine in bytes
- @param Argc Returns the number of arguments in the CmdLine current command
- @param Argv Argc pointers to each string in CmdLine
-
- @return Next Command in the command line or NULL if non exists
-**/
-VOID
-ParseArguments (
- IN CHAR8 *CmdLine,
- IN UINTN CmdLineSize,
- OUT UINTN *Argc,
- OUT CHAR8 **Argv
- )
-{
- UINTN Arg;
- CHAR8 *Char;
- BOOLEAN LookingForArg;
- BOOLEAN InQuote;
- UINTN Index;
-
- *Argc = 0;
- if ((CmdLineSize == 0) || (AsciiStrLen (CmdLine) == 0)) {
- // basic error checking failed on the arguments
- return;
- }
-
- // Walk a single command line. A CMD_SEPARATOR allows multiple commands on a single line
- InQuote = FALSE;
- LookingForArg = TRUE;
- for (Char = CmdLine, Arg = 0, Index = 0; *Char != '\0' && *Char != CMD_SEPARATOR; Char++, Index++) {
- // Perform any text conversion here
- if (*Char == '\t') {
- // TAB to space
- *Char = ' ';
- }
-
- if (LookingForArg) {
- // Look for the beginning of an Argv[] entry
- if (*Char == '"') {
- Argv[Arg++] = ++Char;
- LookingForArg = FALSE;
- InQuote = TRUE;
- } else if (*Char != ' ') {
- Argv[Arg++] = Char;
- LookingForArg = FALSE;
- }
- } else {
- // Looking for the terminator of an Argv[] entry
- if ((InQuote && (*Char == '"')) || (!InQuote && (*Char == ' '))) {
- *Char = '\0';
- LookingForArg = TRUE;
- }
- }
-
- if ((Arg >= MAX_ARGS) || (Index > CmdLineSize)) {
- // Error check buffer and exit since it does not look valid
- break;
- }
- }
-
- *Argc = Arg;
-
- if (*Char == CMD_SEPARATOR) {
- // Replace the command delimiter with null
- *Char = '\0';
- }
-
- return;
-}
-
-
-
-
-/**
- Embedded Boot Loader (EBL) - A simple EFI command line application for embedded
- devices. PcdEmbeddedAutomaticBootCommand is a complied in command line that
- gets executed automatically. The ; separator allows multiple commands
- for each command line.
-
- @param ImageHandle EFI ImageHandle for this application.
- @param SystemTable EFI system table
-
- @return EFI status of the application
-
-**/
-EFI_STATUS
-EFIAPI
-EdkExternCmdEntry (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
- UINTN Argc;
- CHAR8 *Argv[MAX_ARGS];
-
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);
- if (EFI_ERROR (Status)) {
- Argc = 0;
- } else {
- // Looks like valid commands were passed in.
- ParseArguments (ImageInfo->LoadOptions, ImageInfo->LoadOptionsSize, &Argc, Argv);
- }
-
- return EblMain (Argc, Argv);
-}
-
-
diff --git a/EmbeddedPkg/EblExternCmd/Main.c b/EmbeddedPkg/EblExternCmd/Main.c
deleted file mode 100644
index dbfe336899..0000000000
--- a/EmbeddedPkg/EblExternCmd/Main.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/** @file
- Example of an external EBL command. It's loaded via EBL start command.
- Argc and Argv are passed in via "" of the EBL command line.
-
- Start fs0:\EdkExternCmd.efi "Argv[0] Argv[1] 2"
-
- will launch this command with
- Argv[0] = "Argv[0]"
- Argv[1] = "Argv[2]"
- Argv[2] = "3"
-
- 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.
-
-
-**/
-
-#include "Ebl.h"
-
-/**
- Entry point with Argc, Argv. Put your code here.
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblMain (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Index;
-
- AsciiPrint ("Hello World\n");
- for (Index = 0; Index < Argc; Index++) {
- AsciiPrint ("Argv[%d] = %a\n", Index, Argv[Index]);
- }
-
- return EFI_SUCCESS;
-}
-
diff --git a/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c b/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c
deleted file mode 100644
index 1dec02e65a..0000000000
--- a/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/** @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/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-#include <Protocol/MonotonicCounter.h>
-
-UINT64 gCurrentMonotonicCount = 0;
-
-EFI_STATUS
-EFIAPI
-GetNextMonotonicCount (
- OUT UINT64 *Count
- )
-{
- if (Count == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- *Count = gCurrentMonotonicCount++;
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-GetNextHighMonotonicCount (
- OUT UINT32 *HighCount
- )
-{
- if (HighCount == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- gCurrentMonotonicCount += 0x0000000100000000ULL;
-
- *HighCount = (UINT32)RShiftU64 (gCurrentMonotonicCount, 32) & 0xFFFFFFFF;
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-MonotonicCounterDriverInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE Handle = NULL;
-
- // Make sure the Monotonic Counter Architectural Protocol is not already installed in the system
- ASSERT_PROTOCOL_ALREADY_INSTALLED(NULL, &gEfiMonotonicCounterArchProtocolGuid);
-
- // Fill in the EFI Boot Services and EFI Runtime Services Monotonic Counter Fields
- gBS->GetNextMonotonicCount = GetNextMonotonicCount;
- gRT->GetNextHighMonotonicCount = GetNextHighMonotonicCount;
-
- // Install the Monotonic Counter Architectural Protocol onto a new handle
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiMonotonicCounterArchProtocolGuid, NULL,
- NULL
- );
- return Status;
-}
diff --git a/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf b/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
deleted file mode 100644
index 9f28522252..0000000000
--- a/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
+++ /dev/null
@@ -1,41 +0,0 @@
-#/** @file
-#
-# 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = EmbeddedMonotonicCounter
- FILE_GUID = FCABE6A7-7953-4A84-B7EC-D29E89B62E87
- MODULE_TYPE = DXE_RUNTIME_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = MonotonicCounterDriverInitialize
-
-[Sources.common]
- EmbeddedMonotonicCounter.c
-
-[Packages]
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- UefiRuntimeServicesTableLib
-
-[Protocols]
- gEfiMonotonicCounterArchProtocolGuid
-
-[Depex]
- TRUE
-
diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
deleted file mode 100644
index f557527281..0000000000
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ /dev/null
@@ -1,184 +0,0 @@
-#/** @file
-# Framework Module Development Environment Industry Standards
-#
-# This Package provides headers and libraries that conform to EFI/PI Industry standards.
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# Copyright (c) 2012-2015, ARM Ltd. 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]
- DEC_SPECIFICATION = 0x00010005
- PACKAGE_NAME = EmbeddedPkg
- PACKAGE_GUID = dea8e498-7e1b-47c1-b6fa-4bc04092587e
- PACKAGE_VERSION = 0.1
-
-
-################################################################################
-#
-# Include Section - list of Include Paths that are provided by this package.
-# Comments are used for Keywords and Module Types.
-#
-# Supported Module Types:
-# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
-#
-################################################################################
-[Includes.common]
- Include # Root include for the package
-
-[LibraryClasses.common]
- EfiFileLib|Include/Library/EfiFileLib.h
- PrePiLib|Include/Library/PrePiLib.h
- RealTimeClockLib|Include/Library/RealTimeClockLib.h
- EfiResetSystemLib|Include/Library/EfiResetSystemLib.h
- EblCmdLib|Include/Library/EblCmdLib.h
- EblAddExternalCommandLib|Include/Library/EblAddExternalCommandLib.h
- EblNetworkLib|Include/Library/EblNetworkLib.h
- GdbSerialLib|Include/Library/GdbSerialLib.h
- DebugAgentTimerLib|Include/Library/DebugAgentTimerLib.h
-
-
-[Guids.common]
- gEmbeddedTokenSpaceGuid = { 0xe0d8ca17, 0x4276, 0x4386, { 0xbb, 0x79, 0x48, 0xcb, 0x81, 0x3d, 0x3c, 0x4f }}
-
- ## FDT Configuration Table
- # Include/Guid/Fdt.h
- gFdtTableGuid = { 0xb1b621d5, 0xf19c, 0x41a5, { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
- # Include/Guid/FdtHob.h
- gFdtHobGuid = { 0x16958446, 0x19B7, 0x480B, { 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } }
- gFdtVariableGuid = { 0x25a4fd4a, 0x9703, 0x4ba9, { 0xa1, 0x90, 0xb7, 0xc8, 0x4e, 0xfb, 0x3e, 0x57 } }
-
-[Protocols.common]
- gHardwareInterruptProtocolGuid = { 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } }
- gEfiDebugSupportPeriodicCallbackProtocolGuid = { 0x9546e07c, 0x2cbb, 0x4c88, { 0x98, 0x6c, 0xcd, 0x34, 0x10, 0x86, 0xf0, 0x44 } }
- gEfiEblAddCommandProtocolGuid = { 0xaeda2428, 0x9a22, 0x4637, { 0x9b, 0x21, 0x54, 0x5e, 0x28, 0xfb, 0xb8, 0x29 } }
- gEmbeddedDeviceGuid = { 0xbf4b9d10, 0x13ec, 0x43dd, { 0x88, 0x80, 0xe9, 0xb, 0x71, 0x8f, 0x27, 0xde } }
- gEmbeddedExternalDeviceProtocolGuid = { 0x735F8C64, 0xD696, 0x44D0, { 0xBD, 0xF2, 0x44, 0x7F, 0xD0, 0x5A, 0x54, 0x06 }}
- gEmbeddedGpioProtocolGuid = { 0x17a0a3d7, 0xc0a5, 0x4635, { 0xbb, 0xd5, 0x07, 0x21, 0x87, 0xdf, 0xe2, 0xee }}
- gPeCoffLoaderProtocolGuid = { 0xB323179B, 0x97FB, 0x477E, { 0xB0, 0xFE, 0xD8, 0x85, 0x91, 0xFA, 0x11, 0xAB } }
- gEfiMmcHostProtocolGuid = { 0x3e591c00, 0x9e4a, 0x11df, {0x92, 0x44, 0x00, 0x02, 0xA5, 0xD5, 0xC5, 0x1B }}
- gAndroidFastbootTransportProtocolGuid = { 0x74bd9fe0, 0x8902, 0x11e3, {0xb9, 0xd3, 0xf7, 0x22, 0x38, 0xfc, 0x9a, 0x31}}
- gAndroidFastbootPlatformProtocolGuid = { 0x524685a0, 0x89a0, 0x11e3, {0x9d, 0x4d, 0xbf, 0xa9, 0xf6, 0xa4, 0x03, 0x08}}
- gUsbDeviceProtocolGuid = { 0x021bd2ca, 0x51d2, 0x11e3, {0x8e, 0x56, 0xb7, 0x54, 0x17, 0xc7, 0x0b, 0x44 }}
-
-[PcdsFeatureFlag.common]
- gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot|FALSE|BOOLEAN|0x00000001
- gEmbeddedTokenSpaceGuid.PcdEmbeddedDirCmd|TRUE|BOOLEAN|0x00000002
- gEmbeddedTokenSpaceGuid.PcdEmbeddedHobCmd|TRUE|BOOLEAN|0x00000003
- gEmbeddedTokenSpaceGuid.PcdEmbeddedHwDebugCmd|TRUE|BOOLEAN|0x00000004
- gEmbeddedTokenSpaceGuid.PcdEmbeddedIoEnable|FALSE|BOOLEAN|0x00000005
- gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd|FALSE|BOOLEAN|0x00000006
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPciDebugCmd|FALSE|BOOLEAN|0x00000041
- gEmbeddedTokenSpaceGuid.PcdEmbeddedProbeRemovable|TRUE|BOOLEAN|0x00000052
-
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE|BOOLEAN|0x0000001b
- gEmbeddedTokenSpaceGuid.PcdCacheEnable|FALSE|BOOLEAN|0x00000042
- gEmbeddedTokenSpaceGuid.PcdGdbSerial|FALSE|BOOLEAN|0x00000053
- # Enable the development specific features
- gEmbeddedTokenSpaceGuid.PcdOverridePlatformFdt|TRUE|BOOLEAN|0x00000054
- # Add 'dumpfdt' EFI Shell command
- gEmbeddedTokenSpaceGuid.PcdDumpFdtShellCommand|TRUE|BOOLEAN|0x00000056
-
- gEmbeddedTokenSpaceGuid.PcdSataSiI3132FeaturePMPSupport|FALSE|BOOLEAN|0x00000050
- gEmbeddedTokenSpaceGuid.PcdSataSiI3132FeatureDirectCommandIssuing|FALSE|BOOLEAN|0x00000051
-
-[PcdsFixedAtBuild.common]
- gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand|L""|VOID*|0x00000007
- gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor|0x07|UINT32|0x00000008
- gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize|0x10000|UINT32|0x00000009
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"Ebl"|VOID*|0x00000034
-
- gEmbeddedTokenSpaceGuid.PcdPrePiHobBase|131072|UINT32|0x00000040
- gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0|UINT32|0x0000000b
- gEmbeddedTokenSpaceGuid.PcdPrePiStackSize|131072|UINT32|0x0000000c
-
- gEmbeddedTokenSpaceGuid.PcdMemoryBase|0x0|UINT32|0x0000004e
- gEmbeddedTokenSpaceGuid.PcdMemorySize|0x0|UINT32|0x0000004f
-
- gEmbeddedTokenSpaceGuid.PcdFlashFvMainBase|0x0|UINT32|0x00000043
- gEmbeddedTokenSpaceGuid.PcdFlashFvMainOffset|0x0|UINT32|0x00000044
- gEmbeddedTokenSpaceGuid.PcdFlashFvMainSize|0x0|UINT32|0x00000045
-
-# Used to help reduce fragmentation in the EFI memory map
-# EFI Pages (4K) are the units used
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0|UINT32|0x00000012
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0|UINT32|0x00000013
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0|UINT32|0x00000014
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0|UINT32|0x00000015
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0|UINT32|0x00000016
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|0|UINT32|0x00000017
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|0|UINT32|0x00000018
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|0|UINT32|0x00000019
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0|UINT32|0x0000001a
-
- gEmbeddedTokenSpaceGuid.PcdTimerBaseAddress|0x3c700000|UINT32|0x0000001c
- gEmbeddedTokenSpaceGuid.PcdTimerVector|7|UINT32|0x0000001d
- gEmbeddedTokenSpaceGuid.PcdTimerPeriod|100000|UINT32|0x0000001e
- gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress|0x38e00000|UINT32|0x0000001f
-
- gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|100|UINT32|0x00000020
-
- gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress|0xffff0000|UINT32|0x00000030
- gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize|0x0000000|UINT32|0x00000031
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterFrequencyInHz|0x0000000|UINT64|0x00000032
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterPeriodInNanoseconds|0x0000000|UINT32|0x00000033
-
-# Shell characteristics
- gEmbeddedTokenSpaceGuid.PcdEmbeddedShellCharacterEcho|TRUE|BOOLEAN|0x00000046
-
- gEmbeddedTokenSpaceGuid.PcdGdbBaudRate|115200|UINT64|0x00000047
- gEmbeddedTokenSpaceGuid.PcdGdbDataBits|8|UINT8|0x00000048
- gEmbeddedTokenSpaceGuid.PcdGdbParity|1|UINT8|0x00000049
- gEmbeddedTokenSpaceGuid.PcdGdbStopBits|1|UINT8|0x0000004a
- gEmbeddedTokenSpaceGuid.PcdGdbUartPort|0x3f8|UINT32|0x0000004b
- gEmbeddedTokenSpaceGuid.PcdGdbMaxPacketRetryCount|10000000|UINT32|0x0000004c
- gEmbeddedTokenSpaceGuid.PcdGdbTimerPeriodMilliseconds|250|UINT32|0x0000004d
-
- # LAN9118 Ethernet Driver PCDs
- gEmbeddedTokenSpaceGuid.PcdLan9118DxeBaseAddress|0x0|UINT32|0x00000025
- gEmbeddedTokenSpaceGuid.PcdLan9118DefaultMacAddress|0x0|UINT64|0x00000026
-
- #
- # Android FastBoot
- #
-
- # The Android FastBoot utility has hard-coded USB Vendor IDs that it recognises
- # (and 0xf00d isn't one of them!).
- # You'll need to pass it "-i 0xf00d" to get it to recognise this device.
- gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbVendorId|0xf00d|UINT32|0x00000022
- gEmbeddedTokenSpaceGuid.PcdAndroidFastbootUsbProductId|0xbeef|UINT32|0x00000023
- gEmbeddedTokenSpaceGuid.PcdAndroidFastbootTcpPort|1234|UINT32|0x00000024
-
-
-[PcdsFixedAtBuild.ARM]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|32|UINT8|0x00000010
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0|UINT8|0x00000011
-
- # ISP1761 USB OTG Controller
- gEmbeddedTokenSpaceGuid.PcdIsp1761BaseAddress|0|UINT32|0x00000021
-
-[PcdsFixedAtBuild.AARCH64]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|48|UINT8|0x00000010
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0|UINT8|0x00000011
-
- # ISP1761 USB OTG Controller
- gEmbeddedTokenSpaceGuid.PcdIsp1761BaseAddress|0|UINT64|0x00000021
-
-[PcdsFixedAtBuild.IA32]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|36|UINT8|0x00000010
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16|UINT8|0x00000011
-
-[PcdsFixedAtBuild.X64]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|52|UINT8|0x00000010
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16|UINT8|0x00000011
-
-[PcdsFixedAtBuild.common, PcdsDynamic.common]
- gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055
diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
deleted file mode 100644
index a5507ed220..0000000000
--- a/EmbeddedPkg/EmbeddedPkg.dsc
+++ /dev/null
@@ -1,290 +0,0 @@
-#/** @file
-# Embedded Package
-#
-#
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
-# Copyright (c) 2012-2015, ARM Ltd. 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|AARCH64
- 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
-
- 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|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.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
-
- AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
- FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
-
- # Shell libraries
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
-
- # Networking Requirements
- NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
- UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.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, LibraryClasses.AARCH64]
- ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
- BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
- SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
-
- # Add support for GCC stack protector
- NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
-
-[LibraryClasses.ARM]
- ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
-
-[LibraryClasses.AARCH64]
- ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64Lib.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""
- 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.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
-
-[BuildOptions]
- RVCT:*_*_ARM_PLATFORM_FLAGS == --cpu=7-A.security
-
-
-################################################################################
-#
-# 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/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/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
- EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
- EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf {
- <LibraryClasses>
- TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
- }
-
- EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
-
- # FDT installation
- EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf {
- <LibraryClasses>
- # It depends on BdsLib that depends on TimerLib
- TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
- }
-
- EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf {
- <LibraryClasses>
- # It depends on BdsLib that depends on TimerLib
- TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
- }
- EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf
- EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcpDxe.inf
-
- # Drivers
- EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.inf
- EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf
- EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
-
-[Components.IA32, Components.X64, Components.IPF, Components.ARM]
- EmbeddedPkg/GdbStub/GdbStub.inf
diff --git a/EmbeddedPkg/EmbeddedPkg.fdf b/EmbeddedPkg/EmbeddedPkg.fdf
deleted file mode 100644
index c84a5193ef..0000000000
--- a/EmbeddedPkg/EmbeddedPkg.fdf
+++ /dev/null
@@ -1,141 +0,0 @@
-# This is Ebl FDF file
-#
-# Copyright (c) 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.
-#
-
-################################################################################
-#
-# FV Section
-#
-# [FV] section is used to define what components or modules are placed within a flash
-# device file. This section also defines order the components and modules are positioned
-# within the image. The [FV] section consists of define statements, set statements and
-# module statements.
-#
-################################################################################
-[FV.FvLoad]
-FvAlignment = 16 #FV alignment and FV attributes setting.
-ERASE_POLARITY = 1
-MEMORY_MAPPED = TRUE
-STICKY_WRITE = TRUE
-LOCK_CAP = TRUE
-LOCK_STATUS = TRUE
-WRITE_DISABLED_CAP = TRUE
-WRITE_ENABLED_CAP = TRUE
-WRITE_STATUS = TRUE
-WRITE_LOCK_CAP = TRUE
-WRITE_LOCK_STATUS = TRUE
-READ_DISABLED_CAP = TRUE
-READ_ENABLED_CAP = TRUE
-READ_STATUS = TRUE
-READ_LOCK_CAP = TRUE
-READ_LOCK_STATUS = TRUE
-
-################################################################################
-#
-# The INF statements point to module INF files, which will be placed into this FV image.
-# Parsing tools will scan the INF file to determine the type of component or module.
-# The component or module type is used to reference the standard rules
-# defined elsewhere in the FDF file.
-#
-# The format for INF statements is:
-# INF $(PathAndInfFileName)
-#
-################################################################################
-INF EmbeddedPkg/Ebl/Ebl.inf
-
-################################################################################
-#
-# Rules are use with the [FV] section's module INF type to define
-# how an FFS file is created for a given INF file. The following Rule are the default
-# rules for the different module type. User can add the customized rules to define the
-# content of the FFS file.
-#
-################################################################################
-
-
-############################################################################
-# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section #
-############################################################################
-#
-#[Rule.Common.DXE_DRIVER]
-# FILE DRIVER = $(NAMED_GUID) {
-# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
-# COMPRESS PI_STD {
-# GUIDED {
-# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
-# UI STRING="$(MODULE_NAME)" Optional
-# VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
-# }
-# }
-# }
-#
-############################################################################
-
-[Rule.Common.SEC]
- FILE SEC = $(NAMED_GUID) {
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- }
-
-[Rule.Common.PEI_CORE]
- FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING ="$(MODULE_NAME)" Optional
- }
-
-[Rule.Common.PEIM]
- FILE PEIM = $(NAMED_GUID) {
- PEI_DEPEX PEI_DEPEX Optional $(MODULE_NAME).depex
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING="$(MODULE_NAME)" Optional
- }
-
-[Rule.Common.PEIM.TIANOCOMPRESSED]
- FILE PEIM = $(NAMED_GUID) DEBUG_MYTOOLS_IA32 {
- PEI_DEPEX PEI_DEPEX Optional $(MODULE_NAME).depex
- GUIDED A31280AD-481E-41B6-95E8-127F4C984779 PROCESSING_REQUIRED = TRUE {
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING="$(MODULE_NAME)" Optional
- }
- }
-
-[Rule.Common.DXE_CORE]
- FILE DXE_CORE = $(NAMED_GUID) {
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING="$(MODULE_NAME)" Optional
- }
-
-[Rule.Common.UEFI_DRIVER]
- FILE DRIVER = $(NAMED_GUID) {
- DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING="$(MODULE_NAME)" Optional
- }
-
-[Rule.Common.DXE_DRIVER]
- FILE DRIVER = $(NAMED_GUID) {
- DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING="$(MODULE_NAME)" Optional
- }
-
-[Rule.Common.DXE_RUNTIME_DRIVER]
- FILE DRIVER = $(NAMED_GUID) {
- DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING="$(MODULE_NAME)" Optional
- }
-
-[Rule.Common.UEFI_APPLICATION]
- FILE APPLICATION = $(NAMED_GUID) {
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
- UI STRING="$(MODULE_NAME)" Optional
- }
diff --git a/EmbeddedPkg/GdbStub/Arm/Processor.c b/EmbeddedPkg/GdbStub/Arm/Processor.c
deleted file mode 100644
index 96b4f570c4..0000000000
--- a/EmbeddedPkg/GdbStub/Arm/Processor.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/** @file
- Processor specific parts of the GDB stub
-
- 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 <GdbStubInternal.h>
-#include <Library/CacheMaintenanceLib.h>
-#include <Library/PrintLib.h>
-
-//
-// Array of exception types that need to be hooked by the debugger
-// (efi, gdb) //efi number
-//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_ARM_SOFTWARE_INTERRUPT, GDB_SIGTRAP }
-// { EXCEPT_ARM_UNDEFINED_INSTRUCTION, GDB_SIGTRAP },
-// { EXCEPT_ARM_PREFETCH_ABORT, GDB_SIGTRAP },
-// { EXCEPT_ARM_DATA_ABORT, GDB_SIGEMT },
-// { EXCEPT_ARM_RESERVED, GDB_SIGILL }
-};
-
-// Shut up some annoying RVCT warnings
-#ifdef __CC_ARM
-#pragma diag_suppress 1296
-#endif
-
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R0),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R1),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R2),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R3),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R4),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R5),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R6),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R7),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R8),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R9),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R10),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R11),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R12),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, SP),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, LR),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, PC),
- 0x00000F01, // f0
- 0x00000F02,
- 0x00000F03,
- 0x00000F11, // f1
- 0x00000F12,
- 0x00000F13,
- 0x00000F21, // f2
- 0x00000F22,
- 0x00000F23,
- 0x00000F31, // f3
- 0x00000F32,
- 0x00000F33,
- 0x00000F41, // f4
- 0x00000F42,
- 0x00000F43,
- 0x00000F51, // f5
- 0x00000F52,
- 0x00000F53,
- 0x00000F61, // f6
- 0x00000F62,
- 0x00000F63,
- 0x00000F71, // f7
- 0x00000F72,
- 0x00000F73,
- 0x00000FFF, // fps
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, CPSR)
-};
-
-// restore warnings for RVCT
-#ifdef __CC_ARM
-#pragma diag_default 1296
-#endif
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- )
-{
- return sizeof (gExceptionType) / sizeof (EFI_EXCEPTION_TYPE_ENTRY);
-}
-
-
-/**
- Return the number of entries in the gRegisters[]
-
- @retval UINTN, the number of entries (registers) in the gRegisters[] array.
- **/
-UINTN
-MaxRegisterCount (
- VOID
- )
-{
- return sizeof (gRegisterOffsets) / sizeof (UINTN);
-}
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported
-
-**/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- )
-{
- if (Isa == IsaArm) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-
-/**
- This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
- It is, by default, set to find the register pointer of the ARM member
- @param SystemContext Register content at time of the exception
- @param RegNumber The register to which we want to find a pointer
- @retval the pointer to the RegNumber-th pointer
- **/
-UINTN *
-FindPointerToRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- )
-{
- UINT8 *TempPtr;
- ASSERT(gRegisterOffsets[RegNumber] < 0xF00);
- TempPtr = ((UINT8 *)SystemContext.SystemContextArm) + gRegisterOffsets[RegNumber];
- return (UINT32 *)TempPtr;
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to read
- @param OutBufPtr pointer to the output buffer's end. the new data will be added from this point on.
- @retval the pointer to the next character of the output buffer that is available to be written on.
- **/
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- )
-{
- UINTN RegSize;
- CHAR8 Char;
-
- if (gRegisterOffsets[RegNumber] > 0xF00) {
- AsciiSPrint (OutBufPtr, 9, "00000000");
- OutBufPtr += 8;
- return OutBufPtr;
- }
-
- RegSize = 0;
- while (RegSize < 32) {
- Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- RegSize = RegSize + 8;
- }
- return OutBufPtr;
-}
-
-
-/**
- Reads the n-th register's value into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
-
- if (RegNumber >= MaxRegisterCount ()) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
-
- OutBufPtr = OutBuffer;
- OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket (OutBuffer);
-}
-
-
-/**
- Reads the general registers into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINTN Index;
- CHAR8 *OutBuffer;
- CHAR8 *OutBufPtr;
- UINTN RegisterCount = MaxRegisterCount ();
-
- // It is not safe to allocate pool here....
- OutBuffer = AllocatePool ((RegisterCount * 8) + 1); // 8 bytes per register in string format plus a null to terminate
- OutBufPtr = OutBuffer;
- for (Index = 0; Index < RegisterCount; Index++) {
- OutBufPtr = BasicReadRegister (SystemContext, Index, OutBufPtr);
- }
-
- *OutBufPtr = '\0';
- SendPacket (OutBuffer);
- FreePool (OutBuffer);
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to write
- @param InBufPtr pointer to the output buffer. the new data will be extracted from the input buffer from this point on.
- @retval the pointer to the next character of the input buffer that can be used
- **/
-CHAR8
-*BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- )
-{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT32 NewValue; // the new value of the RegNumber-th Register
-
- if (gRegisterOffsets[RegNumber] > 0xF00) {
- return InBufPtr + 8;
- }
-
- NewValue = 0;
- RegSize = 0;
- while (RegSize < 32) {
- TempValue = HexCharToInt (*InBufPtr++);
-
- if ((INTN)TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt (*InBufPtr++);
-
- if ((INTN)TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
- }
- *(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
- return InBufPtr;
-}
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
- @param SystemContext Register content at time of the exception
- @param InBuffer Ponter to the input buffer received from gdb server
- **/
-VOID
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
-
- // find the register number to write
- InBufPtr = &InBuffer[1];
- RegNumBufPtr = RegNumBuffer;
- while (*InBufPtr != '=') {
- *RegNumBufPtr++ = *InBufPtr++;
- }
- *RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
-
- // check if this is a valid Register Number
- if (RegNumber >= MaxRegisterCount ()) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
- InBufPtr++; // skips the '=' character
- BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
-}
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-
-VOID
-EFIAPI
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
- UINTN MinLength;
- UINTN RegisterCount = MaxRegisterCount ();
-
- MinLength = (RegisterCount * 8) + 1; // 'G' plus the registers in ASCII format
-
- if (AsciiStrLen (InBuffer) < MinLength) {
- //Bad message. Message is not the right length
- SendError (GDB_EBADBUFSIZE);
- return;
- }
-
- InBufPtr = &InBuffer[1];
-
- // Read the new values for the registers from the input buffer to an array, NewValueArray.
- // The values in the array are in the gdb ordering
- for (i = 0; i < RegisterCount; i++) {
- InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
- }
-
- SendSuccess ();
-}
-
-// What about Thumb?
-// Use SWI 0xdbdbdb as the debug instruction
-#define GDB_ARM_BKPT 0xefdbdbdb
-
-BOOLEAN mSingleStepActive = FALSE;
-UINT32 mSingleStepPC;
-UINT32 mSingleStepData;
-UINTN mSingleStepDataSize;
-
-typedef struct {
- LIST_ENTRY Link;
- UINT64 Signature;
- UINT32 Address;
- UINT32 Instruction;
-} ARM_SOFTWARE_BREAKPOINT;
-
-#define ARM_SOFTWARE_BREAKPOINT_SIGNATURE SIGNATURE_64('A', 'R', 'M', 'B', 'R', 'K', 'P', 'T')
-#define ARM_SOFTWARE_BREAKPOINT_FROM_LINK(a) CR(a, ARM_SOFTWARE_BREAKPOINT, Link, ARM_SOFTWARE_BREAKPOINT_SIGNATURE)
-
-LIST_ENTRY BreakpointList;
-
-/**
- Insert Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-AddSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- if (mSingleStepActive) {
- // Currently don't support nesting
- return;
- }
- mSingleStepActive = TRUE;
-
- mSingleStepPC = SystemContext.SystemContextArm->PC;
-
- mSingleStepDataSize = sizeof (UINT32);
- mSingleStepData = (*(UINT32 *)mSingleStepPC);
- *(UINT32 *)mSingleStepPC = GDB_ARM_BKPT;
- if (*(UINT32 *)mSingleStepPC != GDB_ARM_BKPT) {
- // For some reason our breakpoint did not take
- mSingleStepActive = FALSE;
- }
-
- InvalidateInstructionCacheRange ((VOID *)mSingleStepPC, mSingleStepDataSize);
- //DEBUG((EFI_D_ERROR, "AddSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, mSingleStepData, *(UINT32 *)mSingleStepPC));
-}
-
-
-/**
- Remove Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-RemoveSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- if (!mSingleStepActive) {
- return;
- }
-
- if (mSingleStepDataSize == sizeof (UINT16)) {
- *(UINT16 *)mSingleStepPC = (UINT16)mSingleStepData;
- } else {
- //DEBUG((EFI_D_ERROR, "RemoveSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, *(UINT32 *)mSingleStepPC, mSingleStepData));
- *(UINT32 *)mSingleStepPC = mSingleStepData;
- }
- InvalidateInstructionCacheRange ((VOID *)mSingleStepPC, mSingleStepDataSize);
- mSingleStepActive = FALSE;
-}
-
-
-
-/**
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextArm->PC = AsciiStrHexToUintn (&PacketData[1]);
- }
-}
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- SendNotSupported ();
-}
-
-UINTN
-GetBreakpointDataAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- return 0;
-}
-
-UINTN
-GetBreakpointDetected (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- return 0;
-}
-
-BREAK_TYPE
-GetBreakpointType (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- return NotSupported;
-}
-
-ARM_SOFTWARE_BREAKPOINT *
-SearchBreakpointList (
- IN UINT32 Address
- )
-{
- LIST_ENTRY *Current;
- ARM_SOFTWARE_BREAKPOINT *Breakpoint;
-
- Current = GetFirstNode (&BreakpointList);
- while (!IsNull (&BreakpointList, Current)) {
- Breakpoint = ARM_SOFTWARE_BREAKPOINT_FROM_LINK(Current);
-
- if (Address == Breakpoint->Address) {
- return Breakpoint;
- }
-
- Current = GetNextNode (&BreakpointList, Current);
- }
-
- return NULL;
-}
-
-VOID
-SetBreakpoint (
- IN UINT32 Address
- )
-{
- ARM_SOFTWARE_BREAKPOINT *Breakpoint;
-
- Breakpoint = SearchBreakpointList (Address);
-
- if (Breakpoint != NULL) {
- return;
- }
-
- // create and fill breakpoint structure
- Breakpoint = AllocatePool (sizeof(ARM_SOFTWARE_BREAKPOINT));
-
- Breakpoint->Signature = ARM_SOFTWARE_BREAKPOINT_SIGNATURE;
- Breakpoint->Address = Address;
- Breakpoint->Instruction = *(UINT32 *)Address;
-
- // Add it to the list
- InsertTailList (&BreakpointList, &Breakpoint->Link);
-
- // Insert the software breakpoint
- *(UINT32 *)Address = GDB_ARM_BKPT;
- InvalidateInstructionCacheRange ((VOID *)Address, 4);
-
- //DEBUG((EFI_D_ERROR, "SetBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, Breakpoint->Instruction, *(UINT32 *)Address));
-}
-
-VOID
-ClearBreakpoint (
- IN UINT32 Address
- )
-{
- ARM_SOFTWARE_BREAKPOINT *Breakpoint;
-
- Breakpoint = SearchBreakpointList (Address);
-
- if (Breakpoint == NULL) {
- return;
- }
-
- // Add it to the list
- RemoveEntryList (&Breakpoint->Link);
-
- // Restore the original instruction
- *(UINT32 *)Address = Breakpoint->Instruction;
- InvalidateInstructionCacheRange ((VOID *)Address, 4);
-
- //DEBUG((EFI_D_ERROR, "ClearBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, GDB_ARM_BKPT, *(UINT32 *)Address));
-
- FreePool (Breakpoint);
-}
-
-VOID
-EFIAPI
-InsertBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN ErrorCode;
-
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
- case 0: //Software breakpoint
- break;
-
- default :
- DEBUG((EFI_D_ERROR, "Insert breakpoint default: %x\n", Type));
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- SetBreakpoint (Address);
-
- SendSuccess ();
-}
-
-VOID
-EFIAPI
-RemoveBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN ErrorCode;
-
- //Parse breakpoint packet data
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
- case 0: //Software breakpoint
- break;
-
- default:
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- ClearBreakpoint (Address);
-
- SendSuccess ();
-}
-
-VOID
-InitializeProcessor (
- VOID
- )
-{
- // Initialize breakpoint list
- InitializeListHead (&BreakpointList);
-}
-
-BOOLEAN
-ValidateAddress (
- IN VOID *Address
- )
-{
- if ((UINT32)Address < 0x80000000) {
- return FALSE;
- } else {
- return TRUE;
- }
-}
-
-BOOLEAN
-ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINT32 ExceptionAddress;
- UINT32 Instruction;
-
- // Is it a debugger SWI?
- ExceptionAddress = SystemContext.SystemContextArm->PC -= 4;
- Instruction = *(UINT32 *)ExceptionAddress;
- if (Instruction != GDB_ARM_BKPT) {
- return FALSE;
- }
-
- // Special for SWI-based exception handling. SWI sets up the context
- // to return to the instruction following the SWI instruction - NOT what we want
- // for a debugger!
- SystemContext.SystemContextArm->PC = ExceptionAddress;
-
- return TRUE;
-}
-
diff --git a/EmbeddedPkg/GdbStub/GdbStub.c b/EmbeddedPkg/GdbStub/GdbStub.c
deleted file mode 100644
index 213038ad08..0000000000
--- a/EmbeddedPkg/GdbStub/GdbStub.c
+++ /dev/null
@@ -1,1257 +0,0 @@
-/** @file
- UEFI driver that implements a GDB stub
-
- Note: Any code in the path of the Serial IO output can not call DEBUG as will
- will blow out the stack. Serial IO calls DEBUG, debug calls Serail IO, ...
-
-
- 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 <GdbStubInternal.h>
-#include <Protocol/DebugPort.h>
-
-
-UINTN gMaxProcessorIndex = 0;
-
-//
-// Buffers for basic gdb communication
-//
-CHAR8 gInBuffer[MAX_BUF_SIZE];
-CHAR8 gOutBuffer[MAX_BUF_SIZE];
-
-// Assume gdb does a "qXfer:libraries:read::offset,length" when it connects so we can default
-// this value to FALSE. Since gdb can reconnect its self a global default is not good enough
-BOOLEAN gSymbolTableUpdate = FALSE;
-EFI_EVENT gEvent;
-VOID *gGdbSymbolEventHandlerRegistration = NULL;
-
-//
-// Globals for returning XML from qXfer:libraries:read packet
-//
-UINTN gPacketqXferLibraryOffset = 0;
-UINTN gEfiDebugImageTableEntry = 0;
-EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
-EFI_DEBUG_IMAGE_INFO *gDebugTable = NULL;
-CHAR8 gXferLibraryBuffer[2000];
-
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexToStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-
-
-VOID
-EFIAPI
-GdbSymbolEventHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
-}
-
-
-/**
- The user Entry Point for Application. The user code starts with this function
- as the real entry point for the image goes into a library that calls this
- function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-GdbStubEntry (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;
- UINTN HandleCount;
- EFI_HANDLE *Handles;
- UINTN Index;
- UINTN Processor;
- BOOLEAN IsaSupported;
-
- Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);
- if (EFI_ERROR (Status)) {
- gDebugImageTableHeader = NULL;
- }
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiDebugSupportProtocolGuid,
- NULL,
- &HandleCount,
- &Handles
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Debug Support Protocol not found\n"));
-
- return Status;
- }
-
- DebugSupport = NULL;
- IsaSupported = FALSE;
- do {
- HandleCount--;
- Status = gBS->HandleProtocol (
- Handles[HandleCount],
- &gEfiDebugSupportProtocolGuid,
- (VOID **) &DebugSupport
- );
- if (!EFI_ERROR (Status)) {
- if (CheckIsa (DebugSupport->Isa)) {
- // We found what we are looking for so break out of the loop
- IsaSupported = TRUE;
- break;
- }
- }
- } while (HandleCount > 0);
- FreePool (Handles);
-
- if (!IsaSupported) {
- DEBUG ((EFI_D_ERROR, "Debug Support Protocol does not support our ISA\n"));
-
- return EFI_NOT_FOUND;
- }
-
- Status = DebugSupport->GetMaximumProcessorIndex (DebugSupport, &gMaxProcessorIndex);
- ASSERT_EFI_ERROR (Status);
-
- DEBUG ((EFI_D_INFO, "Debug Support Protocol ISA %x\n", DebugSupport->Isa));
- DEBUG ((EFI_D_INFO, "Debug Support Protocol Processor Index %d\n", gMaxProcessorIndex));
-
- // Call processor-specific init routine
- InitializeProcessor ();
-
- for (Processor = 0; Processor <= gMaxProcessorIndex; Processor++) {
- for (Index = 0; Index < MaxEfiException (); Index++) {
- Status = DebugSupport->RegisterExceptionCallback (DebugSupport, Processor, GdbExceptionHandler, gExceptionType[Index].Exception);
- ASSERT_EFI_ERROR (Status);
- }
- //
- // Current edk2 DebugPort is not interrupt context safe so we can not use it
- //
- Status = DebugSupport->RegisterPeriodicCallback (DebugSupport, Processor, GdbPeriodicCallBack);
- ASSERT_EFI_ERROR (Status);
- }
-
- //
- // This even fires every time an image is added. This allows the stub to know when gdb needs
- // to update the symbol table.
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- GdbSymbolEventHandler,
- NULL,
- &gEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Register for protocol notifications on this event
- //
- Status = gBS->RegisterProtocolNotify (
- &gEfiLoadedImageProtocolGuid,
- gEvent,
- &gGdbSymbolEventHandlerRegistration
- );
- ASSERT_EFI_ERROR (Status);
-
-
- if (PcdGetBool (PcdGdbSerial)) {
- GdbInitializeSerialConsole ();
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Transfer length bytes of input buffer, starting at Address, to memory.
-
- @param length the number of the bytes to be transferred/written
- @param *address the start address of the transferring/writing the memory
- @param *new_data the new data to be written to memory
- **/
-
-VOID
-TransferFromInBufToMem (
- IN UINTN Length,
- IN unsigned char *Address,
- IN CHAR8 *NewData
- )
-{
- CHAR8 c1;
- CHAR8 c2;
-
- while (Length-- > 0) {
- c1 = (CHAR8)HexCharToInt (*NewData++);
- c2 = (CHAR8)HexCharToInt (*NewData++);
-
- if ((c1 < 0) || (c2 < 0)) {
- Print ((CHAR16 *)L"Bad message from write to memory..\n");
- SendError (GDB_EBADMEMDATA);
- return;
- }
- *Address++ = (UINT8)((c1 << 4) + c2);
- }
-
- SendSuccess();
-}
-
-
-/**
- Transfer Length bytes of memory starting at Address to an output buffer, OutBuffer. This function will finally send the buffer
- as a packet.
-
- @param Length the number of the bytes to be transferred/read
- @param *address pointer to the start address of the transferring/reading the memory
- **/
-
-VOID
-TransferFromMemToOutBufAndSend (
- IN UINTN Length,
- IN unsigned char *Address
- )
-{
- // there are Length bytes and every byte is represented as 2 hex chars
- CHAR8 OutBuffer[MAX_BUF_SIZE];
- CHAR8 *OutBufPtr; // pointer to the output buffer
- CHAR8 Char;
-
- if (ValidateAddress(Address) == FALSE) {
- SendError(14);
- return;
- }
-
- OutBufPtr = OutBuffer;
- while (Length > 0) {
-
- Char = mHexToStr[*Address >> 4];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- Char = mHexToStr[*Address & 0x0f];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- Address++;
- Length--;
- }
-
- *OutBufPtr = '\0' ; // the end of the buffer
- SendPacket (OutBuffer);
-}
-
-
-
-/**
- Send a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up
- in an infinit loop. This is so if you unplug the debugger code just keeps running
-
- @param PacketData Payload data for the packet
-
-
- @retval Number of bytes of packet data sent.
-
-**/
-UINTN
-SendPacket (
- IN CHAR8 *PacketData
- )
-{
- UINT8 CheckSum;
- UINTN Timeout;
- CHAR8 *Ptr;
- CHAR8 TestChar;
- UINTN Count;
-
- Timeout = PcdGet32 (PcdGdbMaxPacketRetryCount);
-
- Count = 0;
- do {
-
- Ptr = PacketData;
-
- if (Timeout-- == 0) {
- // Only try a finite number of times so we don't get stuck in the loop
- return Count;
- }
-
- // Packet prefix
- GdbPutChar ('$');
-
- for (CheckSum = 0, Count =0 ; *Ptr != '\0'; Ptr++, Count++) {
- GdbPutChar (*Ptr);
- CheckSum = CheckSum + *Ptr;
- }
-
- // Packet terminating character and checksum
- GdbPutChar ('#');
- GdbPutChar (mHexToStr[CheckSum >> 4]);
- GdbPutChar (mHexToStr[CheckSum & 0x0F]);
-
- TestChar = GdbGetChar ();
- } while (TestChar != '+');
-
- return Count;
-}
-
-/**
- Receive a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed.
- (In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)
-
- If an ack '+' is not sent resend the packet
-
- @param PacketData Payload data for the packet
-
- @retval Number of bytes of packet data received.
-
-**/
-UINTN
-ReceivePacket (
- OUT CHAR8 *PacketData,
- IN UINTN PacketDataSize
- )
-{
- UINT8 CheckSum;
- UINTN Index;
- CHAR8 Char;
- CHAR8 SumString[3];
- CHAR8 TestChar;
-
- ZeroMem (PacketData, PacketDataSize);
-
- for (;;) {
- // wait for the start of a packet
- TestChar = GdbGetChar ();
- while (TestChar != '$') {
- TestChar = GdbGetChar ();
- };
-
- retry:
- for (Index = 0, CheckSum = 0; Index < (PacketDataSize - 1); Index++) {
- Char = GdbGetChar ();
- if (Char == '$') {
- goto retry;
- }
- if (Char == '#') {
- break;
- }
-
- PacketData[Index] = Char;
- CheckSum = CheckSum + Char;
- }
- PacketData[Index] = '\0';
-
- if (Index == PacketDataSize) {
- continue;
- }
-
- SumString[0] = GdbGetChar ();
- SumString[1] = GdbGetChar ();
- SumString[2] = '\0';
-
- if (AsciiStrHexToUintn (SumString) == CheckSum) {
- // Ack: Success
- GdbPutChar ('+');
-
- // Null terminate the callers string
- PacketData[Index] = '\0';
- return Index;
- } else {
- // Ack: Failure
- GdbPutChar ('-');
- }
- }
-
- //return 0;
-}
-
-
-/**
- Empties the given buffer
- @param Buf pointer to the first element in buffer to be emptied
- **/
-VOID
-EmptyBuffer (
- IN CHAR8 *Buf
- )
-{
- *Buf = '\0';
-}
-
-
-/**
- Converts an 8-bit Hex Char into a INTN.
-
- @param Char the hex character to be converted into UINTN
- @retval a INTN, from 0 to 15, that corressponds to Char
- -1 if Char is not a hex character
- **/
-INTN
-HexCharToInt (
- IN CHAR8 Char
- )
-{
- if ((Char >= 'A') && (Char <= 'F')) {
- return Char - 'A' + 10;
- } else if ((Char >= 'a') && (Char <= 'f')) {
- return Char - 'a' + 10;
- } else if ((Char >= '0') && (Char <= '9')) {
- return Char - '0';
- } else { // if not a hex value, return a negative value
- return -1;
- }
-}
-
- // 'E' + the biggest error number is 255, so its 2 hex digits + buffer end
-CHAR8 *gError = "E__";
-
-/** 'E NN'
- Send an error with the given error number after converting to hex.
- The error number is put into the buffer in hex. '255' is the biggest errno we can send.
- ex: 162 will be sent as A2.
-
- @param errno the error number that will be sent
- **/
-VOID
-EFIAPI
-SendError (
- IN UINT8 ErrorNum
- )
-{
- //
- // Replace _, or old data, with current errno
- //
- gError[1] = mHexToStr [ErrorNum >> 4];
- gError[2] = mHexToStr [ErrorNum & 0x0f];
-
- SendPacket (gError); // send buffer
-}
-
-
-
-/**
- Send 'OK' when the function is done executing successfully.
- **/
-VOID
-EFIAPI
-SendSuccess (
- VOID
- )
-{
- SendPacket ("OK"); // send buffer
-}
-
-
-/**
- Send empty packet to specify that particular command/functionality is not supported.
- **/
-VOID
-EFIAPI
-SendNotSupported (
- VOID
- )
-{
- SendPacket ("");
-}
-
-
-/**
- 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
-GdbSendTSignal (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINT8 GdbExceptionType
- )
-{
- CHAR8 TSignalBuffer[128];
- CHAR8 *TSignalPtr;
- UINTN BreakpointDetected;
- BREAK_TYPE BreakType;
- UINTN DataAddress;
- CHAR8 *WatchStrPtr = NULL;
- UINTN RegSize;
-
- TSignalPtr = &TSignalBuffer[0];
-
- //Construct TSignal packet
- *TSignalPtr++ = 'T';
-
- //
- // replace _, or previous value, with Exception type
- //
- *TSignalPtr++ = mHexToStr [GdbExceptionType >> 4];
- *TSignalPtr++ = mHexToStr [GdbExceptionType & 0x0f];
-
- if (GdbExceptionType == GDB_SIGTRAP) {
- if (gSymbolTableUpdate) {
- //
- // We can only send back on reason code. So if the flag is set it means the breakpoint is from our event handler
- //
- WatchStrPtr = "library:;";
- while (*WatchStrPtr != '\0') {
- *TSignalPtr++ = *WatchStrPtr++;
- }
- gSymbolTableUpdate = FALSE;
- } else {
-
-
- //
- // possible n:r pairs
- //
-
- //Retrieve the breakpoint number
- BreakpointDetected = GetBreakpointDetected (SystemContext);
-
- //Figure out if the exception is happend due to watch, rwatch or awatch.
- BreakType = GetBreakpointType (SystemContext, BreakpointDetected);
-
- //INFO: rwatch is not supported due to the way IA32 debug registers work
- if ((BreakType == DataWrite) || (BreakType == DataRead) || (BreakType == DataReadWrite)) {
-
- //Construct n:r pair
- DataAddress = GetBreakpointDataAddress (SystemContext, BreakpointDetected);
-
- //Assign appropriate buffer to print particular watchpoint type
- if (BreakType == DataWrite) {
- WatchStrPtr = "watch";
- } else if (BreakType == DataRead) {
- WatchStrPtr = "rwatch";
- } else if (BreakType == DataReadWrite) {
- WatchStrPtr = "awatch";
- }
-
- while (*WatchStrPtr != '\0') {
- *TSignalPtr++ = *WatchStrPtr++;
- }
-
- *TSignalPtr++ = ':';
-
- //Set up series of bytes in big-endian byte order. "awatch" won't work with little-endian byte order.
- RegSize = REG_SIZE;
- while (RegSize > 0) {
- RegSize = RegSize-4;
- *TSignalPtr++ = mHexToStr[(UINT8)(DataAddress >> RegSize) & 0xf];
- }
-
- //Always end n:r pair with ';'
- *TSignalPtr++ = ';';
- }
- }
- }
-
- *TSignalPtr = '\0';
-
- SendPacket (TSignalBuffer);
-}
-
-
-/**
- Translates the EFI mapping to GDB mapping
-
- @param EFIExceptionType EFI Exception that is being processed
- @retval UINTN that corresponds to EFIExceptionType's GDB exception type number
- **/
-UINT8
-ConvertEFItoGDBtype (
- IN EFI_EXCEPTION_TYPE EFIExceptionType
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < MaxEfiException () ; Index++) {
- if (gExceptionType[Index].Exception == EFIExceptionType) {
- return gExceptionType[Index].SignalNo;
- }
- }
- return GDB_SIGTRAP; // this is a GDB trap
-}
-
-
-/** "m addr,length"
- Find the Length of the area to read and the start addres. Finally, pass them to
- another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
- send it as a packet.
- **/
-
-VOID
-EFIAPI
-ReadFromMemory (
- CHAR8 *PacketData
- )
-{
- UINTN Address;
- UINTN Length;
- CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the address in hex chars
- CHAR8 *AddrBufPtr; // pointer to the address buffer
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- AddrBufPtr = AddressBuffer;
- InBufPtr = &PacketData[1];
- while (*InBufPtr != ',') {
- *AddrBufPtr++ = *InBufPtr++;
- }
- *AddrBufPtr = '\0';
-
- InBufPtr++; // this skips ',' in the buffer
-
- /* Error checking */
- if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
- Print((CHAR16 *)L"Address is too long\n");
- SendError (GDB_EBADMEMADDRBUFSIZE);
- return;
- }
-
- // 2 = 'm' + ','
- if (AsciiStrLen (PacketData) - AsciiStrLen (AddressBuffer) - 2 >= MAX_LENGTH_SIZE) {
- Print((CHAR16 *)L"Length is too long\n");
- SendError (GDB_EBADMEMLENGTH);
- return;
- }
-
- Address = AsciiStrHexToUintn (AddressBuffer);
- Length = AsciiStrHexToUintn (InBufPtr);
-
- TransferFromMemToOutBufAndSend (Length, (unsigned char *)Address);
-}
-
-
-/** "M addr,length :XX..."
- Find the Length of the area in bytes to write and the start addres. Finally, pass them to
- another function, TransferFromInBufToMem, that will write to that memory space the info in
- the input buffer.
- **/
-VOID
-EFIAPI
-WriteToMemory (
- IN CHAR8 *PacketData
- )
-{
- UINTN Address;
- UINTN Length;
- UINTN MessageLength;
- CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the Address in hex chars
- CHAR8 LengthBuffer[MAX_LENGTH_SIZE]; // the buffer that will hold the Length in hex chars
- CHAR8 *AddrBufPtr; // pointer to the Address buffer
- CHAR8 *LengthBufPtr; // pointer to the Length buffer
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- AddrBufPtr = AddressBuffer;
- LengthBufPtr = LengthBuffer;
- InBufPtr = &PacketData[1];
-
- while (*InBufPtr != ',') {
- *AddrBufPtr++ = *InBufPtr++;
- }
- *AddrBufPtr = '\0';
-
- InBufPtr++; // this skips ',' in the buffer
-
- while (*InBufPtr != ':') {
- *LengthBufPtr++ = *InBufPtr++;
- }
- *LengthBufPtr = '\0';
-
- InBufPtr++; // this skips ':' in the buffer
-
- Address = AsciiStrHexToUintn (AddressBuffer);
- Length = AsciiStrHexToUintn (LengthBuffer);
-
- /* Error checking */
-
- //Check if Address is not too long.
- if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
- Print ((CHAR16 *)L"Address too long..\n");
- SendError (GDB_EBADMEMADDRBUFSIZE);
- return;
- }
-
- //Check if message length is not too long
- if (AsciiStrLen (LengthBuffer) >= MAX_LENGTH_SIZE) {
- Print ((CHAR16 *)L"Length too long..\n");
- SendError (GDB_EBADMEMLENGBUFSIZE);
- return;
- }
-
- // Check if Message is not too long/short.
- // 3 = 'M' + ',' + ':'
- MessageLength = (AsciiStrLen (PacketData) - AsciiStrLen (AddressBuffer) - AsciiStrLen (LengthBuffer) - 3);
- if (MessageLength != (2*Length)) {
- //Message too long/short. New data is not the right size.
- SendError (GDB_EBADMEMDATASIZE);
- return;
- }
- TransferFromInBufToMem (Length, (unsigned char *)Address, InBufPtr);
-}
-
-/**
- Parses breakpoint packet data and captures Breakpoint type, Address and length.
- In case of an error, function returns particular error code. Returning 0 meaning
- no error.
-
- @param PacketData Pointer to the payload data for the packet.
- @param Type Breakpoint type
- @param Address Breakpoint address
- @param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
-
- @retval 1 Success
- @retval {other} Particular error code
-
-**/
-UINTN
-ParseBreakpointPacket (
- IN CHAR8 *PacketData,
- OUT UINTN *Type,
- OUT UINTN *Address,
- OUT UINTN *Length
- )
-{
- CHAR8 AddressBuffer[MAX_ADDR_SIZE];
- CHAR8 *AddressBufferPtr;
- CHAR8 *PacketDataPtr;
-
- PacketDataPtr = &PacketData[1];
- AddressBufferPtr = AddressBuffer;
-
- *Type = AsciiStrHexToUintn (PacketDataPtr);
-
- //Breakpoint/watchpoint type should be between 0 to 4
- if (*Type > 4) {
- Print ((CHAR16 *)L"Type is invalid\n");
- return 22; //EINVAL: Invalid argument.
- }
-
- //Skip ',' in the buffer.
- while (*PacketDataPtr++ != ',');
-
- //Parse Address information
- while (*PacketDataPtr != ',') {
- *AddressBufferPtr++ = *PacketDataPtr++;
- }
- *AddressBufferPtr = '\0';
-
- //Check if Address is not too long.
- if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
- Print ((CHAR16 *)L"Address too long..\n");
- return 40; //EMSGSIZE: Message size too long.
- }
-
- *Address = AsciiStrHexToUintn (AddressBuffer);
-
- PacketDataPtr++; //This skips , in the buffer
-
- //Parse Length information
- *Length = AsciiStrHexToUintn (PacketDataPtr);
-
- //Length should be 1, 2 or 4 bytes
- if (*Length > 4) {
- Print ((CHAR16 *)L"Length is invalid\n");
- return 22; //EINVAL: Invalid argument
- }
-
- return 0; //0 = No error
-}
-
-UINTN
-gXferObjectReadResponse (
- IN CHAR8 Type,
- IN CHAR8 *Str
- )
-{
- CHAR8 *OutBufPtr; // pointer to the output buffer
- CHAR8 Char;
- UINTN Count;
-
- // Response starts with 'm' or 'l' if it is the end
- OutBufPtr = gOutBuffer;
- *OutBufPtr++ = Type;
- Count = 1;
-
- // Binary data encoding
- OutBufPtr = gOutBuffer;
- while (*Str != '\0') {
- Char = *Str++;
- if ((Char == 0x7d) || (Char == 0x23) || (Char == 0x24) || (Char == 0x2a)) {
- // escape character
- *OutBufPtr++ = 0x7d;
-
- Char ^= 0x20;
- }
- *OutBufPtr++ = Char;
- Count++;
- }
-
- *OutBufPtr = '\0' ; // the end of the buffer
- SendPacket (gOutBuffer);
-
- return Count;
-}
-
-
-/**
- Note: This should be a library function. In the Apple case you have to add
- the size of the PE/COFF header into the starting address to make things work
- right as there is no way to pad the Mach-O for the size of the PE/COFF header.
-
-
- Returns a pointer to the PDB file name for a PE/COFF image that has been
- loaded into system memory with the PE/COFF Loader Library functions.
-
- Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
- the PE/COFF image specified by Pe32Data is not a valid, then NULL is
- returned. If the PE/COFF image specified by Pe32Data does not contain a
- debug directory entry, then NULL is returned. If the debug directory entry
- in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
- then NULL is returned.
- If Pe32Data is NULL, then ASSERT().
-
- @param Pe32Data Pointer to the PE/COFF image that is loaded in system
- memory.
- @param DebugBase Address that the debugger would use as the base of the image
-
- @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
- if it cannot be retrieved. DebugBase is only valid if PDB file name is
- valid.
-
-**/
-VOID *
-EFIAPI
-PeCoffLoaderGetDebuggerInfo (
- IN VOID *Pe32Data,
- OUT VOID **DebugBase
- )
-{
- EFI_IMAGE_DOS_HEADER *DosHdr;
- EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
- EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
- EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
- UINTN DirCount;
- VOID *CodeViewEntryPointer;
- INTN TEImageAdjust;
- UINT32 NumberOfRvaAndSizes;
- UINT16 Magic;
- UINTN SizeOfHeaders;
-
- ASSERT (Pe32Data != NULL);
-
- TEImageAdjust = 0;
- DirectoryEntry = NULL;
- DebugEntry = NULL;
- NumberOfRvaAndSizes = 0;
- SizeOfHeaders = 0;
-
- DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
- if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
- //
- // DOS image header is present, so read the PE header after the DOS image header.
- //
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
- } else {
- //
- // DOS image header is not present, so PE header is at the image base.
- //
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
- }
-
- if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
- if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
- DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
- TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +
- Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
- TEImageAdjust);
- }
- SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
-
- // __APPLE__ check this math...
- *DebugBase = ((CHAR8 *)Pe32Data) - TEImageAdjust;
- } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
-
- *DebugBase = Pe32Data;
-
-
- //
- // NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
- // It is due to backward-compatibility, for some system might
- // generate PE32+ image with PE32 Magic.
- //
- switch (Hdr.Pe32->FileHeader.Machine) {
- case EFI_IMAGE_MACHINE_IA32:
- //
- // Assume PE32 image with IA32 Machine field.
- //
- Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
- break;
- case EFI_IMAGE_MACHINE_X64:
- case EFI_IMAGE_MACHINE_IA64:
- //
- // Assume PE32+ image with X64 or IPF Machine field
- //
- Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
- break;
- default:
- //
- // For unknow Machine field, use Magic in optional Header
- //
- Magic = Hdr.Pe32->OptionalHeader.Magic;
- }
-
- if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
- //
- // Use PE32 offset get Debug Directory Entry
- //
- SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
- NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
- } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
- //
- // Use PE32+ offset get Debug Directory Entry
- //
- SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;
- NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
- }
-
- if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
- DirectoryEntry = NULL;
- DebugEntry = NULL;
- }
- } else {
- return NULL;
- }
-
- if (DebugEntry == NULL || DirectoryEntry == NULL) {
- return NULL;
- }
-
- for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {
- if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
- if (DebugEntry->SizeOfData > 0) {
- CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
- switch (* (UINT32 *) CodeViewEntryPointer) {
- case CODEVIEW_SIGNATURE_NB10:
- return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
- case CODEVIEW_SIGNATURE_RSDS:
- return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
- case CODEVIEW_SIGNATURE_MTOC:
- *DebugBase = (VOID *)(UINTN)((UINTN)DebugBase - SizeOfHeaders);
- return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
- default:
- break;
- }
- }
- }
- }
-
- (void)SizeOfHeaders;
- return NULL;
-}
-
-
-/**
- Process "qXfer:object:read:annex:offset,length" request.
-
- Returns an XML document that contains loaded libraries. In our case it is
- information in the EFI Debug Image Table converted into an XML document.
-
- GDB will call with an arbitrary length (it can't know the real length and
- will reply with chunks of XML that are easy for us to deal with. Gdb will
- keep calling until we say we are done. XML doc looks like:
-
- <library-list>
- <library name="/a/a/c/d.dSYM"><segment address="0x10000000"/></library>
- <library name="/a/m/e/e.pdb"><segment address="0x20000000"/></library>
- <library name="/a/l/f/f.dll"><segment address="0x30000000"/></library>
- </library-list>
-
- Since we can not allocate memory in interrupt context this module has
- assumptions about how it will get called:
- 1) Length will generally be max remote packet size (big enough)
- 2) First Offset of an XML document read needs to be 0
- 3) This code will return back small chunks of the XML document on every read.
- Each subsequent call will ask for the next available part of the document.
-
- Note: The only variable size element in the XML is:
- " <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
- based on the file path and name of the symbol file. If the symbol file name
- is bigger than the max gdb remote packet size we could update this code
- to respond back in chunks.
-
- @param Offset offset into special data area
- @param Length number of bytes to read starting at Offset
-
- **/
-VOID
-QxferLibrary (
- IN UINTN Offset,
- IN UINTN Length
- )
-{
- VOID *LoadAddress;
- CHAR8 *Pdb;
- UINTN Size;
-
- if (Offset != gPacketqXferLibraryOffset) {
- SendError (GDB_EINVALIDARG);
- Print (L"\nqXferLibrary (%d, %d) != %d\n", Offset, Length, gPacketqXferLibraryOffset);
-
- // Force a retry from the beginning
- gPacketqXferLibraryOffset = 0;
-
- return;
- }
-
- if (Offset == 0) {
- gPacketqXferLibraryOffset += gXferObjectReadResponse ('m', "<library-list>\n");
-
- // The owner of the table may have had to ralloc it so grab a fresh copy every time
- // we assume qXferLibrary will get called over and over again until the entire XML table is
- // returned in a tight loop. Since we are in the debugger the table should not get updated
- gDebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;
- gEfiDebugImageTableEntry = 0;
- return;
- }
-
- if (gDebugTable != NULL) {
- for (; gEfiDebugImageTableEntry < gDebugImageTableHeader->TableSize; gEfiDebugImageTableEntry++, gDebugTable++) {
- if (gDebugTable->NormalImage != NULL) {
- if ((gDebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
- (gDebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
- Pdb = PeCoffLoaderGetDebuggerInfo (
- gDebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase,
- &LoadAddress
- );
- if (Pdb != NULL) {
- Size = AsciiSPrint (
- gXferLibraryBuffer,
- sizeof (gXferLibraryBuffer),
- " <library name=\"%a\"><segment address=\"0x%p\"/></library>\n",
- Pdb,
- LoadAddress
- );
- if ((Size != 0) && (Size != (sizeof (gXferLibraryBuffer) - 1))) {
- gPacketqXferLibraryOffset += gXferObjectReadResponse ('m', gXferLibraryBuffer);
-
- // Update loop variables so we are in the right place when we get back
- gEfiDebugImageTableEntry++;
- gDebugTable++;
- return;
- } else {
- // We could handle <library> entires larger than sizeof (gXferLibraryBuffer) here if
- // needed by breaking up into N packets
- // "<library name=\"%s
- // the rest of the string (as many packets as required
- // \"><segment address=\"%d\"/></library> (fixed size)
- //
- // But right now we just skip any entry that is too big
- }
- }
- }
- }
- }
- }
-
-
- gXferObjectReadResponse ('l', "</library-list>\n");
- gPacketqXferLibraryOffset = 0;
- return;
-}
-
-
-/**
- Exception Hanldler for GDB. It will be called for all exceptions
- registered via the gExceptionType[] array.
-
- @param ExceptionType Exception that is being processed
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-GdbExceptionHandler (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINT8 GdbExceptionType;
- CHAR8 *Ptr;
-
-
- if (ValidateException (ExceptionType, SystemContext) == FALSE) {
- return;
- }
-
- RemoveSingleStep (SystemContext);
-
- GdbExceptionType = ConvertEFItoGDBtype (ExceptionType);
- GdbSendTSignal (SystemContext, GdbExceptionType);
-
- for( ; ; ) {
- ReceivePacket (gInBuffer, MAX_BUF_SIZE);
-
- switch (gInBuffer[0]) {
- case '?':
- GdbSendTSignal (SystemContext, GdbExceptionType);
- break;
-
- case 'c':
- ContinueAtAddress (SystemContext, gInBuffer);
- return;
-
- case 'g':
- ReadGeneralRegisters (SystemContext);
- break;
-
- case 'G':
- WriteGeneralRegisters (SystemContext, gInBuffer);
- break;
-
- case 'H':
- //Return "OK" packet since we don't have more than one thread.
- SendSuccess ();
- break;
-
- case 'm':
- ReadFromMemory (gInBuffer);
- break;
-
- case 'M':
- WriteToMemory (gInBuffer);
- break;
-
- case 'P':
- WriteNthRegister (SystemContext, gInBuffer);
- break;
-
- //
- // Still debugging this code. Not used in Darwin
- //
- case 'q':
- // General Query Packets
- if (AsciiStrnCmp (gInBuffer, "qSupported", 10) == 0) {
- // return what we currently support, we don't parse what gdb suports
- AsciiSPrint (gOutBuffer, MAX_BUF_SIZE, "qXfer:libraries:read+;PacketSize=%d", MAX_BUF_SIZE);
- SendPacket (gOutBuffer);
- } else if (AsciiStrnCmp (gInBuffer, "qXfer:libraries:read::", 22) == 0) {
- // ‘qXfer:libraries:read::offset,length
- // gInBuffer[22] is offset string, ++Ptr is length string’
- for (Ptr = &gInBuffer[22]; *Ptr != ','; Ptr++);
-
- // Not sure if multi-radix support is required. Currently only support decimal
- QxferLibrary (AsciiStrHexToUintn (&gInBuffer[22]), AsciiStrHexToUintn (++Ptr));
- } if (AsciiStrnCmp (gInBuffer, "qOffsets", 10) == 0) {
- AsciiSPrint (gOutBuffer, MAX_BUF_SIZE, "Text=1000;Data=f000;Bss=f000");
- SendPacket (gOutBuffer);
- } else {
- //Send empty packet
- SendNotSupported ();
- }
- break;
-
- case 's':
- SingleStep (SystemContext, gInBuffer);
- return;
-
- case 'z':
- RemoveBreakPoint (SystemContext, gInBuffer);
- break;
-
- case 'Z':
- InsertBreakPoint (SystemContext, gInBuffer);
- break;
-
- default:
- //Send empty packet
- SendNotSupported ();
- break;
- }
- }
-}
-
-
-/**
- Periodic callback for GDB. This function is used to catch a ctrl-c or other
- break in type command from GDB.
-
- @param SystemContext Register content at time of the call
- **/
-VOID
-EFIAPI
-GdbPeriodicCallBack (
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- //
- // gCtrlCBreakFlag may have been set from a previous F response package
- // and we set the global as we need to process it at a point where we
- // can update the system context. If we are in the middle of processing
- // a F Packet it is not safe to read the GDB serial stream so we need
- // to skip it on this check
- //
- if (!gCtrlCBreakFlag && !gProcessingFPacket) {
- //
- // Ctrl-C was not pending so grab any pending characters and see if they
- // are a Ctrl-c (0x03). If so set the Ctrl-C global.
- //
- while (TRUE) {
- if (!GdbIsCharAvailable ()) {
- //
- // No characters are pending so exit the loop
- //
- break;
- }
-
- if (GdbGetChar () == 0x03) {
- gCtrlCBreakFlag = TRUE;
- //
- // We have a ctrl-c so exit the loop
- //
- break;
- }
- }
- }
-
- if (gCtrlCBreakFlag) {
- //
- // Update the context to force a single step trap when we exit the GDB
- // stub. This will transfer control to GdbExceptionHandler () and let
- // us break into the program. We don't want to break into the GDB stub.
- //
- AddSingleStep (SystemContext);
- gCtrlCBreakFlag = FALSE;
- }
-}
diff --git a/EmbeddedPkg/GdbStub/GdbStub.inf b/EmbeddedPkg/GdbStub/GdbStub.inf
deleted file mode 100644
index ecb5c61b82..0000000000
--- a/EmbeddedPkg/GdbStub/GdbStub.inf
+++ /dev/null
@@ -1,77 +0,0 @@
-#/** @file
-# UEFI GDB stub
-#
-# This is a shell application that will display Hello World.
-# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#**/
-
-################################################################################
-#
-# Defines Section - statements that will be processed to create a Makefile.
-#
-################################################################################
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = GdbStub
- FILE_GUID = 1F2CCB4F-D817-404E-98E7-80E4851FB33E
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = GdbStubEntry
-
-[Sources.common]
- GdbStub.c
- SerialIo.c
-
-[Sources.ARM]
- Arm/Processor.c
-
-[Sources.IA32]
- Ia32/Processor.c
-
-[Sources.X64]
- X64/Processor.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- UefiLib
- UefiDriverEntryPoint
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- BaseMemoryLib
- MemoryAllocationLib
- DevicePathLib
- PcdLib
- GdbSerialLib
- PrintLib
- CacheMaintenanceLib
-
-
-[Protocols]
- gEfiDebugSupportProtocolGuid
- gEfiDebugPortProtocolGuid
- gEfiSerialIoProtocolGuid
-
-[Guids]
- gEfiDebugImageInfoTableGuid
-
-[FeaturePcd.common]
- gEmbeddedTokenSpaceGuid.PcdGdbSerial
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdGdbMaxPacketRetryCount
diff --git a/EmbeddedPkg/GdbStub/GdbStubInternal.h b/EmbeddedPkg/GdbStub/GdbStubInternal.h
deleted file mode 100644
index 521c3442e0..0000000000
--- a/EmbeddedPkg/GdbStub/GdbStubInternal.h
+++ /dev/null
@@ -1,746 +0,0 @@
-/** @file
- Private include file for GDB stub
-
- 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_STUB_INTERNAL__
-#define __GDB_STUB_INTERNAL__
-
-#include <Uefi.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/PcdLib.h>
-#include <Library/GdbSerialLib.h>
-#include <Library/PrintLib.h>
-
-#include <Protocol/DebugSupport.h>
-#include <Protocol/SerialIo.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/LoadedImage.h>
-#include <Guid/DebugImageInfoTable.h>
-#include <IndustryStandard/PeImage.h>
-
-extern CONST CHAR8 mHexToStr[];
-
-// maximum size of input and output buffers
-// This value came from the show remote command of the gdb we tested against
-#define MAX_BUF_SIZE 2000
-
-// maximum size of address buffer
-#define MAX_ADDR_SIZE 32
-
-// maximum size of register number buffer
-#define MAX_REG_NUM_BUF_SIZE 32
-
-// maximum size of length buffer
-#define MAX_LENGTH_SIZE 32
-
-// maximum size of T signal members
-#define MAX_T_SIGNAL_SIZE 64
-
-// the mask used to clear all the cache
-#define TF_BIT 0x00000100
-
-
-//
-// GDB Signal definitions - generic names for interrupts
-//
-#define GDB_SIGILL 4 // Illegal instruction
-#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)
-#define GDB_SIGEMT 7 // Emulator Trap
-#define GDB_SIGFPE 8 // Floating point exception
-#define GDB_SIGSEGV 11 // Segment violation, page fault
-
-
-//
-// GDB File I/O Error values, zero means no error
-// Includes all general GDB Unix like error values
-//
-#define GDB_EBADMEMADDRBUFSIZE 11 // the buffer that stores memory Address to be read from/written to is not the right size
-#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size
-#define GDB_EBADMEMLENGTH 13 // Length, the given number of bytes to read or write, is not the right size
-#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is leess than 0
-#define GDB_EBADMEMDATASIZE 15 // the memory data, 'XX..', is too short or too long
-#define GDB_EBADBUFSIZE 21 // the buffer created is not the correct size
-#define GDB_EINVALIDARG 31 // argument is invalid
-#define GDB_ENOSPACE 41 //
-#define GDB_EINVALIDBRKPOINTTYPE 51 // the breakpoint type is not recognized
-#define GDB_EINVALIDREGNUM 61 // given register number is not valid: either <0 or >=Number of Registers
-#define GDB_EUNKNOWN 255 // unknown
-
-
-//
-// These devices are open by GDB so we can just read and write to them
-//
-#define GDB_STDIN 0x00
-#define GDB_STDOUT 0x01
-#define GDB_STDERR 0x02
-
-//
-//Define Register size for different architectures
-//
-#if defined (MDE_CPU_IA32)
-#define REG_SIZE 32
-#elif defined (MDE_CPU_X64)
-#define REG_SIZE 64
-#elif defined (MDE_CPU_ARM)
-#define REG_SIZE 32
-#endif
-
-#define GDB_SERIAL_DEV_SIGNATURE SIGNATURE_32 ('g', 'd', 'b', 's')
-
-typedef struct {
- VENDOR_DEVICE_PATH VendorDevice;
- UINT32 Index; // Suport more than one
- EFI_DEVICE_PATH_PROTOCOL End;
-} GDB_SERIAL_DEVICE_PATH;
-
-//
-// Name: SERIAL_DEV
-// Purpose: To provide device specific information
-// Fields:
-// Signature UINTN: The identity of the serial device
-// SerialIo SERIAL_IO_PROTOCOL: Serial I/O protocol interface
-// SerialMode SERIAL_IO_MODE:
-// DevicePath EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device
-//
-typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
- EFI_SERIAL_IO_PROTOCOL SerialIo;
- EFI_SERIAL_IO_MODE SerialMode;
- GDB_SERIAL_DEVICE_PATH DevicePath;
- INTN InFileDescriptor;
- INTN OutFileDescriptor;
-} GDB_SERIAL_DEV;
-
-
-#define GDB_SERIAL_DEV_FROM_THIS(a) CR (a, GDB_SERIAL_DEV, SerialIo, GDB_SERIAL_DEV_SIGNATURE)
-
-
-typedef struct {
- EFI_EXCEPTION_TYPE Exception;
- UINT8 SignalNo;
-} EFI_EXCEPTION_TYPE_ENTRY;
-
-
-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
-
-//
-// Byte packed structure for DR6
-// 32-bits on IA-32
-// 64-bits on X64. The upper 32-bits on X64 are reserved
-//
-typedef union {
- struct {
- UINT32 B0:1; // Breakpoint condition detected
- UINT32 B1:1; // Breakpoint condition detected
- UINT32 B2:1; // Breakpoint condition detected
- UINT32 B3:1; // Breakpoint condition detected
- UINT32 Reserved_1:9; // Reserved
- UINT32 BD:1; // Debug register access detected
- UINT32 BS:1; // Single step
- UINT32 BT:1; // Task switch
- UINT32 Reserved_2:16; // Reserved
- } Bits;
- UINTN UintN;
-} IA32_DR6;
-
-//
-// Byte packed structure for DR7
-// 32-bits on IA-32
-// 64-bits on X64. The upper 32-bits on X64 are reserved
-//
-typedef union {
- struct {
- UINT32 L0:1; // Local breakpoint enable
- UINT32 G0:1; // Global breakpoint enable
- UINT32 L1:1; // Local breakpoint enable
- UINT32 G1:1; // Global breakpoint enable
- UINT32 L2:1; // Local breakpoint enable
- UINT32 G2:1; // Global breakpoint enable
- UINT32 L3:1; // Local breakpoint enable
- UINT32 G3:1; // Global breakpoint enable
- UINT32 LE:1; // Local exact breakpoint enable
- UINT32 GE:1; // Global exact breakpoint enable
- UINT32 Reserved_1:3; // Reserved
- UINT32 GD:1; // Global detect enable
- UINT32 Reserved_2:2; // Reserved
- UINT32 RW0:2; // Read/Write field
- UINT32 LEN0:2; // Length field
- UINT32 RW1:2; // Read/Write field
- UINT32 LEN1:2; // Length field
- UINT32 RW2:2; // Read/Write field
- UINT32 LEN2:2; // Length field
- UINT32 RW3:2; // Read/Write field
- UINT32 LEN3:2; // Length field
- } Bits;
- UINTN UintN;
-} IA32_DR7;
-
-#endif /* if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) */
-
-typedef enum {
- InstructionExecution, //Hardware breakpoint
- DataWrite, //watch
- DataRead, //rwatch
- DataReadWrite, //awatch
- SoftwareBreakpoint, //Software breakpoint
- NotSupported
-} BREAK_TYPE;
-
-//
-// Array of exception types that need to be hooked by the debugger
-//
-extern EFI_EXCEPTION_TYPE_ENTRY gExceptionType[];
-
-//
-// Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c
-// here we need to wait for the periodic callback to do this.
-//
-extern BOOLEAN gCtrlCBreakFlag;
-
-//
-// If the periodic callback is called while we are processing an F packet we need
-// to let the callback know to not read from the serail stream as it could steal
-// characters from the F reponse packet
-//
-extern BOOLEAN gProcessingFPacket;
-
-
-// The offsets of registers SystemContext.
-// The fields in the array are in the gdb ordering.
-//
-extern UINTN gRegisterOffsets[];
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- );
-
-
-/**
- Return the number of entries in the gRegisters[]
-
- @retval UINTN, the number of entries (registers) in the gRegisters[] array.
- **/
-UINTN
-MaxRegisterCount (
- VOID
- );
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported,
- FALSE otherwise.
- **/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- );
-
-
-/**
- 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
-GdbSendTSignal (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINT8 GdbExceptionType
- );
-
-
-/**
- Translates the EFI mapping to GDB mapping
-
- @param EFIExceptionType EFI Exception that is being processed
- @retval UINTN that corresponds to EFIExceptionType's GDB exception type number
- **/
-UINT8
-ConvertEFItoGDBtype (
- IN EFI_EXCEPTION_TYPE EFIExceptionType
- );
-
-
-/**
- Empties the given buffer
- @param *Buf pointer to the first element in buffer to be emptied
- **/
-VOID
-EmptyBuffer (
- IN CHAR8 *Buf
- );
-
-
-/**
- Converts an 8-bit Hex Char into a INTN.
-
- @param Char - the hex character to be converted into UINTN
- @retval a INTN, from 0 to 15, that corressponds to Char
- -1 if Char is not a hex character
- **/
-INTN
-HexCharToInt (
- IN CHAR8 Char
- );
-
-
-/** 'E NN'
- Send an error with the given error number after converting to hex.
- The error number is put into the buffer in hex. '255' is the biggest errno we can send.
- ex: 162 will be sent as A2.
-
- @param errno the error number that will be sent
- **/
-VOID
-EFIAPI
-SendError (
- IN UINT8 ErrorNum
- );
-
-
-/**
- Send 'OK' when the function is done executing successfully.
- **/
-VOID
-SendSuccess (
- VOID
- );
-
-
-/**
- Send empty packet to specify that particular command/functionality is not supported.
- **/
-VOID
-SendNotSupported (
- VOID
- );
-
-/** ‘p n’
- Reads the n-th register's value into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- @param InBuffer This is the input buffer received from gdb server
- **/
-VOID
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- );
-
-
-/** ‘g’
- Reads the general registers into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- **/
-VOID
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
- @param SystemContext Register content at time of the exception
- @param InBuffer This is the input buffer received from gdb server
- **/
-VOID
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- );
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-
-VOID
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- );
-
-
-/** ‘m addr,length ’
- Find the Length of the area to read and the start addres. Finally, pass them to
- another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
- send it as a packet.
-
- @param *PacketData Pointer to Payload data for the packet
- **/
-VOID
-ReadFromMemory (
- IN CHAR8 *PacketData
- );
-
-
-/** ‘M addr,length :XX...’
- Find the Length of the area in bytes to write and the start addres. Finally, pass them to
- another function, TransferFromInBufToMem, that will write to that memory space the info in
- the input buffer.
-
- @param PacketData Pointer to Payload data for the packet
- **/
-VOID
-WriteToMemory (
- IN CHAR8 *PacketData
- );
-
-
-/** ‘c [addr ]’
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to PacketData
- **/
-
-VOID
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- @param PacketData Pointer to Payload data for the packet
- **/
-VOID
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-/**
- Insert Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-AddSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-/**
- Remove Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-RemoveSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- ‘Z1, [addr], [length]’
- ‘Z2, [addr], [length]’
- ‘Z3, [addr], [length]’
- ‘Z4, [addr], [length]’
-
- Insert hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-InsertBreakPoint(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-
-/**
- ‘z1, [addr], [length]’
- ‘z2, [addr], [length]’
- ‘z3, [addr], [length]’
- ‘z4, [addr], [length]’
-
- Remove hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-RemoveBreakPoint(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-
-/**
- Exception Hanldler for GDB. It will be called for all exceptions
- registered via the gExceptionType[] array.
-
- @param ExceptionType Exception that is being processed
- @param SystemContext Register content at time of the exception
-
- **/
-VOID
-EFIAPI
-GdbExceptionHandler (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- Periodic callback for GDB. This function is used to catch a ctrl-c or other
- break in type command from GDB.
-
- @param SystemContext Register content at time of the call
-
- **/
-VOID
-EFIAPI
-GdbPeriodicCallBack (
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- Make two serail consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.
-
- These console show up on the remote system running GDB
-
-**/
-
-VOID
-GdbInitializeSerialConsole (
- VOID
- );
-
-
-/**
- Send a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up
- in an infinit loop. This is so if you unplug the debugger code just keeps running
-
- @param PacketData Payload data for the packet
-
- @retval Number of bytes of packet data sent.
-
-**/
-UINTN
-SendPacket (
- IN CHAR8 *PacketData
- );
-
-
-/**
- Receive a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed.
- (In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)
-
- If an ack '+' is not sent resend the packet
-
- @param PacketData Payload data for the packet
-
- @retval Number of bytes of packet data received.
-
- **/
-UINTN
-ReceivePacket (
- OUT CHAR8 *PacketData,
- IN UINTN PacketDataSize
- );
-
-
-/**
- Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates
- the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.
-
- @param FileDescriptor Device to talk to.
- @param Buffer Buffer to hold Count bytes that were read
- @param Count Number of bytes to transfer.
-
- @retval -1 Error
- @retval {other} Number of bytes read.
-
-**/
-INTN
-GdbRead (
- IN INTN FileDescriptor,
- OUT VOID *Buffer,
- IN UINTN Count
- );
-
-
-/**
- Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates
- nothing was written. On error -1 is returned.
-
- @param FileDescriptor Device to talk to.
- @param Buffer Buffer to hold Count bytes that are to be written
- @param Count Number of bytes to transfer.
-
- @retval -1 Error
- @retval {other} Number of bytes written.
-
-**/
-INTN
-GdbWrite (
- IN INTN FileDescriptor,
- OUT CONST VOID *Buffer,
- IN UINTN Count
- );
-
-UINTN *
-FindPointerToRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- );
-
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- );
-
-VOID
-TransferFromInBufToMem (
- IN UINTN Length,
- IN UINT8 *Address,
- IN CHAR8 *NewData
- );
-
-VOID
-TransferFromMemToOutBufAndSend (
- IN UINTN Length,
- IN UINT8 *Address
- );
-
-CHAR8 *
-BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- );
-
-VOID
-PrintReg (
- EFI_SYSTEM_CONTEXT SystemContext
- );
-
-UINTN
-ParseBreakpointPacket (
- IN CHAR8 *PacketData,
- OUT UINTN *Type,
- OUT UINTN *Address,
- OUT UINTN *Length
- );
-
-UINTN
-GetBreakpointDataAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- );
-
-UINTN
-GetBreakpointDetected (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-BREAK_TYPE
-GetBreakpointType (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- );
-
-UINTN
-ConvertLengthData (
- IN UINTN Length
- );
-
-EFI_STATUS
-FindNextFreeDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT UINTN *Register
- );
-
-EFI_STATUS
-EnableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type
- );
-
-EFI_STATUS
-FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- );
-
-EFI_STATUS
-DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- );
-
-VOID
-InitializeProcessor (
- VOID
- );
-
-BOOLEAN
-ValidateAddress (
- IN VOID *Address
- );
-
-BOOLEAN
-ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- );
-
-#endif
diff --git a/EmbeddedPkg/GdbStub/Ia32/Processor.c b/EmbeddedPkg/GdbStub/Ia32/Processor.c
deleted file mode 100644
index bd94b31109..0000000000
--- a/EmbeddedPkg/GdbStub/Ia32/Processor.c
+++ /dev/null
@@ -1,993 +0,0 @@
-/** @file
- Processor specific parts of the GDB stub
-
- 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 <GdbStubInternal.h>
-
-//
-// Array of exception types that need to be hooked by the debugger
-// {EFI mapping, GDB mapping}
-//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_IA32_DIVIDE_ERROR, GDB_SIGFPE },
- { EXCEPT_IA32_DEBUG, GDB_SIGTRAP },
- { EXCEPT_IA32_NMI, GDB_SIGEMT },
- { EXCEPT_IA32_BREAKPOINT, GDB_SIGTRAP },
- { EXCEPT_IA32_OVERFLOW, GDB_SIGSEGV },
- { EXCEPT_IA32_BOUND, GDB_SIGSEGV },
- { EXCEPT_IA32_INVALID_OPCODE, GDB_SIGILL },
- { EXCEPT_IA32_DOUBLE_FAULT, GDB_SIGEMT },
- { EXCEPT_IA32_STACK_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_GP_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_PAGE_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_FP_ERROR, GDB_SIGEMT },
- { EXCEPT_IA32_ALIGNMENT_CHECK, GDB_SIGEMT },
- { EXCEPT_IA32_MACHINE_CHECK, GDB_SIGEMT }
-};
-
-
-// The offsets of registers SystemContext.
-// The fields in the array are in the gdb ordering.
-//
-//16 regs
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eax),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ecx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Edx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ebx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Esp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ebp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Esi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Edi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eip),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eflags),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Cs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ss),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ds),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Es),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Fs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Gs)
-};
-
-
-//Debug only..
-VOID
-PrintReg (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- Print ((CHAR16 *)L"EAX: %x ", SystemContext.SystemContextIa32->Eax);
- Print ((CHAR16 *)L"ECX: %x ", SystemContext.SystemContextIa32->Ecx);
- Print ((CHAR16 *)L"EDX: %x ", SystemContext.SystemContextIa32->Edx);
- Print ((CHAR16 *)L"EBX: %x ", SystemContext.SystemContextIa32->Ebx);
- Print ((CHAR16 *)L"ESP: %x ", SystemContext.SystemContextIa32->Esp);
- Print ((CHAR16 *)L"EBP: %x ", SystemContext.SystemContextIa32->Ebp);
- Print ((CHAR16 *)L"ESI: %x ", SystemContext.SystemContextIa32->Esi);
- Print ((CHAR16 *)L"EDI: %x ", SystemContext.SystemContextIa32->Edi);
- Print ((CHAR16 *)L"EIP: %x\n", SystemContext.SystemContextIa32->Eip);
- Print ((CHAR16 *)L"EFlags: %x\n", SystemContext.SystemContextIa32->Eflags);
-}
-
-//Debug only..
-VOID
-PrintDRreg (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- Print ((CHAR16 *)L"DR0: %x ", SystemContext.SystemContextIa32->Dr0);
- Print ((CHAR16 *)L"DR1: %x ", SystemContext.SystemContextIa32->Dr1);
- Print ((CHAR16 *)L"DR2: %x ", SystemContext.SystemContextIa32->Dr2);
- Print ((CHAR16 *)L"DR3: %x ", SystemContext.SystemContextIa32->Dr3);
- Print ((CHAR16 *)L"DR6: %x ", SystemContext.SystemContextIa32->Dr6);
- Print ((CHAR16 *)L"DR7: %x\n", SystemContext.SystemContextIa32->Dr7);
-}
-
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- )
-{
- return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
-}
-
-
-/**
- Return the number of entries in the gRegisters[]
-
- @retval UINTN, the number of entries (registers) in the gRegisters[] array.
- **/
-UINTN
-MaxRegisterCount (
- VOID
- )
-{
- return sizeof (gRegisterOffsets)/sizeof (UINTN);
-}
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported,
- FALSE otherwise.
-**/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- )
-{
- return (BOOLEAN)(Isa == IsaIa32);
-}
-
-
-/**
- This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
- It is, by default, set to find the register pointer of the IA32 member
-
- @param SystemContext Register content at time of the exception
- @param RegNumber The register to which we want to find a pointer
- @retval the pointer to the RegNumber-th pointer
- **/
-UINTN *
-FindPointerToRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- )
-{
- UINT8 *TempPtr;
- TempPtr = ((UINT8 *)SystemContext.SystemContextIa32) + gRegisterOffsets[RegNumber];
- return (UINTN *)TempPtr;
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
-
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to read
- @param OutBufPtr pointer to the output buffer's end. the new data will be added from this point on.
- @retval the pointer to the next character of the output buffer that is available to be written on.
- **/
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- )
-{
- UINTN RegSize;
-
- RegSize = 0;
- while (RegSize < REG_SIZE) {
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
- RegSize = RegSize + 8;
- }
- return OutBufPtr;
-}
-
-
-/** ‘p n’
- Reads the n-th register's value into an output buffer and sends it as a packet
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
-
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
-
- OutBufPtr = OutBuffer;
- OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket(OutBuffer);
-}
-
-
-/** ‘g’
- Reads the general registers into an output buffer and sends it as a packet
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINTN i;
- CHAR8 OutBuffer[129]; // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- OutBufPtr = OutBuffer;
- for (i = 0 ; i < MaxRegisterCount() ; i++) { // there are only 16 registers to read
- OutBufPtr = BasicReadRegister (SystemContext, i, OutBufPtr);
- }
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket(OutBuffer);
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
-
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to write
- @param InBufPtr pointer to the output buffer. the new data will be extracted from the input buffer from this point on.
- @retval the pointer to the next character of the input buffer that can be used
- **/
-CHAR8 *
-BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- )
-{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT32 NewValue; // the new value of the RegNumber-th Register
-
- NewValue = 0;
- RegSize = 0;
- while (RegSize < REG_SIZE) {
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
- }
- *(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
- return InBufPtr;
-}
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Ponter to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
-
- // find the register number to write
- InBufPtr = &InBuffer[1];
- RegNumBufPtr = RegNumBuffer;
- while (*InBufPtr != '=') {
- *RegNumBufPtr++ = *InBufPtr++;
- }
- *RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
-
- // check if this is a valid Register Number
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
- InBufPtr++; // skips the '=' character
- BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
-}
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- // check to see if the buffer is the right size which is
- // 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129
- if (AsciiStrLen(InBuffer) != 129) { // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
- //Bad message. Message is not the right length
- SendError (GDB_EBADBUFSIZE);
- return;
- }
-
- InBufPtr = &InBuffer[1];
-
- // Read the new values for the registers from the input buffer to an array, NewValueArray.
- // The values in the array are in the gdb ordering
- for (i=0; i < MaxRegisterCount(); i++) { // there are only 16 registers to write
- InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
- }
-
- SendSuccess();
-}
-
-
-/**
- Insert Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-AddSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- SystemContext.SystemContextIa32->Eflags |= TF_BIT; //Setting the TF bit.
-}
-
-
-/**
- Remove Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-RemoveSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- SystemContext.SystemContextIa32->Eflags &= ~TF_BIT; // clearing the TF bit.
-}
-
-
-
-/** ‘c [addr ]’
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextIa32->Eip = AsciiStrHexToUintn (&PacketData[1]);
- }
-}
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextIa32->Eip = AsciiStrHexToUintn (&PacketData[1]);
- }
-
- AddSingleStep (SystemContext);
-}
-
-
-/**
- Returns breakpoint data address from DR0-DR3 based on the input breakpoint number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval Address Data address from DR0-DR3 based on the breakpoint number.
-
-**/
-UINTN
-GetBreakpointDataAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- UINTN Address;
-
- if (BreakpointNumber == 1) {
- Address = SystemContext.SystemContextIa32->Dr0;
- } else if (BreakpointNumber == 2) {
- Address = SystemContext.SystemContextIa32->Dr1;
- } else if (BreakpointNumber == 3) {
- Address = SystemContext.SystemContextIa32->Dr2;
- } else if (BreakpointNumber == 4) {
- Address = SystemContext.SystemContextIa32->Dr3;
- } else {
- Address = 0;
- }
-
- return Address;
-}
-
-
-/**
- Returns currently detected breakpoint value based on the register DR6 B0-B3 field.
- If no breakpoint is detected then it returns 0.
-
- @param SystemContext Register content at time of the exception
-
- @retval {1-4} Currently detected breakpoint value
- @retval 0 No breakpoint detected.
-
-**/
-UINTN
-GetBreakpointDetected (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- IA32_DR6 Dr6;
- UINTN BreakpointNumber;
-
- Dr6.UintN = SystemContext.SystemContextIa32->Dr6;
-
- if (Dr6.Bits.B0 == 1) {
- BreakpointNumber = 1;
- } else if (Dr6.Bits.B1 == 1) {
- BreakpointNumber = 2;
- } else if (Dr6.Bits.B2 == 1) {
- BreakpointNumber = 3;
- } else if (Dr6.Bits.B3 == 1) {
- BreakpointNumber = 4;
- } else {
- BreakpointNumber = 0; //No breakpoint detected
- }
-
- return BreakpointNumber;
-}
-
-
-/**
- Returns Breakpoint type (InstructionExecution, DataWrite, DataRead or DataReadWrite)
- based on the Breakpoint number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval BREAK_TYPE Breakpoint type value read from register DR7 RWn field
- For unknown value, it returns NotSupported.
-
-**/
-BREAK_TYPE
-GetBreakpointType (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- IA32_DR7 Dr7;
- BREAK_TYPE Type = NotSupported; //Default is NotSupported type
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (BreakpointNumber == 1) {
- Type = (BREAK_TYPE) Dr7.Bits.RW0;
- } else if (BreakpointNumber == 2) {
- Type = (BREAK_TYPE) Dr7.Bits.RW1;
- } else if (BreakpointNumber == 3) {
- Type = (BREAK_TYPE) Dr7.Bits.RW2;
- } else if (BreakpointNumber == 4) {
- Type = (BREAK_TYPE) Dr7.Bits.RW3;
- }
-
- return Type;
-}
-
-
-/**
- Parses Length and returns the length which DR7 LENn field accepts.
- For example: If we receive 1-Byte length then we should return 0.
- Zero gets written to DR7 LENn field.
-
- @param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
-
- @retval Length Appropriate converted values which DR7 LENn field accepts.
-
-**/
-UINTN
-ConvertLengthData (
- IN UINTN Length
- )
-{
- if (Length == 1) { //1-Byte length
- return 0;
- } else if (Length == 2) { //2-Byte length
- return 1;
- } else if (Length == 4) { //4-Byte length
- return 3;
- } else { //Undefined or 8-byte length
- return 2;
- }
-}
-
-
-/**
- Finds the next free debug register. If all the registers are occupied then
- EFI_OUT_OF_RESOURCES is returned.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3 for the first free debug register)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindNextFreeDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Dr7.Bits.G0 == 0) {
- *Register = 0;
- } else if (Dr7.Bits.G1 == 0) {
- *Register = 1;
- } else if (Dr7.Bits.G2 == 0) {
- *Register = 2;
- } else if (Dr7.Bits.G3 == 0) {
- *Register = 3;
- } else {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Enables the debug register. Writes Address value to appropriate DR0-3 register.
- Sets LENn, Gn, RWn bits in DR7 register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3)
- @param Address Breakpoint address value
- @param Type Breakpoint type (Instruction, Data write, Data read
- or write etc.)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-EnableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type
- )
-{
- IA32_DR7 Dr7;
-
- //Convert length data
- Length = ConvertLengthData (Length);
-
- //For Instruction execution, length should be 0
- //(Ref. Intel reference manual 18.2.4)
- if ((Type == 0) && (Length != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 1;
- Dr7.Bits.RW0 = Type;
- Dr7.Bits.LEN0 = Length;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 1;
- Dr7.Bits.RW1 = Type;
- Dr7.Bits.LEN1 = Length;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 1;
- Dr7.Bits.RW2 = Type;
- Dr7.Bits.LEN2 = Length;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 1;
- Dr7.Bits.RW3 = Type;
- Dr7.Bits.LEN3 = Length;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update Dr7 with appropriate Gn, RWn and LENn bits
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Returns register number 0 - 3 for the maching debug register.
- This function compares incoming Address, Type, Length and
- if there is a match then it returns the appropriate register number.
- In case of mismatch, function returns EFI_NOT_FOUND message.
-
- @param SystemContext Register content at time of the exception
- @param Address Breakpoint address value
- @param Length Breakpoint length value
- @param Type Breakpoint type (Instruction, Data write,
- Data read or write etc.)
- @param Register Register value to be returned
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Convert length data
- Length = ConvertLengthData(Length);
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if ((Dr7.Bits.G0 == 1) &&
- (Dr7.Bits.LEN0 == Length) &&
- (Dr7.Bits.RW0 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr0)) {
- *Register = 0;
- } else if ((Dr7.Bits.G1 == 1) &&
- (Dr7.Bits.LEN1 == Length) &&
- (Dr7.Bits.RW1 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr1)) {
- *Register = 1;
- } else if ((Dr7.Bits.G2 == 1) &&
- (Dr7.Bits.LEN2 == Length) &&
- (Dr7.Bits.RW2 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr2)) {
- *Register = 2;
- } else if ((Dr7.Bits.G3 == 1) &&
- (Dr7.Bits.LEN3 == Length) &&
- (Dr7.Bits.RW3 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr3)) {
- *Register = 3;
- } else {
- Print ((CHAR16 *)L"No match found..\n");
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Disables the particular debug register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register to be disabled
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- )
-{
- IA32_DR7 Dr7;
- UINTN Address = 0;
-
- //Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 0;
- Dr7.Bits.RW0 = 0;
- Dr7.Bits.LEN0 = 0;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 0;
- Dr7.Bits.RW1 = 0;
- Dr7.Bits.LEN1 = 0;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 0;
- Dr7.Bits.RW2 = 0;
- Dr7.Bits.LEN2 = 0;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 0;
- Dr7.Bits.RW3 = 0;
- Dr7.Bits.LEN3 = 0;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- ‘Z1, [addr], [length]’
- ‘Z2, [addr], [length]’
- ‘Z3, [addr], [length]’
- ‘Z4, [addr], [length]’
-
- Insert hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-InsertBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- EFI_STATUS Status;
- BREAK_TYPE BreakType = NotSupported;
- UINTN ErrorCode;
-
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- Print ((CHAR16 *)L"Insert breakpoint default: %x\n", Type);
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- // Find next free debug register
- Status = FindNextFreeDebugRegister (SystemContext, &Register);
- if (EFI_ERROR(Status)) {
- Print ((CHAR16 *)L"No space left on device\n");
- SendError (GDB_ENOSPACE);
- return;
- }
-
- // Write Address, length data at particular DR register
- Status = EnableDebugRegister (SystemContext, Register, Address, Length, (UINTN)BreakType);
- if (EFI_ERROR(Status)) {
-
- if (Status == EFI_UNSUPPORTED) {
- Print ((CHAR16 *)L"Not supported\n");
- SendNotSupported ();
- return;
- }
-
- Print ((CHAR16 *)L"Invalid argument\n");
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-/**
- ‘z1, [addr], [length]’
- ‘z2, [addr], [length]’
- ‘z3, [addr], [length]’
- ‘z4, [addr], [length]’
-
- Remove hardware breakpoint/watchpoint at address addr of size length
-
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-RemoveBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- BREAK_TYPE BreakType = NotSupported;
- EFI_STATUS Status;
- UINTN ErrorCode;
-
- //Parse breakpoint packet data
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- //Find matching debug register
- Status = FindMatchingDebugRegister (SystemContext, Address, Length, (UINTN)BreakType, &Register);
- if (EFI_ERROR(Status)) {
-
- if (Status == EFI_UNSUPPORTED) {
- Print ((CHAR16 *)L"Not supported.\n");
- SendNotSupported ();
- return;
- }
-
- Print ((CHAR16 *)L"No matching register found.\n");
- SendError (GDB_ENOSPACE);
- return;
- }
-
- //Remove breakpoint
- Status = DisableDebugRegister (SystemContext, Register);
- if (EFI_ERROR(Status)) {
- Print ((CHAR16 *)L"Invalid argument.\n");
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-VOID
-InitializeProcessor (
- VOID
- )
-{
-}
-
-BOOLEAN
-ValidateAddress (
- IN VOID *Address
- )
-{
- return TRUE;
-}
-
-BOOLEAN
-ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- return TRUE;
-}
-
diff --git a/EmbeddedPkg/GdbStub/SerialIo.c b/EmbeddedPkg/GdbStub/SerialIo.c
deleted file mode 100644
index 32ceaf1233..0000000000
--- a/EmbeddedPkg/GdbStub/SerialIo.c
+++ /dev/null
@@ -1,553 +0,0 @@
-/** @file
- Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows up on the system
- running GDB. One consle for error information and another console for user input/output.
-
- Basic packet format is $packet-data#checksum. So every comand has 4 bytes of overhead: $,
- #, 0, 0. The 0 and 0 are the ascii characters for the checksum.
-
-
- 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 <GdbStubInternal.h>
-
-//
-// Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c
-// here we need to wait for the periodic callback to do this.
-//
-BOOLEAN gCtrlCBreakFlag = FALSE;
-
-//
-// If the periodic callback is called while we are processing an F packet we need
-// to let the callback know to not read from the serail stream as it could steal
-// characters from the F reponse packet
-//
-BOOLEAN gProcessingFPacket = FALSE;
-
-/**
- Process a control-C break message.
-
- Currently a place holder, remove the ASSERT when it gets implemented.
-
- @param ErrNo Error infomration from the F reply packet or other source
-
-**/
-
-VOID
-GdbCtrlCBreakMessage (
- IN UINTN ErrNo
- )
-{
- // See D.10.5 of gdb.pdf
- // This should look like a break message. Should look like SIGINT
-
- /* TODO: Make sure if we should do anything with ErrNo */
- //Turn on the global Ctrl-C flag.
- gCtrlCBreakFlag = TRUE;
-}
-
-
-/**
- Parse the F reply packet and extract the return value and an ErrNo if it exists.
-
- @param Packet Packet to parse like an F reply packet
- @param ErrNo Buffer to hold Count bytes that were read
-
- @retval -1 Error, not a valid F reply packet
- @retval other Return the return code from the F reply packet
-
-**/
-INTN
-GdbParseFReplyPacket (
- IN CHAR8 *Packet,
- OUT UINTN *ErrNo
- )
-{
- INTN RetCode;
-
- if (Packet[0] != 'F') {
- // A valid responce would be an F packet
- return -1;
- }
-
- RetCode = AsciiStrHexToUintn (&Packet[1]);
-
- // Find 1st comma
- for (;*Packet != '\0' && *Packet != ','; Packet++);
- if (*Packet == '\0') {
- *ErrNo = 0;
- return RetCode;
- }
-
- *ErrNo = AsciiStrHexToUintn (++Packet);
-
- // Find 2nd comma
- for (;*Packet != '\0' && *Packet != ','; Packet++);
- if (*Packet == '\0') {
- return RetCode;
- }
-
- if (*(++Packet) == 'C') {
- GdbCtrlCBreakMessage (*ErrNo);
- }
-
- return RetCode;
-}
-
-
-/**
- Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates
- the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.
-
- @param FileDescriptor Device to talk to.
- @param Buffer Buffer to hold Count bytes that were read
- @param Count Number of bytes to transfer.
-
- @retval -1 Error
- @retval {other} Number of bytes read.
-
-**/
-INTN
-GdbRead (
- IN INTN FileDescriptor,
- OUT VOID *Buffer,
- IN UINTN Count
- )
-{
- CHAR8 Packet[128];
- UINTN Size;
- INTN RetCode;
- UINTN ErrNo;
- BOOLEAN ReceiveDone = FALSE;
-
- // Send:
- // "Fread,XX,YYYYYYYY,XX
- //
- // XX - FileDescriptor in ASCII
- // YYYYYYYY - Buffer address in ASCII
- // XX - Count in ASCII
- // SS - check sum
- //
- Size = AsciiSPrint (Packet, sizeof (Packet), "Fread,%x,%x,%x", FileDescriptor, Buffer, Count);
- // Packet array is too small if you got this ASSERT
- ASSERT (Size < sizeof (Packet));
-
- gProcessingFPacket = TRUE;
- SendPacket (Packet);
- Print ((CHAR16 *)L"Packet sent..\n");
-
- do {
- // Reply:
- ReceivePacket (Packet, sizeof (Packet));
- Print ((CHAR16 *)L"Command received..%c\n", Packet[0]);
-
- // Process GDB commands
- switch (Packet[0]) {
- //Write memory command.
- //M addr,length:XX...
- case 'M':
- WriteToMemory (Packet);
- break;
-
- //Fretcode, errno, Ctrl-C flag
- //retcode - Count read
- case 'F':
- //Once target receives F reply packet that means the previous
- //transactions are finished.
- ReceiveDone = TRUE;
- break;
-
- //Send empty buffer
- default :
- SendNotSupported();
- break;
- }
- } while (ReceiveDone == FALSE);
-
- RetCode = GdbParseFReplyPacket (Packet, &ErrNo);
- Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo);
-
- if (ErrNo > 0) {
- //Send error to the host if there is any.
- SendError ((UINT8)ErrNo);
- }
-
- gProcessingFPacket = FALSE;
-
- return RetCode;
-}
-
-
-/**
- Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates
- nothing was written. On error -1 is returned.
-
- @param FileDescriptor Device to talk to.
- @param Buffer Buffer to hold Count bytes that are to be written
- @param Count Number of bytes to transfer.
-
- @retval -1 Error
- @retval {other} Number of bytes written.
-
-**/
-INTN
-GdbWrite (
- IN INTN FileDescriptor,
- OUT CONST VOID *Buffer,
- IN UINTN Count
- )
-{
- CHAR8 Packet[128];
- UINTN Size;
- INTN RetCode;
- UINTN ErrNo;
- BOOLEAN ReceiveDone = FALSE;
-
- // Send:
- // #Fwrite,XX,YYYYYYYY,XX$SS
- //
- // XX - FileDescriptor in ASCII
- // YYYYYYYY - Buffer address in ASCII
- // XX - Count in ASCII
- // SS - check sum
- //
- Size = AsciiSPrint (Packet, sizeof (Packet), "Fwrite,%x,%x,%x", FileDescriptor, Buffer, Count);
- // Packet array is too small if you got this ASSERT
- ASSERT (Size < sizeof (Packet));
-
- SendPacket (Packet);
- Print ((CHAR16 *)L"Packet sent..\n");
-
- do {
- // Reply:
- ReceivePacket (Packet, sizeof (Packet));
- Print ((CHAR16 *)L"Command received..%c\n", Packet[0]);
-
- // Process GDB commands
- switch (Packet[0]) {
- //Read memory command.
- //m addr,length.
- case 'm':
- ReadFromMemory (Packet);
- break;
-
- //Fretcode, errno, Ctrl-C flag
- //retcode - Count read
- case 'F':
- //Once target receives F reply packet that means the previous
- //transactions are finished.
- ReceiveDone = TRUE;
- break;
-
- //Send empty buffer
- default :
- SendNotSupported();
- break;
- }
- } while (ReceiveDone == FALSE);
-
- RetCode = GdbParseFReplyPacket (Packet, &ErrNo);
- Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo);
-
- //Send error to the host if there is any.
- if (ErrNo > 0) {
- SendError((UINT8)ErrNo);
- }
-
- return RetCode;
-}
-
-
-/**
- Reset the serial device.
-
- @param This Protocol instance pointer.
-
- @retval EFI_SUCCESS The device was reset.
- @retval EFI_DEVICE_ERROR The serial device could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-GdbSerialReset (
- IN EFI_SERIAL_IO_PROTOCOL *This
- )
-{
- return EFI_SUCCESS;
-}
-
-
-/**
- Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
- data buts, and stop bits on a serial device.
-
- @param This Protocol instance pointer.
- @param BaudRate The requested baud rate. A BaudRate value of 0 will use the the
- device's default interface speed.
- @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
- serial interface. A ReceiveFifoDepth value of 0 will use
- the device's dfault FIFO depth.
- @param Timeout The requested time out for a single character in microseconds.
- This timeout applies to both the transmit and receive side of the
- interface. A Timeout value of 0 will use the device's default time
- out value.
- @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 reset.
- @retval EFI_DEVICE_ERROR The serial device could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-GdbSerialSetAttributes (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-
-/**
- Set the control bits on a serial device
-
- @param This Protocol instance pointer.
- @param Control Set the bits of Control that are settable.
-
- @retval EFI_SUCCESS The new control bits were set on the serial device.
- @retval EFI_UNSUPPORTED The serial device does not support this operation.
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-EFI_STATUS
-EFIAPI
-GdbSerialSetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT32 Control
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-
-/**
- Retrieves the status of thecontrol bits on a serial device
-
- @param This Protocol instance pointer.
- @param Control A pointer to return the current Control signals 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.
-
-**/
-EFI_STATUS
-EFIAPI
-GdbSerialGetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- OUT UINT32 *Control
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-
-/**
- Writes data to a serial device.
-
- @param This Protocol instance pointer.
- @param BufferSize On input, the size of the Buffer. On output, the amount of
- data actually written.
- @param Buffer The buffer of data to write
-
- @retval EFI_SUCCESS The data was written.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_TIMEOUT The data write was stopped due to a timeout.
-
-**/
-EFI_STATUS
-EFIAPI
-GdbSerialWrite (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
- )
-{
- GDB_SERIAL_DEV *SerialDev;
- UINTN Return;
-
- SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);
-
- Return = GdbWrite (SerialDev->OutFileDescriptor, Buffer, *BufferSize);
- if (Return == (UINTN)-1) {
- return EFI_DEVICE_ERROR;
- }
-
- if (Return != *BufferSize) {
- *BufferSize = Return;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Writes data to a serial device.
-
- @param This Protocol instance pointer.
- @param BufferSize On input, the size of the Buffer. On output, the amount of
- data returned in Buffer.
- @param Buffer The buffer to return the data into.
-
- @retval EFI_SUCCESS The data was read.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_TIMEOUT The data write was stopped due to a timeout.
-
-**/
-
-EFI_STATUS
-EFIAPI
-GdbSerialRead (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
- )
-{
- GDB_SERIAL_DEV *SerialDev;
- UINTN Return;
-
- SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);
-
- Return = GdbRead (SerialDev->InFileDescriptor, Buffer, *BufferSize);
- if (Return == (UINTN)-1) {
- return EFI_DEVICE_ERROR;
- }
-
- if (Return != *BufferSize) {
- *BufferSize = Return;
- }
-
- return EFI_SUCCESS;
-}
-
-
-//
-// Template used to initailize the GDB Serial IO protocols
-//
-GDB_SERIAL_DEV gdbSerialDevTemplate = {
- GDB_SERIAL_DEV_SIGNATURE,
- NULL,
-
- { // SerialIo
- SERIAL_IO_INTERFACE_REVISION,
- GdbSerialReset,
- GdbSerialSetAttributes,
- GdbSerialSetControl,
- GdbSerialGetControl,
- GdbSerialWrite,
- GdbSerialRead,
- NULL
- },
- { // SerialMode
- 0, // ControlMask
- 0, // Timeout
- 0, // BaudRate
- 1, // RceiveFifoDepth
- 0, // DataBits
- 0, // Parity
- 0 // StopBits
- },
- {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8) (sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)) >> 8)
- },
- },
- EFI_SERIAL_IO_PROTOCOL_GUID
- },
- 0,
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL) >> 8)
- }
- },
- },
- GDB_STDIN,
- GDB_STDOUT
-};
-
-
-/**
- Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.
-
- These console show up on the remote system running GDB
-
-**/
-VOID
-GdbInitializeSerialConsole (
- VOID
- )
-{
- EFI_STATUS Status;
- GDB_SERIAL_DEV *StdOutSerialDev;
- GDB_SERIAL_DEV *StdErrSerialDev;
-
- // Use the template to make a copy of the Serial Console private data structure.
- StdOutSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
- ASSERT (StdOutSerialDev != NULL);
-
- // Fixup pointer after the copy
- StdOutSerialDev->SerialIo.Mode = &StdOutSerialDev->SerialMode;
-
- StdErrSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
- ASSERT (StdErrSerialDev != NULL);
-
- // Fixup pointer and modify stuff that is different for StdError
- StdErrSerialDev->SerialIo.Mode = &StdErrSerialDev->SerialMode;
- StdErrSerialDev->DevicePath.Index = 1;
- StdErrSerialDev->OutFileDescriptor = GDB_STDERR;
-
- // Make a new handle with Serial IO protocol and its device path on it.
- Status = gBS->InstallMultipleProtocolInterfaces (
- &StdOutSerialDev->Handle,
- &gEfiSerialIoProtocolGuid, &StdOutSerialDev->SerialIo,
- &gEfiDevicePathProtocolGuid, &StdOutSerialDev->DevicePath,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- // Make a new handle with Serial IO protocol and its device path on it.
- Status = gBS->InstallMultipleProtocolInterfaces (
- &StdErrSerialDev->Handle,
- &gEfiSerialIoProtocolGuid, &StdErrSerialDev->SerialIo,
- &gEfiDevicePathProtocolGuid, &StdErrSerialDev->DevicePath,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-}
-
diff --git a/EmbeddedPkg/GdbStub/X64/Processor.c b/EmbeddedPkg/GdbStub/X64/Processor.c
deleted file mode 100644
index cbe50d78ec..0000000000
--- a/EmbeddedPkg/GdbStub/X64/Processor.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/** @file
- Processor specific parts of the GDB stub
-
- 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 <GdbStubInternal.h>
-
-//
-// Array of exception types that need to be hooked by the debugger
-//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_X64_DIVIDE_ERROR, GDB_SIGFPE },
- { EXCEPT_X64_DEBUG, GDB_SIGTRAP },
- { EXCEPT_X64_NMI, GDB_SIGEMT },
- { EXCEPT_X64_BREAKPOINT, GDB_SIGTRAP },
- { EXCEPT_X64_OVERFLOW, GDB_SIGSEGV },
- { EXCEPT_X64_BOUND, GDB_SIGSEGV },
- { EXCEPT_X64_INVALID_OPCODE, GDB_SIGILL },
- { EXCEPT_X64_DOUBLE_FAULT, GDB_SIGEMT },
- { EXCEPT_X64_STACK_FAULT, GDB_SIGSEGV },
- { EXCEPT_X64_GP_FAULT, GDB_SIGSEGV },
- { EXCEPT_X64_PAGE_FAULT, GDB_SIGSEGV },
- { EXCEPT_X64_FP_ERROR, GDB_SIGEMT },
- { EXCEPT_X64_ALIGNMENT_CHECK, GDB_SIGEMT },
- { EXCEPT_X64_MACHINE_CHECK, GDB_SIGEMT }
-};
-
-
-// The offsets of registers SystemContextX64.
-// The fields in the array are in the gdb ordering.
-// HAVE TO DOUBLE-CHECK THE ORDER of the 24 regs
-//
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rax),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rcx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rdx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rbx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rsp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rbp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rsi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rdi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rip),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rflags),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Cs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Ss),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Ds),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Es),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Fs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Gs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R8),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R9),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R10),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R11),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R12),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R13),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R14),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R15)
-};
-
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- )
-{
- return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
-}
-
-
-/**
- Return the number of entries in the gRegisters[]
-
- @retval UINTN, the number of entries (registers) in the gRegisters[] array.
- **/
-UINTN
-MaxRegisterCount (
- VOID
- )
-{
- return sizeof (gRegisterOffsets)/sizeof (UINTN);
-}
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported
-**/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- )
-{
- return (BOOLEAN)(Isa == IsaX64);
-}
-
-
-/**
- This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
- It is, by default, set to find the register pointer of the X64 member
- @param SystemContext Register content at time of the exception
- @param RegNumber The register to which we want to find a pointer
- @retval the pointer to the RegNumber-th pointer
- **/
-UINTN *
-FindPointerToRegister(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- )
-{
- UINT8 *TempPtr;
- TempPtr = ((UINT8 *)SystemContext.SystemContextX64) + gRegisterOffsets[RegNumber];
- return (UINTN *)TempPtr;
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to read
- @param OutBufPtr pointer to the output buffer's end. the new data will be added from this point on.
- @retval the pointer to the next character of the output buffer that is available to be written on.
- **/
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- )
-{
- UINTN RegSize;
-
- RegSize = 0;
- while (RegSize < 64) {
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
- RegSize = RegSize + 8;
- }
- return OutBufPtr;
-}
-
-
-/** ‘p n’
- Reads the n-th register's value into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 OutBuffer[17]; // 1 reg=16 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
-
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
-
- OutBufPtr = OutBuffer;
- OutBufPtr = BasicReadRegister(SystemContext, RegNumber, OutBufPtr);
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket (OutBuffer);
-}
-
-
-/** ‘g’
- Reads the general registers into an output buffer and sends it as a packet
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINTN i;
- CHAR8 OutBuffer[385]; // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- OutBufPtr = OutBuffer;
- for(i = 0 ; i < MaxRegisterCount() ; i++) { // there are only 24 registers to read
- OutBufPtr = BasicReadRegister(SystemContext, i, OutBufPtr);
- }
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket (OutBuffer);
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
-
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to write
- @param InBufPtr pointer to the output buffer. the new data will be extracted from the input buffer from this point on.
- @retval the pointer to the next character of the input buffer that can be used
- **/
-CHAR8 *
-BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- )
-{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT64 NewValue; // the new value of the RegNumber-th Register
-
- NewValue = 0;
- RegSize = 0;
- while (RegSize < 64) {
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
- }
- *(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
- return InBufPtr;
-}
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Ponter to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
-
- // find the register number to write
- InBufPtr = &InBuffer[1];
- RegNumBufPtr = RegNumBuffer;
- while (*InBufPtr != '=') {
- *RegNumBufPtr++ = *InBufPtr++;
- }
- *RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
-
- // check if this is a valid Register Number
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
- InBufPtr++; // skips the '=' character
- BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
-}
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- // check to see if the buffer is the right size which is
- // 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 385
- if (AsciiStrLen(InBuffer) != 385) { // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
- //Bad message. Message is not the right length
- SendError (GDB_EBADBUFSIZE);
- return;
- }
-
- InBufPtr = &InBuffer[1];
-
- // Read the new values for the registers from the input buffer to an array, NewValueArray.
- // The values in the array are in the gdb ordering
- for(i=0; i < MaxRegisterCount(); i++) { // there are only 16 registers to write
- InBufPtr = BasicWriteRegister(SystemContext, i, InBufPtr);
- }
-
- SendSuccess();
-}
-
-
- /**
- Insert Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-AddSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- SystemContext.SystemContextX64->Rflags |= TF_BIT; //Setting the TF bit.
-}
-
-
-
-/**
- Remove Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-RemoveSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- SystemContext.SystemContextX64->Rflags &= ~TF_BIT; // clearing the TF bit.
-}
-
-
-
-/** ‘c [addr ]’
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn(&PacketData[1]);
- }
-}
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn (&PacketData[1]);
- }
-
- AddSingleStep (SystemContext);
-}
-
-
-/**
- Returns breakpoint data address from DR0-DR3 based on the input breakpoint
- number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval Address Data address from DR0-DR3 based on the
- breakpoint number.
-
-**/
-UINTN
-GetBreakpointDataAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- UINTN Address;
-
- if (BreakpointNumber == 1) {
- Address = SystemContext.SystemContextIa32->Dr0;
- } else if (BreakpointNumber == 2) {
- Address = SystemContext.SystemContextIa32->Dr1;
- } else if (BreakpointNumber == 3) {
- Address = SystemContext.SystemContextIa32->Dr2;
- } else if (BreakpointNumber == 4) {
- Address = SystemContext.SystemContextIa32->Dr3;
- } else {
- Address = 0;
- }
-
- return Address;
-}
-
-/**
- Returns currently detected breakpoint value based on the register
- DR6 B0-B3 field.
- If no breakpoint is detected then it returns 0.
-
- @param SystemContext Register content at time of the exception
-
- @retval {1-4} Currently detected breakpoint value
- @retval 0 No breakpoint detected.
-
-**/
-UINTN
-GetBreakpointDetected (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- IA32_DR6 Dr6;
- UINTN BreakpointNumber;
-
- Dr6.UintN = SystemContext.SystemContextIa32->Dr6;
-
- if (Dr6.Bits.B0 == 1) {
- BreakpointNumber = 1;
- } else if (Dr6.Bits.B1 == 1) {
- BreakpointNumber = 2;
- } else if (Dr6.Bits.B2 == 1) {
- BreakpointNumber = 3;
- } else if (Dr6.Bits.B3 == 1) {
- BreakpointNumber = 4;
- } else {
- BreakpointNumber = 0; //No breakpoint detected
- }
-
- return BreakpointNumber;
-}
-
-/**
- Returns Breakpoint type (InstructionExecution, DataWrite, DataRead
- or DataReadWrite) based on the Breakpoint number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval BREAK_TYPE Breakpoint type value read from register DR7 RWn
- field. For unknown value, it returns NotSupported.
-
-**/
-BREAK_TYPE
-GetBreakpointType (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- IA32_DR7 Dr7;
- BREAK_TYPE Type = NotSupported; //Default is NotSupported type
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (BreakpointNumber == 1) {
- Type = (BREAK_TYPE) Dr7.Bits.RW0;
- } else if (BreakpointNumber == 2) {
- Type = (BREAK_TYPE) Dr7.Bits.RW1;
- } else if (BreakpointNumber == 3) {
- Type = (BREAK_TYPE) Dr7.Bits.RW2;
- } else if (BreakpointNumber == 4) {
- Type = (BREAK_TYPE) Dr7.Bits.RW3;
- }
-
- return Type;
-}
-
-
-/**
- Parses Length and returns the length which DR7 LENn field accepts.
- For example: If we receive 1-Byte length then we should return 0.
- Zero gets written to DR7 LENn field.
-
- @param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
-
- @retval Length Appropriate converted values which DR7 LENn field accepts.
-
-**/
-UINTN
-ConvertLengthData (
- IN UINTN Length
- )
-{
- if (Length == 1) { //1-Byte length
- return 0;
- } else if (Length == 2) { //2-Byte length
- return 1;
- } else if (Length == 4) { //4-Byte length
- return 3;
- } else { //Undefined or 8-byte length
- return 2;
- }
-}
-
-
-/**
- Finds the next free debug register. If all the registers are occupied then
- EFI_OUT_OF_RESOURCES is returned.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3 for the first free debug register)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindNextFreeDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Dr7.Bits.G0 == 0) {
- *Register = 0;
- } else if (Dr7.Bits.G1 == 0) {
- *Register = 1;
- } else if (Dr7.Bits.G2 == 0) {
- *Register = 2;
- } else if (Dr7.Bits.G3 == 0) {
- *Register = 3;
- } else {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Enables the debug register. Writes Address value to appropriate DR0-3 register.
- Sets LENn, Gn, RWn bits in DR7 register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3)
- @param Address Breakpoint address value
- @param Type Breakpoint type (Instruction, Data write,
- Data read or write etc.)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-EnableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type
- )
-{
- IA32_DR7 Dr7;
-
- //Convert length data
- Length = ConvertLengthData (Length);
-
- //For Instruction execution, length should be 0
- //(Ref. Intel reference manual 18.2.4)
- if ((Type == 0) && (Length != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 1;
- Dr7.Bits.RW0 = Type;
- Dr7.Bits.LEN0 = Length;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 1;
- Dr7.Bits.RW1 = Type;
- Dr7.Bits.LEN1 = Length;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 1;
- Dr7.Bits.RW2 = Type;
- Dr7.Bits.LEN2 = Length;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 1;
- Dr7.Bits.RW3 = Type;
- Dr7.Bits.LEN3 = Length;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update Dr7 with appropriate Gn, RWn and LENn bits
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Returns register number 0 - 3 for the maching debug register.
- This function compares incoming Address, Type, Length and
- if there is a match then it returns the appropriate register number.
- In case of mismatch, function returns EFI_NOT_FOUND message.
-
- @param SystemContext Register content at time of the exception
- @param Address Breakpoint address value
- @param Length Breakpoint length value
- @param Type Breakpoint type (Instruction, Data write, Data read
- or write etc.)
- @param Register Register value to be returned
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Convert length data
- Length = ConvertLengthData(Length);
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if ((Dr7.Bits.G0 == 1) &&
- (Dr7.Bits.LEN0 == Length) &&
- (Dr7.Bits.RW0 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr0)) {
- *Register = 0;
- } else if ((Dr7.Bits.G1 == 1) &&
- (Dr7.Bits.LEN1 == Length) &&
- (Dr7.Bits.RW1 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr1)) {
- *Register = 1;
- } else if ((Dr7.Bits.G2 == 1) &&
- (Dr7.Bits.LEN2 == Length) &&
- (Dr7.Bits.RW2 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr2)) {
- *Register = 2;
- } else if ((Dr7.Bits.G3 == 1) &&
- (Dr7.Bits.LEN3 == Length) &&
- (Dr7.Bits.RW3 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr3)) {
- *Register = 3;
- } else {
- Print ((CHAR16 *)L"No match found..\n");
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Disables the particular debug register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register to be disabled
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- )
-{
- IA32_DR7 Dr7;
- UINTN Address = 0;
-
- //Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 0;
- Dr7.Bits.RW0 = 0;
- Dr7.Bits.LEN0 = 0;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 0;
- Dr7.Bits.RW1 = 0;
- Dr7.Bits.LEN1 = 0;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 0;
- Dr7.Bits.RW2 = 0;
- Dr7.Bits.LEN2 = 0;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 0;
- Dr7.Bits.RW3 = 0;
- Dr7.Bits.LEN3 = 0;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-/**
- ‘Z1, [addr], [length]’
- ‘Z2, [addr], [length]’
- ‘Z3, [addr], [length]’
- ‘Z4, [addr], [length]’
-
- Insert hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-InsertBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- EFI_STATUS Status;
- BREAK_TYPE BreakType = NotSupported;
- UINTN ErrorCode;
-
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- Print ((CHAR16 *)L"Insert breakpoint default: %x\n", Type);
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- // Find next free debug register
- Status = FindNextFreeDebugRegister (SystemContext, &Register);
- if (EFI_ERROR(Status)) {
- Print ((CHAR16 *)L"No space left on device\n");
- SendError (GDB_ENOSPACE);
- return;
- }
-
- // Write Address, length data at particular DR register
- Status = EnableDebugRegister (SystemContext, Register, Address, Length, (UINTN)BreakType);
- if (EFI_ERROR(Status)) {
-
- if (Status == EFI_UNSUPPORTED) {
- Print ((CHAR16 *)L"Not supported\n");
- SendNotSupported();
- return;
- }
-
- Print ((CHAR16 *)L"Invalid argument\n");
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-/**
- ‘z1, [addr], [length]’
- ‘z2, [addr], [length]’
- ‘z3, [addr], [length]’
- ‘z4, [addr], [length]’
-
- Remove hardware breakpoint/watchpoint at address addr of size length
-
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-RemoveBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- BREAK_TYPE BreakType = NotSupported;
- EFI_STATUS Status;
- UINTN ErrorCode;
-
- //Parse breakpoint packet data
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- //Find matching debug register
- Status = FindMatchingDebugRegister (SystemContext, Address, Length, (UINTN)BreakType, &Register);
- if (EFI_ERROR(Status)) {
-
- if (Status == EFI_UNSUPPORTED) {
- Print ((CHAR16 *)L"Not supported.\n");
- SendNotSupported();
- return;
- }
-
- Print ((CHAR16 *)L"No matching register found.\n");
- SendError (GDB_ENOSPACE);
- return;
- }
-
- //Remove breakpoint
- Status = DisableDebugRegister(SystemContext, Register);
- if (EFI_ERROR(Status)) {
- Print ((CHAR16 *)L"Invalid argument.\n");
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-VOID
-InitializeProcessor (
- VOID
- )
-{
-}
-
-BOOLEAN
-ValidateAddress (
- IN VOID *Address
- )
-{
- return TRUE;
-}
-
-BOOLEAN
-ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- return TRUE;
-}
-
diff --git a/EmbeddedPkg/Include/Guid/ExtractSection.h b/EmbeddedPkg/Include/Guid/ExtractSection.h
deleted file mode 100644
index f471e876a1..0000000000
--- a/EmbeddedPkg/Include/Guid/ExtractSection.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/** @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 __EXTRACT_SECTION_GUID_H__
-#define __EXTRACT_SECTION_GUID_H__
-
-#include <Library/ExtractGuidedSectionLib.h>
-
-
-//
-// The GUID for this protocol mathes the Decompression scheme being used
-// So for example LZMA would be gLzmaCustomDecompressGuid
-//
-typedef struct {
- EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo;
- EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction;
-} EXTRACT_SECTION_DATA;
-
-typedef struct {
- EFI_HOB_GUID_TYPE Hob;
- EXTRACT_SECTION_DATA Data;
-} EXTRACT_SECTION_HOB;
-
-#endif
-
diff --git a/EmbeddedPkg/Include/Guid/Fdt.h b/EmbeddedPkg/Include/Guid/Fdt.h
deleted file mode 100644
index 74c85dc30b..0000000000
--- a/EmbeddedPkg/Include/Guid/Fdt.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
-*
-* Copyright (c) 2013-2014, 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__
-
-#define FDT_TABLE_GUID \
- { 0xb1b621d5, 0xf19c, 0x41a5, { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
-
-extern EFI_GUID gFdtTableGuid;
-
-#define FDT_VARIABLE_GUID \
- { 0x25a4fd4a, 0x9703, 0x4ba9, { 0xa1, 0x90, 0xb7, 0xc8, 0x4e, 0xfb, 0x3e, 0x57 } }
-
-extern EFI_GUID gFdtVariableGuid;
-
-#endif /* __FDT_H__ */
diff --git a/EmbeddedPkg/Include/Guid/FdtHob.h b/EmbeddedPkg/Include/Guid/FdtHob.h
deleted file mode 100644
index 287729e0c3..0000000000
--- a/EmbeddedPkg/Include/Guid/FdtHob.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file
- GUID for the HOB that contains the copy of the flattened device tree blob
-
- Copyright (C) 2014, Linaro Ltd.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License that 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_HOB_H__
-#define __FDT_HOB_H__
-
-#define FDT_HOB_GUID { \
- 0x16958446, 0x19B7, 0x480B, \
- { 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } \
- }
-
-extern EFI_GUID gFdtHobGuid;
-
-#endif
diff --git a/EmbeddedPkg/Include/Library/AcpiLib.h b/EmbeddedPkg/Include/Library/AcpiLib.h
deleted file mode 100644
index 42710fd1fd..0000000000
--- a/EmbeddedPkg/Include/Library/AcpiLib.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/** @file
- Helper Library for ACPI
-
- Copyright (c) 2014-2015, 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 __ACPI_LIB_H__
-#define __ACPI_LIB_H__
-
-#include <Uefi.h>
-
-#include <IndustryStandard/Acpi10.h>
-
-//
-// Macros for the Generic Address Space
-//
-#define NULL_GAS { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_UNDEFINED, 0L }
-#define ARM_GAS8(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 8, 0, EFI_ACPI_5_0_BYTE, Address }
-#define ARM_GAS16(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 16, 0, EFI_ACPI_5_0_WORD, Address }
-#define ARM_GAS32(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 32, 0, EFI_ACPI_5_0_DWORD, Address }
-#define ARM_GASN(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_DWORD, Address }
-
-//
-// Macros for the Multiple APIC Description Table (MADT)
-//
-#define EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(GicDistHwId, GicDistBase, GicDistVector) \
- { \
- EFI_ACPI_5_0_GICD, sizeof (EFI_ACPI_5_0_GIC_DISTRIBUTOR_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
- GicDistHwId, GicDistBase, GicDistVector, EFI_ACPI_RESERVED_DWORD \
- }
-
-// Note the parking protocol is configured by UEFI if required
-#define EFI_ACPI_5_0_GIC_STRUCTURE_INIT(GicId, AcpiCpuId, Flags, PmuIrq, GicBase) \
- { \
- EFI_ACPI_5_0_GIC, sizeof (EFI_ACPI_5_0_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
- GicId, AcpiCpuId, Flags, 0, PmuIrq, 0, GicBase \
- }
-
-// Note the parking protocol is configured by UEFI if required
-#define EFI_ACPI_5_1_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq, \
- GicBase, GicVBase, GicHBase, GsivId, GicRBase) \
- { \
- EFI_ACPI_5_1_GIC, sizeof (EFI_ACPI_5_1_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
- GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase, \
- GsivId, GicRBase, Mpidr \
- }
-
-#define EFI_ACPI_6_0_GIC_MSI_FRAME_INIT(GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase) \
- { \
- EFI_ACPI_6_0_GIC_MSI_FRAME, sizeof (EFI_ACPI_6_0_GIC_MSI_FRAME_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
- GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase \
- }
-
-//
-// SBSA Generic Watchdog
-//
-#define EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(RefreshFramePhysicalAddress, \
- ControlFramePhysicalAddress, WatchdogTimerGSIV, WatchdogTimerFlags) \
- { \
- EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG, sizeof(EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE), \
- EFI_ACPI_RESERVED_WORD, RefreshFramePhysicalAddress, ControlFramePhysicalAddress, \
- WatchdogTimerGSIV, WatchdogTimerFlags \
- }
-
-typedef
-BOOLEAN
-(EFIAPI *EFI_LOCATE_ACPI_CHECK) (
- IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader
- );
-
-/**
- Locate and Install the ACPI tables from the Firmware Volume if it verifies
- the function condition.
-
- @param AcpiFile Guid of the ACPI file into the Firmware Volume
- @param CheckAcpiTableFunction Function that checks if the ACPI table should be installed
-
- @return EFI_SUCCESS The function completed successfully.
- @return EFI_NOT_FOUND The protocol could not be located.
- @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
-
-**/
-EFI_STATUS
-LocateAndInstallAcpiFromFvConditional (
- IN CONST EFI_GUID* AcpiFile,
- IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
- );
-
-/**
- Locate and Install the ACPI tables from the Firmware Volume
-
- @param AcpiFile Guid of the ACPI file into the Firmware Volume
-
- @return EFI_SUCCESS The function completed successfully.
- @return EFI_NOT_FOUND The protocol could not be located.
- @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
-
-**/
-EFI_STATUS
-LocateAndInstallAcpiFromFv (
- IN CONST EFI_GUID* AcpiFile
- );
-
-#endif // __ACPI_LIB_H__
diff --git a/EmbeddedPkg/Include/Library/DebugAgentTimerLib.h b/EmbeddedPkg/Include/Library/DebugAgentTimerLib.h
deleted file mode 100755
index 0a5e5d491e..0000000000
--- a/EmbeddedPkg/Include/Library/DebugAgentTimerLib.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/** @file
- Platform specific Debug Agent abstraction for timer used by the agent.
-
- The timer is used by the debugger to break into a running program.
-
- 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 __GDB_TIMER_LIB__
-#define __GDB_TIMER_LIB__
-
-
-
-/**
- Setup all the hardware needed for the debug agents timer.
-
- This function is used to set up debug enviroment. It may enable interrupts.
-
-**/
-VOID
-EFIAPI
-DebugAgentTimerIntialize (
- VOID
- );
-
-
-/**
- Set the period for the debug agent timer. Zero means disable the timer.
-
- @param[in] TimerPeriodMilliseconds Frequency of the debug agent timer.
-
-**/
-VOID
-EFIAPI
-DebugAgentTimerSetPeriod (
- IN UINT32 TimerPeriodMilliseconds
- );
-
-
-/**
- Perform End Of Interrupt for the debug agent timer. This is called in the
- interrupt handler after the interrupt has been processed.
-
-**/
-VOID
-EFIAPI
-DebugAgentTimerEndOfInterrupt (
- VOID
- );
-
-#endif
-
-
diff --git a/EmbeddedPkg/Include/Library/DmaLib.h b/EmbeddedPkg/Include/Library/DmaLib.h
deleted file mode 100755
index 3814291c28..0000000000
--- a/EmbeddedPkg/Include/Library/DmaLib.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/** @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 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__
-
-typedef enum {
- ///
- /// A read operation from system memory by a bus master.
- ///
- MapOperationBusMasterRead,
- ///
- /// A write operation from system memory by a bus master.
- ///
- MapOperationBusMasterWrite,
- ///
- /// Provides both read and write access to system memory by both the processor and a
- /// bus master. The buffer is coherent from both the processor's and the bus master's point of view.
- ///
- MapOperationBusMasterCommonBuffer,
- MapOperationMaximum
-} DMA_MAP_OPERATION;
-
-
-
-
-/**
- Provides the DMA controller-specific addresses needed to access system memory.
-
- Operation is relative to the DMA bus master.
-
- @param Operation Indicates if the bus master is going to read or write to system memory.
- @param HostAddress The system memory address to map to the DMA controller.
- @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
- that were mapped.
- @param DeviceAddress The resulting map address for the bus master controller to use to
- access the hosts HostAddress.
- @param Mapping A resulting value to pass to DmaUnmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
- @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,
- 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.
-
- @param Mapping The mapping value returned from 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 (
- IN VOID *Mapping
- );
-
-
-/**
- Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer.
- mapping.
-
- @param MemoryType The type of memory to allocate, EfiBootServicesData or
- EfiRuntimeServicesData.
- @param Pages The number of pages to allocate.
- @param HostAddress A pointer to store the base system memory address of the
- allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
- @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
- MEMORY_WRITE_COMBINE and MEMORY_CACHED.
- @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,
- IN UINTN Pages,
- OUT VOID **HostAddress
- );
-
-
-/**
- Frees memory that was allocated with DmaAllocateBuffer().
-
- @param Pages The number of pages to free.
- @param HostAddress The base system memory address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
- @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
- was not allocated with DmaAllocateBuffer().
-
-**/
-EFI_STATUS
-EFIAPI
-DmaFreeBuffer (
- IN UINTN Pages,
- IN VOID *HostAddress
- );
-
-
-#endif
-
diff --git a/EmbeddedPkg/Include/Library/EblAddExternalCommandLib.h b/EmbeddedPkg/Include/Library/EblAddExternalCommandLib.h
deleted file mode 100644
index 65aedddddd..0000000000
--- a/EmbeddedPkg/Include/Library/EblAddExternalCommandLib.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/** @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
-
diff --git a/EmbeddedPkg/Include/Library/EblCmdLib.h b/EmbeddedPkg/Include/Library/EblCmdLib.h
deleted file mode 100644
index 5df71e634a..0000000000
--- a/EmbeddedPkg/Include/Library/EblCmdLib.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/** @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
-
diff --git a/EmbeddedPkg/Include/Library/EblNetworkLib.h b/EmbeddedPkg/Include/Library/EblNetworkLib.h
deleted file mode 100644
index 66dc6ac305..0000000000
--- a/EmbeddedPkg/Include/Library/EblNetworkLib.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/** @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
-
diff --git a/EmbeddedPkg/Include/Library/EfiFileLib.h b/EmbeddedPkg/Include/Library/EfiFileLib.h
deleted file mode 100644
index e86be4c95b..0000000000
--- a/EmbeddedPkg/Include/Library/EfiFileLib.h
+++ /dev/null
@@ -1,350 +0,0 @@
-/** @file
- Library functions that perform file IO. Memory buffer, file system, and
- fimrware volume operations are supproted.
-
- 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.
-
- Basic support for opening files on different device types. The device string
- is in the form of DevType:Path. Current DevType is required as there is no
- current mounted device concept of current working directory concept implement
- by this library.
-
- Device names are case insensative and only check the leading characters for
- unique matches. Thus the following are all the same:
- LoadFile0:
- l0:
- L0:
- Lo0:
-
- Supported Device Names:
- A0x1234:0x12 - A memory buffer starting at address 0x1234 for 0x12 bytes
- l1: - EFI LoadFile device one.
- B0: - EFI BlockIo zero.
- fs3: - EFI Simple File System device 3
- Fv2: - EFI Firmware VOlume device 2
- 1.2.3.4:name - TFTP IP and file name
-
-**/
-
-#ifndef __EFI_FILE_LIB_H__
-#define __EFI_FILE_LIB_H__
-
-#include <PiDxe.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/FirmwareVolumeBlock.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/LoadFile.h>
-#include <Protocol/LoadFile.h>
-#include <Protocol/SimpleFileSystem.h>
-#include <Guid/FileInfo.h>
-#include <Guid/FileSystemInfo.h>
-
-#define MAX_PATHNAME 0x200
-
-/// Type of the file that has been opened
-typedef enum {
- EfiOpenLoadFile,
- EfiOpenMemoryBuffer,
- EfiOpenFirmwareVolume,
- EfiOpenFileSystem,
- EfiOpenBlockIo,
- EfiOpenTftp,
- EfiOpenMaxValue
-} EFI_OPEN_FILE_TYPE;
-
-
-/// Public information about the open file
-typedef struct {
- UINTN Version; // Common information
- EFI_OPEN_FILE_TYPE Type;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_STATUS LastError;
- EFI_HANDLE EfiHandle;
- CHAR8 *DeviceName;
- CHAR8 *FileName;
-
- UINT64 CurrentPosition; // Information for Seek
- UINT64 MaxPosition;
-
- UINTN BaseOffset; // Base offset for hexdump command
-
- UINTN Size; // Valid for all types other than l#:
- UINT8 *Buffer; // Information valid for A#:
-
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; // Information valid for Fv#:
- EFI_GUID FvNameGuid;
- EFI_SECTION_TYPE FvSectionType;
- EFI_FV_FILETYPE FvType;
- EFI_FV_FILE_ATTRIBUTES FvAttributes;
-
- EFI_PHYSICAL_ADDRESS FvStart;
- UINTN FvSize;
- UINTN FvHeaderSize;
-
- EFI_FILE *FsFileHandle; // Information valid for Fs#:
- EFI_FILE_SYSTEM_INFO *FsInfo;
- EFI_FILE_INFO *FsFileInfo;
- EFI_BLOCK_IO_MEDIA *FsBlockIoMedia; // Information valid for Fs#: or B#:
- EFI_BLOCK_IO_PROTOCOL *FsBlockIo; // Information valid for Fs#: or B#:
-
- UINTN DiskOffset; // Information valid for B#:
-
- EFI_LOAD_FILE_PROTOCOL *LoadFile; // Information valid for l#:
-
- EFI_IP_ADDRESS ServerIp; // Information valid for t:
- BOOLEAN IsDirty;
- BOOLEAN IsBufferValid;
-
-} EFI_OPEN_FILE;
-
-
-/// Type of Seek to perform
-typedef enum {
- EfiSeekStart,
- EfiSeekCurrent,
- EfiSeekEnd,
- EfiSeekMax
-} EFI_SEEK_TYPE;
-
-
-/**
- Open a device named by PathName. The PathName includes a device name and
- path separated by a :. See file header for more details on the PathName
- syntax. There is no checking to prevent a file from being opened more than
- one type.
-
- SectionType is only used to open an FV. Each file in an FV contains multiple
- sections and only the SectionType section is opened.
-
- For any file that is opened with EfiOpen() must be closed with EfiClose().
-
- @param PathName Path to parse to open
- @param OpenMode Same as EFI_FILE.Open()
- @param SectionType Section in FV to open.
-
- @return NULL Open failed
- @return Valid EFI_OPEN_FILE handle
-
-**/
-EFI_OPEN_FILE *
-EfiOpen (
- IN CHAR8 *PathName,
- IN CONST UINT64 OpenMode,
- IN CONST EFI_SECTION_TYPE SectionType
- );
-
-EFI_STATUS
-EfiCopyFile (
- IN CHAR8 *DestinationFile,
- IN CHAR8 *SourceFile
- );
-
-/**
- Use DeviceType and Index to form a valid PathName and try and open it.
-
- @param DeviceType Device type to open
- @param Index Device Index to use. Zero relative.
-
- @return NULL Open failed
- @return Valid EFI_OPEN_FILE handle
-
-**/
-EFI_OPEN_FILE *
-EfiDeviceOpenByType (
- IN EFI_OPEN_FILE_TYPE DeviceType,
- IN UINTN Index
- );
-
-
-/**
- Close a file handle opened by EfiOpen() and free all resources allocated by
- EfiOpen().
-
- @param Stream Open File Handle
-
- @return EFI_INVALID_PARAMETER Stream is not an Open File
- @return EFI_SUCCESS Steam closed
-
-**/
-EFI_STATUS
-EfiClose (
- IN EFI_OPEN_FILE *Stream
- );
-
-
-/**
- Return the size of the file represented by Stream. Also return the current
- Seek position. Opening a file will enable a valid file size to be returned.
- LoadFile is an exception as a load file size is set to zero.
-
- @param Stream Open File Handle
-
- @return 0 Stream is not an Open File or a valid LoadFile handle
-
-**/
-UINTN
-EfiTell (
- IN EFI_OPEN_FILE *Stream,
- OUT UINT64 *CurrentPosition OPTIONAL
- );
-
-
-/**
- Seek to the Offset location in the file. LoadFile and FV device types do
- not support EfiSeek(). It is not possible to grow the file size using
- EfiSeek().
-
- SeekType defines how use Offset to calculate the new file position:
- EfiSeekStart : Position = Offset
- EfiSeekCurrent: Position is Offset bytes from the current position
- EfiSeekEnd : Only supported if Offset is zero to seek to end of file.
-
- @param Stream Open File Handle
- @param Offset Offset to seek too.
- @param SeekType Type of seek to perform
-
-
- @return EFI_INVALID_PARAMETER Stream is not an Open File
- @return EFI_UNSUPPORTED LoadFile and FV does not support Seek
- @return EFI_NOT_FOUND Seek past the end of the file.
- @return EFI_SUCCESS Steam closed
-
-**/
-EFI_STATUS
-EfiSeek (
- IN EFI_OPEN_FILE *Stream,
- IN EFI_LBA Offset,
- IN EFI_SEEK_TYPE SeekType
- );
-
-
-/**
- Read BufferSize bytes from the current location in the file. For load file
- and FV case you must read the entire file.
-
- @param Stream Open File Handle
- @param Buffer Caller allocated buffer.
- @param BufferSize Size of buffer in bytes.
-
-
- @return EFI_SUCCESS Stream is not an Open File
- @return EFI_END_OF_FILE Tried to read past the end of the file
- @return EFI_INVALID_PARAMETER Stream is not an open file handle
- @return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read
- @return "other" Error returned from device read
-
-**/
-EFI_STATUS
-EfiRead (
- IN EFI_OPEN_FILE *Stream,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
- );
-
-
-/**
- Read the entire file into a buffer. This routine allocates the buffer and
- returns it to the user full of the read data.
-
- This is very useful for load file where it's hard to know how big the buffer
- must be.
-
- @param Stream Open File Handle
- @param Buffer Pointer to buffer to return.
- @param BufferSize Pointer to Size of buffer return..
-
-
- @return EFI_SUCCESS Stream is not an Open File
- @return EFI_END_OF_FILE Tried to read past the end of the file
- @return EFI_INVALID_PARAMETER Stream is not an open file handle
- @return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read
- @return "other" Error returned from device read
-
-**/
-EFI_STATUS
-EfiReadAllocatePool (
- IN EFI_OPEN_FILE *Stream,
- OUT VOID **Buffer,
- OUT UINTN *BufferSize
- );
-
-
-/**
- Write data back to the file.
-
- @param Stream Open File Handle
- @param Buffer Pointer to buffer to return.
- @param BufferSize Pointer to Size of buffer return..
-
-
- @return EFI_SUCCESS Stream is not an Open File
- @return EFI_END_OF_FILE Tried to read past the end of the file
- @return EFI_INVALID_PARAMETER Stream is not an open file handle
- @return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read
- @return "other" Error returned from device write
-
-**/
-EFI_STATUS
-EfiWrite (
- IN EFI_OPEN_FILE *Stream,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
- );
-
-
-/**
- Return the number of devices of the current type active in the system
-
- @param Type Device type to check
-
- @return 0 Invalid type
-
-**/
-UINTN
-EfiGetDeviceCounts (
- IN EFI_OPEN_FILE_TYPE Type
- );
-
-
-/**
- Set the Current Working Directory (CWD). If a call is made to EfiOpen () and
- the path does not contain a device name, The CWD is prepended to the path.
-
- @param Cwd Current Working Directory to set
-
-
- @return EFI_SUCCESS CWD is set
- @return EFI_INVALID_PARAMETER Cwd is not a valid device:path
-
-**/
-EFI_STATUS
-EfiSetCwd (
- IN CHAR8 *Cwd
- );
-
-/**
- Set the Current Working Directory (CWD). If a call is made to EfiOpen () and
- the path does not contain a device name, The CWD is prepended to the path.
-
- @param Cwd Current Working Directory
-
-
- @return NULL No CWD set
- @return 'other' malloc'ed buffer contains CWD.
-
-**/
-CHAR8 *
-EfiGetCwd (
- VOID
- );
-
-#endif
diff --git a/EmbeddedPkg/Include/Library/EfiResetSystemLib.h b/EmbeddedPkg/Include/Library/EfiResetSystemLib.h
deleted file mode 100644
index 83b95c9ddb..0000000000
--- a/EmbeddedPkg/Include/Library/EfiResetSystemLib.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/** @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 __EFI_RESET_SYSTEM_LIB_H___
-#define __EFI_RESET_SYSTEM_LIB_H___
-
-
-/**
- Resets the entire platform.
-
- @param ResetType The type of reset to perform.
- @param ResetStatus The status code for the reset.
- @param DataSize The size, in bytes, of WatchdogData.
- @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
- EfiResetShutdown the data buffer starts with a Null-terminated
- Unicode string, optionally followed by additional binary data.
-
-**/
-EFI_STATUS
-EFIAPI
-LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- );
-
-
-
-/**
- Initialize any infrastructure required for LibResetSystem () to function.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-EFI_STATUS
-EFIAPI
-LibInitializeResetSystem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-#endif
diff --git a/EmbeddedPkg/Include/Library/FdtLoadLib.h b/EmbeddedPkg/Include/Library/FdtLoadLib.h
deleted file mode 100644
index e08f499745..0000000000
--- a/EmbeddedPkg/Include/Library/FdtLoadLib.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, 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_LOAD_LIB_H_
-#define _FDT_LOAD_LIB_H_
-
-/**
- Load and Install FDT from Semihosting
-
- @param Filename Name of the file to load from semihosting
-
- @return EFI_SUCCESS Fdt Blob was successfully installed into the configuration table
- from semihosting
- @return EFI_NOT_FOUND Fail to locate the file in semihosting
- @return EFI_OUT_OF_RESOURCES Fail to allocate memory to contain the blob
-**/
-EFI_STATUS
-InstallFdtFromSemihosting (
- IN CONST CHAR16* FileName
- );
-
-/**
- Load and Install FDT from Firmware Volume
-
- @param Filename Guid of the FDT blob to load from firmware volume
-
- @return EFI_SUCCESS Fdt Blob was successfully installed into the configuration table
- from firmware volume
- @return EFI_NOT_FOUND Failed to locate the file in firmware volume
- @return EFI_OUT_OF_RESOURCES Failed to allocate memory to contain the blob
-**/
-EFI_STATUS
-InstallFdtFromFv (
- IN CONST EFI_GUID *FileName
- );
-
-#endif
diff --git a/EmbeddedPkg/Include/Library/GdbSerialLib.h b/EmbeddedPkg/Include/Library/GdbSerialLib.h
deleted file mode 100644
index aa4c3ff640..0000000000
--- a/EmbeddedPkg/Include/Library/GdbSerialLib.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @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
-
diff --git a/EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h b/EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h
deleted file mode 100644
index af813956f1..0000000000
--- a/EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/** @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 __RUNTIME_SERVICES_LIB_H__
-#define __RUNTIME_SERVICES_LIB_H__
-
-VOID
-LibMtcInitialize (VOID);
-
-VOID
-LibMtcVirtualAddressChangeEvent (VOID);
-
-EFI_STATUS
-EFIAPI
-LibMtcGetNextHighMonotonicCount (
- OUT UINT32 *HighCount
- );
-
-EFI_STATUS
-LibMtcGetNextMonotonicCount (
- OUT UINT64 *Count
- );
-
-
-
-VOID
-LibVariableInitialize (VOID);
-
-VOID
-LibVariableVirtualAddressChangeEvent (VOID);
-
-EFI_STATUS
-LibGetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- OUT UINT32 *Attributes OPTIONAL,
- IN OUT UINTN *DataSize,
- OUT VOID *Data
- );
-
-EFI_STATUS
-LibGetNextVariableName (
- IN OUT UINTN *VariableNameSize,
- IN OUT CHAR16 *VariableName,
- IN OUT EFI_GUID *VendorGuid
- );
-
-EFI_STATUS
-LibSetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
- );
-
-EFI_STATUS
-LibQueryVariableInfo (
- IN UINT32 Attributes,
- OUT UINT64 *MaximumVariableStorageSize,
- OUT UINT64 *RemainingVariableStorageSize,
- OUT UINT64 *MaximumVariableSize
- );
-
-
-
-VOID
-LibResetInitializeReset (VOID);
-
-VOID
-LibResetVirtualAddressChangeEvent (VOID);
-
-VOID
-LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- );
-
-
-VOID
-LibCapsuleInitialize (VOID);
-
-VOID
-LibCapsuleVirtualAddressChangeEvent (VOID);
-
-EFI_STATUS
-LibUpdateCapsule (
- IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
- IN UINTN CapsuleCount,
- IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
- );
-
-EFI_STATUS
-QueryCapsuleCapabilities (
- IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
- IN UINTN CapsuleCount,
- OUT UINT64 *MaxiumCapsuleSize,
- OUT EFI_RESET_TYPE *ResetType
- );
-
-
-
-VOID
-LibRtcInitialize (VOID);
-
-VOID
-LibRtcVirtualAddressChangeEvent (VOID);
-
-EFI_STATUS
-LibGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities
- );
-
-EFI_STATUS
-LibSetTime (
- IN EFI_TIME *Time
- );
-
-EFI_STATUS
-LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
- );
-
-EFI_STATUS
-LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
- );
-
-
-VOID
-LibReportStatusCodeInitialize (VOID);
-
-VOID
-LibReportStatusCodeVirtualAddressChangeEvent (VOID);
-
-EFI_STATUS
-LibReportStatusCode (
- IN EFI_STATUS_CODE_TYPE CodeType,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN EFI_GUID *CallerId,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
- );
-
-
-#endif
-
diff --git a/EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h b/EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h
deleted file mode 100644
index 16b9ed2e24..0000000000
--- a/EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011, 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 __PREPI_HOBLIST_POINTER_LIB_H__
-#define __PREPI_HOBLIST_POINTER_LIB_H__
-
-/**
- Returns the pointer to the HOB list.
-
- This function returns the pointer to first HOB in the list.
-
- @return The pointer to the HOB list.
-
-**/
-VOID *
-EFIAPI
-PrePeiGetHobList (
- VOID
- );
-
-/**
- Updates the pointer to the HOB list.
-
- @param HobList Hob list pointer to store
-
-**/
-EFI_STATUS
-EFIAPI
-PrePeiSetHobList (
- IN VOID *HobList
- );
-
-#endif
diff --git a/EmbeddedPkg/Include/Library/PrePiLib.h b/EmbeddedPkg/Include/Library/PrePiLib.h
deleted file mode 100644
index cf70fca3b6..0000000000
--- a/EmbeddedPkg/Include/Library/PrePiLib.h
+++ /dev/null
@@ -1,789 +0,0 @@
-/** @file
- Library that helps implement monolithic PEI. (SEC goes to DXE)
-
- 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 __PRE_PI_LIB_H__
-#define __PRE_PI_LIB_H__
-
-#include <Guid/ExtractSection.h>
-
-/**
- This service enables discovery of additional firmware volumes.
-
- @param Instance This instance of the firmware volume to find. The value 0 is the
- Boot Firmware Volume (BFV).
- @param FwVolHeader Pointer to the firmware volume header of the volume to return.
-
- @retval EFI_SUCCESS The volume was found.
- @retval EFI_NOT_FOUND The volume was not found.
- @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindNextVolume (
- IN UINTN Instance,
- IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
- );
-
-
-/**
- This service enables discovery of additional firmware files.
-
- @param SearchType A filter to find files only of this type.
- @param FwVolHeader Pointer to the firmware volume header of the volume to search.
- This parameter must point to a valid FFS volume.
- @param FileHeader Pointer to the current file from which to begin searching.
-
- @retval EFI_SUCCESS The file was found.
- @retval EFI_NOT_FOUND The file was not found.
- @retval EFI_NOT_FOUND The header checksum was not zero.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindNextFile (
- IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
- );
-
-
-/**
- This service enables discovery sections of a given type within a valid FFS file.
-
- @param SearchType The value of the section type to find.
- @param FfsFileHeader A pointer to the file header that contains the set of sections to
- be searched.
- @param SectionData A pointer to the discovered section, if successful.
-
- @retval EFI_SUCCESS The section was found.
- @retval EFI_NOT_FOUND The section was not found.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT VOID **SectionData
- );
-
-
-/**
- Find a file in the volume by name
-
- @param FileName A pointer to the name of the file to
- find within the firmware volume.
-
- @param VolumeHandle The firmware volume to search FileHandle
- Upon exit, points to the found file's
- handle or NULL if it could not be found.
-
- @retval EFI_SUCCESS File was found.
-
- @retval EFI_NOT_FOUND File was not found.
-
- @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
- FileName was NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindByName (
- IN CONST EFI_GUID *FileName,
- IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
- );
-
-
-/**
- Get information about the file by name.
-
- @param FileHandle Handle of the file.
-
- @param FileInfo Upon exit, points to the file's
- information.
-
- @retval EFI_SUCCESS File information returned.
-
- @retval EFI_INVALID_PARAMETER If FileHandle does not
- represent a valid file.
-
- @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsGetFileInfo (
- IN CONST EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_FV_FILE_INFO *FileInfo
- );
-
-
-/**
- Get Information about the volume by name
-
- @param VolumeHandle Handle of the volume.
-
- @param VolumeInfo Upon exit, points to the volume's
- information.
-
- @retval EFI_SUCCESS File information returned.
-
- @retval EFI_INVALID_PARAMETER If FileHandle does not
- represent a valid file.
-
- @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_FV_INFO *VolumeInfo
- );
-
-
-
-/**
- Get Fv image from the FV type file, then add FV & FV2 Hob.
-
- @param FileHandle File handle of a Fv type file.
-
- @retval EFI_NOT_FOUND FV image can't be found.
- @retval EFI_SUCCESS Successfully to process it.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsProcessFvFile (
- IN EFI_PEI_FILE_HANDLE FvFileHandle
- );
-
-
-/**
- Search through every FV until you find a file of type FileType
-
- @param FileType File handle of a Fv type file.
- @param Volumehandle On succes Volume Handle of the match
- @param FileHandle On success File Handle of the match
-
- @retval EFI_NOT_FOUND FV image can't be found.
- @retval EFI_SUCCESS Successfully found FileType
-
-**/
-EFI_STATUS
-EFIAPI
-FfsAnyFvFindFirstFile (
- IN EFI_FV_FILETYPE FileType,
- OUT EFI_PEI_FV_HANDLE *VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
- );
-
-
-/**
- Get Fv image from the FV type file, then add FV & FV2 Hob.
-
- @param FileHandle File handle of a Fv type file.
-
-
- @retval EFI_NOT_FOUND FV image can't be found.
- @retval EFI_SUCCESS Successfully to process it.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsProcessFvFile (
- IN EFI_PEI_FILE_HANDLE FvFileHandle
- );
-
-
-/**
- This service enables PEIMs to ascertain the present value of the boot mode.
-
-
- @retval BootMode
-
-**/
-EFI_BOOT_MODE
-EFIAPI
-GetBootMode (
- VOID
- );
-
-
-/**
- This service enables PEIMs to update the boot mode variable.
-
- @param BootMode The value of the boot mode to set.
-
- @retval EFI_SUCCESS The value was successfully updated
-
-**/
-EFI_STATUS
-EFIAPI
-SetBootMode (
- IN EFI_BOOT_MODE BootMode
- );
-
-/**
- This service enables a PEIM to ascertain the address of the list of HOBs in memory.
-
- @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
-
- @retval EFI_SUCCESS The list was successfully returned.
- @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
-
-**/
-VOID *
-EFIAPI
-GetHobList (
- VOID
- );
-
-
-/**
- Updates the pointer to the HOB list.
-
- @param HobList Hob list pointer to store
-
-**/
-EFI_STATUS
-EFIAPI
-SetHobList (
- IN VOID *HobList
- );
-
-EFI_HOB_HANDOFF_INFO_TABLE*
-HobConstructor (
- IN VOID *EfiMemoryBegin,
- IN UINTN EfiMemoryLength,
- IN VOID *EfiFreeMemoryBottom,
- IN VOID *EfiFreeMemoryTop
- );
-
-/**
- Retrieves the magic value from the PE/COFF header.
-
- @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
-
- @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32
- @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
-
-**/
-VOID
-CreateHobList (
- IN VOID *MemoryBegin,
- IN UINTN MemoryLength,
- IN VOID *HobBase,
- IN VOID *StackBase
- );
-
-
-/**
- This service enables PEIMs to create various types of HOBs.
-
- @param Type The type of HOB to be installed.
- @param Length The length of the HOB to be added.
-
- @retval !NULL The HOB was successfully created.
- @retval NULL There is no additional space for HOB creation.
-
-**/
-VOID *
-CreateHob (
- IN UINT16 HobType,
- IN UINT16 HobLenght
- );
-
-
-/**
- Returns the next instance of a HOB type from the starting HOB.
-
- This function searches the first instance of a HOB type from the starting HOB pointer.
- If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
- In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
- unconditionally: it returns HobStart back if HobStart itself meets the requirement;
- caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
- If HobStart is NULL, then ASSERT().
-
- @param Type The HOB type to return.
- @param HobStart The starting HOB pointer to search from.
-
- @return The next instance of a HOB type from the starting HOB.
-
-**/
-VOID *
-EFIAPI
-GetNextHob (
- IN UINT16 Type,
- IN CONST VOID *HobStart
- );
-
-/**
- Returns the first instance of a HOB type among the whole HOB list.
-
- This function searches the first instance of a HOB type among the whole HOB list.
- If there does not exist such HOB type in the HOB list, it will return NULL.
-
- @param Type The HOB type to return.
-
- @return The next instance of a HOB type from the starting HOB.
-
-**/
-VOID *
-EFIAPI
-GetFirstHob (
- IN UINT16 Type
- );
-
-/**
- This function searches the first instance of a HOB from the starting HOB pointer.
- Such HOB should satisfy two conditions:
- its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
- If there does not exist such HOB from the starting HOB pointer, it will return NULL.
- Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
- to extract the data section and its size info respectively.
- In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
- unconditionally: it returns HobStart back if HobStart itself meets the requirement;
- caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
- If Guid is NULL, then ASSERT().
- If HobStart is NULL, then ASSERT().
-
- @param Guid The GUID to match with in the HOB list.
- @param HobStart A pointer to a Guid.
-
- @return The next instance of the matched GUID HOB from the starting HOB.
-
-**/
-VOID *
-EFIAPI
-GetNextGuidHob (
- IN CONST EFI_GUID *Guid,
- IN CONST VOID *HobStart
- );
-
-/**
- This function searches the first instance of a HOB among the whole HOB list.
- Such HOB should satisfy two conditions:
- its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
- If there does not exist such HOB from the starting HOB pointer, it will return NULL.
- Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
- to extract the data section and its size info respectively.
- If Guid is NULL, then ASSERT().
-
- @param Guid The GUID to match with in the HOB list.
-
- @return The first instance of the matched GUID HOB among the whole HOB list.
-
-**/
-VOID *
-EFIAPI
-GetFirstGuidHob (
- IN CONST EFI_GUID *Guid
- );
-
-
-/**
- Builds a HOB for a loaded PE32 module.
-
- This function builds a HOB for a loaded PE32 module.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If ModuleName is NULL, then ASSERT().
- If there is no additional space for HOB creation, then ASSERT().
-
- @param ModuleName The GUID File Name of the module.
- @param MemoryAllocationModule The 64 bit physical address of the module.
- @param ModuleLength The length of the module in bytes.
- @param EntryPoint The 64 bit physical address of the module entry point.
-
-**/
-VOID
-EFIAPI
-BuildModuleHob (
- IN CONST EFI_GUID *ModuleName,
- IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
- IN UINT64 ModuleLength,
- IN EFI_PHYSICAL_ADDRESS EntryPoint
- );
-
-/**
- Builds a HOB that describes a chunk of system memory.
-
- This function builds a HOB that describes a chunk of system memory.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param ResourceType The type of resource described by this HOB.
- @param ResourceAttribute The resource attributes of the memory described by this HOB.
- @param PhysicalStart The 64 bit physical address of memory described by this HOB.
- @param NumberOfBytes The length of the memory described by this HOB in bytes.
-
-**/
-VOID
-EFIAPI
-BuildResourceDescriptorHob (
- IN EFI_RESOURCE_TYPE ResourceType,
- IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
- IN EFI_PHYSICAL_ADDRESS PhysicalStart,
- IN UINT64 NumberOfBytes
- );
-
-/**
- Builds a GUID HOB with a certain data length.
-
- This function builds a customized HOB tagged with a GUID for identification
- and returns the start address of GUID HOB data so that caller can fill the customized data.
- The HOB Header and Name field is already stripped.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If Guid is NULL, then ASSERT().
- If there is no additional space for HOB creation, then ASSERT().
- If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
-
- @param Guid The GUID to tag the customized HOB.
- @param DataLength The size of the data payload for the GUID HOB.
-
- @return The start address of GUID HOB data.
-
-**/
-VOID *
-EFIAPI
-BuildGuidHob (
- IN CONST EFI_GUID *Guid,
- IN UINTN DataLength
- );
-
-/**
- Copies a data buffer to a newly-built HOB.
-
- This function builds a customized HOB tagged with a GUID for identification,
- copies the input data to the HOB data field and returns the start address of the GUID HOB data.
- The HOB Header and Name field is already stripped.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If Guid is NULL, then ASSERT().
- If Data is NULL and DataLength > 0, then ASSERT().
- If there is no additional space for HOB creation, then ASSERT().
- If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
-
- @param Guid The GUID to tag the customized HOB.
- @param Data The data to be copied into the data field of the GUID HOB.
- @param DataLength The size of the data payload for the GUID HOB.
-
- @return The start address of GUID HOB data.
-
-**/
-VOID *
-EFIAPI
-BuildGuidDataHob (
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN UINTN DataLength
- );
-
-/**
- Builds a Firmware Volume HOB.
-
- This function builds a Firmware Volume HOB.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The base address of the Firmware Volume.
- @param Length The size of the Firmware Volume in bytes.
-
-**/
-VOID
-EFIAPI
-BuildFvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- );
-
-/**
- Builds a Firmware Volume HOB and a resrouce descriptor hob
-
- This function builds a Firmware Volume HOB.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The base address of the Firmware Volume.
- @param Length The size of the Firmware Volume in bytes.
-
-**/
-VOID
-EFIAPI
-BuildFvHobs (
- IN EFI_PHYSICAL_ADDRESS PhysicalStart,
- IN UINT64 NumberOfBytes,
- IN EFI_RESOURCE_ATTRIBUTE_TYPE *ResourceAttribute OPTIONAL
- );
-
-
-/**
- Builds a EFI_HOB_TYPE_FV2 HOB.
-
- This function builds a EFI_HOB_TYPE_FV2 HOB.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The base address of the Firmware Volume.
- @param Length The size of the Firmware Volume in bytes.
- @param FvName The name of the Firmware Volume.
- @param FileName The name of the file.
-
-**/
-VOID
-EFIAPI
-BuildFv2Hob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN CONST EFI_GUID *FvName,
- IN CONST EFI_GUID *FileName
- );
-
-/**
- Builds a Capsule Volume HOB.
-
- This function builds a Capsule Volume HOB.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The base address of the Capsule Volume.
- @param Length The size of the Capsule Volume in bytes.
-
-**/
-VOID
-EFIAPI
-BuildCvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- );
-
-/**
- Builds a HOB for the CPU.
-
- This function builds a HOB for the CPU.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
- @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
-
-**/
-VOID
-EFIAPI
-BuildCpuHob (
- IN UINT8 SizeOfMemorySpace,
- IN UINT8 SizeOfIoSpace
- );
-
-/**
- Builds a HOB for the Stack.
-
- This function builds a HOB for the stack.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The 64 bit physical address of the Stack.
- @param Length The length of the stack in bytes.
-
-**/
-VOID
-EFIAPI
-BuildStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- );
-
-/**
- Update the Stack Hob if the stack has been moved
-
- @param BaseAddress The 64 bit physical address of the Stack.
- @param Length The length of the stack in bytes.
-
-**/
-VOID
-UpdateStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- );
-
-
-/**
- Builds a HOB for the BSP store.
-
- This function builds a HOB for BSP store.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The 64 bit physical address of the BSP.
- @param Length The length of the BSP store in bytes.
- @param MemoryType Type of memory allocated by this HOB.
-
-**/
-VOID
-EFIAPI
-BuildBspStoreHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
- );
-
-/**
- Builds a HOB for the memory allocation.
-
- This function builds a HOB for the memory allocation.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The 64 bit physical address of the memory.
- @param Length The length of the memory allocation in bytes.
- @param MemoryType Type of memory allocated by this HOB.
-
-**/
-VOID
-EFIAPI
-BuildMemoryAllocationHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
- );
-
-
-VOID
-EFIAPI
-BuildExtractSectionHob (
- IN EFI_GUID *Guid,
- IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo,
- IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction
- );
-
-VOID
-EFIAPI
-BuildPeCoffLoaderHob (
- VOID
- );
-
-
-/**
- Allocates one or more 4KB pages of type EfiBootServicesData.
-
- Allocates the number of 4KB pages of MemoryType and returns a pointer to the
- allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
- is returned. If there is not enough memory remaining to satisfy the request, then NULL is
- returned.
-
- @param Pages The number of 4 KB pages to allocate.
-
- @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocatePages (
- IN UINTN Pages
- );
-
-/**
- Allocates a buffer of type EfiBootServicesData.
-
- Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
- pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
- returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
-
- @param AllocationSize The number of bytes to allocate.
-
- @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocatePool (
- IN UINTN AllocationSize
- );
-
-
-/**
- Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
-
- Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
- alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
- returned. If there is not enough memory at the specified alignment remaining to satisfy the
- request, then NULL is returned.
- If Alignment is not a power of two and Alignment is not zero, then ASSERT().
-
- @param Pages The number of 4 KB pages to allocate.
- @param Alignment The requested alignment of the allocation. Must be a power of two.
- If Alignment is zero, then byte alignment is used.
-
- @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocateAlignedPages (
- IN UINTN Pages,
- IN UINTN Alignment
- );
-
-
-EFI_STATUS
-EFIAPI
-LoadPeCoffImage (
- IN VOID *PeCoffImage,
- OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
- OUT UINT64 *ImageSize,
- OUT EFI_PHYSICAL_ADDRESS *EntryPoint
- );
-
-EFI_STATUS
-EFIAPI
-LoadDxeCoreFromFfsFile (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN UINTN StackSize
- );
-
-EFI_STATUS
-EFIAPI
-LoadDxeCoreFromFv (
- IN UINTN *FvInstance, OPTIONAL
- IN UINTN StackSize
- );
-
-EFI_STATUS
-EFIAPI
-DecompressFirstFv (
- VOID
- );
-
-VOID
-EFIAPI
-AddDxeCoreReportStatusCodeCallback (
- VOID
- );
-
-
-#endif
diff --git a/EmbeddedPkg/Include/Library/RealTimeClockLib.h b/EmbeddedPkg/Include/Library/RealTimeClockLib.h
deleted file mode 100644
index 59a34aad13..0000000000
--- a/EmbeddedPkg/Include/Library/RealTimeClockLib.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/** @file
- Implement EFI RealTimeClock runtime services via Lib.
-
- Currently this driver does not support runtime virtual calling.
-
- 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 __REAL_TIME_CLOCK_LIB__
-#define __REAL_TIME_CLOCK_LIB__
-
-
-/**
- Returns the current time and date information, and the time-keeping capabilities
- of the hardware platform.
-
- @param Time A pointer to storage to receive a snapshot of the current time.
- @param Capabilities An optional pointer to a buffer to receive the real time clock
- device's capabilities.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER Time is NULL.
- @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities
- );
-
-
-/**
- Sets the current local time and date information.
-
- @param Time A pointer to the current time.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibSetTime (
- IN EFI_TIME *Time
- );
-
-
-/**
- Returns the current wakeup alarm clock setting.
-
- @param Enabled Indicates if the alarm is currently enabled or disabled.
- @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
- @param Time The current alarm setting.
-
- @retval EFI_SUCCESS The alarm settings were returned.
- @retval EFI_INVALID_PARAMETER Any parameter is NULL.
- @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
- );
-
-
-/**
- Sets the system wakeup alarm clock time.
-
- @param Enabled Enable or disable the wakeup alarm.
- @param Time If Enable is TRUE, the time to set the wakeup alarm for.
-
- @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
- Enable is FALSE, then the wakeup alarm was disabled.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
- @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
-
-**/
-EFI_STATUS
-EFIAPI
-LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
- );
-
-
-
-/**
- This is the declaration of an EFI image entry point. This can be the entry point to an application
- written to this specification, an EFI boot service driver, or an EFI runtime driver.
-
- @param ImageHandle Handle that identifies the loaded image.
- @param SystemTable System Table for this image.
-
- @retval EFI_SUCCESS The operation completed successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-LibRtcInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-
-/**
- Fixup internal data so that EFI can be call in virtual mode.
- Call the passed in Child Notify event and convert any pointers in
- lib to virtual mode.
-
- @param[in] Event The Event that is being processed
- @param[in] Context Event Context
-**/
-VOID
-EFIAPI
-LibRtcVirtualNotifyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-
-#endif
-
diff --git a/EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h b/EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h
deleted file mode 100644
index a9b4aac482..0000000000
--- a/EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/** @file
-
- Copyright (c) 2014, ARM Ltd. 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 __ANDROID_FASTBOOT_PLATFORM_H__
-#define __ANDROID_FASTBOOT_PLATFORM_H__
-
-extern EFI_GUID gAndroidFastbootPlatformProtocolGuid;
-
-/*
- Protocol for platform-specific operations initiated by Android Fastboot.
-
- Based on Fastboot Protocol version 0.4. See
- system/core/fastboot/fastboot_protocol.txt in the AOSP source tree for more
- info.
-
- Doesn't support image verification.
-*/
-
-/*
- Do any initialisation that needs to be done in order to be able to respond to
- commands.
-
- @retval EFI_SUCCESS Initialised successfully.
- @retval !EFI_SUCCESS Error in initialisation.
-*/
-typedef
-EFI_STATUS
-(*FASTBOOT_PLATFORM_INIT) (
- VOID
- );
-
-/*
- To be called when Fastboot is finished and we aren't rebooting or booting an
- image. Undo initialisation, free resrouces.
-*/
-typedef
-VOID
-(*FASTBOOT_PLATFORM_UN_INIT) (
- VOID
- );
-
-/*
- Flash the partition named (according to a platform-specific scheme)
- PartitionName, with the image pointed to by Buffer, whose size is BufferSize.
-
- @param[in] PartitionName Null-terminated name of partition to write.
- @param[in] BufferSize Size of Buffer in byets.
- @param[in] Buffer Data to write to partition.
-
- @retval EFI_NOT_FOUND No such partition.
- @retval EFI_DEVICE_ERROR Flashing failed.
-*/
-typedef
-EFI_STATUS
-(*FASTBOOT_PLATFORM_FLASH) (
- IN CHAR8 *PartitionName,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-/*
- Erase the partition named PartitionName.
-
- @param[in] PartitionName Null-terminated name of partition to erase.
-
- @retval EFI_NOT_FOUND No such partition.
- @retval EFI_DEVICE_ERROR Erasing failed.
-*/
-typedef
-EFI_STATUS
-(*FASTBOOT_PLATFORM_ERASE) (
- IN CHAR8 *PartitionName
- );
-
-/*
- If the variable referred to by Name exists, copy it (as a null-terminated
- string) into Value. If it doesn't exist, put the Empty string in Value.
-
- Variable names and values may not be larger than 60 bytes, excluding the
- terminal null character. This is a limitation of the Fastboot protocol.
-
- The Fastboot application will handle platform-nonspecific variables
- (Currently "version" is the only one of these.)
-
- @param[in] Name Null-terminated name of Fastboot variable to retrieve.
- @param[out] Value Caller-allocated buffer for null-terminated value of
- variable.
-
- @retval EFI_SUCCESS The variable was retrieved, or it doesn't exist.
- @retval EFI_DEVICE_ERROR There was an error looking up the variable. This
- does _not_ include the variable not existing.
-*/
-typedef
-EFI_STATUS
-(*FASTBOOT_PLATFORM_GETVAR) (
- IN CHAR8 *Name,
- OUT CHAR8 *Value
- );
-
-/*
- React to an OEM-specific command.
-
- Future versions of this function might want to allow the platform to do some
- extra communication with the host. A way to do this would be to add a function
- to the FASTBOOT_TRANSPORT_PROTOCOL that allows the implementation of
- DoOemCommand to replace the ReceiveEvent with its own, and to restore the old
- one when it's finished.
-
- However at the moment although the specification allows it, the AOSP fastboot
- host application doesn't handle receiving any data from the client, and it
- doesn't support a data phase for OEM commands.
-
- @param[in] Command Null-terminated command string.
-
- @retval EFI_SUCCESS The command executed successfully.
- @retval EFI_NOT_FOUND The command wasn't recognised.
- @retval EFI_DEVICE_ERROR There was an error executing the command.
-*/
-typedef
-EFI_STATUS
-(*FASTBOOT_PLATFORM_OEM_COMMAND) (
- IN CHAR8 *Command
- );
-
-typedef struct _FASTBOOT_PLATFORM_PROTOCOL {
- FASTBOOT_PLATFORM_INIT Init;
- FASTBOOT_PLATFORM_UN_INIT UnInit;
- FASTBOOT_PLATFORM_FLASH FlashPartition;
- FASTBOOT_PLATFORM_ERASE ErasePartition;
- FASTBOOT_PLATFORM_GETVAR GetVar;
- FASTBOOT_PLATFORM_OEM_COMMAND DoOemCommand;
-} FASTBOOT_PLATFORM_PROTOCOL;
-
-#endif
diff --git a/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h b/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h
deleted file mode 100644
index 807068717e..0000000000
--- a/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/** @file
-
- Copyright (c) 2014, ARM Ltd. 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.
-
-**/
-
-/*
- Transport protocol over which Android Fastboot transactions can be made.
- Fastboot is designed for USB, but this protocol is intended as an abstraction
- so that it can be implemented over any transport mechanism.
-*/
-
-#ifndef __ANDROID_FASTBOOT_TRANSPORT_H__
-#define __ANDROID_FASTBOOT_TRANSPORT_H__
-
-extern EFI_GUID gAndroidFastbootTransportProtocolGuid;
-
-/*
- Set up the transport system for use by Fastboot.
- e.g. For USB this probably means making the device enumerable. For TCP,
- preparing to accept incoming connections.
-
- It is _not_ the responsibility of this protocol's implementer to unite the
- data phase into a single buffer - that is handled by the Fastboot UEFI
- application. As the Fastboot protocol spec says: "Short packets are always
- acceptable and zero-length packets are ignored."
- However the commands and responses must be in a single packet, and the order
- of the packets must of course be maintained.
-
- If there is a fatal error in the receive channel, ReceiveEvent will be
- signalled, and a subsequent call to Receive() will return an error. This
- allows data transported prior to the error to be received.
-
- @param[in] ReceiveEvent Event to be Signalled when a packet has been received
- and is ready to be retrieved via Receive().
-
- @retval EFI_SUCCESS Initialised successfully.
- @retval EFI_DEVICE_ERROR Error in initialising hardware
- @retval (other) Error return from LocateProtocol functions.
-*/
-typedef
-EFI_STATUS
-(*FASTBOOT_TRANSPORT_START) (
- IN EFI_EVENT ReceiveEvent
- );
-
-/*
- Function to be called when all Fastboot transactions are finished, to
- de-initialise the transport system.
- e.g. A USB OTG system might want to get out of peripheral mode so it can be
- a USB host.
-
- Note that this function will be called after an error is reported by Send or
- Receive
-
- @retval EFI_SUCCESS De-initialised successfully.
- @retval EFI_DEVICE_ERROR Error de-initialising hardware.
-*/
-typedef
-EFI_STATUS
-(* FASTBOOT_TRANSPORT_STOP) (
- VOID
- );
-
-/*
- Send data. This function can be used both for command responses like "OKAY"
- and for the data phase (the protocol doesn't describe any situation when the
- latter might be necessary, but does allow it)
-
- Transmission need not finish before the function returns.
- If there is an error in transmission from which the transport system cannot
- recover, FatalErrorEvent will be signalled. Otherwise, it is assumed that all
- data was delivered successfully.
-
- @param[in] BufferSize Size in bytes of data to send.
- @param[in] Buffer Data to send.
- @param[in] FatalErrorEvent Event to signal if there was an error in
- transmission from which the transport system
- cannot recover.
-
- @retval EFI_SUCCESS The data was sent or queued for send.
- @retval EFI_DEVICE_ERROR There was an error preparing to send the data.
- */
-typedef
-EFI_STATUS
-(*FASTBOOT_TRANSPORT_SEND) (
- IN UINTN BufferSize,
- IN CONST VOID *Buffer,
- IN EFI_EVENT *FatalErrorEvent
- );
-
-/*
- When the event has been Signalled to say data is available from the host,
- this function is used to get data. In order to handle the case where several
- packets are received before ReceiveEvent's notify function is called, packets
- received are queued, and each call to this function returns the next packet in
- the queue. It should therefore be called in a loop, the exit condition being a
- return of EFI_NOT_READY.
-
- @param[out] Buffer Pointer to received data. Callee allocated - the
- caller must free it with FreePool.
- @param[out] BufferSize The size of received data in bytes
-
- @retval EFI_NOT_READY There is no data available
- @retval EFI_DEVICE_ERROR There was a fatal error in the receive channel.
- e.g. for USB the cable was unplugged or for TCP the
- connection was closed by the remote host..
-*/
-typedef
-EFI_STATUS
-(*FASTBOOT_TRANSPORT_RECEIVE) (
- OUT UINTN *BufferSize,
- OUT VOID **Buffer
- );
-
-typedef struct _FASTBOOT_TRANSPORT_PROTOCOL {
- FASTBOOT_TRANSPORT_START Start;
- FASTBOOT_TRANSPORT_STOP Stop;
- FASTBOOT_TRANSPORT_SEND Send;
- FASTBOOT_TRANSPORT_RECEIVE Receive;
-} FASTBOOT_TRANSPORT_PROTOCOL;
-
-#endif
diff --git a/EmbeddedPkg/Include/Protocol/DebugSupportPeriodicCallback.h b/EmbeddedPkg/Include/Protocol/DebugSupportPeriodicCallback.h
deleted file mode 100644
index 3d95f930b9..0000000000
--- a/EmbeddedPkg/Include/Protocol/DebugSupportPeriodicCallback.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/** @file
- Protocol is used to help implement DebugSupport.RegisterPeriodicCallback() functionality.
- This enables the DXE timer driver to support the periodic callback function so the
- DebugSupport driver does not need to contain platform specific information about how a timer
- works.
-
- 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 __DEBUG_SUPPORT_PERIODIC_CALLBACK_H__
-#define __DEBUG_SUPPORT_PERIODIC_CALLBACK_H__
-
-#include <Protocol/DebugSupport.h>
-
-typedef struct _EFI_DEBUG_SUPPORT_PERIODIC_CALLBACK_PROTOCOL EFI_DEBUG_SUPPORT_PERIODIC_CALLBACK_PROTOCOL;
-
-
-// {9546E07C-2CBB-4c88-986C-CD341086F044}
-#define EFI_DEBUG_SUPPORT_PERIODIC_CALLBACK_PROTOCOL_GUID \
- { 0x9546e07c, 0x2cbb, 0x4c88, { 0x98, 0x6c, 0xcd, 0x34, 0x10, 0x86, 0xf0, 0x44 } }
-
-
-//
-// DebugSupport protocol definition
-//
-struct _EFI_DEBUG_SUPPORT_PERIODIC_CALLBACK_PROTOCOL {
- EFI_PERIODIC_CALLBACK PeriodicCallback;
-};
-
-extern EFI_GUID gEfiDebugSupportPeriodicCallbackProtocolGuid;
-
-#endif
diff --git a/EmbeddedPkg/Include/Protocol/EblAddCommand.h b/EmbeddedPkg/Include/Protocol/EblAddCommand.h
deleted file mode 100644
index 4a9f494c5d..0000000000
--- a/EmbeddedPkg/Include/Protocol/EblAddCommand.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/** @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 __EBL_ADD_COMMAND_H__
-#define __EBL_ADD_COMMAND_H__
-
-
-
-//
-// Protocol GUID
-//
-// AEDA2428-9A22-4637-9B21-545E28FBB829
-
-#define EBL_ADD_COMMAND_PROTOCOL_GUID \
- { 0xaeda2428, 0x9a22, 0x4637, { 0x9b, 0x21, 0x54, 0x5e, 0x28, 0xfb, 0xb8, 0x29 } }
-
-
-typedef struct _EBL_ADD_COMMAND_PROTOCOL EBL_ADD_COMMAND_PROTOCOL;
-
-typedef
-EFI_STATUS
-(EFIAPI *EBL_COMMMAND) (
- IN UINTN Argc,
- IN CHAR8 **Argv
- );
-
-typedef struct {
- CHAR8 *Name;
- CHAR8 *HelpSummary;
- CHAR8 *Help;
- EBL_COMMMAND Command;
-} EBL_COMMAND_TABLE;
-
-
-/**
- Add a single command table entry.
-
- @param EntryArray Pointer EBL_COMMAND_TABLE of the command that is being added
-
-**/
-typedef
-VOID
-(EFIAPI *EBL_ADD_COMMAND) (
- IN const EBL_COMMAND_TABLE *Entry
- );
-
-
-/**
- Add a multiple command table entry.
-
- @param EntryArray Pointer EBL_COMMAND_TABLE of the commands that are being added
-
- @param ArrayCount Number of commands in the EntryArray.
-
-**/
-typedef
-VOID
-(EFIAPI *EBL_ADD_COMMANDS) (
- IN const EBL_COMMAND_TABLE *EntryArray,
- IN UINTN ArrayCount
- );
-
-
-typedef
-VOID
-(EFIAPI *EBL_GET_CHAR_CALL_BACK) (
- IN UINTN ElapsedTime
- );
-
-/**
- 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
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *EBL_GET_CHAR_KEY) (
- 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.
-
-**/
-typedef
-BOOLEAN
-(EFIAPI *EBL_ANY_KEY_CONTINUE_Q_QUIT) (
- IN UINTN *CurrentRow,
- IN BOOLEAN PrefixNewline
- );
-
-
-
-struct _EBL_ADD_COMMAND_PROTOCOL {
- EBL_ADD_COMMAND AddCommand;
- EBL_ADD_COMMANDS AddCommands;
-
- // Commands to reuse EBL infrastructure
- EBL_GET_CHAR_KEY EblGetCharKey;
- EBL_ANY_KEY_CONTINUE_Q_QUIT EblAnyKeyToContinueQtoQuit;
-};
-
-extern EFI_GUID gEfiEblAddCommandProtocolGuid;
-
-#endif
-
-
diff --git a/EmbeddedPkg/Include/Protocol/EmbeddedDevice.h b/EmbeddedPkg/Include/Protocol/EmbeddedDevice.h
deleted file mode 100644
index a999a97557..0000000000
--- a/EmbeddedPkg/Include/Protocol/EmbeddedDevice.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/** @file
- Deal with devices that just exist in memory space.
-
- To follow the EFI driver model you need a root handle to start with. An
- EFI driver will have a driver binding protocol (Supported, Start, Stop)
- that is used to layer on top of a handle via a gBS->ConnectController.
- The first handle has to just be in the system to make that work. For
- PCI it is a PCI Root Bridge IO protocol that provides the root.
-
- On an embedded system with MMIO device we need a handle to just
- show up. That handle will have this protocol and a device path
- protocol on it.
-
- For an ethernet device the device path must contain a MAC address device path
- node.
-
- 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_DEVICE_PROTOCOL_H__
-#define __EMBEDDED_DEVICE_PROTOCOL_H__
-
-
-//
-// Protocol GUID
-//
-// BF4B9D10-13EC-43dd-8880-E90B718F27DE
-
-#define EMBEDDED_DEVICE_PROTOCOL_GUID \
- { 0xbf4b9d10, 0x13ec, 0x43dd, { 0x88, 0x80, 0xe9, 0xb, 0x71, 0x8f, 0x27, 0xde } }
-
-
-
-typedef struct {
- UINT16 VendorId;
- UINT16 DeviceId;
- UINT16 RevisionId;
- UINT16 SubsystemId;
- UINT16 SubsystemVendorId;
- UINT8 ClassCode[3];
- UINT8 HeaderSize;
- UINTN BaseAddress;
-} EMBEDDED_DEVICE_PROTOCOL;
-
-extern EFI_GUID gEmbeddedDeviceGuid;
-
-#endif
-
-
diff --git a/EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h b/EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h
deleted file mode 100644
index 06d2f034d0..0000000000
--- a/EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/** @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__
diff --git a/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h b/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h
deleted file mode 100644
index 4e7c8dbcd6..0000000000
--- a/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/** @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
diff --git a/EmbeddedPkg/Include/Protocol/HardwareInterrupt.h b/EmbeddedPkg/Include/Protocol/HardwareInterrupt.h
deleted file mode 100644
index c4b5b9fa62..0000000000
--- a/EmbeddedPkg/Include/Protocol/HardwareInterrupt.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/** @file
- Abstraction for hardware based interrupt routine
-
- On non IA-32 systems it is common to have a single hardware interrupt vector
- and a 2nd layer of software that routes the interrupt handlers based on the
- interrupt source. This protocol enables this routing. The driver implementing
- this protocol is responsible for clearing the pending interrupt in the
- interrupt routing hardware. The HARDWARE_INTERRUPT_HANDLER is responsible
- for clearing interrupt sources from individual devices.
-
-
- 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 __HARDWARE_INTERRUPT_H__
-#define __HARDWARE_INTERRUPT_H__
-
-#include <Protocol/DebugSupport.h>
-
-
-//
-// Protocol GUID
-//
-// EAB39028-3D05-4316-AD0C-D64808DA3FF1
-
-#define EFI_HARDWARE_INTERRUPT_PROTOCOL_GGUID \
- { 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } }
-
-
-typedef struct _EFI_HARDWARE_INTERRUPT_PROTOCOL EFI_HARDWARE_INTERRUPT_PROTOCOL;
-
-
-typedef UINTN HARDWARE_INTERRUPT_SOURCE;
-
-
-/**
- C Interrupt Handler calledin the interrupt context when Source interrupt is active.
-
- @param Source Source of the interrupt. Hardware routing off a specific platform defines
- what source means.
- @param SystemContext Pointer to system register context. Mostly used by debuggers and will
- update the system context after the return from the interrupt if
- modified. Don't change these values unless you know what you are doing
-
-**/
-typedef
-VOID
-(EFIAPI *HARDWARE_INTERRUPT_HANDLER) (
- IN HARDWARE_INTERRUPT_SOURCE Source,
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- Register Handler for the specified interrupt source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
- @param Handler Callback for interrupt. NULL to unregister
-
- @retval EFI_SUCCESS Source was updated to support Handler.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_REGISTER) (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source,
- IN HARDWARE_INTERRUPT_HANDLER Handler
- );
-
-
-/**
- Enable interrupt source Source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
-
- @retval EFI_SUCCESS Source interrupt enabled.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_ENABLE) (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source
- );
-
-
-
-/**
- Disable interrupt source Source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
-
- @retval EFI_SUCCESS Source interrupt disabled.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_DISABLE) (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source
- );
-
-
-/**
- Return current state of interrupt source Source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
- @param InterruptState TRUE: source enabled, FALSE: source disabled.
-
- @retval EFI_SUCCESS InterruptState is valid
- @retval EFI_DEVICE_ERROR InterruptState is not valid
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_INTERRUPT_STATE) (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source,
- IN BOOLEAN *InterruptState
- );
-
-/**
- Signal to the hardware that the End Of Intrrupt state
- has been reached.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
-
- @retval EFI_SUCCESS Source interrupt EOI'ed.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_END_OF_INTERRUPT) (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source
- );
-
-
-struct _EFI_HARDWARE_INTERRUPT_PROTOCOL {
- HARDWARE_INTERRUPT_REGISTER RegisterInterruptSource;
- HARDWARE_INTERRUPT_ENABLE EnableInterruptSource;
- HARDWARE_INTERRUPT_DISABLE DisableInterruptSource;
- HARDWARE_INTERRUPT_INTERRUPT_STATE GetInterruptSourceState;
- HARDWARE_INTERRUPT_END_OF_INTERRUPT EndOfInterrupt;
-};
-
-extern EFI_GUID gHardwareInterruptProtocolGuid;
-
-#endif
-
-
diff --git a/EmbeddedPkg/Include/Protocol/MmcHost.h b/EmbeddedPkg/Include/Protocol/MmcHost.h
deleted file mode 100644
index 89f2e80b5c..0000000000
--- a/EmbeddedPkg/Include/Protocol/MmcHost.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/** @file
- Definition of the MMC Host Protocol
-
- Copyright (c) 2011-2014, 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 __MMC_HOST_H__
-#define __MMC_HOST_H__
-
-///
-/// Global ID for the MMC Host Protocol
-///
-#define EFI_MMC_HOST_PROTOCOL_GUID \
- { 0x3e591c00, 0x9e4a, 0x11df, {0x92, 0x44, 0x00, 0x02, 0xA5, 0xD5, 0xC5, 0x1B } }
-
-#define MMC_RESPONSE_TYPE_R1 0
-#define MMC_RESPONSE_TYPE_R1b 0
-#define MMC_RESPONSE_TYPE_R2 1
-#define MMC_RESPONSE_TYPE_R3 0
-#define MMC_RESPONSE_TYPE_R6 0
-#define MMC_RESPONSE_TYPE_R7 0
-#define MMC_RESPONSE_TYPE_OCR 0
-#define MMC_RESPONSE_TYPE_CID 1
-#define MMC_RESPONSE_TYPE_CSD 1
-#define MMC_RESPONSE_TYPE_RCA 0
-
-typedef UINT32 MMC_RESPONSE_TYPE;
-
-typedef UINT32 MMC_CMD;
-
-#define MMC_CMD_WAIT_RESPONSE (1 << 16)
-#define MMC_CMD_LONG_RESPONSE (1 << 17)
-#define MMC_CMD_NO_CRC_RESPONSE (1 << 18)
-
-#define MMC_INDX(Index) ((Index) & 0xFFFF)
-#define MMC_GET_INDX(MmcCmd) ((MmcCmd) & 0xFFFF)
-
-#define MMC_CMD0 (MMC_INDX(0) | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD1 (MMC_INDX(1) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD2 (MMC_INDX(2) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
-#define MMC_CMD3 (MMC_INDX(3) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD5 (MMC_INDX(5) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD7 (MMC_INDX(7) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD8 (MMC_INDX(8) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD9 (MMC_INDX(9) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
-#define MMC_CMD11 (MMC_INDX(11) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD12 (MMC_INDX(12) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD13 (MMC_INDX(13) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD16 (MMC_INDX(16) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD17 (MMC_INDX(17) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD18 (MMC_INDX(18) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD20 (MMC_INDX(20) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD23 (MMC_INDX(23) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD24 (MMC_INDX(24) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD55 (MMC_INDX(55) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_ACMD41 (MMC_INDX(41) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-
-// Valid responses for CMD1 in eMMC
-#define EMMC_CMD1_CAPACITY_LESS_THAN_2GB 0x00FF8080 // Capacity <= 2GB, byte addressing used
-#define EMMC_CMD1_CAPACITY_GREATER_THAN_2GB 0x40FF8080 // Capacity > 2GB, 512-byte sector addressing used
-
-typedef enum _MMC_STATE {
- MmcInvalidState = 0,
- MmcHwInitializationState,
- MmcIdleState,
- MmcReadyState,
- MmcIdentificationState,
- MmcStandByState,
- MmcTransferState,
- MmcSendingDataState,
- MmcReceiveDataState,
- MmcProgrammingState,
- MmcDisconnectState,
-} MMC_STATE;
-
-///
-/// Forward declaration for EFI_MMC_HOST_PROTOCOL
-///
-typedef struct _EFI_MMC_HOST_PROTOCOL EFI_MMC_HOST_PROTOCOL;
-
-typedef BOOLEAN (EFIAPI *MMC_ISCARDPRESENT) (
- IN EFI_MMC_HOST_PROTOCOL *This
- );
-
-typedef BOOLEAN (EFIAPI *MMC_ISREADONLY) (
- IN EFI_MMC_HOST_PROTOCOL *This
- );
-
-typedef EFI_STATUS (EFIAPI *MMC_BUILDDEVICEPATH) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
- );
-
-typedef EFI_STATUS (EFIAPI *MMC_NOTIFYSTATE) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_STATE State
- );
-
-typedef EFI_STATUS (EFIAPI *MMC_SENDCOMMAND) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_CMD Cmd,
- IN UINT32 Argument
- );
-
-typedef EFI_STATUS (EFIAPI *MMC_RECEIVERESPONSE) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_RESPONSE_TYPE Type,
- IN UINT32 *Buffer
- );
-
-typedef EFI_STATUS (EFIAPI *MMC_READBLOCKDATA) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- OUT UINT32 *Buffer
- );
-
-typedef EFI_STATUS (EFIAPI *MMC_WRITEBLOCKDATA) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- IN UINT32 *Buffer
- );
-
-
-struct _EFI_MMC_HOST_PROTOCOL {
-
- UINT32 Revision;
- MMC_ISCARDPRESENT IsCardPresent;
- MMC_ISREADONLY IsReadOnly;
- MMC_BUILDDEVICEPATH BuildDevicePath;
-
- MMC_NOTIFYSTATE NotifyState;
-
- MMC_SENDCOMMAND SendCommand;
- MMC_RECEIVERESPONSE ReceiveResponse;
-
- MMC_READBLOCKDATA ReadBlockData;
- MMC_WRITEBLOCKDATA WriteBlockData;
-
-};
-
-#define MMC_HOST_PROTOCOL_REVISION 0x00010001 // 1.1
-
-extern EFI_GUID gEfiMmcHostProtocolGuid;
-
-#endif
-
diff --git a/EmbeddedPkg/Include/Protocol/PeCoffLoader.h b/EmbeddedPkg/Include/Protocol/PeCoffLoader.h
deleted file mode 100644
index 1f93cefd17..0000000000
--- a/EmbeddedPkg/Include/Protocol/PeCoffLoader.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/** @file
-
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
- Portions copyright (c) 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 __PE_COFF_LOADER_H__
-#define __PE_COFF_LOADER_H__
-
-// Needed for PE_COFF_LOADER_IMAGE_CONTEXT
-#include <Library/PeCoffLib.h>
-
-// B323179B-97FB-477E-B0FE-D88591FA11AB
-#define PE_COFF_LOADER_PROTOCOL_GUID \
- { 0xB323179B, 0x97FB, 0x477E, { 0xB0, 0xFE, 0xD8, 0x85, 0x91, 0xFA, 0x11, 0xAB } }
-
-
-typedef struct _PE_COFF_LOADER_PROTOCOL PE_COFF_LOADER_PROTOCOL;
-
-
-
-/**
- Retrieves information about a PE/COFF image.
-
- Computes the PeCoffHeaderOffset, IsTeImage, ImageType, ImageAddress, ImageSize,
- DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and
- DebugDirectoryEntryRva fields of the ImageContext structure.
- If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
- If the PE/COFF image accessed through the ImageRead service in the ImageContext
- structure is not a supported PE/COFF image type, then return RETURN_UNSUPPORTED.
- If any errors occur while computing the fields of ImageContext,
- then the error status is returned in the ImageError field of ImageContext.
- If the image is a TE image, then SectionAlignment is set to 0.
- The ImageRead and Handle fields of ImageContext structure must be valid prior
- to invoking this service.
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image that needs to be examined by this function.
-
- @retval RETURN_SUCCESS The information on the PE/COFF image was collected.
- @retval RETURN_INVALID_PARAMETER ImageContext is NULL.
- @retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
-
-**/
-typedef
-RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_GET_IMAGE_INFO) (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- );
-
-
-/**
- Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
-
- If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
- ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
- of ImageContext as the relocation base address. The caller must allocate the relocation
- fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
-
- The ImageRead, Handle, PeCoffHeaderOffset, IsTeImage, Machine, ImageType, ImageAddress,
- ImageSize, DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders,
- DebugDirectoryEntryRva, EntryPoint, FixupDataSize, CodeView, PdbPointer, and FixupData of
- the ImageContext structure must be valid prior to invoking this service.
-
- If ImageContext is NULL, then ASSERT().
-
- Note that if the platform does not maintain coherency between the instruction cache(s) and the data
- cache(s) in hardware, then the caller is responsible for performing cache maintenance operations
- prior to transferring control to a PE/COFF image that is loaded using this library.
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image that is being relocated.
-
- @retval RETURN_SUCCESS The PE/COFF image was relocated.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_UNSUPPORTED A relocation record type is not supported.
- Extended status information is in the ImageError field of ImageContext.
-
-**/
-typedef
-RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_RELOCATE_IMAGE) (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- );
-
-
-/**
- Loads a PE/COFF image into memory.
-
- Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
- specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
- the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
- The EntryPoint, FixupDataSize, CodeView, PdbPointer and HiiResourceData fields of ImageContext are computed.
- The ImageRead, Handle, PeCoffHeaderOffset, IsTeImage, Machine, ImageType, ImageAddress, ImageSize,
- DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
- fields of the ImageContext structure must be valid prior to invoking this service.
-
- If ImageContext is NULL, then ASSERT().
-
- Note that if the platform does not maintain coherency between the instruction cache(s) and the data
- cache(s) in hardware, then the caller is responsible for performing cache maintenance operations
- prior to transferring control to a PE/COFF image that is loaded using this library.
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image that is being loaded.
-
- @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
- the ImageAddress and ImageSize fields of ImageContext.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_INVALID_PARAMETER The image address is invalid.
- Extended status information is in the ImageError field of ImageContext.
-
-**/
-typedef
-RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_LOAD_IMAGE) (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- );
-
-
-
-/**
- Reads contents of a PE/COFF image from a buffer in system memory.
-
- This is the default implementation of a PE_COFF_LOADER_READ_FILE function
- that assumes FileHandle pointer to the beginning of a PE/COFF image.
- This function reads contents of the PE/COFF image that starts at the system memory
- address specified by FileHandle. The read operation copies ReadSize bytes from the
- PE/COFF image starting at byte offset FileOffset into the buffer specified by Buffer.
- The size of the buffer actually read is returned in ReadSize.
-
- If FileHandle is NULL, then ASSERT().
- If ReadSize is NULL, then ASSERT().
- If Buffer is NULL, then ASSERT().
-
- @param FileHandle Pointer to base of the input stream
- @param FileOffset Offset into the PE/COFF image to begin the read operation.
- @param ReadSize On input, the size in bytes of the requested read operation.
- On output, the number of bytes actually read.
- @param Buffer Output buffer that contains the data read from the PE/COFF image.
-
- @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
- the buffer.
-**/
-typedef
-RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_READ_FROM_MEMORY) (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
- );
-
-
-
-/**
- Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
- runtime.
-
- This function reapplies relocation fixups to the PE/COFF image specified by ImageBase
- and ImageSize so the image will execute correctly when the PE/COFF image is mapped
- to the address specified by VirtualImageBase. RelocationData must be identical
- to the FiuxupData buffer from the PE_COFF_LOADER_IMAGE_CONTEXT structure
- after this PE/COFF image was relocated with PeCoffLoaderRelocateImage().
-
- Note that if the platform does not maintain coherency between the instruction cache(s) and the data
- cache(s) in hardware, then the caller is responsible for performing cache maintenance operations
- prior to transferring control to a PE/COFF image that is loaded using this library.
-
- @param ImageBase Base address of a PE/COFF image that has been loaded
- and relocated into system memory.
- @param VirtImageBase The request virtual address that the PE/COFF image is to
- be fixed up for.
- @param ImageSize The size, in bytes, of the PE/COFF image.
- @param RelocationData A pointer to the relocation data that was collected when the PE/COFF
- image was relocated using PeCoffLoaderRelocateImage().
-
-**/
-typedef
-VOID
-(EFIAPI *PE_COFF_LOADER_RELOCATE_IMAGE_FOR_RUNTIME) (
- IN PHYSICAL_ADDRESS ImageBase,
- IN PHYSICAL_ADDRESS VirtImageBase,
- IN UINTN ImageSize,
- IN VOID *RelocationData
- );
-
-
-
-/**
- Unloads a loaded PE/COFF image from memory and releases its taken resource.
- Releases any environment specific resources that were allocated when the image
- specified by ImageContext was loaded using PeCoffLoaderLoadImage().
-
- For NT32 emulator, the PE/COFF image loaded by system needs to release.
- For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
- this function can simply return RETURN_SUCCESS.
-
- If ImageContext is NULL, then ASSERT().
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image to be unloaded.
-
- @retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.
-**/
-typedef
-RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_UNLOAD_IMAGE) (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- );
-
-
-struct _PE_COFF_LOADER_PROTOCOL {
- PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo;
- PE_COFF_LOADER_LOAD_IMAGE LoadImage;
- PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage;
- PE_COFF_LOADER_READ_FROM_MEMORY ReadFromMemory;
- PE_COFF_LOADER_RELOCATE_IMAGE_FOR_RUNTIME RelocateImageForRuntime;
- PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;
-};
-
-
-extern EFI_GUID gPeCoffLoaderProtocolGuid;
-
-
-#endif
-
diff --git a/EmbeddedPkg/Include/Protocol/UsbDevice.h b/EmbeddedPkg/Include/Protocol/UsbDevice.h
deleted file mode 100644
index 13a48dda07..0000000000
--- a/EmbeddedPkg/Include/Protocol/UsbDevice.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/** @file
-
- Copyright (c) 2013-2014, ARM Ltd. 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 __USB_DEVICE_PROTOCOL_H__
-#define __USB_DEVICE_PROTOCOL_H__
-
-#include <IndustryStandard/Usb.h>
-
-extern EFI_GUID gUsbDeviceProtocolGuid;
-
-/*
- * Note: This Protocol is just the bare minimum for Android Fastboot. It
- * only makes sense for devices that only do Bulk Transfers and only have one
- * endpoint.
- */
-
-/*
- Callback to be called when data is received.
- Buffer is callee-allocated and it's the caller's responsibility to free it with
- FreePool.
-
- @param[in] Size Size in bytes of data.
- @param[in] Buffer Pointer to data.
-*/
-typedef
-VOID
-(*USB_DEVICE_RX_CALLBACK) (
- IN UINTN Size,
- IN VOID *Buffer
- );
-
-/*
- Callback to be called when the host asks for data by sending an IN token
- (excluding during the data stage of a control transfer).
- When this function is called, data previously buffered by calling Send() has
- been sent.
-
- @param[in]Endpoint Endpoint index, as specified in endpoint descriptors, of
- the endpoint the IN token was sent to.
-*/
-typedef
-VOID
-(*USB_DEVICE_TX_CALLBACK) (
- IN UINT8 EndpointIndex
- );
-
-/*
- Put data in the Tx buffer to be sent on the next IN token.
- Don't call this function again until the TxCallback has been called.
-
- @param[in]Endpoint Endpoint index, as specified in endpoint descriptors, of
- the endpoint to send the data from.
- @param[in]Size Size in bytes of data.
- @param[in]Buffer Pointer to data.
-
- @retval EFI_SUCCESS The data was queued successfully.
- @retval EFI_INVALID_PARAMETER There was an error sending the data.
-*/
-typedef
-EFI_STATUS
-(*USB_DEVICE_SEND) (
- IN UINT8 EndpointIndex,
- IN UINTN Size,
- IN CONST VOID *Buffer
- );
-
-/*
- Restart the USB peripheral controller and respond to enumeration.
-
- @param[in] DeviceDescriptor pointer to device descriptor
- @param[in] Descriptors Array of pointers to buffers, where
- Descriptors[n] contains the response to a
- GET_DESCRIPTOR request for configuration n. From
- USB Spec section 9.4.3:
- "The first interface descriptor follows the
- configuration descriptor. The endpoint
- descriptors for the first interface follow the
- first interface descriptor. If there are
- additional interfaces, their interface
- descriptor and endpoint descriptors follow the
- first interface’s endpoint descriptors".
-
- The size of each buffer is the TotalLength
- member of the Configuration Descriptor.
-
- The size of the array is
- DeviceDescriptor->NumConfigurations.
- @param[in]RxCallback See USB_DEVICE_RX_CALLBACK
- @param[in]TxCallback See USB_DEVICE_TX_CALLBACK
-*/
-typedef
-EFI_STATUS
-(*USB_DEVICE_START) (
- IN USB_DEVICE_DESCRIPTOR *DeviceDescriptor,
- IN VOID **Descriptors,
- IN USB_DEVICE_RX_CALLBACK RxCallback,
- IN USB_DEVICE_TX_CALLBACK TxCallback
- );
-
-struct _USB_DEVICE_PROTOCOL {
- USB_DEVICE_START Start;
- USB_DEVICE_SEND Send;
-};
-
-typedef struct _USB_DEVICE_PROTOCOL USB_DEVICE_PROTOCOL;
-
-#endif //ifndef __USB_DEVICE_PROTOCOL_H__
diff --git a/EmbeddedPkg/Include/fdt.h b/EmbeddedPkg/Include/fdt.h
deleted file mode 100644
index 0187749f19..0000000000
--- a/EmbeddedPkg/Include/fdt.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#ifndef _FDT_H
-#define _FDT_H
-/*
- * libfdt - Flat Device Tree manipulation
- * Copyright (C) 2006 David Gibson, IBM Corporation.
- * Copyright 2012 Kim Phillips, Freescale Semiconductor.
- *
- * 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.
- */
-
-#ifndef __ASSEMBLY__
-
-struct fdt_header {
- fdt32_t magic; /* magic word FDT_MAGIC */
- fdt32_t totalsize; /* total size of DT block */
- fdt32_t off_dt_struct; /* offset to structure */
- fdt32_t off_dt_strings; /* offset to strings */
- fdt32_t off_mem_rsvmap; /* offset to memory reserve map */
- fdt32_t version; /* format version */
- fdt32_t last_comp_version; /* last compatible version */
-
- /* version 2 fields below */
- fdt32_t boot_cpuid_phys; /* Which physical CPU id we're
- booting on */
- /* version 3 fields below */
- fdt32_t size_dt_strings; /* size of the strings block */
-
- /* version 17 fields below */
- fdt32_t size_dt_struct; /* size of the structure block */
-};
-
-struct fdt_reserve_entry {
- fdt64_t address;
- fdt64_t size;
-};
-
-struct fdt_node_header {
- fdt32_t tag;
- char name[0];
-};
-
-struct fdt_property {
- fdt32_t tag;
- fdt32_t len;
- fdt32_t nameoff;
- char data[0];
-};
-
-#endif /* !__ASSEMBLY */
-
-#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
-#define FDT_TAGSIZE sizeof(fdt32_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(fdt32_t))
-#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t))
-#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t))
-#define FDT_V16_SIZE FDT_V3_SIZE
-#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
-
-#endif /* _FDT_H */
diff --git a/EmbeddedPkg/Include/libfdt.h b/EmbeddedPkg/Include/libfdt.h
deleted file mode 100644
index 212cb995df..0000000000
--- a/EmbeddedPkg/Include/libfdt.h
+++ /dev/null
@@ -1,1514 +0,0 @@
-#ifndef _LIBFDT_H
-#define _LIBFDT_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 <libfdt_env.h>
-#include <fdt.h>
-
-#define FDT_FIRST_SUPPORTED_VERSION 0x10
-#define FDT_LAST_SUPPORTED_VERSION 0x11
-
-/* Error codes: informative error codes */
-#define FDT_ERR_NOTFOUND 1
- /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
-#define FDT_ERR_EXISTS 2
- /* FDT_ERR_EXISTS: Attemped to create a node or property which
- * already exists */
-#define FDT_ERR_NOSPACE 3
- /* FDT_ERR_NOSPACE: Operation needed to expand the device
- * tree, but its buffer did not have sufficient space to
- * contain the expanded tree. Use fdt_open_into() to move the
- * device tree to a buffer with more space. */
-
-/* Error codes: codes for bad parameters */
-#define FDT_ERR_BADOFFSET 4
- /* FDT_ERR_BADOFFSET: Function was passed a structure block
- * offset which is out-of-bounds, or which points to an
- * unsuitable part of the structure for the operation. */
-#define FDT_ERR_BADPATH 5
- /* FDT_ERR_BADPATH: Function was passed a badly formatted path
- * (e.g. missing a leading / for a function which requires an
- * absolute path) */
-#define FDT_ERR_BADPHANDLE 6
- /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle
- * value. phandle values of 0 and -1 are not permitted. */
-#define FDT_ERR_BADSTATE 7
- /* FDT_ERR_BADSTATE: Function was passed an incomplete device
- * tree created by the sequential-write functions, which is
- * not sufficiently complete for the requested operation. */
-
-/* Error codes: codes for bad device tree blobs */
-#define FDT_ERR_TRUNCATED 8
- /* FDT_ERR_TRUNCATED: Structure block of the given device tree
- * ends without an FDT_END tag. */
-#define FDT_ERR_BADMAGIC 9
- /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a
- * device tree at all - it is missing the flattened device
- * tree magic number. */
-#define FDT_ERR_BADVERSION 10
- /* FDT_ERR_BADVERSION: Given device tree has a version which
- * can't be handled by the requested operation. For
- * read-write functions, this may mean that fdt_open_into() is
- * required to convert the tree to the expected version. */
-#define FDT_ERR_BADSTRUCTURE 11
- /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt
- * structure block or other serious error (e.g. misnested
- * nodes, or subnodes preceding properties). */
-#define FDT_ERR_BADLAYOUT 12
- /* FDT_ERR_BADLAYOUT: For read-write functions, the given
- * device tree has it's sub-blocks in an order that the
- * function can't handle (memory reserve map, then structure,
- * then strings). Use fdt_open_into() to reorganize the tree
- * into a form suitable for the read-write operations. */
-
-/* "Can't happen" error indicating a bug in libfdt */
-#define FDT_ERR_INTERNAL 13
- /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.
- * Should never be returned, if it is, it indicates a bug in
- * libfdt itself. */
-
-#define FDT_ERR_MAX 13
-
-/**********************************************************************/
-/* Low-level functions (you probably don't need these) */
-/**********************************************************************/
-
-const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
-static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
-{
- return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
-}
-
-uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
-
-/**********************************************************************/
-/* Traversal functions */
-/**********************************************************************/
-
-int fdt_next_node(const void *fdt, int offset, int *depth);
-
-/**
- * fdt_first_subnode() - get offset of first direct subnode
- *
- * @fdt: FDT blob
- * @offset: Offset of node to check
- * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
- */
-int fdt_first_subnode(const void *fdt, int offset);
-
-/**
- * fdt_next_subnode() - get offset of next direct subnode
- *
- * After first calling fdt_first_subnode(), call this function repeatedly to
- * get direct subnodes of a parent node.
- *
- * @fdt: FDT blob
- * @offset: Offset of previous subnode
- * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
- * subnodes
- */
-int fdt_next_subnode(const void *fdt, int offset);
-
-/**********************************************************************/
-/* General functions */
-/**********************************************************************/
-
-#define fdt_get_header(fdt, field) \
- (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
-#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
-#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
-#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
-#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
-#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
-#define fdt_version(fdt) (fdt_get_header(fdt, version))
-#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
-#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
-#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
-#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
-
-#define __fdt_set_hdr(name) \
- static inline void fdt_set_##name(void *fdt, uint32_t val) \
- { \
- struct fdt_header *fdth = (struct fdt_header*)fdt; \
- fdth->name = cpu_to_fdt32(val); \
- }
-__fdt_set_hdr(magic);
-__fdt_set_hdr(totalsize);
-__fdt_set_hdr(off_dt_struct);
-__fdt_set_hdr(off_dt_strings);
-__fdt_set_hdr(off_mem_rsvmap);
-__fdt_set_hdr(version);
-__fdt_set_hdr(last_comp_version);
-__fdt_set_hdr(boot_cpuid_phys);
-__fdt_set_hdr(size_dt_strings);
-__fdt_set_hdr(size_dt_struct);
-#undef __fdt_set_hdr
-
-/**
- * fdt_check_header - sanity check a device tree or possible device tree
- * @fdt: pointer to data which might be a flattened device tree
- *
- * fdt_check_header() checks that the given buffer contains what
- * appears to be a flattened device tree with sane information in its
- * header.
- *
- * returns:
- * 0, if the buffer appears to contain a valid device tree
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE, standard meanings, as above
- */
-int fdt_check_header(const void *fdt);
-
-/**
- * fdt_move - move a device tree around in memory
- * @fdt: pointer to the device tree to move
- * @buf: pointer to memory where the device is to be moved
- * @bufsize: size of the memory space at buf
- *
- * fdt_move() relocates, if possible, the device tree blob located at
- * fdt to the buffer at buf of size bufsize. The buffer may overlap
- * with the existing device tree blob at fdt. Therefore,
- * fdt_move(fdt, fdt, fdt_totalsize(fdt))
- * should always succeed.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE, standard meanings
- */
-int fdt_move(const void *fdt, void *buf, int bufsize);
-
-/**********************************************************************/
-/* Read-only functions */
-/**********************************************************************/
-
-/**
- * fdt_string - retrieve a string from the strings block of a device tree
- * @fdt: pointer to the device tree blob
- * @stroffset: offset of the string within the strings block (native endian)
- *
- * fdt_string() retrieves a pointer to a single string from the
- * strings block of the device tree blob at fdt.
- *
- * returns:
- * a pointer to the string, on success
- * NULL, if stroffset is out of bounds
- */
-const char *fdt_string(const void *fdt, int stroffset);
-
-/**
- * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
- * @fdt: pointer to the device tree blob
- *
- * Returns the number of entries in the device tree blob's memory
- * reservation map. This does not include the terminating 0,0 entry
- * or any other (0,0) entries reserved for expansion.
- *
- * returns:
- * the number of entries
- */
-int fdt_num_mem_rsv(const void *fdt);
-
-/**
- * fdt_get_mem_rsv - retrieve one memory reserve map entry
- * @fdt: pointer to the device tree blob
- * @address, @size: pointers to 64-bit variables
- *
- * On success, *address and *size will contain the address and size of
- * the n-th reserve map entry from the device tree blob, in
- * native-endian format.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE, standard meanings
- */
-int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
-
-/**
- * fdt_subnode_offset_namelen - find a subnode based on substring
- * @fdt: pointer to the device tree blob
- * @parentoffset: structure block offset of a node
- * @name: name of the subnode to locate
- * @namelen: number of characters of name to consider
- *
- * Identical to fdt_subnode_offset(), but only examine the first
- * namelen characters of name for matching the subnode name. This is
- * useful for finding subnodes based on a portion of a larger string,
- * such as a full path.
- */
-int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
- const char *name, int namelen);
-/**
- * fdt_subnode_offset - find a subnode of a given node
- * @fdt: pointer to the device tree blob
- * @parentoffset: structure block offset of a node
- * @name: name of the subnode to locate
- *
- * fdt_subnode_offset() finds a subnode of the node at structure block
- * offset parentoffset with the given name. name may include a unit
- * address, in which case fdt_subnode_offset() will find the subnode
- * with that unit address, or the unit address may be omitted, in
- * which case fdt_subnode_offset() will find an arbitrary subnode
- * whose name excluding unit address matches the given name.
- *
- * returns:
- * structure block offset of the requested subnode (>=0), on success
- * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
- * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
- */
-int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
-
-/**
- * fdt_path_offset - find a tree node by its full path
- * @fdt: pointer to the device tree blob
- * @path: full path of the node to locate
- *
- * fdt_path_offset() finds a node of a given path in the device tree.
- * Each path component may omit the unit address portion, but the
- * results of this are undefined if any such path component is
- * ambiguous (that is if there are multiple nodes at the relevant
- * level matching the given component, differentiated only by unit
- * address).
- *
- * returns:
- * structure block offset of the node with the requested path (>=0), on success
- * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
- * -FDT_ERR_NOTFOUND, if the requested node does not exist
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
- */
-int fdt_path_offset(const void *fdt, const char *path);
-
-/**
- * fdt_get_name - retrieve the name of a given node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: structure block offset of the starting node
- * @lenp: pointer to an integer variable (will be overwritten) or NULL
- *
- * fdt_get_name() retrieves the name (including unit address) of the
- * device tree node at structure block offset nodeoffset. If lenp is
- * non-NULL, the length of this name is also returned, in the integer
- * pointed to by lenp.
- *
- * returns:
- * pointer to the node's name, on success
- * If lenp is non-NULL, *lenp contains the length of that name (>=0)
- * NULL, on error
- * if lenp is non-NULL *lenp contains an error code (<0):
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE, standard meanings
- */
-const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
-
-/**
- * fdt_first_property_offset - find the offset of a node's first property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: structure block offset of a node
- *
- * fdt_first_property_offset() finds the first property of the node at
- * the given structure block offset.
- *
- * returns:
- * structure block offset of the property (>=0), on success
- * -FDT_ERR_NOTFOUND, if the requested node has no properties
- * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
- */
-int fdt_first_property_offset(const void *fdt, int nodeoffset);
-
-/**
- * fdt_next_property_offset - step through a node's properties
- * @fdt: pointer to the device tree blob
- * @offset: structure block offset of a property
- *
- * fdt_next_property_offset() finds the property immediately after the
- * one at the given structure block offset. This will be a property
- * of the same node as the given property.
- *
- * returns:
- * structure block offset of the next property (>=0), on success
- * -FDT_ERR_NOTFOUND, if the given property is the last in its node
- * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
- */
-int fdt_next_property_offset(const void *fdt, int offset);
-
-/**
- * fdt_get_property_by_offset - retrieve the property at a given offset
- * @fdt: pointer to the device tree blob
- * @offset: offset of the property to retrieve
- * @lenp: pointer to an integer variable (will be overwritten) or NULL
- *
- * fdt_get_property_by_offset() retrieves a pointer to the
- * fdt_property structure within the device tree blob at the given
- * offset. If lenp is non-NULL, the length of the property value is
- * also returned, in the integer pointed to by lenp.
- *
- * returns:
- * pointer to the structure representing the property
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
- int offset,
- int *lenp);
-
-/**
- * fdt_get_property_namelen - find a property based on substring
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to find
- * @name: name of the property to find
- * @namelen: number of characters of name to consider
- * @lenp: pointer to an integer variable (will be overwritten) or NULL
- *
- * Identical to fdt_get_property_namelen(), but only examine the first
- * namelen characters of name for matching the property name.
- */
-const struct fdt_property *fdt_get_property_namelen(const void *fdt,
- int nodeoffset,
- const char *name,
- int namelen, int *lenp);
-
-/**
- * fdt_get_property - find a given property in a given node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to find
- * @name: name of the property to find
- * @lenp: pointer to an integer variable (will be overwritten) or NULL
- *
- * fdt_get_property() retrieves a pointer to the fdt_property
- * structure within the device tree blob corresponding to the property
- * named 'name' of the node at offset nodeoffset. If lenp is
- * non-NULL, the length of the property value is also returned, in the
- * integer pointed to by lenp.
- *
- * returns:
- * pointer to the structure representing the property
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_NOTFOUND, node does not have named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,
- const char *name, int *lenp);
-static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
- const char *name,
- int *lenp)
-{
- return (struct fdt_property *)(uintptr_t)
- fdt_get_property(fdt, nodeoffset, name, lenp);
-}
-
-/**
- * fdt_getprop_by_offset - retrieve the value of a property at a given offset
- * @fdt: pointer to the device tree blob
- * @ffset: offset of the property to read
- * @namep: pointer to a string variable (will be overwritten) or NULL
- * @lenp: pointer to an integer variable (will be overwritten) or NULL
- *
- * fdt_getprop_by_offset() retrieves a pointer to the value of the
- * property at structure block offset 'offset' (this will be a pointer
- * to within the device blob itself, not a copy of the value). If
- * lenp is non-NULL, the length of the property value is also
- * returned, in the integer pointed to by lenp. If namep is non-NULL,
- * the property's namne will also be returned in the char * pointed to
- * by namep (this will be a pointer to within the device tree's string
- * block, not a new copy of the name).
- *
- * returns:
- * pointer to the property's value
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * if namep is non-NULL *namep contiains a pointer to the property
- * name.
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-const void *fdt_getprop_by_offset(const void *fdt, int offset,
- const char **namep, int *lenp);
-
-/**
- * fdt_getprop_namelen - get property value based on substring
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to find
- * @name: name of the property to find
- * @namelen: number of characters of name to consider
- * @lenp: pointer to an integer variable (will be overwritten) or NULL
- *
- * Identical to fdt_getprop(), but only examine the first namelen
- * characters of name for matching the property name.
- */
-const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
- const char *name, int namelen, int *lenp);
-
-/**
- * fdt_getprop - retrieve the value of a given property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to find
- * @name: name of the property to find
- * @lenp: pointer to an integer variable (will be overwritten) or NULL
- *
- * fdt_getprop() retrieves a pointer to the value of the property
- * named 'name' of the node at offset nodeoffset (this will be a
- * pointer to within the device blob itself, not a copy of the value).
- * If lenp is non-NULL, the length of the property value is also
- * returned, in the integer pointed to by lenp.
- *
- * returns:
- * pointer to the property's value
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_NOTFOUND, node does not have named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-const void *fdt_getprop(const void *fdt, int nodeoffset,
- const char *name, int *lenp);
-static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
- const char *name, int *lenp)
-{
- return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
-}
-
-/**
- * fdt_get_phandle - retrieve the phandle of a given node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: structure block offset of the node
- *
- * fdt_get_phandle() retrieves the phandle of the device tree node at
- * structure block offset nodeoffset.
- *
- * returns:
- * the phandle of the node at nodeoffset, on success (!= 0, != -1)
- * 0, if the node has no phandle, or another error occurs
- */
-uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
-
-/**
- * fdt_get_alias_namelen - get alias based on substring
- * @fdt: pointer to the device tree blob
- * @name: name of the alias th look up
- * @namelen: number of characters of name to consider
- *
- * Identical to fdt_get_alias(), but only examine the first namelen
- * characters of name for matching the alias name.
- */
-const char *fdt_get_alias_namelen(const void *fdt,
- const char *name, int namelen);
-
-/**
- * fdt_get_alias - retreive the path referenced by a given alias
- * @fdt: pointer to the device tree blob
- * @name: name of the alias th look up
- *
- * fdt_get_alias() retrieves the value of a given alias. That is, the
- * value of the property named 'name' in the node /aliases.
- *
- * returns:
- * a pointer to the expansion of the alias named 'name', if it exists
- * NULL, if the given alias or the /aliases node does not exist
- */
-const char *fdt_get_alias(const void *fdt, const char *name);
-
-/**
- * fdt_get_path - determine the full path of a node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose path to find
- * @buf: character buffer to contain the returned path (will be overwritten)
- * @buflen: size of the character buffer at buf
- *
- * fdt_get_path() computes the full path of the node at offset
- * nodeoffset, and records that path in the buffer at buf.
- *
- * NOTE: This function is expensive, as it must scan the device tree
- * structure from the start to nodeoffset.
- *
- * returns:
- * 0, on success
- * buf contains the absolute path of the node at
- * nodeoffset, as a NUL-terminated string.
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)
- * characters and will not fit in the given buffer.
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
-
-/**
- * fdt_supernode_atdepth_offset - find a specific ancestor of a node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose parent to find
- * @supernodedepth: depth of the ancestor to find
- * @nodedepth: pointer to an integer variable (will be overwritten) or NULL
- *
- * fdt_supernode_atdepth_offset() finds an ancestor of the given node
- * at a specific depth from the root (where the root itself has depth
- * 0, its immediate subnodes depth 1 and so forth). So
- * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);
- * will always return 0, the offset of the root node. If the node at
- * nodeoffset has depth D, then:
- * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);
- * will return nodeoffset itself.
- *
- * NOTE: This function is expensive, as it must scan the device tree
- * structure from the start to nodeoffset.
- *
- * returns:
-
- * structure block offset of the node at node offset's ancestor
- * of depth supernodedepth (>=0), on success
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
-* -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of nodeoffset
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
- int supernodedepth, int *nodedepth);
-
-/**
- * fdt_node_depth - find the depth of a given node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose parent to find
- *
- * fdt_node_depth() finds the depth of a given node. The root node
- * has depth 0, its immediate subnodes depth 1 and so forth.
- *
- * NOTE: This function is expensive, as it must scan the device tree
- * structure from the start to nodeoffset.
- *
- * returns:
- * depth of the node at nodeoffset (>=0), on success
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_node_depth(const void *fdt, int nodeoffset);
-
-/**
- * fdt_parent_offset - find the parent of a given node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose parent to find
- *
- * fdt_parent_offset() locates the parent node of a given node (that
- * is, it finds the offset of the node which contains the node at
- * nodeoffset as a subnode).
- *
- * NOTE: This function is expensive, as it must scan the device tree
- * structure from the start to nodeoffset, *twice*.
- *
- * returns:
- * structure block offset of the parent of the node at nodeoffset
- * (>=0), on success
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_parent_offset(const void *fdt, int nodeoffset);
-
-/**
- * fdt_node_offset_by_prop_value - find nodes with a given property value
- * @fdt: pointer to the device tree blob
- * @startoffset: only find nodes after this offset
- * @propname: property name to check
- * @propval: property value to search for
- * @proplen: length of the value in propval
- *
- * fdt_node_offset_by_prop_value() returns the offset of the first
- * node after startoffset, which has a property named propname whose
- * value is of length proplen and has value equal to propval; or if
- * startoffset is -1, the very first such node in the tree.
- *
- * To iterate through all nodes matching the criterion, the following
- * idiom can be used:
- * offset = fdt_node_offset_by_prop_value(fdt, -1, propname,
- * propval, proplen);
- * while (offset != -FDT_ERR_NOTFOUND) {
- * // other code here
- * offset = fdt_node_offset_by_prop_value(fdt, offset, propname,
- * propval, proplen);
- * }
- *
- * Note the -1 in the first call to the function, if 0 is used here
- * instead, the function will never locate the root node, even if it
- * matches the criterion.
- *
- * returns:
- * structure block offset of the located node (>= 0, >startoffset),
- * on success
- * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
- * tree after startoffset
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
- const char *propname,
- const void *propval, int proplen);
-
-/**
- * fdt_node_offset_by_phandle - find the node with a given phandle
- * @fdt: pointer to the device tree blob
- * @phandle: phandle value
- *
- * fdt_node_offset_by_phandle() returns the offset of the node
- * which has the given phandle value. If there is more than one node
- * in the tree with the given phandle (an invalid tree), results are
- * undefined.
- *
- * returns:
- * structure block offset of the located node (>= 0), on success
- * -FDT_ERR_NOTFOUND, no node with that phandle exists
- * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
-
-/**
- * fdt_node_check_compatible: check a node's compatible property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of a tree node
- * @compatible: string to match against
- *
- *
- * fdt_node_check_compatible() returns 0 if the given node contains a
- * 'compatible' property with the given string as one of its elements,
- * it returns non-zero otherwise, or on error.
- *
- * returns:
- * 0, if the node has a 'compatible' property listing the given string
- * 1, if the node has a 'compatible' property, but it does not list
- * the given string
- * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property
- * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_node_check_compatible(const void *fdt, int nodeoffset,
- const char *compatible);
-
-/**
- * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value
- * @fdt: pointer to the device tree blob
- * @startoffset: only find nodes after this offset
- * @compatible: 'compatible' string to match against
- *
- * fdt_node_offset_by_compatible() returns the offset of the first
- * node after startoffset, which has a 'compatible' property which
- * lists the given compatible string; or if startoffset is -1, the
- * very first such node in the tree.
- *
- * To iterate through all nodes matching the criterion, the following
- * idiom can be used:
- * offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
- * while (offset != -FDT_ERR_NOTFOUND) {
- * // other code here
- * offset = fdt_node_offset_by_compatible(fdt, offset, compatible);
- * }
- *
- * Note the -1 in the first call to the function, if 0 is used here
- * instead, the function will never locate the root node, even if it
- * matches the criterion.
- *
- * returns:
- * structure block offset of the located node (>= 0, >startoffset),
- * on success
- * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
- * tree after startoffset
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
- */
-int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
- const char *compatible);
-
-/**
- * fdt_stringlist_contains - check a string list property for a string
- * @strlist: Property containing a list of strings to check
- * @listlen: Length of property
- * @str: String to search for
- *
- * This is a utility function provided for convenience. The list contains
- * one or more strings, each terminated by \0, as is found in a device tree
- * "compatible" property.
- *
- * @return: 1 if the string is found in the list, 0 not found, or invalid list
- */
-int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
-
-/**********************************************************************/
-/* Write-in-place functions */
-/**********************************************************************/
-
-/**
- * fdt_setprop_inplace - change a property's value, but not its size
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: pointer to data to replace the property value with
- * @len: length of the property value
- *
- * fdt_setprop_inplace() replaces the value of a given property with
- * the data in val, of length len. This function cannot change the
- * size of a property, and so will only work if len is equal to the
- * current length of the property.
- *
- * This function will alter only the bytes in the blob which contain
- * the given property value, and will not alter or move any other part
- * of the tree.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, if len is not equal to the property's current length
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
- const void *val, int len);
-
-/**
- * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: 32-bit integer value to replace the property with
- *
- * fdt_setprop_inplace_u32() replaces the value of a given property
- * with the 32-bit integer value in val, converting val to big-endian
- * if necessary. This function cannot change the size of a property,
- * and so will only work if the property already exists and has length
- * 4.
- *
- * This function will alter only the bytes in the blob which contain
- * the given property value, and will not alter or move any other part
- * of the tree.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, if the property's length is not equal to 4
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
-{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
-}
-
-/**
- * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: 64-bit integer value to replace the property with
- *
- * fdt_setprop_inplace_u64() replaces the value of a given property
- * with the 64-bit integer value in val, converting val to big-endian
- * if necessary. This function cannot change the size of a property,
- * and so will only work if the property already exists and has length
- * 8.
- *
- * This function will alter only the bytes in the blob which contain
- * the given property value, and will not alter or move any other part
- * of the tree.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, if the property's length is not equal to 8
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
- const char *name, uint64_t val)
-{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
-}
-
-/**
- * fdt_setprop_inplace_cell - change the value of a single-cell property
- *
- * This is an alternative name for fdt_setprop_inplace_u32()
- */
-static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
-{
- return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
-}
-
-/**
- * fdt_nop_property - replace a property with nop tags
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to nop
- * @name: name of the property to nop
- *
- * fdt_nop_property() will replace a given property's representation
- * in the blob with FDT_NOP tags, effectively removing it from the
- * tree.
- *
- * This function will alter only the bytes in the blob which contain
- * the property, and will not alter or move any other part of the
- * tree.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
-
-/**
- * fdt_nop_node - replace a node (subtree) with nop tags
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node to nop
- *
- * fdt_nop_node() will replace a given node's representation in the
- * blob, including all its subnodes, if any, with FDT_NOP tags,
- * effectively removing it from the tree.
- *
- * This function will alter only the bytes in the blob which contain
- * the node and its properties and subnodes, and will not alter or
- * move any other part of the tree.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_nop_node(void *fdt, int nodeoffset);
-
-/**********************************************************************/
-/* Sequential write functions */
-/**********************************************************************/
-
-int fdt_create(void *buf, int bufsize);
-int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
-int fdt_finish_reservemap(void *fdt);
-int fdt_begin_node(void *fdt, const char *name);
-int fdt_property(void *fdt, const char *name, const void *val, int len);
-static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
-{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_property(fdt, name, &tmp, sizeof(tmp));
-}
-static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
-{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_property(fdt, name, &tmp, sizeof(tmp));
-}
-static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
-{
- return fdt_property_u32(fdt, name, val);
-}
-#define fdt_property_string(fdt, name, str) \
- fdt_property(fdt, name, str, strlen(str)+1)
-int fdt_end_node(void *fdt);
-int fdt_finish(void *fdt);
-
-/**********************************************************************/
-/* Read-write functions */
-/**********************************************************************/
-
-int fdt_create_empty_tree(void *buf, int bufsize);
-int fdt_open_into(const void *fdt, void *buf, int bufsize);
-int fdt_pack(void *fdt);
-
-/**
- * fdt_add_mem_rsv - add one memory reserve map entry
- * @fdt: pointer to the device tree blob
- * @address, @size: 64-bit values (native endian)
- *
- * Adds a reserve map entry to the given blob reserving a region at
- * address address of length size.
- *
- * This function will insert data into the reserve map and will
- * therefore change the indexes of some entries in the table.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new reservation entry
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
-
-/**
- * fdt_del_mem_rsv - remove a memory reserve map entry
- * @fdt: pointer to the device tree blob
- * @n: entry to remove
- *
- * fdt_del_mem_rsv() removes the n-th memory reserve map entry from
- * the blob.
- *
- * This function will delete data from the reservation table and will
- * therefore change the indexes of some entries in the table.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there
- * are less than n+1 reserve map entries)
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_del_mem_rsv(void *fdt, int n);
-
-/**
- * fdt_set_name - change the name of a given node
- * @fdt: pointer to the device tree blob
- * @nodeoffset: structure block offset of a node
- * @name: name to give the node
- *
- * fdt_set_name() replaces the name (including unit address, if any)
- * of the given node with the given string. NOTE: this function can't
- * efficiently check if the new name is unique amongst the given
- * node's siblings; results are undefined if this function is invoked
- * with a name equal to one of the given node's siblings.
- *
- * This function may insert or delete data from the blob, and will
- * therefore change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob
- * to contain the new name
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE, standard meanings
- */
-int fdt_set_name(void *fdt, int nodeoffset, const char *name);
-
-/**
- * fdt_setprop - create or change a property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: pointer to data to set the property value to
- * @len: length of the property value
- *
- * fdt_setprop() sets the value of the named property in the given
- * node to the given value and length, creating the property if it
- * does not already exist.
- *
- * This function may insert or delete data from the blob, and will
- * therefore change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_setprop(void *fdt, int nodeoffset, const char *name,
- const void *val, int len);
-
-/**
- * fdt_setprop_u32 - set a property to a 32-bit integer
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: 32-bit integer value for the property (native endian)
- *
- * fdt_setprop_u32() sets the value of the named property in the given
- * node to the given 32-bit integer value (converting to big-endian if
- * necessary), or creates a new property with that value if it does
- * not already exist.
- *
- * This function may insert or delete data from the blob, and will
- * therefore change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
- uint32_t val)
-{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
-}
-
-/**
- * fdt_setprop_u64 - set a property to a 64-bit integer
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: 64-bit integer value for the property (native endian)
- *
- * fdt_setprop_u64() sets the value of the named property in the given
- * node to the given 64-bit integer value (converting to big-endian if
- * necessary), or creates a new property with that value if it does
- * not already exist.
- *
- * This function may insert or delete data from the blob, and will
- * therefore change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
- uint64_t val)
-{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
-}
-
-/**
- * fdt_setprop_cell - set a property to a single cell value
- *
- * This is an alternative name for fdt_setprop_u32()
- */
-static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
- uint32_t val)
-{
- return fdt_setprop_u32(fdt, nodeoffset, name, val);
-}
-
-/**
- * fdt_setprop_string - set a property to a string value
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @str: string value for the property
- *
- * fdt_setprop_string() sets the value of the named property in the
- * given node to the given string value (using the length of the
- * string to determine the new length of the property), or creates a
- * new property with that value if it does not already exist.
- *
- * This function may insert or delete data from the blob, and will
- * therefore change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-#define fdt_setprop_string(fdt, nodeoffset, name, str) \
- fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
-
-/**
- * fdt_appendprop - append to or create a property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to append to
- * @val: pointer to data to append to the property value
- * @len: length of the data to append to the property value
- *
- * fdt_appendprop() appends the value to the named property in the
- * given node, creating the property if it does not already exist.
- *
- * This function may insert data into the blob, and will therefore
- * change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
- const void *val, int len);
-
-/**
- * fdt_appendprop_u32 - append a 32-bit integer value to a property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: 32-bit integer value to append to the property (native endian)
- *
- * fdt_appendprop_u32() appends the given 32-bit integer value
- * (converting to big-endian if necessary) to the value of the named
- * property in the given node, or creates a new property with that
- * value if it does not already exist.
- *
- * This function may insert data into the blob, and will therefore
- * change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
-{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
-}
-
-/**
- * fdt_appendprop_u64 - append a 64-bit integer value to a property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @val: 64-bit integer value to append to the property (native endian)
- *
- * fdt_appendprop_u64() appends the given 64-bit integer value
- * (converting to big-endian if necessary) to the value of the named
- * property in the given node, or creates a new property with that
- * value if it does not already exist.
- *
- * This function may insert data into the blob, and will therefore
- * change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
- const char *name, uint64_t val)
-{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
-}
-
-/**
- * fdt_appendprop_cell - append a single cell value to a property
- *
- * This is an alternative name for fdt_appendprop_u32()
- */
-static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
-{
- return fdt_appendprop_u32(fdt, nodeoffset, name, val);
-}
-
-/**
- * fdt_appendprop_string - append a string to a property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to change
- * @name: name of the property to change
- * @str: string value to append to the property
- *
- * fdt_appendprop_string() appends the given string to the value of
- * the named property in the given node, or creates a new property
- * with that value if it does not already exist.
- *
- * This function may insert data into the blob, and will therefore
- * change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-#define fdt_appendprop_string(fdt, nodeoffset, name, str) \
- fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
-
-/**
- * fdt_delprop - delete a property
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node whose property to nop
- * @name: name of the property to nop
- *
- * fdt_del_property() will delete the given property.
- *
- * This function will delete data from the blob, and will therefore
- * change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_delprop(void *fdt, int nodeoffset, const char *name);
-
-/**
- * fdt_add_subnode_namelen - creates a new node based on substring
- * @fdt: pointer to the device tree blob
- * @parentoffset: structure block offset of a node
- * @name: name of the subnode to locate
- * @namelen: number of characters of name to consider
- *
- * Identical to fdt_add_subnode(), but use only the first namelen
- * characters of name as the name of the new node. This is useful for
- * creating subnodes based on a portion of a larger string, such as a
- * full path.
- */
-int fdt_add_subnode_namelen(void *fdt, int parentoffset,
- const char *name, int namelen);
-
-/**
- * fdt_add_subnode - creates a new node
- * @fdt: pointer to the device tree blob
- * @parentoffset: structure block offset of a node
- * @name: name of the subnode to locate
- *
- * fdt_add_subnode() creates a new node as a subnode of the node at
- * structure block offset parentoffset, with the given name (which
- * should include the unit address, if any).
- *
- * This function will insert data into the blob, and will therefore
- * change the offsets of some existing nodes.
-
- * returns:
- * structure block offset of the created nodeequested subnode (>=0), on success
- * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
- * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag
- * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of
- * the given name
- * -FDT_ERR_NOSPACE, if there is insufficient free space in the
- * blob to contain the new node
- * -FDT_ERR_NOSPACE
- * -FDT_ERR_BADLAYOUT
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
- */
-int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
-
-/**
- * fdt_del_node - delete a node (subtree)
- * @fdt: pointer to the device tree blob
- * @nodeoffset: offset of the node to nop
- *
- * fdt_del_node() will remove the given node, including all its
- * subnodes if any, from the blob.
- *
- * This function will delete data from the blob, and will therefore
- * change the offsets of some existing nodes.
- *
- * returns:
- * 0, on success
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_del_node(void *fdt, int nodeoffset);
-
-/**********************************************************************/
-/* Debugging / informational functions */
-/**********************************************************************/
-
-const char *fdt_strerror(int errval);
-
-#endif /* _LIBFDT_H */
diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h
deleted file mode 100644
index 3e24db9409..0000000000
--- a/EmbeddedPkg/Include/libfdt_env.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2014, 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 UINT16 fdt16_t;
-typedef UINT32 fdt32_t;
-typedef UINT64 fdt64_t;
-
-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(fdt16_t x)
-{
- return SwapBytes16 (x);
-}
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
-
-static inline uint32_t fdt32_to_cpu(fdt32_t x)
-{
- return SwapBytes32 (x);
-}
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
-
-static inline uint64_t fdt64_to_cpu(fdt64_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 */
diff --git a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c b/EmbeddedPkg/Library/AcpiLib/AcpiLib.c
deleted file mode 100644
index 0e27276c22..0000000000
--- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/** @file
-*
-* Copyright (c) 2014-2015, 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.
-*
-**/
-
-#include <Uefi.h>
-
-#include <Library/AcpiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include <Protocol/AcpiTable.h>
-#include <Protocol/FirmwareVolume2.h>
-
-#include <IndustryStandard/Acpi.h>
-
-/**
- Locate and Install the ACPI tables from the Firmware Volume if it verifies
- the function condition.
-
- @param AcpiFile Guid of the ACPI file into the Firmware Volume
- @param CheckAcpiTableFunction Function that checks if the ACPI table should be installed
-
- @return EFI_SUCCESS The function completed successfully.
- @return EFI_NOT_FOUND The protocol could not be located.
- @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
-
-**/
-EFI_STATUS
-LocateAndInstallAcpiFromFvConditional (
- IN CONST EFI_GUID* AcpiFile,
- IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
- )
-{
- EFI_STATUS Status;
- EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- UINT32 FvStatus;
- UINTN Index;
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
- INTN SectionInstance;
- UINTN SectionSize;
- EFI_ACPI_COMMON_HEADER *AcpiTable;
- UINTN AcpiTableSize;
- UINTN AcpiTableKey;
- BOOLEAN Valid;
-
- // Ensure the ACPI Table is present
- Status = gBS->LocateProtocol (
- &gEfiAcpiTableProtocolGuid,
- NULL,
- (VOID**)&AcpiProtocol
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- FvStatus = 0;
- SectionInstance = 0;
-
- // Locate all the Firmware Volume protocols.
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiFirmwareVolume2ProtocolGuid,
- NULL,
- &NumberOfHandles,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Looking for FV with ACPI storage file
- for (Index = 0; Index < NumberOfHandles; Index++) {
- //
- // Get the protocol on this handle
- // This should not fail because of LocateHandleBuffer
- //
- Status = gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiFirmwareVolume2ProtocolGuid,
- (VOID**) &FvInstance
- );
- if (EFI_ERROR (Status)) {
- goto FREE_HANDLE_BUFFER;
- }
-
- while (Status == EFI_SUCCESS) {
- // AcpiTable must be allocated by ReadSection (ie: AcpiTable == NULL)
- AcpiTable = NULL;
-
- // See if it has the ACPI storage file
- Status = FvInstance->ReadSection (
- FvInstance,
- AcpiFile,
- EFI_SECTION_RAW,
- SectionInstance,
- (VOID**) &AcpiTable,
- &SectionSize,
- &FvStatus
- );
- if (!EFI_ERROR (Status)) {
- AcpiTableKey = 0;
- AcpiTableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Length;
- ASSERT (SectionSize >= AcpiTableSize);
-
- DEBUG ((EFI_D_ERROR, "- Found '%c%c%c%c' ACPI Table\n",
- (((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature & 0xFF),
- ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 8) & 0xFF),
- ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 16) & 0xFF),
- ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 24) & 0xFF)));
-
- // Is the ACPI table valid?
- if (CheckAcpiTableFunction) {
- Valid = CheckAcpiTableFunction ((EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable);
- } else {
- Valid = TRUE;
- }
-
- // Install the ACPI Table
- if (Valid) {
- Status = AcpiProtocol->InstallAcpiTable (
- AcpiProtocol,
- AcpiTable,
- AcpiTableSize,
- &AcpiTableKey
- );
- }
-
- // Free memory allocated by ReadSection
- gBS->FreePool (AcpiTable);
-
- if (EFI_ERROR (Status)) {
- break;
- }
-
- // Increment the section instance
- SectionInstance++;
- }
- }
- }
-
-FREE_HANDLE_BUFFER:
- //
- // Free any allocated buffers
- //
- gBS->FreePool (HandleBuffer);
-
- return EFI_SUCCESS;
-}
-
-/**
- Locate and Install the ACPI tables from the Firmware Volume
-
- @param AcpiFile Guid of the ACPI file into the Firmware Volume
-
- @return EFI_SUCCESS The function completed successfully.
- @return EFI_NOT_FOUND The protocol could not be located.
- @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
-
-**/
-EFI_STATUS
-LocateAndInstallAcpiFromFv (
- IN CONST EFI_GUID* AcpiFile
- )
-{
- return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL);
-}
diff --git a/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf b/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
deleted file mode 100644
index 5080c50756..0000000000
--- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
+++ /dev/null
@@ -1,36 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2014, 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.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = AcpiLib
- FILE_GUID = 24b9d62c-5a36-417b-94b6-38dbaea90dcf
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = AcpiLib
-
-[Sources.common]
- AcpiLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- DebugLib
- UefiBootServicesTableLib
-
-[Protocols]
- gEfiAcpiTableProtocolGuid
- gEfiFirmwareVolume2ProtocolGuid
diff --git a/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c b/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c
deleted file mode 100755
index bb1ea132cf..0000000000
--- a/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/** @file
- Null Debug Agent timer.
-
- The debug agent uses the timer so the debugger can break into running programs.
- If you link against this library you will not be able to break into a running
- program with the debugger.
-
- 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.
-
-**/
-
-
-/**
- Setup all the hardware needed for the debug agents timer.
-
- This function is used to set up debug enviroment. It may enable interrupts.
-
-**/
-VOID
-EFIAPI
-DebugAgentTimerIntialize (
- VOID
- )
-{
-}
-
-
-/**
- Set the period for the debug agent timer. Zero means disable the timer.
-
- @param[in] TimerPeriodMilliseconds Frequency of the debug agent timer.
-
-**/
-VOID
-EFIAPI
-DebugAgentTimerSetPeriod (
- IN UINT32 TimerPeriodMilliseconds
- )
-{
-}
-
-
-/**
- Perform End Of Interrupt for the debug agent timer. This is called in the
- interrupt handler after the interrupt has been processed.
-
-**/
-VOID
-EFIAPI
-DebugAgentTimerEndOfInterrupt (
- VOID
- )
-{
-}
-
diff --git a/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf b/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
deleted file mode 100755
index 010bed3ad3..0000000000
--- a/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
+++ /dev/null
@@ -1,37 +0,0 @@
-#/** @file
-# Component description file for Base PCI Cf8 Library.
-#
-# PCI CF8 Library that uses I/O ports 0xCF8 and 0xCFC to perform PCI Configuration cycles.
-# Layers on top of an I/O Library instance.
-# 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]
- INF_VERSION = 0x00010005
- BASE_NAME = DebugAgentTimerLibNull
- FILE_GUID = 02f04694-2c0a-4f1e-b0ce-64be25890b03
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = DebugAgentTimerLib|SEC BASE DXE_CORE
-
-
-[Sources.common]
- DebugAgentTimerLib.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- IoLib
-
diff --git a/EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoff.c b/EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoff.c
deleted file mode 100644
index bcc694816a..0000000000
--- a/EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoff.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/** @file
- PE/COFF Loader Library implementation that wraps a protocol passed up from
- SEC/PEI via a HOB. This is done to save space.
-
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
- Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiDxe.h>
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-
-#include <Protocol/PeCoffLoader.h>
-
-
-PE_COFF_LOADER_PROTOCOL *gPeCoffLoader = NULL;
-
-
-/**
- Retrieves information about a PE/COFF image.
-
- Computes the PeCoffHeaderOffset, IsTeImage, ImageType, ImageAddress, ImageSize,
- DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and
- DebugDirectoryEntryRva fields of the ImageContext structure.
- If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
- If the PE/COFF image accessed through the ImageRead service in the ImageContext
- structure is not a supported PE/COFF image type, then return RETURN_UNSUPPORTED.
- If any errors occur while computing the fields of ImageContext,
- then the error status is returned in the ImageError field of ImageContext.
- If the image is a TE image, then SectionAlignment is set to 0.
- The ImageRead and Handle fields of ImageContext structure must be valid prior
- to invoking this service.
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image that needs to be examined by this function.
-
- @retval RETURN_SUCCESS The information on the PE/COFF image was collected.
- @retval RETURN_INVALID_PARAMETER ImageContext is NULL.
- @retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
-
-**/
-RETURN_STATUS
-EFIAPI
-PeCoffLoaderGetImageInfo (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- )
-{
- return gPeCoffLoader->GetImageInfo (ImageContext);
-}
-
-
-/**
- Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
-
- If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
- ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
- of ImageContext as the relocation base address. The caller must allocate the relocation
- fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
-
- The ImageRead, Handle, PeCoffHeaderOffset, IsTeImage, Machine, ImageType, ImageAddress,
- ImageSize, DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders,
- DebugDirectoryEntryRva, EntryPoint, FixupDataSize, CodeView, PdbPointer, and FixupData of
- the ImageContext structure must be valid prior to invoking this service.
-
- If ImageContext is NULL, then ASSERT().
-
- Note that if the platform does not maintain coherency between the instruction cache(s) and the data
- cache(s) in hardware, then the caller is responsible for performing cache maintenance operations
- prior to transferring control to a PE/COFF image that is loaded using this library.
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image that is being relocated.
-
- @retval RETURN_SUCCESS The PE/COFF image was relocated.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_UNSUPPORTED A relocation record type is not supported.
- Extended status information is in the ImageError field of ImageContext.
-
-**/
-RETURN_STATUS
-EFIAPI
-PeCoffLoaderRelocateImage (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- )
-{
- return gPeCoffLoader->RelocateImage (ImageContext);
-}
-
-/**
- Loads a PE/COFF image into memory.
-
- Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
- specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
- the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
- The EntryPoint, FixupDataSize, CodeView, PdbPointer and HiiResourceData fields of ImageContext are computed.
- The ImageRead, Handle, PeCoffHeaderOffset, IsTeImage, Machine, ImageType, ImageAddress, ImageSize,
- DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
- fields of the ImageContext structure must be valid prior to invoking this service.
-
- If ImageContext is NULL, then ASSERT().
-
- Note that if the platform does not maintain coherency between the instruction cache(s) and the data
- cache(s) in hardware, then the caller is responsible for performing cache maintenance operations
- prior to transferring control to a PE/COFF image that is loaded using this library.
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image that is being loaded.
-
- @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
- the ImageAddress and ImageSize fields of ImageContext.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
- Extended status information is in the ImageError field of ImageContext.
- @retval RETURN_INVALID_PARAMETER The image address is invalid.
- Extended status information is in the ImageError field of ImageContext.
-
-**/
-RETURN_STATUS
-EFIAPI
-PeCoffLoaderLoadImage (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- )
-{
- return gPeCoffLoader->LoadImage (ImageContext);
-}
-
-
-
-/**
- Reads contents of a PE/COFF image from a buffer in system memory.
-
- This is the default implementation of a PE_COFF_LOADER_READ_FILE function
- that assumes FileHandle pointer to the beginning of a PE/COFF image.
- This function reads contents of the PE/COFF image that starts at the system memory
- address specified by FileHandle. The read operation copies ReadSize bytes from the
- PE/COFF image starting at byte offset FileOffset into the buffer specified by Buffer.
- The size of the buffer actually read is returned in ReadSize.
-
- If FileHandle is NULL, then ASSERT().
- If ReadSize is NULL, then ASSERT().
- If Buffer is NULL, then ASSERT().
-
- @param FileHandle Pointer to base of the input stream
- @param FileOffset Offset into the PE/COFF image to begin the read operation.
- @param ReadSize On input, the size in bytes of the requested read operation.
- On output, the number of bytes actually read.
- @param Buffer Output buffer that contains the data read from the PE/COFF image.
-
- @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
- the buffer.
-**/
-RETURN_STATUS
-EFIAPI
-PeCoffLoaderImageReadFromMemory (
- IN VOID *FileHandle,
- IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
- OUT VOID *Buffer
- )
-{
- return gPeCoffLoader->ReadFromMemory (
- FileHandle,
- FileOffset,
- ReadSize,
- Buffer
- );
-
-}
-
-
-
-/**
- Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
- runtime.
-
- This function reapplies relocation fixups to the PE/COFF image specified by ImageBase
- and ImageSize so the image will execute correctly when the PE/COFF image is mapped
- to the address specified by VirtualImageBase. RelocationData must be identical
- to the FiuxupData buffer from the PE_COFF_LOADER_IMAGE_CONTEXT structure
- after this PE/COFF image was relocated with PeCoffLoaderRelocateImage().
-
- Note that if the platform does not maintain coherency between the instruction cache(s) and the data
- cache(s) in hardware, then the caller is responsible for performing cache maintenance operations
- prior to transferring control to a PE/COFF image that is loaded using this library.
-
- @param ImageBase Base address of a PE/COFF image that has been loaded
- and relocated into system memory.
- @param VirtImageBase The request virtual address that the PE/COFF image is to
- be fixed up for.
- @param ImageSize The size, in bytes, of the PE/COFF image.
- @param RelocationData A pointer to the relocation data that was collected when the PE/COFF
- image was relocated using PeCoffLoaderRelocateImage().
-
-**/
-VOID
-EFIAPI
-PeCoffLoaderRelocateImageForRuntime (
- IN PHYSICAL_ADDRESS ImageBase,
- IN PHYSICAL_ADDRESS VirtImageBase,
- IN UINTN ImageSize,
- IN VOID *RelocationData
- )
-{
- return gPeCoffLoader->RelocateImageForRuntime (
- ImageBase,
- VirtImageBase,
- ImageSize,
- RelocationData
- );
-}
-
-
-/**
- Unloads a loaded PE/COFF image from memory and releases its taken resource.
- Releases any environment specific resources that were allocated when the image
- specified by ImageContext was loaded using PeCoffLoaderLoadImage().
-
- For NT32 emulator, the PE/COFF image loaded by system needs to release.
- For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
- this function can simply return RETURN_SUCCESS.
-
- If ImageContext is NULL, then ASSERT().
-
- @param ImageContext Pointer to the image context structure that describes the PE/COFF
- image to be unloaded.
-
- @retval RETURN_SUCCESS The PE/COFF image was unloaded successfully.
-**/
-RETURN_STATUS
-EFIAPI
-PeCoffLoaderUnloadImage (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- )
-{
- return gPeCoffLoader->UnloadImage (ImageContext);
-}
-
-typedef struct {
- EFI_HOB_GUID_TYPE Hob;
- VOID *Interface;
-} PROTOCOL_HOB;
-
-
-/**
- The constructor function caches the pointer of DXE Services Table.
-
- The constructor function caches the pointer of DXE Services Table.
- It will ASSERT() if that operation fails.
- It will ASSERT() if the pointer of DXE Services Table is NULL.
- It will always return EFI_SUCCESS.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-EFI_STATUS
-EFIAPI
-DxeHobPeCoffLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- PROTOCOL_HOB *Hob;
-
- Hob = GetFirstGuidHob (&gPeCoffLoaderProtocolGuid);
- if (Hob == NULL) {
- return EFI_NOT_FOUND;
- }
-
- gPeCoffLoader = Hob->Interface;
- return EFI_SUCCESS;
-}
-
-
diff --git a/EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoffLib.inf b/EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoffLib.inf
deleted file mode 100644
index d6eb1cf0cf..0000000000
--- a/EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoffLib.inf
+++ /dev/null
@@ -1,44 +0,0 @@
-#/** @file
-# PE/COFF Loader Library implementation that wraps a protocol passed up from
-# SEC/PEI via a HOB. This is done to save space.
-#
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-# Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = DxeHobPeCoffLib
- FILE_GUID = 671C6FD7-99FB-4EE3-B640-4B1D463BC3B5
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = PeCoffLib
- CONSTRUCTOR = DxeHobPeCoffLibConstructor
-
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM
-#
-
-[Sources.common]
- DxeHobPeCoff.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- DebugLib
- HobLib
-
-[Protocols]
- gPeCoffLoaderProtocolGuid
diff --git a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.c b/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.c
deleted file mode 100644
index 3b9f1846d3..0000000000
--- a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/** @file
- Add external EblCmd Lib
-
- 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.
-
-
-**/
-
-#include <Uefi.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/EblAddExternalCommandLib.h>
-#include <Protocol/EblAddCommand.h>
-
-STATIC BOOLEAN gInstalledCommand = FALSE;
-STATIC EFI_EVENT mEblCommandRegistration = NULL;
-
-STATIC const EBL_COMMAND_TABLE *mAddExternalCmdLibTemplate = NULL;
-STATIC UINTN mAddExternalCmdLibTemplateSize = 0;
-EBL_ADD_COMMAND_PROTOCOL *gEblExternalCommand = NULL;
-
-
-/**
- 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
- )
-{
- if (gEblExternalCommand != NULL) {
- return gEblExternalCommand->EblGetCharKey (Key, TimeoutInSec, CallBack);
- }
- return EFI_TIMEOUT;
-}
-
-
-/**
- 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
- )
-{
- if (gEblExternalCommand != NULL) {
- return gEblExternalCommand->EblAnyKeyToContinueQtoQuit (CurrentRow, PrefixNewline);
- }
- return FALSE;
-}
-
-
-
-/**
- Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is
- reinstalled.
-
- @param Event The Event that is being processed
- @param Context Event Context
-
-**/
-VOID
-EFIAPI
-EblAddCommandNotificationEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
-
- if (!gInstalledCommand) {
- Status = gBS->LocateProtocol (&gEfiEblAddCommandProtocolGuid, NULL, (VOID **)&gEblExternalCommand);
- if (!EFI_ERROR (Status)) {
- gEblExternalCommand->AddCommands (mAddExternalCmdLibTemplate, mAddExternalCmdLibTemplateSize);
- gInstalledCommand = TRUE;
- }
- }
-}
-
-
-
-/**
- The user Entry Point for the driver. The user code starts with this function
- as the real entry point for the image goes into a library that calls this
- function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-EblAddExternalCommands (
- IN const EBL_COMMAND_TABLE *EntryArray,
- IN UINTN ArrayCount
- )
-{
- if (mAddExternalCmdLibTemplate != NULL) {
- return EFI_ALREADY_STARTED;
- }
-
- mAddExternalCmdLibTemplate = EntryArray;
- mAddExternalCmdLibTemplateSize = ArrayCount;
-
- EfiCreateProtocolNotifyEvent (
- &gEfiEblAddCommandProtocolGuid,
- TPL_CALLBACK,
- EblAddCommandNotificationEvent,
- NULL,
- &mEblCommandRegistration
- );
-
- return EFI_SUCCESS;
-}
-
diff --git a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf b/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf
deleted file mode 100644
index 335386a8c8..0000000000
--- a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf
+++ /dev/null
@@ -1,47 +0,0 @@
-#/** @file
-# Component description file for the entry point to a EFIDXE Drivers
-#
-# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification
-# Copyright (c) 2007 - 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]
- INF_VERSION = 0x00010005
- BASE_NAME = EblAddExternalCommandLib
- FILE_GUID = 9195D970-C6F7-484E-8013-5B03C89C3B81
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EblAddExternalCommandLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER
-
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- EblAddExternalCommandLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- UefiLib
- EblAddExternalCommandLib
-
-[Protocols]
- gEfiEblAddCommandProtocolGuid
-
-[Guids]
diff --git a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.c b/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.c
deleted file mode 100644
index 6cde5f95ab..0000000000
--- a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- Null EblCmdLib
-
- 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.
-
-
-**/
-
-#include <PiDxe.h>
-#include <Library/EblCmdLib.h>
-
-
-VOID
-EblInitializeExternalCmd (
- VOID
- )
-{
- return;
-}
diff --git a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf b/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf
deleted file mode 100644
index c7935ae37e..0000000000
--- a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf
+++ /dev/null
@@ -1,43 +0,0 @@
-#/** @file
-# Component description file for the entry point to a EFIDXE Drivers
-#
-# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification
-# Copyright (c) 2007 - 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]
- INF_VERSION = 0x00010005
- BASE_NAME = EblCmdLibNull
- FILE_GUID = 3513C4E2-06D6-4921-9C2B-E938777BA79E
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiCmdLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER
-
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- EblCmdLibNull.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
-
-[Protocols]
-
-[Guids]
diff --git a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c b/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c
deleted file mode 100644
index 1c945cd33b..0000000000
--- a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/** @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;
-}
-
diff --git a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf b/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
deleted file mode 100644
index c9b2d31dc4..0000000000
--- a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
+++ /dev/null
@@ -1,34 +0,0 @@
-#/** @file
-#
-# 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = EblNetworkLib
- FILE_GUID = D885869A-7869-47DB-9429-DE03C318BCFD
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EblNetworkLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
-
-[sources.common]
- EblNetworkLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[Protocols]
- gEfiSimpleNetworkProtocolGuid
- gEfiPxeBaseCodeProtocolGuid
-
-[Depex]
- TRUE
diff --git a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c b/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c
deleted file mode 100644
index 4d58c83086..0000000000
--- a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c
+++ /dev/null
@@ -1,1779 +0,0 @@
-/** @file
-File IO routines inspired by Streams with an EFI flavor
-
-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.
-
-Basic support for opening files on different device types. The device string
-is in the form of DevType:Path. Current DevType is required as there is no
-current mounted device concept of current working directory concept implement
-by this library.
-
-Device names are case insensitive and only check the leading characters for
-unique matches. Thus the following are all the same:
-LoadFile0:
-l0:
-L0:
-Lo0:
-
-Supported Device Names:
-A0x1234:0x12 - A memory buffer starting at address 0x1234 for 0x12 bytes
-l1: - EFI LoadFile device one.
-B0: - EFI BlockIo zero.
-fs3: - EFI Simple File System device 3
-Fv2: - EFI Firmware VOlume device 2
-10.0.1.102: - TFTP service IP followed by the file name
-**/
-
-#include <PiDxe.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/DiskIo.h>
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/LoadFile.h>
-#include <Protocol/FirmwareVolumeBlock.h>
-
-#include <Guid/FileInfo.h>
-#include <Guid/ZeroGuid.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/PcdLib.h>
-#include <Library/EblNetworkLib.h>
-
-
-CHAR8 *gCwd = NULL;
-
-#define EFI_OPEN_FILE_GUARD_HEADER 0x4B4D4641
-#define EFI_OPEN_FILE_GUARD_FOOTER 0x444D5A56
-
-// Need to defend against this overflowing
-#define MAX_CMD_LINE 0x200
-
-typedef struct {
- UINT32 Header;
- EFI_OPEN_FILE File;
- UINT32 Footer;
-} EFI_OPEN_FILE_GUARD;
-
-
-// globals to store current open device info
-EFI_HANDLE *mBlkIo = NULL;
-UINTN mBlkIoCount = 0;
-
-EFI_HANDLE *mFs = NULL;
-UINTN mFsCount = 0;
-// mFsInfo[] array entries must match mFs[] handles
-EFI_FILE_SYSTEM_INFO **mFsInfo = NULL;
-
-EFI_HANDLE *mFv = NULL;
-UINTN mFvCount = 0;
-EFI_HANDLE *mLoadFile = NULL;
-UINTN mLoadFileCount = 0;
-
-
-
-/**
-Internal worker function to validate a File handle.
-
-@param File Open File Handle
-
-@return TRUE File is valid
-@return FALSE File is not valid
-
-
-**/
-BOOLEAN
-FileHandleValid (
- IN EFI_OPEN_FILE *File
- )
-{
- EFI_OPEN_FILE_GUARD *GuardFile;
-
- // Look right before and after file structure for the correct signatures
- GuardFile = BASE_CR (File, EFI_OPEN_FILE_GUARD, File);
- if ((GuardFile->Header != EFI_OPEN_FILE_GUARD_HEADER) ||
- (GuardFile->Footer != EFI_OPEN_FILE_GUARD_FOOTER) ) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
-Internal worker function. If Buffer is not NULL free it.
-
-@param Buffer Buffer to FreePool()
-
-**/
-VOID
-EblFreePool (
- IN VOID *Buffer
- )
-{
- if (Buffer != NULL) {
- FreePool (Buffer);
- }
-}
-
-/**
-Update Device List Global Variables
-
-**/
-VOID
-EblUpdateDeviceLists (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN Size;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- EFI_FILE_HANDLE Root;
- UINTN Index;
-
- if (mBlkIo != NULL) {
- FreePool (mBlkIo);
- }
- gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mBlkIoCount, &mBlkIo);
-
-
-
- if (mFv != NULL) {
- FreePool (mFv);
- }
- gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &mFvCount, &mFv);
-
- if (mLoadFile != NULL) {
- FreePool (mLoadFile);
- }
- gBS->LocateHandleBuffer (ByProtocol, &gEfiLoadFileProtocolGuid, NULL, &mLoadFileCount, &mLoadFile);
-
- if (mFs != NULL) {
- FreePool (mFs);
- }
-
- if (&mFsInfo[0] != NULL) {
- // Need to Free the mFsInfo prior to recalculating mFsCount so don't move this code
- for (Index = 0; Index < mFsCount; Index++) {
- if (mFsInfo[Index] != NULL) {
- FreePool (mFsInfo[Index]);
- }
- }
- FreePool (mFsInfo);
- }
-
- gBS->LocateHandleBuffer (ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &mFsCount, &mFs);
-
-
- mFsInfo = AllocateZeroPool (mFsCount * sizeof (EFI_FILE_SYSTEM_INFO *));
- if (mFsInfo == NULL) {
- // If we can't do this then we can't support file system entries
- mFsCount = 0;
- } else {
- // Loop through all the file system structures and cache the file system info data
- for (Index =0; Index < mFsCount; Index++) {
- Status = gBS->HandleProtocol (mFs[Index], &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
- if (!EFI_ERROR (Status)) {
- Status = Fs->OpenVolume (Fs, &Root);
- if (!EFI_ERROR (Status)) {
- // Get information about the volume
- Size = 0;
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, mFsInfo[Index]);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- mFsInfo[Index] = AllocatePool (Size);
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, mFsInfo[Index]);
- }
-
- Root->Close (Root);
- }
- }
- }
- }
-}
-
-
-/**
-PathName is in the form <device name>:<path> for example fs1:\ or ROOT:\.
-Return TRUE if the <devce name> prefix of PathName matches a file system
-Volume Name. MatchIndex is the array index in mFsInfo[] of the match,
-and it can be used with mFs[] to find the handle that needs to be opened
-
-@param PathName PathName to check
-@param FileStart Index of the first character of the <path>
-@param MatchIndex Index in mFsInfo[] that matches
-
-@return TRUE PathName matches a Volume Label and MatchIndex is valid
-@return FALSE PathName does not match a Volume Label MatchIndex undefined
-
-**/
-BOOLEAN
-EblMatchVolumeName (
- IN CHAR8 *PathName,
- IN UINTN FileStart,
- OUT UINTN *MatchIndex
- )
-{
- UINTN Index;
- UINTN Compare;
- UINTN VolStrLen;
- BOOLEAN Match;
-
- for (Index =0; Index < mFsCount; Index++) {
- if (mFsInfo[Index] == NULL) {
- // FsInfo is not valid so skip it
- continue;
- }
- VolStrLen = StrLen (mFsInfo[Index]->VolumeLabel);
- for (Compare = 0, Match = TRUE; Compare < (FileStart - 1); Compare++) {
- if (Compare > VolStrLen) {
- Match = FALSE;
- break;
- }
- if (PathName[Compare] != (CHAR8)mFsInfo[Index]->VolumeLabel[Compare]) {
- // If the VolumeLabel has a space allow a _ to match with it in addition to ' '
- if (!((PathName[Compare] == '_') && (mFsInfo[Index]->VolumeLabel[Compare] == L' '))) {
- Match = FALSE;
- break;
- }
- }
- }
- if (Match) {
- *MatchIndex = Index;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
-/**
-Return the number of devices of the current type active in the system
-
-@param Type Device type to check
-
-@return 0 Invalid type
-
-**/
-UINTN
-EfiGetDeviceCounts (
- IN EFI_OPEN_FILE_TYPE DeviceType
- )
-{
- switch (DeviceType) {
- case EfiOpenLoadFile:
- return mLoadFileCount;
- case EfiOpenFirmwareVolume:
- return mFvCount;
- case EfiOpenFileSystem:
- return mFsCount;
- case EfiOpenBlockIo:
- return mBlkIoCount;
- default:
- return 0;
- }
-}
-
-EFI_STATUS
-ConvertIpStringToEfiIp (
- IN CHAR8 *PathName,
- OUT EFI_IP_ADDRESS *ServerIp
- )
-{
- CHAR8 *Str;
-
- Str = PathName;
- ServerIp->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (Str);
-
- Str = AsciiStrStr (Str, ".");
- if (Str == NULL) {
- return EFI_DEVICE_ERROR;
- }
-
- ServerIp->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (++Str);
-
- Str = AsciiStrStr (Str, ".");
- if (Str == NULL) {
- return EFI_DEVICE_ERROR;
- }
-
- ServerIp->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (++Str);
-
- Str = AsciiStrStr (Str, ".");
- if (Str == NULL) {
- return EFI_DEVICE_ERROR;
- }
-
- ServerIp->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (++Str);
-
- return EFI_SUCCESS;
-}
-
-
-/**
-Internal work function to extract a device number from a string skipping
-text. Easy way to extract numbers from strings like blk7:.
-
-@param Str String to extract device number form
-
-@return -1 Device string is not valid
-@return Device #
-
-**/
-UINTN
-EblConvertDevStringToNumber (
- IN CHAR8 *Str
- )
-{
- UINTN Max;
- UINTN Index;
-
-
- // Find the first digit
- Max = AsciiStrLen (Str);
- for (Index = 0; !((*Str >= '0') && (*Str <= '9')) && (Index < Max); Index++) {
- Str++;
- }
- if (Index == Max) {
- return (UINTN)-1;
- }
-
- return AsciiStrDecimalToUintn (Str);
-}
-
-
-/**
-Internal work function to fill in EFI_OPEN_FILE information for the Fs and BlkIo
-
-@param File Open file handle
-@param FileName Name of file after device stripped off
-
-
-**/
-EFI_STATUS
-EblFileDevicePath (
- IN OUT EFI_OPEN_FILE *File,
- IN CHAR8 *FileName,
- IN CONST UINT64 OpenMode
- )
-{
- EFI_STATUS Status;
- UINTN Size;
- FILEPATH_DEVICE_PATH *FilePath;
- EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
- CHAR16 UnicodeFileName[MAX_PATHNAME];
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- EFI_FILE_HANDLE Root;
-
-
- if ( *FileName != 0 ) {
- AsciiStrToUnicodeStr (FileName, UnicodeFileName);
- } else {
- AsciiStrToUnicodeStr ("\\", UnicodeFileName);
- }
-
- Size = StrSize (UnicodeFileName);
- FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));
- if (FileDevicePath != NULL) {
- FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;
- FilePath->Header.Type = MEDIA_DEVICE_PATH;
- FilePath->Header.SubType = MEDIA_FILEPATH_DP;
- CopyMem (&FilePath->PathName, UnicodeFileName, Size);
- SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);
- SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));
-
- if (File->EfiHandle != NULL) {
- File->DevicePath = DevicePathFromHandle (File->EfiHandle);
- }
-
- File->DevicePath = AppendDevicePath (File->DevicePath, FileDevicePath);
- FreePool (FileDevicePath);
- }
-
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);
- if (!EFI_ERROR (Status)) {
- File->FsBlockIoMedia = BlkIo->Media;
- File->FsBlockIo = BlkIo;
-
- // If we are not opening the device this will get over written with file info
- File->MaxPosition = MultU64x32 (BlkIo->Media->LastBlock + 1, BlkIo->Media->BlockSize);
- }
-
- if (File->Type == EfiOpenFileSystem) {
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
- if (!EFI_ERROR (Status)) {
- Status = Fs->OpenVolume (Fs, &Root);
- if (!EFI_ERROR (Status)) {
- // Get information about the volume
- Size = 0;
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, File->FsInfo);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- File->FsInfo = AllocatePool (Size);
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, File->FsInfo);
- }
-
- // Get information about the file
- Status = Root->Open (Root, &File->FsFileHandle, UnicodeFileName, OpenMode, 0);
- if (!EFI_ERROR (Status)) {
- Size = 0;
- Status = File->FsFileHandle->GetInfo (File->FsFileHandle, &gEfiFileInfoGuid, &Size, NULL);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- File->FsFileInfo = AllocatePool (Size);
- Status = File->FsFileHandle->GetInfo (File->FsFileHandle, &gEfiFileInfoGuid, &Size, File->FsFileInfo);
- if (!EFI_ERROR (Status)) {
- File->Size = (UINTN)File->FsFileInfo->FileSize;
- File->MaxPosition = (UINT64)File->Size;
- }
- }
- }
-
- Root->Close (Root);
- }
- }
- } else if (File->Type == EfiOpenBlockIo) {
- File->Size = (UINTN)File->MaxPosition;
- }
-
- return Status;
-}
-
-#define ToUpper(a) ((((a) >= 'a') && ((a) <= 'z')) ? ((a) - 'a' + 'A') : (a))
-
-EFI_STATUS
-CompareGuidToString (
- IN EFI_GUID *Guid,
- IN CHAR8 *String
- )
-{
- CHAR8 AsciiGuid[64];
- CHAR8 *StringPtr;
- CHAR8 *GuidPtr;
-
- AsciiSPrint (AsciiGuid, sizeof(AsciiGuid), "%g", Guid);
-
- StringPtr = String;
- GuidPtr = AsciiGuid;
-
- while ((*StringPtr != '\0') && (*GuidPtr != '\0')) {
- // Skip dashes
- if (*StringPtr == '-') {
- StringPtr++;
- continue;
- }
-
- if (*GuidPtr == '-') {
- GuidPtr++;
- continue;
- }
-
- if (ToUpper(*StringPtr) != ToUpper(*GuidPtr)) {
- return EFI_NOT_FOUND;
- }
-
- StringPtr++;
- GuidPtr++;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
-Internal work function to fill in EFI_OPEN_FILE information for the FV
-
-@param File Open file handle
-@param FileName Name of file after device stripped off
-
-
-**/
-EFI_STATUS
-EblFvFileDevicePath (
- IN OUT EFI_OPEN_FILE *File,
- IN CHAR8 *FileName,
- IN CONST UINT64 OpenMode
- )
-{
- EFI_STATUS Status;
- EFI_STATUS GetNextFileStatus;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH DevicePathNode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN Key;
- UINT32 AuthenticationStatus;
- CHAR8 AsciiSection[MAX_PATHNAME];
- VOID *Section;
- UINTN SectionSize;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
- EFI_LBA Lba;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- EFI_FIRMWARE_VOLUME_HEADER *FvHeader = NULL;
- UINTN Index;
-
-
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&File->Fv);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Get FVB Info about the handle
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolumeBlockProtocolGuid, (VOID **)&Fvb);
- if (!EFI_ERROR (Status)) {
- Status = Fvb->GetPhysicalAddress (Fvb, &File->FvStart);
- if (!EFI_ERROR (Status)) {
- FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)File->FvStart;
- File->FvHeaderSize = sizeof (EFI_FIRMWARE_VOLUME_HEADER);
- for (Index = 0; FvHeader->BlockMap[Index].Length !=0; Index++) {
- File->FvHeaderSize += sizeof (EFI_FV_BLOCK_MAP_ENTRY);
- }
-
- for (Lba = 0, File->FvSize = 0, NumberOfBlocks = 0; ; File->FvSize += (BlockSize * NumberOfBlocks), Lba += NumberOfBlocks) {
- Status = Fvb->GetBlockSize (Fvb, Lba, &BlockSize, &NumberOfBlocks);
- if (EFI_ERROR (Status)) {
- break;
- }
- }
- }
- }
-
-
- DevicePath = DevicePathFromHandle (File->EfiHandle);
-
- if (*FileName == '\0') {
- File->DevicePath = DuplicateDevicePath (DevicePath);
- File->Size = File->FvSize;
- File->MaxPosition = File->Size;
- } else {
- Key = 0;
- do {
- File->FvType = EFI_FV_FILETYPE_ALL;
- GetNextFileStatus = File->Fv->GetNextFile (
- File->Fv,
- &Key,
- &File->FvType,
- &File->FvNameGuid,
- &File->FvAttributes,
- &File->Size
- );
- if (!EFI_ERROR (GetNextFileStatus)) {
- // Compare GUID first
- Status = CompareGuidToString (&File->FvNameGuid, FileName);
- if (!EFI_ERROR(Status)) {
- break;
- }
-
- Section = NULL;
- Status = File->Fv->ReadSection (
- File->Fv,
- &File->FvNameGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- &Section,
- &SectionSize,
- &AuthenticationStatus
- );
- if (!EFI_ERROR (Status)) {
- UnicodeStrToAsciiStr (Section, AsciiSection);
- if (AsciiStriCmp (FileName, AsciiSection) == 0) {
- FreePool (Section);
- break;
- }
- FreePool (Section);
- }
- }
- } while (!EFI_ERROR (GetNextFileStatus));
-
- if (EFI_ERROR (GetNextFileStatus)) {
- return GetNextFileStatus;
- }
-
- if (OpenMode != EFI_SECTION_ALL) {
- // Calculate the size of the section we are targeting
- Section = NULL;
- File->Size = 0;
- Status = File->Fv->ReadSection (
- File->Fv,
- &File->FvNameGuid,
- (EFI_SECTION_TYPE)OpenMode,
- 0,
- &Section,
- &File->Size,
- &AuthenticationStatus
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- File->MaxPosition = File->Size;
- EfiInitializeFwVolDevicepathNode (&DevicePathNode, &File->FvNameGuid);
- File->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&DevicePathNode);
- }
-
-
- // FVB not required if FV was soft loaded...
- return EFI_SUCCESS;
-}
-
-
-
-
-/**
-Open a device named by PathName. The PathName includes a device name and
-path separated by a :. See file header for more details on the PathName
-syntax. There is no checking to prevent a file from being opened more than
-one type.
-
-SectionType is only used to open an FV. Each file in an FV contains multiple
-sections and only the SectionType section is opened.
-
-For any file that is opened with EfiOpen() must be closed with EfiClose().
-
-@param PathName Path to parse to open
-@param OpenMode Same as EFI_FILE.Open()
-@param SectionType Section in FV to open.
-
-@return NULL Open failed
-@return Valid EFI_OPEN_FILE handle
-
-**/
-EFI_OPEN_FILE *
-EfiOpen (
- IN CHAR8 *PathName,
- IN CONST UINT64 OpenMode,
- IN CONST EFI_SECTION_TYPE SectionType
- )
-{
- EFI_STATUS Status;
- EFI_OPEN_FILE *File;
- EFI_OPEN_FILE FileData;
- UINTN StrLen;
- UINTN FileStart;
- UINTN DevNumber = 0;
- EFI_OPEN_FILE_GUARD *GuardFile;
- BOOLEAN VolumeNameMatch;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN Size;
- EFI_IP_ADDRESS Ip;
- CHAR8 *CwdPlusPathName;
- UINTN Index;
- EFI_SECTION_TYPE ModifiedSectionType;
-
- EblUpdateDeviceLists ();
-
- File = &FileData;
- ZeroMem (File, sizeof (EFI_OPEN_FILE));
-
- StrLen = AsciiStrSize (PathName);
- if (StrLen <= 1) {
- // Smallest valid path is 1 char and a null
- return NULL;
- }
-
- for (FileStart = 0; FileStart < StrLen; FileStart++) {
- if (PathName[FileStart] == ':') {
- FileStart++;
- break;
- }
- }
-
- //
- // Matching volume name has precedence over handle based names
- //
- VolumeNameMatch = EblMatchVolumeName (PathName, FileStart, &DevNumber);
- if (!VolumeNameMatch) {
- if (FileStart == StrLen) {
- // No Volume name or device name, so try Current Working Directory
- if (gCwd == NULL) {
- // No CWD
- return NULL;
- }
-
- // We could add a current working directory concept
- CwdPlusPathName = AllocatePool (AsciiStrSize (gCwd) + AsciiStrSize (PathName));
- if (CwdPlusPathName == NULL) {
- return NULL;
- }
-
- if ((PathName[0] == '/') || (PathName[0] == '\\')) {
- // PathName starts in / so this means we go to the root of the device in the CWD.
- CwdPlusPathName[0] = '\0';
- for (FileStart = 0; gCwd[FileStart] != '\0'; FileStart++) {
- CwdPlusPathName[FileStart] = gCwd[FileStart];
- if (gCwd[FileStart] == ':') {
- FileStart++;
- CwdPlusPathName[FileStart] = '\0';
- break;
- }
- }
- } else {
- AsciiStrCpy (CwdPlusPathName, gCwd);
- StrLen = AsciiStrLen (gCwd);
- if ((*PathName != '/') && (*PathName != '\\') && (gCwd[StrLen-1] != '/') && (gCwd[StrLen-1] != '\\')) {
- AsciiStrCat (CwdPlusPathName, "\\");
- }
- }
-
- AsciiStrCat (CwdPlusPathName, PathName);
- if (AsciiStrStr (CwdPlusPathName, ":") == NULL) {
- // Extra error check to make sure we don't recurse and blow stack
- return NULL;
- }
-
- File = EfiOpen (CwdPlusPathName, OpenMode, SectionType);
- FreePool (CwdPlusPathName);
- return File;
- }
-
- DevNumber = EblConvertDevStringToNumber ((CHAR8 *)PathName);
- }
-
- File->DeviceName = AllocatePool (StrLen);
- AsciiStrCpy (File->DeviceName, PathName);
- File->DeviceName[FileStart - 1] = '\0';
- File->FileName = &File->DeviceName[FileStart];
- if (File->FileName[0] == '\0') {
- // if it is just a file name use / as root
- File->FileName = "\\";
- }
-
- //
- // Use best match algorithm on the dev names so we only need to look at the
- // first few charters to match the full device name. Short name forms are
- // legal from the caller.
- //
- Status = EFI_SUCCESS;
- if (*PathName == 'f' || *PathName == 'F' || VolumeNameMatch) {
- if (PathName[1] == 's' || PathName[1] == 'S' || VolumeNameMatch) {
- if (DevNumber >= mFsCount) {
- goto ErrorExit;
- }
- File->Type = EfiOpenFileSystem;
- File->EfiHandle = mFs[DevNumber];
- Status = EblFileDevicePath (File, &PathName[FileStart], OpenMode);
-
- } else if (PathName[1] == 'v' || PathName[1] == 'V') {
- if (DevNumber >= mFvCount) {
- goto ErrorExit;
- }
- File->Type = EfiOpenFirmwareVolume;
- File->EfiHandle = mFv[DevNumber];
-
- if ((PathName[FileStart] == '/') || (PathName[FileStart] == '\\')) {
- // Skip leading / as its not really needed for the FV since no directories are supported
- FileStart++;
- }
-
- // Check for 2nd :
- ModifiedSectionType = SectionType;
- for (Index = FileStart; PathName[Index] != '\0'; Index++) {
- if (PathName[Index] == ':') {
- // Support fv0:\DxeCore:0x10
- // This means open the PE32 Section of the file
- ModifiedSectionType = (EFI_SECTION_TYPE)AsciiStrHexToUintn (&PathName[Index + 1]);
- PathName[Index] = '\0';
- }
- }
- File->FvSectionType = ModifiedSectionType;
- Status = EblFvFileDevicePath (File, &PathName[FileStart], ModifiedSectionType);
- }
- } else if ((*PathName == 'A') || (*PathName == 'a')) {
- // Handle a:0x10000000:0x1234 address form a:ADDRESS:SIZE
- File->Type = EfiOpenMemoryBuffer;
- // 1st colon is at PathName[FileStart - 1]
- File->Buffer = (VOID *)AsciiStrHexToUintn (&PathName[FileStart]);
-
- // Find 2nd colon
- while ((PathName[FileStart] != ':') && (PathName[FileStart] != '\0')) {
- FileStart++;
- }
-
- // If we ran out of string, there's no extra data
- if (PathName[FileStart] == '\0') {
- File->Size = 0;
- } else {
- File->Size = AsciiStrHexToUintn (&PathName[FileStart + 1]);
- }
-
- // if there's no number after the second colon, default
- // the end of memory
- if (File->Size == 0) {
- File->Size = (UINTN)(0 - (UINTN)File->Buffer);
- }
-
- File->MaxPosition = File->Size;
- File->BaseOffset = (UINTN)File->Buffer;
-
- } else if (*PathName== 'l' || *PathName == 'L') {
- if (DevNumber >= mLoadFileCount) {
- goto ErrorExit;
- }
- File->Type = EfiOpenLoadFile;
- File->EfiHandle = mLoadFile[DevNumber];
-
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiLoadFileProtocolGuid, (VOID **)&File->LoadFile);
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
-
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
- File->DevicePath = DuplicateDevicePath (DevicePath);
-
- } else if (*PathName == 'b' || *PathName == 'B') {
- // Handle b#:0x10000000:0x1234 address form b#:ADDRESS:SIZE
- if (DevNumber >= mBlkIoCount) {
- goto ErrorExit;
- }
- File->Type = EfiOpenBlockIo;
- File->EfiHandle = mBlkIo[DevNumber];
- EblFileDevicePath (File, "", OpenMode);
-
- // 1st colon is at PathName[FileStart - 1]
- File->DiskOffset = AsciiStrHexToUintn (&PathName[FileStart]);
-
- // Find 2nd colon
- while ((PathName[FileStart] != ':') && (PathName[FileStart] != '\0')) {
- FileStart++;
- }
-
- // If we ran out of string, there's no extra data
- if (PathName[FileStart] == '\0') {
- Size = 0;
- } else {
- Size = AsciiStrHexToUintn (&PathName[FileStart + 1]);
- }
-
- // if a zero size is passed in (or the size is left out entirely),
- // go to the end of the device.
- if (Size == 0) {
- File->Size = File->Size - File->DiskOffset;
- } else {
- File->Size = Size;
- }
-
- File->MaxPosition = File->Size;
- File->BaseOffset = File->DiskOffset;
- } else if ((*PathName) >= '0' && (*PathName <= '9')) {
-
- // Get current IP address
- Status = EblGetCurrentIpAddress (&Ip);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Device IP Address is not configured.\n");
- goto ErrorExit;
- }
-
-
- // Parse X.X.X.X:Filename, only support IPv4 TFTP for now...
- File->Type = EfiOpenTftp;
- File->IsDirty = FALSE;
- File->IsBufferValid = FALSE;
-
- Status = ConvertIpStringToEfiIp (PathName, &File->ServerIp);
- }
-
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
-
- GuardFile = (EFI_OPEN_FILE_GUARD *)AllocateZeroPool (sizeof (EFI_OPEN_FILE_GUARD));
- if (GuardFile == NULL) {
- goto ErrorExit;
- }
-
- GuardFile->Header = EFI_OPEN_FILE_GUARD_HEADER;
- CopyMem (&(GuardFile->File), &FileData, sizeof (EFI_OPEN_FILE));
- GuardFile->Footer = EFI_OPEN_FILE_GUARD_FOOTER;
-
- return &(GuardFile->File);
-
-ErrorExit:
- FreePool (File->DeviceName);
- return NULL;
-}
-
-#define FILE_COPY_CHUNK 0x01000000
-
-EFI_STATUS
-EfiCopyFile (
- IN CHAR8 *DestinationFile,
- IN CHAR8 *SourceFile
- )
-{
- EFI_OPEN_FILE *Source = NULL;
- EFI_OPEN_FILE *Destination = NULL;
- EFI_STATUS Status = EFI_SUCCESS;
- VOID *Buffer = NULL;
- UINTN Size;
- UINTN Offset;
- UINTN Chunk = FILE_COPY_CHUNK;
-
- Source = EfiOpen (SourceFile, EFI_FILE_MODE_READ, 0);
- if (Source == NULL) {
- AsciiPrint("Source file open error.\n");
- Status = EFI_NOT_FOUND;
- goto Exit;
- }
-
- Destination = EfiOpen (DestinationFile, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
- if (Destination == NULL) {
- AsciiPrint("Destination file open error.\n");
- Status = EFI_NOT_FOUND;
- goto Exit;
- }
-
- Buffer = AllocatePool(FILE_COPY_CHUNK);
- if (Buffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
-
- Size = EfiTell(Source, NULL);
-
- for (Offset = 0; Offset + FILE_COPY_CHUNK <= Size; Offset += Chunk) {
- Chunk = FILE_COPY_CHUNK;
-
- Status = EfiRead(Source, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Read file error %r\n", Status);
- goto Exit;
- }
-
- Status = EfiWrite(Destination, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Write file error %r\n", Status);
- goto Exit;
- }
- }
-
- // Any left over?
- if (Offset < Size) {
- Chunk = Size - Offset;
-
- Status = EfiRead(Source, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Read file error\n");
- goto Exit;
- }
-
- Status = EfiWrite(Destination, Buffer, &Chunk);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Write file error\n");
- goto Exit;
- }
- }
-
-Exit:
- if (Source != NULL) {
- Status = EfiClose(Source);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Source close error");
- }
- }
-
- if (Destination != NULL) {
- Status = EfiClose(Destination);
- if (EFI_ERROR(Status)) {
- AsciiPrint("Destination close error");
- }
- }
-
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
-
- return Status;
-}
-
-/**
-Use DeviceType and Index to form a valid PathName and try and open it.
-
-@param DeviceType Device type to open
-@param Index Device Index to use. Zero relative.
-
-@return NULL Open failed
-@return Valid EFI_OPEN_FILE handle
-
-**/
-EFI_OPEN_FILE *
-EfiDeviceOpenByType (
- IN EFI_OPEN_FILE_TYPE DeviceType,
- IN UINTN Index
- )
-{
- CHAR8 *DevStr;
- CHAR8 Path[MAX_CMD_LINE];
-
- switch (DeviceType) {
- case EfiOpenLoadFile:
- DevStr = "loadfile%d:";
- break;
- case EfiOpenFirmwareVolume:
- DevStr = "fv%d:";
- break;
- case EfiOpenFileSystem:
- DevStr = "fs%d:";
- break;
- case EfiOpenBlockIo:
- DevStr = "blk%d:";
- break;
- case EfiOpenMemoryBuffer:
- DevStr = "a%d:";
- break;
- default:
- return NULL;
- }
-
- AsciiSPrint (Path, MAX_PATHNAME, DevStr, Index);
-
- return EfiOpen (Path, EFI_FILE_MODE_READ, 0);
-}
-
-
-/**
-Close a file handle opened by EfiOpen() and free all resources allocated by
-EfiOpen().
-
-@param Stream Open File Handle
-
-@return EFI_INVALID_PARAMETER Stream is not an Open File
-@return EFI_SUCCESS Steam closed
-
-**/
-EFI_STATUS
-EfiClose (
- IN EFI_OPEN_FILE *File
- )
-{
- EFI_STATUS Status;
- UINT64 TftpBufferSize;
-
- if (!FileHandleValid (File)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //Write the buffer contents to TFTP file.
- if ((File->Type == EfiOpenTftp) && (File->IsDirty)) {
-
- TftpBufferSize = File->Size;
- Status = EblMtftp (
- EFI_PXE_BASE_CODE_TFTP_WRITE_FILE,
- File->Buffer,
- TRUE,
- &TftpBufferSize,
- NULL,
- &File->ServerIp,
- (UINT8 *)File->FileName,
- NULL,
- FALSE
- );
- if (EFI_ERROR(Status)) {
- AsciiPrint("TFTP error during APPLE_NSP_TFTP_WRITE_FILE: %r\n", Status);
- return Status;
- }
- }
-
- if ((File->Type == EfiOpenLoadFile) ||
- ((File->Type == EfiOpenTftp) && (File->IsBufferValid == TRUE)) ||
- ((File->Type == EfiOpenFirmwareVolume) && (File->IsBufferValid == TRUE))) {
- EblFreePool(File->Buffer);
- }
-
- EblFreePool (File->DevicePath);
- EblFreePool (File->DeviceName);
- EblFreePool (File->FsFileInfo);
- EblFreePool (File->FsInfo);
-
- if (File->FsFileHandle != NULL) {
- File->FsFileHandle->Close (File->FsFileHandle);
- }
-
- // Need to free File and it's Guard structures
- EblFreePool (BASE_CR (File, EFI_OPEN_FILE_GUARD, File));
- return EFI_SUCCESS;
-}
-
-
-/**
-Return the size of the file represented by Stream. Also return the current
-Seek position. Opening a file will enable a valid file size to be returned.
-LoadFile is an exception as a load file size is set to zero.
-
-@param Stream Open File Handle
-
-@return 0 Stream is not an Open File or a valid LoadFile handle
-
-**/
-UINTN
-EfiTell (
- IN EFI_OPEN_FILE *File,
- OUT EFI_LBA *CurrentPosition OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINT64 BufferSize = 0;
-
- if (!FileHandleValid (File)) {
- return 0;
- }
-
- if (CurrentPosition != NULL) {
- *CurrentPosition = File->CurrentPosition;
- }
-
- if (File->Type == EfiOpenLoadFile) {
- // Figure out the File->Size
- File->Buffer = NULL;
- File->Size = 0;
- Status = File->LoadFile->LoadFile (File->LoadFile, File->DevicePath, FALSE, &File->Size, File->Buffer);
- if (Status != EFI_BUFFER_TOO_SMALL) {
- return 0;
- }
-
- File->MaxPosition = (UINT64)File->Size;
- } else if (File->Type == EfiOpenTftp) {
-
- Status = EblMtftp (
- EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,
- NULL,
- FALSE,
- &BufferSize,
- NULL,
- &File->ServerIp,
- (UINT8 *)File->FileName,
- NULL,
- TRUE
- );
- if (EFI_ERROR(Status)) {
- AsciiPrint("TFTP error during APPLE_NSP_TFTP_GET_FILE_SIZE: %r\n", Status);
- return 0;
- }
-
- File->Size = (UINTN)BufferSize;
- File->MaxPosition = File->Size;
- }
-
- return File->Size;
-}
-
-
-/**
-Seek to the Offset location in the file. LoadFile and FV device types do
-not support EfiSeek(). It is not possible to grow the file size using
-EfiSeek().
-
-SeekType defines how use Offset to calculate the new file position:
-EfiSeekStart : Position = Offset
-EfiSeekCurrent: Position is Offset bytes from the current position
-EfiSeekEnd : Only supported if Offset is zero to seek to end of file.
-
-@param Stream Open File Handle
-@param Offset Offset to seek too.
-@param SeekType Type of seek to perform
-
-
-@return EFI_INVALID_PARAMETER Stream is not an Open File
-@return EFI_UNSUPPORTED LoadFile and FV do not support Seek
-@return EFI_NOT_FOUND Seek past the end of the file.
-@return EFI_SUCCESS Steam closed
-
-**/
-EFI_STATUS
-EfiSeek (
- IN EFI_OPEN_FILE *File,
- IN EFI_LBA Offset,
- IN EFI_SEEK_TYPE SeekType
- )
-{
- EFI_STATUS Status;
- UINT64 CurrentPosition;
-
- if (!FileHandleValid (File)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (File->Type == EfiOpenLoadFile) {
- // LoadFile does not support Seek
- return EFI_UNSUPPORTED;
- }
-
- CurrentPosition = File->CurrentPosition;
- switch (SeekType) {
- case EfiSeekStart:
- if (Offset > File->MaxPosition) {
- return EFI_NOT_FOUND;
- }
- CurrentPosition = Offset;
- break;
-
- case EfiSeekCurrent:
- if ((File->CurrentPosition + Offset) > File->MaxPosition) {
- return EFI_NOT_FOUND;
- }
- CurrentPosition += Offset;
- break;
-
- case EfiSeekEnd:
- if (Offset != 0) {
- // We don't support growing file size via seeking past end of file
- return EFI_UNSUPPORTED;
- }
- CurrentPosition = File->MaxPosition;
- break;
-
- default:
- return EFI_NOT_FOUND;
- }
-
- Status = EFI_SUCCESS;
- if (File->FsFileHandle != NULL) {
- Status = File->FsFileHandle->SetPosition (File->FsFileHandle, CurrentPosition);
- }
-
- if (!EFI_ERROR (Status)) {
- File->CurrentPosition = CurrentPosition;
- }
-
- return Status;
-}
-
-EFI_STATUS
-CacheTftpFile (
- IN OUT EFI_OPEN_FILE *File
- )
-{
- EFI_STATUS Status;
- UINT64 TftpBufferSize;
-
- if (File->IsBufferValid) {
- return EFI_SUCCESS;
- }
-
- // Make sure the file size is set.
- EfiTell (File, NULL);
-
- //Allocate a buffer to hold the whole file.
- File->Buffer = AllocatePool(File->Size);
- if (File->Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- TftpBufferSize = File->Size;
-
- Status = EblMtftp (
- EFI_PXE_BASE_CODE_TFTP_READ_FILE,
- File->Buffer,
- FALSE,
- &TftpBufferSize,
- NULL,
- &File->ServerIp,
- (UINT8 *)File->FileName,
- NULL,
- FALSE);
- if (EFI_ERROR(Status)) {
- AsciiPrint("TFTP error during APPLE_NSP_TFTP_READ_FILE: %r\n", Status);
- FreePool(File->Buffer);
- return Status;
- }
-
- // Set the buffer valid flag.
- File->IsBufferValid = TRUE;
-
- return Status;
-}
-
-/**
-Read BufferSize bytes from the current location in the file. For load file,
-FV, and TFTP case you must read the entire file.
-
-@param Stream Open File Handle
-@param Buffer Caller allocated buffer.
-@param BufferSize Size of buffer in bytes.
-
-
-@return EFI_SUCCESS Stream is not an Open File
-@return EFI_END_OF_FILE Tried to read past the end of the file
-@return EFI_INVALID_PARAMETER Stream is not an open file handle
-@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read
-@return "other" Error returned from device read
-
-**/
-EFI_STATUS
-EfiRead (
- IN EFI_OPEN_FILE *File,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
- )
-{
- EFI_STATUS Status;
- UINT32 AuthenticationStatus;
- EFI_DISK_IO_PROTOCOL *DiskIo;
-
- if (!FileHandleValid (File)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Don't read past the end of the file.
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {
- return EFI_END_OF_FILE;
- }
-
- switch (File->Type) {
- case EfiOpenLoadFile:
- // Figure out the File->Size
- EfiTell (File, NULL);
-
- Status = File->LoadFile->LoadFile (File->LoadFile, File->DevicePath, FALSE, BufferSize, Buffer);
- break;
-
- case EfiOpenFirmwareVolume:
- if (CompareGuid (&File->FvNameGuid, &gZeroGuid)) {
- // This is the entire FV device, so treat like a memory buffer
- CopyMem (Buffer, (VOID *)(UINTN)(File->FvStart + File->CurrentPosition), *BufferSize);
- File->CurrentPosition += *BufferSize;
- Status = EFI_SUCCESS;
- } else {
- if (File->Buffer == NULL) {
- if (File->FvSectionType == EFI_SECTION_ALL) {
- Status = File->Fv->ReadFile (
- File->Fv,
- &File->FvNameGuid,
- (VOID **)&File->Buffer,
- &File->Size,
- &File->FvType,
- &File->FvAttributes,
- &AuthenticationStatus
- );
- } else {
- Status = File->Fv->ReadSection (
- File->Fv,
- &File->FvNameGuid,
- File->FvSectionType,
- 0,
- (VOID **)&File->Buffer,
- &File->Size,
- &AuthenticationStatus
- );
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
- File->IsBufferValid = TRUE;
- }
- // Operate on the cached buffer so Seek will work
- CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize);
- File->CurrentPosition += *BufferSize;
- Status = EFI_SUCCESS;
- }
- break;
-
- case EfiOpenMemoryBuffer:
- CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize);
- File->CurrentPosition += *BufferSize;
- Status = EFI_SUCCESS;
- break;
-
- case EfiOpenFileSystem:
- Status = File->FsFileHandle->Read (File->FsFileHandle, BufferSize, Buffer);
- File->CurrentPosition += *BufferSize;
- break;
-
- case EfiOpenBlockIo:
- Status = gBS->HandleProtocol(File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);
- if (!EFI_ERROR(Status)) {
- Status = DiskIo->ReadDisk(DiskIo, File->FsBlockIoMedia->MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);
- }
- File->CurrentPosition += *BufferSize;
- break;
-
- case EfiOpenTftp:
- // Cache the file if it hasn't been cached yet.
- if (File->IsBufferValid == FALSE) {
- Status = CacheTftpFile (File);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- // Copy out the requested data
- CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize);
- File->CurrentPosition += *BufferSize;
-
- Status = EFI_SUCCESS;
- break;
-
- default:
- return EFI_INVALID_PARAMETER;
- };
-
- return Status;
-}
-
-
-/**
-Read the entire file into a buffer. This routine allocates the buffer and
-returns it to the user full of the read data.
-
-This is very useful for load file where it's hard to know how big the buffer
-must be.
-
-@param Stream Open File Handle
-@param Buffer Pointer to buffer to return.
-@param BufferSize Pointer to Size of buffer return..
-
-
-@return EFI_SUCCESS Stream is not an Open File
-@return EFI_END_OF_FILE Tried to read past the end of the file
-@return EFI_INVALID_PARAMETER Stream is not an open file handle
-@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read
-@return "other" Error returned from device read
-
-**/
-EFI_STATUS
-EfiReadAllocatePool (
- IN EFI_OPEN_FILE *File,
- OUT VOID **Buffer,
- OUT UINTN *BufferSize
- )
-{
- if (!FileHandleValid (File)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Loadfile defers file size determination on Open so use tell to find it
- EfiTell (File, NULL);
-
- *BufferSize = File->Size;
- *Buffer = AllocatePool (*BufferSize);
- if (*Buffer == NULL) {
- return EFI_NOT_FOUND;
- }
-
- return EfiRead (File, *Buffer, BufferSize);
-}
-
-
-/**
-Write data back to the file. For TFTP case you must write the entire file.
-
-@param Stream Open File Handle
-@param Buffer Pointer to buffer to return.
-@param BufferSize Pointer to Size of buffer return..
-
-
-@return EFI_SUCCESS Stream is not an Open File
-@return EFI_END_OF_FILE Tried to read past the end of the file
-@return EFI_INVALID_PARAMETER Stream is not an open file handle
-@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read
-@return "other" Error returned from device write
-
-**/
-EFI_STATUS
-EfiWrite (
- IN EFI_OPEN_FILE *File,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
- )
-{
- EFI_STATUS Status;
- EFI_FV_WRITE_FILE_DATA FileData;
- EFI_DISK_IO_PROTOCOL *DiskIo;
-
- if (!FileHandleValid (File)) {
- return EFI_INVALID_PARAMETER;
- }
-
- switch (File->Type) {
- case EfiOpenMemoryBuffer:
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {
- return EFI_END_OF_FILE;
- }
-
- CopyMem (File->Buffer + File->CurrentPosition, Buffer, *BufferSize);
- File->CurrentPosition += *BufferSize;
- Status = EFI_SUCCESS;
-
- case EfiOpenLoadFile:
- // LoadFile device is read only be definition
- Status = EFI_UNSUPPORTED;
-
- case EfiOpenFirmwareVolume:
- if (File->FvSectionType != EFI_SECTION_ALL) {
- // Writes not support to a specific section. You have to update entire file
- return EFI_UNSUPPORTED;
- }
-
- FileData.NameGuid = &(File->FvNameGuid);
- FileData.Type = File->FvType;
- FileData.FileAttributes = File->FvAttributes;
- FileData.Buffer = Buffer;
- FileData.BufferSize = (UINT32)*BufferSize;
- Status = File->Fv->WriteFile (File->Fv, 1, EFI_FV_UNRELIABLE_WRITE, &FileData);
- break;
-
- case EfiOpenFileSystem:
- Status = File->FsFileHandle->Write (File->FsFileHandle, BufferSize, Buffer);
- File->CurrentPosition += *BufferSize;
- break;
-
- case EfiOpenBlockIo:
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {
- return EFI_END_OF_FILE;
- }
-
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);
- if (!EFI_ERROR(Status)) {
- Status = DiskIo->WriteDisk (DiskIo, File->FsBlockIoMedia->MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);
- }
- File->CurrentPosition += *BufferSize;
- break;
-
- case EfiOpenTftp:
- // Cache the file if it hasn't been cached yet.
- if (File->IsBufferValid == FALSE) {
- Status = CacheTftpFile(File);
- if (EFI_ERROR(Status)) {
- return Status;
- }
- }
-
- // Don't overwrite the buffer
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {
- UINT8 *TempBuffer;
-
- TempBuffer = File->Buffer;
-
- File->Buffer = AllocatePool ((UINTN)(File->CurrentPosition + *BufferSize));
- if (File->Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- CopyMem (File->Buffer, TempBuffer, File->Size);
-
- FreePool (TempBuffer);
-
- File->Size = (UINTN)(File->CurrentPosition + *BufferSize);
- File->MaxPosition = (UINT64)File->Size;
- }
-
- // Copy in the requested data
- CopyMem (File->Buffer + File->CurrentPosition, Buffer, *BufferSize);
- File->CurrentPosition += *BufferSize;
-
- // Mark the file dirty
- File->IsDirty = TRUE;
-
- Status = EFI_SUCCESS;
- break;
-
- default:
- Status = EFI_INVALID_PARAMETER;
- };
-
- return Status;
-}
-
-
-/**
-Given Cwd expand Path to remove .. and replace them with real
-directory names.
-
-@param Cwd Current Working Directory
-@param Path Path to expand
-
-@return NULL Cwd or Path are not valid
-@return 'other' Path with .. expanded
-
-**/
-CHAR8 *
-ExpandPath (
- IN CHAR8 *Cwd,
- IN CHAR8 *Path
- )
-{
- CHAR8 *NewPath;
- CHAR8 *Work, *Start, *End;
- UINTN StrLen;
- INTN i;
-
- if (Cwd == NULL || Path == NULL) {
- return NULL;
- }
-
- StrLen = AsciiStrSize (Cwd);
- if (StrLen <= 2) {
- // Smallest valid path is 1 char and a null
- return NULL;
- }
-
- StrLen = AsciiStrSize (Path);
- NewPath = AllocatePool (AsciiStrSize (Cwd) + StrLen + 1);
- if (NewPath == NULL) {
- return NULL;
- }
- AsciiStrCpy (NewPath, Cwd);
-
- End = Path + StrLen;
- for (Start = Path ;;) {
- Work = AsciiStrStr (Start, "..") ;
- if (Work == NULL) {
- // Remaining part of Path contains no more ..
- break;
- }
-
- // append path prior to ..
- AsciiStrnCat (NewPath, Start, Work - Start);
- StrLen = AsciiStrLen (NewPath);
- for (i = StrLen; i >= 0; i--) {
- if (NewPath[i] == ':') {
- // too many ..
- return NULL;
- }
- if (NewPath[i] == '/' || NewPath[i] == '\\') {
- if ((i > 0) && (NewPath[i-1] == ':')) {
- // leave the / before a :
- NewPath[i+1] = '\0';
- } else {
- // replace / will Null to remove trailing file/dir reference
- NewPath[i] = '\0';
- }
- break;
- }
- }
-
- Start = Work + 3;
- }
-
- // Handle the path that remains after the ..
- AsciiStrnCat (NewPath, Start, End - Start);
-
- return NewPath;
-}
-
-
-/**
-Set the Current Working Directory (CWD). If a call is made to EfiOpen () and
-the path does not contain a device name, The CWD is prepended to the path.
-
-@param Cwd Current Working Directory to set
-
-
-@return EFI_SUCCESS CWD is set
-@return EFI_INVALID_PARAMETER Cwd is not a valid device:path
-
-**/
-EFI_STATUS
-EfiSetCwd (
- IN CHAR8 *Cwd
- )
-{
- EFI_OPEN_FILE *File;
- UINTN Len;
- CHAR8 *Path;
-
- if (Cwd == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (AsciiStrCmp (Cwd, ".") == 0) {
- // cd . is a no-op
- return EFI_SUCCESS;
- }
-
- Path = Cwd;
- if (AsciiStrStr (Cwd, "..") != NULL) {
- if (gCwd == NULL) {
- // no parent
- return EFI_SUCCESS;
- }
-
- Len = AsciiStrLen (gCwd);
- if ((gCwd[Len-2] == ':') && ((gCwd[Len-1] == '/') || (gCwd[Len-1] == '\\'))) {
- // parent is device so nothing to do
- return EFI_SUCCESS;
- }
-
- // Expand .. in Cwd, given we know current working directory
- Path = ExpandPath (gCwd, Cwd);
- if (Path == NULL) {
- return EFI_NOT_FOUND;
- }
- }
-
- File = EfiOpen (Path, EFI_FILE_MODE_READ, 0);
- if (File == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (gCwd != NULL) {
- FreePool (gCwd);
- }
-
- // Use the info returned from EfiOpen as it can add in CWD if needed. So Cwd could be
- // relative to the current gCwd or not.
- gCwd = AllocatePool (AsciiStrSize (File->DeviceName) + AsciiStrSize (File->FileName) + 10);
- if (gCwd == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- AsciiStrCpy (gCwd, File->DeviceName);
- if (File->FileName == NULL) {
- AsciiStrCat (gCwd, ":\\");
- } else {
- AsciiStrCat (gCwd, ":");
- AsciiStrCat (gCwd, File->FileName);
- }
-
-
- EfiClose (File);
- if (Path != Cwd) {
- FreePool (Path);
- }
- return EFI_SUCCESS;
-}
-
-
-/**
-Set the Current Working Directory (CWD). If a call is made to EfiOpen () and
-the path does not contain a device name, The CWD is prepended to the path.
-The CWD buffer is only valid until a new call is made to EfiSetCwd(). After
-a call to EfiSetCwd() it is not legal to use the pointer returned by
-this function.
-
-@param Cwd Current Working Directory
-
-
-@return "" No CWD set
-@return 'other' Returns buffer that contains CWD.
-
-**/
-CHAR8 *
-EfiGetCwd (
- VOID
- )
-{
- if (gCwd == NULL) {
- return "";
- }
- return gCwd;
-}
-
-
diff --git a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf b/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
deleted file mode 100644
index b8cb255268..0000000000
--- a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf
+++ /dev/null
@@ -1,64 +0,0 @@
-#/** @file
-# Component description file for the entry point to a EFIDXE Drivers
-#
-# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification
-# Copyright (c) 2007 - 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]
- INF_VERSION = 0x00010005
- BASE_NAME = EfiFileLib
- FILE_GUID = d8c640db-73ba-48f5-a7ed-8e93c6012491
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiFileLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER
-
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- EfiFileLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- BaseLib
- MemoryAllocationLib
- DevicePathLib
- PrintLib
- BaseMemoryLib
- UefiLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- DebugLib
- EblNetworkLib
-
-[Protocols]
- gEfiBlockIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiDiskIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiSimpleFileSystemProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiLoadFileProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
-
-[Guids]
- gEfiFileInfoGuid
- gEfiFileSystemInfoGuid
- gZeroGuid
diff --git a/EmbeddedPkg/Library/FdtLib/FdtLib.inf b/EmbeddedPkg/Library/FdtLib/FdtLib.inf
deleted file mode 100644
index f3da231143..0000000000
--- a/EmbeddedPkg/Library/FdtLib/FdtLib.inf
+++ /dev/null
@@ -1,38 +0,0 @@
-#/* @file
-# Copyright (c) 2011-2014, 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.
-#
-#*/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = FdtLib
- FILE_GUID = 6b2478c0-be23-11e0-a28c-0002a5d5c51b
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = FdtLib
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = ARM AARCH64
-#
-
-[Sources]
- fdt_ro.c
- fdt_rw.c
- fdt_strerror.c
- fdt_sw.c
- fdt_wip.c
- fdt.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
diff --git a/EmbeddedPkg/Library/FdtLib/Makefile.libfdt b/EmbeddedPkg/Library/FdtLib/Makefile.libfdt
deleted file mode 100644
index 91126c000a..0000000000
--- a/EmbeddedPkg/Library/FdtLib/Makefile.libfdt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Makefile.libfdt
-#
-# This is not a complete Makefile of itself. Instead, it is designed to
-# be easily embeddable into other systems of Makefiles.
-#
-LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1
-LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h
-LIBFDT_VERSION = version.lds
-LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c
-LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
diff --git a/EmbeddedPkg/Library/FdtLib/README.txt b/EmbeddedPkg/Library/FdtLib/README.txt
deleted file mode 100755
index fb4010539f..0000000000
--- a/EmbeddedPkg/Library/FdtLib/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-See: https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=EmbeddedPkg/Fdt \ No newline at end of file
diff --git a/EmbeddedPkg/Library/FdtLib/TODO b/EmbeddedPkg/Library/FdtLib/TODO
deleted file mode 100644
index 288437e394..0000000000
--- a/EmbeddedPkg/Library/FdtLib/TODO
+++ /dev/null
@@ -1,3 +0,0 @@
-- Tree traversal functions
-- Graft function
-- Complete libfdt.h documenting comments
diff --git a/EmbeddedPkg/Library/FdtLib/fdt.c b/EmbeddedPkg/Library/FdtLib/fdt.c
deleted file mode 100644
index 963952820b..0000000000
--- a/EmbeddedPkg/Library/FdtLib/fdt.c
+++ /dev/null
@@ -1,250 +0,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 fdt32_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;
-}
-
-int fdt_first_subnode(const void *fdt, int offset)
-{
- int depth = 0;
-
- offset = fdt_next_node(fdt, offset, &depth);
- if (offset < 0 || depth != 1)
- return -FDT_ERR_NOTFOUND;
-
- return offset;
-}
-
-int fdt_next_subnode(const void *fdt, int offset)
-{
- int depth = 1;
-
- /*
- * With respect to the parent, the depth of the next subnode will be
- * the same as the last.
- */
- do {
- offset = fdt_next_node(fdt, offset, &depth);
- if (offset < 0 || depth < 1)
- return -FDT_ERR_NOTFOUND;
- } while (depth > 1);
-
- 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;
-}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c b/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c
deleted file mode 100644
index f00a8991d4..0000000000
--- a/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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);
-}
-
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_ro.c b/EmbeddedPkg/Library/FdtLib/fdt_ro.c
deleted file mode 100644
index 2055891e71..0000000000
--- a/EmbeddedPkg/Library/FdtLib/fdt_ro.c
+++ /dev/null
@@ -1,574 +0,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_nodename_eq(const void *fdt, int offset,
- const char *s, int len)
-{
- const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
-
- if (! p)
- /* short match */
- return 0;
-
- if (memcmp(p, s, len) != 0)
- return 0;
-
- if (p[len] == '\0')
- return 1;
- else if (!memchr(s, '@', len) && (p[len] == '@'))
- return 1;
- else
- return 0;
-}
-
-const char *fdt_string(const void *fdt, int stroffset)
-{
- return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
-}
-
-static int _fdt_string_eq(const void *fdt, int stroffset,
- const char *s, int len)
-{
- const char *p = fdt_string(fdt, stroffset);
-
- return (strlen(p) == len) && (memcmp(p, s, len) == 0);
-}
-
-int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
-{
- FDT_CHECK_HEADER(fdt);
- *address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);
- *size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);
- return 0;
-}
-
-int fdt_num_mem_rsv(const void *fdt)
-{
- int i = 0;
-
- while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->size) != 0)
- i++;
- return i;
-}
-
-static int _nextprop(const void *fdt, int offset)
-{
- uint32_t tag;
- int nextoffset;
-
- do {
- tag = fdt_next_tag(fdt, offset, &nextoffset);
-
- switch (tag) {
- case FDT_END:
- if (nextoffset >= 0)
- return -FDT_ERR_BADSTRUCTURE;
- else
- return nextoffset;
-
- case FDT_PROP:
- return offset;
- }
- offset = nextoffset;
- } while (tag == FDT_NOP);
-
- return -FDT_ERR_NOTFOUND;
-}
-
-int fdt_subnode_offset_namelen(const void *fdt, int offset,
- const char *name, int namelen)
-{
- int depth;
-
- FDT_CHECK_HEADER(fdt);
-
- for (depth = 0;
- (offset >= 0) && (depth >= 0);
- offset = fdt_next_node(fdt, offset, &depth))
- if ((depth == 1)
- && _fdt_nodename_eq(fdt, offset, name, namelen))
- return offset;
-
- if (depth < 0)
- return -FDT_ERR_NOTFOUND;
- return offset; /* error */
-}
-
-int fdt_subnode_offset(const void *fdt, int parentoffset,
- const char *name)
-{
- return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name));
-}
-
-int fdt_path_offset(const void *fdt, const char *path)
-{
- const char *end = path + strlen(path);
- const char *p = path;
- int offset = 0;
-
- FDT_CHECK_HEADER(fdt);
-
- /* see if we have an alias */
- if (*path != '/') {
- const char *q = strchr(path, '/');
-
- if (!q)
- q = end;
-
- p = fdt_get_alias_namelen(fdt, p, q - p);
- if (!p)
- return -FDT_ERR_BADPATH;
- offset = fdt_path_offset(fdt, p);
-
- p = q;
- }
-
- while (*p) {
- const char *q;
-
- while (*p == '/')
- p++;
- if (! *p)
- return offset;
- q = strchr(p, '/');
- if (! q)
- q = end;
-
- offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
- if (offset < 0)
- return offset;
-
- p = q;
- }
-
- return offset;
-}
-
-const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
-{
- const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset);
- int err;
-
- if (((err = fdt_check_header(fdt)) != 0)
- || ((err = _fdt_check_node_offset(fdt, nodeoffset)) < 0))
- goto fail;
-
- if (len)
- *len = strlen(nh->name);
-
- return nh->name;
-
- fail:
- if (len)
- *len = err;
- return NULL;
-}
-
-int fdt_first_property_offset(const void *fdt, int nodeoffset)
-{
- int offset;
-
- if ((offset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
- return offset;
-
- return _nextprop(fdt, offset);
-}
-
-int fdt_next_property_offset(const void *fdt, int offset)
-{
- if ((offset = _fdt_check_prop_offset(fdt, offset)) < 0)
- return offset;
-
- return _nextprop(fdt, offset);
-}
-
-const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
- int offset,
- int *lenp)
-{
- int err;
- const struct fdt_property *prop;
-
- if ((err = _fdt_check_prop_offset(fdt, offset)) < 0) {
- if (lenp)
- *lenp = err;
- return NULL;
- }
-
- prop = _fdt_offset_ptr(fdt, offset);
-
- if (lenp)
- *lenp = fdt32_to_cpu(prop->len);
-
- return prop;
-}
-
-const struct fdt_property *fdt_get_property_namelen(const void *fdt,
- int offset,
- const char *name,
- int namelen, int *lenp)
-{
- for (offset = fdt_first_property_offset(fdt, offset);
- (offset >= 0);
- (offset = fdt_next_property_offset(fdt, offset))) {
- const struct fdt_property *prop;
-
- prop = fdt_get_property_by_offset(fdt, offset, lenp);
- if (!prop) {
- offset = -FDT_ERR_INTERNAL;
- break;
- }
- if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->nameoff),
- name, namelen))
- return prop;
- }
-
- if (lenp)
- *lenp = offset;
- return NULL;
-}
-
-const struct fdt_property *fdt_get_property(const void *fdt,
- int nodeoffset,
- const char *name, int *lenp)
-{
- return fdt_get_property_namelen(fdt, nodeoffset, name,
- strlen(name), lenp);
-}
-
-const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
- const char *name, int namelen, int *lenp)
-{
- const struct fdt_property *prop;
-
- prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);
- if (! prop)
- return NULL;
-
- return prop->data;
-}
-
-const void *fdt_getprop_by_offset(const void *fdt, int offset,
- const char **namep, int *lenp)
-{
- const struct fdt_property *prop;
-
- prop = fdt_get_property_by_offset(fdt, offset, lenp);
- if (!prop)
- return NULL;
- if (namep)
- *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
- return prop->data;
-}
-
-const void *fdt_getprop(const void *fdt, int nodeoffset,
- const char *name, int *lenp)
-{
- return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp);
-}
-
-uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
-{
- const fdt32_t *php;
- int len;
-
- /* FIXME: This is a bit sub-optimal, since we potentially scan
- * over all the properties twice. */
- php = fdt_getprop(fdt, nodeoffset, "phandle", &len);
- if (!php || (len != sizeof(*php))) {
- php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len);
- if (!php || (len != sizeof(*php)))
- return 0;
- }
-
- return fdt32_to_cpu(*php);
-}
-
-const char *fdt_get_alias_namelen(const void *fdt,
- const char *name, int namelen)
-{
- int aliasoffset;
-
- aliasoffset = fdt_path_offset(fdt, "/aliases");
- if (aliasoffset < 0)
- return NULL;
-
- return fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL);
-}
-
-const char *fdt_get_alias(const void *fdt, const char *name)
-{
- return fdt_get_alias_namelen(fdt, name, strlen(name));
-}
-
-int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
-{
- int pdepth = 0, p = 0;
- int offset, depth, namelen;
- const char *name;
-
- FDT_CHECK_HEADER(fdt);
-
- if (buflen < 2)
- return -FDT_ERR_NOSPACE;
-
- for (offset = 0, depth = 0;
- (offset >= 0) && (offset <= nodeoffset);
- offset = fdt_next_node(fdt, offset, &depth)) {
- while (pdepth > depth) {
- do {
- p--;
- } while (buf[p-1] != '/');
- pdepth--;
- }
-
- if (pdepth >= depth) {
- name = fdt_get_name(fdt, offset, &namelen);
- if (!name)
- return namelen;
- if ((p + namelen + 1) <= buflen) {
- memcpy(buf + p, name, namelen);
- p += namelen;
- buf[p++] = '/';
- pdepth++;
- }
- }
-
- if (offset == nodeoffset) {
- if (pdepth < (depth + 1))
- return -FDT_ERR_NOSPACE;
-
- if (p > 1) /* special case so that root path is "/", not "" */
- p--;
- buf[p] = '\0';
- return 0;
- }
- }
-
- if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))
- return -FDT_ERR_BADOFFSET;
- else if (offset == -FDT_ERR_BADOFFSET)
- return -FDT_ERR_BADSTRUCTURE;
-
- return offset; /* error from fdt_next_node() */
-}
-
-int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
- int supernodedepth, int *nodedepth)
-{
- int offset, depth;
- int supernodeoffset = -FDT_ERR_INTERNAL;
-
- FDT_CHECK_HEADER(fdt);
-
- if (supernodedepth < 0)
- return -FDT_ERR_NOTFOUND;
-
- for (offset = 0, depth = 0;
- (offset >= 0) && (offset <= nodeoffset);
- offset = fdt_next_node(fdt, offset, &depth)) {
- if (depth == supernodedepth)
- supernodeoffset = offset;
-
- if (offset == nodeoffset) {
- if (nodedepth)
- *nodedepth = depth;
-
- if (supernodedepth > depth)
- return -FDT_ERR_NOTFOUND;
- else
- return supernodeoffset;
- }
- }
-
- if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))
- return -FDT_ERR_BADOFFSET;
- else if (offset == -FDT_ERR_BADOFFSET)
- return -FDT_ERR_BADSTRUCTURE;
-
- return offset; /* error from fdt_next_node() */
-}
-
-int fdt_node_depth(const void *fdt, int nodeoffset)
-{
- int nodedepth;
- int err;
-
- err = fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, &nodedepth);
- if (err)
- return (err < 0) ? err : -FDT_ERR_INTERNAL;
- return nodedepth;
-}
-
-int fdt_parent_offset(const void *fdt, int nodeoffset)
-{
- int nodedepth = fdt_node_depth(fdt, nodeoffset);
-
- if (nodedepth < 0)
- return nodedepth;
- return fdt_supernode_atdepth_offset(fdt, nodeoffset,
- nodedepth - 1, NULL);
-}
-
-int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
- const char *propname,
- const void *propval, int proplen)
-{
- int offset;
- const void *val;
- int len;
-
- FDT_CHECK_HEADER(fdt);
-
- /* FIXME: The algorithm here is pretty horrible: we scan each
- * property of a node in fdt_getprop(), then if that didn't
- * find what we want, we scan over them again making our way
- * to the next node. Still it's the easiest to implement
- * approach; performance can come later. */
- for (offset = fdt_next_node(fdt, startoffset, NULL);
- offset >= 0;
- offset = fdt_next_node(fdt, offset, NULL)) {
- val = fdt_getprop(fdt, offset, propname, &len);
- if (val && (len == proplen)
- && (memcmp(val, propval, len) == 0))
- return offset;
- }
-
- return offset; /* error from fdt_next_node() */
-}
-
-int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
-{
- int offset;
-
- if ((phandle == 0) || (phandle == (uint32_t)-1))
- return -FDT_ERR_BADPHANDLE;
-
- FDT_CHECK_HEADER(fdt);
-
- /* FIXME: The algorithm here is pretty horrible: we
- * potentially scan each property of a node in
- * fdt_get_phandle(), then if that didn't find what
- * we want, we scan over them again making our way to the next
- * node. Still it's the easiest to implement approach;
- * performance can come later. */
- for (offset = fdt_next_node(fdt, -1, NULL);
- offset >= 0;
- offset = fdt_next_node(fdt, offset, NULL)) {
- if (fdt_get_phandle(fdt, offset) == phandle)
- return offset;
- }
-
- return offset; /* error from fdt_next_node() */
-}
-
-int fdt_stringlist_contains(const char *strlist, int listlen, const char *str)
-{
- int len = strlen(str);
- const char *p;
-
- while (listlen >= len) {
- if (memcmp(str, strlist, len+1) == 0)
- return 1;
- p = memchr(strlist, '\0', listlen);
- if (!p)
- return 0; /* malformed strlist.. */
- listlen -= (p-strlist) + 1;
- strlist = p + 1;
- }
- return 0;
-}
-
-int fdt_node_check_compatible(const void *fdt, int nodeoffset,
- const char *compatible)
-{
- const void *prop;
- int len;
-
- prop = fdt_getprop(fdt, nodeoffset, "compatible", &len);
- if (!prop)
- return len;
- if (fdt_stringlist_contains(prop, len, compatible))
- return 0;
- else
- return 1;
-}
-
-int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
- const char *compatible)
-{
- int offset, err;
-
- FDT_CHECK_HEADER(fdt);
-
- /* FIXME: The algorithm here is pretty horrible: we scan each
- * property of a node in fdt_node_check_compatible(), then if
- * that didn't find what we want, we scan over them again
- * making our way to the next node. Still it's the easiest to
- * implement approach; performance can come later. */
- for (offset = fdt_next_node(fdt, startoffset, NULL);
- offset >= 0;
- offset = fdt_next_node(fdt, offset, NULL)) {
- err = fdt_node_check_compatible(fdt, offset, compatible);
- if ((err < 0) && (err != -FDT_ERR_NOTFOUND))
- return err;
- else if (err == 0)
- return offset;
- }
-
- return offset; /* error from fdt_next_node() */
-}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_rw.c b/EmbeddedPkg/Library/FdtLib/fdt_rw.c
deleted file mode 100644
index 7a2bcf3d07..0000000000
--- a/EmbeddedPkg/Library/FdtLib/fdt_rw.c
+++ /dev/null
@@ -1,495 +0,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;
- fdt32_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 = (fdt32_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;
-}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_strerror.c b/EmbeddedPkg/Library/FdtLib/fdt_strerror.c
deleted file mode 100644
index a49793d936..0000000000
--- a/EmbeddedPkg/Library/FdtLib/fdt_strerror.c
+++ /dev/null
@@ -1,96 +0,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"
-
-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>";
-}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_sw.c b/EmbeddedPkg/Library/FdtLib/fdt_sw.c
deleted file mode 100644
index 991919b436..0000000000
--- a/EmbeddedPkg/Library/FdtLib/fdt_sw.c
+++ /dev/null
@@ -1,256 +0,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)
-{
- fdt32_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;
- fdt32_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;
-}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_wip.c b/EmbeddedPkg/Library/FdtLib/fdt_wip.c
deleted file mode 100644
index 3f2b58172b..0000000000
--- a/EmbeddedPkg/Library/FdtLib/fdt_wip.c
+++ /dev/null
@@ -1,118 +0,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)
-{
- fdt32_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;
-}
diff --git a/EmbeddedPkg/Library/FdtLib/libfdt_internal.h b/EmbeddedPkg/Library/FdtLib/libfdt_internal.h
deleted file mode 100644
index 15456110a3..0000000000
--- a/EmbeddedPkg/Library/FdtLib/libfdt_internal.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#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 */
diff --git a/EmbeddedPkg/Library/FdtLib/version.lds b/EmbeddedPkg/Library/FdtLib/version.lds
deleted file mode 100644
index 80b322bed6..0000000000
--- a/EmbeddedPkg/Library/FdtLib/version.lds
+++ /dev/null
@@ -1,60 +0,0 @@
-LIBFDT_1.2 {
- global:
- fdt_next_node;
- fdt_check_header;
- fdt_move;
- fdt_string;
- fdt_num_mem_rsv;
- fdt_get_mem_rsv;
- fdt_subnode_offset_namelen;
- fdt_subnode_offset;
- fdt_path_offset;
- fdt_get_name;
- fdt_get_property_namelen;
- fdt_get_property;
- fdt_getprop_namelen;
- fdt_getprop;
- fdt_get_phandle;
- fdt_get_alias_namelen;
- fdt_get_alias;
- fdt_get_path;
- fdt_supernode_atdepth_offset;
- fdt_node_depth;
- fdt_parent_offset;
- fdt_node_offset_by_prop_value;
- fdt_node_offset_by_phandle;
- fdt_node_check_compatible;
- fdt_node_offset_by_compatible;
- fdt_setprop_inplace;
- fdt_nop_property;
- fdt_nop_node;
- fdt_create;
- fdt_add_reservemap_entry;
- fdt_finish_reservemap;
- fdt_begin_node;
- fdt_property;
- fdt_end_node;
- fdt_finish;
- fdt_open_into;
- fdt_pack;
- fdt_add_mem_rsv;
- fdt_del_mem_rsv;
- fdt_set_name;
- fdt_setprop;
- fdt_delprop;
- fdt_add_subnode_namelen;
- fdt_add_subnode;
- fdt_del_node;
- fdt_strerror;
- fdt_offset_ptr;
- fdt_next_tag;
- fdt_appendprop;
- fdt_create_empty_tree;
- fdt_first_property_offset;
- fdt_get_property_by_offset;
- fdt_getprop_by_offset;
- fdt_next_property_offset;
-
- local:
- *;
-};
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.S b/EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.S
deleted file mode 100755
index df1543a6d2..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.S
+++ /dev/null
@@ -1,258 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# 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
-
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.asm b/EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.asm
deleted file mode 100755
index 611e83d7da..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.asm
+++ /dev/null
@@ -1,259 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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
-
-
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/Arm/Processor.c b/EmbeddedPkg/Library/GdbDebugAgent/Arm/Processor.c
deleted file mode 100755
index 61c6184fae..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/Arm/Processor.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/** @file
- Processor specific parts of the GDB stub
-
- Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-
-#include <GdbDebugAgent.h>
-#include <Library/PrintLib.h>
-#include <Library/ArmLib.h>
-
-//
-// Externs from the exception handler assembly file
-//
-VOID
-ExceptionHandlersStart (
- VOID
- );
-
-VOID
-ExceptionHandlersEnd (
- VOID
- );
-
-VOID
-CommonExceptionEntry (
- VOID
- );
-
-VOID
-AsmCommonExceptionEntry (
- VOID
- );
-
-
-//
-// Array of exception types that need to be hooked by the debugger
-// (efi, gdb) //efi number
-//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_ARM_SOFTWARE_INTERRUPT, GDB_SIGTRAP },
- { EXCEPT_ARM_UNDEFINED_INSTRUCTION, GDB_SIGTRAP },
- { EXCEPT_ARM_PREFETCH_ABORT, GDB_SIGTRAP },
- { EXCEPT_ARM_DATA_ABORT, GDB_SIGTRAP }, // GDB_SIGEMT
- { EXCEPT_ARM_RESERVED, GDB_SIGTRAP }, // GDB_SIGILL
- { EXCEPT_ARM_FIQ, GDB_SIGINT } // Used for ctrl-c
-};
-
-// Shut up some annoying RVCT warnings
-#ifdef __CC_ARM
-#pragma diag_suppress 1296
-#endif
-
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R0),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R1),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R2),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R3),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R4),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R5),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R6),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R7),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R8),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R9),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R10),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R11),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R12),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, SP),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, LR),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, PC),
- 0x00000F01, // f0
- 0x00000F02,
- 0x00000F03,
- 0x00000F11, // f1
- 0x00000F12,
- 0x00000F13,
- 0x00000F21, // f2
- 0x00000F22,
- 0x00000F23,
- 0x00000F31, // f3
- 0x00000F32,
- 0x00000F33,
- 0x00000F41, // f4
- 0x00000F42,
- 0x00000F43,
- 0x00000F51, // f5
- 0x00000F52,
- 0x00000F53,
- 0x00000F61, // f6
- 0x00000F62,
- 0x00000F63,
- 0x00000F71, // f7
- 0x00000F72,
- 0x00000F73,
- 0x00000FFF, // fps
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, CPSR)
-};
-
-// restore warnings for RVCT
-#ifdef __CC_ARM
-#pragma diag_default 1296
-#endif
-
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- )
-{
- return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
-}
-
-
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported
-
-**/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- )
-{
- if (Isa == IsaArm) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-
-/**
- This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
- It is, by default, set to find the register pointer of the ARM member
- @param SystemContext Register content at time of the exception
- @param RegNumber The register to which we want to find a pointer
- @retval the pointer to the RegNumber-th pointer
- **/
-UINTN *
-FindPointerToRegister(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- )
-{
- UINT8 *TempPtr;
- ASSERT(gRegisterOffsets[RegNumber] < 0xF00);
- TempPtr = ((UINT8 *)SystemContext.SystemContextArm) + gRegisterOffsets[RegNumber];
- return (UINT32 *)TempPtr;
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to read
- @param OutBufPtr pointer to the output buffer's end. the new data will be added from this point on.
- @retval the pointer to the next character of the output buffer that is available to be written on.
- **/
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- )
-{
- UINTN RegSize;
- CHAR8 Char;
-
- if (gRegisterOffsets[RegNumber] > 0xF00) {
- AsciiSPrint(OutBufPtr, 9, "00000000");
- OutBufPtr += 8;
- return OutBufPtr;
- }
-
- RegSize = 0;
- while (RegSize < 32) {
- Char = mHexToStr[(UINT8)((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- Char = mHexToStr[(UINT8)((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- RegSize = RegSize + 8;
- }
- return OutBufPtr;
-}
-
-
-/**
- Reads the n-th register's value into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
-
- if (RegNumber >= (sizeof (gRegisterOffsets)/sizeof (UINTN))) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
-
- OutBufPtr = OutBuffer;
- OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket(OutBuffer);
-}
-
-
-/**
- Reads the general registers into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINTN Index;
- // a UINT32 takes 8 ascii characters
- CHAR8 OutBuffer[(sizeof (gRegisterOffsets) * 2) + 1];
- CHAR8 *OutBufPtr;
-
- // It is not safe to allocate pool here....
- OutBufPtr = OutBuffer;
- for (Index = 0; Index < (sizeof (gRegisterOffsets)/sizeof (UINTN)); Index++) {
- OutBufPtr = BasicReadRegister (SystemContext, Index, OutBufPtr);
- }
-
- *OutBufPtr = '\0';
- SendPacket(OutBuffer);
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to write
- @param InBufPtr pointer to the output buffer. the new data will be extracted from the input buffer from this point on.
- @retval the pointer to the next character of the input buffer that can be used
- **/
-CHAR8 *
-BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- )
-{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT32 NewValue; // the new value of the RegNumber-th Register
-
- if (gRegisterOffsets[RegNumber] > 0xF00) {
- return InBufPtr + 8;
- }
-
- NewValue = 0;
- RegSize = 0;
- while (RegSize < 32) {
- TempValue = HexCharToInt(*InBufPtr++);
-
- if ((INTN)TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt(*InBufPtr++);
-
- if ((INTN)TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
- }
- *(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
- return InBufPtr;
-}
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
- @param SystemContext Register content at time of the exception
- @param InBuffer Ponter to the input buffer received from gdb server
- **/
-VOID
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
-
- // find the register number to write
- InBufPtr = &InBuffer[1];
- RegNumBufPtr = RegNumBuffer;
- while (*InBufPtr != '=') {
- *RegNumBufPtr++ = *InBufPtr++;
- }
- *RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
-
- // check if this is a valid Register Number
- if (RegNumber >= (sizeof (gRegisterOffsets)/sizeof (UINTN))) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
- InBufPtr++; // skips the '=' character
- BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
-}
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-
-VOID
-EFIAPI
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
- UINTN MinLength;
- UINTN RegisterCount = (sizeof (gRegisterOffsets)/sizeof (UINTN));
-
- MinLength = (RegisterCount * 8) + 1; // 'G' plus the registers in ASCII format
-
- if (AsciiStrLen(InBuffer) < MinLength) {
- //Bad message. Message is not the right length
- SendError (GDB_EBADBUFSIZE);
- return;
- }
-
- InBufPtr = &InBuffer[1];
-
- // Read the new values for the registers from the input buffer to an array, NewValueArray.
- // The values in the array are in the gdb ordering
- for(i = 0; i < RegisterCount; i++) {
- InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
- }
-
- SendSuccess ();
-}
-
-
-
-
-/**
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextArm->PC = AsciiStrHexToUintn(&PacketData[1]);
- }
-}
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- SendNotSupported();
-}
-
-
-VOID
-EFIAPI
-InsertBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- SendNotSupported ();
-}
-
-VOID
-EFIAPI
-RemoveBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- SendNotSupported ();
-}
-
-
-/**
- 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
- ticks in the GDB stub. The stub disables FIQ on entry, but this is the
- third instruction that executes in the execption handler. Thus we have
- a crack we need to test for.
-
- @param PC PC of execption
-
- @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;
-}
-
-
-/**
- Check to see if this exception is related to ctrl-c handling.
-
- In this scheme we dedicate FIQ to the ctrl-c handler so it is
- independent of the rest of the system.
-
- SaveAndSetDebugTimerInterrupt () can be used to
-
- @param ExceptionType Exception that is being processed
- @param SystemContext Register content at time of the exception
-
- @return TRUE This was a ctrl-c check that did not find a ctrl-c
- @return FALSE This was not a ctrl-c check or some one hit ctrl-c
- **/
-BOOLEAN
-ProcessorControlC (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- CHAR8 Char;
- BOOLEAN Return = TRUE;
-
- if (ExceptionType != EXCEPT_ARM_FIQ) {
- // Skip it as it is not related to ctrl-c
- return FALSE;
- }
-
- if (InFiqCrack (SystemContext.SystemContextArm->PC)) {
- // We are in our own interrupt preable, so skip this tick.
- // We never want to let gdb see the debug stub running if we can help it
- 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;
- }
- }
-
- DebugAgentTimerEndOfInterrupt ();
-
- // Force an exit from the exception handler as we are done
- return Return;
-}
-
-
-/**
- Enable/Disable the interrupt of debug timer and return the interrupt state
- prior to the operation.
-
- If EnableStatus is TRUE, enable the interrupt of debug timer.
- If EnableStatus is FALSE, disable the interrupt of debug timer.
-
- @param[in] EnableStatus Enable/Disable.
-
- @retval TRUE Debug timer interrupt were enabled on entry to this call.
- @retval FALSE Debug timer interrupt were disabled on entry to this call.
-
-**/
-BOOLEAN
-EFIAPI
-SaveAndSetDebugTimerInterrupt (
- IN BOOLEAN EnableStatus
- )
-{
- BOOLEAN FiqEnabled;
-
- FiqEnabled = ArmGetFiqState ();
-
- if (EnableStatus) {
- DebugAgentTimerSetPeriod (PcdGet32 (PcdGdbTimerPeriodMilliseconds));
- ArmEnableFiq ();
- } else {
- DebugAgentTimerSetPeriod (0);
- ArmDisableFiq ();
- }
-
- return FiqEnabled;
-}
-
-
-
-VOID
-GdbFPutString (
- IN CHAR8 *String
- );
-
-/**
- Initialize debug agent.
-
- This function is used to set up debug environment to support source level debugging.
- If certain Debug Agent Library instance has to save some private data in the stack,
- this function must work on the mode that doesn't return to the caller, then
- the caller needs to wrap up all rest of logic after InitializeDebugAgent() into one
- function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is
- responsible to invoke the passing-in function at the end of InitializeDebugAgent().
-
- If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by
- passing in the Context to be its parameter.
-
- If Function() is NULL, Debug Agent Library instance will return after setup debug
- environment.
-
- @param[in] InitFlag Init flag is used to decide the initialize process.
- @param[in] Context Context needed according to InitFlag; it was optional.
- @param[in] Function Continue function called by debug agent library; it was
- optional.
-
-**/
-VOID
-EFIAPI
-InitializeDebugAgent (
- IN UINT32 InitFlag,
- IN VOID *Context, OPTIONAL
- IN DEBUG_AGENT_CONTINUE Function OPTIONAL
- )
-{
- UINTN Offset;
- UINTN Length;
- BOOLEAN IrqEnabled;
- UINT32 *VectorBase;
-
-
- //
- // Disable interrupts
- //
- IrqEnabled = ArmGetInterruptState ();
- ArmDisableInterrupts ();
- ArmDisableFiq ();
-
- //
- // Copy an implementation of the ARM exception vectors to PcdCpuVectorBaseAddress.
- //
- Length = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart;
-
- //
- // Reserve space for the exception handlers
- //
- VectorBase = (UINT32 *)(UINTN)PcdGet32 (PcdCpuVectorBaseAddress);
-
-
- // Copy our assembly code into the page that contains the exception vectors.
- CopyMem ((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length);
-
- //
- // Patch in the common Assembly exception handler
- //
- Offset = (UINTN)CommonExceptionEntry - (UINTN)ExceptionHandlersStart;
- *(UINTN *) (((UINT8 *)VectorBase) + Offset) = (UINTN)AsmCommonExceptionEntry;
-
- // Flush Caches since we updated executable stuff
- InvalidateInstructionCacheRange ((VOID *)PcdGet32(PcdCpuVectorBaseAddress), Length);
-
- // setup a timer so gdb can break in via ctrl-c
- DebugAgentTimerIntialize ();
-
- if (IrqEnabled) {
- ArmEnableInterrupts ();
- }
-
- if (Function != NULL) {
- Function (Context);
- }
-
- return;
-}
-
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.c b/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.c
deleted file mode 100755
index 2e67de6f99..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.c
+++ /dev/null
@@ -1,815 +0,0 @@
-/** @file
- Debug Agent library implementition with empty functions.
-
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "GdbDebugAgent.h"
-
-
-UINTN gMaxProcessorIndex = 0;
-
-//
-// Buffers for basic gdb communication
-//
-CHAR8 gInBuffer[MAX_BUF_SIZE];
-CHAR8 gOutBuffer[MAX_BUF_SIZE];
-
-
-//
-// Globals for returning XML from qXfer:libraries:read packet
-//
-UINTN gPacketqXferLibraryOffset = 0;
-UINTN gEfiDebugImageTableEntry = 0;
-CHAR8 gXferLibraryBuffer[2000];
-
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexToStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-
-
-// add-symbol-file c:/work/edk2/Build/BeagleBoard/DEBUG_GCC48/ARM/BeagleBoardPkg/Sec/Sec/DEBUG/BeagleBoardSec.dll 0x80008360
-CHAR8 *qXferHack = "<library name=\"c:/work/edk2/Build/BeagleBoard/DEBUG_GCC48/ARM/BeagleBoardPkg/Sec/Sec/DEBUG/BeagleBoardSec.dll\"><segment address=\"0x80008360\"/></library>";
-
-UINTN
-gXferObjectReadResponse (
- IN CHAR8 Type,
- IN CHAR8 *Str
- )
-{
- CHAR8 *OutBufPtr; // pointer to the output buffer
- CHAR8 Char;
- UINTN Count;
-
- // responce starts with 'm' or 'l' if it is the end
- OutBufPtr = gOutBuffer;
- *OutBufPtr++ = Type;
- Count = 1;
-
- // Binary data encoding
- OutBufPtr = gOutBuffer;
- while (*Str != '\0') {
- Char = *Str++;
- if ((Char == 0x7d) || (Char == 0x23) || (Char == 0x24) || (Char == 0x2a)) {
- // escape character
- *OutBufPtr++ = 0x7d;
-
- Char ^= 0x20;
- }
- *OutBufPtr++ = Char;
- Count++;
- }
-
- *OutBufPtr = '\0' ; // the end of the buffer
- SendPacket (gOutBuffer);
-
- return Count;
-}
-
-/**
- Process "qXfer:object:read:annex:offset,length" request.
-
- Returns an XML document that contains loaded libraries. In our case it is
- infomration in the EFI Debug Inmage Table converted into an XML document.
-
- GDB will call with an arbitrary length (it can't know the real length and
- will reply with chunks of XML that are easy for us to deal with. Gdb will
- keep calling until we say we are done. XML doc looks like:
-
- <library-list>
- <library name="/a/a/c/d.dSYM"><segment address="0x10000000"/></library>
- <library name="/a/m/e/e.pdb"><segment address="0x20000000"/></library>
- <library name="/a/l/f/f.dll"><segment address="0x30000000"/></library>
- </library-list>
-
- Since we can not allocate memory in interupt context this module has
- assumptions about how it will get called:
- 1) Length will generally be max remote packet size (big enough)
- 2) First Offset of an XML document read needs to be 0
- 3) This code will return back small chunks of the XML document on every read.
- Each subseqent call will ask for the next availble part of the document.
-
- Note: The only variable size element in the XML is:
- " <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
- based on the file path and name of the symbol file. If the symbol file name
- is bigger than the max gdb remote packet size we could update this code
- to respond back in chunks.
-
- @param Offset offset into special data area
- @param Length number of bytes to read starting at Offset
-
- **/
-VOID
-QxferLibrary (
- IN UINTN Offset,
- IN UINTN Length
- )
-{
- gPacketqXferLibraryOffset += gXferObjectReadResponse ('m', "<library-list>\n");
- gPacketqXferLibraryOffset += gXferObjectReadResponse ('m', qXferHack);
- gXferObjectReadResponse ('l', "</library-list>\n");
- gPacketqXferLibraryOffset = 0;
-}
-
-/**
- Transfer length bytes of input buffer, starting at Address, to memory.
-
- @param length the number of the bytes to be transferred/written
- @param *address the start address of the transferring/writing the memory
- @param *new_data the new data to be written to memory
- **/
-
-VOID
-TransferFromInBufToMem (
- IN UINTN Length,
- IN unsigned char *Address,
- IN CHAR8 *NewData
- )
-{
- CHAR8 c1;
- CHAR8 c2;
-
- while (Length-- > 0) {
- c1 = (CHAR8)HexCharToInt (*NewData++);
- c2 = (CHAR8)HexCharToInt (*NewData++);
-
- if ((c1 < 0) || (c2 < 0)) {
- SendError (GDB_EBADMEMDATA);
- return;
- }
- *Address++ = (UINT8)((c1 << 4) + c2);
- }
-
- SendSuccess();
-}
-
-
-/**
- Transfer Length bytes of memory starting at Address to an output buffer, OutBuffer. This function will finally send the buffer
- as a packet.
-
- @param Length the number of the bytes to be transferred/read
- @param *address pointer to the start address of the transferring/reading the memory
- **/
-
-VOID
-TransferFromMemToOutBufAndSend (
- IN UINTN Length,
- IN unsigned char *Address
- )
-{
- // there are Length bytes and every byte is represented as 2 hex chars
- CHAR8 OutBuffer[MAX_BUF_SIZE];
- CHAR8 *OutBufPtr; // pointer to the output buffer
- CHAR8 Char;
-
- OutBufPtr = OutBuffer;
- while (Length > 0) {
-
- Char = mHexToStr[*Address >> 4];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- Char = mHexToStr[*Address & 0x0f];
- if ((Char >= 'A') && (Char <= 'F')) {
- Char = Char - 'A' + 'a';
- }
- *OutBufPtr++ = Char;
-
- Address++;
- Length--;
- }
-
- *OutBufPtr = '\0' ; // the end of the buffer
- SendPacket (OutBuffer);
-}
-
-
-
-/**
- Send a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up
- in an infinit loop. This is so if you unplug the debugger code just keeps running
-
- @param PacketData Payload data for the packet
-
-
- @retval Number of bytes of packet data sent.
-
-**/
-UINTN
-SendPacket (
- IN CHAR8 *PacketData
- )
-{
- UINT8 CheckSum;
- UINTN Timeout;
- CHAR8 *Ptr;
- CHAR8 TestChar;
- UINTN Count;
-
- Timeout = PcdGet32 (PcdGdbMaxPacketRetryCount);
-
- Count = 0;
- do {
-
- Ptr = PacketData;
-
- if (Timeout-- == 0) {
- // Only try a finite number of times so we don't get stuck in the loop
- return Count;
- }
-
- // Packet prefix
- GdbPutChar ('$');
-
- for (CheckSum = 0, Count =0 ; *Ptr != '\0'; Ptr++, Count++) {
- GdbPutChar (*Ptr);
- CheckSum = CheckSum + *Ptr;
- }
-
- // Packet terminating character and checksum
- GdbPutChar ('#');
- GdbPutChar (mHexToStr[CheckSum >> 4]);
- GdbPutChar (mHexToStr[CheckSum & 0x0F]);
-
- TestChar = GdbGetChar ();
- } while (TestChar != '+');
-
- return Count;
-}
-
-/**
- Receive a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed.
- (In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)
-
- If an ack '+' is not sent resend the packet
-
- @param PacketData Payload data for the packet
-
- @retval Number of bytes of packet data received.
-
-**/
-UINTN
-ReceivePacket (
- OUT CHAR8 *PacketData,
- IN UINTN PacketDataSize
- )
-{
- UINT8 CheckSum;
- UINTN Index;
- CHAR8 Char;
- CHAR8 SumString[3];
- CHAR8 TestChar;
-
- ZeroMem (PacketData, PacketDataSize);
-
- for (;;) {
- // wait for the start of a packet
- TestChar = GdbGetChar ();
- while (TestChar != '$') {
- TestChar = GdbGetChar ();
- };
-
- retry:
- for (Index = 0, CheckSum = 0; Index < (PacketDataSize - 1); Index++) {
- Char = GdbGetChar ();
- if (Char == '$') {
- goto retry;
- }
- if (Char == '#') {
- break;
- }
-
- PacketData[Index] = Char;
- CheckSum = CheckSum + Char;
- }
- PacketData[Index] = '\0';
-
- if (Index == PacketDataSize) {
- continue;
- }
-
- SumString[0] = GdbGetChar ();
- SumString[1] = GdbGetChar ();
- SumString[2] = '\0';
-
- if (AsciiStrHexToUintn (SumString) == CheckSum) {
- // Ack: Success
- GdbPutChar ('+');
-
- // Null terminate the callers string
- PacketData[Index] = '\0';
- return Index;
- } else {
- // Ack: Failure
- GdbPutChar ('-');
- }
- }
-
- //return 0;
-}
-
-
-/**
- Empties the given buffer
- @param Buf pointer to the first element in buffer to be emptied
- **/
-VOID
-EmptyBuffer (
- IN CHAR8 *Buf
- )
-{
- *Buf = '\0';
-}
-
-
-/**
- Converts an 8-bit Hex Char into a INTN.
-
- @param Char the hex character to be converted into UINTN
- @retval a INTN, from 0 to 15, that corressponds to Char
- -1 if Char is not a hex character
- **/
-INTN
-HexCharToInt (
- IN CHAR8 Char
- )
-{
- if ((Char >= 'A') && (Char <= 'F')) {
- return Char - 'A' + 10;
- } else if ((Char >= 'a') && (Char <= 'f')) {
- return Char - 'a' + 10;
- } else if ((Char >= '0') && (Char <= '9')) {
- return Char - '0';
- } else { // if not a hex value, return a negative value
- return -1;
- }
-}
-
- // 'E' + the biggest error number is 255, so its 2 hex digits + buffer end
-CHAR8 *gError = "E__";
-
-/** 'E NN'
- Send an error with the given error number after converting to hex.
- The error number is put into the buffer in hex. '255' is the biggest errno we can send.
- ex: 162 will be sent as A2.
-
- @param errno the error number that will be sent
- **/
-VOID
-EFIAPI
-SendError (
- IN UINT8 ErrorNum
- )
-{
- //
- // Replace _, or old data, with current errno
- //
- gError[1] = mHexToStr [ErrorNum >> 4];
- gError[2] = mHexToStr [ErrorNum & 0x0f];
-
- SendPacket (gError); // send buffer
-}
-
-
-
-/**
- Send 'OK' when the function is done executing successfully.
- **/
-VOID
-EFIAPI
-SendSuccess (
- VOID
- )
-{
- SendPacket ("OK"); // send buffer
-}
-
-
-/**
- Send empty packet to specify that particular command/functionality is not supported.
- **/
-VOID
-EFIAPI
-SendNotSupported (
- VOID
- )
-{
- SendPacket ("");
-}
-
-
-
-
-
-/**
- Translates the EFI mapping to GDB mapping
-
- @param EFIExceptionType EFI Exception that is being processed
- @retval UINTN that corresponds to EFIExceptionType's GDB exception type number
- **/
-UINT8
-ConvertEFItoGDBtype (
- IN EFI_EXCEPTION_TYPE EFIExceptionType
- )
-{
- UINTN i;
-
- for (i=0; i < MaxEfiException() ; i++) {
- if (gExceptionType[i].Exception == EFIExceptionType) {
- return gExceptionType[i].SignalNo;
- }
- }
- return GDB_SIGTRAP; // this is a GDB trap
-}
-
-
-/** "m addr,length"
- Find the Length of the area to read and the start addres. Finally, pass them to
- another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
- send it as a packet.
- **/
-
-VOID
-EFIAPI
-ReadFromMemory (
- CHAR8 *PacketData
- )
-{
- UINTN Address;
- UINTN Length;
- CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the address in hex chars
- CHAR8 *AddrBufPtr; // pointer to the address buffer
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- AddrBufPtr = AddressBuffer;
- InBufPtr = &PacketData[1];
- while (*InBufPtr != ',') {
- *AddrBufPtr++ = *InBufPtr++;
- }
- *AddrBufPtr = '\0';
-
- InBufPtr++; // this skips ',' in the buffer
-
- /* Error checking */
- if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
- SendError (GDB_EBADMEMADDRBUFSIZE);
- return;
- }
-
- // 2 = 'm' + ','
- if (AsciiStrLen(PacketData) - AsciiStrLen(AddressBuffer) - 2 >= MAX_LENGTH_SIZE) {
- SendError (GDB_EBADMEMLENGTH);
- return;
- }
-
- Address = AsciiStrHexToUintn (AddressBuffer);
- Length = AsciiStrHexToUintn (InBufPtr);
-
- TransferFromMemToOutBufAndSend (Length, (unsigned char *)Address);
-}
-
-
-/** "M addr,length :XX..."
- Find the Length of the area in bytes to write and the start addres. Finally, pass them to
- another function, TransferFromInBufToMem, that will write to that memory space the info in
- the input buffer.
- **/
-VOID
-EFIAPI
-WriteToMemory (
- IN CHAR8 *PacketData
- )
-{
- UINTN Address;
- UINTN Length;
- UINTN MessageLength;
- CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the Address in hex chars
- CHAR8 LengthBuffer[MAX_LENGTH_SIZE]; // the buffer that will hold the Length in hex chars
- CHAR8 *AddrBufPtr; // pointer to the Address buffer
- CHAR8 *LengthBufPtr; // pointer to the Length buffer
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- AddrBufPtr = AddressBuffer;
- LengthBufPtr = LengthBuffer;
- InBufPtr = &PacketData[1];
-
- while (*InBufPtr != ',') {
- *AddrBufPtr++ = *InBufPtr++;
- }
- *AddrBufPtr = '\0';
-
- InBufPtr++; // this skips ',' in the buffer
-
- while (*InBufPtr != ':') {
- *LengthBufPtr++ = *InBufPtr++;
- }
- *LengthBufPtr = '\0';
-
- InBufPtr++; // this skips ':' in the buffer
-
- Address = AsciiStrHexToUintn (AddressBuffer);
- Length = AsciiStrHexToUintn (LengthBuffer);
-
- /* Error checking */
-
- //Check if Address is not too long.
- if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
- SendError (GDB_EBADMEMADDRBUFSIZE);
- return;
- }
-
- //Check if message length is not too long
- if (AsciiStrLen(LengthBuffer) >= MAX_LENGTH_SIZE) {
- SendError (GDB_EBADMEMLENGBUFSIZE);
- return;
- }
-
- // Check if Message is not too long/short.
- // 3 = 'M' + ',' + ':'
- MessageLength = (AsciiStrLen(PacketData) - AsciiStrLen(AddressBuffer) - AsciiStrLen(LengthBuffer) - 3);
- if (MessageLength != (2*Length)) {
- //Message too long/short. New data is not the right size.
- SendError (GDB_EBADMEMDATASIZE);
- return;
- }
- TransferFromInBufToMem (Length, (unsigned char *)Address, InBufPtr);
-}
-
-/**
- Parses breakpoint packet data and captures Breakpoint type, Address and length.
- In case of an error, function returns particular error code. Returning 0 meaning
- no error.
-
- @param PacketData Pointer to the payload data for the packet.
- @param Type Breakpoint type
- @param Address Breakpoint address
- @param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
-
- @retval 1 Success
- @retval {other} Particular error code
-
-**/
-UINTN
-ParseBreakpointPacket (
- IN CHAR8 *PacketData,
- OUT UINTN *Type,
- OUT UINTN *Address,
- OUT UINTN *Length
- )
-{
- CHAR8 AddressBuffer[MAX_ADDR_SIZE];
- CHAR8 *AddressBufferPtr;
- CHAR8 *PacketDataPtr;
-
- PacketDataPtr = &PacketData[1];
- AddressBufferPtr = AddressBuffer;
-
- *Type = AsciiStrHexToUintn (PacketDataPtr);
-
- //Breakpoint/watchpoint type should be between 0 to 4
- if (*Type > 4) {
- return 22; //EINVAL: Invalid argument.
- }
-
- //Skip ',' in the buffer.
- while (*PacketDataPtr++ != ',');
-
- //Parse Address information
- while (*PacketDataPtr != ',') {
- *AddressBufferPtr++ = *PacketDataPtr++;
- }
- *AddressBufferPtr = '\0';
-
- //Check if Address is not too long.
- if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
- return 40; //EMSGSIZE: Message size too long.
- }
-
- *Address = AsciiStrHexToUintn (AddressBuffer);
-
- PacketDataPtr++; //This skips , in the buffer
-
- //Parse Length information
- *Length = AsciiStrHexToUintn (PacketDataPtr);
-
- //Length should be 1, 2 or 4 bytes
- if (*Length > 4) {
- return 22; //EINVAL: Invalid argument
- }
-
- return 0; //0 = No error
-}
-
-
-
-/**
- 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
-GdbSendTSignal (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINT8 GdbExceptionType
- )
-{
- CHAR8 TSignalBuffer[128];
- CHAR8 *TSignalPtr;
-
- TSignalPtr = &TSignalBuffer[0];
-
- //Construct TSignal packet
- *TSignalPtr++ = 'T';
-
- //
- // replace _, or previous value, with Exception type
- //
- *TSignalPtr++ = mHexToStr [GdbExceptionType >> 4];
- *TSignalPtr++ = mHexToStr [GdbExceptionType & 0x0f];
-
- ProcessorSendTSignal (SystemContext, GdbExceptionType, TSignalPtr, sizeof (TSignalBuffer) - 2);
-
- SendPacket (TSignalBuffer);
-}
-
-VOID
-GdbFWrite (
- IN UINTN Fd,
- IN CHAR8 *Data,
- IN UINTN DataSize
- )
-{
- CHAR8 Buffer[128];
-
- AsciiSPrint (Buffer, sizeof (Buffer), "Fwrite,%x,%x,%x", Fd, Data, DataSize);
- SendPacket (Buffer);
-
- for( ; ; ) {
- ReceivePacket (gInBuffer, MAX_BUF_SIZE);
-
- switch (gInBuffer[0]) {
- case 'm':
- ReadFromMemory (gInBuffer);
- break;
-
- case 'M':
- WriteToMemory (gInBuffer);
- break;
-
- case 'F':
- return;
- }
- }
-}
-
-
-VOID
-GdbFPutString (
- IN CHAR8 *String
- )
-{
- UINTN Len = AsciiStrSize (String);
-
- GdbFWrite (2, String, Len);
-}
-
-
-/**
- Exception Hanldler for GDB. It will be called for all exceptions
- registered via the gExceptionType[] array.
-
- @param ExceptionType Exception that is being processed
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-GdbExceptionHandler (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINT8 GdbExceptionType;
- CHAR8 *Ptr;
-
- if (ProcessorControlC (ExceptionType, SystemContext)) {
- // We tried to process a control C handler and there is nothing to do
- return;
- }
-
- GdbExceptionType = ConvertEFItoGDBtype (ExceptionType);
- GdbSendTSignal (SystemContext, GdbExceptionType);
-
- for( ; ; ) {
- ReceivePacket (gInBuffer, MAX_BUF_SIZE);
-
- switch (gInBuffer[0]) {
- case '?':
- GdbSendTSignal (SystemContext, GdbExceptionType);
- break;
-
- case 'c':
- ContinueAtAddress (SystemContext, gInBuffer);
- return;
-
- case 'D':
- // gdb wants to disconnect so return "OK" packet since.
- SendSuccess ();
- return;
-
- case 'g':
- ReadGeneralRegisters (SystemContext);
- break;
-
- case 'G':
- WriteGeneralRegisters (SystemContext, gInBuffer);
- break;
-
- case 'H':
- //Return "OK" packet since we don't have more than one thread.
- SendSuccess ();
- break;
-
- case 'm':
- ReadFromMemory (gInBuffer);
- break;
-
- case 'M':
- WriteToMemory (gInBuffer);
- break;
-
- case 'P':
- WriteNthRegister (SystemContext, gInBuffer);
- break;
-
- //
- // Still debugging this code. Not used in Darwin
- //
- case 'q':
- // General Query Packets
- if (AsciiStrnCmp (gInBuffer, "qSupported", 10) == 0) {
- // return what we currently support, we don't parse what gdb suports
- AsciiSPrint (gOutBuffer, MAX_BUF_SIZE, "qXfer:libraries:read+;PacketSize=%d", MAX_BUF_SIZE);
- SendPacket (gOutBuffer);
- } else if (AsciiStrnCmp (gInBuffer, "qXfer:libraries:read::", 22) == 0) {
- // ‘qXfer:libraries:read::offset,length
- // gInBuffer[22] is offset string, ++Ptr is length string’
- for (Ptr = &gInBuffer[22]; *Ptr != ','; Ptr++);
-
- // Not sure if multi-radix support is required. Currently only support decimal
- QxferLibrary (AsciiStrHexToUintn (&gInBuffer[22]), AsciiStrHexToUintn (++Ptr));
- } else if (AsciiStrnCmp (gInBuffer, "qOffsets", 8) == 0) {
- AsciiSPrint (gOutBuffer, MAX_BUF_SIZE, "Text=1000;Data=f000;Bss=f000");
- SendPacket (gOutBuffer);
- } else if (AsciiStrnCmp (gInBuffer, "qAttached", 9) == 0) {
- // remote server attached to an existing process
- SendPacket ("1");
- } else {
- //Send empty packet
- SendNotSupported ();
- }
- break;
-
- case 's':
- SingleStep (SystemContext, gInBuffer);
- return;
-
- case 'z':
- RemoveBreakPoint (SystemContext, gInBuffer);
- break;
-
- case 'Z':
- InsertBreakPoint (SystemContext, gInBuffer);
- break;
-
- default:
- //Send empty packet
- SendNotSupported ();
- break;
- }
- }
-}
-
-
-
-
-
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.h b/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.h
deleted file mode 100755
index dfdc016d9d..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.h
+++ /dev/null
@@ -1,728 +0,0 @@
-/** @file
- Private include file for GDB stub
-
- 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 __GCC_DEBUG_AGENT_INTERNAL__
-#define __GCC_DEBUG_AGENT_INTERNAL__
-
-#include <Uefi.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/GdbSerialLib.h>
-#include <Library/PrintLib.h>
-#include <Library/CacheMaintenanceLib.h>
-#include <Library/DebugAgentTimerLib.h>
-#include <Library/DebugAgentLib.h>
-
-#include <IndustryStandard/PeImage.h>
-#include <Protocol/DebugSupport.h>
-
-extern CONST CHAR8 mHexToStr[];
-
-// maximum size of input and output buffers
-// This value came from the show remote command of the gdb we tested against
-#define MAX_BUF_SIZE 2000
-
-// maximum size of address buffer
-#define MAX_ADDR_SIZE 32
-
-// maximum size of register number buffer
-#define MAX_REG_NUM_BUF_SIZE 32
-
-// maximum size of length buffer
-#define MAX_LENGTH_SIZE 32
-
-// maximum size of T signal members
-#define MAX_T_SIGNAL_SIZE 64
-
-// the mask used to clear all the cache
-#define TF_BIT 0x00000100
-
-
-//
-// GDB Signal definitions - generic names for interrupts
-//
-#define GDB_SIGINT 2 // Interrupt process via ctrl-c
-#define GDB_SIGILL 4 // Illegal instruction
-#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)
-#define GDB_SIGEMT 7 // Emulator Trap
-#define GDB_SIGFPE 8 // Floating point exception
-#define GDB_SIGSEGV 11 // Setgment violation, page fault
-
-
-//
-// GDB File I/O Error values, zero means no error
-// Includes all general GDB Unix like error values
-//
-#define GDB_EBADMEMADDRBUFSIZE 11 // the buffer that stores memory Address to be read from/written to is not the right size
-#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size
-#define GDB_EBADMEMLENGTH 13 // Length, the given number of bytes to read or write, is not the right size
-#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is leess than 0
-#define GDB_EBADMEMDATASIZE 15 // the memory data, 'XX..', is too short or too long
-#define GDB_EBADBUFSIZE 21 // the buffer created is not the correct size
-#define GDB_EINVALIDARG 31 // argument is invalid
-#define GDB_ENOSPACE 41 //
-#define GDB_EINVALIDBRKPOINTTYPE 51 // the breakpoint type is not recognized
-#define GDB_EINVALIDREGNUM 61 // given register number is not valid: either <0 or >=Number of Registers
-#define GDB_EUNKNOWN 255 // unknown
-
-
-//
-// These devices are open by GDB so we can just read and write to them
-//
-#define GDB_STDIN 0x00
-#define GDB_STDOUT 0x01
-#define GDB_STDERR 0x02
-
-//
-//Define Register size for different architectures
-//
-#if defined (MDE_CPU_IA32)
-#define REG_SIZE 32
-#elif defined (MDE_CPU_X64)
-#define REG_SIZE 64
-#elif defined (MDE_CPU_ARM)
-#define REG_SIZE 32
-#endif
-
-
-typedef struct {
- EFI_EXCEPTION_TYPE Exception;
- UINT8 SignalNo;
-} EFI_EXCEPTION_TYPE_ENTRY;
-
-
-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
-
-//
-// Byte packed structure for DR6
-// 32-bits on IA-32
-// 64-bits on X64. The upper 32-bits on X64 are reserved
-//
-typedef union {
- struct {
- UINT32 B0:1; // Breakpoint condition detected
- UINT32 B1:1; // Breakpoint condition detected
- UINT32 B2:1; // Breakpoint condition detected
- UINT32 B3:1; // Breakpoint condition detected
- UINT32 Reserved_1:9; // Reserved
- UINT32 BD:1; // Debug register access detected
- UINT32 BS:1; // Single step
- UINT32 BT:1; // Task switch
- UINT32 Reserved_2:16; // Reserved
- } Bits;
- UINTN UintN;
-} IA32_DR6;
-
-//
-// Byte packed structure for DR7
-// 32-bits on IA-32
-// 64-bits on X64. The upper 32-bits on X64 are reserved
-//
-typedef union {
- struct {
- UINT32 L0:1; // Local breakpoint enable
- UINT32 G0:1; // Global breakpoint enable
- UINT32 L1:1; // Local breakpoint enable
- UINT32 G1:1; // Global breakpoint enable
- UINT32 L2:1; // Local breakpoint enable
- UINT32 G2:1; // Global breakpoint enable
- UINT32 L3:1; // Local breakpoint enable
- UINT32 G3:1; // Global breakpoint enable
- UINT32 LE:1; // Local exact breakpoint enable
- UINT32 GE:1; // Global exact breakpoint enable
- UINT32 Reserved_1:3; // Reserved
- UINT32 GD:1; // Global detect enable
- UINT32 Reserved_2:2; // Reserved
- UINT32 RW0:2; // Read/Write field
- UINT32 LEN0:2; // Length field
- UINT32 RW1:2; // Read/Write field
- UINT32 LEN1:2; // Length field
- UINT32 RW2:2; // Read/Write field
- UINT32 LEN2:2; // Length field
- UINT32 RW3:2; // Read/Write field
- UINT32 LEN3:2; // Length field
- } Bits;
- UINTN UintN;
-} IA32_DR7;
-
-#endif /* if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) */
-
-typedef enum {
- InstructionExecution, //Hardware breakpoint
- DataWrite, //watch
- DataRead, //rwatch
- DataReadWrite, //awatch
- SoftwareBreakpoint, //Software breakpoint
- NotSupported
-} BREAK_TYPE;
-
-//
-// Array of exception types that need to be hooked by the debugger
-//
-extern EFI_EXCEPTION_TYPE_ENTRY gExceptionType[];
-
-//
-// If the periodic callback is called while we are processing an F packet we need
-// to let the callback know to not read from the serail stream as it could steal
-// characters from the F reponse packet
-//
-extern BOOLEAN gProcessingFPacket;
-
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- );
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported,
- FALSE otherwise.
- **/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- );
-
-
-/**
- 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
-GdbSendTSignal (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINT8 GdbExceptionType
- );
-
-
-/**
- Translates the EFI mapping to GDB mapping
-
- @param EFIExceptionType EFI Exception that is being processed
- @retval UINTN that corresponds to EFIExceptionType's GDB exception type number
- **/
-UINT8
-ConvertEFItoGDBtype (
- IN EFI_EXCEPTION_TYPE EFIExceptionType
- );
-
-
-/**
- Empties the given buffer
- @param *Buf pointer to the first element in buffer to be emptied
- **/
-VOID
-EmptyBuffer (
- IN CHAR8 *Buf
- );
-
-
-/**
- Converts an 8-bit Hex Char into a INTN.
-
- @param Char - the hex character to be converted into UINTN
- @retval a INTN, from 0 to 15, that corressponds to Char
- -1 if Char is not a hex character
- **/
-INTN
-HexCharToInt (
- IN CHAR8 Char
- );
-
-
-/** 'E NN'
- Send an error with the given error number after converting to hex.
- The error number is put into the buffer in hex. '255' is the biggest errno we can send.
- ex: 162 will be sent as A2.
-
- @param errno the error number that will be sent
- **/
-VOID
-EFIAPI
-SendError (
- IN UINT8 ErrorNum
- );
-
-
-/**
- Send 'OK' when the function is done executing successfully.
- **/
-VOID
-SendSuccess (
- VOID
- );
-
-
-/**
- Send empty packet to specify that particular command/functionality is not supported.
- **/
-VOID
-SendNotSupported (
- VOID
- );
-
-/** ‘p n’
- Reads the n-th register's value into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- @param InBuffer This is the input buffer received from gdb server
- **/
-VOID
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- );
-
-
-/** ‘g’
- Reads the general registers into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- **/
-VOID
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
- @param SystemContext Register content at time of the exception
- @param InBuffer This is the input buffer received from gdb server
- **/
-VOID
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- );
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-
-VOID
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- );
-
-
-/** ‘m addr,length ’
- Find the Length of the area to read and the start addres. Finally, pass them to
- another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
- send it as a packet.
-
- @param *PacketData Pointer to Payload data for the packet
- **/
-VOID
-ReadFromMemory (
- IN CHAR8 *PacketData
- );
-
-
-/** ‘M addr,length :XX...’
- Find the Length of the area in bytes to write and the start addres. Finally, pass them to
- another function, TransferFromInBufToMem, that will write to that memory space the info in
- the input buffer.
-
- @param PacketData Pointer to Payload data for the packet
- **/
-VOID
-WriteToMemory (
- IN CHAR8 *PacketData
- );
-
-
-/** ‘c [addr ]’
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to PacketData
- **/
-
-VOID
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- @param PacketData Pointer to Payload data for the packet
- **/
-VOID
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-/**
- Insert Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-AddSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-/**
- Remove Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-RemoveSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- ‘Z1, [addr], [length]’
- ‘Z2, [addr], [length]’
- ‘Z3, [addr], [length]’
- ‘Z4, [addr], [length]’
-
- Insert hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-InsertBreakPoint(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-
-/**
- ‘z1, [addr], [length]’
- ‘z2, [addr], [length]’
- ‘z3, [addr], [length]’
- ‘z4, [addr], [length]’
-
- Remove hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-RemoveBreakPoint(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- );
-
-
-/**
- Exception Hanldler for GDB. It will be called for all exceptions
- registered via the gExceptionType[] array.
-
- @param ExceptionType Exception that is being processed
- @param SystemContext Register content at time of the exception
-
- **/
-VOID
-EFIAPI
-GdbExceptionHandler (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- Periodic callback for GDB. This function is used to catch a ctrl-c or other
- break in type command from GDB.
-
- @param SystemContext Register content at time of the call
-
- **/
-VOID
-EFIAPI
-GdbPeriodicCallBack (
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- Make two serail consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.
-
- These console show up on the remote system running GDB
-
-**/
-
-VOID
-GdbInitializeSerialConsole (
- VOID
- );
-
-
-/**
- Send a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up
- in an infinit loop. This is so if you unplug the debugger code just keeps running
-
- @param PacketData Payload data for the packet
-
- @retval Number of bytes of packet data sent.
-
-**/
-UINTN
-SendPacket (
- IN CHAR8 *PacketData
- );
-
-
-/**
- Receive a GDB Remote Serial Protocol Packet
-
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
- the packet teminating character '#' and the two digit checksum.
-
- If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed.
- (In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)
-
- If an ack '+' is not sent resend the packet
-
- @param PacketData Payload data for the packet
-
- @retval Number of bytes of packet data received.
-
- **/
-UINTN
-ReceivePacket (
- OUT CHAR8 *PacketData,
- IN UINTN PacketDataSize
- );
-
-
-/**
- Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates
- the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.
-
- @param FileDescriptor Device to talk to.
- @param Buffer Buffer to hold Count bytes that were read
- @param Count Number of bytes to transfer.
-
- @retval -1 Error
- @retval {other} Number of bytes read.
-
-**/
-INTN
-GdbRead (
- IN INTN FileDescriptor,
- OUT VOID *Buffer,
- IN UINTN Count
- );
-
-
-/**
- Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates
- nothing was written. On error -1 is returned.
-
- @param FileDescriptor Device to talk to.
- @param Buffer Buffer to hold Count bytes that are to be written
- @param Count Number of bytes to transfer.
-
- @retval -1 Error
- @retval {other} Number of bytes written.
-
-**/
-INTN
-GdbWrite (
- IN INTN FileDescriptor,
- OUT CONST VOID *Buffer,
- IN UINTN Count
- );
-
-UINTN *
-FindPointerToRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- );
-
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- );
-
-VOID
-TransferFromInBufToMem (
- IN UINTN Length,
- IN UINT8 *Address,
- IN CHAR8 *NewData
- );
-
-VOID
-TransferFromMemToOutBufAndSend (
- IN UINTN Length,
- IN UINT8 *Address
- );
-
-CHAR8 *
-BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- );
-
-VOID
-PrintReg (
- EFI_SYSTEM_CONTEXT SystemContext
- );
-
-UINTN
-ParseBreakpointPacket (
- IN CHAR8 *PacketData,
- OUT UINTN *Type,
- OUT UINTN *Address,
- OUT UINTN *Length
- );
-
-UINTN
-GetBreakpointDataAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- );
-
-UINTN
-GetBreakpointDetected (
- IN EFI_SYSTEM_CONTEXT SystemContext
- );
-
-BREAK_TYPE
-GetBreakpointType (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- );
-
-UINTN
-ConvertLengthData (
- IN UINTN Length
- );
-
-EFI_STATUS
-FindNextFreeDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT UINTN *Register
- );
-
-EFI_STATUS
-EnableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type
- );
-
-EFI_STATUS
-FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- );
-
-EFI_STATUS
-DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- );
-
-VOID
-InitializeProcessor (
- VOID
- );
-
-/**
- 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
- );
-
-/**
- Check to see if this exception is related to ctrl-c handling.
-
- @param ExceptionType Exception that is being processed
- @param SystemContext Register content at time of the exception
-
- @return TRUE This was a ctrl-c check that did not find a ctrl-c
- @return FALSE This was not a ctrl-c check or some one hit ctrl-c
- **/
-BOOLEAN
-ProcessorControlC (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- );
-
-
-/**
- Initialize debug agent.
-
- This function is used to set up debug enviroment. It may enable interrupts.
-
- @param[in] InitFlag Init flag is used to decide initialize process.
- @param[in] Context Context needed according to InitFlag, it was optional.
-
-**/
-VOID
-EFIAPI
-DebugAgentHookExceptions (
- IN UINT32 InitFlag,
- IN VOID *Context OPTIONAL
- );
-
-
-#endif
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf b/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf
deleted file mode 100755
index 02f80579b1..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf
+++ /dev/null
@@ -1,70 +0,0 @@
-#/** @file
-# Null instance of Debug Agent Library with empty functions.
-#
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = GdbDebugAgent
- FILE_GUID = b9f10c17-6ca0-40b5-9b44-6253cfc7d24b
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = DebugAgentLib
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- GdbDebugAgent.c
-
-[Sources.arm]
- Arm/Processor.c
- Arm/ExceptionSupport.ARMv6.S
- Arm/ExceptionSupport.ARMv6.asm
-
-[Sources.X64]
- Ia32/Processor.c
-
-[Sources.Ia32]
- X64/Processor.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[Packages.arm]
- ArmPkg/ArmPkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- BaseMemoryLib
- PcdLib
- GdbSerialLib
- CacheMaintenanceLib
- DebugAgentTimerLib
-
-[FeaturePcd.common]
- gEmbeddedTokenSpaceGuid.PcdGdbSerial
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdGdbMaxPacketRetryCount
- gEmbeddedTokenSpaceGuid.PcdGdbTimerPeriodMilliseconds
-
-[FixedPcd.arm]
- gArmTokenSpaceGuid.PcdCpuVectorBaseAddress
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/Ia32/Processor.c b/EmbeddedPkg/Library/GdbDebugAgent/Ia32/Processor.c
deleted file mode 100755
index d465b21183..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/Ia32/Processor.c
+++ /dev/null
@@ -1,951 +0,0 @@
-/** @file
- Processor specific parts of the GDB stub
-
- 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 <GdbDebugAgent.h>
-
-//
-// Array of exception types that need to be hooked by the debugger
-// {EFI mapping, GDB mapping}
-//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_IA32_DIVIDE_ERROR, GDB_SIGFPE },
- { EXCEPT_IA32_DEBUG, GDB_SIGTRAP },
- { EXCEPT_IA32_NMI, GDB_SIGEMT },
- { EXCEPT_IA32_BREAKPOINT, GDB_SIGTRAP },
- { EXCEPT_IA32_OVERFLOW, GDB_SIGSEGV },
- { EXCEPT_IA32_BOUND, GDB_SIGSEGV },
- { EXCEPT_IA32_INVALID_OPCODE, GDB_SIGILL },
- { EXCEPT_IA32_DOUBLE_FAULT, GDB_SIGEMT },
- { EXCEPT_IA32_STACK_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_GP_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_PAGE_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_FP_ERROR, GDB_SIGEMT },
- { EXCEPT_IA32_ALIGNMENT_CHECK, GDB_SIGEMT },
- { EXCEPT_IA32_MACHINE_CHECK, GDB_SIGEMT }
-};
-
-
-// The offsets of registers SystemContext.
-// The fields in the array are in the gdb ordering.
-//
-//16 regs
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eax),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ecx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Edx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ebx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Esp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ebp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Esi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Edi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eip),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eflags),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Cs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ss),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ds),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Es),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Fs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Gs)
-};
-
-
-//Debug only..
-VOID
-PrintReg (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- Print ((CHAR16 *)L"EAX: %x ", SystemContext.SystemContextIa32->Eax);
- Print ((CHAR16 *)L"ECX: %x ", SystemContext.SystemContextIa32->Ecx);
- Print ((CHAR16 *)L"EDX: %x ", SystemContext.SystemContextIa32->Edx);
- Print ((CHAR16 *)L"EBX: %x ", SystemContext.SystemContextIa32->Ebx);
- Print ((CHAR16 *)L"ESP: %x ", SystemContext.SystemContextIa32->Esp);
- Print ((CHAR16 *)L"EBP: %x ", SystemContext.SystemContextIa32->Ebp);
- Print ((CHAR16 *)L"ESI: %x ", SystemContext.SystemContextIa32->Esi);
- Print ((CHAR16 *)L"EDI: %x ", SystemContext.SystemContextIa32->Edi);
- Print ((CHAR16 *)L"EIP: %x\n", SystemContext.SystemContextIa32->Eip);
- Print ((CHAR16 *)L"EFlags: %x\n", SystemContext.SystemContextIa32->Eflags);
-}
-
-//Debug only..
-VOID
-PrintDRreg (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- Print ((CHAR16 *)L"DR0: %x ", SystemContext.SystemContextIa32->Dr0);
- Print ((CHAR16 *)L"DR1: %x ", SystemContext.SystemContextIa32->Dr1);
- Print ((CHAR16 *)L"DR2: %x ", SystemContext.SystemContextIa32->Dr2);
- Print ((CHAR16 *)L"DR3: %x ", SystemContext.SystemContextIa32->Dr3);
- Print ((CHAR16 *)L"DR6: %x ", SystemContext.SystemContextIa32->Dr6);
- Print ((CHAR16 *)L"DR7: %x\n", SystemContext.SystemContextIa32->Dr7);
-}
-
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- )
-{
- return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
-}
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported,
- FALSE otherwise.
-**/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- )
-{
- return (BOOLEAN)(Isa == IsaIa32);
-}
-
-
-/**
- This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
- It is, by default, set to find the register pointer of the IA32 member
-
- @param SystemContext Register content at time of the exception
- @param RegNumber The register to which we want to find a pointer
- @retval the pointer to the RegNumber-th pointer
- **/
-UINTN *
-FindPointerToRegister(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- )
-{
- UINT8 *TempPtr;
- TempPtr = ((UINT8 *)SystemContext.SystemContextIa32) + gRegisterOffsets[RegNumber];
- return (UINTN *)TempPtr;
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
-
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to read
- @param OutBufPtr pointer to the output buffer's end. the new data will be added from this point on.
- @retval the pointer to the next character of the output buffer that is available to be written on.
- **/
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- )
-{
- UINTN RegSize;
-
- RegSize = 0;
- while (RegSize < REG_SIZE) {
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
- RegSize = RegSize + 8;
- }
- return OutBufPtr;
-}
-
-
-/** ‘p n’
- Reads the n-th register's value into an output buffer and sends it as a packet
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
-
- if ((RegNumber < 0) || (RegNumber >= sizeof (gRegisterOffsets)/sizeof (UINTN))) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
-
- OutBufPtr = OutBuffer;
- OutBufPtr = BasicReadRegister(SystemContext, RegNumber, OutBufPtr);
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket(OutBuffer);
-}
-
-
-/** ‘g’
- Reads the general registers into an output buffer and sends it as a packet
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINTN i;
- CHAR8 OutBuffer[129]; // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- OutBufPtr = OutBuffer;
- for(i = 0 ; i < sizeof (gRegisterOffsets)/sizeof (UINTN) ; i++) { // there are only 16 registers to read
- OutBufPtr = BasicReadRegister(SystemContext, i, OutBufPtr);
- }
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket(OutBuffer);
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
-
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to write
- @param InBufPtr pointer to the output buffer. the new data will be extracted from the input buffer from this point on.
- @retval the pointer to the next character of the input buffer that can be used
- **/
-CHAR8 *
-BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- )
-{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT32 NewValue; // the new value of the RegNumber-th Register
-
- NewValue = 0;
- RegSize = 0;
- while (RegSize < REG_SIZE) {
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
- }
- *(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
- return InBufPtr;
-}
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Ponter to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
-
- // find the register number to write
- InBufPtr = &InBuffer[1];
- RegNumBufPtr = RegNumBuffer;
- while (*InBufPtr != '=') {
- *RegNumBufPtr++ = *InBufPtr++;
- }
- *RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
-
- // check if this is a valid Register Number
- if ((RegNumber < 0) || (RegNumber >= sizeof (gRegisterOffsets)/sizeof (UINTN))) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
- InBufPtr++; // skips the '=' character
- BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
-}
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- // check to see if the buffer is the right size which is
- // 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129
- if (AsciiStrLen(InBuffer) != 129) { // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
- //Bad message. Message is not the right length
- SendError (GDB_EBADBUFSIZE);
- return;
- }
-
- InBufPtr = &InBuffer[1];
-
- // Read the new values for the registers from the input buffer to an array, NewValueArray.
- // The values in the array are in the gdb ordering
- for(i=0; i < sizeof (gRegisterOffsets)/sizeof (UINTN); i++) { // there are only 16 registers to write
- InBufPtr = BasicWriteRegister(SystemContext, i, InBufPtr);
- }
-
- SendSuccess();
-}
-
-/** ‘c [addr ]’
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextIa32->Eip = AsciiStrHexToUintn (&PacketData[1]);
- }
-}
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- SendNotSupported();
-}
-
-
-/**
- Returns breakpoint data address from DR0-DR3 based on the input breakpoint number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval Address Data address from DR0-DR3 based on the breakpoint number.
-
-**/
-UINTN
-GetBreakpointDataAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- UINTN Address;
-
- if (BreakpointNumber == 1) {
- Address = SystemContext.SystemContextIa32->Dr0;
- } else if (BreakpointNumber == 2) {
- Address = SystemContext.SystemContextIa32->Dr1;
- } else if (BreakpointNumber == 3) {
- Address = SystemContext.SystemContextIa32->Dr2;
- } else if (BreakpointNumber == 4) {
- Address = SystemContext.SystemContextIa32->Dr3;
- } else {
- Address = 0;
- }
-
- return Address;
-}
-
-
-/**
- Returns currently detected breakpoint value based on the register DR6 B0-B3 field.
- If no breakpoint is detected then it returns 0.
-
- @param SystemContext Register content at time of the exception
-
- @retval {1-4} Currently detected breakpoint value
- @retval 0 No breakpoint detected.
-
-**/
-UINTN
-GetBreakpointDetected (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- IA32_DR6 Dr6;
- UINTN BreakpointNumber;
-
- Dr6.UintN = SystemContext.SystemContextIa32->Dr6;
-
- if (Dr6.Bits.B0 == 1) {
- BreakpointNumber = 1;
- } else if (Dr6.Bits.B1 == 1) {
- BreakpointNumber = 2;
- } else if (Dr6.Bits.B2 == 1) {
- BreakpointNumber = 3;
- } else if (Dr6.Bits.B3 == 1) {
- BreakpointNumber = 4;
- } else {
- BreakpointNumber = 0; //No breakpoint detected
- }
-
- return BreakpointNumber;
-}
-
-
-/**
- Returns Breakpoint type (InstructionExecution, DataWrite, DataRead or DataReadWrite)
- based on the Breakpoint number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval BREAK_TYPE Breakpoint type value read from register DR7 RWn field
- For unknown value, it returns NotSupported.
-
-**/
-BREAK_TYPE
-GetBreakpointType (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- IA32_DR7 Dr7;
- BREAK_TYPE Type = NotSupported; //Default is NotSupported type
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (BreakpointNumber == 1) {
- Type = (BREAK_TYPE) Dr7.Bits.RW0;
- } else if (BreakpointNumber == 2) {
- Type = (BREAK_TYPE) Dr7.Bits.RW1;
- } else if (BreakpointNumber == 3) {
- Type = (BREAK_TYPE) Dr7.Bits.RW2;
- } else if (BreakpointNumber == 4) {
- Type = (BREAK_TYPE) Dr7.Bits.RW3;
- }
-
- return Type;
-}
-
-
-/**
- Parses Length and returns the length which DR7 LENn field accepts.
- For example: If we receive 1-Byte length then we should return 0.
- Zero gets written to DR7 LENn field.
-
- @param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
-
- @retval Length Appropriate converted values which DR7 LENn field accepts.
-
-**/
-UINTN
-ConvertLengthData (
- IN UINTN Length
- )
-{
- if (Length == 1) { //1-Byte length
- return 0;
- } else if (Length == 2) { //2-Byte length
- return 1;
- } else if (Length == 4) { //4-Byte length
- return 3;
- } else { //Undefined or 8-byte length
- return 2;
- }
-}
-
-
-/**
- Finds the next free debug register. If all the registers are occupied then
- EFI_OUT_OF_RESOURCES is returned.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3 for the first free debug register)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindNextFreeDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Dr7.Bits.G0 == 0) {
- *Register = 0;
- } else if (Dr7.Bits.G1 == 0) {
- *Register = 1;
- } else if (Dr7.Bits.G2 == 0) {
- *Register = 2;
- } else if (Dr7.Bits.G3 == 0) {
- *Register = 3;
- } else {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Enables the debug register. Writes Address value to appropriate DR0-3 register.
- Sets LENn, Gn, RWn bits in DR7 register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3)
- @param Address Breakpoint address value
- @param Type Breakpoint type (Instruction, Data write, Data read
- or write etc.)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-EnableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type
- )
-{
- IA32_DR7 Dr7;
-
- //Convert length data
- Length = ConvertLengthData (Length);
-
- //For Instruction execution, length should be 0
- //(Ref. Intel reference manual 18.2.4)
- if ((Type == 0) && (Length != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 1;
- Dr7.Bits.RW0 = Type;
- Dr7.Bits.LEN0 = Length;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 1;
- Dr7.Bits.RW1 = Type;
- Dr7.Bits.LEN1 = Length;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 1;
- Dr7.Bits.RW2 = Type;
- Dr7.Bits.LEN2 = Length;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 1;
- Dr7.Bits.RW3 = Type;
- Dr7.Bits.LEN3 = Length;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update Dr7 with appropriate Gn, RWn and LENn bits
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Returns register number 0 - 3 for the maching debug register.
- This function compares incoming Address, Type, Length and
- if there is a match then it returns the appropriate register number.
- In case of mismatch, function returns EFI_NOT_FOUND message.
-
- @param SystemContext Register content at time of the exception
- @param Address Breakpoint address value
- @param Length Breakpoint length value
- @param Type Breakpoint type (Instruction, Data write,
- Data read or write etc.)
- @param Register Register value to be returned
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Convert length data
- Length = ConvertLengthData(Length);
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if ((Dr7.Bits.G0 == 1) &&
- (Dr7.Bits.LEN0 == Length) &&
- (Dr7.Bits.RW0 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr0)) {
- *Register = 0;
- } else if ((Dr7.Bits.G1 == 1) &&
- (Dr7.Bits.LEN1 == Length) &&
- (Dr7.Bits.RW1 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr1)) {
- *Register = 1;
- } else if ((Dr7.Bits.G2 == 1) &&
- (Dr7.Bits.LEN2 == Length) &&
- (Dr7.Bits.RW2 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr2)) {
- *Register = 2;
- } else if ((Dr7.Bits.G3 == 1) &&
- (Dr7.Bits.LEN3 == Length) &&
- (Dr7.Bits.RW3 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr3)) {
- *Register = 3;
- } else {
- Print ((CHAR16 *)L"No match found..\n");
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Disables the particular debug register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register to be disabled
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- )
-{
- IA32_DR7 Dr7;
- UINTN Address = 0;
-
- //Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 0;
- Dr7.Bits.RW0 = 0;
- Dr7.Bits.LEN0 = 0;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 0;
- Dr7.Bits.RW1 = 0;
- Dr7.Bits.LEN1 = 0;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 0;
- Dr7.Bits.RW2 = 0;
- Dr7.Bits.LEN2 = 0;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 0;
- Dr7.Bits.RW3 = 0;
- Dr7.Bits.LEN3 = 0;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- ‘Z1, [addr], [length]’
- ‘Z2, [addr], [length]’
- ‘Z3, [addr], [length]’
- ‘Z4, [addr], [length]’
-
- Insert hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-InsertBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- EFI_STATUS Status;
- BREAK_TYPE BreakType = NotSupported;
- UINTN ErrorCode;
-
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- Print ((CHAR16 *)L"Insert breakpoint default: %x\n", Type);
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- // Find next free debug register
- Status = FindNextFreeDebugRegister (SystemContext, &Register);
- if (EFI_ERROR(Status)) {
- Print ((CHAR16 *)L"No space left on device\n");
- SendError (GDB_ENOSPACE);
- return;
- }
-
- // Write Address, length data at particular DR register
- Status = EnableDebugRegister (SystemContext, Register, Address, Length, (UINTN)BreakType);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_UNSUPPORTED) {
- SendNotSupported();
- return;
- }
-
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-/**
- ‘z1, [addr], [length]’
- ‘z2, [addr], [length]’
- ‘z3, [addr], [length]’
- ‘z4, [addr], [length]’
-
- Remove hardware breakpoint/watchpoint at address addr of size length
-
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-RemoveBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- BREAK_TYPE BreakType = NotSupported;
- EFI_STATUS Status;
- UINTN ErrorCode;
-
- //Parse breakpoint packet data
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- //Find matching debug register
- Status = FindMatchingDebugRegister (SystemContext, Address, Length, (UINTN)BreakType, &Register);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_UNSUPPORTED) {
- SendNotSupported();
- return;
- }
-
- SendError (GDB_ENOSPACE);
- return;
- }
-
- //Remove breakpoint
- Status = DisableDebugRegister(SystemContext, Register);
- if (EFI_ERROR(Status)) {
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-/**
- Initialize debug agent.
-
- This function is used to set up debug environment to support source level debugging.
- If certain Debug Agent Library instance has to save some private data in the stack,
- this function must work on the mode that doesn't return to the caller, then
- the caller needs to wrap up all rest of logic after InitializeDebugAgent() into one
- function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is
- responsible to invoke the passing-in function at the end of InitializeDebugAgent().
-
- If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by
- passing in the Context to be its parameter.
-
- If Function() is NULL, Debug Agent Library instance will return after setup debug
- environment.
-
- @param[in] InitFlag Init flag is used to decide the initialize process.
- @param[in] Context Context needed according to InitFlag; it was optional.
- @param[in] Function Continue function called by debug agent library; it was
- optional.
-
-**/
-VOID
-EFIAPI
-InitializeDebugAgent (
- IN UINT32 InitFlag,
- IN VOID *Context, OPTIONAL
- IN DEBUG_AGENT_CONTINUE Function OPTIONAL
- )
-{
- // BugBug: Add the code to build an GDT/IDT
-
- if (Function != NULL) {
- Function (Context);
- }
-}
-
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/X64/Processor.c b/EmbeddedPkg/Library/GdbDebugAgent/X64/Processor.c
deleted file mode 100755
index cbe50d78ec..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/X64/Processor.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/** @file
- Processor specific parts of the GDB stub
-
- 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 <GdbStubInternal.h>
-
-//
-// Array of exception types that need to be hooked by the debugger
-//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_X64_DIVIDE_ERROR, GDB_SIGFPE },
- { EXCEPT_X64_DEBUG, GDB_SIGTRAP },
- { EXCEPT_X64_NMI, GDB_SIGEMT },
- { EXCEPT_X64_BREAKPOINT, GDB_SIGTRAP },
- { EXCEPT_X64_OVERFLOW, GDB_SIGSEGV },
- { EXCEPT_X64_BOUND, GDB_SIGSEGV },
- { EXCEPT_X64_INVALID_OPCODE, GDB_SIGILL },
- { EXCEPT_X64_DOUBLE_FAULT, GDB_SIGEMT },
- { EXCEPT_X64_STACK_FAULT, GDB_SIGSEGV },
- { EXCEPT_X64_GP_FAULT, GDB_SIGSEGV },
- { EXCEPT_X64_PAGE_FAULT, GDB_SIGSEGV },
- { EXCEPT_X64_FP_ERROR, GDB_SIGEMT },
- { EXCEPT_X64_ALIGNMENT_CHECK, GDB_SIGEMT },
- { EXCEPT_X64_MACHINE_CHECK, GDB_SIGEMT }
-};
-
-
-// The offsets of registers SystemContextX64.
-// The fields in the array are in the gdb ordering.
-// HAVE TO DOUBLE-CHECK THE ORDER of the 24 regs
-//
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rax),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rcx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rdx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rbx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rsp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rbp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rsi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rdi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rip),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rflags),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Cs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Ss),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Ds),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Es),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Fs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Gs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R8),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R9),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R10),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R11),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R12),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R13),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R14),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R15)
-};
-
-
-/**
- Return the number of entries in the gExceptionType[]
-
- @retval UINTN, the number of entries in the gExceptionType[] array.
- **/
-UINTN
-MaxEfiException (
- VOID
- )
-{
- return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
-}
-
-
-/**
- Return the number of entries in the gRegisters[]
-
- @retval UINTN, the number of entries (registers) in the gRegisters[] array.
- **/
-UINTN
-MaxRegisterCount (
- VOID
- )
-{
- return sizeof (gRegisterOffsets)/sizeof (UINTN);
-}
-
-
-/**
- Check to see if the ISA is supported.
- ISA = Instruction Set Architecture
-
- @retval TRUE if Isa is supported
-**/
-BOOLEAN
-CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
- )
-{
- return (BOOLEAN)(Isa == IsaX64);
-}
-
-
-/**
- This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
- It is, by default, set to find the register pointer of the X64 member
- @param SystemContext Register content at time of the exception
- @param RegNumber The register to which we want to find a pointer
- @retval the pointer to the RegNumber-th pointer
- **/
-UINTN *
-FindPointerToRegister(
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
- )
-{
- UINT8 *TempPtr;
- TempPtr = ((UINT8 *)SystemContext.SystemContextX64) + gRegisterOffsets[RegNumber];
- return (UINTN *)TempPtr;
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to read
- @param OutBufPtr pointer to the output buffer's end. the new data will be added from this point on.
- @retval the pointer to the next character of the output buffer that is available to be written on.
- **/
-CHAR8 *
-BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
- )
-{
- UINTN RegSize;
-
- RegSize = 0;
- while (RegSize < 64) {
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
- RegSize = RegSize + 8;
- }
- return OutBufPtr;
-}
-
-
-/** ‘p n’
- Reads the n-th register's value into an output buffer and sends it as a packet
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 OutBuffer[17]; // 1 reg=16 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
-
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
-
- OutBufPtr = OutBuffer;
- OutBufPtr = BasicReadRegister(SystemContext, RegNumber, OutBufPtr);
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket (OutBuffer);
-}
-
-
-/** ‘g’
- Reads the general registers into an output buffer and sends it as a packet
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINTN i;
- CHAR8 OutBuffer[385]; // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
-
- OutBufPtr = OutBuffer;
- for(i = 0 ; i < MaxRegisterCount() ; i++) { // there are only 24 registers to read
- OutBufPtr = BasicReadRegister(SystemContext, i, OutBufPtr);
- }
-
- *OutBufPtr = '\0'; // the end of the buffer
- SendPacket (OutBuffer);
-}
-
-
-/**
- Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
-
- @param SystemContext Register content at time of the exception
- @param RegNumber the number of the register that we want to write
- @param InBufPtr pointer to the output buffer. the new data will be extracted from the input buffer from this point on.
- @retval the pointer to the next character of the input buffer that can be used
- **/
-CHAR8 *
-BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
- )
-{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT64 NewValue; // the new value of the RegNumber-th Register
-
- NewValue = 0;
- RegSize = 0;
- while (RegSize < 64) {
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt(*InBufPtr++);
-
- if (TempValue < 0) {
- SendError (GDB_EBADMEMDATA);
- return NULL;
- }
-
- NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
- }
- *(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
- return InBufPtr;
-}
-
-
-/** ‘P n...=r...’
- Writes the new value of n-th register received into the input buffer to the n-th register
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Ponter to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
-
- // find the register number to write
- InBufPtr = &InBuffer[1];
- RegNumBufPtr = RegNumBuffer;
- while (*InBufPtr != '=') {
- *RegNumBufPtr++ = *InBufPtr++;
- }
- *RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
-
- // check if this is a valid Register Number
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
- SendError (GDB_EINVALIDREGNUM);
- return;
- }
- InBufPtr++; // skips the '=' character
- BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
-}
-
-
-/** ‘G XX...’
- Writes the new values received into the input buffer to the general registers
-
- @param SystemContext Register content at time of the exception
- @param InBuffer Pointer to the input buffer received from gdb server
- **/
-VOID
-EFIAPI
-WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
- )
-{
- UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- // check to see if the buffer is the right size which is
- // 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 385
- if (AsciiStrLen(InBuffer) != 385) { // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
- //Bad message. Message is not the right length
- SendError (GDB_EBADBUFSIZE);
- return;
- }
-
- InBufPtr = &InBuffer[1];
-
- // Read the new values for the registers from the input buffer to an array, NewValueArray.
- // The values in the array are in the gdb ordering
- for(i=0; i < MaxRegisterCount(); i++) { // there are only 16 registers to write
- InBufPtr = BasicWriteRegister(SystemContext, i, InBufPtr);
- }
-
- SendSuccess();
-}
-
-
- /**
- Insert Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-AddSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- SystemContext.SystemContextX64->Rflags |= TF_BIT; //Setting the TF bit.
-}
-
-
-
-/**
- Remove Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-RemoveSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- SystemContext.SystemContextX64->Rflags &= ~TF_BIT; // clearing the TF bit.
-}
-
-
-
-/** ‘c [addr ]’
- Continue. addr is Address to resume. If addr is omitted, resume at current
- Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn(&PacketData[1]);
- }
-}
-
-
-/** ‘s [addr ]’
- Single step. addr is the Address at which to resume. If addr is omitted, resume
- at same Address.
-
- @param SystemContext Register content at time of the exception
- **/
-VOID
-EFIAPI
-SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- if (PacketData[1] != '\0') {
- SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn (&PacketData[1]);
- }
-
- AddSingleStep (SystemContext);
-}
-
-
-/**
- Returns breakpoint data address from DR0-DR3 based on the input breakpoint
- number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval Address Data address from DR0-DR3 based on the
- breakpoint number.
-
-**/
-UINTN
-GetBreakpointDataAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- UINTN Address;
-
- if (BreakpointNumber == 1) {
- Address = SystemContext.SystemContextIa32->Dr0;
- } else if (BreakpointNumber == 2) {
- Address = SystemContext.SystemContextIa32->Dr1;
- } else if (BreakpointNumber == 3) {
- Address = SystemContext.SystemContextIa32->Dr2;
- } else if (BreakpointNumber == 4) {
- Address = SystemContext.SystemContextIa32->Dr3;
- } else {
- Address = 0;
- }
-
- return Address;
-}
-
-/**
- Returns currently detected breakpoint value based on the register
- DR6 B0-B3 field.
- If no breakpoint is detected then it returns 0.
-
- @param SystemContext Register content at time of the exception
-
- @retval {1-4} Currently detected breakpoint value
- @retval 0 No breakpoint detected.
-
-**/
-UINTN
-GetBreakpointDetected (
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- IA32_DR6 Dr6;
- UINTN BreakpointNumber;
-
- Dr6.UintN = SystemContext.SystemContextIa32->Dr6;
-
- if (Dr6.Bits.B0 == 1) {
- BreakpointNumber = 1;
- } else if (Dr6.Bits.B1 == 1) {
- BreakpointNumber = 2;
- } else if (Dr6.Bits.B2 == 1) {
- BreakpointNumber = 3;
- } else if (Dr6.Bits.B3 == 1) {
- BreakpointNumber = 4;
- } else {
- BreakpointNumber = 0; //No breakpoint detected
- }
-
- return BreakpointNumber;
-}
-
-/**
- Returns Breakpoint type (InstructionExecution, DataWrite, DataRead
- or DataReadWrite) based on the Breakpoint number
-
- @param SystemContext Register content at time of the exception
- @param BreakpointNumber Breakpoint number
-
- @retval BREAK_TYPE Breakpoint type value read from register DR7 RWn
- field. For unknown value, it returns NotSupported.
-
-**/
-BREAK_TYPE
-GetBreakpointType (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN BreakpointNumber
- )
-{
- IA32_DR7 Dr7;
- BREAK_TYPE Type = NotSupported; //Default is NotSupported type
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (BreakpointNumber == 1) {
- Type = (BREAK_TYPE) Dr7.Bits.RW0;
- } else if (BreakpointNumber == 2) {
- Type = (BREAK_TYPE) Dr7.Bits.RW1;
- } else if (BreakpointNumber == 3) {
- Type = (BREAK_TYPE) Dr7.Bits.RW2;
- } else if (BreakpointNumber == 4) {
- Type = (BREAK_TYPE) Dr7.Bits.RW3;
- }
-
- return Type;
-}
-
-
-/**
- Parses Length and returns the length which DR7 LENn field accepts.
- For example: If we receive 1-Byte length then we should return 0.
- Zero gets written to DR7 LENn field.
-
- @param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
-
- @retval Length Appropriate converted values which DR7 LENn field accepts.
-
-**/
-UINTN
-ConvertLengthData (
- IN UINTN Length
- )
-{
- if (Length == 1) { //1-Byte length
- return 0;
- } else if (Length == 2) { //2-Byte length
- return 1;
- } else if (Length == 4) { //4-Byte length
- return 3;
- } else { //Undefined or 8-byte length
- return 2;
- }
-}
-
-
-/**
- Finds the next free debug register. If all the registers are occupied then
- EFI_OUT_OF_RESOURCES is returned.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3 for the first free debug register)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindNextFreeDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Dr7.Bits.G0 == 0) {
- *Register = 0;
- } else if (Dr7.Bits.G1 == 0) {
- *Register = 1;
- } else if (Dr7.Bits.G2 == 0) {
- *Register = 2;
- } else if (Dr7.Bits.G3 == 0) {
- *Register = 3;
- } else {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Enables the debug register. Writes Address value to appropriate DR0-3 register.
- Sets LENn, Gn, RWn bits in DR7 register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register value (0 - 3)
- @param Address Breakpoint address value
- @param Type Breakpoint type (Instruction, Data write,
- Data read or write etc.)
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-EnableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type
- )
-{
- IA32_DR7 Dr7;
-
- //Convert length data
- Length = ConvertLengthData (Length);
-
- //For Instruction execution, length should be 0
- //(Ref. Intel reference manual 18.2.4)
- if ((Type == 0) && (Length != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 1;
- Dr7.Bits.RW0 = Type;
- Dr7.Bits.LEN0 = Length;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 1;
- Dr7.Bits.RW1 = Type;
- Dr7.Bits.LEN1 = Length;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 1;
- Dr7.Bits.RW2 = Type;
- Dr7.Bits.LEN2 = Length;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 1;
- Dr7.Bits.RW3 = Type;
- Dr7.Bits.LEN3 = Length;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update Dr7 with appropriate Gn, RWn and LENn bits
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Returns register number 0 - 3 for the maching debug register.
- This function compares incoming Address, Type, Length and
- if there is a match then it returns the appropriate register number.
- In case of mismatch, function returns EFI_NOT_FOUND message.
-
- @param SystemContext Register content at time of the exception
- @param Address Breakpoint address value
- @param Length Breakpoint length value
- @param Type Breakpoint type (Instruction, Data write, Data read
- or write etc.)
- @param Register Register value to be returned
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- )
-{
- IA32_DR7 Dr7;
-
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
- if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
- return EFI_UNSUPPORTED;
- }
-
- //Convert length data
- Length = ConvertLengthData(Length);
-
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if ((Dr7.Bits.G0 == 1) &&
- (Dr7.Bits.LEN0 == Length) &&
- (Dr7.Bits.RW0 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr0)) {
- *Register = 0;
- } else if ((Dr7.Bits.G1 == 1) &&
- (Dr7.Bits.LEN1 == Length) &&
- (Dr7.Bits.RW1 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr1)) {
- *Register = 1;
- } else if ((Dr7.Bits.G2 == 1) &&
- (Dr7.Bits.LEN2 == Length) &&
- (Dr7.Bits.RW2 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr2)) {
- *Register = 2;
- } else if ((Dr7.Bits.G3 == 1) &&
- (Dr7.Bits.LEN3 == Length) &&
- (Dr7.Bits.RW3 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr3)) {
- *Register = 3;
- } else {
- Print ((CHAR16 *)L"No match found..\n");
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Disables the particular debug register.
-
- @param SystemContext Register content at time of the exception
- @param Register Register to be disabled
-
- @retval EFI_STATUS Appropriate status value.
-
-**/
-EFI_STATUS
-DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- )
-{
- IA32_DR7 Dr7;
- UINTN Address = 0;
-
- //Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
-
- if (Register == 0) {
- SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 0;
- Dr7.Bits.RW0 = 0;
- Dr7.Bits.LEN0 = 0;
- } else if (Register == 1) {
- SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 0;
- Dr7.Bits.RW1 = 0;
- Dr7.Bits.LEN1 = 0;
- } else if (Register == 2) {
- SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 0;
- Dr7.Bits.RW2 = 0;
- Dr7.Bits.LEN2 = 0;
- } else if (Register == 3) {
- SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 0;
- Dr7.Bits.RW3 = 0;
- Dr7.Bits.LEN3 = 0;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- //Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
- SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
-
- return EFI_SUCCESS;
-}
-
-/**
- ‘Z1, [addr], [length]’
- ‘Z2, [addr], [length]’
- ‘Z3, [addr], [length]’
- ‘Z4, [addr], [length]’
-
- Insert hardware breakpoint/watchpoint at address addr of size length
-
- @param SystemContext Register content at time of the exception
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-InsertBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- EFI_STATUS Status;
- BREAK_TYPE BreakType = NotSupported;
- UINTN ErrorCode;
-
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- Print ((CHAR16 *)L"Insert breakpoint default: %x\n", Type);
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- // Find next free debug register
- Status = FindNextFreeDebugRegister (SystemContext, &Register);
- if (EFI_ERROR(Status)) {
- Print ((CHAR16 *)L"No space left on device\n");
- SendError (GDB_ENOSPACE);
- return;
- }
-
- // Write Address, length data at particular DR register
- Status = EnableDebugRegister (SystemContext, Register, Address, Length, (UINTN)BreakType);
- if (EFI_ERROR(Status)) {
-
- if (Status == EFI_UNSUPPORTED) {
- Print ((CHAR16 *)L"Not supported\n");
- SendNotSupported();
- return;
- }
-
- Print ((CHAR16 *)L"Invalid argument\n");
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-/**
- ‘z1, [addr], [length]’
- ‘z2, [addr], [length]’
- ‘z3, [addr], [length]’
- ‘z4, [addr], [length]’
-
- Remove hardware breakpoint/watchpoint at address addr of size length
-
- @param *PacketData Pointer to the Payload data for the packet
-
-**/
-VOID
-EFIAPI
-RemoveBreakPoint (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
- )
-{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- BREAK_TYPE BreakType = NotSupported;
- EFI_STATUS Status;
- UINTN ErrorCode;
-
- //Parse breakpoint packet data
- ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
- if (ErrorCode > 0) {
- SendError ((UINT8)ErrorCode);
- return;
- }
-
- switch (Type) {
-
- case 0: //Software breakpoint
- BreakType = SoftwareBreakpoint;
- break;
-
- case 1: //Hardware breakpoint
- BreakType = InstructionExecution;
- break;
-
- case 2: //Write watchpoint
- BreakType = DataWrite;
- break;
-
- case 3: //Read watchpoint
- BreakType = DataRead;
- break;
-
- case 4: //Access watchpoint
- BreakType = DataReadWrite;
- break;
-
- default :
- SendError (GDB_EINVALIDBRKPOINTTYPE);
- return;
- }
-
- //Find matching debug register
- Status = FindMatchingDebugRegister (SystemContext, Address, Length, (UINTN)BreakType, &Register);
- if (EFI_ERROR(Status)) {
-
- if (Status == EFI_UNSUPPORTED) {
- Print ((CHAR16 *)L"Not supported.\n");
- SendNotSupported();
- return;
- }
-
- Print ((CHAR16 *)L"No matching register found.\n");
- SendError (GDB_ENOSPACE);
- return;
- }
-
- //Remove breakpoint
- Status = DisableDebugRegister(SystemContext, Register);
- if (EFI_ERROR(Status)) {
- Print ((CHAR16 *)L"Invalid argument.\n");
- SendError (GDB_EINVALIDARG);
- return;
- }
-
- SendSuccess ();
-}
-
-
-VOID
-InitializeProcessor (
- VOID
- )
-{
-}
-
-BOOLEAN
-ValidateAddress (
- IN VOID *Address
- )
-{
- return TRUE;
-}
-
-BOOLEAN
-ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- return TRUE;
-}
-
diff --git a/EmbeddedPkg/Library/GdbDebugAgent/gdbnotes.txt b/EmbeddedPkg/Library/GdbDebugAgent/gdbnotes.txt
deleted file mode 100755
index 287b09e6a8..0000000000
--- a/EmbeddedPkg/Library/GdbDebugAgent/gdbnotes.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-arm-none-eabi-gcc -march=armv7-a -mthumb t.c -Wl,-nostdlib --emit-relocs
-
-target remote com7
-set debug remote 1
-set remotetimeout 30
-set remotelogfile log.txt
-add-symbol-file c:/work/edk2/Build/BeagleBoard/DEBUG_GCC48/ARM/BeagleBoardPkg/Sec/Sec/DEBUG/BeagleBoardSec.dll 0x80008360
-
-
-qSupported
-Hg0
-
-Hc-1
-qC
-qAttached \ No newline at end of file
diff --git a/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c b/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c
deleted file mode 100644
index e3d1b47cc4..0000000000
--- a/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/** @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.
-
-**/
-
-#include <Uefi.h>
-#include <Library/GdbSerialLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include <Protocol/DebugPort.h>
-
-
-EFI_DEBUGPORT_PROTOCOL *gDebugPort = NULL;
-UINTN gTimeOut = 0;
-
-/**
- The constructor function initializes the UART.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-RETURN_STATUS
-EFIAPI
-GdbSerialLibDebugPortConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **)&gDebugPort);
- if (!EFI_ERROR (Status)) {
- gTimeOut = PcdGet32 (PcdGdbMaxPacketRetryCount);
- gDebugPort->Reset (gDebugPort);
- }
-
- return Status;
-}
-
-
-
-/**
- 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
- )
-{
- EFI_STATUS Status;
-
- Status = gDebugPort->Reset (gDebugPort);
- return Status;
-}
-
-
-/**
- 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
- )
-{
- EFI_STATUS Status;
-
- Status = gDebugPort->Poll (gDebugPort);
-
- return (Status == EFI_SUCCESS ? TRUE : FALSE);
-}
-
-
-/**
- Get a character from GDB. This function must be able to run in interrupt context.
-
- @return A character from GDB
-
-**/
-CHAR8
-EFIAPI
-GdbGetChar (
- VOID
- )
-{
- EFI_STATUS Status;
- CHAR8 Char;
- UINTN BufferSize;
-
- do {
- BufferSize = sizeof (Char);
- Status = gDebugPort->Read (gDebugPort, gTimeOut, &BufferSize, &Char);
- } while (EFI_ERROR (Status) || BufferSize != sizeof (Char));
-
- return Char;
-}
-
-
-/**
- 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
- )
-{
- EFI_STATUS Status;
- UINTN BufferSize;
-
- do {
- BufferSize = sizeof (Char);
- Status = gDebugPort->Write (gDebugPort, gTimeOut, &BufferSize, &Char);
- } while (EFI_ERROR (Status) || BufferSize != sizeof (Char));
-
- return;
-}
-
-/**
- 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
- )
-{
- // We could performance enhance this function by calling gDebugPort->Write ()
- while (*String != '\0') {
- GdbPutChar (*String);
- String++;
- }
-}
-
-
-
-
diff --git a/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf b/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf
deleted file mode 100644
index b7c289c5a3..0000000000
--- a/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf
+++ /dev/null
@@ -1,49 +0,0 @@
-#/** @file
-# Component description file for Base PCI Cf8 Library.
-#
-# PCI CF8 Library that uses I/O ports 0xCF8 and 0xCFC to perform PCI Configuration cycles.
-# Layers on top of an I/O Library instance.
-# 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]
- INF_VERSION = 0x00010005
- BASE_NAME = GdbSerialDebugPortLib
- FILE_GUID = 42ABB10A-660A-4BEC-AEFA-CC94AB4D993D
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = GdbSerialLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
-
- CONSTRUCTOR = GdbSerialLibDebugPortConstructor
-
-
-[Sources.common]
- GdbSerialDebugPortLib.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- DebugLib
- IoLib
-
-[Protocols.common]
- gEfiDebugPortProtocolGuid
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdGdbBaudRate|115200
- gEmbeddedTokenSpaceGuid.PcdGdbDataBits|8
- gEmbeddedTokenSpaceGuid.PcdGdbParity|1
- gEmbeddedTokenSpaceGuid.PcdGdbStopBits|1
- gEmbeddedTokenSpaceGuid.PcdGdbMaxPacketRetryCount
diff --git a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c b/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
deleted file mode 100644
index 7ea976ff9d..0000000000
--- a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/** @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.
-
-**/
-
-#include <Uefi.h>
-#include <Library/GdbSerialLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/DebugLib.h>
-
-
-//---------------------------------------------
-// UART Register Offsets
-//---------------------------------------------
-#define BAUD_LOW_OFFSET 0x00
-#define BAUD_HIGH_OFFSET 0x01
-#define IER_OFFSET 0x01
-#define LCR_SHADOW_OFFSET 0x01
-#define FCR_SHADOW_OFFSET 0x02
-#define IR_CONTROL_OFFSET 0x02
-#define FCR_OFFSET 0x02
-#define EIR_OFFSET 0x02
-#define BSR_OFFSET 0x03
-#define LCR_OFFSET 0x03
-#define MCR_OFFSET 0x04
-#define LSR_OFFSET 0x05
-#define MSR_OFFSET 0x06
-
-//---------------------------------------------
-// UART Register Bit Defines
-//---------------------------------------------
-#define LSR_TXRDY 0x20
-#define LSR_RXDA 0x01
-#define DLAB 0x01
-#define ENABLE_FIFO 0x01
-#define CLEAR_FIFOS 0x06
-
-
-
-// IO Port Base for the UART
-UINTN gPort;
-
-
-/**
- The constructor function initializes the UART.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-RETURN_STATUS
-EFIAPI
-GdbSerialLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- UINT64 BaudRate;
- UINT8 DataBits;
- UINT8 Parity;
- UINT8 StopBits;
-
- gPort = (UINTN)PcdGet32 (PcdGdbUartPort);
-
- BaudRate = PcdGet64 (PcdGdbBaudRate);
- Parity = PcdGet8 (PcdGdbParity);
- DataBits = PcdGet8 (PcdGdbDataBits);
- StopBits = PcdGet8 (PcdGdbStopBits);
-
- return GdbSerialInit (BaudRate, Parity, DataBits, StopBits);
-}
-
-
-
-/**
- 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
- )
-{
- UINTN Divisor;
- UINT8 OutputData;
- UINT8 Data;
- UINT8 BreakSet = 0;
-
- //
- // We assume the UART has been turned on to decode gPort address range
- //
-
- //
- // Map 5..8 to 0..3
- //
- Data = (UINT8) (DataBits - (UINT8)5);
-
- //
- // Calculate divisor for baud generator
- //
- Divisor = 115200/(UINTN)BaudRate;
-
- //
- // Set communications format
- //
- OutputData = (UINT8)((DLAB << 7) | ((BreakSet << 6) | ((Parity << 3) | ((StopBits << 2) | Data))));
- IoWrite8 (gPort + LCR_OFFSET, OutputData);
-
- //
- // Configure baud rate
- //
- IoWrite8 (gPort + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8));
- IoWrite8 (gPort + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff));
-
-
- //
- // Switch back to bank 0
- //
- OutputData = (UINT8)((~DLAB<<7)|((BreakSet<<6)|((Parity<<3)|((StopBits<<2)| Data))));
- IoWrite8 (gPort + LCR_OFFSET, OutputData);
-
- // Not sure this is the right place to enable the FIFOs....
- // We probably need the FIFO enabled to not drop input
- IoWrite8 (gPort + FCR_SHADOW_OFFSET, ENABLE_FIFO);
-
-
- // Configure the UART hardware here
- return RETURN_SUCCESS;
-}
-
-
-/**
- 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
- )
-{
- UINT8 Data;
-
- Data = IoRead8 (gPort + LSR_OFFSET);
-
- return ((Data & LSR_RXDA) == LSR_RXDA);
-}
-
-
-/**
- Get a character from GDB. This function must be able to run in interrupt context.
-
- @return A character from GDB
-
-**/
-CHAR8
-EFIAPI
-GdbGetChar (
- VOID
- )
-{
- UINT8 Data;
- CHAR8 Char;
-
- // Wait for the serial port to be ready
- do {
- Data = IoRead8 (gPort + LSR_OFFSET);
- } while ((Data & LSR_RXDA) == 0);
-
- Char = IoRead8 (gPort);
-
- // Make this an EFI_D_INFO after we get everything debugged.
- DEBUG ((EFI_D_ERROR, "<%c<", Char));
- return Char;
-}
-
-
-/**
- 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
- )
-{
- UINT8 Data;
-
- // Make this an EFI_D_INFO after we get everything debugged.
- DEBUG ((EFI_D_ERROR, ">%c>", Char));
-
- // Wait for the serial port to be ready
- do {
- Data = IoRead8 (gPort + LSR_OFFSET);
- } while ((Data & LSR_TXRDY) == 0);
-
- IoWrite8 (gPort, 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
- )
-{
- while (*String != '\0') {
- GdbPutChar (*String);
- String++;
- }
-}
-
-
-
-
diff --git a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf b/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf
deleted file mode 100644
index fed36b059d..0000000000
--- a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf
+++ /dev/null
@@ -1,46 +0,0 @@
-#/** @file
-# Component description file for Base PCI Cf8 Library.
-#
-# PCI CF8 Library that uses I/O ports 0xCF8 and 0xCFC to perform PCI Configuration cycles.
-# Layers on top of an I/O Library instance.
-# 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]
- INF_VERSION = 0x00010005
- BASE_NAME = GdbSerialLib
- FILE_GUID = 9999B4EE-081F-4501-AEDC-137A534BAF69
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = GdbSerialLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
-
- CONSTRUCTOR = GdbSerialLibConstructor
-
-
-[Sources.common]
- GdbSerialLib.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- DebugLib
- IoLib
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdGdbBaudRate|115200
- gEmbeddedTokenSpaceGuid.PcdGdbDataBits|8
- gEmbeddedTokenSpaceGuid.PcdGdbParity|1
- gEmbeddedTokenSpaceGuid.PcdGdbStopBits|1
- gEmbeddedTokenSpaceGuid.PcdGdbUartPort
diff --git a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Capsule.c b/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Capsule.c
deleted file mode 100644
index ec89cfdeec..0000000000
--- a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Capsule.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/** @file
- Generic Capsule services
-
- 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 <Common/CapsuleName.h>
-
-
-//
-//Max size capsule services support are platform policy,to populate capsules we just need
-//memory to maintain them across reset,it is not a problem. And to special capsules ,for
-//example,update flash,it is mostly decided by the platform. Here is a sample size for
-//different type capsules.
-//
-#define MAX_SIZE_POPULATE (0)
-#define MAX_SIZE_NON_POPULATE (0)
-#define MAX_SUPPORT_CAPSULE_NUM 0x10
-
-
-BOOLEAN
-EFIAPI
-SupportUpdateCapsuleRest (
- VOID
- )
-{
- //
- //If the platform has a way to guarantee the memory integrity across a system reset, return
- //TRUE, else FALSE.
- //
- return FALSE;
-}
-
-
-
-VOID
-EFIAPI
-SupportCapsuleSize (
- IN OUT UINT32 *MaxSizePopulate,
- IN OUT UINT32 *MaxSizeNonPopulate
- )
-{
- //
- //Here is a sample size, different platforms have different sizes.
- //
- *MaxSizePopulate = MAX_SIZE_POPULATE;
- *MaxSizeNonPopulate = MAX_SIZE_NON_POPULATE;
- return;
-}
-
-
-
-
-EFI_STATUS
-LibUpdateCapsule (
- IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
- IN UINTN CapsuleCount,
- IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
- )
-/*++
-
-Routine Description:
-
- This code finds if the capsule needs reset to update, if no, update immediately.
-
-Arguments:
-
- CapsuleHeaderArray A array of pointers to capsule headers passed in
- CapsuleCount The number of capsule
- ScatterGatherList Physical address of datablock list points to capsule
-
-Returns:
-
- EFI STATUS
- EFI_SUCCESS Valid capsule was passed.If CAPSULE_FLAG_PERSIT_ACROSS_RESET is
- not set, the capsule has been successfully processed by the firmware.
- If it set, the ScattlerGatherList is successfully to be set.
- EFI_INVALID_PARAMETER CapsuleCount is less than 1,CapsuleGuid is not supported.
- EFI_DEVICE_ERROR Failed to SetVariable or AllocatePool or ProcessFirmwareVolume.
-
---*/
-{
- UINTN CapsuleSize;
- UINTN ArrayNumber;
- VOID *BufferPtr;
- EFI_STATUS Status;
- EFI_HANDLE FvHandle;
- UEFI_CAPSULE_HEADER *CapsuleHeader;
-
- if ((CapsuleCount < 1) || (CapsuleCount > MAX_SUPPORT_CAPSULE_NUM)){
- return EFI_INVALID_PARAMETER;
- }
-
- BufferPtr = NULL;
- CapsuleHeader = NULL;
-
- //
- //Compare GUIDs with EFI_CAPSULE_GUID, if capsule header contains CAPSULE_FLAGS_PERSIST_ACROSS_RESET
- //and CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE flags,whatever the GUID is ,the service supports.
- //
- for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {
- CapsuleHeader = CapsuleHeaderArray[ArrayNumber];
- if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)) == CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) {
- return EFI_INVALID_PARAMETER;
- }
- if (!CompareGuid (&CapsuleHeader->CapsuleGuid, &gEfiCapsuleGuid)) {
- if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {
- return EFI_UNSUPPORTED;
- }
- }
- }
-
- //
- //Assume that capsules have the same flags on reseting or not.
- //
- CapsuleHeader = CapsuleHeaderArray[0];
-
- if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
- //
- //Check if the platform supports update capsule across a system reset
- //
- if (!SupportUpdateCapsuleRest()) {
- return EFI_UNSUPPORTED;
- }
-
- if (ScatterGatherList == 0) {
- return EFI_INVALID_PARAMETER;
- } else {
- Status = EfiSetVariable (
- EFI_CAPSULE_VARIABLE_NAME,
- &gEfiCapsuleVendorGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (UINTN),
- (VOID *) &ScatterGatherList
- );
- if (Status != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- }
- return EFI_SUCCESS;
- }
-
- //
- //The rest occurs in the condition of non-reset mode
- //
- if (EfiAtRuntime ()) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- //Here should be in the boot-time
- //
- for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {
- CapsuleHeader = CapsuleHeaderArray[ArrayNumber];
- CapsuleSize = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize;
- Status = gBS->AllocatePool (EfiBootServicesData, CapsuleSize, &BufferPtr);
- if (Status != EFI_SUCCESS) {
- goto Done;
- }
- gBS->CopyMem (BufferPtr, (UINT8*)CapsuleHeader+ CapsuleHeader->HeaderSize, CapsuleSize);
-
- //
- //Call DXE service ProcessFirmwareVolume to process immediatelly
- //
- Status = gDS->ProcessFirmwareVolume (BufferPtr, CapsuleSize, &FvHandle);
- if (Status != EFI_SUCCESS) {
- gBS->FreePool (BufferPtr);
- return EFI_DEVICE_ERROR;
- }
- gDS->Dispatch ();
- gBS->FreePool (BufferPtr);
- }
- return EFI_SUCCESS;
-
-Done:
- if (BufferPtr != NULL) {
- gBS->FreePool (BufferPtr);
- }
- return EFI_DEVICE_ERROR;
-}
-
-
-EFI_STATUS
-QueryCapsuleCapabilities (
- IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
- IN UINTN CapsuleCount,
- OUT UINT64 *MaxiumCapsuleSize,
- OUT EFI_RESET_TYPE *ResetType
- )
-/*++
-
-Routine Description:
-
- This code is query about capsule capability.
-
-Arguments:
-
- CapsuleHeaderArray A array of pointers to capsule headers passed in
- CapsuleCount The number of capsule
- MaxiumCapsuleSize Max capsule size is supported
- ResetType Reset type the capsule indicates, if reset is not needed,return EfiResetCold.
- If reset is needed, return EfiResetWarm.
-
-Returns:
-
- EFI STATUS
- EFI_SUCCESS Valid answer returned
- EFI_INVALID_PARAMETER MaxiumCapsuleSize is NULL,ResetType is NULL.CapsuleCount is less than 1,CapsuleGuid is not supported.
- EFI_UNSUPPORTED The capsule type is not supported.
-
---*/
-{
- UINTN ArrayNumber;
- UEFI_CAPSULE_HEADER *CapsuleHeader;
- UINT32 MaxSizePopulate;
- UINT32 MaxSizeNonPopulate;
-
-
- if ((CapsuleCount < 1) || (CapsuleCount > MAX_SUPPORT_CAPSULE_NUM)){
- return EFI_INVALID_PARAMETER;
- }
-
- if ((MaxiumCapsuleSize == NULL) ||(ResetType == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- CapsuleHeader = NULL;
-
- //
- //Compare GUIDs with EFI_CAPSULE_GUID, if capsule header contains CAPSULE_FLAGS_PERSIST_ACROSS_RESET
- //and CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE flags,whatever the GUID is ,the service supports.
- //
- for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {
- CapsuleHeader = CapsuleHeaderArray[ArrayNumber];
- if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)) == CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) {
- return EFI_INVALID_PARAMETER;
- }
- if (!CompareGuid (&CapsuleHeader->CapsuleGuid, &gEfiCapsuleGuid)) {
- if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {
- return EFI_UNSUPPORTED;
- }
- }
- }
-
- SupportCapsuleSize(&MaxSizePopulate,&MaxSizeNonPopulate);
- //
- //Assume that capsules have the same flags on reseting or not.
- //
- CapsuleHeader = CapsuleHeaderArray[0];
- if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
- //
- //Check if the platform supports update capsule across a system reset
- //
- if (!SupportUpdateCapsuleRest()) {
- return EFI_UNSUPPORTED;
- }
- *ResetType = EfiResetWarm;
- *MaxiumCapsuleSize = MaxSizePopulate;
- } else {
- *ResetType = EfiResetCold;
- *MaxiumCapsuleSize = MaxSizeNonPopulate;
- }
- return EFI_SUCCESS;
-}
-
-
-VOID
-LibCapsuleVirtualAddressChangeEvent (
- VOID
- )
-{
-}
-
-VOID
-LibCapsuleInitialize (
- VOID
- )
-{
-}
diff --git a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Mtc.c b/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Mtc.c
deleted file mode 100644
index 2b60d07203..0000000000
--- a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Mtc.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/** @file
- Generic Monotonic Counter services
-
- 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.
-
-
-**/
-
-
-//
-// The current Monotonic count value
-//
-UINT64 mEfiMtc = 0;
-
-
-//
-// Event to use to update the Mtc's high part when wrapping
-//
-EFI_EVENT mEfiMtcEvent;
-
-//
-// EfiMtcName - Variable name of the MTC value
-//
-CHAR16 *mEfiMtcName = L"MTC";
-
-//
-// EfiMtcGuid - Guid of the MTC value
-//
-EFI_GUID mEfiMtcGuid = { 0xeb704011, 0x1402, 0x11d3, { 0x8e, 0x77, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } };
-
-
-
-//
-// Worker functions
-//
-
-
-VOID
-EFIAPI
-EfiMtcEventHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-/*++
-
-Routine Description:
-
- Monotonic count event handler. This handler updates the high monotonic count.
-
-Arguments:
-
- Event The event to handle
- Context The event context
-
-Returns:
-
- EFI_SUCCESS The event has been handled properly
- EFI_NOT_FOUND An error occurred updating the variable.
-
---*/
-{
- UINT32 HighCount;
-
- EfiGetNextHighMonotonicCount (&HighCount);
- return;
-}
-
-
-
-VOID
-LibMtcVirtualAddressChangeEvent (VOID)
-{
-}
-
-
-EFI_STATUS
-EFIAPI
-LibMtcGetNextHighMonotonicCount (
- OUT UINT32 *HighCount
- )
-{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
-
- //
- // Check input parameters
- //
- if (HighCount == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
-
- if (!EfiAtRuntime ()) {
- // Use a lock if called before ExitBootServices()
- OldTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
- }
-
- *HighCount = (UINT32) RShiftU64 (mEfiMtc, 32) + 1;
- mEfiMtc = LShiftU64 (*HighCount, 32);
-
- if (!EfiAtRuntime ()) {
- gBS->RestoreTPL (OldTpl);
- }
-
- //
- // Update the NvRam store to match the new high part
- //
- Status = EfiSetVariable (
- mEfiMtcName,
- &mEfiMtcGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (UINT32),
- HighCount
- );
-
- return Status;
-}
-
-
-EFI_STATUS
-LibMtcGetNextMonotonicCount (
- OUT UINT64 *Count
- )
-{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- UINT32 HighCount;
- UINTN BufferSize;
-
- //
- // Can not be called after ExitBootServices()
- //
- if (EfiAtRuntime ()) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // Check input parameters
- //
- if (Count == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (mEfiMtc == 0) {
- //
- // If the MTC has not been initialized read the variable
- //
-
- //
- // Read the last high part
- //
- BufferSize = sizeof (UINT32);
- Status = EfiGetVariable (
- mEfiMtcName,
- &mEfiMtcGuid,
- NULL,
- &BufferSize,
- &HighCount
- );
- if (EFI_ERROR (Status)) {
- HighCount = 0;
- }
-
- //
- // Set the current value
- //
- mEfiMtc = LShiftU64 (HighCount, 32);
- //
- // Increment the upper 32 bits for this boot
- // Continue even if it fails. It will only fail if the variable services are
- // not functional.
- //
- Status = EfiGetNextHighMonotonicCount (&HighCount);
- }
-
-
- //
- // Update the monotonic counter with a lock
- //
- OldTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
- *Count = mEfiMtc;
- mEfiMtc++;
- gBS->RestoreTPL (OldTpl);
-
- //
- // If the MSB bit of the low part toggled, then signal that the high
- // part needs updated now
- //
- if ((((UINT32) mEfiMtc) ^ ((UINT32) *Count)) & 0x80000000) {
- gBS->SignalEvent (mEfiMtcEvent);
- }
-
- return EFI_SUCCESS;
-}
-
-
-
-VOID
-LibMtcInitialize (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // Initialize event to handle overflows
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- EFI_TPL_CALLBACK,
- EfiMtcEventHandler,
- NULL,
- &mEfiMtcEvent
- );
- ASSERT_EFI_ERROR (Status);
-}
-
diff --git a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/ReportStatusCode.c b/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/ReportStatusCode.c
deleted file mode 100644
index e2d5500ae0..0000000000
--- a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/ReportStatusCode.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/** @file
- Report status code lib on top of either SerialLib and/or EFI Serial Protocol.
- Based on PcdStatusCodeUseEfiSerial & PcdStatusCodeUseHardSerial settings
-
- There is just a single runtime memory buffer that contans all the data.
-
- 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.
-
-
-**/
-
-//////////#include "DxeStatusCode.h"
-
-
-EFI_SERIAL_IO_PROTOCOL *mSerialIoProtocol = NULL;
-
-
-EFI_STATUS
-LibReportStatusCode (
- IN EFI_STATUS_CODE_TYPE CodeType,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN EFI_GUID *CallerId,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
- )
-{
- CHAR8 *Filename;
- CHAR8 *Description;
- CHAR8 *Format;
- CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
- UINT32 ErrorLevel;
- UINT32 LineNumber;
- UINTN CharCount;
- VA_LIST Marker;
- EFI_DEBUG_INFO *DebugInfo;
- EFI_TPL CurrentTpl;
-
-
- if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {
- if (EfiAtRuntime ()) {
- return EFI_DEVICE_ERROR;
- }
- CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
- gBS->RestoreTPL (CurrentTpl);
-
- if (CurrentTpl > EFI_TPL_CALLBACK ) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- 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\rDXE_ASSERT!: %a (%d): %a\n\r",
- Filename,
- LineNumber,
- Description
- );
- } else if (Data != NULL &&
- ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
- //
- // Print DEBUG() information into output buffer.
- //
- CharCount = AsciiVSPrint (
- 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 = (VA_LIST) (DebugInfo + 1);
- Format = (CHAR8 *) (((UINT64 *) (DebugInfo + 1)) + 12);
-
- CharCount = AsciiVSPrint (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
- );
- }
-
-
- if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {
- //
- // Callout to SerialPort Lib function to do print.
- //
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
- }
- if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {
- if (mSerialIoProtocol == NULL) {
- gBS->LocateProtocol (&gEfiSerialIoProtocolGuid, NULL, (VOID **) &mSerialIoProtocol);
- }
-
- if (mSerialIoProtocol == NULL) {
- mSerialIoProtocol->Write (
- mSerialIoProtocol,
- &CharCount,
- Buffer
- );
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-VOID
-LibReportStatusCodeVirtualAddressChangeEvent (
- VOID
- )
-{
- return;
-}
-
-VOID
-LibReportStatusCodeInitialize (
- VOID
- )
-{
- return;
-}
-
-
-
diff --git a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Reset.c b/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Reset.c
deleted file mode 100644
index c6ae1f0c32..0000000000
--- a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Reset.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/** @file
- Simple PC Port 0x92 reset driver
-
- 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.
-
-
-**/
-
-
-
-VOID
-LibResetInitializeReset (
- VOID
- )
-{
-}
-
-VOID
-LibResetVirtualAddressChangeEvent (
- VOID
- )
-{
-}
-
-
-VOID
-LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- )
-{
- UINT8 Data;
-
- switch (ResetType) {
- case EfiResetWarm:
- case EfiResetCold:
- case EfiResetShutdown:
- Data = IoRead8 (0x92);
- Data |= 1;
- IoWrite8 (0x92, Data);
- break;
-
- default:
- return ;
- }
-
- //
- // Given we should have reset getting here would be bad
- //
- ASSERT (FALSE);
-}
-
diff --git a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Rtc.c b/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Rtc.c
deleted file mode 100644
index c35d72c03c..0000000000
--- a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Rtc.c
+++ /dev/null
@@ -1,862 +0,0 @@
-/** @file
- Simple PC RTC
-
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2014, 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.
-
-
-**/
-
-
-
-typedef struct {
- EFI_LOCK RtcLock;
- UINT16 SavedTimeZone;
- UINT8 Daylight;
-} PC_RTC_GLOBALS;
-
-#define PCAT_RTC_ADDRESS_REGISTER 0x70
-#define PCAT_RTC_DATA_REGISTER 0x71
-
-//
-// Dallas DS12C887 Real Time Clock
-//
-#define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
-#define RTC_ADDRESS_SECONDS_ALARM 1 // R/W Range 0..59
-#define RTC_ADDRESS_MINUTES 2 // R/W Range 0..59
-#define RTC_ADDRESS_MINUTES_ALARM 3 // R/W Range 0..59
-#define RTC_ADDRESS_HOURS 4 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
-#define RTC_ADDRESS_HOURS_ALARM 5 // R/W Range 1..12 or 0..23 Bit 7 is AM/PM
-#define RTC_ADDRESS_DAY_OF_THE_WEEK 6 // R/W Range 1..7
-#define RTC_ADDRESS_DAY_OF_THE_MONTH 7 // R/W Range 1..31
-#define RTC_ADDRESS_MONTH 8 // R/W Range 1..12
-#define RTC_ADDRESS_YEAR 9 // R/W Range 0..99
-#define RTC_ADDRESS_REGISTER_A 10 // R/W[0..6] R0[7]
-#define RTC_ADDRESS_REGISTER_B 11 // R/W
-#define RTC_ADDRESS_REGISTER_C 12 // RO
-#define RTC_ADDRESS_REGISTER_D 13 // RO
-#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
-//
-// Date and time initial values.
-// They are used if the RTC values are invalid during driver initialization
-//
-#define RTC_INIT_SECOND 0
-#define RTC_INIT_MINUTE 0
-#define RTC_INIT_HOUR 0
-#define RTC_INIT_DAY 1
-#define RTC_INIT_MONTH 1
-#define RTC_INIT_YEAR 2001
-
-//
-// Register initial values
-//
-#define RTC_INIT_REGISTER_A 0x26
-#define RTC_INIT_REGISTER_B 0x02
-#define RTC_INIT_REGISTER_D 0x0
-
-#pragma pack(1)
-//
-// Register A
-//
-typedef struct {
- UINT8 RS : 4; // Rate Selection Bits
- UINT8 DV : 3; // Divisor
- UINT8 UIP : 1; // Update in progress
-} RTC_REGISTER_A_BITS;
-
-typedef union {
- RTC_REGISTER_A_BITS Bits;
- UINT8 Data;
-} RTC_REGISTER_A;
-
-//
-// Register B
-//
-typedef struct {
- UINT8 DSE : 1; // 0 - Daylight saving disabled 1 - Daylight savings enabled
- UINT8 MIL : 1; // 0 - 12 hour mode 1 - 24 hour mode
- UINT8 DM : 1; // 0 - BCD Format 1 - Binary Format
- UINT8 SQWE : 1; // 0 - Disable SQWE output 1 - Enable SQWE output
- UINT8 UIE : 1; // 0 - Update INT disabled 1 - Update INT enabled
- UINT8 AIE : 1; // 0 - Alarm INT disabled 1 - Alarm INT Enabled
- UINT8 PIE : 1; // 0 - Periodic INT disabled 1 - Periodic INT Enabled
- UINT8 SET : 1; // 0 - Normal operation. 1 - Updates inhibited
-} RTC_REGISTER_B_BITS;
-
-typedef union {
- RTC_REGISTER_B_BITS Bits;
- UINT8 Data;
-} RTC_REGISTER_B;
-
-//
-// Register C
-//
-typedef struct {
- UINT8 Reserved : 4; // Read as zero. Can not be written.
- UINT8 UF : 1; // Update End Interrupt Flag
- UINT8 AF : 1; // Alarm Interrupt Flag
- UINT8 PF : 1; // Periodic Interrupt Flag
- UINT8 IRQF : 1; // Iterrupt Request Flag = PF & PIE | AF & AIE | UF & UIE
-} RTC_REGISTER_C_BITS;
-
-typedef union {
- RTC_REGISTER_C_BITS Bits;
- UINT8 Data;
-} RTC_REGISTER_C;
-
-//
-// Register D
-//
-typedef struct {
- UINT8 Reserved : 7; // Read as zero. Can not be written.
- UINT8 VRT : 1; // Valid RAM and Time
-} RTC_REGISTER_D_BITS;
-
-typedef union {
- RTC_REGISTER_D_BITS Bits;
- UINT8 Data;
-} RTC_REGISTER_D;
-
-#pragma pack()
-
-PC_RTC_GLOBALS mRtc;
-
-BOOLEAN
-IsLeapYear (
- IN EFI_TIME *Time
- )
-{
- if (Time->Year % 4 == 0) {
- if (Time->Year % 100 == 0) {
- if (Time->Year % 400 == 0) {
- return TRUE;
- } else {
- return FALSE;
- }
- } else {
- return TRUE;
- }
- } else {
- return FALSE;
- }
-}
-
-
-const INTN mDayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-
-BOOLEAN
-DayValid (
- IN EFI_TIME *Time
- )
-{
- if (Time->Day < 1 ||
- Time->Day > mDayOfMonth[Time->Month - 1] ||
- (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
- ) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-UINT8
-DecimaltoBcd (
- IN UINT8 DecValue
- )
-{
- UINTN High;
- UINTN Low;
-
- High = DecValue / 10;
- Low = DecValue - (High * 10);
-
- return (UINT8) (Low + (High << 4));
-}
-
-UINT8
-BcdToDecimal (
- IN UINT8 BcdValue
- )
-{
- UINTN High;
- UINTN Low;
-
- High = BcdValue >> 4;
- Low = BcdValue - (High << 4);
-
- return (UINT8) (Low + (High * 10));
-}
-
-
-
-
-VOID
-ConvertEfiTimeToRtcTime (
- IN EFI_TIME *Time,
- IN RTC_REGISTER_B RegisterB,
- IN UINT8 *Century
- )
-{
- BOOLEAN PM;
-
- PM = TRUE;
- //
- // Adjust hour field if RTC in in 12 hour mode
- //
- if (RegisterB.Bits.MIL == 0) {
- if (Time->Hour < 12) {
- PM = FALSE;
- }
-
- if (Time->Hour >= 13) {
- Time->Hour = (UINT8) (Time->Hour - 12);
- } else if (Time->Hour == 0) {
- Time->Hour = 12;
- }
- }
- //
- // Set the Time/Date/Daylight Savings values.
- //
- *Century = DecimaltoBcd ((UINT8) (Time->Year / 100));
-
- Time->Year = (UINT16) (Time->Year % 100);
-
- if (RegisterB.Bits.DM == 0) {
- Time->Year = DecimaltoBcd ((UINT8) Time->Year);
- Time->Month = DecimaltoBcd (Time->Month);
- Time->Day = DecimaltoBcd (Time->Day);
- Time->Hour = DecimaltoBcd (Time->Hour);
- Time->Minute = DecimaltoBcd (Time->Minute);
- Time->Second = DecimaltoBcd (Time->Second);
- }
- //
- // If we are in 12 hour mode and PM is set, then set bit 7 of the Hour field.
- //
- if (RegisterB.Bits.MIL == 0 && PM) {
- Time->Hour = (UINT8) (Time->Hour | 0x80);
- }
-}
-
-/**
- Check the validity of all the fields of a data structure of type EFI_TIME
-
- @param[in] Time Pointer to a data structure of type EFI_TIME that defines a date and time
-
- @retval EFI_SUCCESS All date and time fields are valid
- @retval EFI_INVALID_PARAMETER At least one date or time field is not valid
-**/
-EFI_STATUS
-RtcTimeFieldsValid (
- IN EFI_TIME *Time
- )
-{
- if ((Time->Year < 1998 ) ||
- (Time->Year > 2099 ) ||
- (Time->Month < 1 ) ||
- (Time->Month > 12 ) ||
- (!DayValid (Time)) ||
- (Time->Hour > 23 ) ||
- (Time->Minute > 59 ) ||
- (Time->Second > 59 ) ||
- (Time->Nanosecond > 999999999) ||
- ((Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) &&
- ((Time->TimeZone < -1440) ||
- (Time->TimeZone > 1440 ) ) ) ||
- (Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT |
- EFI_TIME_IN_DAYLIGHT )))
- ) {
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
-}
-
-UINT8
-RtcRead (
- IN UINT8 Address
- )
-{
- IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, (UINT8) (Address | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
- return IoRead8 (PCAT_RTC_DATA_REGISTER);
-}
-
-VOID
-RtcWrite (
- IN UINT8 Address,
- IN UINT8 Data
- )
-{
- IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, (UINT8) (Address | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
- IoWrite8 (PCAT_RTC_DATA_REGISTER, Data);
-}
-
-
-EFI_STATUS
-RtcTestCenturyRegister (
- VOID
- )
-{
- UINT8 Century;
- UINT8 Temp;
-
- Century = RtcRead (RTC_ADDRESS_CENTURY);
- //
- // RtcWrite (RTC_ADDRESS_CENTURY, 0x00);
- //
- Temp = (UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f);
- RtcWrite (RTC_ADDRESS_CENTURY, Century);
- if (Temp == 0x19 || Temp == 0x20) {
- return EFI_SUCCESS;
- }
-
- return EFI_DEVICE_ERROR;
-}
-
-VOID
-ConvertRtcTimeToEfiTime (
- IN EFI_TIME *Time,
- IN RTC_REGISTER_B RegisterB
- )
-{
- BOOLEAN PM;
-
- if ((Time->Hour) & 0x80) {
- PM = TRUE;
- } else {
- PM = FALSE;
- }
-
- Time->Hour = (UINT8) (Time->Hour & 0x7f);
-
- if (RegisterB.Bits.DM == 0) {
- Time->Year = BcdToDecimal ((UINT8) Time->Year);
- Time->Month = BcdToDecimal (Time->Month);
- Time->Day = BcdToDecimal (Time->Day);
- Time->Hour = BcdToDecimal (Time->Hour);
- Time->Minute = BcdToDecimal (Time->Minute);
- Time->Second = BcdToDecimal (Time->Second);
- }
- //
- // If time is in 12 hour format, convert it to 24 hour format
- //
- if (RegisterB.Bits.MIL == 0) {
- if (PM && Time->Hour < 12) {
- Time->Hour = (UINT8) (Time->Hour + 12);
- }
-
- if (!PM && Time->Hour == 12) {
- Time->Hour = 0;
- }
- }
-
- Time->Nanosecond = 0;
- Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- Time->Daylight = 0;
-}
-
-EFI_STATUS
-RtcWaitToUpdate (
- UINTN Timeout
- )
-{
- RTC_REGISTER_A RegisterA;
- RTC_REGISTER_D RegisterD;
-
- //
- // See if the RTC is functioning correctly
- //
- RegisterD.Data = RtcRead (RTC_ADDRESS_REGISTER_D);
-
- if (RegisterD.Bits.VRT == 0) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Wait for up to 0.1 seconds for the RTC to be ready.
- //
- Timeout = (Timeout / 10) + 1;
- RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
- while (RegisterA.Bits.UIP == 1 && Timeout > 0) {
- MicroSecondDelay (10);
- RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
- Timeout--;
- }
-
- RegisterD.Data = RtcRead (RTC_ADDRESS_REGISTER_D);
- if (Timeout == 0 || RegisterD.Bits.VRT == 0) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-LibGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities
- )
-{
- EFI_STATUS Status;
- RTC_REGISTER_B RegisterB;
- UINT8 Century;
- UINTN BufferSize;
-
- //
- // Check parameters for null pointer
- //
- if (Time == NULL) {
- return EFI_INVALID_PARAMETER;
-
- }
- //
- // Acquire RTC Lock to make access to RTC atomic
- //
- EfiAcquireLock (&mRtc.RtcLock);
-
- //
- // Wait for up to 0.1 seconds for the RTC to be updated
- //
- Status = RtcWaitToUpdate (100000);
- if (EFI_ERROR (Status)) {
- EfiReleaseLock (&mRtc.RtcLock);
- return Status;
- }
- //
- // Read Register B
- //
- RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
-
- //
- // Get the Time/Date/Daylight Savings values.
- //
- Time->Second = RtcRead (RTC_ADDRESS_SECONDS);
- Time->Minute = RtcRead (RTC_ADDRESS_MINUTES);
- Time->Hour = RtcRead (RTC_ADDRESS_HOURS);
- Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
- Time->Month = RtcRead (RTC_ADDRESS_MONTH);
- Time->Year = RtcRead (RTC_ADDRESS_YEAR);
-
- ConvertRtcTimeToEfiTime (Time, RegisterB);
-
- if (RtcTestCenturyRegister () == EFI_SUCCESS) {
- Century = BcdToDecimal ((UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f));
- } else {
- Century = BcdToDecimal (RtcRead (RTC_ADDRESS_CENTURY));
- }
-
- Time->Year = (UINT16) (Century * 100 + Time->Year);
-
- //
- // Release RTC Lock.
- //
- EfiReleaseLock (&mRtc.RtcLock);
-
- //
- // Get the variable that containts the TimeZone and Daylight fields
- //
- Time->TimeZone = mRtc.SavedTimeZone;
- Time->Daylight = mRtc.Daylight;
-
- BufferSize = sizeof (INT16) + sizeof (UINT8);
-
- //
- // Make sure all field values are in correct range
- //
- Status = RtcTimeFieldsValid (Time);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Fill in Capabilities if it was passed in
- //
- if (Capabilities) {
- Capabilities->Resolution = 1;
- //
- // 1 hertz
- //
- Capabilities->Accuracy = 50000000;
- //
- // 50 ppm
- //
- Capabilities->SetsToZero = FALSE;
- }
-
- return EFI_SUCCESS;
-}
-
-
-
-EFI_STATUS
-LibSetTime (
- IN EFI_TIME *Time
- )
-{
- EFI_STATUS Status;
- EFI_TIME RtcTime;
- RTC_REGISTER_B RegisterB;
- UINT8 Century;
-
- if (Time == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Make sure that the time fields are valid
- //
- Status = RtcTimeFieldsValid (Time);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- CopyMem (&RtcTime, Time, sizeof (EFI_TIME));
-
- //
- // Acquire RTC Lock to make access to RTC atomic
- //
- EfiAcquireLock (&mRtc.RtcLock);
-
- //
- // Wait for up to 0.1 seconds for the RTC to be updated
- //
- Status = RtcWaitToUpdate (100000);
- if (EFI_ERROR (Status)) {
- EfiReleaseLock (&mRtc.RtcLock);
- return Status;
- }
- //
- // Read Register B, and inhibit updates of the RTC
- //
- RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
- RegisterB.Bits.SET = 1;
- RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
-
- ConvertEfiTimeToRtcTime (&RtcTime, RegisterB, &Century);
-
- RtcWrite (RTC_ADDRESS_SECONDS, RtcTime.Second);
- RtcWrite (RTC_ADDRESS_MINUTES, RtcTime.Minute);
- RtcWrite (RTC_ADDRESS_HOURS, RtcTime.Hour);
- RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH, RtcTime.Day);
- RtcWrite (RTC_ADDRESS_MONTH, RtcTime.Month);
- RtcWrite (RTC_ADDRESS_YEAR, (UINT8) RtcTime.Year);
- if (RtcTestCenturyRegister () == EFI_SUCCESS) {
- Century = (UINT8) ((Century & 0x7f) | (RtcRead (RTC_ADDRESS_CENTURY) & 0x80));
- }
-
- RtcWrite (RTC_ADDRESS_CENTURY, Century);
-
- //
- // Allow updates of the RTC registers
- //
- RegisterB.Bits.SET = 0;
- RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
-
- //
- // Release RTC Lock.
- //
- EfiReleaseLock (&mRtc.RtcLock);
-
- //
- // Set the variable that containts the TimeZone and Daylight fields
- //
- mRtc.SavedTimeZone = Time->TimeZone;
- mRtc.Daylight = Time->Daylight;
- return Status;
-}
-
-EFI_STATUS
-libGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
- )
-{
- EFI_STATUS Status;
- RTC_REGISTER_B RegisterB;
- RTC_REGISTER_C RegisterC;
- UINT8 Century;
-
- //
- // Check paramters for null pointers
- //
- if ((Enabled == NULL) || (Pending == NULL) || (Time == NULL)) {
- return EFI_INVALID_PARAMETER;
-
- }
- //
- // Acquire RTC Lock to make access to RTC atomic
- //
- EfiAcquireLock (&mRtc.RtcLock);
-
- //
- // Wait for up to 0.1 seconds for the RTC to be updated
- //
- Status = RtcWaitToUpdate (100000);
- if (EFI_ERROR (Status)) {
- EfiReleaseLock (&mRtc.RtcLock);
- return EFI_DEVICE_ERROR;
- }
- //
- // Read Register B and Register C
- //
- RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
- RegisterC.Data = RtcRead (RTC_ADDRESS_REGISTER_C);
-
- //
- // Get the Time/Date/Daylight Savings values.
- //
- *Enabled = RegisterB.Bits.AIE;
- if (*Enabled) {
- Time->Second = RtcRead (RTC_ADDRESS_SECONDS_ALARM);
- Time->Minute = RtcRead (RTC_ADDRESS_MINUTES_ALARM);
- Time->Hour = RtcRead (RTC_ADDRESS_HOURS_ALARM);
- Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
- Time->Month = RtcRead (RTC_ADDRESS_MONTH);
- Time->Year = RtcRead (RTC_ADDRESS_YEAR);
- } else {
- Time->Second = 0;
- Time->Minute = 0;
- Time->Hour = 0;
- Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
- Time->Month = RtcRead (RTC_ADDRESS_MONTH);
- Time->Year = RtcRead (RTC_ADDRESS_YEAR);
- }
-
- ConvertRtcTimeToEfiTime (Time, RegisterB);
-
- if (RtcTestCenturyRegister () == EFI_SUCCESS) {
- Century = BcdToDecimal ((UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f));
- } else {
- Century = BcdToDecimal (RtcRead (RTC_ADDRESS_CENTURY));
- }
-
- Time->Year = (UINT16) (Century * 100 + Time->Year);
-
- //
- // Release RTC Lock.
- //
- EfiReleaseLock (&mRtc.RtcLock);
-
- //
- // Make sure all field values are in correct range
- //
- Status = RtcTimeFieldsValid (Time);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- *Pending = RegisterC.Bits.AF;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
- )
-{
- EFI_STATUS Status;
- EFI_TIME RtcTime;
- RTC_REGISTER_B RegisterB;
- UINT8 Century;
- EFI_TIME_CAPABILITIES Capabilities;
-
- if (Enabled) {
-
- if (Time == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Make sure that the time fields are valid
- //
- Status = RtcTimeFieldsValid (Time);
- if (EFI_ERROR (Status)) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Just support set alarm time within 24 hours
- //
- LibGetTime (&RtcTime, &Capabilities);
- if (Time->Year != RtcTime.Year ||
- Time->Month != RtcTime.Month ||
- (Time->Day != RtcTime.Day && Time->Day != (RtcTime.Day + 1))
- ) {
- return EFI_UNSUPPORTED;
- }
- //
- // Make a local copy of the time and date
- //
- CopyMem (&RtcTime, Time, sizeof (EFI_TIME));
-
- }
- //
- // Acquire RTC Lock to make access to RTC atomic
- //
- EfiAcquireLock (&mRtc.RtcLock);
-
- //
- // Wait for up to 0.1 seconds for the RTC to be updated
- //
- Status = RtcWaitToUpdate (100000);
- if (EFI_ERROR (Status)) {
- EfiReleaseLock (&mRtc.RtcLock);
- return EFI_DEVICE_ERROR;
- }
- //
- // Read Register B, and inhibit updates of the RTC
- //
- RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
-
- RegisterB.Bits.SET = 1;
- RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
-
- if (Enabled) {
- ConvertEfiTimeToRtcTime (&RtcTime, RegisterB, &Century);
-
- //
- // Set RTC alarm time
- //
- RtcWrite (RTC_ADDRESS_SECONDS_ALARM, RtcTime.Second);
- RtcWrite (RTC_ADDRESS_MINUTES_ALARM, RtcTime.Minute);
- RtcWrite (RTC_ADDRESS_HOURS_ALARM, RtcTime.Hour);
-
- RegisterB.Bits.AIE = 1;
-
- } else {
- RegisterB.Bits.AIE = 0;
- }
- //
- // Allow updates of the RTC registers
- //
- RegisterB.Bits.SET = 0;
- RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
-
- //
- // Release RTC Lock.
- //
- EfiReleaseLock (&mRtc.RtcLock);
-
- return EFI_SUCCESS;
-}
-
-
-
-VOID
-LibRtcVirtualAddressChangeEvent (
- VOID
- )
-{
-}
-
-
-VOID
-LibRtcInitialize (
- VOID
- )
-{
- EFI_STATUS Status;
- RTC_REGISTER_A RegisterA;
- RTC_REGISTER_B RegisterB;
- RTC_REGISTER_C RegisterC;
- RTC_REGISTER_D RegisterD;
- UINT8 Century;
- EFI_TIME Time;
-
- //
- // Acquire RTC Lock to make access to RTC atomic
- //
- EfiAcquireLock (&mRtc.RtcLock);
-
- //
- // Initialize RTC Register
- //
- // Make sure Division Chain is properly configured,
- // or RTC clock won't "tick" -- time won't increment
- //
- RegisterA.Data = RTC_INIT_REGISTER_A;
- RtcWrite (RTC_ADDRESS_REGISTER_A, RegisterA.Data);
-
- //
- // Read Register B
- //
- RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);
-
- //
- // Clear RTC flag register
- //
- RegisterC.Data = RtcRead (RTC_ADDRESS_REGISTER_C);
-
- //
- // Clear RTC register D
- //
- RegisterD.Data = RTC_INIT_REGISTER_D;
- RtcWrite (RTC_ADDRESS_REGISTER_D, RegisterD.Data);
-
- //
- // Wait for up to 0.1 seconds for the RTC to be updated
- //
- Status = RtcWaitToUpdate (100000);
- if (EFI_ERROR (Status)) {
- EfiReleaseLock (&mRtc.RtcLock);
- return;
- }
-
- //
- // Get the Time/Date/Daylight Savings values.
- //
- Time.Second = RtcRead (RTC_ADDRESS_SECONDS);
- Time.Minute = RtcRead (RTC_ADDRESS_MINUTES);
- Time.Hour = RtcRead (RTC_ADDRESS_HOURS);
- Time.Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH);
- Time.Month = RtcRead (RTC_ADDRESS_MONTH);
- Time.Year = RtcRead (RTC_ADDRESS_YEAR);
-
- ConvertRtcTimeToEfiTime (&Time, RegisterB);
-
- if (RtcTestCenturyRegister () == EFI_SUCCESS) {
- Century = BcdToDecimal ((UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f));
- } else {
- Century = BcdToDecimal (RtcRead (RTC_ADDRESS_CENTURY));
- }
-
- Time.Year = (UINT16) (Century * 100 + Time.Year);
-
- //
- // Set RTC configuration after get original time
- //
- RtcWrite (RTC_ADDRESS_REGISTER_B, RTC_INIT_REGISTER_B);
-
- //
- // Release RTC Lock.
- //
- EfiReleaseLock (&mRtc.RtcLock);
-
- //
- // Validate time fields
- //
- Status = RtcTimeFieldsValid (&Time);
- if (EFI_ERROR (Status)) {
- Time.Second = RTC_INIT_SECOND;
- Time.Minute = RTC_INIT_MINUTE;
- Time.Hour = RTC_INIT_HOUR;
- Time.Day = RTC_INIT_DAY;
- Time.Month = RTC_INIT_MONTH;
- Time.Year = RTC_INIT_YEAR;
- }
- //
- // Reset time value according to new RTC configuration
- //
- LibSetTime (&Time);
-
- return;
-}
-
-
diff --git a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Variable.c b/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Variable.c
deleted file mode 100644
index 0c1b76a4bb..0000000000
--- a/EmbeddedPkg/Library/HalRuntimeServicesExampleLib/Variable.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/** @file
- Variable services implemented from system memory
-
- There is just a single runtime memory buffer that contans all the data.
-
- 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.
-
-
-**/
-
-
-UINT64 mMaximumVariableStorageSize;
-UINT64 mRemainingVariableStorageSize;
-UINT64 mMaximumVariableSize;
-
-typedef struct {
- EFI_GUID VendorGuid;
- UINT32 Attribute;
- UINTN DataSize;
-} VARIABLE_ARRAY_ENTRY;
-// CHAR16 VariableName[]
-// UINT8 Data[]
-
-VARIABLE_ARRAY_ENTRY *mVariableArray = NULL;
-VARIABLE_ARRAY_ENTRY *mVariableArrayNextFree = NULL;
-VARIABLE_ARRAY_ENTRY *mVariableArrayEnd = NULL;
-
-
-VARIABLE_ARRAY_ENTRY *
-AddEntry (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
- )
-{
- UINTN Size;
- UINTN SizeOfString;
- VARIABLE_ARRAY_ENTRY *Entry;
- EFI_TPL CurrentTpl;
-
-
- SizeOfString = StrSize (VariableName);
- Size = SizeOfString + sizeof (VARIABLE_ARRAY_ENTRY) + DataSize;
- if ((VARIABLE_ARRAY_ENTRY *)(((UINT8 *)mVariableArrayNextFree) + Size) > mVariableArrayEnd) {
- // ran out of space
- return NULL;
- }
-
- if (!EfiAtRuntime ()) {
- // Enter critical section
- CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
- }
-
- Entry = mVariableArrayNextFree;
- CopyGuid (&Entry->VendorGuid, VendorGuid);
- Entry->Attribute = Attributes;
- Entry->DataSize = DataSize;
- StrCpy ((CHAR16 *)++mVariableArrayNextFree, VariableName);
- mVariableArrayNextFree = (VARIABLE_ARRAY_ENTRY *)(((UINT8 *)mVariableArrayNextFree) + SizeOfString);
- CopyMem (mVariableArrayNextFree, Data, DataSize);
- mVariableArrayNextFree = (VARIABLE_ARRAY_ENTRY *)(((UINT8 *)mVariableArrayNextFree) + DataSize);
-
- if (!EfiAtRuntime ()) {
- // Exit Critical section
- gBS->RestoreTPL (CurrentTpl);
- }
-
- return Entry;
-}
-
-VOID
-DeleteEntry (
- IN VARIABLE_ARRAY_ENTRY *Entry
- )
-{
- UINTN Size;
- UINT8 *Data;
- EFI_TPL CurrentTpl;
-
- Size = StrSize ((CHAR16 *)(Entry + 1)) + sizeof (VARIABLE_ARRAY_ENTRY) + Entry->DataSize;
- Data = ((UINT8 *)Entry) + Size;
-
- CopyMem (Entry, Data, (UINTN)mVariableArrayNextFree - (UINTN)Data);
-
- if (!EfiAtRuntime ()) {
- // Enter critical section
- CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
- }
-
- mVariableArrayNextFree = (VARIABLE_ARRAY_ENTRY *)(((UINT8 *)mVariableArrayNextFree) - Size);
-
- if (!EfiAtRuntime ()) {
- // Exit Critical section
- gBS->RestoreTPL (CurrentTpl);
- }
-}
-
-
-VARIABLE_ARRAY_ENTRY *
-GetVariableArrayEntry (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- OUT VOID **Data OPTIONAL
- )
-{
- VARIABLE_ARRAY_ENTRY *Entry;
- UINTN Size;
-
- if (*VariableName == L'\0') {
- // by definition first entry is null-terminated string
- if (mVariableArray == mVariableArrayNextFree) {
- return NULL;
- }
- return mVariableArray;
- }
-
- for (Entry = mVariableArray; Entry < mVariableArrayEnd;) {
- if (CompareGuid (VendorGuid, &Entry->VendorGuid)) {
- if (StrCmp (VariableName, (CHAR16 *)(Entry + 1))) {
- Size = StrSize ((CHAR16 *)(Entry + 1));
- if (Data != NULL) {
- *Data = (VOID *)(((UINT8 *)Entry) + (Size + sizeof (VARIABLE_ARRAY_ENTRY)));
- }
- return Entry;
- }
- }
-
- Size = StrSize ((CHAR16 *)(Entry + 1)) + sizeof (VARIABLE_ARRAY_ENTRY) + Entry->DataSize;
- Entry = (VARIABLE_ARRAY_ENTRY *)(((UINT8 *)Entry) + Size);
- }
-
- return NULL;
-}
-
-
-EFI_STATUS
-LibGetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- OUT UINT32 *Attributes OPTIONAL,
- IN OUT UINTN *DataSize,
- OUT VOID *Data
- )
-{
- VARIABLE_ARRAY_ENTRY *Entry;
- VOID *InternalData;
-
- if (EfiAtRuntime () && (Attributes != NULL)) {
- if ((*Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) {
- return EFI_NOT_FOUND;
- }
- }
-
- Entry = GetVariableArrayEntry (VariableName, VendorGuid, &InternalData);
- if (Entry == NULL) {
- return EFI_NOT_FOUND;
- }
-
- if (*DataSize < Entry->DataSize) {
- *DataSize = Entry->DataSize;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *DataSize = Entry->DataSize;
- if (Attributes != NULL) {
- *Attributes = Entry->Attribute;
- }
-
- CopyMem (Data, InternalData, *DataSize);
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-LibGetNextVariableName (
- IN OUT UINTN *VariableNameSize,
- IN OUT CHAR16 *VariableName,
- IN OUT EFI_GUID *VendorGuid
- )
-{
- VARIABLE_ARRAY_ENTRY *Entry;
- VOID *InternalData;
- UINTN StringSize;
- BOOLEAN Done;
-
- for (Done = FALSE; !Done; ) {
- Entry = GetVariableArrayEntry (VariableName, VendorGuid, &InternalData);
- if (Entry == NULL) {
- return EFI_NOT_FOUND;
- }
-
- // If we are at runtime skip variables that do not have the Runitme attribute set.
- Done = (EfiAtRuntime () && ((Entry->Attribute & EFI_VARIABLE_RUNTIME_ACCESS) == 0)) ? FALSE : TRUE;
- }
-
- StringSize = StrSize ((CHAR16 *)(Entry + 1));
- Entry = (VARIABLE_ARRAY_ENTRY *)(((UINT8 *)Entry) + (StringSize + sizeof (VARIABLE_ARRAY_ENTRY) + Entry->DataSize));
- if (Entry >= mVariableArrayEnd) {
- return EFI_NOT_FOUND;
- }
-
- if (*VariableNameSize < StringSize) {
- *VariableNameSize = StringSize;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *VariableNameSize = StringSize;
- CopyMem (VariableName, (CHAR16 *)(Entry + 1), StringSize);
- CopyMem (VendorGuid, &Entry->VendorGuid, sizeof (EFI_GUID));
- return EFI_SUCCESS;
-}
-
-
-
-EFI_STATUS
-LibSetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
- )
-{
- VARIABLE_ARRAY_ENTRY *Entry;
- VOID *InternalData;
-
- if (EfiAtRuntime () && ((Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0)) {
- return EFI_NOT_FOUND;
- }
-
- Entry = GetVariableArrayEntry (VariableName, VendorGuid, &InternalData);
- if (Entry == NULL) {
- if (DataSize == 0) {
- return EFI_NOT_FOUND;
- }
- Entry = AddEntry (VariableName, VendorGuid, Attributes, DataSize, Data);
- return (Entry == NULL) ? EFI_OUT_OF_RESOURCES : EFI_SUCCESS;
-
- } else if (DataSize == 0) {
- // DataSize is zero so delete
- DeleteEntry (Entry);
- } else if (DataSize == Entry->DataSize) {
- // No change is size so just update the store
- Entry->Attribute |= Attributes;
- CopyMem (InternalData, Data, DataSize);
- } else {
- // Grow the entry by deleting and adding back. Don't lose previous Attributes
- Attributes |= Entry->Attribute;
- DeleteEntry (Entry);
- Entry = AddEntry (VariableName, VendorGuid, Attributes, DataSize, Data);
- return (Entry == NULL) ? EFI_OUT_OF_RESOURCES : EFI_SUCCESS;
- }
-}
-
-
-EFI_STATUS
-LibQueryVariableInfo (
- IN UINT32 Attributes,
- OUT UINT64 *MaximumVariableStorageSize,
- OUT UINT64 *RemainingVariableStorageSize,
- OUT UINT64 *MaximumVariableSize
- )
-{
- *MaximumVariableStorageSize = mMaximumVariableStorageSize;
- *RemainingVariableStorageSize = mRemainingVariableStorageSize;
- *MaximumVariableStorageSize = mRemainingVariableStorageSize;
- return EFI_SUCCESS;
-}
-
-
-VOID
-LibVariableVirtualAddressChangeEvent (VOID)
-{
- EfiConvertPointer (0, (VOID **)&mVariableArray);
- EfiConvertPointer (0, (VOID **)&mVariableArrayNextFree);
- EfiConvertPointer (0, (VOID **)&mVariableArrayEnd);
-}
-
-
-VOID
-LibVariableInitialize (VOID)
-{
- UINTN Size;
-
- Size = PcdGet32 (PcdEmbeddedMemVariableStoreSize);
- mVariableArray = mVariableArrayNextFree = (VARIABLE_ARRAY_ENTRY *)AllocateRuntimePool (Size);
- ASSERT (mVariableArray != NULL);
-
- mVariableArrayEnd = (VARIABLE_ARRAY_ENTRY *)(((UINT8 *)mVariableArray) + Size);
-
- mMaximumVariableStorageSize = Size - sizeof (VARIABLE_ARRAY_ENTRY);
- mRemainingVariableStorageSize = mMaximumVariableStorageSize;
- mMaximumVariableSize = mMaximumVariableStorageSize;
-}
-
diff --git a/EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.c b/EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.c
deleted file mode 100644
index 2a91a98ba8..0000000000
--- a/EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/** @file
- LZMA Decompress GUIDed Section Extraction Library.
- It wraps Lzma decompress interfaces to GUIDed Section Extraction interfaces
- and registers them into GUIDed handler table.
-
- Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiDxe.h>
-#include <Library/HobLib.h>
-#include <Library/ExtractGuidedSectionLib.h>
-
-#include <Guid/ExtractSection.h>
-#include <Guid/LzmaDecompress.h>
-
-
-/**
- Register LzmaDecompress and LzmaDecompressGetInfo handlers with LzmaCustomerDecompressGuid.
-
- @retval RETURN_SUCCESS Register successfully.
- @retval RETURN_OUT_OF_RESOURCES No enough memory to store this handler.
-**/
-EFI_STATUS
-EFIAPI
-LzmaDecompressLibConstructor (
- )
-{
- EXTRACT_SECTION_HOB *Hob;
-
- Hob = GetFirstGuidHob (&gLzmaCustomDecompressGuid);
- if (Hob == NULL) {
- return EFI_NOT_FOUND;
- }
-
- // Locate Guided Hob
-
- return ExtractGuidedSectionRegisterHandlers (
- &gLzmaCustomDecompressGuid,
- Hob->Data.SectionGetInfo,
- Hob->Data.SectionExtraction
- );
-}
diff --git a/EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf b/EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf
deleted file mode 100644
index d64f5a3ff0..0000000000
--- a/EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf
+++ /dev/null
@@ -1,50 +0,0 @@
-#/** @file
-# LzmaCustomDecompressLib produces LZMA custom decompression algorithm.
-#
-# It is based on the LZMA SDK 4.65.
-# LZMA SDK 4.65 was placed in the public domain on 2009-02-03.
-# It was released on the http://www.7-zip.org/sdk.html website.
-#
-# Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = LzmaDecompressLib
- FILE_GUID = 35194660-7421-44ad-9636-e44885f092d1
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL
- CONSTRUCTOR = LzmaDecompressLibConstructor
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- LzmaHobCustomDecompressLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[Guids]
- gLzmaCustomDecompressGuid ## PRODUCED ## GUID specifies LZMA custom decompress algorithm.
-
-[LibraryClasses]
- DebugLib
- HobLib
- ExtractGuidedSectionLib
-
diff --git a/EmbeddedPkg/Library/NullDmaLib/NullDmaLib.c b/EmbeddedPkg/Library/NullDmaLib/NullDmaLib.c
deleted file mode 100755
index a0bb57541d..0000000000
--- a/EmbeddedPkg/Library/NullDmaLib/NullDmaLib.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/** @file
- Generic ARM implementation of DmaLib.h
-
- Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Uefi.h>
-#include <Library/DebugLib.h>
-#include <Library/DmaLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-
-
-/**
- Provides the DMA controller-specific addresses needed to access system memory.
-
- Operation is relative to the DMA bus master.
-
- @param Operation Indicates if the bus master is going to read or write to system memory.
- @param HostAddress The system memory address to map to the DMA controller.
- @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
- that were mapped.
- @param DeviceAddress The resulting map address for the bus master controller to use to
- access the hosts HostAddress.
- @param Mapping A resulting value to pass to Unmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
- @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,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- *DeviceAddress = (PHYSICAL_ADDRESS)(UINTN)HostAddress;
- *Mapping = NULL;
- return EFI_SUCCESS;
-}
-
-
-/**
- Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or DmaMapBusMasterCommonBuffer()
- operation and releases any corresponding resources.
-
- @param Mapping The mapping value returned from 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 (
- IN VOID *Mapping
- )
-{
- return EFI_SUCCESS;
-}
-
-/**
- Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer.
- mapping.
-
- @param MemoryType The type of memory to allocate, EfiBootServicesData or
- EfiRuntimeServicesData.
- @param Pages The number of pages to allocate.
- @param HostAddress A pointer to store the base system memory address of the
- allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
- @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
- MEMORY_WRITE_COMBINE and MEMORY_CACHED.
- @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,
- IN UINTN Pages,
- OUT VOID **HostAddress
- )
-{
- if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData
- //
- // We used uncached memory to keep coherency
- //
- if (MemoryType == EfiBootServicesData) {
- *HostAddress = AllocatePages (Pages);
- } else if (MemoryType != EfiRuntimeServicesData) {
- *HostAddress = AllocateRuntimePages (Pages);
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Frees memory that was allocated with DmaAllocateBuffer().
-
- @param Pages The number of pages to free.
- @param HostAddress The base system memory address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
- @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
- was not allocated with DmaAllocateBuffer().
-
-**/
-EFI_STATUS
-EFIAPI
-DmaFreeBuffer (
- IN UINTN Pages,
- IN VOID *HostAddress
- )
-{
- if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- FreePages (HostAddress, Pages);
- return EFI_SUCCESS;
-}
-
diff --git a/EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf b/EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf
deleted file mode 100755
index 38261d5ede..0000000000
--- a/EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf
+++ /dev/null
@@ -1,41 +0,0 @@
-#/** @file
-#
-# 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = NullDmaLib
- FILE_GUID = 0F2A0816-D319-4ee7-A6B8-D58524E4428F
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = DmaLib
-
-[Sources.common]
- NullDmaLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- DebugLib
- MemoryAllocationLib
-
-
-[Protocols]
-
-[Guids]
-
-[Pcd]
-
-[Depex]
- TRUE
diff --git a/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c b/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c
deleted file mode 100644
index cee15c4be2..0000000000
--- a/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/** @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 <PiPei.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/ExtractGuidedSectionLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PrePiLib.h>
-
-#define PRE_PI_EXTRACT_GUIDED_SECTION_DATA_GUID { 0x385A982C, 0x2F49, 0x4043, { 0xA5, 0x1E, 0x49, 0x01, 0x02, 0x5C, 0x8B, 0x6B }}
-
-typedef struct {
- UINT32 NumberOfExtractHandler;
- GUID *ExtractHandlerGuidTable;
- EXTRACT_GUIDED_SECTION_DECODE_HANDLER *ExtractDecodeHandlerTable;
- EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *ExtractGetInfoHandlerTable;
-} PRE_PI_EXTRACT_GUIDED_SECTION_DATA;
-
-PRE_PI_EXTRACT_GUIDED_SECTION_DATA *
-GetSavedData (
- VOID
- )
-{
- EFI_HOB_GUID_TYPE *GuidHob;
- GUID SavedDataGuid = PRE_PI_EXTRACT_GUIDED_SECTION_DATA_GUID;
-
- GuidHob = GetFirstGuidHob(&SavedDataGuid);
- GuidHob++;
-
- return (PRE_PI_EXTRACT_GUIDED_SECTION_DATA *)GuidHob;
-}
-
-RETURN_STATUS
-EFIAPI
-ExtractGuidedSectionRegisterHandlers (
- IN CONST GUID *SectionGuid,
- IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,
- IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler
- )
-{
- PRE_PI_EXTRACT_GUIDED_SECTION_DATA *SavedData;
- UINT32 Index;
- //
- // Check input paramter.
- //
- if (SectionGuid == NULL) {
- return RETURN_INVALID_PARAMETER;
- }
-
- SavedData = GetSavedData();
-
- //
- // Search the match registered GetInfo handler for the input guided section.
- //
- for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {
- if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], SectionGuid)) {
- break;
- }
- }
-
- //
- // If the guided handler has been registered before, only update its handler.
- //
- if (Index < SavedData->NumberOfExtractHandler) {
- SavedData->ExtractDecodeHandlerTable [Index] = DecodeHandler;
- SavedData->ExtractGetInfoHandlerTable [Index] = GetInfoHandler;
- return RETURN_SUCCESS;
- }
-
- //
- // Check the global table is enough to contain new Handler.
- //
- if (SavedData->NumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {
- return RETURN_OUT_OF_RESOURCES;
- }
-
- //
- // Register new Handler and guid value.
- //
- CopyGuid (&SavedData->ExtractHandlerGuidTable [SavedData->NumberOfExtractHandler], SectionGuid);
- SavedData->ExtractDecodeHandlerTable [SavedData->NumberOfExtractHandler] = DecodeHandler;
- SavedData->ExtractGetInfoHandlerTable [SavedData->NumberOfExtractHandler++] = GetInfoHandler;
-
- return RETURN_SUCCESS;
-}
-
-UINTN
-EFIAPI
-ExtractGuidedSectionGetGuidList (
- IN OUT GUID **ExtractHandlerGuidTable
- )
-{
- PRE_PI_EXTRACT_GUIDED_SECTION_DATA *SavedData;
-
- ASSERT(ExtractHandlerGuidTable != NULL);
-
- SavedData = GetSavedData();
-
- *ExtractHandlerGuidTable = SavedData->ExtractHandlerGuidTable;
- return SavedData->NumberOfExtractHandler;
-}
-
-RETURN_STATUS
-EFIAPI
-ExtractGuidedSectionGetInfo (
- IN CONST VOID *InputSection,
- OUT UINT32 *OutputBufferSize,
- OUT UINT32 *ScratchBufferSize,
- OUT UINT16 *SectionAttribute
- )
-{
- PRE_PI_EXTRACT_GUIDED_SECTION_DATA *SavedData;
- UINT32 Index;
-
- if (InputSection == NULL) {
- return RETURN_INVALID_PARAMETER;
- }
-
- ASSERT (OutputBufferSize != NULL);
- ASSERT (ScratchBufferSize != NULL);
- ASSERT (SectionAttribute != NULL);
-
- SavedData = GetSavedData();
-
- //
- // Search the match registered GetInfo handler for the input guided section.
- //
- for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {
- if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
- break;
- }
- }
-
- //
- // Not found, the input guided section is not supported.
- //
- if (Index == SavedData->NumberOfExtractHandler) {
- return RETURN_INVALID_PARAMETER;
- }
-
- //
- // Call the match handler to getinfo for the input section data.
- //
- return SavedData->ExtractGetInfoHandlerTable [Index] (
- InputSection,
- OutputBufferSize,
- ScratchBufferSize,
- SectionAttribute
- );
-}
-
-RETURN_STATUS
-EFIAPI
-ExtractGuidedSectionDecode (
- IN CONST VOID *InputSection,
- OUT VOID **OutputBuffer,
- OUT VOID *ScratchBuffer, OPTIONAL
- OUT UINT32 *AuthenticationStatus
- )
-{
- PRE_PI_EXTRACT_GUIDED_SECTION_DATA *SavedData;
- UINT32 Index;
-
- if (InputSection == NULL) {
- return RETURN_INVALID_PARAMETER;
- }
-
- ASSERT (OutputBuffer != NULL);
- ASSERT (AuthenticationStatus != NULL);
-
- SavedData = GetSavedData();
-
- //
- // Search the match registered GetInfo handler for the input guided section.
- //
- for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {
- if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
- break;
- }
- }
-
- //
- // Not found, the input guided section is not supported.
- //
- if (Index == SavedData->NumberOfExtractHandler) {
- return RETURN_INVALID_PARAMETER;
- }
-
- //
- // Call the match handler to getinfo for the input section data.
- //
- return SavedData->ExtractDecodeHandlerTable [Index] (
- InputSection,
- OutputBuffer,
- ScratchBuffer,
- AuthenticationStatus
- );
-}
-
-RETURN_STATUS
-EFIAPI
-ExtractGuidedSectionLibConstructor (
- VOID
- )
-{
- PRE_PI_EXTRACT_GUIDED_SECTION_DATA SavedData;
- GUID HobGuid = PRE_PI_EXTRACT_GUIDED_SECTION_DATA_GUID;
-
- //
- // Allocate global pool space to store the registered handler and its guid value.
- //
- SavedData.ExtractHandlerGuidTable = (GUID *)AllocatePool(PcdGet32(PcdMaximumGuidedExtractHandler) * sizeof(GUID));
- if (SavedData.ExtractHandlerGuidTable == NULL) {
- return RETURN_OUT_OF_RESOURCES;
- }
-
- SavedData.ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *)AllocatePool(PcdGet32(PcdMaximumGuidedExtractHandler) * sizeof(EXTRACT_GUIDED_SECTION_DECODE_HANDLER));
- if (SavedData.ExtractDecodeHandlerTable == NULL) {
- return RETURN_OUT_OF_RESOURCES;
- }
-
- SavedData.ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *)AllocatePool(PcdGet32(PcdMaximumGuidedExtractHandler) * sizeof(EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));
- if (SavedData.ExtractGetInfoHandlerTable == NULL) {
- return RETURN_OUT_OF_RESOURCES;
- }
-
- //
- // the initialized number is Zero.
- //
- SavedData.NumberOfExtractHandler = 0;
-
- BuildGuidDataHob(&HobGuid, &SavedData, sizeof(SavedData));
-
- return RETURN_SUCCESS;
-}
diff --git a/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf b/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
deleted file mode 100644
index ba74c26268..0000000000
--- a/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
+++ /dev/null
@@ -1,36 +0,0 @@
-#/** @file
-#
-# 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PrePiExtractGuidedSectionLib
- FILE_GUID = 36F6E94E-6E8E-488E-89A4-7AD911C5AFB1
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ExtractGuidedSectionLib
-
- CONSTRUCTOR = ExtractGuidedSectionLibConstructor
-
-[Sources.common]
- PrePiExtractGuidedSectionLib.c
-
-[Packages]
- EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- BaseMemoryLib
- DebugLib
-
-[FixedPcd.common]
- gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler
diff --git a/EmbeddedPkg/Library/PrePiHobLib/Hob.c b/EmbeddedPkg/Library/PrePiHobLib/Hob.c
deleted file mode 100644
index aff532259e..0000000000
--- a/EmbeddedPkg/Library/PrePiHobLib/Hob.c
+++ /dev/null
@@ -1,852 +0,0 @@
-/** @file
-
- Copyright (c) 2010, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiPei.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PeCoffLib.h>
-#include <Library/HobLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PrePiHobListPointerLib.h>
-
-#include <Protocol/PeCoffLoader.h>
-#include <Guid/ExtractSection.h>
-#include <Guid/MemoryTypeInformation.h>
-#include <Guid/MemoryAllocationHob.h>
-
-VOID
-BuildMemoryTypeInformationHob (
- VOID
- );
-
-/**
- Returns the pointer to the HOB list.
-
- This function returns the pointer to first HOB in the list.
-
- @return The pointer to the HOB list.
-
-**/
-VOID *
-EFIAPI
-GetHobList (
- VOID
- )
-{
- return PrePeiGetHobList ();
-}
-
-
-
-/**
- Updates the pointer to the HOB list.
-
- @param HobList Hob list pointer to store
-
-**/
-EFI_STATUS
-EFIAPI
-SetHobList (
- IN VOID *HobList
- )
-{
- return PrePeiSetHobList (HobList);
-}
-
-/**
-
-
-**/
-EFI_HOB_HANDOFF_INFO_TABLE*
-HobConstructor (
- IN VOID *EfiMemoryBegin,
- IN UINTN EfiMemoryLength,
- IN VOID *EfiFreeMemoryBottom,
- IN VOID *EfiFreeMemoryTop
- )
-{
- EFI_HOB_HANDOFF_INFO_TABLE *Hob;
- EFI_HOB_GENERIC_HEADER *HobEnd;
-
- Hob = EfiFreeMemoryBottom;
- HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
-
- Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
- Hob->Header.HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);
- Hob->Header.Reserved = 0;
-
- HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
- HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
- HobEnd->Reserved = 0;
-
- Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
- Hob->BootMode = BOOT_WITH_FULL_CONFIGURATION;
-
- Hob->EfiMemoryTop = (UINTN)EfiMemoryBegin + EfiMemoryLength;
- Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
- Hob->EfiFreeMemoryTop = (UINTN)EfiFreeMemoryTop;
- Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
- Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
-
- return Hob;
-}
-
-VOID *
-CreateHob (
- IN UINT16 HobType,
- IN UINT16 HobLength
- )
-{
- EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
- EFI_HOB_GENERIC_HEADER *HobEnd;
- EFI_PHYSICAL_ADDRESS FreeMemory;
- VOID *Hob;
-
- HandOffHob = GetHobList ();
-
- HobLength = (UINT16)((HobLength + 0x7) & (~0x7));
-
- FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom;
-
- if (FreeMemory < HobLength) {
- return NULL;
- }
-
- Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
- ((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType;
- ((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength;
- ((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0;
-
- HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength);
- HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
-
- HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
- HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
- HobEnd->Reserved = 0;
- HobEnd++;
- HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
-
- return Hob;
-}
-
-/**
- Builds a HOB that describes a chunk of system memory.
-
- This function builds a HOB that describes a chunk of system memory.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param ResourceType The type of resource described by this HOB.
- @param ResourceAttribute The resource attributes of the memory described by this HOB.
- @param PhysicalStart The 64 bit physical address of memory described by this HOB.
- @param NumberOfBytes The length of the memory described by this HOB in bytes.
-
-**/
-VOID
-EFIAPI
-BuildResourceDescriptorHob (
- IN EFI_RESOURCE_TYPE ResourceType,
- IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
- IN EFI_PHYSICAL_ADDRESS PhysicalStart,
- IN UINT64 NumberOfBytes
- )
-{
- EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
-
- Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
- ASSERT(Hob != NULL);
-
- Hob->ResourceType = ResourceType;
- Hob->ResourceAttribute = ResourceAttribute;
- Hob->PhysicalStart = PhysicalStart;
- Hob->ResourceLength = NumberOfBytes;
-}
-
-/**
-
-
-**/
-VOID
-CreateHobList (
- IN VOID *MemoryBegin,
- IN UINTN MemoryLength,
- IN VOID *HobBase,
- IN VOID *StackBase
- )
-{
- EFI_HOB_HANDOFF_INFO_TABLE *Hob;
- EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
-
- Hob = HobConstructor (MemoryBegin,MemoryLength,HobBase,StackBase);
- SetHobList (Hob);
-
- BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
-
- Attributes =(
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_TESTED |
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
- );
-
- BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, Attributes, (UINTN)MemoryBegin, MemoryLength);
-
- BuildStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)StackBase, ((UINTN)MemoryBegin + MemoryLength) - (UINTN)StackBase);
-
- if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) {
- // Optional feature that helps prevent EFI memory map fragmentation.
- BuildMemoryTypeInformationHob ();
- }
-}
-
-
-VOID
-EFIAPI
-BuildFvHobs (
- IN EFI_PHYSICAL_ADDRESS PhysicalStart,
- IN UINT64 NumberOfBytes,
- IN EFI_RESOURCE_ATTRIBUTE_TYPE *ResourceAttribute
- )
-{
-
- EFI_RESOURCE_ATTRIBUTE_TYPE Resource;
-
- BuildFvHob (PhysicalStart, NumberOfBytes);
-
- if (ResourceAttribute == NULL) {
- Resource = (EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_TESTED |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE);
- } else {
- Resource = *ResourceAttribute;
- }
-
- BuildResourceDescriptorHob (EFI_RESOURCE_FIRMWARE_DEVICE, Resource, PhysicalStart, NumberOfBytes);
-}
-
-/**
- Returns the next instance of a HOB type from the starting HOB.
-
- This function searches the first instance of a HOB type from the starting HOB pointer.
- If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
- In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
- unconditionally: it returns HobStart back if HobStart itself meets the requirement;
- caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
- If HobStart is NULL, then ASSERT().
-
- @param Type The HOB type to return.
- @param HobStart The starting HOB pointer to search from.
-
- @return The next instance of a HOB type from the starting HOB.
-
-**/
-VOID *
-EFIAPI
-GetNextHob (
- IN UINT16 Type,
- IN CONST VOID *HobStart
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
-
- ASSERT (HobStart != NULL);
-
- Hob.Raw = (UINT8 *) HobStart;
- //
- // Parse the HOB list until end of list or matching type is found.
- //
- while (!END_OF_HOB_LIST (Hob)) {
- if (Hob.Header->HobType == Type) {
- return Hob.Raw;
- }
- Hob.Raw = GET_NEXT_HOB (Hob);
- }
- return NULL;
-}
-
-
-
-/**
- Returns the first instance of a HOB type among the whole HOB list.
-
- This function searches the first instance of a HOB type among the whole HOB list.
- If there does not exist such HOB type in the HOB list, it will return NULL.
-
- @param Type The HOB type to return.
-
- @return The next instance of a HOB type from the starting HOB.
-
-**/
-VOID *
-EFIAPI
-GetFirstHob (
- IN UINT16 Type
- )
-{
- VOID *HobList;
-
- HobList = GetHobList ();
- return GetNextHob (Type, HobList);
-}
-
-
-/**
- This function searches the first instance of a HOB from the starting HOB pointer.
- Such HOB should satisfy two conditions:
- its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
- If there does not exist such HOB from the starting HOB pointer, it will return NULL.
- Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
- to extract the data section and its size info respectively.
- In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
- unconditionally: it returns HobStart back if HobStart itself meets the requirement;
- caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
- If Guid is NULL, then ASSERT().
- If HobStart is NULL, then ASSERT().
-
- @param Guid The GUID to match with in the HOB list.
- @param HobStart A pointer to a Guid.
-
- @return The next instance of the matched GUID HOB from the starting HOB.
-
-**/
-VOID *
-EFIAPI
-GetNextGuidHob (
- IN CONST EFI_GUID *Guid,
- IN CONST VOID *HobStart
- ){
- EFI_PEI_HOB_POINTERS GuidHob;
-
- GuidHob.Raw = (UINT8 *) HobStart;
- while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
- if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
- break;
- }
- GuidHob.Raw = GET_NEXT_HOB (GuidHob);
- }
- return GuidHob.Raw;
-}
-
-
-/**
- This function searches the first instance of a HOB among the whole HOB list.
- Such HOB should satisfy two conditions:
- its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
- If there does not exist such HOB from the starting HOB pointer, it will return NULL.
- Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
- to extract the data section and its size info respectively.
- If Guid is NULL, then ASSERT().
-
- @param Guid The GUID to match with in the HOB list.
-
- @return The first instance of the matched GUID HOB among the whole HOB list.
-
-**/
-VOID *
-EFIAPI
-GetFirstGuidHob (
- IN CONST EFI_GUID *Guid
- )
-{
- VOID *HobList;
-
- HobList = GetHobList ();
- return GetNextGuidHob (Guid, HobList);
-}
-
-
-/**
- Get the Boot Mode from the HOB list.
-
- This function returns the system boot mode information from the
- PHIT HOB in HOB list.
-
- @param VOID
-
- @return The Boot Mode.
-
-**/
-EFI_BOOT_MODE
-EFIAPI
-GetBootMode (
- VOID
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
-
- Hob.Raw = GetHobList ();
- return Hob.HandoffInformationTable->BootMode;
-}
-
-
-/**
- Get the Boot Mode from the HOB list.
-
- This function returns the system boot mode information from the
- PHIT HOB in HOB list.
-
- @param VOID
-
- @return The Boot Mode.
-
-**/
-EFI_STATUS
-EFIAPI
-SetBootMode (
- IN EFI_BOOT_MODE BootMode
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
-
- Hob.Raw = GetHobList ();
- Hob.HandoffInformationTable->BootMode = BootMode;
- return BootMode;
-}
-
-/**
- Builds a HOB for a loaded PE32 module.
-
- This function builds a HOB for a loaded PE32 module.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If ModuleName is NULL, then ASSERT().
- If there is no additional space for HOB creation, then ASSERT().
-
- @param ModuleName The GUID File Name of the module.
- @param MemoryAllocationModule The 64 bit physical address of the module.
- @param ModuleLength The length of the module in bytes.
- @param EntryPoint The 64 bit physical address of the module entry point.
-
-**/
-VOID
-EFIAPI
-BuildModuleHob (
- IN CONST EFI_GUID *ModuleName,
- IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
- IN UINT64 ModuleLength,
- IN EFI_PHYSICAL_ADDRESS EntryPoint
- )
-{
- EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
-
- ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
- ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
-
- Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
-
- CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);
- Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
- Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;
- Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;
-
- //
- // Zero the reserved space to match HOB spec
- //
- ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));
-
- CopyGuid (&Hob->ModuleName, ModuleName);
- Hob->EntryPoint = EntryPoint;
-}
-
-/**
- Builds a GUID HOB with a certain data length.
-
- This function builds a customized HOB tagged with a GUID for identification
- and returns the start address of GUID HOB data so that caller can fill the customized data.
- The HOB Header and Name field is already stripped.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If Guid is NULL, then ASSERT().
- If there is no additional space for HOB creation, then ASSERT().
- If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
-
- @param Guid The GUID to tag the customized HOB.
- @param DataLength The size of the data payload for the GUID HOB.
-
- @return The start address of GUID HOB data.
-
-**/
-VOID *
-EFIAPI
-BuildGuidHob (
- IN CONST EFI_GUID *Guid,
- IN UINTN DataLength
- )
-{
- EFI_HOB_GUID_TYPE *Hob;
-
- //
- // Make sure that data length is not too long.
- //
- ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
-
- Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));
- CopyGuid (&Hob->Name, Guid);
- return Hob + 1;
-}
-
-
-/**
- Copies a data buffer to a newly-built HOB.
-
- This function builds a customized HOB tagged with a GUID for identification,
- copies the input data to the HOB data field and returns the start address of the GUID HOB data.
- The HOB Header and Name field is already stripped.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If Guid is NULL, then ASSERT().
- If Data is NULL and DataLength > 0, then ASSERT().
- If there is no additional space for HOB creation, then ASSERT().
- If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
-
- @param Guid The GUID to tag the customized HOB.
- @param Data The data to be copied into the data field of the GUID HOB.
- @param DataLength The size of the data payload for the GUID HOB.
-
- @return The start address of GUID HOB data.
-
-**/
-VOID *
-EFIAPI
-BuildGuidDataHob (
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN UINTN DataLength
- )
-{
- VOID *HobData;
-
- ASSERT (Data != NULL || DataLength == 0);
-
- HobData = BuildGuidHob (Guid, DataLength);
-
- return CopyMem (HobData, Data, DataLength);
-}
-
-
-/**
- Builds a Firmware Volume HOB.
-
- This function builds a Firmware Volume HOB.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The base address of the Firmware Volume.
- @param Length The size of the Firmware Volume in bytes.
-
-**/
-VOID
-EFIAPI
-BuildFvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- )
-{
- EFI_HOB_FIRMWARE_VOLUME *Hob;
-
- Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));
-
- Hob->BaseAddress = BaseAddress;
- Hob->Length = Length;
-}
-
-
-/**
- Builds a EFI_HOB_TYPE_FV2 HOB.
-
- This function builds a EFI_HOB_TYPE_FV2 HOB.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The base address of the Firmware Volume.
- @param Length The size of the Firmware Volume in bytes.
- @param FvName The name of the Firmware Volume.
- @param FileName The name of the file.
-
-**/
-VOID
-EFIAPI
-BuildFv2Hob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN CONST EFI_GUID *FvName,
- IN CONST EFI_GUID *FileName
- )
-{
- EFI_HOB_FIRMWARE_VOLUME2 *Hob;
-
- Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));
-
- Hob->BaseAddress = BaseAddress;
- Hob->Length = Length;
- CopyGuid (&Hob->FvName, FvName);
- CopyGuid (&Hob->FileName, FileName);
-}
-
-
-
-/**
- Builds a Capsule Volume HOB.
-
- This function builds a Capsule Volume HOB.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The base address of the Capsule Volume.
- @param Length The size of the Capsule Volume in bytes.
-
-**/
-VOID
-EFIAPI
-BuildCvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- )
-{
- ASSERT (FALSE);
-}
-
-
-/**
- Builds a HOB for the CPU.
-
- This function builds a HOB for the CPU.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
- @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
-
-**/
-VOID
-EFIAPI
-BuildCpuHob (
- IN UINT8 SizeOfMemorySpace,
- IN UINT8 SizeOfIoSpace
- )
-{
- EFI_HOB_CPU *Hob;
-
- Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));
-
- Hob->SizeOfMemorySpace = SizeOfMemorySpace;
- Hob->SizeOfIoSpace = SizeOfIoSpace;
-
- //
- // Zero the reserved space to match HOB spec
- //
- ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));
-}
-
-
-/**
- Builds a HOB for the Stack.
-
- This function builds a HOB for the stack.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The 64 bit physical address of the Stack.
- @param Length The length of the stack in bytes.
-
-**/
-VOID
-EFIAPI
-BuildStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- )
-{
- EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
-
- ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
- ((Length & (EFI_PAGE_SIZE - 1)) == 0));
-
- Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));
-
- CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);
- Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
- Hob->AllocDescriptor.MemoryLength = Length;
- Hob->AllocDescriptor.MemoryType = EfiBootServicesData;
-
- //
- // Zero the reserved space to match HOB spec
- //
- ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
-}
-
-
-/**
- Update the Stack Hob if the stack has been moved
-
- @param BaseAddress The 64 bit physical address of the Stack.
- @param Length The length of the stack in bytes.
-
-**/
-VOID
-UpdateStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
-
- Hob.Raw = GetHobList ();
- while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {
- if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) {
- //
- // Build a new memory allocation HOB with old stack info with EfiConventionalMemory type
- // to be reclaimed by DXE core.
- //
- BuildMemoryAllocationHob (
- Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress,
- Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength,
- EfiConventionalMemory
- );
- //
- // Update the BSP Stack Hob to reflect the new stack info.
- //
- Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress = BaseAddress;
- Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;
- break;
- }
- Hob.Raw = GET_NEXT_HOB (Hob);
- }
-}
-
-
-
-/**
- Builds a HOB for the memory allocation.
-
- This function builds a HOB for the memory allocation.
- It can only be invoked during PEI phase;
- for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
- If there is no additional space for HOB creation, then ASSERT().
-
- @param BaseAddress The 64 bit physical address of the memory.
- @param Length The length of the memory allocation in bytes.
- @param MemoryType Type of memory allocated by this HOB.
-
-**/
-VOID
-EFIAPI
-BuildMemoryAllocationHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
- )
-{
- EFI_HOB_MEMORY_ALLOCATION *Hob;
-
- ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
- ((Length & (EFI_PAGE_SIZE - 1)) == 0));
-
- Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
-
- ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
- Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
- Hob->AllocDescriptor.MemoryLength = Length;
- Hob->AllocDescriptor.MemoryType = MemoryType;
- //
- // Zero the reserved space to match HOB spec
- //
- ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
-}
-
-
-
-VOID
-EFIAPI
-BuildExtractSectionHob (
- IN EFI_GUID *Guid,
- IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo,
- IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction
- )
-{
- EXTRACT_SECTION_DATA Data;
-
- Data.SectionGetInfo = SectionGetInfo;
- Data.SectionExtraction = SectionExtraction;
- BuildGuidDataHob (Guid, &Data, sizeof (Data));
-}
-
-PE_COFF_LOADER_PROTOCOL gPeCoffProtocol = {
- PeCoffLoaderGetImageInfo,
- PeCoffLoaderLoadImage,
- PeCoffLoaderRelocateImage,
- PeCoffLoaderImageReadFromMemory,
- PeCoffLoaderRelocateImageForRuntime,
- PeCoffLoaderUnloadImage
-};
-
-
-
-VOID
-EFIAPI
-BuildPeCoffLoaderHob (
- VOID
- )
-{
- VOID *Ptr;
-
- Ptr = &gPeCoffProtocol;
- BuildGuidDataHob (&gPeCoffLoaderProtocolGuid, &Ptr, sizeof (VOID *));
-}
-
-// May want to put this into a library so you only need the PCD setings if you are using the feature?
-VOID
-BuildMemoryTypeInformationHob (
- VOID
- )
-{
- EFI_MEMORY_TYPE_INFORMATION Info[10];
-
- Info[0].Type = EfiACPIReclaimMemory;
- Info[0].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory);
- Info[1].Type = EfiACPIMemoryNVS;
- Info[1].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS);
- Info[2].Type = EfiReservedMemoryType;
- Info[2].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiReservedMemoryType);
- Info[3].Type = EfiRuntimeServicesData;
- Info[3].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiRuntimeServicesData);
- Info[4].Type = EfiRuntimeServicesCode;
- Info[4].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode);
- Info[5].Type = EfiBootServicesCode;
- Info[5].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiBootServicesCode);
- Info[6].Type = EfiBootServicesData;
- Info[6].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiBootServicesData);
- Info[7].Type = EfiLoaderCode;
- Info[7].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiLoaderCode);
- Info[8].Type = EfiLoaderData;
- Info[8].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiLoaderData);
-
- // Terminator for the list
- Info[9].Type = EfiMaxMemoryType;
- Info[9].NumberOfPages = 0;
-
-
- BuildGuidDataHob (&gEfiMemoryTypeInformationGuid, &Info, sizeof (Info));
-}
-
diff --git a/EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf b/EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
deleted file mode 100644
index 19e5a298f3..0000000000
--- a/EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
+++ /dev/null
@@ -1,64 +0,0 @@
-#/** @file
-# Hob lib that does not contain the APIs as they are already in the PrePiLib
-#
-# 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.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PrePiHobLib
- FILE_GUID = 1F3A3278-82EB-4C0D-86F1-5BCDA5846CB2
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = HobLib
-
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- Hob.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- PrePiHobListPointerLib
-
-[Guids]
- gEfiHobMemoryAllocModuleGuid
- gEfiHobMemoryAllocStackGuid
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
-
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
-
diff --git a/EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c b/EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c
deleted file mode 100644
index 9065b1132f..0000000000
--- a/EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011, 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.
-*
-**/
-
-#include <PiPei.h>
-#include <Library/PrePiHobListPointerLib.h>
-#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.
-//
-VOID *gHobList = NULL;
-
-
-/**
- Returns the pointer to the HOB list.
-
- This function returns the pointer to first HOB in the list.
-
- @return The pointer to the HOB list.
-
-**/
-VOID *
-EFIAPI
-PrePeiGetHobList (
- VOID
- )
-{
- if (gHobList == NULL) {
- return (VOID *)*(UINTN*)PcdGet32 (PcdPrePiHobBase);
- } else {
- return gHobList;
- }
-}
-
-
-
-/**
- Updates the pointer to the HOB list.
-
- @param HobList Hob list pointer to store
-
-**/
-EFI_STATUS
-EFIAPI
-PrePeiSetHobList (
- IN VOID *HobList
- )
-{
- gHobList = HobList;
-
- //
- // If this code is running from ROM this could fail
- //
- return (gHobList == HobList) ? EFI_SUCCESS: EFI_UNSUPPORTED;
-}
diff --git a/EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf b/EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
deleted file mode 100644
index bfd3c209a1..0000000000
--- a/EmbeddedPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
+++ /dev/null
@@ -1,38 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2011, 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PrePiHobListPointerLib
- FILE_GUID = 7a6a7fc0-5ee0-11e0-b47f-0002a5d5c51b
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = PrePiHobListPointerLib
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
-#
-
-[Sources]
- PrePiHobListPointer.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- #DebugLib
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdPrePiHobBase
diff --git a/EmbeddedPkg/Library/PrePiLib/FwVol.c b/EmbeddedPkg/Library/PrePiLib/FwVol.c
deleted file mode 100644
index 530fc15dca..0000000000
--- a/EmbeddedPkg/Library/PrePiLib/FwVol.c
+++ /dev/null
@@ -1,845 +0,0 @@
-/** @file
- Implementation of the 6 PEI Ffs (FV) APIs in library form.
-
- This code only knows about a FV if it has a EFI_HOB_TYPE_FV entry in the HOB list
-
- 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/ExtractGuidedSectionLib.h>
-
-
-#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
- (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
-
-
-/**
- Returns the highest bit set of the State field
-
- @param ErasePolarity Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY
- in the Attributes field.
- @param FfsHeader Pointer to FFS File Header
-
-
- @retval the highest bit in the State field
-
-**/
-STATIC
-EFI_FFS_FILE_STATE
-GetFileState(
- IN UINT8 ErasePolarity,
- IN EFI_FFS_FILE_HEADER *FfsHeader
- )
-{
- EFI_FFS_FILE_STATE FileState;
- EFI_FFS_FILE_STATE HighestBit;
-
- FileState = FfsHeader->State;
-
- if (ErasePolarity != 0) {
- FileState = (EFI_FFS_FILE_STATE)~FileState;
- }
-
- HighestBit = 0x80;
- while (HighestBit != 0 && (HighestBit & FileState) == 0) {
- HighestBit >>= 1;
- }
-
- return HighestBit;
-}
-
-
-/**
- Calculates the checksum of the header of a file.
- The header is a zero byte checksum, so zero means header is good
-
- @param FfsHeader Pointer to FFS File Header
-
- @retval Checksum of the header
-
-**/
-STATIC
-UINT8
-CalculateHeaderChecksum (
- IN EFI_FFS_FILE_HEADER *FileHeader
- )
-{
- UINT8 *Ptr;
- UINTN Index;
- UINT8 Sum;
-
- Sum = 0;
- Ptr = (UINT8 *)FileHeader;
-
- for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER) - 3; Index += 4) {
- Sum = (UINT8)(Sum + Ptr[Index]);
- Sum = (UINT8)(Sum + Ptr[Index+1]);
- Sum = (UINT8)(Sum + Ptr[Index+2]);
- Sum = (UINT8)(Sum + Ptr[Index+3]);
- }
-
- for (; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {
- Sum = (UINT8)(Sum + Ptr[Index]);
- }
-
- //
- // State field (since this indicates the different state of file).
- //
- Sum = (UINT8)(Sum - FileHeader->State);
- //
- // Checksum field of the file is not part of the header checksum.
- //
- Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);
-
- return Sum;
-}
-
-
-/**
- Given a FileHandle return the VolumeHandle
-
- @param FileHandle File handle to look up
- @param VolumeHandle Match for FileHandle
-
- @retval TRUE VolumeHandle is valid
-
-**/
-STATIC
-BOOLEAN
-EFIAPI
-FileHandleToVolume (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_PEI_FV_HANDLE *VolumeHandle
- )
-{
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
- EFI_PEI_HOB_POINTERS Hob;
-
- Hob.Raw = GetHobList ();
- if (Hob.Raw == NULL) {
- return FALSE;
- }
-
- do {
- Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, Hob.Raw);
- if (Hob.Raw != NULL) {
- FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(Hob.FirmwareVolume->BaseAddress);
- if (((UINT64) (UINTN) FileHandle > (UINT64) (UINTN) FwVolHeader ) && \
- ((UINT64) (UINTN) FileHandle <= ((UINT64) (UINTN) FwVolHeader + FwVolHeader->FvLength - 1))) {
- *VolumeHandle = (EFI_PEI_FV_HANDLE)FwVolHeader;
- return TRUE;
- }
-
- Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, GET_NEXT_HOB (Hob));
- }
- } while (Hob.Raw != NULL);
-
- return FALSE;
-}
-
-
-
-/**
- Given the input file pointer, search for the next matching file in the
- FFS volume as defined by SearchType. The search starts from FileHeader inside
- the Firmware Volume defined by FwVolHeader.
-
- @param FileHandle File handle to look up
- @param VolumeHandle Match for FileHandle
-
-
-**/
-EFI_STATUS
-FindFileEx (
- IN CONST EFI_PEI_FV_HANDLE FvHandle,
- IN CONST EFI_GUID *FileName, OPTIONAL
- IN EFI_FV_FILETYPE SearchType,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
- )
-{
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
- EFI_FFS_FILE_HEADER **FileHeader;
- EFI_FFS_FILE_HEADER *FfsFileHeader;
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
- UINT32 FileLength;
- UINT32 FileOccupiedSize;
- UINT32 FileOffset;
- UINT64 FvLength;
- UINT8 ErasePolarity;
- UINT8 FileState;
-
- FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvHandle;
- FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
-
- FvLength = FwVolHeader->FvLength;
- if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
- ErasePolarity = 1;
- } else {
- ErasePolarity = 0;
- }
-
- //
- // If FileHeader is not specified (NULL) or FileName is not NULL,
- // start with the first file in the firmware volume. Otherwise,
- // start from the FileHeader.
- //
- if ((*FileHeader == NULL) || (FileName != NULL)) {
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
- if (FwVolHeader->ExtHeaderOffset != 0) {
- FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(((UINT8 *)FwVolHeader) + FwVolHeader->ExtHeaderOffset);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FwVolExHeaderInfo) + FwVolExHeaderInfo->ExtHeaderSize);
- }
- } else {
- //
- // Length is 24 bits wide so mask upper 8 bits
- // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
- //
- FileLength = *(UINT32 *)(*FileHeader)->Size & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)*FileHeader + FileOccupiedSize);
- }
-
- // FFS files begin with a header that is aligned on an 8-byte boundary
- FfsFileHeader = ALIGN_POINTER (FfsFileHeader, 8);
-
- FileOffset = (UINT32) ((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
- ASSERT (FileOffset <= 0xFFFFFFFF);
-
- while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
- //
- // Get FileState which is the highest bit of the State
- //
- FileState = GetFileState (ErasePolarity, FfsFileHeader);
-
- switch (FileState) {
-
- case EFI_FILE_HEADER_INVALID:
- FileOffset += sizeof(EFI_FFS_FILE_HEADER);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER));
- break;
-
- case EFI_FILE_DATA_VALID:
- case EFI_FILE_MARKED_FOR_UPDATE:
- if (CalculateHeaderChecksum (FfsFileHeader) != 0) {
- ASSERT (FALSE);
- *FileHeader = NULL;
- return EFI_NOT_FOUND;
- }
-
- FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
-
- if (FileName != NULL) {
- if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
- *FileHeader = FfsFileHeader;
- return EFI_SUCCESS;
- }
- } else if (((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) &&
- (FfsFileHeader->Type != EFI_FV_FILETYPE_FFS_PAD)) {
- *FileHeader = FfsFileHeader;
- return EFI_SUCCESS;
- }
-
- FileOffset += FileOccupiedSize;
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
- break;
-
- case EFI_FILE_DELETED:
- FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
- FileOffset += FileOccupiedSize;
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
- break;
-
- default:
- *FileHeader = NULL;
- return EFI_NOT_FOUND;
- }
- }
-
-
- *FileHeader = NULL;
- return EFI_NOT_FOUND;
-}
-
-
-/**
- Go through the file to search SectionType section,
- when meeting an encapsuled section.
-
- @param SectionType - Filter to find only section of this type.
- @param Section - From where to search.
- @param SectionSize - The file size to search.
- @param OutputBuffer - Pointer to the section to search.
-
- @retval EFI_SUCCESS
-**/
-EFI_STATUS
-FfsProcessSection (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_COMMON_SECTION_HEADER *Section,
- IN UINTN SectionSize,
- OUT VOID **OutputBuffer
- )
-{
- EFI_STATUS Status;
- UINT32 SectionLength;
- UINT32 ParsedLength;
- EFI_COMPRESSION_SECTION *CompressionSection;
- UINT32 DstBufferSize;
- VOID *ScratchBuffer;
- UINT32 ScratchBufferSize;
- VOID *DstBuffer;
- UINT16 SectionAttribute;
- UINT32 AuthenticationStatus;
-
-
- *OutputBuffer = NULL;
- ParsedLength = 0;
- Status = EFI_NOT_FOUND;
- while (ParsedLength < SectionSize) {
- if (Section->Type == SectionType) {
- *OutputBuffer = (VOID *)(Section + 1);
-
- return EFI_SUCCESS;
- } else if ((Section->Type == EFI_SECTION_COMPRESSION) || (Section->Type == EFI_SECTION_GUID_DEFINED)) {
-
- if (Section->Type == EFI_SECTION_COMPRESSION) {
- CompressionSection = (EFI_COMPRESSION_SECTION *) Section;
- SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;
-
- if (CompressionSection->CompressionType != EFI_STANDARD_COMPRESSION) {
- return EFI_UNSUPPORTED;
- }
-
- Status = UefiDecompressGetInfo (
- (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),
- (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION),
- &DstBufferSize,
- &ScratchBufferSize
- );
- } else if (Section->Type == EFI_SECTION_GUID_DEFINED) {
- Status = ExtractGuidedSectionGetInfo (
- Section,
- &DstBufferSize,
- &ScratchBufferSize,
- &SectionAttribute
- );
- }
-
- if (EFI_ERROR (Status)) {
- //
- // GetInfo failed
- //
- DEBUG ((EFI_D_ERROR, "Decompress GetInfo Failed - %r\n", Status));
- return EFI_NOT_FOUND;
- }
- //
- // Allocate scratch buffer
- //
- ScratchBuffer = (VOID *)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));
- if (ScratchBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Allocate destination buffer, extra one page for adjustment
- //
- DstBuffer = (VOID *)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize) + 1);
- if (DstBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // DstBuffer still is one section. Adjust DstBuffer offset, skip EFI section header
- // to make section data at page alignment.
- //
- DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER);
- //
- // Call decompress function
- //
- if (Section->Type == EFI_SECTION_COMPRESSION) {
- Status = UefiDecompress (
- (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),
- DstBuffer,
- ScratchBuffer
- );
- } else if (Section->Type == EFI_SECTION_GUID_DEFINED) {
- Status = ExtractGuidedSectionDecode (
- Section,
- &DstBuffer,
- ScratchBuffer,
- &AuthenticationStatus
- );
- }
-
- if (EFI_ERROR (Status)) {
- //
- // Decompress failed
- //
- DEBUG ((EFI_D_ERROR, "Decompress Failed - %r\n", Status));
- return EFI_NOT_FOUND;
- } else {
- return FfsProcessSection (
- SectionType,
- DstBuffer,
- DstBufferSize,
- OutputBuffer
- );
- }
- }
-
- //
- // Size is 24 bits wide so mask upper 8 bits.
- // SectionLength is adjusted it is 4 byte aligned.
- // Go to the next section
- //
- SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;
- SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
- ASSERT (SectionLength != 0);
- ParsedLength += SectionLength;
- Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
- }
-
- return EFI_NOT_FOUND;
-}
-
-
-
-/**
- This service enables discovery sections of a given type within a valid FFS file.
-
- @param SearchType The value of the section type to find.
- @param FfsFileHeader A pointer to the file header that contains the set of sections to
- be searched.
- @param SectionData A pointer to the discovered section, if successful.
-
- @retval EFI_SUCCESS The section was found.
- @retval EFI_NOT_FOUND The section was not found.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT VOID **SectionData
- )
-{
- EFI_FFS_FILE_HEADER *FfsFileHeader;
- UINT32 FileSize;
- EFI_COMMON_SECTION_HEADER *Section;
-
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);
-
- //
- // Size is 24 bits wide so mask upper 8 bits.
- // Does not include FfsFileHeader header size
- // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
- //
- Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
- FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
- FileSize -= sizeof (EFI_FFS_FILE_HEADER);
-
- return FfsProcessSection (
- SectionType,
- Section,
- FileSize,
- SectionData
- );
-}
-
-
-
-
-
-
-/**
- This service enables discovery of additional firmware files.
-
- @param SearchType A filter to find files only of this type.
- @param FwVolHeader Pointer to the firmware volume header of the volume to search.
- This parameter must point to a valid FFS volume.
- @param FileHeader Pointer to the current file from which to begin searching.
-
- @retval EFI_SUCCESS The file was found.
- @retval EFI_NOT_FOUND The file was not found.
- @retval EFI_NOT_FOUND The header checksum was not zero.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindNextFile (
- IN UINT8 SearchType,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
- )
-{
- return FindFileEx (VolumeHandle, NULL, SearchType, FileHandle);
-}
-
-
-/**
- This service enables discovery of additional firmware volumes.
-
- @param Instance This instance of the firmware volume to find. The value 0 is the
- Boot Firmware Volume (BFV).
- @param FwVolHeader Pointer to the firmware volume header of the volume to return.
-
- @retval EFI_SUCCESS The volume was found.
- @retval EFI_NOT_FOUND The volume was not found.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindNextVolume (
- IN UINTN Instance,
- IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
-
-
- Hob.Raw = GetHobList ();
- if (Hob.Raw == NULL) {
- return EFI_NOT_FOUND;
- }
-
- do {
- Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, Hob.Raw);
- if (Hob.Raw != NULL) {
- if (Instance-- == 0) {
- *VolumeHandle = (EFI_PEI_FV_HANDLE)(UINTN)(Hob.FirmwareVolume->BaseAddress);
- return EFI_SUCCESS;
- }
-
- Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, GET_NEXT_HOB (Hob));
- }
- } while (Hob.Raw != NULL);
-
- return EFI_NOT_FOUND;
-
-}
-
-
-/**
- Find a file in the volume by name
-
- @param FileName A pointer to the name of the file to
- find within the firmware volume.
-
- @param VolumeHandle The firmware volume to search FileHandle
- Upon exit, points to the found file's
- handle or NULL if it could not be found.
-
- @retval EFI_SUCCESS File was found.
-
- @retval EFI_NOT_FOUND File was not found.
-
- @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
- FileName was NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsFindFileByName (
- IN CONST EFI_GUID *FileName,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
- )
-{
- EFI_STATUS Status;
- if ((VolumeHandle == NULL) || (FileName == NULL) || (FileHandle == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
- Status = FindFileEx (VolumeHandle, FileName, 0, FileHandle);
- if (Status == EFI_NOT_FOUND) {
- *FileHandle = NULL;
- }
- return Status;
-}
-
-
-
-
-/**
- Get information about the file by name.
-
- @param FileHandle Handle of the file.
-
- @param FileInfo Upon exit, points to the file's
- information.
-
- @retval EFI_SUCCESS File information returned.
-
- @retval EFI_INVALID_PARAMETER If FileHandle does not
- represent a valid file.
-
- @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsGetFileInfo (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_FV_FILE_INFO *FileInfo
- )
-{
- UINT8 FileState;
- UINT8 ErasePolarity;
- EFI_FFS_FILE_HEADER *FileHeader;
- EFI_PEI_FV_HANDLE VolumeHandle;
-
- if ((FileHandle == NULL) || (FileInfo == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- VolumeHandle = 0;
- //
- // Retrieve the FirmwareVolume which the file resides in.
- //
- if (!FileHandleToVolume(FileHandle, &VolumeHandle)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (((EFI_FIRMWARE_VOLUME_HEADER*)VolumeHandle)->Attributes & EFI_FVB2_ERASE_POLARITY) {
- ErasePolarity = 1;
- } else {
- ErasePolarity = 0;
- }
-
- //
- // Get FileState which is the highest bit of the State
- //
- FileState = GetFileState (ErasePolarity, (EFI_FFS_FILE_HEADER*)FileHandle);
-
- switch (FileState) {
- case EFI_FILE_DATA_VALID:
- case EFI_FILE_MARKED_FOR_UPDATE:
- break;
- default:
- return EFI_INVALID_PARAMETER;
- }
-
- FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;
- CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));
- FileInfo->FileType = FileHeader->Type;
- FileInfo->FileAttributes = FileHeader->Attributes;
- FileInfo->BufferSize = ((*(UINT32 *)FileHeader->Size) & 0x00FFFFFF) - sizeof (EFI_FFS_FILE_HEADER);
- FileInfo->Buffer = (FileHeader + 1);
- return EFI_SUCCESS;
-}
-
-
-/**
- Get Information about the volume by name
-
- @param VolumeHandle Handle of the volume.
-
- @param VolumeInfo Upon exit, points to the volume's
- information.
-
- @retval EFI_SUCCESS File information returned.
-
- @retval EFI_INVALID_PARAMETER If FileHandle does not
- represent a valid file.
-
- @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_FV_INFO *VolumeInfo
- )
-{
- EFI_FIRMWARE_VOLUME_HEADER FwVolHeader;
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
-
- if (VolumeInfo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // VolumeHandle may not align at 8 byte,
- // but FvLength is UINT64 type, which requires FvHeader align at least 8 byte.
- // So, Copy FvHeader into the local FvHeader structure.
- //
- CopyMem (&FwVolHeader, VolumeHandle, sizeof (EFI_FIRMWARE_VOLUME_HEADER));
- //
- // Check Fv Image Signature
- //
- if (FwVolHeader.Signature != EFI_FVH_SIGNATURE) {
- return EFI_INVALID_PARAMETER;
- }
- VolumeInfo->FvAttributes = FwVolHeader.Attributes;
- VolumeInfo->FvStart = (VOID *) VolumeHandle;
- VolumeInfo->FvSize = FwVolHeader.FvLength;
- CopyMem (&VolumeInfo->FvFormat, &FwVolHeader.FileSystemGuid, sizeof(EFI_GUID));
-
- if (FwVolHeader.ExtHeaderOffset != 0) {
- FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(((UINT8 *)VolumeHandle) + FwVolHeader.ExtHeaderOffset);
- CopyMem (&VolumeInfo->FvName, &FwVolExHeaderInfo->FvName, sizeof(EFI_GUID));
- }
- return EFI_SUCCESS;
-}
-
-
-
-/**
- Search through every FV until you find a file of type FileType
-
- @param FileType File handle of a Fv type file.
- @param Volumehandle On succes Volume Handle of the match
- @param FileHandle On success File Handle of the match
-
- @retval EFI_NOT_FOUND FV image can't be found.
- @retval EFI_SUCCESS Successfully found FileType
-
-**/
-EFI_STATUS
-EFIAPI
-FfsAnyFvFindFirstFile (
- IN EFI_FV_FILETYPE FileType,
- OUT EFI_PEI_FV_HANDLE *VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
- )
-{
- EFI_STATUS Status;
- UINTN Instance;
-
- //
- // Search every FV for the DXE Core
- //
- Instance = 0;
- *FileHandle = NULL;
-
- while (1)
- {
- Status = FfsFindNextVolume (Instance++, VolumeHandle);
- if (EFI_ERROR (Status))
- {
- break;
- }
-
- Status = FfsFindNextFile (FileType, *VolumeHandle, FileHandle);
- if (!EFI_ERROR (Status))
- {
- break;
- }
- }
-
- return Status;
-}
-
-
-
-/**
- Get Fv image from the FV type file, then add FV & FV2 Hob.
-
- @param FileHandle File handle of a Fv type file.
-
-
- @retval EFI_NOT_FOUND FV image can't be found.
- @retval EFI_SUCCESS Successfully to process it.
-
-**/
-EFI_STATUS
-EFIAPI
-FfsProcessFvFile (
- IN EFI_PEI_FILE_HANDLE FvFileHandle
- )
-{
- EFI_STATUS Status;
- EFI_PEI_FV_HANDLE FvImageHandle;
- EFI_FV_INFO FvImageInfo;
- UINT32 FvAlignment;
- VOID *FvBuffer;
- EFI_PEI_HOB_POINTERS HobFv2;
-
- FvBuffer = NULL;
-
-
- //
- // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
- // been extracted.
- //
- HobFv2.Raw = GetHobList ();
- while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {
- if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobFv2.FirmwareVolume2->FileName)) {
- //
- // this FILE has been dispatched, it will not be dispatched again.
- //
- return EFI_SUCCESS;
- }
- HobFv2.Raw = GET_NEXT_HOB (HobFv2);
- }
-
- //
- // Find FvImage in FvFile
- //
- Status = FfsFindSectionData (EFI_SECTION_FIRMWARE_VOLUME_IMAGE, FvFileHandle, (VOID **)&FvImageHandle);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Collect FvImage Info.
- //
- ZeroMem (&FvImageInfo, sizeof (FvImageInfo));
- Status = FfsGetVolumeInfo (FvImageHandle, &FvImageInfo);
- ASSERT_EFI_ERROR (Status);
-
- //
- // FvAlignment must be more than 8 bytes required by FvHeader structure.
- //
- FvAlignment = 1 << ((FvImageInfo.FvAttributes & EFI_FVB2_ALIGNMENT) >> 16);
- if (FvAlignment < 8) {
- FvAlignment = 8;
- }
-
- //
- // Check FvImage
- //
- if ((UINTN) FvImageInfo.FvStart % FvAlignment != 0) {
- FvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvImageInfo.FvSize), FvAlignment);
- if (FvBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem (FvBuffer, FvImageInfo.FvStart, (UINTN) FvImageInfo.FvSize);
- //
- // Update FvImageInfo after reload FvImage to new aligned memory
- //
- FfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo);
- }
-
-
- //
- // Inform HOB consumer phase, i.e. DXE core, the existance of this FV
- //
- BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart, FvImageInfo.FvSize);
-
- //
- // Makes the encapsulated volume show up in DXE phase to skip processing of
- // encapsulated file again.
- //
- BuildFv2Hob (
- (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,
- FvImageInfo.FvSize,
- &FvImageInfo.FvName,
- &(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name)
- );
-
- return EFI_SUCCESS;
-}
-
-
diff --git a/EmbeddedPkg/Library/PrePiLib/PrePi.h b/EmbeddedPkg/Library/PrePiLib/PrePi.h
deleted file mode 100644
index 607561cd24..0000000000
--- a/EmbeddedPkg/Library/PrePiLib/PrePi.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/** @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
diff --git a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c
deleted file mode 100644
index 9a1ef344df..0000000000
--- a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/** @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;
-}
-
-
diff --git a/EmbeddedPkg/Library/PrePiLib/PrePiLib.inf b/EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
deleted file mode 100644
index b27b0441d5..0000000000
--- a/EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
+++ /dev/null
@@ -1,85 +0,0 @@
-#/** @file
-# Component description file for Apple Pre PI Library
-#
-# LIbrary helps you build a platform that skips PEI and loads DXE Core
-# directly. Helps building HOBs, reading data from the FV, and doing
-# decompression.
-#
-# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PrePiLib
- FILE_GUID = 1F3A3278-82EB-4C0D-86F1-5BCDA5846CB2
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = PrePiLib
-
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- FwVol.c
- PrePiLib.c
- ReportStatusCode.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec # needed to support StatusCodes
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec # needed to support StatusCodes
-
-
-[LibraryClasses]
- BaseLib
- DebugLib
- BaseMemoryLib
- UefiDecompressLib
- PeCoffLib
- CacheMaintenanceLib
- PrintLib
- SerialPortLib
- ExtractGuidedSectionLib
- TimerLib
- PerformanceLib
- HobLib
-
-[Guids]
- gEfiStatusCodeSpecificDataGuid
- gEfiMemoryTypeInformationGuid
- gEfiStatusCodeDataTypeDebugGuid
-
-[Protocols]
- gEfiStatusCodeRuntimeProtocolGuid
- gPeCoffLoaderProtocolGuid
-
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
-
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
diff --git a/EmbeddedPkg/Library/PrePiLib/ReportStatusCode.c b/EmbeddedPkg/Library/PrePiLib/ReportStatusCode.c
deleted file mode 100644
index 7a0b90a1e6..0000000000
--- a/EmbeddedPkg/Library/PrePiLib/ReportStatusCode.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/** @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>
-
-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 *));
-}
-
diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
deleted file mode 100644
index 0e75e23933..0000000000
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/** @file
- Implementation of the 6 PEI Ffs (FV) APIs in library form.
-
- 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 <PiPei.h>
-
-#include <Library/BaseLib.h>
-#include <Library/PrePiLib.h>
-#include <Library/DebugLib.h>
-
-
-
-/**
- Allocates one or more 4KB pages of type EfiBootServicesData.
-
- Allocates the number of 4KB pages of MemoryType and returns a pointer to the
- allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
- is returned. If there is not enough memory remaining to satisfy the request, then NULL is
- returned.
-
- @param Pages The number of 4 KB pages to allocate.
-
- @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocatePages (
- IN UINTN Pages
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
- EFI_PHYSICAL_ADDRESS Offset;
-
- Hob.Raw = GetHobList ();
-
- // Check to see if on 4k boundary
- Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;
- if (Offset != 0) {
- // If not aligned, make the allocation aligned.
- Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;
- }
-
- //
- // Verify that there is sufficient memory to satisfy the allocation
- //
- if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) < Hob.HandoffInformationTable->EfiFreeMemoryBottom) {
- return 0;
- } else {
- //
- // Update the PHIT to reflect the memory usage
- //
- Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;
-
- // This routine used to create a memory allocation HOB a la PEI, but that's not
- // necessary for us.
-
- //
- // Create a memory allocation HOB.
- //
- BuildMemoryAllocationHob (
- Hob.HandoffInformationTable->EfiFreeMemoryTop,
- Pages * EFI_PAGE_SIZE,
- EfiBootServicesData
- );
- return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
- }
-}
-
-
-/**
- Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
-
- Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
- alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
- returned. If there is not enough memory at the specified alignment remaining to satisfy the
- request, then NULL is returned.
- If Alignment is not a power of two and Alignment is not zero, then ASSERT().
-
- @param Pages The number of 4 KB pages to allocate.
- @param Alignment The requested alignment of the allocation. Must be a power of two.
- If Alignment is zero, then byte alignment is used.
-
- @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocateAlignedPages (
- IN UINTN Pages,
- IN UINTN Alignment
- )
-{
- VOID *Memory;
- UINTN AlignmentMask;
-
- //
- // Alignment must be a power of two or zero.
- //
- ASSERT ((Alignment & (Alignment - 1)) == 0);
-
- if (Pages == 0) {
- return NULL;
- }
- //
- // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
- //
- ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment)));
- //
- // We would rather waste some memory to save PEI code size.
- //
- Memory = (VOID *)(UINTN)AllocatePages (Pages + EFI_SIZE_TO_PAGES (Alignment));
- if (Alignment == 0) {
- AlignmentMask = Alignment;
- } else {
- AlignmentMask = Alignment - 1;
- }
- return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask);
-}
-
-
-/**
- Frees one or more 4KB pages that were previously allocated with one of the page allocation
- functions in the Memory Allocation Library.
-
- Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
- must have been allocated on a previous call to the page allocation services of the Memory
- Allocation Library. If it is not possible to free allocated pages, then this function will
- perform no actions.
-
- If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
- then ASSERT().
- If Pages is zero, then ASSERT().
-
- @param Buffer Pointer to the buffer of pages to free.
- @param Pages The number of 4 KB pages to free.
-
-**/
-VOID
-EFIAPI
-FreePages (
- IN VOID *Buffer,
- IN UINTN Pages
- )
-{
- // For now, we do not support the ability to free pages in the PrePei Memory Allocator.
- // The allocated memory is lost.
-}
-
-/**
- Allocates a buffer of type EfiBootServicesData.
-
- Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
- pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
- returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
-
- @param AllocationSize The number of bytes to allocate.
-
- @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocatePool (
- IN UINTN AllocationSize
- )
-{
- EFI_HOB_MEMORY_POOL *Hob;
-
- Hob = GetHobList ();
-
-
- //
- // Verify that there is sufficient memory to satisfy the allocation
- //
- if (AllocationSize > 0x10000) {
- // Please call AllcoatePages for big allocations
- return 0;
- } else {
-
- Hob = (EFI_HOB_MEMORY_POOL *)CreateHob (EFI_HOB_TYPE_MEMORY_POOL, (UINT16)(sizeof (EFI_HOB_TYPE_MEMORY_POOL) + AllocationSize));
- return (VOID *)(Hob + 1);
- }
-}
-
-/**
- Frees a buffer that was previously allocated with one of the pool allocation functions in the
- Memory Allocation Library.
-
- Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
- pool allocation services of the Memory Allocation Library. If it is not possible to free pool
- resources, then this function will perform no actions.
-
- If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
- then ASSERT().
-
- @param Buffer Pointer to the buffer to free.
-
-**/
-VOID
-EFIAPI
-FreePool (
- IN VOID *Buffer
- )
-{
- // Not implemented yet
-}
diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
deleted file mode 100644
index 21f6eb1e14..0000000000
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
+++ /dev/null
@@ -1,39 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2011, ARM Ltd. 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 = PrePiMemoryAllocationLib
- FILE_GUID = 4f14c900-51a9-11e0-afbf-0002a5d5c51b
- MODULE_TYPE = PEIM
- VERSION_STRING = 1.0
- LIBRARY_CLASS = MemoryAllocationLib
-
-
-#
-# VALID_ARCHITECTURES = ARM
-#
-
-[Sources]
- MemoryAllocationLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- DebugLib
- BaseMemoryLib
- PrePiLib
- #PeiServicesLib
-
diff --git a/EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c b/EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c
deleted file mode 100644
index 8e4ee9b919..0000000000
--- a/EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/** @file
- Implement EFI RealTimeClock runtime services via RTC Lib.
-
- Currently this driver does not support runtime virtual calling.
-
- 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 <PiDxe.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/RealTimeClockLib.h>
-
-
-/**
- Returns the current time and date information, and the time-keeping capabilities
- of the hardware platform.
-
- @param Time A pointer to storage to receive a snapshot of the current time.
- @param Capabilities An optional pointer to a buffer to receive the real time clock
- device's capabilities.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER Time is NULL.
- @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibGetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities
- )
-{
- //
- // Fill in Time and Capabilities via data from you RTC
- //
- return EFI_DEVICE_ERROR;
-}
-
-
-/**
- Sets the current local time and date information.
-
- @param Time A pointer to the current time.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibSetTime (
- IN EFI_TIME *Time
- )
-{
- //
- // Use Time, to set the time in your RTC hardware
- //
- return EFI_DEVICE_ERROR;
-}
-
-
-/**
- Returns the current wakeup alarm clock setting.
-
- @param Enabled Indicates if the alarm is currently enabled or disabled.
- @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
- @param Time The current alarm setting.
-
- @retval EFI_SUCCESS The alarm settings were returned.
- @retval EFI_INVALID_PARAMETER Any parameter is NULL.
- @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
- )
-{
- // Not a required feature
- return EFI_UNSUPPORTED;
-}
-
-
-/**
- Sets the system wakeup alarm clock time.
-
- @param Enabled Enable or disable the wakeup alarm.
- @param Time If Enable is TRUE, the time to set the wakeup alarm for.
-
- @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
- Enable is FALSE, then the wakeup alarm was disabled.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
- @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
-
-**/
-EFI_STATUS
-EFIAPI
-LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
- )
-{
- // Not a required feature
- return EFI_UNSUPPORTED;
-}
-
-
-
-/**
- This is the declaration of an EFI image entry point. This can be the entry point to an application
- written to this specification, an EFI boot service driver, or an EFI runtime driver.
-
- @param ImageHandle Handle that identifies the loaded image.
- @param SystemTable System Table for this image.
-
- @retval EFI_SUCCESS The operation completed successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-LibRtcInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // Do some initialization if reqruied to turn on the RTC
- //
- return EFI_SUCCESS;
-}
-
-
-/**
- Fixup internal data so that EFI can be call in virtual mode.
- Call the passed in Child Notify event and convert any pointers in
- lib to virtual mode.
-
- @param[in] Event The Event that is being processed
- @param[in] Context Event Context
-**/
-VOID
-EFIAPI
-LibRtcVirtualNotifyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- //
- // Only needed if you are going to support the OS calling RTC functions in virtual mode.
- // You will need to call EfiConvertPointer (). To convert any stored physical addresses
- // to virtual address. After the OS transistions to calling in virtual mode, all future
- // runtime calls will be made in virtual mode.
- //
- return;
-}
-
-
-
diff --git a/EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf b/EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
deleted file mode 100644
index ebc3729aae..0000000000
--- a/EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
+++ /dev/null
@@ -1,36 +0,0 @@
-#/** @file
-# Memory Status Code Library for UEFI drivers
-#
-# Lib to provide memory journal status code reporting Routines
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = TemplateRealTimeClockLib
- FILE_GUID = B661E02D-A90B-42AB-A5F9-CF841AAA43D9
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = RealTimeClockLib
-
-
-[Sources.common]
- RealTimeClockLib.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- IoLib
- DebugLib
diff --git a/EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c b/EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
deleted file mode 100644
index 328bcbcf16..0000000000
--- a/EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/** @file
- Template library implementation to support ResetSystem Runtime call.
-
- Fill in the templates with what ever makes you system reset.
-
-
- 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 <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/IoLib.h>
-#include <Library/EfiResetSystemLib.h>
-
-
-/**
- Resets the entire platform.
-
- @param ResetType The type of reset to perform.
- @param ResetStatus The status code for the reset.
- @param DataSize The size, in bytes, of WatchdogData.
- @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
- EfiResetShutdown the data buffer starts with a Null-terminated
- Unicode string, optionally followed by additional binary data.
-
-**/
-EFI_STATUS
-EFIAPI
-LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- )
-{
- UINTN Address;
- UINT8 Data;
-
-
- switch (ResetType) {
- case EfiResetCold:
- // system power cycle
-
- // Example using IoLib functions to do IO.
- Address = 0x12345678;
- Data = MmioRead8 (Address);
- MmioWrite8 (Address, Data | 0x01);
-
- // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing
- break;
-
- case EfiResetWarm:
- // not a full power cycle, maybe memory stays around.
- // if not support do the same thing as EfiResetCold.
- break;
-
- case EfiResetShutdown:
- // turn off the system.
- // if not support do the same thing as EfiResetCold.
- break;
-
- default:
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // If we reset, we would not have returned...
- //
- return EFI_DEVICE_ERROR;
-}
-
-
-
-/**
- Initialize any infrastructure required for LibResetSystem () to function.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-EFI_STATUS
-EFIAPI
-LibInitializeResetSystem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return EFI_SUCCESS;
-}
-
diff --git a/EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf b/EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf
deleted file mode 100644
index 375cb49421..0000000000
--- a/EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf
+++ /dev/null
@@ -1,35 +0,0 @@
-#/** @file
-# Memory Status Code Library for UEFI drivers
-#
-# Lib to provide memory journal status code reporting Routines
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = TemplateResetSystemLib
- FILE_GUID = 40BAFDE5-4CC8-4FBE-A8BA-071890076E50
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiResetSystemLib
-
-
-[Sources.common]
- ResetSystemLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- IoLib
- DebugLib \ No newline at end of file
diff --git a/EmbeddedPkg/License.txt b/EmbeddedPkg/License.txt
deleted file mode 100755
index 05dbd3606d..0000000000
--- a/EmbeddedPkg/License.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright (c) 2009-2010, Apple Inc. All rights reserved.
-Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-* Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-* 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 HOLDER 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.
diff --git a/EmbeddedPkg/MetronomeDxe/Metronome.c b/EmbeddedPkg/MetronomeDxe/Metronome.c
deleted file mode 100644
index b43bf9558b..0000000000
--- a/EmbeddedPkg/MetronomeDxe/Metronome.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/** @file
-
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2013, 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.
-
-**/
-
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/PcdLib.h>
-#include <Library/TimerLib.h>
-
-#include <Protocol/Metronome.h>
-
-EFI_STATUS
-EFIAPI
-WaitForTick (
- IN EFI_METRONOME_ARCH_PROTOCOL *This,
- IN UINT32 TickNumber
- );
-
-/**
- Interface structure for the Metronome Architectural Protocol.
-
- @par Protocol Description:
- This protocol provides access to a known time source in the platform to the
- core. The core uses this known time source to produce core services that
- require calibrated delays.
-
- @param WaitForTick
- Waits for a specified number of ticks from a known time source
- in the platform. The actual time passed between entry of this
- function and the first tick is between 0 and TickPeriod 100 nS
- units. If you want to guarantee that at least TickPeriod time
- has elapsed, wait for two ticks.
-
- @param TickPeriod
- The period of platform's known time source in 100 nS units.
- This value on any platform must be at least 10 uS, and must not
- exceed 200 uS. The value in this field is a constant that must
- not be modified after the Metronome architectural protocol is
- installed. All consumers must treat this as a read-only field.
-
-**/
-EFI_METRONOME_ARCH_PROTOCOL gMetronome = {
- WaitForTick,
- FixedPcdGet32 (PcdMetronomeTickPeriod)
-};
-
-
-/**
- The WaitForTick() function waits for the number of ticks specified by
- TickNumber from a known time source in the platform. If TickNumber of
- ticks are detected, then EFI_SUCCESS is returned. The actual time passed
- between entry of this function and the first tick is between 0 and
- TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod
- time has elapsed, wait for two ticks. This function waits for a hardware
- event to determine when a tick occurs. It is possible for interrupt
- processing, or exception processing to interrupt the execution of the
- WaitForTick() function. Depending on the hardware source for the ticks, it
- is possible for a tick to be missed. This function cannot guarantee that
- ticks will not be missed. If a timeout occurs waiting for the specified
- number of ticks, then EFI_TIMEOUT is returned.
-
- @param This The EFI_METRONOME_ARCH_PROTOCOL instance.
- @param TickNumber Number of ticks to wait.
-
- @retval EFI_SUCCESS The wait for the number of ticks specified by TickNumber
- succeeded.
- @retval EFI_TIMEOUT A timeout occurred waiting for the specified number of ticks.
-
-**/
-EFI_STATUS
-EFIAPI
-WaitForTick (
- IN EFI_METRONOME_ARCH_PROTOCOL *This,
- IN UINT32 TickNumber
- )
-{
- //
- // Compute how long to stall the CPU.
- // gMetronome.TickPeriod is in 100 ns units so it needs to be divided by 10
- // to get it in microseconds units.
- //
- MicroSecondDelay (TickNumber * gMetronome.TickPeriod / 10);
- return EFI_SUCCESS;
-}
-
-
-EFI_HANDLE gMetronomeHandle = NULL;
-
-
-
-/**
- Initialize the state information for the CPU Architectural Protocol
-
- @param ImageHandle of the loaded driver
- @param SystemTable Pointer to the System Table
-
- @retval EFI_SUCCESS Protocol registered
- @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
- @retval EFI_DEVICE_ERROR Hardware problems
-
-**/
-EFI_STATUS
-MetronomeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Do any hardware init required to make WaitForTick () to work here.
- //
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &gMetronomeHandle,
- &gEfiMetronomeArchProtocolGuid, &gMetronome,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
diff --git a/EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf b/EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
deleted file mode 100644
index bb5bf0ee95..0000000000
--- a/EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
+++ /dev/null
@@ -1,50 +0,0 @@
-#/** @file
-#
-# Component description file for Bds module
-#
-# Copyright (c) 2008, Apple Inc. All rights reserved.
-# 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MetronomeDxe
- FILE_GUID = 4C6E0267-C77D-410D-8100-1495911A989D
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = MetronomeInitialize
-
-[Sources.common]
- Metronome.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- BaseLib
- UefiLib
- UefiBootServicesTableLib
- DebugLib
- PrintLib
- UefiDriverEntryPoint
- TimerLib
-
-[FixedPcd]
- gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod
-
-[Protocols]
- gEfiMetronomeArchProtocolGuid
-
-[depex]
- TRUE
diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
deleted file mode 100644
index 80af8cf824..0000000000
--- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/** @file
- Implement EFI RealTimeClock runtime services via RTC Lib.
-
- Currently this driver does not support runtime virtual calling.
-
-
- 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 <PiDxe.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/RealTimeClockLib.h>
-#include <Protocol/RealTimeClock.h>
-
-EFI_HANDLE mHandle = NULL;
-
-
-
-/**
- Returns the current time and date information, and the time-keeping capabilities
- of the hardware platform.
-
- @param Time A pointer to storage to receive a snapshot of the current time.
- @param Capabilities An optional pointer to a buffer to receive the real time clock
- device's capabilities.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER Time is NULL.
- @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-GetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities
- )
-{
- return LibGetTime (Time, Capabilities);
-}
-
-
-
-/**
- Sets the current local time and date information.
-
- @param Time A pointer to the current time.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-SetTime (
- IN EFI_TIME *Time
- )
-{
- return LibSetTime (Time);
-}
-
-
-/**
- Returns the current wakeup alarm clock setting.
-
- @param Enabled Indicates if the alarm is currently enabled or disabled.
- @param Pending Indicates if the alarm signal is pending and requires acknowledgement.
- @param Time The current alarm setting.
-
- @retval EFI_SUCCESS The alarm settings were returned.
- @retval EFI_INVALID_PARAMETER Any parameter is NULL.
- @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.
-
-**/
-EFI_STATUS
-EFIAPI
-GetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
- )
-{
- return LibGetWakeupTime (Enabled, Pending, Time);
-}
-
-
-/**
- Sets the system wakeup alarm clock time.
-
- @param Enabled Enable or disable the wakeup alarm.
- @param Time If Enable is TRUE, the time to set the wakeup alarm for.
-
- @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled. If
- Enable is FALSE, then the wakeup alarm was disabled.
- @retval EFI_INVALID_PARAMETER A time field is out of range.
- @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.
- @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.
-
-**/
-EFI_STATUS
-EFIAPI
-SetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
- )
-{
- return LibSetWakeupTime (Enabled, Time);
-}
-
-
-
-/**
- This is the declaration of an EFI image entry point. This can be the entry point to an application
- written to this specification, an EFI boot service driver, or an EFI runtime driver.
-
- @param ImageHandle Handle that identifies the loaded image.
- @param SystemTable System Table for this image.
-
- @retval EFI_SUCCESS The operation completed successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeRealTimeClock (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- LibRtcInitialize (ImageHandle, SystemTable);
-
- SystemTable->RuntimeServices->GetTime = GetTime;
- SystemTable->RuntimeServices->SetTime = SetTime;
- SystemTable->RuntimeServices->GetWakeupTime = GetWakeupTime;
- SystemTable->RuntimeServices->SetWakeupTime = SetWakeupTime;
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mHandle,
- &gEfiRealTimeClockArchProtocolGuid,
- NULL,
- NULL
- );
-
- return Status;
-}
-
diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
deleted file mode 100644
index 186d4610bd..0000000000
--- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
+++ /dev/null
@@ -1,44 +0,0 @@
-#/** @file
-# Reset Architectural Protocol Driver as defined in PI
-#
-# This Reset module simulates system reset by process exit on NT.
-# Copyright (c) 2006 - 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]
- INF_VERSION = 0x00010005
- BASE_NAME = RealTimeClock
- FILE_GUID = B336F62D-4135-4A55-AE4E-4971BBF0885D
- MODULE_TYPE = DXE_RUNTIME_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = InitializeRealTimeClock
-
-[Sources.common]
- RealTimeClock.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- DebugLib
- RealTimeClockLib
-
-[Protocols]
- gEfiRealTimeClockArchProtocolGuid
-
-[Depex]
- TRUE
-
diff --git a/EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf b/EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
deleted file mode 100644
index 95cdee4c17..0000000000
--- a/EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
+++ /dev/null
@@ -1,50 +0,0 @@
-#/** @file
-# Reset Architectural Protocol Driver as defined in PI
-#
-# This Reset module simulates system reset by process exit on NT.
-# Copyright (c) 2006 - 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]
- INF_VERSION = 0x00010005
- BASE_NAME = Reset
- FILE_GUID = 16036A73-E8EF-46D0-953C-9B8E96527D13
- MODULE_TYPE = DXE_RUNTIME_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = InitializeReset
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32
-#
-
-[Sources.common]
- reset.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- DebugLib
- EfiResetSystemLib
-
-[Protocols]
- gEfiResetArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
-
-[Depex]
- TRUE
-
diff --git a/EmbeddedPkg/ResetRuntimeDxe/reset.c b/EmbeddedPkg/ResetRuntimeDxe/reset.c
deleted file mode 100644
index 3b9129ed29..0000000000
--- a/EmbeddedPkg/ResetRuntimeDxe/reset.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/** @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 <PiDxe.h>
-#include <Protocol/Reset.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/EfiResetSystemLib.h>
-
-
-/**
- Resets the entire platform.
-
- @param ResetType The type of reset to perform.
- @param ResetStatus The status code for the reset.
- @param DataSize The size, in bytes, of WatchdogData.
- @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
- EfiResetShutdown the data buffer starts with a Null-terminated
- Unicode string, optionally followed by additional binary data.
-
-**/
-VOID
-EFIAPI
-ResetSystemViaLib (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
- )
-{
- LibResetSystem (ResetType, ResetStatus, DataSize, ResetData);
- return;
-}
-
-
-
-EFI_STATUS
-EFIAPI
-InitializeReset (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
-
- LibInitializeResetSystem (ImageHandle, SystemTable);
-
- SystemTable->RuntimeServices->ResetSystem = ResetSystemViaLib;
-
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiResetArchProtocolGuid,
- NULL,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM b/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM
deleted file mode 100755
index d02b02297c..0000000000
--- a/EmbeddedPkg/Scripts/LauterbachT32/EFI.CMM
+++ /dev/null
@@ -1,40 +0,0 @@
-;
-; Copyright (c) 2011, Hewlett-Packard Company. 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.
-;
-
-;choose hex mode for input
- radix hex
-
- menu.rp
- (
- add
- toolbar
- (
- separator
- toolitem "Reset Target" "RS" "sys.ResetTarget"
- separator
- toolitem "Load EFI DXE Symbols" "DX" "do EfiLoadDxe"
- toolitem "Load EFI Runtime Symbols" "RT" "do EfiLoadRuntimeDxe"
- )
- )
-
- system.config.debugaccessport 0
- system.config.corebase 0x80001000
- system.attach
- break.sel.program onchip
-
- setup.var %hex.on
- setup.var %decimal.OFF
-
-
-enddo
-
-
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
deleted file mode 100755
index 8ec1ac4bf3..0000000000
--- a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadDxe.cmm
+++ /dev/null
@@ -1,135 +0,0 @@
-;
-; Copyright (c) 2011, Hewlett-Packard Company. 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.
-;
-
- LOCAL &maxmem &systbl &memsize
-
- &memsize=0x20000000 ; default to 512MB
-
- gosub FindSystemTable &memsize
- ENTRY &systbl
-
- if &systbl!=0
- (
- print "found system table at &systbl"
- gosub FindDebugInfo &systbl
- )
- else
- (
- print "ERROR: system table not found, check memory size"
- )
- enddo
-
-FindSystemTable:
- LOCAL &TopOfRam &offset
- ENTRY &TopOfRam
-
- print "FindSystemTable"
- print "top of mem is &TopOfRam$"
-
- &offset=&TopOfRam
-
- ; align to highest 4MB boundary
- &offset=&offset&0xFFC00000
-
- ; start at top and look on 4MB boundaries for system table ptr structure
- while &offset>0
- (
- ; low signature match
- if Data.Long(a:&offset)==0x20494249
- (
- ; high signature match
- if Data.Long(a:&offset+4)==0x54535953
- (
- ; less than 4GB?
- if Data.Long(a:&offset+0x0c)==0
- (
- ; less than top of ram?
- if Data.Long(a:&offset+8)<&TopOfRam
- (
- return Data.Long(a:&offset+8)
- )
- )
- )
- )
-
- if &offset<0x400000
- (
- return 0
- )
- &offset=&offset-0x400000
- )
-
- return 0
-
-
-FindDebugInfo:
- LOCAL &SystemTable &CfgTableEntries &ConfigTable &i &offset &dbghdr &dbgentries &dbgptr &dbginfo &loadedimg
- ENTRY &SystemTable
-
- print "FindDebugInfo"
-
- &dbgentries=0
- &CfgTableEntries=Data.Long(a:&SystemTable+0x40)
- &ConfigTable=Data.Long(a:&SystemTable+0x44)
-
- print "config table is at &ConfigTable (&CfgTableEntries entries)"
-
- ; now search for debug info entry with guid 49152E77-1ADA-4764-B7A2-7AFEFED95E8B
- ; 0x49152E77 0x47641ADA 0xFE7AA2B7 0x8B5ED9FE
- &i=0
- while &i<&CfgTableEntries
- (
- &offset=&ConfigTable+(&i*0x14)
- if Data.Long(a:&offset)==0x49152E77
- (
- if Data.Long(a:&offset+4)==0x47641ADA
- (
- if Data.Long(a:&offset+8)==0xFE7AA2B7
- (
- if Data.Long(a:&offset+0xc)==0x8B5ED9FE
- (
- &dbghdr=Data.Long(a:&offset+0x10)
- &dbgentries=Data.Long(a:&dbghdr+4)
- &dbgptr=Data.Long(a:&dbghdr+8)
- )
- )
- )
- )
-
- &i=&i+1
- )
-
- if &dbgentries==0
- (
- print "no debug entries found"
- return
- )
-
- print "debug table at &dbgptr (&dbgentries entries)"
-
- symbol.reset
-
- &i=0
- while &i<&dbgentries
- (
- &dbginfo=Data.Long(a:&dbgptr+(&i*4))
- if &dbginfo!=0
- (
- if Data.Long(a:&dbginfo)==1 ; normal debug info type
- (
- &loadedimg=Data.Long(a:&dbginfo+4)
- do EfiProcessPeImage Data.Long(a:&loadedimg+0x20)
- )
- )
- &i=&i+1
- )
- return
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm
deleted file mode 100755
index e6ccc35b92..0000000000
--- a/EmbeddedPkg/Scripts/LauterbachT32/EfiLoadFv.cmm
+++ /dev/null
@@ -1,131 +0,0 @@
-;
-; Copyright (c) 2011, Hewlett-Packard Company. 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.
-;
-
- LOCAL &fvbase &fvsig &fvsig &ffsoffset &ffsfilesize &ffsfileaddr
- ENTRY &fvbase
-
- &fvsig=Data.Long(a:&fvbase+0x28)
- if &fvsig!=0x4856465F
- (
- print "FV does not have proper signature, exiting"
- return
- )
-
- print "FV signature found"
-
- &fvlen=Data.Long(a:&fvbase+0x20)
-
- ; first ffs file is after fv header, use headerlength field
- &ffsoffset=(Data.Long(a:&fvbase+0x30)&0xffff)
-
- ; loop through ffs files
- &ffsfilesize=1
- while (&ffsfilesize!=0)&&(&ffsoffset<(&fvlen))
- (
- &ffsfileaddr=&fvbase+&ffsoffset
- ;print "found ffs file at &ffsfileaddr"
-
- ; process ffs file and increment by ffs file size field
- gosub ProcessFfsFile &ffsfileaddr
-
- &ffsfilesize=(Data.Long(a:&ffsfileaddr+0x14)&0x00ffffff)
- ;print "ffsfilesize is &ffsfilesize"
-
- &ffsoffset=&ffsoffset+&ffsfilesize
-
- &ffsfilesize=(Data.Long(a:&fvbase+&ffsoffset+0x14)&0x00ffffff)
- ;print "ffsfilesize now is &ffsfilesize"
- if &ffsfilesize==0xffffff
- (
- enddo
- )
-
- ; align to next 8 byte boundary
- if (&ffsoffset&0x7)!=0
- (
- &ffsoffset=&ffsoffset+(0x8-(&ffsoffset&0x7))
- )
-
- ) ; end fv ffs loop
-
-enddo
-
-ProcessFfsFile:
- LOCAL &ffsfilestart &ffsfilesize &ffsfiletype &secoffset &secsize
- ENTRY &ffsfilestart
-
- ;print "processing ffs file at &ffsfilestart"
- &ffsfilesize=Data.Long(a:&ffsfilestart+0x14)
- &ffsfiletype=(&ffsfilesize&0xff000000)>>24.
- &ffsfilesize=&ffsfilesize&0x00ffffff
-
- if &ffsfiletype==0
- (
- return
- )
-
- print "ffs file at &ffsfilestart size &ffsfilesize type &ffsfiletype"
-
- &secoffset=&ffsfilestart+0x18
-
- ; loop through sections in file
- while &secoffset<(&ffsfilestart+&ffsfilesize)
- (
- print "secoffset at &secoffset"
-
- ; process fv section and increment section offset by size
- &secsize=(Data.Long(a:&secoffset)&0x00ffffff)
-
- gosub ProcessFvSection &secoffset
-
-
- &secoffset=(&secoffset+&secsize)
-
- ;print "secsize is &secsize"
- ;print "secoffset at &secoffset"
-
- ; align to next 4 byte boundary
- if (&secoffset&0x3)!=0
- (
- &secoffset=&secoffset+(0x4-(&secoffset&0x3))
- )
- ) ; end section loop
- return
-
-
-ProcessFvSection:
- LOCAL &secstart &sectionsize &sectiontype &secoffset &secsize
- ENTRY &secstart
-
- &sectionsize=Data.Long(a:&secstart)
- &sectiontype=((&sectionsize&0xff000000)>>24.)
- &sectionsize=&sectionsize&0x00ffffff;
-
- print "fv section at &secstart size &sectionsize type &sectiontype"
-
- if &sectiontype==0x10 ; PE32
- (
- do EfiProcessPeImage (&secstart+0x4)
- )
- else
- (
- if &sectiontype==0x12 ; TE
- (
- do EfiProcessTeImage (&secstart+0x4)
- )
- else
- (
- print "unknown section type"
- )
- )
-
- return
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
deleted file mode 100755
index 53d830f7d2..0000000000
--- a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessPeImage.cmm
+++ /dev/null
@@ -1,77 +0,0 @@
-;
-; Copyright (c) 2011, Hewlett-Packard Company. 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.
-;
-
- LOCAL &imgstart &filehdrstart &debugdirentryrva &debugtype &debugrva &dwarfsig &baseofcode &baseofdata &elfbase &elfpath &pathoffset
- ENTRY &imgstart
-
- &imgstart=&imgstart
- print "PE32 image found at &imgstart"
-
- ; offset from dos hdr to PE file hdr
- &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
-
- ; offset to debug dir in PE hdrs
- &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
- if &debugdirentryrva==0
- (
- print "no debug dir for image at &imgstart"
- enddo
- )
-
- &debugtype=Data.Long(c:&imgstart+&debugdirentryrva+0xc)
- if (&debugtype!=0xdf)&&(&debugtype!=0x02)
- (
- print "debug type is not dwarf for image at &imgstart, it's &debugtype"
- enddo
- )
-
- &debugrva=Data.Long(c:&imgstart+&debugdirentryrva+0x14)
- &dwarfsig=Data.Long(c:&imgstart+&debugrva)
-
- if &dwarfsig==0x66727764
- (
- &pathoffset=0xc
- )
- else
- (
- if &dwarfsig==0x3031424E
- (
- &pathoffset=0x10
- )
- else
- (
- print "debug signature not found for image at &imgstart, its &dwarfsig"
- enddo
- )
- )
-
- &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
-
- &baseofcode=&imgstart+Data.Long(c:&filehdrstart+0x28)
- &baseofdata=&imgstart+Data.Long(c:&filehdrstart+0x2c)
-
- if (&baseofcode<&baseofdata)&&(&baseofcode!=0)
- (
- &elfbase=&baseofcode;
- )
- else
- (
- &elfbase=&baseofdata;
- )
-
- print "found path &elfpath"
- ON ERROR GOSUB
- return
- data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
- ON error
-
-enddo
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm b/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm
deleted file mode 100755
index 9347c9c35b..0000000000
--- a/EmbeddedPkg/Scripts/LauterbachT32/EfiProcessTeImage.cmm
+++ /dev/null
@@ -1,70 +0,0 @@
-;
-; Copyright (c) 2011, Hewlett-Packard Company. 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.
-;
-
- LOCAL &imgstart &strippedsize &debugdirentryrva &debugtype &debugrva &dwarfsig &elfbase &elfpath &pathoffset
- ENTRY &imgstart
-
- &imgstart=&imgstart
- print "TE image found at &imgstart"
-
- ; determine pe header bytes removed to account for in rva references
- &strippedsize=(Data.Long(a:&imgstart+0x4)&0xffff0000)>>16.
- &strippedsize=&strippedsize-0x28
-
- &debugdirentryrva=Data.Long(a:&imgstart+0x20)
- if &debugdirentryrva==0
- (
- print "no debug dir for image at &imgstart"
- enddo
- )
- &debugdirentryrva=&debugdirentryrva-&strippedsize
-
- &debugtype=Data.Long(a:&imgstart+&debugdirentryrva+0xc)
- if (&debugtype!=0xdf)&&(&debugtype!=0x02)
- (
- print "debug type is not dwarf for image at &imgstart, it's &debugtype"
- enddo
- )
-
- &debugrva=Data.Long(a:&imgstart+&debugdirentryrva+0x14)
- &debugrva=&debugrva-&strippedsize;
- &dwarfsig=Data.Long(a:&imgstart+&debugrva);
- if &dwarfsig==0x66727764
- (
- &pathoffset=0xc
- )
- else
- (
- if &dwarfsig==0x3031424E
- (
- &pathoffset=0x10
- )
- else
- (
- print "debug signature not found for image at &imgstart, its &dwarfsig"
- enddo
- )
- )
-
- &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
-
- ; elf base is baseofcode (we hope that for TE images it's not baseofdata)
- &elfbase=&imgstart+Data.Long(a:&imgstart+0xc)-&strippedsize
-
- print "found path &elfpath"
- ; $fprintf 50, "load /ni /np /a %s &0x%x\n",elfpath,elfbase$;
- ON ERROR GOSUB
- return
- data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
- ON error
-
-enddo
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/README.txt b/EmbeddedPkg/Scripts/LauterbachT32/README.txt
deleted file mode 100755
index 06602ab876..0000000000
--- a/EmbeddedPkg/Scripts/LauterbachT32/README.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-DXE Phase Debug
-===============
-Update the memsize variable in EfiLoadDxe.cmm for the actual amount of memory available in your system. Allow your system to boot to the point that the DXE core is initialized (so that the System Table and Debug Information table is present in memory) and execute this script (using the toolbar button or ‘do EfiLoadDxe’ from the command area). It will scan memory for the debug info table and load modules in it.
-
-SEC/PEI Phase Debug
-===================
-There is no way to autodetect where these images reside so you must pass an address for the memory-mapped Firmware Volume containing these images. To do this, enter ‘do EfiLoadFv <addr>’ where <addr> is the base address for the firmware volume containing the SEC or PEI code. To be more efficient you may want to create a script that calls this, like MyBoardLoadSec.cmm which contains the call to EfiLoadFv. You can them map this script to a T32 menu or toolbar button for quick access.
diff --git a/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM b/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM
deleted file mode 100755
index 8a73d5f0c2..0000000000
--- a/EmbeddedPkg/Scripts/LauterbachT32/T32.CMM
+++ /dev/null
@@ -1,65 +0,0 @@
-;
-; Copyright (c) 2011, Hewlett-Packard Company. 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.
-;
-
-; Copy this to your C:\T32 directory
-;Default startup program for TRACE32
-;
-;This startup program can be modified according to your needs.
-
-; update this path to reflect YOUR current working dir
-GLOBAL &wcdir
-&wcdir="D:\bios"
-
-;choose hex mode for input
- radix hex
-
-;Add some extra buttons to the toolbar
-
- menu.rp
- (
- add
- toolbar
- (
- separator
- toolitem "Source/List" ":list" "Data.List"
- toolitem "Memory Dump" ":dump" "Data.dump"
- toolitem "Register" ":reg" "Register"
- separator
- toolitem "Watch" ":varwatch" "Var.Watch"
- toolitem "Stack" ":varframe" "Var.Frame /l /c"
- toolitem "Automatic Watch" ":varref" "Var.Ref"
- separator
- toolitem "List Breakpoints" ":break" "Break.List"
- toolitem "List Symbols" ":symbols" "sYmbol.Browse"
- toolitem "System Settings" ":config" "SYStem"
- separator
- )
- )
-
- if language()!=""
- (
- local &menuname
- &menuname="~~/t32"+language()+".men"
- if os.file(&menuname)
- menu.rp &menuname
- )
-
-;Recall and Define History File
- autostore , history bookmark
-
-; Execute EFI setup script
- chdir &wcdir\Platform\T32_Scripts
- do EFI
-
-enddo
-
-
diff --git a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
deleted file mode 100644
index 8df58fce22..0000000000
--- a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
+++ /dev/null
@@ -1,759 +0,0 @@
-/** @file
- Simple Console that sits on a SerialLib.
-
- 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.
-
-**/
-
-/*
- Symbols used in table below
-===========================
- ESC = 0x1B
- CSI = 0x9B
- DEL = 0x7f
- ^ = CTRL
-
-+=========+======+===========+==========+==========+
-| | EFI | UEFI 2.0 | | |
-| | Scan | | VT100+ | |
-| KEY | Code | PC ANSI | VTUTF8 | VT100 |
-+=========+======+===========+==========+==========+
-| NULL | 0x00 | | | |
-| UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |
-| DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |
-| RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C |
-| LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |
-| HOME | 0x05 | ESC [ H | ESC h | ESC [ H |
-| END | 0x06 | ESC [ F | ESC k | ESC [ K |
-| INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |
-| | | ESC [ L | | ESC [ L |
-| DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |
-| PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |
-| | | | | ESC [ ? |
-| PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |
-| | | | | ESC [ / |
-| F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |
-| F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |
-| F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |
-| F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |
-| F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |
-| F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |
-| F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |
-| F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |
-| F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |
-| F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |
-| Escape | 0x17 | ESC | ESC | ESC |
-| F11 | 0x15 | | ESC ! | |
-| F12 | 0x16 | | ESC @ | |
-+=========+======+===========+==========+==========+
-
-*/
-
-#include <PiDxe.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/SerialPortLib.h>
-#include <Library/PcdLib.h>
-
-#include <Protocol/SerialIo.h>
-#include <Protocol/SimpleTextIn.h>
-#include <Protocol/SimpleTextOut.h>
-#include <Protocol/DevicePath.h>
-
-
-#define MODE0_COLUMN_COUNT 80
-#define MODE0_ROW_COUNT 25
-
-
-EFI_STATUS
-EFIAPI
-TextInReset(
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-
-EFI_STATUS
-EFIAPI
-ReadKeyStroke(
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
- );
-
-
-EFI_STATUS
-EFIAPI
-TextOutReset(
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-CHAR8 *
-EFIAPI
-SafeUnicodeStrToAsciiStr (
- IN CONST CHAR16 *Source,
- OUT CHAR8 *Destination
- );
-
-EFI_STATUS
-EFIAPI
-OutputString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *String
- );
-
-
-EFI_STATUS
-EFIAPI
-TestString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *String
- );
-
-
-EFI_STATUS
-EFIAPI
-QueryMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber,
- OUT UINTN *Columns,
- OUT UINTN *Rows
- );
-
-
-EFI_STATUS
-EFIAPI
-SetMode(
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber
- );
-
-
-EFI_STATUS
-EFIAPI
-SetAttribute(
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
- );
-
-
-EFI_STATUS
-EFIAPI
-ClearScreen (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
- );
-
-
-EFI_STATUS
-EFIAPI
-SetCursorPosition (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
- );
-
-
-EFI_STATUS
-EFIAPI
-EnableCursor (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN Enable
- );
-
-
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL mSimpleTextIn = {
- TextInReset,
- ReadKeyStroke,
- NULL
-};
-
- EFI_SIMPLE_TEXT_OUTPUT_MODE mSimpleTextOutMode = {
- 1,
- 0,
- EFI_TEXT_ATTR( EFI_LIGHTGRAY, EFI_BLACK ),
- 0,
- 0,
- TRUE
-};
-
-EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL mSimpleTextOut = {
- TextOutReset,
- OutputString,
- TestString,
- QueryMode,
- SetMode,
- SetAttribute,
- ClearScreen,
- SetCursorPosition,
- EnableCursor,
- &mSimpleTextOutMode
-};
-
-EFI_HANDLE mInstallHandle = NULL;
-
-typedef struct {
- VENDOR_DEVICE_PATH Guid;
- UART_DEVICE_PATH Uart;
- EFI_DEVICE_PATH_PROTOCOL End;
-} SIMPLE_TEXT_OUT_DEVICE_PATH;
-
-SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} },
- EFI_CALLER_ID_GUID
- },
- {
- { MESSAGING_DEVICE_PATH, MSG_UART_DP, { sizeof (UART_DEVICE_PATH), 0} },
- 0, // Reserved
- FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
- FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
- FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)
- FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
- },
- { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0} }
-};
-
-
-
-
-BOOLEAN
-TextOutIsValidAscii (
- IN CHAR16 Ascii
- )
-{
- //
- // valid ASCII code lies in the extent of 0x20 - 0x7F
- //
- if ((Ascii >= 0x20) && (Ascii <= 0x7F)) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-BOOLEAN
-TextOutIsValidEfiCntlChar (
- IN CHAR16 Char
- )
-{
- //
- // only support four control characters.
- //
- if (Char == CHAR_NULL ||
- Char == CHAR_BACKSPACE ||
- Char == CHAR_LINEFEED ||
- Char == CHAR_CARRIAGE_RETURN ||
- Char == CHAR_TAB ) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-VOID
-EFIAPI
-WaitForKeyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- if (SerialPortPoll ()) {
- gBS->SignalEvent (Event);
- }
-}
-
-
-EFI_STATUS
-EFIAPI
-TextInReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-ReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
- )
-{
- CHAR8 Char;
-
- if (!SerialPortPoll ()) {
- return EFI_NOT_READY;
- }
-
- SerialPortRead ((UINT8 *)&Char, 1);
-
- //
- // Check for ESC sequence. This code is not techincally correct VT100 code.
- // An illegal ESC sequence represents an ESC and the characters that follow.
- // This code will eat one or two chars after an escape. This is done to
- // prevent some complex FIFOing of the data. It is good enough to get
- // the arrow and delete keys working
- //
- Key->UnicodeChar = 0;
- Key->ScanCode = SCAN_NULL;
- if (Char == 0x1b) {
- SerialPortRead ((UINT8 *)&Char, 1);
- if (Char == '[') {
- SerialPortRead ((UINT8 *)&Char, 1);
- switch (Char) {
- case 'A':
- Key->ScanCode = SCAN_UP;
- break;
- case 'B':
- Key->ScanCode = SCAN_DOWN;
- break;
- case 'C':
- Key->ScanCode = SCAN_RIGHT;
- break;
- case 'D':
- Key->ScanCode = SCAN_LEFT;
- break;
- case 'H':
- Key->ScanCode = SCAN_HOME;
- break;
- case 'K':
- case 'F': // PC ANSI
- Key->ScanCode = SCAN_END;
- break;
- case '@':
- case 'L':
- Key->ScanCode = SCAN_INSERT;
- break;
- case 'P':
- case 'X': // PC ANSI
- Key->ScanCode = SCAN_DELETE;
- break;
- case 'U':
- case '/':
- case 'G': // PC ANSI
- Key->ScanCode = SCAN_PAGE_DOWN;
- break;
- case 'V':
- case '?':
- case 'I': // PC ANSI
- Key->ScanCode = SCAN_PAGE_UP;
- break;
-
- // PCANSI that does not conflict with VT100
- case 'M':
- Key->ScanCode = SCAN_F1;
- break;
- case 'N':
- Key->ScanCode = SCAN_F2;
- break;
- case 'O':
- Key->ScanCode = SCAN_F3;
- break;
- case 'Q':
- Key->ScanCode = SCAN_F5;
- break;
- case 'R':
- Key->ScanCode = SCAN_F6;
- break;
- case 'S':
- Key->ScanCode = SCAN_F7;
- break;
- case 'T':
- Key->ScanCode = SCAN_F8;
- break;
-
- default:
- Key->UnicodeChar = Char;
- break;
- }
- } else if (Char == '0') {
- SerialPortRead ((UINT8 *)&Char, 1);
- switch (Char) {
- case 'P':
- Key->ScanCode = SCAN_F1;
- break;
- case 'Q':
- Key->ScanCode = SCAN_F2;
- break;
- case 'w':
- Key->ScanCode = SCAN_F3;
- break;
- case 'x':
- Key->ScanCode = SCAN_F4;
- break;
- case 't':
- Key->ScanCode = SCAN_F5;
- break;
- case 'u':
- Key->ScanCode = SCAN_F6;
- break;
- case 'q':
- Key->ScanCode = SCAN_F7;
- break;
- case 'r':
- Key->ScanCode = SCAN_F8;
- break;
- case 'p':
- Key->ScanCode = SCAN_F9;
- break;
- case 'm':
- Key->ScanCode = SCAN_F10;
- break;
- default :
- break;
- }
- }
- } else if (Char < ' ') {
- if ((Char == CHAR_BACKSPACE) ||
- (Char == CHAR_TAB) ||
- (Char == CHAR_LINEFEED) ||
- (Char == CHAR_CARRIAGE_RETURN)) {
- // Only let through EFI required control characters
- Key->UnicodeChar = (CHAR16)Char;
- }
- } else if (Char == 0x7f) {
- Key->ScanCode = SCAN_DELETE;
- } else {
- Key->UnicodeChar = (CHAR16)Char;
- }
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-TextOutReset (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- EFI_STATUS Status;
-
- This->SetAttribute(
- This,
- EFI_TEXT_ATTR(This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK)
- );
-
- Status = This->SetMode (This, 0);
-
- return Status;
-}
-
-CHAR8 *
-EFIAPI
-SafeUnicodeStrToAsciiStr (
- IN CONST CHAR16 *Source,
- OUT CHAR8 *Destination
- )
-{
- CHAR8 *ReturnValue;
-
- ASSERT (Destination != NULL);
-
- //
- // ASSERT if Source is long than PcdMaximumUnicodeStringLength.
- // Length tests are performed inside StrLen().
- //
- ASSERT (StrSize (Source) != 0);
-
- //
- // Source and Destination should not overlap
- //
- ASSERT ((UINTN) ((CHAR16 *) Destination - Source) > StrLen (Source));
- ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source));
-
-
- ReturnValue = Destination;
- while (*Source != '\0') {
- //
- // If any non-ascii characters in Source then replace it with '?'.
- //
- if (*Source < 0x80) {
- *Destination = (CHAR8) *Source;
- } else {
- *Destination = '?';
-
- //Surrogate pair check.
- if ((*Source >= 0xD800) && (*Source <= 0xDFFF)) {
- Source++;
- }
- }
-
- Destination++;
- Source++;
- }
-
- *Destination = '\0';
-
- //
- // ASSERT Original Destination is less long than PcdMaximumAsciiStringLength.
- // Length tests are performed inside AsciiStrLen().
- //
- ASSERT (AsciiStrSize (ReturnValue) != 0);
-
- return ReturnValue;
-}
-
-EFI_STATUS
-EFIAPI
-OutputString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *String
- )
-{
- UINTN Size;
- CHAR8* OutputString;
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
- UINTN MaxColumn;
- UINTN MaxRow;
-
- Size = StrLen(String) + 1;
- OutputString = AllocatePool(Size);
-
- //If there is any non-ascii characters in String buffer then replace it with '?'
- //Eventually, UnicodeStrToAsciiStr API should be fixed.
- SafeUnicodeStrToAsciiStr(String, OutputString);
- SerialPortWrite ((UINT8 *)OutputString, Size - 1);
-
- //
- // Parse each character of the string to output
- // to update the cursor position information
- //
- Mode = This->Mode;
-
- Status = This->QueryMode (
- This,
- Mode->Mode,
- &MaxColumn,
- &MaxRow
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (; *String != CHAR_NULL; String++) {
-
- switch (*String) {
- case CHAR_BACKSPACE:
- if (Mode->CursorColumn > 0) {
- Mode->CursorColumn--;
- }
- break;
-
- case CHAR_LINEFEED:
- if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
- Mode->CursorRow++;
- }
- break;
-
- case CHAR_CARRIAGE_RETURN:
- Mode->CursorColumn = 0;
- break;
-
- default:
- if (Mode->CursorColumn >= (INT32) (MaxColumn - 1)) {
- // Move the cursor as if we print CHAR_CARRIAGE_RETURN & CHAR_LINE_FEED
- // CHAR_LINEFEED
- if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
- Mode->CursorRow++;
- }
- // CHAR_CARIAGE_RETURN
- Mode->CursorColumn = 0;
- } else {
- Mode->CursorColumn++;
- }
- break;
- }
- }
-
- FreePool(OutputString);
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-TestString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *String
- )
-{
- CHAR8 Character;
-
- for ( ; *String != CHAR_NULL; String++) {
- Character = (CHAR8)*String;
- if (!(TextOutIsValidAscii (Character) || TextOutIsValidEfiCntlChar (Character))) {
- return EFI_UNSUPPORTED;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-QueryMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber,
- OUT UINTN *Columns,
- OUT UINTN *Rows
- )
-{
- if (This->Mode->MaxMode > 1) {
- return EFI_DEVICE_ERROR;
- }
-
- if (ModeNumber == 0) {
- *Columns = MODE0_COLUMN_COUNT;
- *Rows = MODE0_ROW_COUNT;
- return EFI_SUCCESS;
- }
-
- return EFI_UNSUPPORTED;
-}
-
-
-EFI_STATUS
-EFIAPI
-SetMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber
- )
-{
- if (ModeNumber != 0) {
- return EFI_UNSUPPORTED;
- }
-
- This->Mode->Mode = 0;
- This->ClearScreen (This);
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-SetAttribute(
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
- )
-{
- This->Mode->Attribute = (INT32)Attribute;
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-ClearScreen (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
- )
-{
- EFI_STATUS Status;
-
- Status = This->SetCursorPosition (This, 0, 0);
- return Status;
-}
-
-
-EFI_STATUS
-EFIAPI
-SetCursorPosition (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
- )
-{
- EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
- EFI_STATUS Status;
- UINTN MaxColumn;
- UINTN MaxRow;
-
- Mode = This->Mode;
-
- Status = This->QueryMode(
- This,
- Mode->Mode,
- &MaxColumn,
- &MaxRow
- );
- if (EFI_ERROR(Status)) {
- return EFI_UNSUPPORTED;
- }
-
- if ((Column >= MaxColumn) || (Row >= MaxRow)) {
- return EFI_UNSUPPORTED;
- }
-
- Mode->CursorColumn = (INT32)Column;
- Mode->CursorRow = (INT32)Row;
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-EnableCursor (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN Enable
- )
-{
- if (!Enable) {
- return EFI_UNSUPPORTED;
- }
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-SimpleTextInOutEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_WAIT,
- TPL_NOTIFY,
- WaitForKeyEvent,
- NULL,
- &mSimpleTextIn.WaitForKey
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->InstallMultipleProtocolInterfaces(
- &mInstallHandle,
- &gEfiSimpleTextInProtocolGuid, &mSimpleTextIn,
- &gEfiSimpleTextOutProtocolGuid, &mSimpleTextOut,
- &gEfiDevicePathProtocolGuid, &mDevicePath,
- NULL
- );
- if (!EFI_ERROR (Status)) {
- gST->ConOut = &mSimpleTextOut;
- gST->ConIn = &mSimpleTextIn;
- }
-
- return Status;
-}
diff --git a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
deleted file mode 100644
index 4b45f83889..0000000000
--- a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
+++ /dev/null
@@ -1,62 +0,0 @@
-#/** @file
-#
-# Component description file for Bds module
-#
-# Copyright (c) 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 = SimpleTextInOutSerial
- FILE_GUID = 6696936D-3637-467C-87CB-14EA8248948C
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = SimpleTextInOutEntryPoint
-
-
-[Sources.common]
- SimpleTextInOut.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- BaseLib
- ReportStatusCodeLib
- MemoryAllocationLib
- UefiLib
- UefiBootServicesTableLib
- BaseMemoryLib
- DebugLib
- UefiDriverEntryPoint
- SerialPortLib
-
-[Guids]
-
-
-[Protocols]
- gEfiSimpleTextInProtocolGuid
- gEfiSimpleTextOutProtocolGuid
- gEfiSerialIoProtocolGuid
- gEfiDevicePathProtocolGuid
-
-[FixedPcd]
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
-
-
-[depex]
- TRUE
diff --git a/EmbeddedPkg/TemplateSec/TemplateSec.c b/EmbeddedPkg/TemplateSec/TemplateSec.c
deleted file mode 100644
index c63adbb6f9..0000000000
--- a/EmbeddedPkg/TemplateSec/TemplateSec.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/** @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 <PiPei.h>
-
-#include <Library/DebugLib.h>
-#include <Library/PrePiLib.h>
-#include <Library/PcdLib.h>
-
-#include <Ppi/GuidedSectionExtraction.h>
-
-VOID
-_ModuleEntryPoint (
- VOID
- )
-{
-}
-
-VOID
-CEntryPoint (
- VOID *MemoryBase,
- UINTN MemorySize,
- VOID *StackBase,
- UINTN StackSize
- )
-{
- EFI_PHYSICAL_ADDRESS MemoryBegin;
- UINT64 MemoryLength;
- VOID *HobBase;
-
- //
- // Boot strap the C environment so the other library services will work properly.
- //
- MemoryBegin = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryBase;
- MemoryLength = (UINT64)MemorySize;
- HobBase = (VOID *)(UINTN)(FixedPcdGet32(PcdEmbeddedFdBaseAddress) + FixedPcdGet32(PcdEmbeddedFdSize));
- CreateHobList (MemoryBase, MemorySize, HobBase, StackBase);
-
- MemoryBegin = (EFI_PHYSICAL_ADDRESS)(UINTN)StackBase;
- MemoryLength = (UINT64)StackSize;
- UpdateStackHob (MemoryBegin, MemoryLength);
-
- DEBUG ((DEBUG_ERROR, "CEntryPoint (%x,%x,%x,%x)\n", MemoryBase, MemorySize, StackBase, StackSize));
-
- //
- // Add your C code stuff here....
- //
-
-
- //
- // Load the DXE Core and transfer control to it
- //
-
- // Give the DXE Core access to our DEBUG and ASSERT infrastructure so this will work prior
- // to the DXE version being loaded. Thus we close the debugging gap between phases.
- AddDxeCoreReportStatusCodeCallback ();
-
- //BuildFvHobs (PcdBfvBase, PcdBfvSize, NULL);
-
- LoadDxeCoreFromFv (NULL, 0);
-
- // DXE Core should always load and never return
- ASSERT (FALSE);
-}
-
diff --git a/EmbeddedPkg/TemplateSec/TemplateSec.inf b/EmbeddedPkg/TemplateSec/TemplateSec.inf
deleted file mode 100644
index 3a63e59294..0000000000
--- a/EmbeddedPkg/TemplateSec/TemplateSec.inf
+++ /dev/null
@@ -1,65 +0,0 @@
-#/** @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
-
diff --git a/EmbeddedPkg/Universal/MmcDxe/ComponentName.c b/EmbeddedPkg/Universal/MmcDxe/ComponentName.c
deleted file mode 100644
index 0161f56d91..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/ComponentName.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/** @file
- Component Name Protocol implementation for the MMC DXE driver
-
- Copyright (c) 2011, 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.
-
-**/
-
-#include "Mmc.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName = {
- MmcGetDriverName,
- MmcGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) MmcGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) MmcGetControllerName,
- "en"
-};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
-mMmcDriverNameTable[] = {
- {"eng;en", L"MMC/SD Card Interface Driver"},
- {NULL, NULL}
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
- @param DriverName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mMmcDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gMmcComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
- @param ChildHandle The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
- @param ControllerName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
deleted file mode 100644
index 783e548d2a..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/** @file
- Diagnostics Protocol implementation for the MMC DXE driver
-
- Copyright (c) 2011-2014, 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.
-
-**/
-
-#include <Uefi.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseLib.h>
-
-#include "Mmc.h"
-
-#define DIAGNOSTIC_LOGBUFFER_MAXCHAR 1024
-
-CHAR16* mLogBuffer = NULL;
-UINTN mLogRemainChar = 0;
-
-CHAR16*
-DiagnosticInitLog (
- UINTN MaxBufferChar
- )
-{
- mLogRemainChar = MaxBufferChar;
- mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof (CHAR16));
- return mLogBuffer;
-}
-
-UINTN
-DiagnosticLog (
- CONST CHAR16* Str
- )
-{
- UINTN len = StrLen (Str);
- if (len <= mLogRemainChar) {
- mLogRemainChar -= len;
- StrCpy (mLogBuffer, Str);
- mLogBuffer += len;
- return len;
- } else {
- return 0;
- }
-}
-
-VOID
-GenerateRandomBuffer (
- VOID* Buffer,
- UINTN BufferSize
- )
-{
- UINT64 i;
- UINT64* Buffer64 = (UINT64*)Buffer;
-
- for (i = 0; i < (BufferSize >> 3); i++) {
- *Buffer64 = i | (~i << 32);
- Buffer64++;
- }
-}
-
-BOOLEAN
-CompareBuffer (
- VOID *BufferA,
- VOID *BufferB,
- UINTN BufferSize
- )
-{
- UINTN i;
- UINT64* BufferA64 = (UINT64*)BufferA;
- UINT64* BufferB64 = (UINT64*)BufferB;
-
- for (i = 0; i < (BufferSize >> 3); i++) {
- if (*BufferA64 != *BufferB64) {
- DEBUG ((EFI_D_ERROR, "CompareBuffer: Error at %i", i));
- DEBUG ((EFI_D_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
- return FALSE;
- }
- BufferA64++;
- BufferB64++;
- }
- return TRUE;
-}
-
-EFI_STATUS
-MmcReadWriteDataTest (
- MMC_HOST_INSTANCE *MmcHostInstance,
- EFI_LBA Lba,
- UINTN BufferSize
- )
-{
- VOID *BackBuffer;
- VOID *WriteBuffer;
- VOID *ReadBuffer;
- EFI_STATUS Status;
-
- // Check if a Media is Present
- if (!MmcHostInstance->BlockIo.Media->MediaPresent) {
- DiagnosticLog (L"ERROR: No Media Present\n");
- return EFI_NO_MEDIA;
- }
-
- if (MmcHostInstance->State != MmcTransferState) {
- DiagnosticLog (L"ERROR: Not ready for Transfer state\n");
- return EFI_NOT_READY;
- }
-
- BackBuffer = AllocatePool (BufferSize);
- WriteBuffer = AllocatePool (BufferSize);
- ReadBuffer = AllocatePool (BufferSize);
-
- // Read (and save) buffer at a specific location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Read Block (1)\n");
- return Status;
- }
-
- // Write buffer at the same location
- GenerateRandomBuffer (WriteBuffer,BufferSize);
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,WriteBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Write Block (1)\n");
- return Status;
- }
-
- // Read the buffer at the same location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Read Block (2)\n");
- return Status;
- }
-
- // Check that is conform
- if (!CompareBuffer (ReadBuffer,WriteBuffer,BufferSize)) {
- DiagnosticLog (L"ERROR: Fail to Read/Write Block (1)\n");
- return EFI_INVALID_PARAMETER;
- }
-
- // Restore content at the original location
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Write Block (2)\n");
- return Status;
- }
-
- // Read the restored content
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Read Block (3)\n");
- return Status;
- }
-
- // Check the content is correct
- if (!CompareBuffer (ReadBuffer,BackBuffer,BufferSize)) {
- DiagnosticLog (L"ERROR: Fail to Read/Write Block (2)\n");
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-MmcDriverDiagnosticsRunDiagnostics (
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
- IN CHAR8 *Language,
- OUT EFI_GUID **ErrorType,
- OUT UINTN *BufferSize,
- OUT CHAR16 **Buffer
- )
-{
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_STATUS Status;
-
- if ((Language == NULL) ||
- (ErrorType == NULL) ||
- (Buffer == NULL) ||
- (ControllerHandle == NULL) ||
- (BufferSize == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check Language is supported (i.e. is "en-*" - only English is supported)
- if (AsciiStrnCmp (Language, "en", 2) != 0) {
- return EFI_UNSUPPORTED;
- }
-
- Status = EFI_SUCCESS;
- *ErrorType = NULL;
- *BufferSize = DIAGNOSTIC_LOGBUFFER_MAXCHAR;
- *Buffer = DiagnosticInitLog (DIAGNOSTIC_LOGBUFFER_MAXCHAR);
-
- DiagnosticLog (L"MMC Driver Diagnostics\n");
-
- // Find the MMC Host instance on which we have been asked to run diagnostics
- MmcHostInstance = NULL;
- CurrentLink = mMmcHostPool.ForwardLink;
- while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
- if (MmcHostInstance->MmcHandle == ControllerHandle) {
- break;
- }
- CurrentLink = CurrentLink->ForwardLink;
- }
-
- // If we didn't find the controller, return EFI_UNSUPPORTED
- if ((MmcHostInstance == NULL)
- || (MmcHostInstance->MmcHandle != ControllerHandle)) {
- return EFI_UNSUPPORTED;
- }
-
- // LBA=1 Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=2 Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Second Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=10 Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=LastBlock Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=1 Size=2*BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, 1, 2 * MmcHostInstance->BlockIo.Media->BlockSize);
-
- return Status;
-}
-
-//
-// EFI Driver Diagnostics 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2 = {
- (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) MmcDriverDiagnosticsRunDiagnostics,
- "en"
-};
diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.c b/EmbeddedPkg/Universal/MmcDxe/Mmc.c
deleted file mode 100644
index 570e1d2e43..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/Mmc.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/** @file
- Main file of the MMC Dxe driver. The driver entrypoint is defined into this file.
-
- Copyright (c) 2011-2013, 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.
-
-**/
-
-#include <Protocol/DevicePath.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-
-#include "Mmc.h"
-
-EFI_BLOCK_IO_MEDIA mMmcMediaTemplate = {
- SIGNATURE_32('m','m','c','o'), // MediaId
- TRUE, // RemovableMedia
- FALSE, // MediaPresent
- FALSE, // LogicalPartition
- FALSE, // ReadOnly
- FALSE, // WriteCaching
- 512, // BlockSize
- 4, // IoAlign
- 0, // Pad
- 0 // LastBlock
-};
-
-//
-// This device structure is serviced as a header.
-// Its next field points to the first root bridge device node.
-//
-LIST_ENTRY mMmcHostPool;
-
-/**
- Event triggered by the timer to check if any cards have been removed
- or if new ones have been plugged in
-**/
-
-EFI_EVENT gCheckCardsEvent;
-
-/**
- Initialize the MMC Host Pool to support multiple MMC devices
-**/
-VOID
-InitializeMmcHostPool (
- VOID
- )
-{
- InitializeListHead (&mMmcHostPool);
-}
-
-/**
- Insert a new Mmc Host controller to the pool
-**/
-VOID
-InsertMmcHost (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- InsertTailList (&mMmcHostPool, &(MmcHostInstance->Link));
-}
-
-/*
- Remove a new Mmc Host controller to the pool
-*/
-VOID
-RemoveMmcHost (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- RemoveEntryList (&(MmcHostInstance->Link));
-}
-
-MMC_HOST_INSTANCE* CreateMmcHostInstance (
- IN EFI_MMC_HOST_PROTOCOL* MmcHost
- )
-{
- EFI_STATUS Status;
- MMC_HOST_INSTANCE* MmcHostInstance;
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- MmcHostInstance = AllocateZeroPool (sizeof (MMC_HOST_INSTANCE));
- if (MmcHostInstance == NULL) {
- return NULL;
- }
-
- MmcHostInstance->Signature = MMC_HOST_INSTANCE_SIGNATURE;
-
- MmcHostInstance->State = MmcHwInitializationState;
-
- MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof(EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);
- if (MmcHostInstance->BlockIo.Media == NULL) {
- goto FREE_INSTANCE;
- }
-
- MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;
- MmcHostInstance->BlockIo.Reset = MmcReset;
- MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks;
- MmcHostInstance->BlockIo.WriteBlocks = MmcWriteBlocks;
- MmcHostInstance->BlockIo.FlushBlocks = MmcFlushBlocks;
-
- MmcHostInstance->MmcHost = MmcHost;
-
- // Create DevicePath for the new MMC Host
- Status = MmcHost->BuildDevicePath (MmcHost, &NewDevicePathNode);
- if (EFI_ERROR (Status)) {
- goto FREE_MEDIA;
- }
-
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
- if (DevicePath == NULL) {
- goto FREE_MEDIA;
- }
-
- SetDevicePathEndNode (DevicePath);
- MmcHostInstance->DevicePath = AppendDevicePathNode (DevicePath, NewDevicePathNode);
-
- // Publish BlockIO protocol interface
- Status = gBS->InstallMultipleProtocolInterfaces (
- &MmcHostInstance->MmcHandle,
- &gEfiBlockIoProtocolGuid,&MmcHostInstance->BlockIo,
- &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
- NULL
- );
- if (EFI_ERROR(Status)) {
- goto FREE_DEVICE_PATH;
- }
-
- return MmcHostInstance;
-
-FREE_DEVICE_PATH:
- FreePool(DevicePath);
-
-FREE_MEDIA:
- FreePool(MmcHostInstance->BlockIo.Media);
-
-FREE_INSTANCE:
- FreePool(MmcHostInstance);
-
- return NULL;
-}
-
-EFI_STATUS DestroyMmcHostInstance (
- IN MMC_HOST_INSTANCE* MmcHostInstance
- )
-{
- EFI_STATUS Status;
-
- // Uninstall Protocol Interfaces
- Status = gBS->UninstallMultipleProtocolInterfaces (
- MmcHostInstance->MmcHandle,
- &gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),
- &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- // Free Memory allocated for the instance
- if (MmcHostInstance->BlockIo.Media) {
- FreePool(MmcHostInstance->BlockIo.Media);
- }
- FreePool (MmcHostInstance);
-
- return Status;
-}
-
-/**
- This function checks if the controller implement the Mmc Host and the Device Path Protocols
-**/
-EFI_STATUS
-EFIAPI
-MmcDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- //EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- EFI_DEV_PATH_PTR Node;
-
- //
- // Check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, go on checking other conditions
- //
- if (!IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // check its validation
- //
- Node.DevPath = RemainingDevicePath;
- if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||
- Node.DevPath->SubType != HW_VENDOR_DP ||
- DevicePathNodeLength(Node.DevPath) != sizeof(VENDOR_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
- }
- }
- }
-
- //
- // Check if Mmc Host protocol is installed by platform
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiMmcHostProtocolGuid,
- (VOID **) &MmcHost,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Close the Mmc Host used to perform the supported test
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiMmcHostProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return EFI_SUCCESS;
-}
-
-/**
-
-**/
-EFI_STATUS
-EFIAPI
-MmcDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
-
- //
- // Check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, return EFI_SUCCESS
- //
- if (IsDevicePathEnd (RemainingDevicePath)) {
- return EFI_SUCCESS;
- }
- }
-
- //
- // Get the Mmc Host protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiMmcHostProtocolGuid,
- (VOID **) &MmcHost,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
- return Status;
- }
-
- MmcHostInstance = CreateMmcHostInstance(MmcHost);
- if (MmcHostInstance != NULL) {
- // Add the handle to the pool
- InsertMmcHost (MmcHostInstance);
-
- MmcHostInstance->Initialized = FALSE;
-
- // Detect card presence now
- CheckCardsCallback (NULL, NULL);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
-
-**/
-EFI_STATUS
-EFIAPI
-MmcDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status = EFI_SUCCESS;
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
-
- MMC_TRACE("MmcDriverBindingStop()");
-
- // For each MMC instance
- CurrentLink = mMmcHostPool.ForwardLink;
- while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
-
- // Close gEfiMmcHostProtocolGuid
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiMmcHostProtocolGuid,(VOID **) &MmcHostInstance->MmcHost,
- This->DriverBindingHandle
- );
-
- // Remove MMC Host Instance from the pool
- RemoveMmcHost (MmcHostInstance);
-
- // Destroy MmcHostInstance
- DestroyMmcHostInstance (MmcHostInstance);
- }
-
- return Status;
-}
-
-VOID
-EFIAPI
-CheckCardsCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_STATUS Status;
-
- CurrentLink = mMmcHostPool.ForwardLink;
- while (CurrentLink != NULL && CurrentLink != &mMmcHostPool) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
-
- if (MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost) == !MmcHostInstance->Initialized) {
- MmcHostInstance->State = MmcHwInitializationState;
- MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized;
- MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
-
- if (MmcHostInstance->BlockIo.Media->MediaPresent) {
- InitializeMmcDevice (MmcHostInstance);
- }
-
- Status = gBS->ReinstallProtocolInterface (
- (MmcHostInstance->MmcHandle),
- &gEfiBlockIoProtocolGuid,
- &(MmcHostInstance->BlockIo),
- &(MmcHostInstance->BlockIo)
- );
-
- if (EFI_ERROR(Status)) {
- Print(L"MMC Card: Error reinstalling BlockIo interface\n");
- }
- }
-
- CurrentLink = CurrentLink->ForwardLink;
- }
-}
-
-
-EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
- MmcDriverBindingSupported,
- MmcDriverBindingStart,
- MmcDriverBindingStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
-
-**/
-EFI_STATUS
-EFIAPI
-MmcDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Initializes MMC Host pool
- //
- InitializeMmcHostPool ();
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gMmcDriverBinding,
- ImageHandle,
- &gMmcComponentName,
- &gMmcComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- // Install driver diagnostics
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ImageHandle,
- &gEfiDriverDiagnostics2ProtocolGuid,&gMmcDriverDiagnostics2,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- // Use a timer to detect if a card has been plugged in or removed
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL | EVT_TIMER,
- TPL_CALLBACK,
- CheckCardsCallback,
- NULL,
- &gCheckCardsEvent);
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->SetTimer(
- gCheckCardsEvent,
- TimerPeriodic,
- (UINT64)(10*1000*200)); // 200 ms
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
deleted file mode 100644
index 46a156cecf..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
+++ /dev/null
@@ -1,337 +0,0 @@
-/** @file
- Main Header file for the MMC DXE driver
-
- Copyright (c) 2011-2015, 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 __MMC_H
-#define __MMC_H
-
-#include <Uefi.h>
-
-#include <Protocol/DiskIo.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/MmcHost.h>
-
-#include <Library/UefiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#define MMC_TRACE(txt) DEBUG((EFI_D_BLKIO, "MMC: " txt "\n"))
-
-#define MMC_IOBLOCKS_READ 0
-#define MMC_IOBLOCKS_WRITE 1
-
-#define MMC_OCR_POWERUP 0x80000000
-
-#define MMC_CSD_GET_CCC(Response) (Response[2] >> 20)
-#define MMC_CSD_GET_TRANSPEED(Response) (Response[3] & 0xFF)
-#define MMC_CSD_GET_READBLLEN(Response) ((Response[2] >> 16) & 0xF)
-#define MMC_CSD_GET_WRITEBLLEN(Response) ((Response[0] >> 22) & 0xF)
-#define MMC_CSD_GET_FILEFORMAT(Response) ((Response[0] >> 10) & 0x3)
-#define MMC_CSD_GET_FILEFORMATGRP(Response) ((Response[0] >> 15) & 0x1)
-#define MMC_CSD_GET_DEVICESIZE(csd) (((Response[1] >> 30) & 0x3) | ((Response[2] & 0x3FF) << 2))
-#define HC_MMC_CSD_GET_DEVICESIZE(Response) ((Response[1] >> 16) | ((Response[2] & 0x40) << 16));
-#define MMC_CSD_GET_DEVICESIZEMULT(csd) ((Response[1] >> 15) & 0x7)
-
-#define MMC_R0_READY_FOR_DATA (1 << 8)
-
-#define MMC_R0_CURRENTSTATE(Response) ((Response[0] >> 9) & 0xF)
-
-#define MMC_R0_STATE_IDLE 0
-#define MMC_R0_STATE_READY 1
-#define MMC_R0_STATE_IDENT 2
-#define MMC_R0_STATE_STDBY 3
-#define MMC_R0_STATE_TRAN 4
-#define MMC_R0_STATE_DATA 5
-
-typedef enum {
- UNKNOWN_CARD,
- MMC_CARD, //MMC card
- MMC_CARD_HIGH, //MMC Card with High capacity
- EMMC_CARD, //eMMC 4.41 card
- SD_CARD, //SD 1.1 card
- SD_CARD_2, //SD 2.0 or above standard card
- SD_CARD_2_HIGH //SD 2.0 or above high capacity card
-} CARD_TYPE;
-
-typedef struct {
- UINT32 Reserved0: 7; // 0
- UINT32 V170_V195: 1; // 1.70V - 1.95V
- UINT32 V200_V260: 7; // 2.00V - 2.60V
- UINT32 V270_V360: 9; // 2.70V - 3.60V
- UINT32 RESERVED_1: 5; // Reserved
- UINT32 AccessMode: 2; // 00b (byte mode), 10b (sector mode)
- UINT32 PowerUp: 1; // This bit is set to LOW if the card has not finished the power up routine
-} OCR;
-
-typedef struct {
- UINT32 NOT_USED; // 1 [0:0]
- UINT32 CRC; // CRC7 checksum [7:1]
- UINT32 MDT; // Manufacturing date [19:8]
- UINT32 RESERVED_1; // Reserved [23:20]
- UINT32 PSN; // Product serial number [55:24]
- UINT8 PRV; // Product revision [63:56]
- UINT8 PNM[5]; // Product name [64:103]
- UINT16 OID; // OEM/Application ID [119:104]
- UINT8 MID; // Manufacturer ID [127:120]
-} CID;
-
-typedef struct {
- UINT8 NOT_USED: 1; // Not used, always 1 [0:0]
- UINT8 CRC: 7; // CRC [7:1]
-
- UINT8 RESERVED_1: 2; // Reserved [9:8]
- UINT8 FILE_FORMAT: 2; // File format [11:10]
- UINT8 TMP_WRITE_PROTECT: 1; // Temporary write protection [12:12]
- UINT8 PERM_WRITE_PROTECT: 1; // Permanent write protection [13:13]
- UINT8 COPY: 1; // Copy flag (OTP) [14:14]
- UINT8 FILE_FORMAT_GRP: 1; // File format group [15:15]
-
- UINT16 RESERVED_2: 5; // Reserved [20:16]
- UINT16 WRITE_BL_PARTIAL: 1; // Partial blocks for write allowed [21:21]
- UINT16 WRITE_BL_LEN: 4; // Max. write data block length [25:22]
- UINT16 R2W_FACTOR: 3; // Write speed factor [28:26]
- UINT16 RESERVED_3: 2; // Reserved [30:29]
- UINT16 WP_GRP_ENABLE: 1; // Write protect group enable [31:31]
-
- UINT32 WP_GRP_SIZE: 7; // Write protect group size [38:32]
- UINT32 SECTOR_SIZE: 7; // Erase sector size [45:39]
- UINT32 ERASE_BLK_EN: 1; // Erase single block enable [46:46]
- UINT32 C_SIZE_MULT: 3; // Device size multiplier [49:47]
- UINT32 VDD_W_CURR_MAX: 3; // Max. write current @ VDD max [52:50]
- UINT32 VDD_W_CURR_MIN: 3; // Max. write current @ VDD min [55:53]
- UINT32 VDD_R_CURR_MAX: 3; // Max. read current @ VDD max [58:56]
- UINT32 VDD_R_CURR_MIN: 3; // Max. read current @ VDD min [61:59]
- UINT32 C_SIZELow2: 2; // Device size [63:62]
-
- UINT32 C_SIZEHigh10: 10;// Device size [73:64]
- UINT32 RESERVED_4: 2; // Reserved [75:74]
- UINT32 DSR_IMP: 1; // DSR implemented [76:76]
- UINT32 READ_BLK_MISALIGN: 1; // Read block misalignment [77:77]
- UINT32 WRITE_BLK_MISALIGN: 1; // Write block misalignment [78:78]
- UINT32 READ_BL_PARTIAL: 1; // Partial blocks for read allowed [79:79]
- UINT32 READ_BL_LEN: 4; // Max. read data block length [83:80]
- UINT32 CCC: 12;// Card command classes [95:84]
-
- UINT8 TRAN_SPEED ; // Max. bus clock frequency [103:96]
- UINT8 NSAC ; // Data read access-time 2 in CLK cycles (NSAC*100) [111:104]
- UINT8 TAAC ; // Data read access-time 1 [119:112]
-
- UINT8 RESERVED_5: 6; // Reserved [125:120]
- UINT8 CSD_STRUCTURE: 2; // CSD structure [127:126]
-} CSD;
-
-typedef struct {
- UINT16 RCA;
- CARD_TYPE CardType;
- OCR OCRData;
- CID CIDData;
- CSD CSDData;
-} CARD_INFO;
-
-typedef struct _MMC_HOST_INSTANCE {
- UINTN Signature;
- LIST_ENTRY Link;
- EFI_HANDLE MmcHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- MMC_STATE State;
- EFI_BLOCK_IO_PROTOCOL BlockIo;
- CARD_INFO CardInfo;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
-
- BOOLEAN Initialized;
-} MMC_HOST_INSTANCE;
-
-#define MMC_HOST_INSTANCE_SIGNATURE SIGNATURE_32('m', 'm', 'c', 'h')
-#define MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS(a) CR (a, MMC_HOST_INSTANCE, BlockIo, MMC_HOST_INSTANCE_SIGNATURE)
-#define MMC_HOST_INSTANCE_FROM_LINK(a) CR (a, MMC_HOST_INSTANCE, Link, MMC_HOST_INSTANCE_SIGNATURE)
-
-
-EFI_STATUS
-EFIAPI
-MmcGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-EFI_STATUS
-EFIAPI
-MmcGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-extern EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2;
-
-extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2;
-
-extern LIST_ENTRY mMmcHostPool;
-
-/**
- Reset the block device.
-
- This function implements EFI_BLOCK_IO_PROTOCOL.Reset().
- It resets the block device hardware.
- ExtendedVerification is ignored in this implementation.
-
- @param This Indicates a pointer to the calling context.
- @param ExtendedVerification Indicates that the driver may perform a more exhaustive
- verification operation of the device during reset.
-
- @retval EFI_SUCCESS The block device was reset.
- @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Reads the requested number of blocks from the device.
-
- This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks().
- It reads the requested number of blocks from the device.
- All the blocks are read, or an error is returned.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId The media ID that the read request is for.
- @param Lba The starting logical block address to read from on the device.
- @param BufferSize The size of the Buffer in bytes.
- This must be a multiple of the intrinsic block size of the device.
- @param Buffer A pointer to the destination buffer for the data. The caller is
- responsible for either having implicit or explicit ownership of the buffer.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the read operation.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- Writes a specified number of blocks to the device.
-
- This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks().
- It writes a specified number of blocks to the device.
- All blocks are written, or an error is returned.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId The media ID that the write request is for.
- @param Lba The starting logical block address to be written.
- @param BufferSize The size of the Buffer in bytes.
- This must be a multiple of the intrinsic block size of the device.
- @param Buffer Pointer to the source buffer for the data.
-
- @retval EFI_SUCCESS The data were written correctly to the device.
- @retval EFI_WRITE_PROTECTED The device cannot be written to.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic
- block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-/**
- Flushes all modified data to a physical block device.
-
- @param This Indicates a pointer to the calling context.
-
- @retval EFI_SUCCESS All outstanding data were written correctly to the device.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data.
- @retval EFI_NO_MEDIA There is no media in the device.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- );
-
-EFI_STATUS
-MmcNotifyState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN MMC_STATE State
- );
-
-EFI_STATUS
-InitializeMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHost
- );
-
-VOID
-EFIAPI
-CheckCardsCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-VOID
-PrintCSD (
- IN UINT32* Csd
- );
-
-VOID
-PrintRCA (
- IN UINT32 Rca
- );
-
-VOID
-PrintOCR (
- IN UINT32 Ocr
- );
-
-VOID
-PrintResponseR1 (
- IN UINT32 Response
- );
-
-VOID
-PrintCID (
- IN UINT32* Cid
- );
-
-#endif
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
deleted file mode 100644
index 0e1ef57263..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2015, 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.
-*
-**/
-
-#include <Library/BaseMemoryLib.h>
-
-#include "Mmc.h"
-
-EFI_STATUS
-MmcNotifyState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN MMC_STATE State
- )
-{
- MmcHostInstance->State = State;
- return MmcHostInstance->MmcHost->NotifyState (MmcHostInstance->MmcHost, State);
-}
-
-EFI_STATUS
-EFIAPI
-MmcGetCardStatus (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- EFI_STATUS Status;
- UINT32 Response[4];
- UINTN CmdArg;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
-
- Status = EFI_SUCCESS;
- MmcHost = MmcHostInstance->MmcHost;
- CmdArg = 0;
-
- if (MmcHost == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- if (MmcHostInstance->State != MmcHwInitializationState) {
- //Get the Status of the card.
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status));
- return Status;
- }
-
- //Read Response
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
- PrintResponseR1 (Response[0]);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-MmcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- MMC_HOST_INSTANCE *MmcHostInstance;
-
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
-
- if (MmcHostInstance->MmcHost == NULL) {
- // Nothing to do
- return EFI_SUCCESS;
- }
-
- // If a card is not present then clear all media settings
- if (!MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost)) {
- MmcHostInstance->BlockIo.Media->MediaPresent = FALSE;
- MmcHostInstance->BlockIo.Media->LastBlock = 0;
- MmcHostInstance->BlockIo.Media->BlockSize = 512; // Should be zero but there is a bug in DiskIo
- MmcHostInstance->BlockIo.Media->ReadOnly = FALSE;
-
- // Indicate that the driver requires initialization
- MmcHostInstance->State = MmcHwInitializationState;
-
- return EFI_SUCCESS;
- }
-
- // Implement me. Either send a CMD0 (could not work for some MMC host) or just turn off/turn
- // on power and restart Identification mode
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-MmcDetectCard (
- EFI_MMC_HOST_PROTOCOL *MmcHost
- )
-{
- if (!MmcHost->IsCardPresent (MmcHost)) {
- return EFI_NO_MEDIA;
- } else {
- return EFI_SUCCESS;
- }
-}
-
-EFI_STATUS
-MmcStopTransmission (
- EFI_MMC_HOST_PROTOCOL *MmcHost
- )
-{
- EFI_STATUS Status;
- UINT32 Response[4];
- // Command 12 - Stop transmission (ends read or write)
- // Normally only needed for streaming transfers or after error.
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
- if (!EFI_ERROR (Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response);
- }
- return Status;
-}
-
-#define MMCI0_BLOCKLEN 512
-#define MMCI0_TIMEOUT 10000
-
-EFI_STATUS
-MmcIoBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Transfer,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- UINT32 Response[4];
- EFI_STATUS Status;
- UINTN CmdArg;
- INTN Timeout;
- UINTN Cmd;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN BytesRemainingToBeTransfered;
- UINTN BlockCount;
-
- BlockCount = 1;
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
- ASSERT (MmcHostInstance != NULL);
- MmcHost = MmcHostInstance->MmcHost;
- ASSERT (MmcHost);
-
- if (This->Media->MediaId != MediaId) {
- return EFI_MEDIA_CHANGED;
- }
-
- if ((MmcHost == NULL) || (Buffer == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check if a Card is Present
- if (!MmcHostInstance->BlockIo.Media->MediaPresent) {
- return EFI_NO_MEDIA;
- }
-
- // All blocks must be within the device
- if ((Lba + (BufferSize / This->Media->BlockSize)) > (This->Media->LastBlock + 1)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
- return EFI_WRITE_PROTECTED;
- }
-
- // Reading 0 Byte is valid
- if (BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- // The buffer size must be an exact multiple of the block size
- if ((BufferSize % This->Media->BlockSize) != 0) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- // Check the alignment
- if ((This->Media->IoAlign > 2) && (((UINTN)Buffer & (This->Media->IoAlign - 1)) != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- BytesRemainingToBeTransfered = BufferSize;
- while (BytesRemainingToBeTransfered > 0) {
-
- // Check if the Card is in Ready status
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
- Response[0] = 0;
- Timeout = 20;
- while( (!(Response[0] & MMC_R0_READY_FOR_DATA))
- && (MMC_R0_CURRENTSTATE (Response) != MMC_R0_STATE_TRAN)
- && Timeout--) {
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
- if (!EFI_ERROR (Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
- }
- }
-
- if (0 == Timeout) {
- DEBUG ((EFI_D_ERROR, "The Card is busy\n"));
- return EFI_NOT_READY;
- }
-
- //Set command argument based on the card access mode (Byte mode or Block mode)
- if (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1) {
- CmdArg = Lba;
- } else {
- CmdArg = Lba * This->Media->BlockSize;
- }
-
- if (Transfer == MMC_IOBLOCKS_READ) {
- // Read a single block
- Cmd = MMC_CMD17;
- } else {
- // Write a single block
- Cmd = MMC_CMD24;
- }
- Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIoBlocks(MMC_CMD%d): Error %r\n", Cmd, Status));
- return Status;
- }
-
- if (Transfer == MMC_IOBLOCKS_READ) {
- // Read one block of Data
- Status = MmcHost->ReadBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status));
- MmcStopTransmission (MmcHost);
- return Status;
- }
- Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIoBlocks() : Error MmcProgrammingState\n"));
- return Status;
- }
- } else {
- // Write one block of Data
- Status = MmcHost->WriteBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Write Block Data and Status = %r\n", Status));
- MmcStopTransmission (MmcHost);
- return Status;
- }
- }
-
- // Command 13 - Read status and wait for programming to complete (return to tran)
- Timeout = MMCI0_TIMEOUT;
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
- Response[0] = 0;
- while( (!(Response[0] & MMC_R0_READY_FOR_DATA))
- && (MMC_R0_CURRENTSTATE (Response) != MMC_R0_STATE_TRAN)
- && Timeout--) {
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
- if (!EFI_ERROR (Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
- if ((Response[0] & MMC_R0_READY_FOR_DATA)) {
- break; // Prevents delay once finished
- }
- }
- gBS->Stall (1);
- }
-
- Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIoBlocks() : Error MmcTransferState\n"));
- return Status;
- }
-
- BytesRemainingToBeTransfered -= This->Media->BlockSize;
- Lba += BlockCount;
- Buffer = (UINT8 *)Buffer + This->Media->BlockSize;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-MmcReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- return MmcIoBlocks (This, MMC_IOBLOCKS_READ, MediaId, Lba, BufferSize, Buffer);
-}
-
-EFI_STATUS
-EFIAPI
-MmcWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- return MmcIoBlocks (This, MMC_IOBLOCKS_WRITE, MediaId, Lba, BufferSize, Buffer);
-}
-
-EFI_STATUS
-EFIAPI
-MmcFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- )
-{
- return EFI_SUCCESS;
-}
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c b/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c
deleted file mode 100644
index a5d3b63124..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, 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.
-*
-**/
-
-#include "Mmc.h"
-
-#if !defined(MDEPKG_NDEBUG)
-CONST CHAR8* mStrUnit[] = { "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",
- "Unknown", "Unknown", "Unknown", "Unknown" };
-CONST CHAR8* mStrValue[] = { "1.0", "1.2", "1.3", "1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0",
- "Unknown", "Unknown", "Unknown", "Unknown" };
-#endif
-
-VOID
-PrintCID (
- IN UINT32* Cid
- )
-{
- DEBUG ((EFI_D_ERROR, "- PrintCID\n"));
- DEBUG ((EFI_D_ERROR, "\t- Manufacturing date: %d/%d\n", (Cid[0] >> 8) & 0xF, (Cid[0] >> 12) & 0xFF));
- DEBUG ((EFI_D_ERROR, "\t- Product serial number: 0x%X%X\n", Cid[1] & 0xFFFFFF, (Cid[0] >> 24) & 0xFF));
- DEBUG ((EFI_D_ERROR, "\t- Product revision: %d\n", Cid[1] >> 24));
- //DEBUG ((EFI_D_ERROR, "\t- Product name: %s\n", (char*)(Cid + 2)));
- DEBUG ((EFI_D_ERROR, "\t- OEM ID: %c%c\n", (Cid[3] >> 8) & 0xFF, (Cid[3] >> 16) & 0xFF));
-}
-
-
-VOID
-PrintCSD (
- IN UINT32* Csd
- )
-{
- UINTN Value;
-
- if (((Csd[2] >> 30) & 0x3) == 0) {
- DEBUG ((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
- } else if (((Csd[2] >> 30) & 0x3) == 1) {
- DEBUG ((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));
- } else {
- DEBUG ((EFI_D_ERROR, "- PrintCSD Version Higher than v3.3\n"));
- }
-
- DEBUG ((EFI_D_ERROR, "\t- Supported card command class: 0x%X\n", MMC_CSD_GET_CCC (Csd)));
- DEBUG ((EFI_D_ERROR, "\t- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED (Csd) >> 3) & 0xF],mStrUnit[MMC_CSD_GET_TRANSPEED (Csd) & 7]));
- DEBUG ((EFI_D_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN (Csd)-1)));
- DEBUG ((EFI_D_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN (Csd)-1)));
-
- if (!MMC_CSD_GET_FILEFORMATGRP (Csd)) {
- Value = MMC_CSD_GET_FILEFORMAT (Csd);
- if (Value == 0) {
- DEBUG ((EFI_D_ERROR, "\t- Format (0): Hard disk-like file system with partition table\n"));
- } else if (Value == 1) {
- DEBUG ((EFI_D_ERROR, "\t- Format (1): DOS FAT (floppy-like) with boot sector only (no partition table)\n"));
- } else if (Value == 2) {
- DEBUG ((EFI_D_ERROR, "\t- Format (2): Universal File Format\n"));
- } else {
- DEBUG ((EFI_D_ERROR, "\t- Format (3): Others/Unknown\n"));
- }
- } else {
- DEBUG ((EFI_D_ERROR, "\t- Format: Reserved\n"));
- }
-}
-
-VOID
-PrintRCA (
- IN UINT32 Rca
- )
-{
- DEBUG ((EFI_D_ERROR, "- PrintRCA: 0x%X\n", Rca));
- DEBUG ((EFI_D_ERROR, "\t- Status: 0x%X\n", Rca & 0xFFFF));
- DEBUG ((EFI_D_ERROR, "\t- RCA: 0x%X\n", (Rca >> 16) & 0xFFFF));
-}
-
-VOID
-PrintOCR (
- IN UINT32 Ocr
- )
-{
- UINTN MinV;
- UINTN MaxV;
- UINTN Volts;
- UINTN Loop;
-
- MinV = 36; // 3.6
- MaxV = 20; // 2.0
- Volts = 20; // 2.0
-
- // The MMC register bits [23:8] indicate the working range of the card
- for (Loop = 8; Loop < 24; Loop++) {
- if (Ocr & (1 << Loop)) {
- if (MinV > Volts) {
- MinV = Volts;
- }
- if (MaxV < Volts) {
- MaxV = Volts + 1;
- }
- }
- Volts++;
- }
-
- DEBUG ((EFI_D_ERROR, "- PrintOCR Ocr (0x%X)\n",Ocr));
- DEBUG ((EFI_D_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", MinV/10, MinV % 10, MaxV/10, MaxV % 10));
- if (((Ocr >> 29) & 3) == 0) {
- DEBUG ((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n"));
- } else {
- DEBUG ((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n", ((Ocr >> 29) & 3)));
- }
-
- if (Ocr & MMC_OCR_POWERUP) {
- DEBUG ((EFI_D_ERROR, "\t- PowerUp\n"));
- } else {
- DEBUG ((EFI_D_ERROR, "\t- Voltage Not Supported\n"));
- }
-}
-
-VOID
-PrintResponseR1 (
- IN UINT32 Response
- )
-{
- DEBUG ((EFI_D_INFO, "Response: 0x%X\n", Response));
- if (Response & MMC_R0_READY_FOR_DATA) {
- DEBUG ((EFI_D_INFO, "\t- READY_FOR_DATA\n"));
- }
-
- switch ((Response >> 9) & 0xF) {
- case 0:
- DEBUG ((EFI_D_INFO, "\t- State: Idle\n"));
- break;
- case 1:
- DEBUG ((EFI_D_INFO, "\t- State: Ready\n"));
- break;
- case 2:
- DEBUG ((EFI_D_INFO, "\t- State: Ident\n"));
- break;
- case 3:
- DEBUG ((EFI_D_INFO, "\t- State: StandBy\n"));
- break;
- case 4:
- DEBUG ((EFI_D_INFO, "\t- State: Tran\n"));
- break;
- case 5:
- DEBUG ((EFI_D_INFO, "\t- State: Data\n"));
- break;
- case 6:
- DEBUG ((EFI_D_INFO, "\t- State: Rcv\n"));
- break;
- case 7:
- DEBUG ((EFI_D_INFO, "\t- State: Prg\n"));
- break;
- case 8:
- DEBUG ((EFI_D_INFO, "\t- State: Dis\n"));
- break;
- default:
- DEBUG ((EFI_D_INFO, "\t- State: Reserved\n"));
- break;
- }
-}
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf b/EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
deleted file mode 100644
index a07288c754..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
+++ /dev/null
@@ -1,51 +0,0 @@
-#/** @file
-# Build file for the MMC DXE driver
-#
-# Copyright (c) 2011-2015, 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.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MmcDxe
- FILE_GUID = b6f44cc0-9e45-11df-be21-0002a5d5c51b
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = MmcDxeInitialize
-
-[Sources.common]
- ComponentName.c
- Mmc.c
- MmcBlockIo.c
- MmcIdentification.c
- MmcDebug.c
- Diagnostics.c
-
-[Packages]
- EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- BaseLib
- UefiLib
- UefiDriverEntryPoint
- BaseMemoryLib
-
-[Protocols]
- gEfiDiskIoProtocolGuid
- gEfiBlockIoProtocolGuid
- gEfiDevicePathProtocolGuid
- gEfiMmcHostProtocolGuid
- gEfiDriverDiagnostics2ProtocolGuid
-
-[Depex]
- TRUE
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
deleted file mode 100644
index 2d8038ffe0..0000000000
--- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2015, 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.
-*
-**/
-
-#include "Mmc.h"
-
-typedef union {
- UINT32 Raw;
- OCR Ocr;
-} OCR_RESPONSE;
-
-#define MAX_RETRY_COUNT 1000
-#define CMD_RETRY_COUNT 20
-#define RCA_SHIFT_OFFSET 16
-#define EMMC_CARD_SIZE 512
-#define EMMC_ECSD_SIZE_OFFSET 53
-
-UINT32 mEmmcRcaCount = 0;
-
-STATIC
-EFI_STATUS
-EFIAPI
-EmmcIdentificationMode (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN OCR_RESPONSE Response
- )
-{
- EFI_MMC_HOST_PROTOCOL *Host;
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
- UINT32 RCA;
- UINT32 ECSD[128];
-
- Host = MmcHostInstance->MmcHost;
- Media = MmcHostInstance->BlockIo.Media;
-
- // Fetch card identity register
- Status = Host->SendCommand (Host, MMC_CMD2, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Failed to send CMD2, Status=%r.\n", Status));
- return Status;
- }
-
- Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R2, (UINT32 *)&(MmcHostInstance->CardInfo.CIDData));
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): CID retrieval error, Status=%r.\n", Status));
- return Status;
- }
-
- // Assign a relative address value to the card
- MmcHostInstance->CardInfo.RCA = ++mEmmcRcaCount; // TODO: might need a more sophisticated way of doing this
- RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
- Status = Host->SendCommand (Host, MMC_CMD3, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): RCA set error, Status=%r.\n", Status));
- return Status;
- }
-
- // Fetch card specific data
- Status = Host->SendCommand (Host, MMC_CMD9, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Failed to send CMD9, Status=%r.\n", Status));
- return Status;
- }
-
- Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R2, (UINT32 *)&(MmcHostInstance->CardInfo.CSDData));
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): CSD retrieval error, Status=%r.\n", Status));
- return Status;
- }
-
- // Select the card
- Status = Host->SendCommand (Host, MMC_CMD7, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Card selection error, Status=%r.\n", Status));
- }
-
- // Fetch ECSD
- Status = Host->SendCommand (Host, MMC_CMD8, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): ECSD fetch error, Status=%r.\n", Status));
- }
-
- Status = Host->ReadBlockData (Host, 0, 512, ECSD);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): ECSD read error, Status=%r.\n", Status));
- return Status;
- }
-
- // Set up media
- Media->BlockSize = EMMC_CARD_SIZE; // 512-byte support is mandatory for eMMC cards
- Media->MediaId = MmcHostInstance->CardInfo.CIDData.PSN;
- Media->ReadOnly = MmcHostInstance->CardInfo.CSDData.PERM_WRITE_PROTECT;
- Media->LogicalBlocksPerPhysicalBlock = 1;
- Media->IoAlign = 4;
- // Compute last block using bits [215:212] of the ECSD
- Media->LastBlock = ECSD[EMMC_ECSD_SIZE_OFFSET] - 1; // eMMC isn't supposed to report this for
- // Cards <2GB in size, but the model does.
-
- // Setup card type
- MmcHostInstance->CardInfo.CardType = EMMC_CARD;
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-InitializeSdMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- UINT32 CmdArg;
- UINT32 Response[4];
- UINTN BlockSize;
- UINTN CardSize;
- UINTN NumBlocks;
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
-
- MmcHost = MmcHostInstance->MmcHost;
-
- // Send a command to get Card specific data
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "InitializeSdMmcDevice(MMC_CMD9): Error, Status=%r\n", Status));
- return Status;
- }
-
- // Read Response
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD, Response);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "InitializeSdMmcDevice(): Failed to receive CSD, Status=%r\n", Status));
- return Status;
- }
- PrintCSD (Response);
-
- if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
- CardSize = HC_MMC_CSD_GET_DEVICESIZE (Response);
- NumBlocks = ((CardSize + 1) * 1024);
- BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response);
- } else {
- CardSize = MMC_CSD_GET_DEVICESIZE (Response);
- NumBlocks = (CardSize + 1) * (1 << (MMC_CSD_GET_DEVICESIZEMULT (Response) + 2));
- BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response);
- }
-
- // For >=2G card, BlockSize may be 1K, but the transfer size is 512 bytes.
- if (BlockSize > 512) {
- NumBlocks = MultU64x32 (NumBlocks, BlockSize / 512);
- BlockSize = 512;
- }
-
- MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1);
- MmcHostInstance->BlockIo.Media->BlockSize = BlockSize;
- MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly (MmcHost);
- MmcHostInstance->BlockIo.Media->MediaPresent = TRUE;
- MmcHostInstance->BlockIo.Media->MediaId++;
-
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "InitializeSdMmcDevice(MMC_CMD7): Error and Status = %r\n", Status));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-MmcIdentificationMode (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- EFI_STATUS Status;
- UINT32 Response[4];
- UINTN Timeout;
- UINTN CmdArg;
- BOOLEAN IsHCS;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- OCR_RESPONSE OcrResponse;
-
- MmcHost = MmcHostInstance->MmcHost;
- CmdArg = 0;
- IsHCS = FALSE;
-
- if (MmcHost == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // We can get into this function if we restart the identification mode
- if (MmcHostInstance->State == MmcHwInitializationState) {
- // Initialize the MMC Host HW
- Status = MmcNotifyState (MmcHostInstance, MmcHwInitializationState);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcHwInitializationState, Status=%r.\n", Status));
- return Status;
- }
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error, Status=%r.\n", Status));
- return Status;
- }
- Status = MmcNotifyState (MmcHostInstance, MmcIdleState);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcIdleState, Status=%r.\n", Status));
- return Status;
- }
-
- // Send CMD1 to get OCR (MMC)
- // This command only valid for MMC and eMMC
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB);
- if (Status == EFI_SUCCESS) {
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, (UINT32 *)&OcrResponse);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
- return Status;
- }
-
- if (!OcrResponse.Ocr.PowerUp) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD1): Card initialisation failure, Status=%r.\n", Status));
- return EFI_DEVICE_ERROR;
- }
- OcrResponse.Ocr.PowerUp = 0;
- if (OcrResponse.Raw == EMMC_CMD1_CAPACITY_GREATER_THAN_2GB) {
- MmcHostInstance->CardInfo.OCRData.AccessMode = BIT1;
- }
- else {
- MmcHostInstance->CardInfo.OCRData.AccessMode = 0x0;
- }
- // Check whether MMC or eMMC
- if (OcrResponse.Raw == EMMC_CMD1_CAPACITY_GREATER_THAN_2GB ||
- OcrResponse.Raw == EMMC_CMD1_CAPACITY_LESS_THAN_2GB) {
- return EmmcIdentificationMode (MmcHostInstance, OcrResponse);
- }
- }
-
- // Are we using SDIO ?
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
- if (Status == EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported, Status=%r.\n", Status));
- return EFI_UNSUPPORTED;
- }
-
- // Check which kind of card we are using. Ver2.00 or later SD Memory Card (PL180 is SD v1.1)
- CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0);
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg);
- if (Status == EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n"));
- IsHCS = TRUE;
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive response to CMD8, Status=%r.\n", Status));
- return Status;
- }
- PrintResponseR1 (Response[0]);
- // Check if it is valid response
- if (Response[0] != CmdArg) {
- DEBUG ((EFI_D_ERROR, "The Card is not usable\n"));
- return EFI_UNSUPPORTED;
- }
- } else {
- DEBUG ((EFI_D_ERROR, "Not a SD2.0 Card\n"));
- }
-
- // We need to wait for the MMC or SD card is ready => (gCardInfo.OCRData.PowerUp == 1)
- Timeout = MAX_RETRY_COUNT;
- while (Timeout > 0) {
- // SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, 0);
- if (Status == EFI_SUCCESS) {
- DEBUG ((EFI_D_INFO, "Card should be SD\n"));
- if (IsHCS) {
- MmcHostInstance->CardInfo.CardType = SD_CARD_2;
- } else {
- MmcHostInstance->CardInfo.CardType = SD_CARD;
- }
-
- // Note: The first time CmdArg will be zero
- CmdArg = ((UINTN *) &(MmcHostInstance->CardInfo.OCRData))[0];
- if (IsHCS) {
- CmdArg |= BIT30;
- }
- Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
- if (!EFI_ERROR (Status)) {
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
- return Status;
- }
- ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
- }
- } else {
- DEBUG ((EFI_D_INFO, "Card should be MMC\n"));
- MmcHostInstance->CardInfo.CardType = MMC_CARD;
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
- if (!EFI_ERROR (Status)) {
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
- return Status;
- }
- ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
- }
- }
-
- if (!EFI_ERROR (Status)) {
- if (!MmcHostInstance->CardInfo.OCRData.PowerUp) {
- gBS->Stall (1);
- Timeout--;
- } else {
- if ((MmcHostInstance->CardInfo.CardType == SD_CARD_2) && (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1)) {
- MmcHostInstance->CardInfo.CardType = SD_CARD_2_HIGH;
- DEBUG ((EFI_D_ERROR, "High capacity card.\n"));
- }
- break; // The MMC/SD card is ready. Continue the Identification Mode
- }
- } else {
- gBS->Stall (1);
- Timeout--;
- }
- }
-
- if (Timeout == 0) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(): No Card\n"));
- return EFI_NO_MEDIA;
- } else {
- PrintOCR (Response[0]);
- }
-
- Status = MmcNotifyState (MmcHostInstance, MmcReadyState);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcReadyState\n"));
- return Status;
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD2, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
- return Status;
- }
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive CID, Status=%r.\n", Status));
- return Status;
- }
-
- PrintCID (Response);
-
- Status = MmcHost->NotifyState (MmcHost, MmcIdentificationState);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcIdentificationState\n"));
- return Status;
- }
-
- //
- // Note, SD specifications say that "if the command execution causes a state change, it
- // will be visible to the host in the response to the next command"
- // The status returned for this CMD3 will be 2 - identification
- //
- CmdArg = 1;
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
- return Status;
- }
-
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_RCA, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive RCA, Status=%r.\n", Status));
- return Status;
- }
- PrintRCA (Response[0]);
-
- // For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
- if (MmcHostInstance->CardInfo.CardType != MMC_CARD) {
- MmcHostInstance->CardInfo.RCA = Response[0] >> 16;
- } else {
- MmcHostInstance->CardInfo.RCA = CmdArg;
- }
- Status = MmcNotifyState (MmcHostInstance, MmcStandByState);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcStandByState\n"));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-InitializeMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN BlockCount;
-
- BlockCount = 1;
- MmcHost = MmcHostInstance->MmcHost;
-
- Status = MmcIdentificationMode (MmcHostInstance);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "InitializeMmcDevice(): Error in Identification Mode, Status=%r\n", Status));
- return Status;
- }
-
- Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "InitializeMmcDevice(): Error MmcTransferState, Status=%r\n", Status));
- return Status;
- }
-
- if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
- Status = InitializeSdMmcDevice (MmcHostInstance);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- // Set Block Length
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "InitializeMmcDevice(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",
- MmcHostInstance->BlockIo.Media->BlockSize, Status));
- return Status;
- }
-
- // Block Count (not used). Could return an error for SD card
- if (MmcHostInstance->CardInfo.CardType == MMC_CARD) {
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "InitializeMmcDevice(MMC_CMD23): Error, Status=%r\n", Status));
- return Status;
- }
- }
-
- return EFI_SUCCESS;
-}