summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c')
-rw-r--r--MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c142
1 files changed, 69 insertions, 73 deletions
diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c
index 19a0afcb6d..6778254b61 100644
--- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c
+++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c
@@ -18,25 +18,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EMMC_PEIM_MEM_BLOCK *
EmmcPeimAllocMemBlock (
- IN UINTN Pages
+ IN UINTN Pages
)
{
- EMMC_PEIM_MEM_BLOCK *Block;
- VOID *BufHost;
- VOID *Mapping;
- EFI_PHYSICAL_ADDRESS MappedAddr;
- EFI_STATUS Status;
- VOID *TempPtr;
+ EMMC_PEIM_MEM_BLOCK *Block;
+ VOID *BufHost;
+ VOID *Mapping;
+ EFI_PHYSICAL_ADDRESS MappedAddr;
+ EFI_STATUS Status;
+ VOID *TempPtr;
TempPtr = NULL;
Block = NULL;
- Status = PeiServicesAllocatePool (sizeof(EMMC_PEIM_MEM_BLOCK), &TempPtr);
+ Status = PeiServicesAllocatePool (sizeof (EMMC_PEIM_MEM_BLOCK), &TempPtr);
if (EFI_ERROR (Status)) {
return NULL;
}
- ZeroMem ((VOID*)(UINTN)TempPtr, sizeof(EMMC_PEIM_MEM_BLOCK));
+ ZeroMem ((VOID *)(UINTN)TempPtr, sizeof (EMMC_PEIM_MEM_BLOCK));
//
// each bit in the bit array represents EMMC_PEIM_MEM_UNIT
@@ -44,18 +44,18 @@ EmmcPeimAllocMemBlock (
//
ASSERT (EMMC_PEIM_MEM_UNIT * 8 <= EFI_PAGE_SIZE);
- Block = (EMMC_PEIM_MEM_BLOCK*)(UINTN)TempPtr;
- Block->BufLen = EFI_PAGES_TO_SIZE (Pages);
- Block->BitsLen = Block->BufLen / (EMMC_PEIM_MEM_UNIT * 8);
+ Block = (EMMC_PEIM_MEM_BLOCK *)(UINTN)TempPtr;
+ Block->BufLen = EFI_PAGES_TO_SIZE (Pages);
+ Block->BitsLen = Block->BufLen / (EMMC_PEIM_MEM_UNIT * 8);
Status = PeiServicesAllocatePool (Block->BitsLen, &TempPtr);
if (EFI_ERROR (Status)) {
return NULL;
}
- ZeroMem ((VOID*)(UINTN)TempPtr, Block->BitsLen);
+ ZeroMem ((VOID *)(UINTN)TempPtr, Block->BitsLen);
- Block->Bits = (UINT8*)(UINTN)TempPtr;
+ Block->Bits = (UINT8 *)(UINTN)TempPtr;
Status = IoMmuAllocateBuffer (
Pages,
@@ -67,10 +67,10 @@ EmmcPeimAllocMemBlock (
return NULL;
}
- ZeroMem ((VOID*)(UINTN)BufHost, EFI_PAGES_TO_SIZE (Pages));
+ ZeroMem ((VOID *)(UINTN)BufHost, EFI_PAGES_TO_SIZE (Pages));
- Block->BufHost = (UINT8 *) (UINTN) BufHost;
- Block->Buf = (UINT8 *) (UINTN) MappedAddr;
+ Block->BufHost = (UINT8 *)(UINTN)BufHost;
+ Block->Buf = (UINT8 *)(UINTN)MappedAddr;
Block->Mapping = Mapping;
Block->Next = NULL;
@@ -86,8 +86,8 @@ EmmcPeimAllocMemBlock (
**/
VOID
EmmcPeimFreeMemBlock (
- IN EMMC_PEIM_MEM_POOL *Pool,
- IN EMMC_PEIM_MEM_BLOCK *Block
+ IN EMMC_PEIM_MEM_POOL *Pool,
+ IN EMMC_PEIM_MEM_BLOCK *Block
)
{
ASSERT ((Pool != NULL) && (Block != NULL));
@@ -107,22 +107,22 @@ EmmcPeimFreeMemBlock (
**/
VOID *
EmmcPeimAllocMemFromBlock (
- IN EMMC_PEIM_MEM_BLOCK *Block,
- IN UINTN Units
+ IN EMMC_PEIM_MEM_BLOCK *Block,
+ IN UINTN Units
)
{
- UINTN Byte;
- UINT8 Bit;
- UINTN StartByte;
- UINT8 StartBit;
- UINTN Available;
- UINTN Count;
+ UINTN Byte;
+ UINT8 Bit;
+ UINTN StartByte;
+ UINT8 StartBit;
+ UINTN Available;
+ UINTN Count;
ASSERT ((Block != 0) && (Units != 0));
- StartByte = 0;
- StartBit = 0;
- Available = 0;
+ StartByte = 0;
+ StartBit = 0;
+ Available = 0;
for (Byte = 0, Bit = 0; Byte < Block->BitsLen;) {
//
@@ -138,13 +138,12 @@ EmmcPeimAllocMemFromBlock (
}
EMMC_PEIM_NEXT_BIT (Byte, Bit);
-
} else {
EMMC_PEIM_NEXT_BIT (Byte, Bit);
- Available = 0;
- StartByte = Byte;
- StartBit = Bit;
+ Available = 0;
+ StartByte = Byte;
+ StartBit = Bit;
}
}
@@ -155,13 +154,13 @@ EmmcPeimAllocMemFromBlock (
//
// Mark the memory as allocated
//
- Byte = StartByte;
- Bit = StartBit;
+ Byte = StartByte;
+ Bit = StartBit;
for (Count = 0; Count < Units; Count++) {
ASSERT (!EMMC_PEIM_MEM_BIT_IS_SET (Block->Bits[Byte], Bit));
- Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] | (UINT8) EMMC_PEIM_MEM_BIT (Bit));
+ Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] | (UINT8)EMMC_PEIM_MEM_BIT (Bit));
EMMC_PEIM_NEXT_BIT (Byte, Bit);
}
@@ -177,8 +176,8 @@ EmmcPeimAllocMemFromBlock (
**/
VOID
EmmcPeimInsertMemBlockToPool (
- IN EMMC_PEIM_MEM_BLOCK *Head,
- IN EMMC_PEIM_MEM_BLOCK *Block
+ IN EMMC_PEIM_MEM_BLOCK *Head,
+ IN EMMC_PEIM_MEM_BLOCK *Block
)
{
ASSERT ((Head != NULL) && (Block != NULL));
@@ -197,11 +196,10 @@ EmmcPeimInsertMemBlockToPool (
**/
BOOLEAN
EmmcPeimIsMemBlockEmpty (
- IN EMMC_PEIM_MEM_BLOCK *Block
+ IN EMMC_PEIM_MEM_BLOCK *Block
)
{
- UINTN Index;
-
+ UINTN Index;
for (Index = 0; Index < Block->BitsLen; Index++) {
if (Block->Bits[Index] != 0) {
@@ -212,8 +210,6 @@ EmmcPeimIsMemBlockEmpty (
return TRUE;
}
-
-
/**
Initialize the memory management pool for the host controller.
@@ -228,9 +224,9 @@ EmmcPeimInitMemPool (
IN EMMC_PEIM_HC_PRIVATE_DATA *Private
)
{
- EMMC_PEIM_MEM_POOL *Pool;
- EFI_STATUS Status;
- VOID *TempPtr;
+ EMMC_PEIM_MEM_POOL *Pool;
+ EFI_STATUS Status;
+ VOID *TempPtr;
TempPtr = NULL;
Pool = NULL;
@@ -240,7 +236,7 @@ EmmcPeimInitMemPool (
return EFI_OUT_OF_RESOURCES;
}
- ZeroMem ((VOID*)(UINTN)TempPtr, sizeof (EMMC_PEIM_MEM_POOL));
+ ZeroMem ((VOID *)(UINTN)TempPtr, sizeof (EMMC_PEIM_MEM_POOL));
Pool = (EMMC_PEIM_MEM_POOL *)((UINTN)TempPtr);
@@ -265,10 +261,10 @@ EmmcPeimInitMemPool (
**/
EFI_STATUS
EmmcPeimFreeMemPool (
- IN EMMC_PEIM_MEM_POOL *Pool
+ IN EMMC_PEIM_MEM_POOL *Pool
)
{
- EMMC_PEIM_MEM_BLOCK *Block;
+ EMMC_PEIM_MEM_BLOCK *Block;
ASSERT (Pool->Head != NULL);
@@ -296,16 +292,16 @@ EmmcPeimFreeMemPool (
**/
VOID *
EmmcPeimAllocateMem (
- IN EMMC_PEIM_MEM_POOL *Pool,
- IN UINTN Size
+ IN EMMC_PEIM_MEM_POOL *Pool,
+ IN UINTN Size
)
{
- EMMC_PEIM_MEM_BLOCK *Head;
- EMMC_PEIM_MEM_BLOCK *Block;
- EMMC_PEIM_MEM_BLOCK *NewBlock;
- VOID *Mem;
- UINTN AllocSize;
- UINTN Pages;
+ EMMC_PEIM_MEM_BLOCK *Head;
+ EMMC_PEIM_MEM_BLOCK *Block;
+ EMMC_PEIM_MEM_BLOCK *NewBlock;
+ VOID *Mem;
+ UINTN AllocSize;
+ UINTN Pages;
Mem = NULL;
AllocSize = EMMC_PEIM_MEM_ROUND (Size);
@@ -368,22 +364,22 @@ EmmcPeimAllocateMem (
**/
VOID
EmmcPeimFreeMem (
- IN EMMC_PEIM_MEM_POOL *Pool,
- IN VOID *Mem,
- IN UINTN Size
+ IN EMMC_PEIM_MEM_POOL *Pool,
+ IN VOID *Mem,
+ IN UINTN Size
)
{
- EMMC_PEIM_MEM_BLOCK *Head;
- EMMC_PEIM_MEM_BLOCK *Block;
- UINT8 *ToFree;
- UINTN AllocSize;
- UINTN Byte;
- UINTN Bit;
- UINTN Count;
+ EMMC_PEIM_MEM_BLOCK *Head;
+ EMMC_PEIM_MEM_BLOCK *Block;
+ UINT8 *ToFree;
+ UINTN AllocSize;
+ UINTN Byte;
+ UINTN Bit;
+ UINTN Count;
Head = Pool->Head;
AllocSize = EMMC_PEIM_MEM_ROUND (Size);
- ToFree = (UINT8 *) Mem;
+ ToFree = (UINT8 *)Mem;
for (Block = Head; Block != NULL; Block = Block->Next) {
//
@@ -394,8 +390,8 @@ EmmcPeimFreeMem (
//
// compute the start byte and bit in the bit array
//
- Byte = ((ToFree - Block->Buf) / EMMC_PEIM_MEM_UNIT) / 8;
- Bit = ((ToFree - Block->Buf) / EMMC_PEIM_MEM_UNIT) % 8;
+ Byte = ((ToFree - Block->Buf) / EMMC_PEIM_MEM_UNIT) / 8;
+ Bit = ((ToFree - Block->Buf) / EMMC_PEIM_MEM_UNIT) % 8;
//
// reset associated bits in bit array
@@ -403,7 +399,7 @@ EmmcPeimFreeMem (
for (Count = 0; Count < (AllocSize / EMMC_PEIM_MEM_UNIT); Count++) {
ASSERT (EMMC_PEIM_MEM_BIT_IS_SET (Block->Bits[Byte], Bit));
- Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] ^ EMMC_PEIM_MEM_BIT (Bit));
+ Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] ^ EMMC_PEIM_MEM_BIT (Bit));
EMMC_PEIM_NEXT_BIT (Byte, Bit);
}
@@ -425,5 +421,5 @@ EmmcPeimFreeMem (
EmmcPeimFreeMemBlock (Pool, Block);
}
- return ;
+ return;
}