]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.h
MdeModulePkg/SdMmc: Add EDKII SD/MMC stack
[mirror_edk2.git] / MdeModulePkg / Bus / Sd / EmmcBlockIoPei / EmmcHcMem.h
CommitLineData
48555339
FT
1/** @file\r
2\r
3Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
4\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions\r
7of the BSD License which accompanies this distribution. The\r
8full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _EMMC_PEIM_MEM_H_\r
17#define _EMMC_PEIM_MEM_H_\r
18\r
19#define EMMC_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))\r
20\r
21#define EMMC_PEIM_MEM_BIT_IS_SET(Data, Bit) \\r
22 ((BOOLEAN)(((Data) & EMMC_PEIM_MEM_BIT(Bit)) == EMMC_PEIM_MEM_BIT(Bit)))\r
23\r
24typedef struct _EMMC_PEIM_MEM_BLOCK EMMC_PEIM_MEM_BLOCK;\r
25\r
26struct _EMMC_PEIM_MEM_BLOCK {\r
27 UINT8 *Bits; // Bit array to record which unit is allocated\r
28 UINTN BitsLen;\r
29 UINT8 *Buf;\r
30 UINTN BufLen; // Memory size in bytes\r
31 EMMC_PEIM_MEM_BLOCK *Next;\r
32};\r
33\r
34typedef struct _EMMC_PEIM_MEM_POOL {\r
35 EMMC_PEIM_MEM_BLOCK *Head;\r
36} EMMC_PEIM_MEM_POOL;\r
37\r
38//\r
39// Memory allocation unit, note that the value must meet EMMC spec alignment requirement.\r
40//\r
41#define EMMC_PEIM_MEM_UNIT 128\r
42\r
43#define EMMC_PEIM_MEM_UNIT_MASK (EMMC_PEIM_MEM_UNIT - 1)\r
44#define EMMC_PEIM_MEM_DEFAULT_PAGES 16\r
45\r
46#define EMMC_PEIM_MEM_ROUND(Len) (((Len) + EMMC_PEIM_MEM_UNIT_MASK) & (~EMMC_PEIM_MEM_UNIT_MASK))\r
47\r
48//\r
49// Advance the byte and bit to the next bit, adjust byte accordingly.\r
50//\r
51#define EMMC_PEIM_NEXT_BIT(Byte, Bit) \\r
52 do { \\r
53 (Bit)++; \\r
54 if ((Bit) > 7) { \\r
55 (Byte)++; \\r
56 (Bit) = 0; \\r
57 } \\r
58 } while (0)\r
59\r
60#endif\r
61\r