]>
Commit | Line | Data |
---|---|---|
48555339 FT |
1 | /** @file\r |
2 | \r | |
85ad9a6e | 3 | Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r |
48555339 | 4 | \r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
48555339 FT |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef _EMMC_PEIM_MEM_H_\r | |
10 | #define _EMMC_PEIM_MEM_H_\r | |
11 | \r | |
12 | #define EMMC_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))\r | |
13 | \r | |
14 | #define EMMC_PEIM_MEM_BIT_IS_SET(Data, Bit) \\r | |
15 | ((BOOLEAN)(((Data) & EMMC_PEIM_MEM_BIT(Bit)) == EMMC_PEIM_MEM_BIT(Bit)))\r | |
16 | \r | |
17 | typedef struct _EMMC_PEIM_MEM_BLOCK EMMC_PEIM_MEM_BLOCK;\r | |
18 | \r | |
19 | struct _EMMC_PEIM_MEM_BLOCK {\r | |
20 | UINT8 *Bits; // Bit array to record which unit is allocated\r | |
21 | UINTN BitsLen;\r | |
22 | UINT8 *Buf;\r | |
85ad9a6e | 23 | UINT8 *BufHost;\r |
48555339 | 24 | UINTN BufLen; // Memory size in bytes\r |
85ad9a6e | 25 | VOID *Mapping;\r |
48555339 FT |
26 | EMMC_PEIM_MEM_BLOCK *Next;\r |
27 | };\r | |
28 | \r | |
29 | typedef struct _EMMC_PEIM_MEM_POOL {\r | |
30 | EMMC_PEIM_MEM_BLOCK *Head;\r | |
31 | } EMMC_PEIM_MEM_POOL;\r | |
32 | \r | |
33 | //\r | |
34 | // Memory allocation unit, note that the value must meet EMMC spec alignment requirement.\r | |
35 | //\r | |
36 | #define EMMC_PEIM_MEM_UNIT 128\r | |
37 | \r | |
38 | #define EMMC_PEIM_MEM_UNIT_MASK (EMMC_PEIM_MEM_UNIT - 1)\r | |
39 | #define EMMC_PEIM_MEM_DEFAULT_PAGES 16\r | |
40 | \r | |
41 | #define EMMC_PEIM_MEM_ROUND(Len) (((Len) + EMMC_PEIM_MEM_UNIT_MASK) & (~EMMC_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 EMMC_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 |