xref: /rk3399_rockchip-uboot/include/memblk.h (revision 75eb6fceb584d246c2b7cfac79b4fe43d0ec0ecd)
1 /* SPDX-License-Identifier:     GPL-2.0+ */
2 /*
3  * (C) Copyright 2019 Rockchip Electronics Co., Ltd
4  */
5 
6 #ifndef _MEMBLK_H
7 #define _MEMBLK_H
8 
9 #define ALIAS_COUNT_MAX		2
10 
11 enum memblk_id {
12 	MEMBLK_ID_UNK,
13 
14 	/* Preloader */
15 	MEMBLK_ID_ATF,
16 	MEMBLK_ID_OPTEE,
17 	MEMBLK_ID_SHM,
18 
19 	/* U-Boot self */
20 	MEMBLK_ID_UBOOT,
21 	MEMBLK_ID_STACK,
22 	MEMBLK_ID_FASTBOOT,
23 
24 	/* Image */
25 	MEMBLK_ID_RAMDISK,
26 	MEMBLK_ID_FDT,
27 	MEMBLK_ID_FDT_DTBO,
28 	MEMBLK_ID_FDT_AOSP,
29 	MEMBLK_ID_KERNEL,
30 	MEMBLK_ID_UNCOMP_KERNEL,
31 	MEMBLK_ID_ANDROID,
32 	MEMBLK_ID_AVB_ANDROID,
33 
34 	/* Other */
35 	MEMBLK_ID_BY_NAME,
36 	MEMBLK_ID_KMEM_RESERVED,
37 	MEMBLK_ID_DEMO,
38 	MEMBLK_ID_MAX,
39 };
40 
41 struct memblk_attr {
42 	const char *name;
43 	const char *alias[ALIAS_COUNT_MAX];
44 	u32 flags;
45 };
46 
47 struct memblock {
48 	phys_addr_t base;
49 	phys_size_t size;
50 	phys_addr_t orig_base;
51 	struct memblk_attr attr;
52 	struct list_head node;
53 };
54 
55 extern const struct memblk_attr *mem_attr;
56 
57 #define SIZE_MB(len)		((len) >> 20)
58 #define SIZE_KB(len)		(((len) % (1 << 20)) >> 10)
59 
60 #define M_ATTR_NONE		0
61 /* Over-Flow-Check for region tail */
62 #define M_ATTR_OFC		(1 << 0)
63 /* Over-Flow-Check for region Head, only for U-Boot stack */
64 #define M_ATTR_HOFC		(1 << 1)
65 /* Memory can be overlap by fdt reserved memory, deprecated */
66 #define M_ATTR_OVERLAP		(1 << 2)
67 /* Just peek, always return success, deprecated */
68 #define M_ATTR_PEEK		(1 << 3)
69 /* The region start address should be aligned to cacheline size */
70 #define M_ATTR_CACHELINE_ALIGN	(1 << 4)
71 /* Kernel 'reserved-memory' */
72 #define M_ATTR_KMEM_RESERVED	(1 << 5)
73 /* The region can be overlap by kernel 'reserved-memory' */
74 #define M_ATTR_KMEM_CAN_OVERLAP	(1 << 6)
75 /* Ignore invisable region reserved by bidram */
76 #define M_ATTR_IGNORE_INVISIBLE	(1 << 7)
77 
78 
79 #endif /* _MEMBLK_H */
80