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

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