Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
| 3 | .. index:: |
| 4 | single: meminfo (command) |
| 5 | |
| 6 | meminfo command |
| 7 | =============== |
| 8 | |
| 9 | Synopsis |
| 10 | -------- |
| 11 | |
| 12 | :: |
| 13 | |
| 14 | meminfo |
| 15 | |
| 16 | Description |
| 17 | ----------- |
| 18 | |
| 19 | The meminfo command shows the amount of memory. If ``CONFIG_CMD_MEMINFO_MAP`` is |
| 20 | enabled, then it also shows the layout of memory used by U-Boot and the region |
Ilias Apalodimas | d21b76f | 2025-02-20 15:54:39 +0200 | [diff] [blame] | 21 | which is free for use by images. In architectures that support it, it also prints |
| 22 | the mapped pages and their permissions. The latter is architecture specific. |
Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 23 | |
| 24 | The layout of memory is set up before relocation, within the init sequence in |
| 25 | ``board_init_f()``, specifically the various ``reserve_...()`` functions. This |
| 26 | 'reservation' of memory starts from the top of RAM and proceeds downwards, |
| 27 | ending with the stack. This results in the maximum possible amount of memory |
| 28 | being left free for image-loading. |
| 29 | |
Ilias Apalodimas | d21b76f | 2025-02-20 15:54:39 +0200 | [diff] [blame] | 30 | The meminfo command writes the DRAM size. If the architecture also supports it, |
| 31 | page table entries will be shown next. Finally the rest of the outputs are |
| 32 | printed in 5 columns: |
Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 33 | |
| 34 | Region |
| 35 | Name of the region |
| 36 | |
| 37 | Base |
| 38 | Base address of the region, i.e. where it starts in memory |
| 39 | |
| 40 | Size |
| 41 | Size of the region, which may be a little smaller than the actual size |
| 42 | reserved, e.g. due to alignment |
| 43 | |
| 44 | End |
| 45 | End of the region. The last byte of the region is one lower than the address |
| 46 | shown here |
| 47 | |
| 48 | Gap |
| 49 | Gap between the end of this region and the base of the one above |
| 50 | |
| 51 | Regions shown are: |
| 52 | |
| 53 | video |
| 54 | Memory reserved for video framebuffers. This reservation happens in the |
| 55 | bind() methods of all video drivers which are present before relocation, |
| 56 | so the size depends on that maximum amount of memory which all such drivers |
| 57 | want to reserve. This may be significantly greater than the amount actually |
| 58 | needed, if the display is ultimately set to a smaller resolution or colour |
| 59 | depth than the maximum supported. |
| 60 | |
| 61 | code |
| 62 | U-Boot's code and Block-Starting Symbol (BSS) region. Before relocation, |
| 63 | U-Boot copies its code to a high region and sets up a BSS immediately after |
| 64 | that. The size of this region is generally therefore ``__bss_end`` - |
| 65 | ``__image_copy_start`` |
| 66 | |
| 67 | malloc |
| 68 | Contains the malloc() heap. The size of this is set by |
| 69 | ``CONFIG_SYS_MALLOC_LEN``. |
| 70 | |
| 71 | board_info |
| 72 | Contains the ``bd_info`` structure, with some information about the current |
| 73 | board. |
| 74 | |
| 75 | global_data |
| 76 | Contains the global-data structure, pointed to by ``gd``. This includes |
| 77 | various pointers, values and flags which control U-Boot. |
| 78 | |
| 79 | devicetree |
| 80 | Contains the flatted devicetree blob (FDT) being used by U-Boot to configure |
| 81 | itself and its devices. |
| 82 | |
| 83 | bootstage |
| 84 | Contains the bootstage records, which keep track of boot time as U-Boot |
| 85 | executes. The size of this is determined by |
| 86 | ``CONFIG_BOOTSTAGE_RECORD_COUNT``, with each record taking approximately |
| 87 | 32 bytes. |
| 88 | |
| 89 | bloblist |
| 90 | Contains the bloblist, which is a list of tables and other data created by |
| 91 | U-Boot while executed. The size of this is determined by |
| 92 | ``CONFIG_BLOBLIST_SIZE``. |
| 93 | |
| 94 | stack |
| 95 | Contains U-Boot's stack, growing downwards from the top. The nominal size of |
| 96 | this region is set by ``CONFIG_STACK_SIZE`` but there is no actual limit |
| 97 | enforced, so the stack can grow behind that. Images should be loaded lower |
| 98 | in memory to avoid any conflict. |
| 99 | |
| 100 | free |
| 101 | Free memory, which is available for loading images. The base address of |
| 102 | this is ``gd->ram_base`` which is generally set by ``CFG_SYS_SDRAM_BASE``. |
| 103 | |
Ilias Apalodimas | d21b76f | 2025-02-20 15:54:39 +0200 | [diff] [blame] | 104 | Aarch64 specific flags |
| 105 | ---------------------- |
| 106 | |
| 107 | More information on the output can be found |
| 108 | Chapter D8 - The AArch64 Virtual Memory System Architecture at |
| 109 | https://developer.arm.com/documentation/ddi0487/latest/ |
| 110 | |
| 111 | In short, for a stage 1 translation regime the following apply: |
| 112 | |
| 113 | * RWX: Pages mapped with Read, Write and Execute permissions |
| 114 | * RO: Pages mapped with Read-Only permissions |
| 115 | * PXN: PXN (Privileged Execute Never) applies to execution at EL1 and above |
| 116 | * UXN: UXN (Unprivileged Execute Never) applies to EL0 |
| 117 | |
Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 118 | Example |
| 119 | ------- |
| 120 | |
| 121 | This example shows output with both ``CONFIG_CMD_MEMINFO`` and |
Ilias Apalodimas | d21b76f | 2025-02-20 15:54:39 +0200 | [diff] [blame] | 122 | ``CONFIG_CMD_MEMINFO_MAP`` enabled for aarch64 qemu:: |
Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 123 | |
Ilias Apalodimas | d21b76f | 2025-02-20 15:54:39 +0200 | [diff] [blame] | 124 | DRAM: 8 GiB |
| 125 | Walking pagetable at 000000023ffe0000, va_bits: 40. Using 4 levels |
| 126 | [0x0000023ffe1000] | Table | | | |
| 127 | [0x0000023ffe2000] | Table | | | |
| 128 | [0x00000000000000 - 0x00000008000000] | Block | RWX | Normal | Inner-shareable |
| 129 | [0x00000008000000 - 0x00000040000000] | Block | PXN UXN | Device-nGnRnE | Non-shareable |
| 130 | [0x00000040000000 - 0x00000200000000] | Block | RWX | Normal | Inner-shareable |
| 131 | [0x0000023ffea000] | Table | | | |
| 132 | [0x00000200000000 - 0x0000023f600000] | Block | RWX | Normal | Inner-shareable |
| 133 | [0x0000023ffeb000] | Table | | | |
| 134 | [0x0000023f600000 - 0x0000023f68c000] | Pages | RWX | Normal | Inner-shareable |
| 135 | [0x0000023f68c000 - 0x0000023f74f000] | Pages | RO | Normal | Inner-shareable |
| 136 | [0x0000023f74f000 - 0x0000023f794000] | Pages | PXN UXN RO | Normal | Inner-shareable |
| 137 | [0x0000023f794000 - 0x0000023f79d000] | Pages | PXN UXN | Normal | Inner-shareable |
| 138 | [0x0000023f79d000 - 0x0000023f800000] | Pages | RWX | Normal | Inner-shareable |
| 139 | [0x0000023f800000 - 0x00000240000000] | Block | RWX | Normal | Inner-shareable |
| 140 | [0x00000240000000 - 0x00004000000000] | Block | RWX | Normal | Inner-shareable |
| 141 | [0x0000023ffe3000] | Table | | | |
| 142 | [0x00004010000000 - 0x00004020000000] | Block | PXN UXN | Device-nGnRnE | Non-shareable |
| 143 | [0x0000023ffe4000] | Table | | | |
| 144 | [0x00008000000000 - 0x00010000000000] | Block | PXN UXN | Device-nGnRnE | Non-shareable |
Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 145 | |
| 146 | Region Base Size End Gap |
| 147 | ------------------------------------------------ |
Ilias Apalodimas | d21b76f | 2025-02-20 15:54:39 +0200 | [diff] [blame] | 148 | video 23f7e0000 800000 23ffe0000 |
| 149 | code 23f68a000 156000 23f7e0000 0 |
| 150 | malloc 23e64a000 1040000 23f68a000 0 |
| 151 | board_info 23e649f80 78 23e649ff8 8 |
| 152 | global_data 23e649df0 188 23e649f78 8 |
| 153 | devicetree 23e549df0 100000 23e649df0 0 |
| 154 | bloblist 23e547000 2000 23e549000 df0 |
| 155 | stack 23d546ff0 1000000 23e546ff0 10 |
| 156 | lmb 23d546ff0 0 23d546ff0 0 |
| 157 | lmb 23d543000 3ff0 23d546ff0 0 |
| 158 | free 40000000 23d543000 27d543000 ffffffffc0000000 |
Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 159 | |
| 160 | Return value |
| 161 | ------------ |
| 162 | |
| 163 | The return value $? is always 0 (true). |