]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.h
MdeModulePkg: Add UFS (Universal Flash Storage) Stack
[mirror_edk2.git] / MdeModulePkg / Bus / Ufs / UfsBlockIoPei / UfsHcMem.h
CommitLineData
0591696e
FT
1/** @file\r
2\r
3Copyright (c) 2014, 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 _UFS_PEIM_MEM_H_\r
17#define _UFS_PEIM_MEM_H_\r
18\r
19#define UFS_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))\r
20\r
21#define UFS_PEIM_MEM_BIT_IS_SET(Data, Bit) \\r
22 ((BOOLEAN)(((Data) & UFS_PEIM_MEM_BIT(Bit)) == UFS_PEIM_MEM_BIT(Bit)))\r
23\r
24typedef struct _UFS_PEIM_MEM_BLOCK UFS_PEIM_MEM_BLOCK;\r
25\r
26struct _UFS_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 UFS_PEIM_MEM_BLOCK *Next;\r
32};\r
33\r
34typedef struct _UFS_PEIM_MEM_POOL {\r
35 UFS_PEIM_MEM_BLOCK *Head;\r
36} UFS_PEIM_MEM_POOL;\r
37\r
38//\r
39// Memory allocation unit, note that the value must meet UFS spec alignment requirement.\r
40//\r
41#define UFS_PEIM_MEM_UNIT 128\r
42\r
43#define UFS_PEIM_MEM_UNIT_MASK (UFS_PEIM_MEM_UNIT - 1)\r
44#define UFS_PEIM_MEM_DEFAULT_PAGES 16\r
45\r
46#define UFS_PEIM_MEM_ROUND(Len) (((Len) + UFS_PEIM_MEM_UNIT_MASK) & (~UFS_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 UFS_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