18c2ecf20Sopenharmony_ciWhat: /sys/firmware/memmap/ 28c2ecf20Sopenharmony_ciDate: June 2008 38c2ecf20Sopenharmony_ciContact: Bernhard Walle <bernhard.walle@gmx.de> 48c2ecf20Sopenharmony_ciDescription: 58c2ecf20Sopenharmony_ci On all platforms, the firmware provides a memory map which the 68c2ecf20Sopenharmony_ci kernel reads. The resources from that memory map are registered 78c2ecf20Sopenharmony_ci in the kernel resource tree and exposed to userspace via 88c2ecf20Sopenharmony_ci /proc/iomem (together with other resources). 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci However, on most architectures that firmware-provided memory 118c2ecf20Sopenharmony_ci map is modified afterwards by the kernel itself, either because 128c2ecf20Sopenharmony_ci the kernel merges that memory map with other information or 138c2ecf20Sopenharmony_ci just because the user overwrites that memory map via command 148c2ecf20Sopenharmony_ci line. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci kexec needs the raw firmware-provided memory map to setup the 178c2ecf20Sopenharmony_ci parameter segment of the kernel that should be booted with 188c2ecf20Sopenharmony_ci kexec. Also, the raw memory map is useful for debugging. For 198c2ecf20Sopenharmony_ci that reason, /sys/firmware/memmap is an interface that provides 208c2ecf20Sopenharmony_ci the raw memory map to userspace. 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci The structure is as follows: Under /sys/firmware/memmap there 238c2ecf20Sopenharmony_ci are subdirectories with the number of the entry as their name:: 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci /sys/firmware/memmap/0 268c2ecf20Sopenharmony_ci /sys/firmware/memmap/1 278c2ecf20Sopenharmony_ci /sys/firmware/memmap/2 288c2ecf20Sopenharmony_ci /sys/firmware/memmap/3 298c2ecf20Sopenharmony_ci ... 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci The maximum depends on the number of memory map entries provided 328c2ecf20Sopenharmony_ci by the firmware. The order is just the order that the firmware 338c2ecf20Sopenharmony_ci provides. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci Each directory contains three files: 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci ======== ===================================================== 388c2ecf20Sopenharmony_ci start The start address (as hexadecimal number with the 398c2ecf20Sopenharmony_ci '0x' prefix). 408c2ecf20Sopenharmony_ci end The end address, inclusive (regardless whether the 418c2ecf20Sopenharmony_ci firmware provides inclusive or exclusive ranges). 428c2ecf20Sopenharmony_ci type Type of the entry as string. See below for a list of 438c2ecf20Sopenharmony_ci valid types. 448c2ecf20Sopenharmony_ci ======== ===================================================== 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci So, for example:: 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci /sys/firmware/memmap/0/start 498c2ecf20Sopenharmony_ci /sys/firmware/memmap/0/end 508c2ecf20Sopenharmony_ci /sys/firmware/memmap/0/type 518c2ecf20Sopenharmony_ci /sys/firmware/memmap/1/start 528c2ecf20Sopenharmony_ci ... 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci Currently following types exist: 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci - System RAM 578c2ecf20Sopenharmony_ci - ACPI Tables 588c2ecf20Sopenharmony_ci - ACPI Non-volatile Storage 598c2ecf20Sopenharmony_ci - reserved 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci Following shell snippet can be used to display that memory 628c2ecf20Sopenharmony_ci map in a human-readable format:: 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci #!/bin/bash 658c2ecf20Sopenharmony_ci cd /sys/firmware/memmap 668c2ecf20Sopenharmony_ci for dir in * ; do 678c2ecf20Sopenharmony_ci start=$(cat $dir/start) 688c2ecf20Sopenharmony_ci end=$(cat $dir/end) 698c2ecf20Sopenharmony_ci type=$(cat $dir/type) 708c2ecf20Sopenharmony_ci printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type" 718c2ecf20Sopenharmony_ci done 72