xref: /rk3399_rockchip-uboot/include/memblk.h (revision efda1f1db3f4fc77c65c060b5bdb91d223df5d69)
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 enum memblk_id {
10 	MEMBLK_ID_UNK,
11 
12 	/* Preloader */
13 	MEMBLK_ID_ATF,
14 	MEMBLK_ID_OPTEE,
15 	MEMBLK_ID_SHM,
16 
17 	/* U-Boot self */
18 	MEMBLK_ID_UBOOT,
19 	MEMBLK_ID_STACK,
20 	MEMBLK_ID_FASTBOOT,
21 
22 	/* Image */
23 	MEMBLK_ID_RAMDISK,
24 	MEMBLK_ID_FDT,
25 	MEMBLK_ID_FDT_DTBO,
26 	MEMBLK_ID_FDT_AOSP,
27 	MEMBLK_ID_KERNEL,
28 	MEMBLK_ID_ANDROID,
29 
30 	/* Other */
31 	MEMBLK_ID_BY_NAME,
32 	MEMBLK_ID_FDT_RESV,
33 	MEMBLK_ID_DEMO,
34 	MEMBLK_ID_MAX,
35 };
36 
37 struct memblk_attr {
38 	const char *name;
39 	const char *alias[2];
40 	u32 flags;
41 };
42 
43 struct memblock {
44 	phys_addr_t base;
45 	phys_size_t size;
46 	struct memblk_attr attr;
47 	struct list_head node;
48 };
49 
50 extern const struct memblk_attr *mem_attr;
51 
52 #define SIZE_MB(len)		((len) >> 20)
53 #define SIZE_KB(len)		(((len) % (1 << 20)) >> 10)
54 
55 #define M_ATTR_NONE		0
56 /* Over-Flow-Check for region tail */
57 #define M_ATTR_OFC		(1 << 0)
58 /* Over-Flow-Check for region Head, only for U-Boot stack */
59 #define M_ATTR_HOFC		(1 << 1)
60 /* Memory can be overlap by fdt reserved memory */
61 #define M_ATTR_OVERLAP		(1 << 2)
62 /* Just peek, always return success */
63 #define M_ATTR_PEEK		(1 << 3)
64 
65 #endif /* _MEMBLK_H */
66