]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Sd / EmmcBlockIoPei / EmmcHcMem.h
1 /** @file
2
3 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _EMMC_PEIM_MEM_H_
10 #define _EMMC_PEIM_MEM_H_
11
12 #define EMMC_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))
13
14 #define EMMC_PEIM_MEM_BIT_IS_SET(Data, Bit) \
15 ((BOOLEAN)(((Data) & EMMC_PEIM_MEM_BIT(Bit)) == EMMC_PEIM_MEM_BIT(Bit)))
16
17 typedef struct _EMMC_PEIM_MEM_BLOCK EMMC_PEIM_MEM_BLOCK;
18
19 struct _EMMC_PEIM_MEM_BLOCK {
20 UINT8 *Bits; // Bit array to record which unit is allocated
21 UINTN BitsLen;
22 UINT8 *Buf;
23 UINT8 *BufHost;
24 UINTN BufLen; // Memory size in bytes
25 VOID *Mapping;
26 EMMC_PEIM_MEM_BLOCK *Next;
27 };
28
29 typedef struct _EMMC_PEIM_MEM_POOL {
30 EMMC_PEIM_MEM_BLOCK *Head;
31 } EMMC_PEIM_MEM_POOL;
32
33 //
34 // Memory allocation unit, note that the value must meet EMMC spec alignment requirement.
35 //
36 #define EMMC_PEIM_MEM_UNIT 128
37
38 #define EMMC_PEIM_MEM_UNIT_MASK (EMMC_PEIM_MEM_UNIT - 1)
39 #define EMMC_PEIM_MEM_DEFAULT_PAGES 16
40
41 #define EMMC_PEIM_MEM_ROUND(Len) (((Len) + EMMC_PEIM_MEM_UNIT_MASK) & (~EMMC_PEIM_MEM_UNIT_MASK))
42
43 //
44 // Advance the byte and bit to the next bit, adjust byte accordingly.
45 //
46 #define EMMC_PEIM_NEXT_BIT(Byte, Bit) \
47 do { \
48 (Bit)++; \
49 if ((Bit) > 7) { \
50 (Byte)++; \
51 (Bit) = 0; \
52 } \
53 } while (0)
54
55 #endif
56