3 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _SD_PEIM_MEM_H_
10 #define _SD_PEIM_MEM_H_
12 #define SD_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))
14 #define SD_PEIM_MEM_BIT_IS_SET(Data, Bit) \
15 ((BOOLEAN)(((Data) & SD_PEIM_MEM_BIT(Bit)) == SD_PEIM_MEM_BIT(Bit)))
17 typedef struct _SD_PEIM_MEM_BLOCK SD_PEIM_MEM_BLOCK
;
19 struct _SD_PEIM_MEM_BLOCK
{
20 UINT8
*Bits
; // Bit array to record which unit is allocated
24 UINTN BufLen
; // Memory size in bytes
26 SD_PEIM_MEM_BLOCK
*Next
;
29 typedef struct _SD_PEIM_MEM_POOL
{
30 SD_PEIM_MEM_BLOCK
*Head
;
34 // Memory allocation unit, note that the value must meet SD spec alignment requirement.
36 #define SD_PEIM_MEM_UNIT 128
38 #define SD_PEIM_MEM_UNIT_MASK (SD_PEIM_MEM_UNIT - 1)
39 #define SD_PEIM_MEM_DEFAULT_PAGES 16
41 #define SD_PEIM_MEM_ROUND(Len) (((Len) + SD_PEIM_MEM_UNIT_MASK) & (~SD_PEIM_MEM_UNIT_MASK))
44 // Advance the byte and bit to the next bit, adjust byte accordingly.
46 #define SD_PEIM_NEXT_BIT(Byte, Bit) \