2007-07-11 08:46:38 +02:00
|
|
|
/** @file
|
|
|
|
|
2008-07-09 03:50:16 +02:00
|
|
|
The definition for UHCI driver model and HC protocol routines.
|
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
Copyright (c) 2004 - 2007, Intel Corporation
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
2008-07-09 03:50:16 +02:00
|
|
|
#ifndef _EFI_UHCI_H_
|
|
|
|
#define _EFI_UHCI_H_
|
2007-07-11 08:46:38 +02:00
|
|
|
|
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/UsbHostController.h>
|
|
|
|
#include <Protocol/PciIo.h>
|
2007-07-20 08:10:09 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
#include <IndustryStandard/Pci22.h>
|
|
|
|
|
|
|
|
typedef struct _USB_HC_DEV USB_HC_DEV;
|
|
|
|
|
|
|
|
#include "UsbHcMem.h"
|
|
|
|
#include "UhciQueue.h"
|
|
|
|
#include "UhciReg.h"
|
|
|
|
#include "UhciSched.h"
|
|
|
|
#include "UhciDebug.h"
|
2008-12-03 09:52:39 +01:00
|
|
|
#include "ComponentName.h"
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2008-07-09 03:50:16 +02:00
|
|
|
typedef enum {
|
2007-10-08 08:14:13 +02:00
|
|
|
UHC_1_MICROSECOND = 1,
|
|
|
|
UHC_1_MILLISECOND = 1000 * UHC_1_MICROSECOND,
|
|
|
|
UHC_1_SECOND = 1000 * UHC_1_MILLISECOND,
|
|
|
|
|
|
|
|
//
|
|
|
|
// UHCI register operation timeout, set by experience
|
2007-07-11 08:46:38 +02:00
|
|
|
//
|
2007-10-08 08:14:13 +02:00
|
|
|
UHC_GENERIC_TIMEOUT = UHC_1_SECOND,
|
2007-10-25 09:59:45 +02:00
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
//
|
2007-10-08 08:14:13 +02:00
|
|
|
// Wait for force global resume(FGR) complete, refers to
|
|
|
|
// specification[UHCI11-2.1.1]
|
2007-10-25 09:59:45 +02:00
|
|
|
//
|
2007-10-08 08:14:13 +02:00
|
|
|
UHC_FORCE_GLOBAL_RESUME_STALL = 20 * UHC_1_MILLISECOND,
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2007-10-08 08:14:13 +02:00
|
|
|
//
|
|
|
|
// Wait for roothub port reset and recovery, reset stall
|
2007-10-25 09:59:45 +02:00
|
|
|
// is set by experience, and recovery stall refers to
|
2007-10-08 08:14:13 +02:00
|
|
|
// specification[UHCI11-2.1.1]
|
|
|
|
//
|
|
|
|
UHC_ROOT_PORT_RESET_STALL = 50 * UHC_1_MILLISECOND,
|
|
|
|
UHC_ROOT_PORT_RECOVERY_STALL = 10 * UHC_1_MILLISECOND,
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2007-10-08 08:14:13 +02:00
|
|
|
//
|
2007-10-25 09:59:45 +02:00
|
|
|
// Sync and Async transfer polling interval, set by experience,
|
2007-10-08 08:14:13 +02:00
|
|
|
// and the unit of Async is 100us.
|
|
|
|
//
|
|
|
|
UHC_SYNC_POLL_INTERVAL = 50 * UHC_1_MICROSECOND,
|
2008-07-09 03:50:16 +02:00
|
|
|
UHC_ASYNC_POLL_INTERVAL = 50 * 10000UL
|
|
|
|
}UHC_TIMEOUT_EXPERIENCE_VALUE;
|
2007-10-25 09:59:45 +02:00
|
|
|
|
2007-07-11 08:46:38 +02:00
|
|
|
|
2008-07-09 03:50:16 +02:00
|
|
|
//
|
|
|
|
// UHC raises TPL to TPL_NOTIFY to serialize all its operations
|
|
|
|
// to protect shared data structures.
|
|
|
|
//
|
|
|
|
#define UHCI_TPL TPL_NOTIFY
|
|
|
|
|
2008-12-16 16:34:21 +01:00
|
|
|
#define USB_HC_DEV_SIGNATURE SIGNATURE_32 ('u', 'h', 'c', 'i')
|
2007-07-11 08:46:38 +02:00
|
|
|
|
|
|
|
#pragma pack(1)
|
|
|
|
typedef struct {
|
|
|
|
UINT8 PI;
|
|
|
|
UINT8 SubClassCode;
|
|
|
|
UINT8 BaseCode;
|
|
|
|
} USB_CLASSC;
|
|
|
|
#pragma pack()
|
|
|
|
|
|
|
|
#define UHC_FROM_USB2_HC_PROTO(This) CR(This, USB_HC_DEV, Usb2Hc, USB_HC_DEV_SIGNATURE)
|
|
|
|
|
|
|
|
//
|
|
|
|
// USB_HC_DEV support the UHCI hardware controller. It schedules
|
|
|
|
// the asynchronous interrupt transfer with the same method as
|
|
|
|
// EHCI: a reversed tree structure. For synchronous interrupt,
|
|
|
|
// control and bulk transfer, it uses three static queue head to
|
|
|
|
// schedule them. SyncIntQh is for interrupt transfer. LsCtrlQh is
|
|
|
|
// for LOW speed control transfer, and FsCtrlBulkQh is for FULL
|
|
|
|
// speed control or bulk transfer. This is because FULL speed contrl
|
|
|
|
// or bulk transfer can reclaim the unused bandwidth. Some USB
|
|
|
|
// device requires this bandwidth reclamation capability.
|
|
|
|
//
|
2007-07-17 03:48:09 +02:00
|
|
|
struct _USB_HC_DEV {
|
2007-07-11 08:46:38 +02:00
|
|
|
UINT32 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
|
|
|
|
|
|
|
//
|
|
|
|
// Schedule data structures
|
|
|
|
//
|
|
|
|
UINT32 *FrameBase;
|
|
|
|
UHCI_QH_SW *SyncIntQh;
|
|
|
|
UHCI_QH_SW *CtrlQh;
|
|
|
|
UHCI_QH_SW *BulkQh;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Structures to maintain asynchronus interrupt transfers.
|
|
|
|
// When asynchronous interrutp transfer is unlinked from
|
|
|
|
// the frame list, the hardware may still hold a pointer
|
|
|
|
// to it. To synchronize with hardware, its resoureces are
|
|
|
|
// released in two steps using Recycle and RecycleWait.
|
|
|
|
// Check the asynchronous interrupt management routines.
|
|
|
|
//
|
|
|
|
LIST_ENTRY AsyncIntList;
|
|
|
|
EFI_EVENT AsyncIntMonitor;
|
|
|
|
UHCI_ASYNC_REQUEST *Recycle;
|
|
|
|
UHCI_ASYNC_REQUEST *RecycleWait;
|
|
|
|
|
|
|
|
|
|
|
|
UINTN RootPorts;
|
|
|
|
USBHC_MEM_POOL *MemPool;
|
|
|
|
EFI_UNICODE_STRING_TABLE *CtrlNameTable;
|
|
|
|
VOID *FrameMapping;
|
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 gUhciDriverBinding;
|
|
|
|
extern EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName;
|
|
|
|
extern EFI_COMPONENT_NAME2_PROTOCOL gUhciComponentName2;
|
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 UsbHcProtocol 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
|
|
|
|
UhciDriverBindingSupported (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Controller,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Starting the Usb UHCI Driver.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param Controller Handle of device to test.
|
|
|
|
@param RemainingDevicePath Not used.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver supports this device.
|
|
|
|
@retval EFI_UNSUPPORTED This driver does not support this device.
|
|
|
|
@retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.
|
|
|
|
EFI_OUT_OF_RESOURCES- Failed due to resource shortage.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
UhciDriverBindingStart (
|
|
|
|
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
|
|
|
|
@return others
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
UhciDriverBindingStop (
|
|
|
|
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
|