2007-07-11 08:46:38 +02:00
|
|
|
/** @file
|
|
|
|
|
2008-07-08 12:26:16 +02:00
|
|
|
Provides some data struct used by EHCI controller driver.
|
|
|
|
|
2010-01-19 07:42:21 +01:00
|
|
|
Copyright (c) 2006 - 2010, Intel Corporation
|
2007-07-11 08:46:38 +02:00
|
|
|
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 _EFI_EHCI_H_
|
|
|
|
#define _EFI_EHCI_H_
|
|
|
|
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2008-08-30 16:09:38 +02:00
|
|
|
#include <Uefi.h>
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
#include <Protocol/Usb2HostController.h>
|
|
|
|
#include <Protocol/PciIo.h>
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2009-04-10 10:31:45 +02:00
|
|
|
#include <Guid/EventGroup.h>
|
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/UefiDriverEntryPoint.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
2008-04-17 13:02:59 +02:00
|
|
|
#include <Library/PcdLib.h>
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2009-07-24 07:34:55 +02:00
|
|
|
#include <IndustryStandard/Pci.h>
|
2007-07-11 08:46:38 +02:00
|
|
|
|
|
|
|
typedef struct _USB2_HC_DEV USB2_HC_DEV;
|
|
|
|
|
|
|
|
#include "UsbHcMem.h"
|
|
|
|
#include "EhciReg.h"
|
|
|
|
#include "EhciUrb.h"
|
|
|
|
#include "EhciSched.h"
|
|
|
|
#include "EhciDebug.h"
|
2008-12-03 09:52:39 +01:00
|
|
|
#include "ComponentName.h"
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2010-01-19 07:42:21 +01:00
|
|
|
//
|
|
|
|
// EHC timeout experience values
|
|
|
|
//
|
|
|
|
|
|
|
|
#define EHC_1_MICROSECOND 1
|
|
|
|
#define EHC_1_MILLISECOND (1000 * EHC_1_MICROSECOND)
|
|
|
|
#define EHC_1_SECOND (1000 * EHC_1_MILLISECOND)
|
|
|
|
|
|
|
|
//
|
|
|
|
// EHCI register operation timeout, set by experience
|
|
|
|
//
|
|
|
|
#define EHC_RESET_TIMEOUT (1 * EHC_1_SECOND)
|
|
|
|
#define EHC_GENERIC_TIMEOUT (10 * EHC_1_MILLISECOND)
|
2008-07-08 12:26:16 +02:00
|
|
|
|
2010-01-19 07:42:21 +01:00
|
|
|
//
|
|
|
|
// Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]
|
|
|
|
//
|
|
|
|
#define EHC_ROOT_PORT_RECOVERY_STALL (20 * EHC_1_MILLISECOND)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sync and Async transfer polling interval, set by experience,
|
|
|
|
// and the unit of Async is 100us, means 50ms as interval.
|
|
|
|
//
|
|
|
|
#define EHC_SYNC_POLL_INTERVAL (1 * EHC_1_MILLISECOND)
|
|
|
|
#define EHC_ASYNC_POLL_INTERVAL (50 * 10000U)
|
2007-10-08 08:14:13 +02:00
|
|
|
|
2009-02-04 07:56:31 +01:00
|
|
|
//
|
|
|
|
// EHC raises TPL to TPL_NOTIFY to serialize all its operations
|
|
|
|
// to protect shared data structures.
|
|
|
|
//
|
2008-07-08 12:26:16 +02:00
|
|
|
#define EHC_TPL TPL_NOTIFY
|
2007-10-08 08:14:13 +02:00
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
//
|
|
|
|
//Iterate through the doule linked list. NOT delete safe
|
|
|
|
//
|
|
|
|
#define EFI_LIST_FOR_EACH(Entry, ListHead) \
|
|
|
|
for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
|
|
|
|
|
|
|
|
//
|
|
|
|
//Iterate through the doule linked list. This is delete-safe.
|
|
|
|
//Don't touch NextEntry
|
|
|
|
//
|
|
|
|
#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
|
|
|
|
for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
|
|
|
|
Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
|
|
|
|
|
2008-12-06 02:23:24 +01:00
|
|
|
#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
|
2007-07-11 08:46:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))
|
|
|
|
#define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
|
|
|
|
#define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
|
|
|
|
|
|
|
|
#define EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) \
|
|
|
|
(EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))
|
|
|
|
|
2009-02-04 07:56:31 +01:00
|
|
|
#define USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i')
|
|
|
|
#define EHC_FROM_THIS(a) CR(a, USB2_HC_DEV, Usb2Hc, USB2_HC_DEV_SIGNATURE)
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2007-07-17 03:48:09 +02:00
|
|
|
struct _USB2_HC_DEV {
|
2007-07-11 08:46:38 +02:00
|
|
|
UINTN Signature;
|
|
|
|
EFI_USB2_HC_PROTOCOL Usb2Hc;
|
|
|
|
|
|
|
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
2007-10-25 09:59:45 +02:00
|
|
|
UINT64 OriginalPciAttributes;
|
2007-07-11 08:46:38 +02:00
|
|
|
USBHC_MEM_POOL *MemPool;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Schedule data shared between asynchronous and periodic
|
|
|
|
// transfers:
|
|
|
|
// ShortReadStop, as its name indicates, is used to terminate
|
|
|
|
// the short read except the control transfer. EHCI follows
|
|
|
|
// the alternative next QTD point when a short read happens.
|
|
|
|
// For control transfer, even the short read happens, try the
|
|
|
|
// status stage.
|
|
|
|
//
|
|
|
|
EHC_QTD *ShortReadStop;
|
|
|
|
EFI_EVENT PollTimer;
|
|
|
|
|
2009-04-10 10:31:45 +02:00
|
|
|
//
|
|
|
|
// ExitBootServicesEvent is used to stop the EHC DMA operation
|
|
|
|
// after exit boot service.
|
|
|
|
//
|
|
|
|
EFI_EVENT ExitBootServiceEvent;
|
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
//
|
|
|
|
// Asynchronous(bulk and control) transfer schedule data:
|
|
|
|
// ReclaimHead is used as the head of the asynchronous transfer
|
|
|
|
// list. It acts as the reclamation header.
|
|
|
|
//
|
|
|
|
EHC_QH *ReclaimHead;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Peroidic (interrupt) transfer schedule data:
|
|
|
|
//
|
2010-02-28 14:00:58 +01:00
|
|
|
VOID *PeriodFrame; // the buffer pointed by this pointer is used to store pci bus address of the QH descriptor.
|
|
|
|
VOID *PeriodFrameHost; // the buffer pointed by this pointer is used to store host memory address of the QH descriptor.
|
2007-07-11 08:46:38 +02:00
|
|
|
VOID *PeriodFrameMap;
|
|
|
|
|
|
|
|
EHC_QH *PeriodOne;
|
|
|
|
LIST_ENTRY AsyncIntTransfers;
|
|
|
|
|
|
|
|
//
|
|
|
|
// EHCI configuration data
|
|
|
|
//
|
|
|
|
UINT32 HcStructParams; // Cache of HC structure parameter, EHC_HCSPARAMS_OFFSET
|
|
|
|
UINT32 HcCapParams; // Cache of HC capability parameter, HCCPARAMS
|
|
|
|
UINT32 CapLen; // Capability length
|
|
|
|
|
|
|
|
//
|
|
|
|
// Misc
|
|
|
|
//
|
|
|
|
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
2007-07-17 03:48:09 +02:00
|
|
|
};
|
2007-07-11 08:46:38 +02:00
|
|
|
|
|
|
|
|
2007-09-30 04:42:47 +02:00
|
|
|
extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;
|
|
|
|
extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;
|
|
|
|
extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2008-12-03 09:52:39 +01:00
|
|
|
/**
|
|
|
|
Test to see if this driver supports ControllerHandle. Any
|
|
|
|
ControllerHandle that has Usb2HcProtocol installed will
|
|
|
|
be supported.
|
|
|
|
|
|
|
|
@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
|
|
|
|
EhcDriverBindingSupported (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Controller,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Starting the Usb EHCI 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
|
|
|
|
EhcDriverBindingStart (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Controller,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
EhcDriverBindingStop (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Controller,
|
|
|
|
IN UINTN NumberOfChildren,
|
|
|
|
IN EFI_HANDLE *ChildHandleBuffer
|
|
|
|
);
|
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
#endif
|
2008-12-03 09:52:39 +01:00
|
|
|
|