]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Ufs / UfsBlockIoPei / UfsHcMem.h
CommitLineData
0591696e
FT
1/** @file\r
2\r
d1102dba
LG
3Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
4\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
0591696e
FT
6\r
7**/\r
8\r
9#ifndef _UFS_PEIM_MEM_H_\r
10#define _UFS_PEIM_MEM_H_\r
11\r
12#define UFS_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))\r
13\r
14#define UFS_PEIM_MEM_BIT_IS_SET(Data, Bit) \\r
15 ((BOOLEAN)(((Data) & UFS_PEIM_MEM_BIT(Bit)) == UFS_PEIM_MEM_BIT(Bit)))\r
16\r
17typedef struct _UFS_PEIM_MEM_BLOCK UFS_PEIM_MEM_BLOCK;\r
18\r
19struct _UFS_PEIM_MEM_BLOCK {\r
20 UINT8 *Bits; // Bit array to record which unit is allocated\r
d1102dba 21 UINTN BitsLen;\r
0591696e 22 UINT8 *Buf;\r
44a0857e 23 UINT8 *BufHost;\r
0591696e 24 UINTN BufLen; // Memory size in bytes\r
44a0857e 25 VOID *Mapping;\r
0591696e
FT
26 UFS_PEIM_MEM_BLOCK *Next;\r
27};\r
28\r
29typedef struct _UFS_PEIM_MEM_POOL {\r
30 UFS_PEIM_MEM_BLOCK *Head;\r
31} UFS_PEIM_MEM_POOL;\r
32\r
33//\r
34// Memory allocation unit, note that the value must meet UFS spec alignment requirement.\r
35//\r
36#define UFS_PEIM_MEM_UNIT 128\r
37\r
38#define UFS_PEIM_MEM_UNIT_MASK (UFS_PEIM_MEM_UNIT - 1)\r
39#define UFS_PEIM_MEM_DEFAULT_PAGES 16\r
40\r
41#define UFS_PEIM_MEM_ROUND(Len) (((Len) + UFS_PEIM_MEM_UNIT_MASK) & (~UFS_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 UFS_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