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