3 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The
8 full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _SD_PEIM_MEM_H_
17 #define _SD_PEIM_MEM_H_
19 #define SD_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))
21 #define SD_PEIM_MEM_BIT_IS_SET(Data, Bit) \
22 ((BOOLEAN)(((Data) & SD_PEIM_MEM_BIT(Bit)) == SD_PEIM_MEM_BIT(Bit)))
24 typedef struct _SD_PEIM_MEM_BLOCK SD_PEIM_MEM_BLOCK
;
26 struct _SD_PEIM_MEM_BLOCK
{
27 UINT8
*Bits
; // Bit array to record which unit is allocated
30 UINTN BufLen
; // Memory size in bytes
31 SD_PEIM_MEM_BLOCK
*Next
;
34 typedef struct _SD_PEIM_MEM_POOL
{
35 SD_PEIM_MEM_BLOCK
*Head
;
39 // Memory allocation unit, note that the value must meet SD spec alignment requirement.
41 #define SD_PEIM_MEM_UNIT 128
43 #define SD_PEIM_MEM_UNIT_MASK (SD_PEIM_MEM_UNIT - 1)
44 #define SD_PEIM_MEM_DEFAULT_PAGES 16
46 #define SD_PEIM_MEM_ROUND(Len) (((Len) + SD_PEIM_MEM_UNIT_MASK) & (~SD_PEIM_MEM_UNIT_MASK))
49 // Advance the byte and bit to the next bit, adjust byte accordingly.
51 #define SD_PEIM_NEXT_BIT(Byte, Bit) \