/** @file
Private Header file for Usb Host Controller PEIM
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The
full text of the license may be found at
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 _RECOVERY_UHC_H_
#define _RECOVERY_UHC_H_
#include <PiPei.h>
#include <Ppi/UsbController.h>
#include <Ppi/UsbHostController.h>
#include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/PeiServicesLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/TimerLib.h>
#include <Library/PeiServicesLib.h>
//
// One memory block uses 16 page
//
/* Status register */
/* Interrupt enable register */
/* Frame Number Register Offset 06-08h */
/* Frame List Base Address Register Offset 08-0Bh */
/* Start of Frame Modify Register Offset 0Ch */
/* USB port status and control registers */
#pragma pack(1)
typedef struct {
typedef struct {
} QUEUE_HEAD;
typedef struct {
} QH_STRUCT;
typedef struct {
} TD;
typedef struct {
} TD_STRUCT;
#pragma pack()
struct _MEMORY_MANAGE_HEADER {
};
typedef struct {
//
// Header1 used for QH,TD memory blocks management
//
} USB_UHC_DEV;
#define PEI_RECOVERY_USB_UHC_DEV_FROM_UHCI_THIS(a) CR (a, USB_UHC_DEV, UsbHostControllerPpi, USB_UHC_DEV_SIGNATURE)
/**
Submits control transfer to a target USB device.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
@param DeviceAddress The target device address.
@param DeviceSpeed Target device speed.
@param MaximumPacketLength Maximum packet size the default control transfer
endpoint is capable of sending or receiving.
@param Request USB device request to send.
@param TransferDirection Specifies the data direction for the data stage.
@param Data Data buffer to be transmitted or received from USB device.
@param DataLength The size (in bytes) of the data buffer.
@param TimeOut Indicates the maximum timeout, in millisecond.
@param TransferResult Return the result of this control transfer.
@retval EFI_SUCCESS Transfer was completed successfully.
@retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.
@retval EFI_INVALID_PARAMETER Some parameters are invalid.
@retval EFI_TIMEOUT Transfer failed due to timeout.
@retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.
**/
);
/**
Submits bulk transfer to a bulk endpoint of a USB device.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
@param DeviceAddress Target device address.
@param EndPointAddress Endpoint number and its direction in bit 7.
@param MaximumPacketLength Maximum packet size the endpoint is capable of
sending or receiving.
@param Data Array of pointers to the buffers of data to transmit
from or receive into.
@param DataLength The lenght of the data buffer.
@param DataToggle On input, the initial data toggle for the transfer;
On output, it is updated to to next data toggle to use of
the subsequent bulk transfer.
@param TimeOut Indicates the maximum time, in millisecond, which the
transfer is allowed to complete.
@param TransferResult A pointer to the detailed result information of the
bulk transfer.
@retval EFI_SUCCESS The transfer was completed successfully.
@retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.
@retval EFI_INVALID_PARAMETER Parameters are invalid.
@retval EFI_TIMEOUT The transfer failed due to timeout.
@retval EFI_DEVICE_ERROR The transfer failed due to host controller error.
**/
);
/**
Retrieves the number of root hub ports.
@param[in] PeiServices The pointer to the PEI Services Table.
@param[in] This The pointer to this instance of the
PEI_USB_HOST_CONTROLLER_PPI.
@param[out] PortNumber The pointer to the number of the root hub ports.
@retval EFI_SUCCESS The port number was retrieved successfully.
@retval EFI_INVALID_PARAMETER PortNumber is NULL.
**/
);
/**
Retrieves the current status of a USB root hub port.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
@param PortNumber The root hub port to retrieve the state from.
@param PortStatus Variable to receive the port state.
@retval EFI_SUCCESS The status of the USB root hub port specified.
by PortNumber was returned in PortStatus.
@retval EFI_INVALID_PARAMETER PortNumber is invalid.
**/
);
/**
Sets a feature for the specified root hub port.
@param PeiServices The pointer of EFI_PEI_SERVICES
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI
@param PortNumber Root hub port to set.
@param PortFeature Feature to set.
@retval EFI_SUCCESS The feature specified by PortFeature was set.
@retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.
@retval EFI_TIMEOUT The time out occurred.
**/
);
/**
Clears a feature for the specified root hub port.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
@param PortNumber Specifies the root hub port whose feature
is requested to be cleared.
@param PortFeature Indicates the feature selector associated with the
feature clear request.
@retval EFI_SUCCESS The feature specified by PortFeature was cleared
for the USB root hub port specified by PortNumber.
@retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.
**/
);
/**
Initialize UHCI.
@param UhcDev UHCI Device.
@retval EFI_SUCCESS UHCI successfully initialized.
@retval EFI_OUT_OF_RESOURCES Resource can not be allocated.
**/
);
/**
Create Frame List Structure.
@param UhcDev UHCI device.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
@retval EFI_SUCCESS Success.
**/
);
/**
Read a 16bit width data from Uhc HC IO space register.
@param UhcDev The UHCI device.
@param Port The IO space address of the register.
@retval the register content read.
**/
);
/**
Write a 16bit width data into Uhc HC IO space register.
@param UhcDev The UHCI device.
@param Port The IO space address of the register.
@param Data The data written into the register.
**/
);
/**
Write a 32bit width data into Uhc HC IO space register.
@param UhcDev The UHCI device.
@param Port The IO space address of the register.
@param Data The data written into the register.
**/
);
/**
Clear the content of UHCI's Status Register.
@param UhcDev The UHCI device.
@param StatusAddr The IO space address of the register.
**/
);
/**
Check whether the host controller operates well.
@param UhcDev The UHCI device.
@param StatusRegAddr The io address of status register.
@retval TRUE Host controller is working.
@retval FALSE Host controller is halted or system error.
**/
);
/**
Get Current Frame Number.
@param UhcDev The UHCI device.
@param FrameNumberAddr The address of frame list register.
@retval The content of the frame list register.
**/
);
/**
Set Frame List Base Address.
@param UhcDev The UHCI device.
@param FrameListRegAddr The address of frame list register.
@param Addr The address of frame list table.
**/
);
/**
Create QH and initialize.
@param UhcDev The UHCI device.
@param PtrQH Place to store QH_STRUCT pointer.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
@retval EFI_SUCCESS Success.
**/
CreateQH (
);
/**
Set the horizontal link pointer in QH.
@param PtrQH Place to store QH_STRUCT pointer.
@param PtrNext Place to the next QH_STRUCT.
**/
);
/**
Get the horizontal link pointer in QH.
@param PtrQH Place to store QH_STRUCT pointer.
@retval The horizontal link pointer in QH.
**/
VOID *
);
/**
Set a QH or TD horizontally to be connected with a specific QH.
@param PtrQH Place to store QH_STRUCT pointer.
@param IsQH Specify QH or TD is connected.
**/
);
/**
Set the horizontal validor bit in QH.
@param PtrQH Place to store QH_STRUCT pointer.
@param IsValid Specify the horizontal linker is valid or not.
**/
);
/**
Set the vertical link pointer in QH.
@param PtrQH Place to store QH_STRUCT pointer.
@param PtrNext Place to the next QH_STRUCT.
**/
);
/**
Set a QH or TD vertically to be connected with a specific QH.
@param PtrQH Place to store QH_STRUCT pointer.
@param IsQH Specify QH or TD is connected.
**/
);
/**
Set the vertical validor bit in QH.
@param PtrQH Place to store QH_STRUCT pointer.
@param IsValid Specify the vertical linker is valid or not.
**/
);
/**
Get the vertical validor bit in QH.
@param PtrQH Place to store QH_STRUCT pointer.
@retval The vertical linker is valid or not.
**/
);
/**
Allocate TD or QH Struct.
@param UhcDev The UHCI device.
@param Size The size of allocation.
@param PtrStruct Place to store TD_STRUCT pointer.
@return EFI_SUCCESS Allocate successfully.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
**/
);
/**
Create a TD Struct.
@param UhcDev The UHCI device.
@param PtrTD Place to store TD_STRUCT pointer.
@return EFI_SUCCESS Allocate successfully.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
**/
CreateTD (
);
/**
Generate Setup Stage TD.
@param UhcDev The UHCI device.
@param DevAddr Device address.
@param Endpoint Endpoint number.
@param DeviceSpeed Device Speed.
@param DevRequest Device reuquest.
@param RequestLen Request length.
@param PtrTD TD_STRUCT generated.
@return EFI_SUCCESS Generate setup stage TD successfully.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
**/
);
/**
Generate Data Stage TD.
@param UhcDev The UHCI device.
@param DevAddr Device address.
@param Endpoint Endpoint number.
@param PtrData Data buffer.
@param Len Data length.
@param PktID PacketID.
@param Toggle Data toggle value.
@param DeviceSpeed Device Speed.
@param PtrTD TD_STRUCT generated.
@return EFI_SUCCESS Generate data stage TD successfully.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
**/
);
/**
Generate Status Stage TD.
@param UhcDev The UHCI device.
@param DevAddr Device address.
@param Endpoint Endpoint number.
@param PktID PacketID.
@param DeviceSpeed Device Speed.
@param PtrTD TD_STRUCT generated.
@return EFI_SUCCESS Generate status stage TD successfully.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
**/
);
/**
Set the link pointer validor bit in TD.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsValid Specify the linker pointer is valid or not.
**/
);
/**
Set the Link Pointer pointing to a QH or TD.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsQH Specify QH or TD is connected.
**/
);
/**
Set the traverse is depth-first or breadth-first.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsDepth Specify the traverse is depth-first or breadth-first.
**/
);
/**
Set TD Link Pointer in TD.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param PtrNext Place to the next TD_STRUCT.
**/
);
/**
Get TD Link Pointer.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval Get TD Link Pointer in TD.
**/
VOID*
);
/**
Get the information about whether the Link Pointer field pointing to
a QH or a TD.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval whether the Link Pointer field pointing to a QH or a TD.
**/
);
/**
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsEnable Enable or disable short packet detection mechanism.
**/
);
/**
Set the max error counter in TD.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param MaxErrors The number of allowable error.
**/
);
/**
Set the TD is targeting a low-speed device or not.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsLowSpeedDevice Whether The device is low-speed.
**/
);
/**
Set the TD is isochronous transfer type or not.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsIsochronous Whether the transaction isochronous transfer type.
**/
);
/**
Set if UCHI should issue an interrupt on completion of the frame
in which this TD is executed
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsSet Whether HC should issue an interrupt on completion.
**/
);
/**
Set if the TD is active and can be executed.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param IsActive Whether the TD is active and can be executed.
**/
);
/**
Specifies the maximum number of data bytes allowed for the transfer.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param MaxLen The maximum number of data bytes allowed.
@retval The allowed maximum number of data.
**/
);
/**
Set the data toggle bit to DATA1.
@param PtrTDStruct Place to store TD_STRUCT pointer.
**/
);
/**
Set the data toggle bit to DATA0.
@param PtrTDStruct Place to store TD_STRUCT pointer.
**/
);
/**
Set EndPoint Number the TD is targeting at.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param EndPoint The Endport number of the target.
**/
);
/**
Set Device Address the TD is targeting at.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param DevAddr The Device Address of the target.
**/
);
/**
Set Packet Identification the TD is targeting at.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@param PacketID The Packet Identification of the target.
**/
);
/**
Set the beginning address of the data buffer that will be used
during the transaction.
@param PtrTDStruct Place to store TD_STRUCT pointer.
**/
);
/**
Detect whether the TD is active.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The TD is active or not.
**/
);
/**
Detect whether the TD is stalled.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The TD is stalled or not.
**/
);
/**
Detect whether Data Buffer Error is happened.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The Data Buffer Error is happened or not.
**/
);
/**
Detect whether Babble Error is happened.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The Babble Error is happened or not.
**/
);
/**
Detect whether NAK is received.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The NAK is received or not.
**/
);
/**
@param PtrTDStruct Place to store TD_STRUCT pointer.
**/
);
/**
Detect whether Bitstuff Error is received.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The Bitstuff Error is received or not.
**/
);
/**
Retrieve the actual number of bytes that were tansferred.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The actual number of bytes that were tansferred.
**/
);
/**
Retrieve the information of whether the Link Pointer field is valid or not.
@param PtrTDStruct Place to store TD_STRUCT pointer.
@retval The linker pointer field is valid or not.
**/
);
/**
Count TD Number from PtrFirstTD.
@param PtrFirstTD Place to store TD_STRUCT pointer.
@retval The queued TDs number.
**/
);
/**
Link TD To QH.
@param PtrQH Place to store QH_STRUCT pointer.
@param PtrTD Place to store TD_STRUCT pointer.
**/
);
/**
Link TD To TD.
@param PtrPreTD Place to store TD_STRUCT pointer.
@param PtrTD Place to store TD_STRUCT pointer.
**/
);
/**
Execute Control Transfer.
@param UhcDev The UCHI device.
@param PtrTD A pointer to TD_STRUCT data.
@param ActualLen Actual transfer Length.
@param TimeOut TimeOut value.
@param TransferResult Transfer Result.
@return EFI_DEVICE_ERROR The transfer failed due to transfer error.
@return EFI_TIMEOUT The transfer failed due to time out.
@return EFI_SUCCESS The transfer finished OK.
**/
);
/**
Execute Bulk Transfer.
@param UhcDev The UCHI device.
@param PtrTD A pointer to TD_STRUCT data.
@param ActualLen Actual transfer Length.
@param DataToggle DataToggle value.
@param TimeOut TimeOut value.
@param TransferResult Transfer Result.
@return EFI_DEVICE_ERROR The transfer failed due to transfer error.
@return EFI_TIMEOUT The transfer failed due to time out.
@return EFI_SUCCESS The transfer finished OK.
**/
);
/**
Delete Queued TDs.
@param UhcDev The UCHI device.
@param PtrFirstTD Place to store TD_STRUCT pointer.
**/
);
/**
Check TDs Results.
@param PtrTD A pointer to TD_STRUCT data.
@param Result The result to return.
@param ErrTDPos The Error TD position.
@param ActualTransferSize Actual transfer size.
@retval The TD is executed successfully or not.
**/
);
/**
Create Memory Block.
@param UhcDev The UCHI device.
@param MemoryHeader The Pointer to allocated memory block.
@param MemoryBlockSizeInPages The page size of memory block to be allocated.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
@retval EFI_SUCCESS Success.
**/
);
/**
Initialize UHCI memory management.
@param UhcDev The UCHI device.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
@retval EFI_SUCCESS Success.
**/
);
/**
Initialize UHCI memory management.
@param UhcDev The UCHI device.
@param Pool Buffer pointer to store the buffer pointer.
@param AllocSize The size of the pool to be allocated.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
@retval EFI_SUCCESS Success.
**/
);
/**
Alloc Memory In MemoryBlock.
@param MemoryHeader The pointer to memory manage header.
@param Pool Buffer pointer to store the buffer pointer.
@param NumberOfMemoryUnit The size of the pool to be allocated.
@retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
@retval EFI_SUCCESS Success.
**/
);
/**
Uhci Free Pool.
@param UhcDev The UHCI device.
@param Pool A pointer to store the buffer address.
@param AllocSize The size of the pool to be freed.
**/
);
/**
Insert a new memory header into list.
@param MemoryHeader A pointer to the memory header list.
@param NewMemoryHeader A new memory header to be inserted into the list.
**/
);
/**
Judge the memory block in the memory header is empty or not.
@param MemoryHeaderPtr A pointer to the memory header list.
@retval Whether the memory block in the memory header is empty or not.
**/
);
/**
remove a memory header from list.
@param FirstMemoryHeader A pointer to the memory header list.
@param FreeMemoryHeader A memory header to be removed into the list.
**/
);
#endif