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