summaryrefslogtreecommitdiff
path: root/EmbeddedPkg/Drivers
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 /EmbeddedPkg/Drivers
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>
Diffstat (limited to 'EmbeddedPkg/Drivers')
-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
25 files changed, 0 insertions, 8747 deletions
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;
- }
-}