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