1. Add NULL QH to set as QH header;

2. Do ping for high speed OUT pipe;
3. Bug fix for QTD size detection;
4. Bug fix for short package detection;
5. Bug fix get next QTD in ExcutionTransfer;
6. BOT module modify to follow spec;
7. Massstorage error hanling enhancement 

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2321 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8 2007-01-26 04:08:57 +00:00
parent 01bf334d2c
commit 4d1fe68e1c
16 changed files with 1998 additions and 1893 deletions

View File

@ -22,7 +22,8 @@ Revision History
#include "Ehci.h" #include "Ehci.h"
void
VOID
DumpEHCIPortsStatus ( DumpEHCIPortsStatus (
IN USB2_HC_DEV *HcDev IN USB2_HC_DEV *HcDev
) )
@ -47,6 +48,8 @@ DumpEHCIPortsStatus (
); );
DEBUG((gEHCDebugLevel, "Port[%d] = 0x%x\n", Index, Value)); DEBUG((gEHCDebugLevel, "Port[%d] = 0x%x\n", Index, Value));
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,20 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
EhciMem.c EhciMem.c
Abstract: Abstract:
Revision History Revision History
--*/ --*/
@ -40,13 +40,13 @@ Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
MemoryHeader - MEMORY_MANAGE_HEADER to output MemoryHeader - MEMORY_MANAGE_HEADER to output
MemoryBlockSizeInPages - MemoryBlockSizeInPages MemoryBlockSizeInPages - MemoryBlockSizeInPages
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Fail for no resources EFI_OUT_OF_RESOURCES Fail for no resources
EFI_UNSUPPORTED Unsupported currently EFI_UNSUPPORTED Unsupported currently
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -73,7 +73,7 @@ Returns:
// //
// each bit in Bit Array will manage 32 bytes memory in memory block // each bit in Bit Array will manage 32 bytes memory in memory block
// //
(*MemoryHeader)->BitArraySizeInBytes = ((*MemoryHeader)->MemoryBlockSizeInBytes / 32) / 8; (*MemoryHeader)->BitArraySizeInBytes = ((*MemoryHeader)->MemoryBlockSizeInBytes / MEM_UNIT_SIZE) / 8;
// //
// Allocate memory for BitArray // Allocate memory for BitArray
@ -83,7 +83,7 @@ Returns:
gBS->FreePool (*MemoryHeader); gBS->FreePool (*MemoryHeader);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Memory Block uses MemoryBlockSizeInPages pages, // Memory Block uses MemoryBlockSizeInPages pages,
// and it is allocated as common buffer use. // and it is allocated as common buffer use.
@ -112,7 +112,7 @@ Returns:
&Mapping &Mapping
); );
// //
// If returned Mapped size is less than the size // If returned Mapped size is less than the size
// we request,do not support. // we request,do not support.
// //
if (EFI_ERROR (Status) || (MemoryBlockSizeInBytes != EFI_PAGES_TO_SIZE (MemoryBlockSizeInPages))) { if (EFI_ERROR (Status) || (MemoryBlockSizeInBytes != EFI_PAGES_TO_SIZE (MemoryBlockSizeInPages))) {
@ -121,9 +121,9 @@ Returns:
gBS->FreePool (*MemoryHeader); gBS->FreePool (*MemoryHeader);
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Data structure involved by host controller // Data structure involved by host controller
// should be restricted into the same 4G // should be restricted into the same 4G
// //
if (HcDev->Is64BitCapable != 0) { if (HcDev->Is64BitCapable != 0) {
@ -135,7 +135,7 @@ Returns:
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
} }
// //
// Set Memory block initial address // Set Memory block initial address
// //
@ -240,16 +240,16 @@ Returns:
ASSERT (MemoryHeader != NULL); ASSERT (MemoryHeader != NULL);
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY + 1); OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY + 1);
// //
// allocate unit is 32 bytes (align on 32 byte) // allocate unit is 32 bytes (align on 32 byte)
// //
if (AllocSize & 0x1F) { if (AllocSize & (MEM_UNIT_SIZE - 1)) {
RealAllocSize = (AllocSize / 32 + 1) * 32; RealAllocSize = (AllocSize / MEM_UNIT_SIZE + 1) * MEM_UNIT_SIZE;
} else { } else {
RealAllocSize = AllocSize; RealAllocSize = AllocSize;
} }
// //
// There may be linked MemoryHeaders. // There may be linked MemoryHeaders.
// To allocate a free pool in Memory blocks, // To allocate a free pool in Memory blocks,
@ -262,22 +262,26 @@ Returns:
Status = AllocMemInMemoryBlock ( Status = AllocMemInMemoryBlock (
TempHeaderPtr, TempHeaderPtr,
(VOID **) Pool, (VOID **) Pool,
RealAllocSize / 32 RealAllocSize / MEM_UNIT_SIZE
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ZeroMem (*Pool, AllocSize); break;
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
} }
} }
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
if (!EFI_ERROR (Status)) {
ZeroMem (*Pool, AllocSize);
return EFI_SUCCESS;
}
// //
// There is no enough memory, // There is no enough memory,
// Create a new Memory Block // Create a new Memory Block
// //
// //
// if pool size is larger than NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES, // if pool size is larger than NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES,
// just allocate a large enough memory block. // just allocate a large enough memory block.
@ -303,13 +307,15 @@ Returns:
Status = AllocMemInMemoryBlock ( Status = AllocMemInMemoryBlock (
NewMemoryHeader, NewMemoryHeader,
(VOID **) Pool, (VOID **) Pool,
RealAllocSize / 32 RealAllocSize / MEM_UNIT_SIZE
); );
gBS->RestoreTPL (OldTpl);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ZeroMem (*Pool, AllocSize); ZeroMem (*Pool, AllocSize);
} }
gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
@ -354,12 +360,12 @@ Returns:
// //
// allocate unit is 32 byte (align on 32 byte) // allocate unit is 32 byte (align on 32 byte)
// //
if (AllocSize & 0x1F) { if (AllocSize & (MEM_UNIT_SIZE - 1)) {
RealAllocSize = (AllocSize / 32 + 1) * 32; RealAllocSize = (AllocSize / MEM_UNIT_SIZE + 1) * MEM_UNIT_SIZE;
} else { } else {
RealAllocSize = AllocSize; RealAllocSize = AllocSize;
} }
// //
// scan the memory header linked list for // scan the memory header linked list for
// the asigned memory to free. // the asigned memory to free.
@ -373,14 +379,16 @@ Returns:
// Pool is in the Memory Block area, // Pool is in the Memory Block area,
// find the start byte and bit in the bit array // find the start byte and bit in the bit array
// //
StartBytePos = ((Pool - TempHeaderPtr->MemoryBlockPtr) / 32) / 8; StartBytePos = ((Pool - TempHeaderPtr->MemoryBlockPtr) / MEM_UNIT_SIZE) / 8;
StartBitPos = (UINT8) (((Pool - TempHeaderPtr->MemoryBlockPtr) / 32) & 0x7); StartBitPos = (UINT8) (((Pool - TempHeaderPtr->MemoryBlockPtr) / MEM_UNIT_SIZE) & 0x7);
// //
// reset associated bits in bit arry // reset associated bits in bit arry
// //
for (Index = StartBytePos, Index2 = StartBitPos, Count = 0; Count < (RealAllocSize / 32); Count++) { for (Index = StartBytePos, Index2 = StartBitPos, Count = 0; Count < (RealAllocSize / MEM_UNIT_SIZE); Count++) {
TempHeaderPtr->BitArrayPtr[Index] = (UINT8) (TempHeaderPtr->BitArrayPtr[Index] ^ (bit (Index2))); ASSERT ((TempHeaderPtr->BitArrayPtr[Index] & bit (Index2) )== bit (Index2));
TempHeaderPtr->BitArrayPtr[Index] ^= (UINT8) (bit (Index2));
Index2++; Index2++;
if (Index2 == 8) { if (Index2 == 8) {
Index += 1; Index += 1;
@ -393,7 +401,7 @@ Returns:
break; break;
} }
} }
// //
// Release emptied memory blocks (only if the memory block is not // Release emptied memory blocks (only if the memory block is not
// the first one in the memory header list // the first one in the memory header list
@ -479,7 +487,7 @@ Arguments:
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_NOT_FOUND Can't find the free memory EFI_NOT_FOUND Can't find the free memory
--*/ --*/
{ {
@ -508,7 +516,7 @@ Returns:
// //
// right shift the byte // right shift the byte
// //
ByteValue /= 2; ByteValue = ByteValue >> 1;
if (BitValue == 0) { if (BitValue == 0) {
// //
@ -564,11 +572,11 @@ Returns:
if (NumberOfZeros < NumberOfMemoryUnit) { if (NumberOfZeros < NumberOfMemoryUnit) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Found enough free space. // Found enough free space.
// //
// //
// The values recorded in (FoundBytePos,FoundBitPos) have two conditions: // The values recorded in (FoundBytePos,FoundBitPos) have two conditions:
// 1)(FoundBytePos,FoundBitPos) record the position // 1)(FoundBytePos,FoundBitPos) record the position
@ -581,7 +589,7 @@ Returns:
if ((MemoryHeader->BitArrayPtr[FoundBytePos] & bit (FoundBitPos)) != 0) { if ((MemoryHeader->BitArrayPtr[FoundBytePos] & bit (FoundBitPos)) != 0) {
FoundBitPos += 1; FoundBitPos += 1;
} }
// //
// Have the (FoundBytePos,FoundBitPos) make sense. // Have the (FoundBytePos,FoundBitPos) make sense.
// //
@ -589,13 +597,14 @@ Returns:
FoundBytePos += 1; FoundBytePos += 1;
FoundBitPos -= 8; FoundBitPos -= 8;
} }
// //
// Set the memory as allocated // Set the memory as allocated
// //
for (TempBytePos = FoundBytePos, Index = FoundBitPos, Count = 0; Count < NumberOfMemoryUnit; Count++) { for (TempBytePos = FoundBytePos, Index = FoundBitPos, Count = 0; Count < NumberOfMemoryUnit; Count++) {
MemoryHeader->BitArrayPtr[TempBytePos] = (UINT8) (MemoryHeader->BitArrayPtr[TempBytePos] | (bit (Index))); ASSERT ((MemoryHeader->BitArrayPtr[TempBytePos] & bit (Index) )== 0);
MemoryHeader->BitArrayPtr[TempBytePos] |= bit (Index);
Index++; Index++;
if (Index == 8) { if (Index == 8) {
TempBytePos += 1; TempBytePos += 1;
@ -603,7 +612,7 @@ Returns:
} }
} }
*Pool = MemoryHeader->MemoryBlockPtr + (FoundBytePos * 8 + FoundBitPos) * 32; *Pool = MemoryHeader->MemoryBlockPtr + (FoundBytePos * 8 + FoundBitPos) * MEM_UNIT_SIZE;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -625,7 +634,7 @@ Arguments:
Returns: Returns:
TRUE Empty TRUE Empty
FALSE Not Empty FALSE Not Empty
--*/ --*/
{ {
@ -675,6 +684,7 @@ Returns:
// Link the before and after // Link the before and after
// //
TempHeaderPtr->Next = NeedFreeMemoryHeader->Next; TempHeaderPtr->Next = NeedFreeMemoryHeader->Next;
NeedFreeMemoryHeader->Next = NULL;
break; break;
} }
} }
@ -698,7 +708,7 @@ Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -736,7 +746,7 @@ Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
MEMORY_MANAGE_HEADER *TempHeaderPtr; MEMORY_MANAGE_HEADER *TempHeaderPtr;

View File

@ -1,20 +1,20 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
Ehchlp.c Ehchlp.c
Abstract: Abstract:
Revision History Revision History
--*/ --*/
@ -29,7 +29,7 @@ HostReset (
{ {
UINT32 Value; UINT32 Value;
UINT32 TimeOut; UINT32 TimeOut;
ReadEhcOperationalReg ( ReadEhcOperationalReg (
HcDev, HcDev,
USBCMD, USBCMD,
@ -102,18 +102,18 @@ ReadEhcCapabiltiyReg (
Routine Description: Routine Description:
Read Ehc Capabitlity register Read Ehc Capabitlity register
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
CapabiltiyRegAddr - Ehc Capability register address CapabiltiyRegAddr - Ehc Capability register address
Data - A pointer to data read from register Data - A pointer to data read from register
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
return HcDev->PciIo->Mem.Read ( return HcDev->PciIo->Mem.Read (
@ -137,18 +137,18 @@ ReadEhcOperationalReg (
Routine Description: Routine Description:
Read Ehc Operation register Read Ehc Operation register
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
OperationalRegAddr - Ehc Operation register address OperationalRegAddr - Ehc Operation register address
Data - A pointer to data read from register Data - A pointer to data read from register
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
ASSERT (HcDev->UsbCapabilityLen); ASSERT (HcDev->UsbCapabilityLen);
@ -173,18 +173,18 @@ WriteEhcOperationalReg (
Routine Description: Routine Description:
Write Ehc Operation register Write Ehc Operation register
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
OperationalRegAddr - Ehc Operation register address OperationalRegAddr - Ehc Operation register address
Data - 32bit write to register Data - 32bit write to register
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
ASSERT (HcDev->UsbCapabilityLen); ASSERT (HcDev->UsbCapabilityLen);
@ -198,6 +198,8 @@ Returns:
); );
} }
VOID VOID
ClearLegacySupport ( ClearLegacySupport (
IN USB2_HC_DEV *HcDev IN USB2_HC_DEV *HcDev
@ -239,7 +241,7 @@ Returns:
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EECP, EECP,
1, 1,
&Value &Value
); );
DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value)); DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value));
@ -249,7 +251,7 @@ Returns:
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EECP + 0x4, EECP + 0x4,
1, 1,
&Value &Value
); );
DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value)); DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value));
@ -259,7 +261,7 @@ Returns:
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EECP, EECP,
1, 1,
&Value &Value
); );
Value = Value | (0x1 << 24); Value = Value | (0x1 << 24);
@ -270,7 +272,7 @@ Returns:
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EECP, EECP,
1, 1,
&Value &Value
); );
TimeOut = 40; TimeOut = 40;
@ -282,7 +284,7 @@ Returns:
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EECP, EECP,
1, 1,
&Value &Value
); );
if ((Value & 0x01010000) == 0x01000000) { if ((Value & 0x01010000) == 0x01000000) {
break; break;
@ -291,8 +293,8 @@ Returns:
if (TimeOut == 0) { if (TimeOut == 0) {
DEBUG((gEHCErrorLevel, "Timeout for getting HC OS Owned Semaphore\n" )); DEBUG((gEHCErrorLevel, "Timeout for getting HC OS Owned Semaphore\n" ));
} }
DEBUG((gEHCErrorLevel, "After Release Value\n" )); DEBUG((gEHCErrorLevel, "After Release Value\n" ));
HcDev->PciIo->Pci.Read ( HcDev->PciIo->Pci.Read (
@ -300,7 +302,7 @@ Returns:
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EECP, EECP,
1, 1,
&Value &Value
); );
DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value)); DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value));
@ -310,7 +312,7 @@ Returns:
EfiPciIoWidthUint32, EfiPciIoWidthUint32,
EECP + 0x4, EECP + 0x4,
1, 1,
&Value &Value
); );
DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value)); DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value));
@ -327,16 +329,16 @@ GetCapabilityLen (
Routine Description: Routine Description:
Get the length of capability register Get the length of capability register
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -364,18 +366,18 @@ SetFrameListLen (
Routine Description: Routine Description:
Set the length of Frame List Set the length of Frame List
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Length - the required length of frame list Length - the required length of frame list
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_INVALID_PARAMETER Invalid parameter EFI_INVALID_PARAMETER Invalid parameter
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -428,14 +430,14 @@ SetFrameListBaseAddr (
Routine Description: Routine Description:
Set base address of frame list first entry Set base address of frame list first entry
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
FrameBuffer - base address of first entry of frame list FrameBuffer - base address of first entry of frame list
Returns: Returns:
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -474,17 +476,17 @@ SetAsyncListAddr (
Routine Description: Routine Description:
Set address of first Async schedule Qh Set address of first Async schedule Qh
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
QhPtr - A pointer to first Qh in the Async schedule QhPtr - A pointer to first Qh in the Async schedule
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -512,16 +514,16 @@ SetCtrlDataStructSeg (
Routine Description: Routine Description:
Set register of control and data structure segment Set register of control and data structure segment
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
@ -550,16 +552,16 @@ SetPortRoutingEhc (
Routine Description: Routine Description:
Set Ehc port routing bit Set Ehc port routing bit
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -601,16 +603,16 @@ SetEhcDoorbell (
Routine Description: Routine Description:
Set Ehc door bell bit Set Ehc door bell bit
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -652,16 +654,16 @@ ClearEhcAllStatus (
Routine Description: Routine Description:
Clear Ehc all status bits Clear Ehc all status bits
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
UINT32 UsbStatusAddr; UINT32 UsbStatusAddr;
@ -684,16 +686,16 @@ EnablePeriodicSchedule (
Routine Description: Routine Description:
Enable periodic schedule Enable periodic schedule
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -735,16 +737,16 @@ DisablePeriodicSchedule (
Routine Description: Routine Description:
Disable periodic schedule Disable periodic schedule
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -784,16 +786,16 @@ EnableAsynchronousSchedule (
Routine Description: Routine Description:
Enable asynchrounous schedule Enable asynchrounous schedule
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -835,16 +837,16 @@ DisableAsynchronousSchedule (
Routine Description: Routine Description:
Disable asynchrounous schedule Disable asynchrounous schedule
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -884,16 +886,16 @@ ResetEhc (
Routine Description: Routine Description:
Reset Ehc Reset Ehc
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -935,16 +937,16 @@ StartScheduleExecution (
Routine Description: Routine Description:
Start Ehc schedule execution Start Ehc schedule execution
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail EFI_DEVICE_ERROR Fail
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -986,16 +988,16 @@ IsFrameListProgrammable (
Routine Description: Routine Description:
Whether frame list is programmable Whether frame list is programmable
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE Programmable TRUE Programmable
FALSE Unprogrammable FALSE Unprogrammable
--*/ --*/
{ {
BOOLEAN Value; BOOLEAN Value;
@ -1028,16 +1030,16 @@ IsPeriodicScheduleEnabled (
Routine Description: Routine Description:
Whether periodic schedule is enabled Whether periodic schedule is enabled
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE Enabled TRUE Enabled
FALSE Disabled FALSE Disabled
--*/ --*/
{ {
BOOLEAN Value; BOOLEAN Value;
@ -1070,16 +1072,16 @@ IsAsyncScheduleEnabled (
Routine Description: Routine Description:
Whether asynchronous schedule is enabled Whether asynchronous schedule is enabled
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE Enabled TRUE Enabled
FALSE Disabled FALSE Disabled
--*/ --*/
{ {
BOOLEAN Value; BOOLEAN Value;
@ -1113,16 +1115,16 @@ IsEhcPortEnabled (
Routine Description: Routine Description:
Whether port is enabled Whether port is enabled
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE Enabled TRUE Enabled
FALSE Disabled FALSE Disabled
--*/ --*/
{ {
UINT32 PortStatusControlAddr; UINT32 PortStatusControlAddr;
@ -1148,16 +1150,16 @@ IsEhcReseted (
Routine Description: Routine Description:
Whether Ehc is reseted Whether Ehc is reseted
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE Reseted TRUE Reseted
FALSE Unreseted FALSE Unreseted
--*/ --*/
{ {
BOOLEAN Value; BOOLEAN Value;
@ -1190,16 +1192,16 @@ IsEhcHalted (
Routine Description: Routine Description:
Whether Ehc is halted Whether Ehc is halted
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE Halted TRUE Halted
FALSE Not halted FALSE Not halted
--*/ --*/
{ {
BOOLEAN Value; BOOLEAN Value;
@ -1232,16 +1234,16 @@ IsEhcSysError (
Routine Description: Routine Description:
Whether Ehc is system error Whether Ehc is system error
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE System error TRUE System error
FALSE No system error FALSE No system error
--*/ --*/
{ {
BOOLEAN Value; BOOLEAN Value;
@ -1268,29 +1270,29 @@ Returns:
BOOLEAN BOOLEAN
IsHighSpeedDevice ( IsHighSpeedDevice (
IN EFI_USB2_HC_PROTOCOL *This, IN EFI_USB2_HC_PROTOCOL *This,
IN UINT8 PortNum IN UINT8 PortNum
) )
/*++ /*++
Routine Description: Routine Description:
Whether high speed device attached Whether high speed device attached
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Returns: Returns:
TRUE High speed TRUE High speed
FALSE Full speed FALSE Full speed
--*/ --*/
{ {
USB2_HC_DEV *HcDev; USB2_HC_DEV *HcDev;
UINT32 PortStatusControlAddr; UINT32 PortStatusControlAddr;
UINT32 PortStatusControlReg; UINT32 PortStatusControlReg;
HcDev = USB2_HC_DEV_FROM_THIS (This); HcDev = USB2_HC_DEV_FROM_THIS (This);
PortStatusControlAddr = (UINT32) (PORTSC + (4 * PortNum)); PortStatusControlAddr = (UINT32) (PORTSC + (4 * PortNum));
@ -1360,17 +1362,17 @@ WaitForEhcReset (
Routine Description: Routine Description:
wait for Ehc reset or timeout wait for Ehc reset or timeout
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1406,17 +1408,17 @@ WaitForEhcHalt (
Routine Description: Routine Description:
wait for Ehc halt or timeout wait for Ehc halt or timeout
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1452,17 +1454,17 @@ WaitForEhcNotHalt (
Routine Description: Routine Description:
wait for Ehc not halt or timeout wait for Ehc not halt or timeout
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1498,17 +1500,17 @@ WaitForAsyncScheduleEnable (
Routine Description: Routine Description:
Wait for Ehc asynchronous schedule enable or timeout Wait for Ehc asynchronous schedule enable or timeout
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1544,17 +1546,17 @@ WaitForAsyncScheduleDisable (
Routine Description: Routine Description:
Wait for Ehc asynchronous schedule disable or timeout Wait for Ehc asynchronous schedule disable or timeout
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1590,17 +1592,17 @@ WaitForPeriodicScheduleEnable (
Routine Description: Routine Description:
Wait for Ehc periodic schedule enable or timeout Wait for Ehc periodic schedule enable or timeout
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1636,17 +1638,17 @@ WaitForPeriodicScheduleDisable (
Routine Description: Routine Description:
Wait for periodic schedule disable or timeout Wait for periodic schedule disable or timeout
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1685,14 +1687,14 @@ Routine Description:
Arguments: Arguments:
HcDev - USB2_HC_DEV HcDev - USB2_HC_DEV
Timeout - timeout threshold Timeout - timeout threshold
Returns: Returns:
EFI_SUCCESS Success EFI_SUCCESS Success
EFI_TIMEOUT Timeout EFI_TIMEOUT Timeout
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -1702,7 +1704,7 @@ Returns:
UsbCommandAddr = USBCMD; UsbCommandAddr = USBCMD;
Delay = (Timeout / 50) + 1; Delay = (Timeout / 50) + 1;
do { do {
Status = ReadEhcOperationalReg ( Status = ReadEhcOperationalReg (
HcDev, HcDev,

File diff suppressed because it is too large Load Diff

View File

@ -485,6 +485,7 @@ UHCIDriverBindingStart (
UINTN FlBaseAddrReg; UINTN FlBaseAddrReg;
EFI_PCI_IO_PROTOCOL *PciIo; EFI_PCI_IO_PROTOCOL *PciIo;
USB_HC_DEV *HcDev; USB_HC_DEV *HcDev;
UINT64 Supports;
HcDev = NULL; HcDev = NULL;
@ -510,10 +511,19 @@ UHCIDriverBindingStart (
// //
Status = PciIo->Attributes ( Status = PciIo->Attributes (
PciIo, PciIo,
EfiPciIoAttributeOperationEnable, EfiPciIoAttributeOperationSupported,
EFI_PCI_DEVICE_ENABLE, 0,
NULL &Supports
); );
if (!EFI_ERROR (Status)) {
Supports &= EFI_PCI_DEVICE_ENABLE;
Status = PciIo->Attributes (
PciIo,
EfiPciIoAttributeOperationEnable,
Supports,
NULL
);
}
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->CloseProtocol ( gBS->CloseProtocol (
Controller, Controller,
@ -777,6 +787,8 @@ UnInstallUHCInterface (
--*/ --*/
{ {
USB_HC_DEV *HcDev; USB_HC_DEV *HcDev;
EFI_STATUS Status;
UINT64 Supports;
HcDev = USB_HC_DEV_FROM_THIS (This); HcDev = USB_HC_DEV_FROM_THIS (This);
@ -823,12 +835,21 @@ UnInstallUHCInterface (
// //
// Disable the USB Host Controller // Disable the USB Host Controller
// //
HcDev->PciIo->Attributes ( Status = HcDev->PciIo->Attributes (
HcDev->PciIo, HcDev->PciIo,
EfiPciIoAttributeOperationDisable, EfiPciIoAttributeOperationSupported,
EFI_PCI_DEVICE_ENABLE, 0,
NULL &Supports
); );
if (!EFI_ERROR (Status)) {
Supports &= EFI_PCI_DEVICE_ENABLE;
Status = HcDev->PciIo->Attributes (
HcDev->PciIo,
EfiPciIoAttributeOperationDisable,
Supports,
NULL
);
}
gBS->FreePool (HcDev); gBS->FreePool (HcDev);

View File

@ -1,13 +1,13 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
@ -70,21 +70,21 @@ UsbBotComponentNameGetDriverName (
Arguments: Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
Language - A pointer to a three character ISO 639-2 language identifier. Language - A pointer to a three character ISO 639-2 language identifier.
This is the language of the driver name that that the caller This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer. driver is up to the driver writer.
DriverName - A pointer to the Unicode string to return. This Unicode string DriverName - A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language is the name of the driver specified by This in the language
specified by Language. specified by Language.
Returns: Returns:
EFI_SUCCESS - The Unicode string for the Driver specified by This EFI_SUCCESS - The Unicode string for the Driver specified by This
and the language specified by Language was returned and the language specified by Language was returned
in DriverName. in DriverName.
EFI_INVALID_PARAMETER - Language is NULL. EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - DriverName is NULL. EFI_INVALID_PARAMETER - DriverName is NULL.
EFI_UNSUPPORTED - The driver specified by This does not support the EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language. language specified by Language.
--*/ --*/
@ -114,39 +114,39 @@ UsbBotComponentNameGetControllerName (
Arguments: Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle - The handle of a controller that the driver specified by ControllerHandle - The handle of a controller that the driver specified by
This is managing. This handle specifies the controller This is managing. This handle specifies the controller
whose name is to be returned. whose name is to be returned.
ChildHandle - The handle of the child controller to retrieve the name ChildHandle - The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller. that wishes to retrieve the name of a child controller.
Language - A pointer to a three character ISO 639-2 language Language - A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name identifier. This is the language of the controller name
that that the caller is requesting, and it must match one that that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the number of languages supported by a driver is up to the
driver writer. driver writer.
ControllerName - A pointer to the Unicode string to return. This Unicode ControllerName - A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified ControllerHandle and ChildHandle in the language specified
by Language from the point of view of the driver specified by Language from the point of view of the driver specified
by This. by This.
Returns: Returns:
EFI_SUCCESS - The Unicode string for the user readable name in the EFI_SUCCESS - The Unicode string for the user readable name in the
language specified by Language for the driver language specified by Language for the driver
specified by This was returned in DriverName. specified by This was returned in DriverName.
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - Language is NULL. EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - ControllerName is NULL. EFI_INVALID_PARAMETER - ControllerName is NULL.
EFI_UNSUPPORTED - The driver specified by This is not currently managing EFI_UNSUPPORTED - The driver specified by This is not currently managing
the controller specified by ControllerHandle and the controller specified by ControllerHandle and
ChildHandle. ChildHandle.
EFI_UNSUPPORTED - The driver specified by This does not support the EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language. language specified by Language.
--*/ --*/

View File

@ -1,13 +1,13 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
@ -19,6 +19,8 @@ Abstract:
#include "bot.h" #include "bot.h"
GLOBAL_REMOVE_IF_UNREFERENCED UINT32 gBOTDebugLevel = EFI_D_INFO;
GLOBAL_REMOVE_IF_UNREFERENCED UINT32 gBOTErrorLevel = EFI_D_INFO;
// //
// Function prototypes // Function prototypes
// //
@ -85,7 +87,7 @@ STATIC
EFI_STATUS EFI_STATUS
BotDataPhase ( BotDataPhase (
IN USB_BOT_DEVICE *UsbBotDev, IN USB_BOT_DEVICE *UsbBotDev,
IN UINT32 *DataSize, IN UINTN *DataSize,
IN OUT VOID *DataBuffer, IN OUT VOID *DataBuffer,
IN EFI_USB_DATA_DIRECTION Direction, IN EFI_USB_DATA_DIRECTION Direction,
IN UINT16 Timeout IN UINT16 Timeout
@ -94,11 +96,10 @@ BotDataPhase (
STATIC STATIC
EFI_STATUS EFI_STATUS
BotStatusPhase ( BotStatusPhase (
IN USB_BOT_DEVICE *UsbBotDev, IN USB_BOT_DEVICE *UsbBotDev,
OUT UINT8 *TransferStatus, OUT UINT32 *DataResidue,
IN UINT16 Timeout IN UINT16 Timeout
); );
// //
// USB Atapi protocol prototype // USB Atapi protocol prototype
// //
@ -193,7 +194,7 @@ BotDriverBindingSupported (
// //
// Check if it is a BOT type Mass Storage Device // Check if it is a BOT type Mass Storage Device
// //
if ((InterfaceDescriptor.InterfaceClass != 0x08) || if ((InterfaceDescriptor.InterfaceClass != MASS_STORAGE_CLASS) ||
(InterfaceDescriptor.InterfaceProtocol != BOT)) { (InterfaceDescriptor.InterfaceProtocol != BOT)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto Exit; goto Exit;
@ -431,7 +432,7 @@ BotDriverBindingStop (
Returns: Returns:
EFI_SUCCESS - This driver is removed DeviceHandle EFI_SUCCESS - This driver is removed DeviceHandle
EFI_UNSUPPORTED - Can't open the gEfiUsbAtapiProtocolGuid protocl EFI_UNSUPPORTED - Can't open the gEfiUsbAtapiProtocolGuid protocl
other - This driver was not removed from this device other - This driver was not removed from this device
--*/ --*/
@ -513,6 +514,38 @@ BotDriverBindingStop (
return Status; return Status;
} }
STATIC
EFI_STATUS
ClearBulkInPipe (
IN USB_BOT_DEVICE *UsbBotDev
)
{
UINT32 Result;
return UsbClearEndpointHalt (
UsbBotDev->UsbIo,
UsbBotDev->BulkInEndpointDescriptor->EndpointAddress,
&Result
);
}
STATIC
EFI_STATUS
ClearBulkOutPipe (
IN USB_BOT_DEVICE *UsbBotDev
)
{
UINT32 Result;
return UsbClearEndpointHalt (
UsbBotDev->UsbIo,
UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress,
&Result
);
}
STATIC STATIC
EFI_STATUS EFI_STATUS
BotRecoveryReset ( BotRecoveryReset (
@ -530,17 +563,12 @@ Arguments:
Returns: Returns:
EFI_SUCCESS - Success the operation EFI_SUCCESS - Success the operation
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Result;
EFI_USB_DEVICE_REQUEST Request; EFI_USB_DEVICE_REQUEST Request;
EFI_USB_IO_PROTOCOL *UsbIo; UINT32 Result;
UINT8 EndpointAddr;
UsbIo = UsbBotDev->UsbIo;
BotReportStatusCode ( BotReportStatusCode (
UsbBotDev->DevicePath, UsbBotDev->DevicePath,
EFI_PROGRESS_CODE, EFI_PROGRESS_CODE,
@ -555,43 +583,24 @@ Returns:
Request.RequestType = 0x21; Request.RequestType = 0x21;
Request.Request = 0xFF; Request.Request = 0xFF;
Status = UsbIo->UsbControlTransfer ( Status = UsbBotDev->UsbIo->UsbControlTransfer (
UsbIo, UsbBotDev->UsbIo,
&Request, &Request,
EfiUsbNoData, EfiUsbNoData,
TIMEOUT_VALUE, TIMEOUT_VALUE,
NULL, NULL,
0, 0,
&Result &Result
); );
gBS->Stall (100 * 1000); gBS->Stall (100 * 1000);
if (!EFI_ERROR (Status)) { ClearBulkInPipe (UsbBotDev);
// ClearBulkOutPipe (UsbBotDev);
// clear bulk in endpoint stall feature
//
EndpointAddr = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;
Status = UsbClearEndpointHalt (
UsbIo,
EndpointAddr,
&Result
);
//
// clear bulk out endpoint stall feature
//
EndpointAddr = UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress;
Status = UsbClearEndpointHalt (
UsbIo,
EndpointAddr,
&Result
);
}
return Status; return Status;
} }
// //
// Bot Protocol Implementation // Bot Protocol Implementation
// //
@ -639,7 +648,17 @@ BotCommandPhase (
cbw.dCBWSignature = CBWSIG; cbw.dCBWSignature = CBWSIG;
cbw.dCBWTag = 0x01; cbw.dCBWTag = 0x01;
cbw.dCBWDataTransferLength = DataTransferLength; cbw.dCBWDataTransferLength = DataTransferLength;
cbw.bmCBWFlags = (UINT8) (Direction << 7); switch (Direction) {
case EfiUsbDataOut:
case EfiUsbNoData:
cbw.bmCBWFlags = 0;
break;
case EfiUsbDataIn:
cbw.bmCBWFlags = 0x80;
break;
default:
break;
}
cbw.bCBWCBLength = CommandSize; cbw.bCBWCBLength = CommandSize;
CopyMem (cbw.CBWCB, Command, CommandSize); CopyMem (cbw.CBWCB, Command, CommandSize);
@ -648,28 +667,20 @@ BotCommandPhase (
Status = UsbIo->UsbBulkTransfer ( Status = UsbIo->UsbBulkTransfer (
UsbIo, UsbIo,
(UsbBotDev->BulkOutEndpointDescriptor)->EndpointAddress, UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress,
&cbw, &cbw,
&DataSize, &DataSize,
Timeout, Timeout,
&Result &Result
); );
if (EFI_ERROR (Status)) { return Status;
//
// Command phase fail, we need to recovery reset this device
//
BotRecoveryReset (UsbBotDev);
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
} }
STATIC STATIC
EFI_STATUS EFI_STATUS
BotDataPhase ( BotDataPhase (
IN USB_BOT_DEVICE *UsbBotDev, IN USB_BOT_DEVICE *UsbBotDev,
IN UINT32 *DataSize, IN UINTN *DataSize,
IN OUT VOID *DataBuffer, IN OUT VOID *DataBuffer,
IN EFI_USB_DATA_DIRECTION Direction, IN EFI_USB_DATA_DIRECTION Direction,
IN UINT16 Timeout IN UINT16 Timeout
@ -695,125 +706,52 @@ BotDataPhase (
UINT32 Result; UINT32 Result;
EFI_USB_IO_PROTOCOL *UsbIo; EFI_USB_IO_PROTOCOL *UsbIo;
UINT8 EndpointAddr; UINT8 EndpointAddr;
UINTN Remain;
UINTN Increment;
UINT32 MaxPacketLen;
UINT8 *BufferPtr; UINT8 *BufferPtr;
UINTN TransferredSize;
UINTN RetryTimes;
UINTN MaxRetry;
UINTN BlockSize;
UINTN PackageNum;
UsbIo = UsbBotDev->UsbIo; UsbIo = UsbBotDev->UsbIo;
Remain = *DataSize;
BufferPtr = (UINT8 *) DataBuffer; BufferPtr = (UINT8 *) DataBuffer;
TransferredSize = 0;
MaxRetry = 10;
PackageNum = 128;
// //
// retrieve the the max packet length of the given endpoint // retrieve the the max packet length of the given endpoint
// //
if (Direction == EfiUsbDataIn) { if (Direction == EfiUsbDataIn) {
MaxPacketLen = (UsbBotDev->BulkInEndpointDescriptor)->MaxPacketSize; EndpointAddr = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;
EndpointAddr = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;
} else { } else {
MaxPacketLen = (UsbBotDev->BulkOutEndpointDescriptor)->MaxPacketSize; EndpointAddr = UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress;
EndpointAddr = (UsbBotDev->BulkOutEndpointDescriptor)->EndpointAddress;
} }
RetryTimes = MaxRetry;
BlockSize = PackageNum * MaxPacketLen;
while (Remain > 0) {
//
// Using 15 packets to aVOID Bitstuff error
//
if (Remain > PackageNum * MaxPacketLen) {
Increment = BlockSize;
} else {
Increment = Remain;
}
Status = UsbIo->UsbBulkTransfer ( Status = UsbIo->UsbBulkTransfer (
UsbIo, UsbIo,
EndpointAddr, EndpointAddr,
BufferPtr, BufferPtr,
&Increment, DataSize,
Timeout, (UINT16)(Timeout),
&Result &Result
); );
TransferredSize += Increment;
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
RetryTimes--; if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
if ((RetryTimes == 0) || ((Result & EFI_USB_ERR_TIMEOUT) == 0)) { if (Direction == EfiUsbDataIn) {
goto ErrorExit; DEBUG((gBOTErrorLevel, "BOT: Data IN Stall, ClearBulkInPipe\n"));
ClearBulkInPipe (UsbBotDev);
} else {
DEBUG((gBOTErrorLevel, "BOT: Data OUT Stall, ClearBulkInPipe\n"));
ClearBulkOutPipe (UsbBotDev);
}
} }
// BotRecoveryReset (UsbBotDev);
}
TransferredSize -= Increment;
continue;
} else {
//
// we try MaxTetry times for every bulk transfer
//
RetryTimes = MaxRetry;
}
BufferPtr += Increment;
Remain -= Increment;
if (Increment < BlockSize && TransferredSize <= *DataSize) {
//
// we get to the end of transter and transter size is
// less than requriedsize
//
break;
}
}
*DataSize = (UINT32) TransferredSize;
return EFI_SUCCESS;
ErrorExit:
if (Direction == EfiUsbDataIn) {
BotReportStatusCode (
UsbBotDev->DevicePath,
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_INPUT_ERROR)
);
} else {
BotReportStatusCode (
UsbBotDev->DevicePath,
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_OUTPUT_ERROR)
);
}
if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
//
// just endpoint stall happens
//
UsbClearEndpointHalt (
UsbIo,
EndpointAddr,
&Result
);
}
*DataSize = (UINT32) TransferredSize;
return Status; return Status;
} }
STATIC STATIC
EFI_STATUS EFI_STATUS
BotStatusPhase ( BotStatusPhase (
IN USB_BOT_DEVICE *UsbBotDev, IN USB_BOT_DEVICE *UsbBotDev,
OUT UINT8 *TransferStatus, OUT UINT32 *DataResidue,
IN UINT16 Timeout IN UINT16 Timeout
) )
/*++ /*++
@ -822,7 +760,6 @@ BotStatusPhase (
Parameters: Parameters:
UsbBotDev - USB_BOT_DEVICE pointer UsbBotDev - USB_BOT_DEVICE pointer
TransferStatus - TransferStatus
Timeout - Time out value in milliseconds Timeout - Time out value in milliseconds
Return Value: Return Value:
EFI_SUCCESS EFI_SUCCESS
@ -832,47 +769,21 @@ BotStatusPhase (
{ {
CSW csw; CSW csw;
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Result;
EFI_USB_IO_PROTOCOL *UsbIo; EFI_USB_IO_PROTOCOL *UsbIo;
UINT8 EndpointAddr; UINT8 EndpointAddr;
UINTN DataSize; UINTN DataSize;
UINT32 Result;
UINT8 Index;
UsbIo = UsbBotDev->UsbIo; UsbIo = UsbBotDev->UsbIo;
EndpointAddr = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;
ZeroMem (&csw, sizeof (CSW));
EndpointAddr = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;
DataSize = sizeof (CSW);
//
// Get the status field from bulk transfer
//
Status = UsbIo->UsbBulkTransfer (
UsbIo,
EndpointAddr,
&csw,
&DataSize,
Timeout,
&Result
);
if (EFI_ERROR (Status)) {
if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
//
// just endpoint stall happens
//
UsbClearEndpointHalt (
UsbIo,
EndpointAddr,
&Result
);
}
for (Index = 0; Index < 3; Index ++) {
ZeroMem (&csw, sizeof (CSW)); ZeroMem (&csw, sizeof (CSW));
DataSize = sizeof (CSW);
Result = 0;
EndpointAddr = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;
DataSize = sizeof (CSW);
Status = UsbIo->UsbBulkTransfer ( Status = UsbIo->UsbBulkTransfer (
UsbIo, UsbIo,
EndpointAddr, EndpointAddr,
@ -883,25 +794,36 @@ BotStatusPhase (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) { if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
UsbClearEndpointHalt ( DEBUG((gBOTDebugLevel, "BOT: CSW Stall, ClearBulkInPipe\n"));
UsbIo, ClearBulkInPipe (UsbBotDev);
EndpointAddr, continue;
&Result }
); }
if (csw.dCSWSignature == CSWSIG) {
if (csw.bCSWStatus == 0 || csw.bCSWStatus == 0x01) {
if (DataResidue != NULL) {
*DataResidue = csw.dCSWDataResidue;
}
if (csw.bCSWStatus == 0x01) {
return EFI_DEVICE_ERROR;
}
break;
} else if (csw.bCSWStatus == 0x02) {
DEBUG((gBOTErrorLevel, "BOT: Bot Phase error\n"));
BotRecoveryReset (UsbBotDev);
} }
return Status;
} }
} }
if (csw.dCSWSignature == CSWSIG) { if (Index == 3) {
*TransferStatus = csw.bCSWStatus;
} else {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// Usb Atapi Protocol implementation // Usb Atapi Protocol implementation
// //
@ -938,81 +860,82 @@ BotAtapiCommand (
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS BotDataStatus; EFI_STATUS BotDataStatus;
UINT8 TransferStatus;
USB_BOT_DEVICE *UsbBotDev; USB_BOT_DEVICE *UsbBotDev;
UINT32 BufferSize; UINTN BufferSize;
UINT8 Index;
BotDataStatus = EFI_SUCCESS; UINT32 DataResidue;
TransferStatus = 0;
// //
// Get the context // Get the context
// //
UsbBotDev = USB_BOT_DEVICE_FROM_THIS (This); UsbBotDev = USB_BOT_DEVICE_FROM_THIS (This);
BotDataStatus = EFI_SUCCESS;
BufferSize = 0;
// for (Index = 0; Index < 3; Index ++) {
// First send ATAPI command through Bot
//
Status = BotCommandPhase (
UsbBotDev,
Command,
CommandSize,
BufferLength,
Direction,
TimeOutInMilliSeconds
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
//
// Send/Get Data if there is a Data Stage
//
switch (Direction) {
case EfiUsbDataIn:
case EfiUsbDataOut:
BufferSize = BufferLength;
BotDataStatus = BotDataPhase (
UsbBotDev,
&BufferSize,
DataBuffer,
Direction,
(UINT16) (TimeOutInMilliSeconds)
);
break;
case EfiUsbNoData:
break;
}
//
// Status Phase
//
Status = BotStatusPhase (
UsbBotDev,
&TransferStatus,
TimeOutInMilliSeconds
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
if (TransferStatus == 0x02) {
// //
// Phase error // First send ATAPI command through Bot
// //
BotRecoveryReset (UsbBotDev); Status = BotCommandPhase (
return EFI_DEVICE_ERROR; UsbBotDev,
} Command,
CommandSize,
BufferLength,
Direction,
10 * 1000
);
if (TransferStatus == 0x01) { if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; DEBUG((gBOTErrorLevel, "BotCommandPhase Fail\n"));
} return Status;
}
//
// Send/Get Data if there is a Data Stage
//
switch (Direction) {
case EfiUsbDataIn:
case EfiUsbDataOut:
BufferSize = BufferLength;
BotDataStatus = BotDataPhase (
UsbBotDev,
&BufferSize,
DataBuffer,
Direction,
(UINT16) (TimeOutInMilliSeconds)
);
if (EFI_ERROR (BotDataStatus)) {
DEBUG((gBOTErrorLevel, "BotDataPhase Fail\n"));
}
break;
case EfiUsbNoData:
break;
}
DataResidue = 0;
//
// Status Phase
//
Status = BotStatusPhase (
UsbBotDev,
&DataResidue,
10 * 1000
);
if (EFI_ERROR (Status)) {
DEBUG((gBOTErrorLevel, "BotStatusPhase Fail\n"));
return Status;
}
if (!EFI_ERROR (BotDataStatus)) {
break;
}
}
return BotDataStatus; return BotDataStatus;
} }

View File

@ -1,13 +1,13 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
@ -22,6 +22,9 @@ Abstract:
#include <IndustryStandard/Usb.h> #include <IndustryStandard/Usb.h>
extern UINT32 gBOTDebugLevel;
extern UINT32 gBOTErrorLevel;
#define MASS_STORAGE_CLASS 0x08
#pragma pack(1) #pragma pack(1)
// //

View File

@ -1,13 +1,13 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
@ -69,21 +69,21 @@ UsbMassStorageComponentNameGetDriverName (
Arguments: Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
Language - A pointer to a three character ISO 639-2 language identifier. Language - A pointer to a three character ISO 639-2 language identifier.
This is the language of the driver name that that the caller This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer. driver is up to the driver writer.
DriverName - A pointer to the Unicode string to return. This Unicode string DriverName - A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language is the name of the driver specified by This in the language
specified by Language. specified by Language.
Returns: Returns:
EFI_SUCCESS - The Unicode string for the Driver specified by This EFI_SUCCESS - The Unicode string for the Driver specified by This
and the language specified by Language was returned and the language specified by Language was returned
in DriverName. in DriverName.
EFI_INVALID_PARAMETER - Language is NULL. EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - DriverName is NULL. EFI_INVALID_PARAMETER - DriverName is NULL.
EFI_UNSUPPORTED - The driver specified by This does not support the EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language. language specified by Language.
--*/ --*/
@ -113,39 +113,39 @@ UsbMassStorageComponentNameGetControllerName (
Arguments: Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle - The handle of a controller that the driver specified by ControllerHandle - The handle of a controller that the driver specified by
This is managing. This handle specifies the controller This is managing. This handle specifies the controller
whose name is to be returned. whose name is to be returned.
ChildHandle - The handle of the child controller to retrieve the name ChildHandle - The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller. that wishes to retrieve the name of a child controller.
Language - A pointer to a three character ISO 639-2 language Language - A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name identifier. This is the language of the controller name
that that the caller is requesting, and it must match one that that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the number of languages supported by a driver is up to the
driver writer. driver writer.
ControllerName - A pointer to the Unicode string to return. This Unicode ControllerName - A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified ControllerHandle and ChildHandle in the language specified
by Language from the point of view of the driver specified by Language from the point of view of the driver specified
by This. by This.
Returns: Returns:
EFI_SUCCESS - The Unicode string for the user readable name in the EFI_SUCCESS - The Unicode string for the user readable name in the
language specified by Language for the driver language specified by Language for the driver
specified by This was returned in DriverName. specified by This was returned in DriverName.
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - Language is NULL. EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - ControllerName is NULL. EFI_INVALID_PARAMETER - ControllerName is NULL.
EFI_UNSUPPORTED - The driver specified by This is not currently managing EFI_UNSUPPORTED - The driver specified by This is not currently managing
the controller specified by ControllerHandle and the controller specified by ControllerHandle and
ChildHandle. ChildHandle.
EFI_UNSUPPORTED - The driver specified by This does not support the EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language. language specified by Language.
--*/ --*/

View File

@ -1,18 +1,18 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
UsbMassStorage.c UsbMassStorage.c
Abstract: Abstract:
USB Mass Storage Driver USB Mass Storage Driver
@ -192,11 +192,11 @@ USBFloppyDriverBindingStart (
EFI_OUT_OF_RESOURCES- Can't allocate memory resources EFI_OUT_OF_RESOURCES- Can't allocate memory resources
EFI_ALREADY_STARTED - Thios driver has been started EFI_ALREADY_STARTED - Thios driver has been started
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_USB_ATAPI_PROTOCOL *AtapiProtocol; EFI_USB_ATAPI_PROTOCOL *AtapiProtocol;
USB_FLOPPY_DEV *UsbFloppyDevice; USB_FLOPPY_DEV *UsbFloppyDevice;
UsbFloppyDevice = NULL; UsbFloppyDevice = NULL;
// //
// Check whether Usb Atapi Protocol attached on the controller handle. // Check whether Usb Atapi Protocol attached on the controller handle.
@ -311,7 +311,7 @@ USBFloppyDriverBindingStop (
EFI_DEVICE_ERROR EFI_DEVICE_ERROR
others others
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
USB_FLOPPY_DEV *UsbFloppyDevice; USB_FLOPPY_DEV *UsbFloppyDevice;
@ -373,17 +373,17 @@ USBFloppyReset (
Routine Description: Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.Reset() function. Implements EFI_BLOCK_IO_PROTOCOL.Reset() function.
Arguments: Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance. This The EFI_BLOCK_IO_PROTOCOL instance.
ExtendedVerification ExtendedVerification
Indicates that the driver may perform a more exhaustive Indicates that the driver may perform a more exhaustive
verification operation of the device during reset. verification operation of the device during reset.
(This parameter is ingored in this driver.) (This parameter is ingored in this driver.)
Returns: Returns:
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
USB_FLOPPY_DEV *UsbFloppyDevice; USB_FLOPPY_DEV *UsbFloppyDevice;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
@ -396,7 +396,7 @@ USBFloppyReset (
// //
// directly calling EFI_USB_ATAPI_PROTOCOL.Reset() to implement reset. // directly calling EFI_USB_ATAPI_PROTOCOL.Reset() to implement reset.
// //
Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, TRUE); Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, ExtendedVerification);
return Status; return Status;
} }
@ -415,26 +415,26 @@ USBFloppyReadBlocks (
Routine Description: Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks() function. Implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks() function.
Arguments: Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance. This The EFI_BLOCK_IO_PROTOCOL instance.
MediaId The media id that the read request is for. MediaId The media id that the read request is for.
LBA The starting logical block address to read from on the device. LBA The starting logical block address to read from on the device.
BufferSize BufferSize
The size of the Buffer in bytes. This must be a multiple of The size of the Buffer in bytes. This must be a multiple of
the intrinsic block size of the device. the intrinsic block size of the device.
Buffer A pointer to the destination buffer for the data. The caller Buffer A pointer to the destination buffer for the data. The caller
is responsible for either having implicit or explicit ownership is responsible for either having implicit or explicit ownership
of the buffer. of the buffer.
Returns: Returns:
EFI_INVALID_PARAMETER - Parameter is error EFI_INVALID_PARAMETER - Parameter is error
EFI_SUCCESS - Success EFI_SUCCESS - Success
EFI_DEVICE_ERROR - Hardware Error EFI_DEVICE_ERROR - Hardware Error
EFI_NO_MEDIA - No media EFI_NO_MEDIA - No media
EFI_MEDIA_CHANGED - Media Change EFI_MEDIA_CHANGED - Media Change
EFI_BAD_BUFFER_SIZE - Buffer size is bad EFI_BAD_BUFFER_SIZE - Buffer size is bad
--*/ --*/
{ {
USB_FLOPPY_DEV *UsbFloppyDevice; USB_FLOPPY_DEV *UsbFloppyDevice;
EFI_STATUS Status; EFI_STATUS Status;
@ -442,12 +442,9 @@ USBFloppyReadBlocks (
UINTN BlockSize; UINTN BlockSize;
UINTN NumberOfBlocks; UINTN NumberOfBlocks;
BOOLEAN MediaChange; BOOLEAN MediaChange;
EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
MediaChange = FALSE; MediaChange = FALSE;
UsbFloppyDevice = USB_FLOPPY_DEV_FROM_THIS (This); UsbFloppyDevice = USB_FLOPPY_DEV_FROM_THIS (This);
// //
@ -473,14 +470,12 @@ USBFloppyReadBlocks (
} }
if (MediaChange) { if (MediaChange) {
gBS->RestoreTPL (OldTpl);
gBS->ReinstallProtocolInterface ( gBS->ReinstallProtocolInterface (
UsbFloppyDevice->Handle, UsbFloppyDevice->Handle,
&gEfiBlockIoProtocolGuid, &gEfiBlockIoProtocolGuid,
&UsbFloppyDevice->BlkIo, &UsbFloppyDevice->BlkIo,
&UsbFloppyDevice->BlkIo &UsbFloppyDevice->BlkIo
); );
gBS->RaiseTPL (EFI_TPL_NOTIFY);
} }
Media = UsbFloppyDevice->BlkIo.Media; Media = UsbFloppyDevice->BlkIo.Media;
@ -517,33 +512,31 @@ USBFloppyReadBlocks (
goto Done; goto Done;
} }
if (!EFI_ERROR (Status)) { while (NumberOfBlocks > 0) {
Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, 1); if (NumberOfBlocks > BLOCK_UNIT) {
if (EFI_ERROR (Status)) { Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);
This->Reset (This, TRUE); } else {
Status = EFI_DEVICE_ERROR; Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
goto Done;
} }
LBA += 1;
NumberOfBlocks -= 1;
Buffer = (UINT8 *) Buffer + This->Media->BlockSize;
if (NumberOfBlocks == 0) {
Status = EFI_SUCCESS;
goto Done;
}
Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
This->Reset (This, TRUE); This->Reset (This, TRUE);
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
}
Done: if (NumberOfBlocks > BLOCK_UNIT) {
gBS->RestoreTPL (OldTpl); NumberOfBlocks -= BLOCK_UNIT;
LBA += BLOCK_UNIT;
Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;
} else {
NumberOfBlocks -= NumberOfBlocks;
LBA += NumberOfBlocks;
Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;
}
}
Done:
return Status; return Status;
} }
@ -561,29 +554,29 @@ USBFloppyWriteBlocks (
Routine Description: Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks() function. Implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks() function.
Arguments: Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance. This The EFI_BLOCK_IO_PROTOCOL instance.
MediaId The media id that the write request is for. MediaId The media id that the write request is for.
LBA The starting logical block address to be written. LBA The starting logical block address to be written.
The caller is responsible for writing to only The caller is responsible for writing to only
legitimate locations. legitimate locations.
BufferSize BufferSize
The size of the Buffer in bytes. This must be a multiple of The size of the Buffer in bytes. This must be a multiple of
the intrinsic block size of the device. the intrinsic block size of the device.
Buffer A pointer to the source buffer for the data. The caller Buffer A pointer to the source buffer for the data. The caller
is responsible for either having implicit or explicit ownership is responsible for either having implicit or explicit ownership
of the buffer. of the buffer.
Returns: Returns:
EFI_INVALID_PARAMETER - Parameter is error EFI_INVALID_PARAMETER - Parameter is error
EFI_SUCCESS - Success EFI_SUCCESS - Success
EFI_DEVICE_ERROR - Hardware Error EFI_DEVICE_ERROR - Hardware Error
EFI_NO_MEDIA - No media EFI_NO_MEDIA - No media
EFI_MEDIA_CHANGED - Media Change EFI_MEDIA_CHANGED - Media Change
EFI_BAD_BUFFER_SIZE - Buffer size is bad EFI_BAD_BUFFER_SIZE - Buffer size is bad
--*/ --*/
{ {
USB_FLOPPY_DEV *UsbFloppyDevice; USB_FLOPPY_DEV *UsbFloppyDevice;
EFI_STATUS Status; EFI_STATUS Status;
@ -591,9 +584,7 @@ USBFloppyWriteBlocks (
UINTN BlockSize; UINTN BlockSize;
UINTN NumberOfBlocks; UINTN NumberOfBlocks;
BOOLEAN MediaChange; BOOLEAN MediaChange;
EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
MediaChange = FALSE; MediaChange = FALSE;
@ -622,14 +613,12 @@ USBFloppyWriteBlocks (
} }
if (MediaChange) { if (MediaChange) {
gBS->RestoreTPL (OldTpl);
gBS->ReinstallProtocolInterface ( gBS->ReinstallProtocolInterface (
UsbFloppyDevice->Handle, UsbFloppyDevice->Handle,
&gEfiBlockIoProtocolGuid, &gEfiBlockIoProtocolGuid,
&UsbFloppyDevice->BlkIo, &UsbFloppyDevice->BlkIo,
&UsbFloppyDevice->BlkIo &UsbFloppyDevice->BlkIo
); );
gBS->RaiseTPL (EFI_TPL_NOTIFY);
} }
Media = UsbFloppyDevice->BlkIo.Media; Media = UsbFloppyDevice->BlkIo.Media;
@ -671,32 +660,32 @@ USBFloppyWriteBlocks (
goto Done; goto Done;
} }
if (!EFI_ERROR (Status)) { while (NumberOfBlocks > 0) {
Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, 1);
if (EFI_ERROR (Status)) { if (NumberOfBlocks > BLOCK_UNIT) {
This->Reset (This, TRUE); Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);
Status = EFI_DEVICE_ERROR; } else {
goto Done; Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
} }
LBA += 1;
NumberOfBlocks -= 1;
Buffer = (UINT8 *) Buffer + This->Media->BlockSize;
if (NumberOfBlocks == 0) {
Status = EFI_SUCCESS;
goto Done;
}
Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
This->Reset (This, TRUE); This->Reset (This, TRUE);
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
}
if (NumberOfBlocks > BLOCK_UNIT) {
NumberOfBlocks -= BLOCK_UNIT;
LBA += BLOCK_UNIT;
Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;
} else {
NumberOfBlocks -= NumberOfBlocks;
LBA += NumberOfBlocks;
Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;
}
}
Done: Done:
gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
@ -711,13 +700,13 @@ USBFloppyFlushBlocks (
Routine Description: Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks() function. Implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks() function.
(In this driver, this function just returns EFI_SUCCESS.) (In this driver, this function just returns EFI_SUCCESS.)
Arguments: Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance. This The EFI_BLOCK_IO_PROTOCOL instance.
Returns: Returns:
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -1,12 +1,12 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
@ -37,6 +37,8 @@ Revision History
#define USBFLOPPY2 2 // for those that use ReadFormatCapacity(0x23) command to retrieve media capacity #define USBFLOPPY2 2 // for those that use ReadFormatCapacity(0x23) command to retrieve media capacity
#define USBCDROM 3 #define USBCDROM 3
#define BLOCK_UNIT 128
#define USB_FLOPPY_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'f', 'l', 'p') #define USB_FLOPPY_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'f', 'l', 'p')
typedef struct { typedef struct {
@ -50,7 +52,6 @@ typedef struct {
REQUEST_SENSE_DATA *SenseData; REQUEST_SENSE_DATA *SenseData;
UINT8 SenseDataNumber; UINT8 SenseDataNumber;
UINT8 DeviceType; UINT8 DeviceType;
} USB_FLOPPY_DEV; } USB_FLOPPY_DEV;
#define USB_FLOPPY_DEV_FROM_THIS(a) \ #define USB_FLOPPY_DEV_FROM_THIS(a) \

View File

@ -1,12 +1,12 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
@ -30,7 +30,7 @@ Revision History
// //
// timeout unit is in millisecond. // timeout unit is in millisecond.
// //
#define USBFLPTIMEOUT 2000 #define USBFLPTIMEOUT 1000
#define STALL_1_MILLI_SECOND 1000 #define STALL_1_MILLI_SECOND 1000
// //

View File

@ -1,18 +1,18 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
UsbMassStorageHelper.c UsbMassStorageHelper.c
Abstract: Abstract:
Helper functions for USB Mass Storage Driver Helper functions for USB Mass Storage Driver
@ -80,19 +80,19 @@ USBFloppyPacketCommand (
Routine Description: Routine Description:
Sends Packet Command to USB Floppy Drive. Sends Packet Command to USB Floppy Drive.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Command - A pointer to the command packet. Command - A pointer to the command packet.
CommandSize - Indicates the size of the command packet. CommandSize - Indicates the size of the command packet.
DataBuffer - A pointer to the buffer for the data transfer DataBuffer - A pointer to the buffer for the data transfer
after the command packet. after the command packet.
BufferLength - Indicates the size of the Data Buffer. BufferLength - Indicates the size of the Data Buffer.
Direction - Transfer Direction Direction - Transfer Direction
TimeOutInMilliSeconds - Timeout Value TimeOutInMilliSeconds - Timeout Value
Returns: Returns:
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
EFI_STATUS Status; EFI_STATUS Status;
@ -123,14 +123,14 @@ USBFloppyIdentify (
Routine Description: Routine Description:
Retrieves device information to tell the device type. Retrieves device information to tell the device type.
Arguments: Arguments:
UsbFloppyDevice The USB_FLOPPY_DEV instance. UsbFloppyDevice The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -144,7 +144,7 @@ USBFloppyIdentify (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Get media removable info from INQUIRY data. // Get media removable info from INQUIRY data.
// //
@ -201,7 +201,7 @@ USBFloppyIdentify (
gBS->FreePool (Idata); gBS->FreePool (Idata);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Get media information. // Get media information.
// //
@ -221,16 +221,16 @@ USBFloppyInquiry (
Routine Description: Routine Description:
Send Inquiry Packet Command to device and retrieve Inquiry Data. Send Inquiry Packet Command to device and retrieve Inquiry Data.
Arguments: Arguments:
UsbFloppyDevice The USB_FLOPPY_DEV instance. UsbFloppyDevice The USB_FLOPPY_DEV instance.
Idata A pointer pointing to the address of Idata A pointer pointing to the address of
Inquiry Data. Inquiry Data.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
ATAPI_PACKET_COMMAND Packet; ATAPI_PACKET_COMMAND Packet;
EFI_STATUS Status; EFI_STATUS Status;
@ -272,31 +272,31 @@ USBFloppyInquiry (
EFI_STATUS EFI_STATUS
USBFloppyRead10 ( USBFloppyRead10 (
IN USB_FLOPPY_DEV *UsbFloppyDevice, IN USB_FLOPPY_DEV *UsbFloppyDevice,
IN VOID *Buffer, IN VOID *Buffer,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN NumberOfBlocks IN UINTN NumberOfBlocks
) )
/*++ /*++
Routine Description: Routine Description:
Sends Read10 Packet Command to device to perform data transfer Sends Read10 Packet Command to device to perform data transfer
from device to host. from device to host.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Buffer - A pointer to the destination buffer for the data. Buffer - A pointer to the destination buffer for the data.
The caller is responsible for either having implicit The caller is responsible for either having implicit
or explicit ownership of the buffer. or explicit ownership of the buffer.
Lba - The starting logical block address to read from Lba - The starting logical block address to read from
on the device. on the device.
NumberOfBlocks - Indicates the number of blocks that the read NumberOfBlocks - Indicates the number of blocks that the read
operation requests. operation requests.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
ATAPI_PACKET_COMMAND Packet; ATAPI_PACKET_COMMAND Packet;
READ10_CMD *Read10Packet; READ10_CMD *Read10Packet;
@ -310,7 +310,7 @@ USBFloppyRead10 (
EFI_STATUS Status; EFI_STATUS Status;
UINT16 TimeOut; UINT16 TimeOut;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
UINTN SenseCounts; UINT8 Index;
UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;
@ -333,78 +333,52 @@ USBFloppyRead10 (
} else { } else {
SectorCount = MaxBlock; SectorCount = MaxBlock;
} }
//
// fill the Packet data structure
//
Read10Packet->opcode = READ_10;
// for (Index = 0; Index < 3; Index ++) {
// Lba0 ~ Lba3 specify the start logical block address of the data transfer.
// Lba0 is MSB, Lba3 is LSB
//
Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
//
// TranLen0 ~ TranLen1 specify the transfer length in block unit.
// TranLen0 is MSB, TranLen is LSB
//
Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
ByteCount = SectorCount * BlockSize;
TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
Status = USBFloppyPacketCommand (
UsbFloppyDevice,
&Packet,
sizeof (ATAPI_PACKET_COMMAND),
(VOID *) ptrBuffer,
ByteCount,
EfiUsbDataIn,
TimeOut
);
if (EFI_ERROR (Status)) {
Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);
if (!EFI_ERROR (Status)) {
if (IsLogicalUnitCommunicationOverRun (
UsbFloppyDevice->SenseData,
SenseCounts
)) {
Lba32 = (UINT32) Lba;
ptrBuffer = Buffer;
BlocksRemaining = (UINT16) NumberOfBlocks;
MaxBlock = (UINT16) (MaxBlock / 4);
if (MaxBlock < 1) {
MaxBlock = 1;
}
continue;
}
} else {
return EFI_DEVICE_ERROR;
}
// //
// retry read10 command // fill the Packet data structure
// //
Read10Packet->opcode = READ_10;
//
// Lba0 ~ Lba3 specify the start logical block address of the data transfer.
// Lba0 is MSB, Lba3 is LSB
//
Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
//
// TranLen0 ~ TranLen1 specify the transfer length in block unit.
// TranLen0 is MSB, TranLen is LSB
//
Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
ByteCount = SectorCount * BlockSize;
TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
Status = USBFloppyPacketCommand ( Status = USBFloppyPacketCommand (
UsbFloppyDevice, UsbFloppyDevice,
&Packet, &Packet,
sizeof (ATAPI_PACKET_COMMAND), sizeof (ATAPI_PACKET_COMMAND),
(VOID *) ptrBuffer, (VOID *) ptrBuffer,
ByteCount, ByteCount,
EfiUsbDataIn, EfiUsbDataIn,
TimeOut TimeOut
); );
if (EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; break;
} }
} }
if (Index == 3) {
return EFI_DEVICE_ERROR;
}
Lba32 += SectorCount; Lba32 += SectorCount;
ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize; ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize;
BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount); BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);
@ -420,17 +394,17 @@ USBFloppyReadCapacity (
/*++ /*++
Routine Description: Routine Description:
Retrieves media capacity information via Retrieves media capacity information via
sending Read Capacity Packet Command. sending Read Capacity Packet Command.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
// //
// status returned by Read Capacity Packet Command // status returned by Read Capacity Packet Command
// //
@ -483,17 +457,17 @@ USBFloppyReadFormatCapacity (
/*++ /*++
Routine Description: Routine Description:
Retrieves media capacity information via sending Read Format Retrieves media capacity information via sending Read Format
Capacity Packet Command. Capacity Packet Command.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
// //
// status returned by Read Capacity Packet Command // status returned by Read Capacity Packet Command
// //
@ -537,7 +511,7 @@ USBFloppyReadFormatCapacity (
} else { } else {
UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) | UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) |
(FormatData.LastLba2 << 16) | (FormatData.LastLba2 << 16) |
(FormatData.LastLba1 << 8) | (FormatData.LastLba1 << 8) |
FormatData.LastLba0; FormatData.LastLba0;
@ -565,17 +539,17 @@ UsbFloppyRequestSense (
/*++ /*++
Routine Description: Routine Description:
Retrieves Sense Data from device via Retrieves Sense Data from device via
sending Request Sense Packet Command. sending Request Sense Packet Command.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
SenseCounts - A pointer to the number of Sense Data returned. SenseCounts - A pointer to the number of Sense Data returned.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
REQUEST_SENSE_DATA *Sense; REQUEST_SENSE_DATA *Sense;
@ -598,7 +572,7 @@ UsbFloppyRequestSense (
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND)); ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
Packet.RequestSense.opcode = REQUEST_SENSE; Packet.RequestSense.opcode = REQUEST_SENSE;
Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA); Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA);
// //
// initialize pointer // initialize pointer
// //
@ -666,7 +640,7 @@ UsbFloppyRequestSense (
// //
SenseReq = FALSE; SenseReq = FALSE;
} }
// //
// If the sense key numbers exceed Sense Data Buffer size, // If the sense key numbers exceed Sense Data Buffer size,
// just skip the loop and do not fetch the sense key in this function. // just skip the loop and do not fetch the sense key in this function.
@ -687,25 +661,25 @@ UsbFloppyTestUnitReady (
Routine Description: Routine Description:
Sends Test Unit ReadyPacket Command to the device. Sends Test Unit ReadyPacket Command to the device.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
ATAPI_PACKET_COMMAND Packet; ATAPI_PACKET_COMMAND Packet;
EFI_STATUS Status; EFI_STATUS Status;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
UINT32 RetryIndex; UINT32 RetryIndex;
UINT32 MaximumRetryTimes; UINT32 MaximumRetryTimes;
UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;
MaximumRetryTimes = 2; MaximumRetryTimes = 2;
// //
// fill command packet // fill command packet
// //
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND)); ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
Packet.TestUnitReady.opcode = TEST_UNIT_READY; Packet.TestUnitReady.opcode = TEST_UNIT_READY;
@ -737,31 +711,31 @@ UsbFloppyTestUnitReady (
EFI_STATUS EFI_STATUS
USBFloppyWrite10 ( USBFloppyWrite10 (
IN USB_FLOPPY_DEV *UsbFloppyDevice, IN USB_FLOPPY_DEV *UsbFloppyDevice,
IN VOID *Buffer, IN VOID *Buffer,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN NumberOfBlocks IN UINTN NumberOfBlocks
) )
/*++ /*++
Routine Description: Routine Description:
Sends Write10 Packet Command to device to perform data transfer Sends Write10 Packet Command to device to perform data transfer
from host to device. from host to device.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Buffer - A pointer to the source buffer for the data. Buffer - A pointer to the source buffer for the data.
The caller is responsible for either having implicit The caller is responsible for either having implicit
or explicit ownership of the buffer. or explicit ownership of the buffer.
Lba - The starting logical block address to written to Lba - The starting logical block address to written to
the device. the device.
NumberOfBlocks - Indicates the number of blocks that the write NumberOfBlocks - Indicates the number of blocks that the write
operation requests. operation requests.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
ATAPI_PACKET_COMMAND Packet; ATAPI_PACKET_COMMAND Packet;
READ10_CMD *Write10Packet; READ10_CMD *Write10Packet;
@ -775,7 +749,7 @@ USBFloppyWrite10 (
EFI_STATUS Status; EFI_STATUS Status;
UINT16 TimeOut; UINT16 TimeOut;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
UINTN SenseCounts; UINT8 Index;
UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;
@ -795,82 +769,56 @@ USBFloppyWrite10 (
while (BlocksRemaining > 0) { while (BlocksRemaining > 0) {
if (BlocksRemaining <= MaxBlock) { if (BlocksRemaining <= MaxBlock) {
SectorCount = BlocksRemaining; SectorCount = BlocksRemaining;
} else { } else {
SectorCount = MaxBlock; SectorCount = MaxBlock;
} }
//
// fill the Packet data structure
//
Write10Packet->opcode = WRITE_10;
// for (Index = 0; Index < 3; Index ++) {
// Lba0 ~ Lba3 specify the start logical block address
// of the data transfer.
// Lba0 is MSB, Lba3 is LSB
//
Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);
Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);
Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);
//
// TranLen0 ~ TranLen1 specify the transfer length in block unit.
// TranLen0 is MSB, TranLen is LSB
//
Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
ByteCount = SectorCount * BlockSize;
TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
Status = USBFloppyPacketCommand (
UsbFloppyDevice,
&Packet,
sizeof (ATAPI_PACKET_COMMAND),
(VOID *) ptrBuffer,
ByteCount,
EfiUsbDataOut,
TimeOut
);
if (EFI_ERROR (Status)) {
Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);
if (!EFI_ERROR (Status)) {
if (IsLogicalUnitCommunicationOverRun (
UsbFloppyDevice->SenseData,
SenseCounts
)) {
Lba32 = (UINT32) Lba;
ptrBuffer = Buffer;
BlocksRemaining = (UINT16) NumberOfBlocks;
MaxBlock = (UINT16) (MaxBlock / 4);
if (MaxBlock < 1) {
MaxBlock = 1;
}
continue;
}
}
// //
// retry write10 command // fill the Packet data structure
// //
Write10Packet->opcode = WRITE_10;
//
// Lba0 ~ Lba3 specify the start logical block address
// of the data transfer.
// Lba0 is MSB, Lba3 is LSB
//
Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);
Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);
Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);
//
// TranLen0 ~ TranLen1 specify the transfer length in block unit.
// TranLen0 is MSB, TranLen is LSB
//
Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
ByteCount = SectorCount * BlockSize;
TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
Status = USBFloppyPacketCommand ( Status = USBFloppyPacketCommand (
UsbFloppyDevice, UsbFloppyDevice,
&Packet, &Packet,
sizeof (ATAPI_PACKET_COMMAND), sizeof (ATAPI_PACKET_COMMAND),
(VOID *) ptrBuffer, (VOID *) ptrBuffer,
ByteCount, ByteCount,
EfiUsbDataOut, EfiUsbDataOut,
TimeOut TimeOut
); );
if (EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; break;
} }
} }
if (Index == 3) {
return EFI_DEVICE_ERROR;
}
Lba32 += SectorCount; Lba32 += SectorCount;
ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize; ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize;
BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount); BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);
@ -888,16 +836,16 @@ UsbFloppyDetectMedia (
Routine Description: Routine Description:
Retrieves media information. Retrieves media information.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
MediaChange - Indicates whether media was changed. MediaChange - Indicates whether media was changed.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
EFI_INVALID_PARAMETER - Parameter is error EFI_INVALID_PARAMETER - Parameter is error
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS FloppyStatus; EFI_STATUS FloppyStatus;
@ -910,11 +858,10 @@ UsbFloppyDetectMedia (
UINTN RetryTimes; UINTN RetryTimes;
UINTN MaximumRetryTimes; UINTN MaximumRetryTimes;
BOOLEAN NeedRetry; BOOLEAN NeedRetry;
BOOLEAN NeedReadCapacity;
// //
// a flag used to determine whether need to perform Read Capacity command. // a flag used to determine whether need to perform Read Capacity command.
// //
BOOLEAN NeedReadCapacity;
REQUEST_SENSE_DATA *SensePtr; REQUEST_SENSE_DATA *SensePtr;
@ -955,14 +902,14 @@ UsbFloppyDetectMedia (
if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) { if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) {
UsbFloppyDevice->BlkIo.Media->MediaId++; UsbFloppyDevice->BlkIo.Media->MediaId++;
} }
// //
// Media Write-protected // Media Write-protected
// //
if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) { if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) {
UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE; UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE;
} }
// //
// Media Error // Media Error
// //
@ -1078,7 +1025,7 @@ UsbFloppyDetectMedia (
} }
if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) { if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) {
// //
// Drive not ready: if NeedRetry, then retry once more; // Drive not ready: if NeedRetry, then retry once more;
// else return error // else return error
@ -1160,18 +1107,18 @@ UsbFloppyModeSense5APage5 (
/*++ /*++
Routine Description: Routine Description:
Retrieves media capacity information via sending Read Format Retrieves media capacity information via sending Read Format
Capacity Packet Command. Capacity Packet Command.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
// //
// status returned by Read Capacity Packet Command // status returned by Read Capacity Packet Command
// //
@ -1246,18 +1193,18 @@ UsbFloppyModeSense5APage1C (
/*++ /*++
Routine Description: Routine Description:
Retrieves media capacity information via sending Read Format Retrieves media capacity information via sending Read Format
Capacity Packet Command. Capacity Packet Command.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
// //
// status returned by Read Capacity Packet Command // status returned by Read Capacity Packet Command
// //
@ -1323,16 +1270,16 @@ UsbFloppyModeSense5APage3F (
Routine Description: Routine Description:
Retrieves mode sense information via sending Mode Sense Retrieves mode sense information via sending Mode Sense
Packet Command. Packet Command.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
// //
// status returned by Read Capacity Packet Command // status returned by Read Capacity Packet Command
// //
@ -1381,16 +1328,16 @@ UsbSCSIModeSense1APage3F (
Routine Description: Routine Description:
Retrieves mode sense information via sending Mode Sense Retrieves mode sense information via sending Mode Sense
Packet Command. Packet Command.
Arguments: Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance. UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Returns: Returns:
EFI_DEVICE_ERROR - Hardware error EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success EFI_SUCCESS - Success
--*/ --*/
{ {
// //
// status returned by Read Capacity Packet Command // status returned by Read Capacity Packet Command
// //
@ -1450,7 +1397,7 @@ IsNoMedia (
for (Index = 0; Index < SenseCounts; Index++) { for (Index = 0; Index < SenseCounts; Index++) {
if ((SensePtr->sense_key == SK_NOT_READY) && if ((SensePtr->sense_key == SK_NOT_READY) &&
(SensePtr->addnl_sense_code == ASC_NO_MEDIA)) { (SensePtr->addnl_sense_code == ASC_NO_MEDIA)) {
NoMedia = TRUE; NoMedia = TRUE;
@ -1479,7 +1426,7 @@ IsMediaError (
for (Index = 0; Index < SenseCounts; Index++) { for (Index = 0; Index < SenseCounts; Index++) {
switch (SensePtr->sense_key) { switch (SensePtr->sense_key) {
// //
// Medium error case // Medium error case
// //

View File

@ -1,12 +1,12 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name: