Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 1 | What: /sys/firmware/memmap/ |
| 2 | Date: June 2008 |
Bernhard Walle | 97bef7d | 2009-02-18 14:48:40 -0800 | [diff] [blame] | 3 | Contact: Bernhard Walle <bernhard.walle@gmx.de> |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 4 | Description: |
| 5 | On all platforms, the firmware provides a memory map which the |
| 6 | kernel reads. The resources from that memory map are registered |
| 7 | in the kernel resource tree and exposed to userspace via |
| 8 | /proc/iomem (together with other resources). |
| 9 | |
| 10 | However, on most architectures that firmware-provided memory |
| 11 | map is modified afterwards by the kernel itself, either because |
| 12 | the kernel merges that memory map with other information or |
| 13 | just because the user overwrites that memory map via command |
| 14 | line. |
| 15 | |
| 16 | kexec needs the raw firmware-provided memory map to setup the |
| 17 | parameter segment of the kernel that should be booted with |
| 18 | kexec. Also, the raw memory map is useful for debugging. For |
| 19 | that reason, /sys/firmware/memmap is an interface that provides |
| 20 | the raw memory map to userspace. |
| 21 | |
| 22 | The structure is as follows: Under /sys/firmware/memmap there |
Mauro Carvalho Chehab | 3443333 | 2020-10-30 08:40:39 +0100 | [diff] [blame] | 23 | are subdirectories with the number of the entry as their name:: |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 24 | |
| 25 | /sys/firmware/memmap/0 |
| 26 | /sys/firmware/memmap/1 |
| 27 | /sys/firmware/memmap/2 |
| 28 | /sys/firmware/memmap/3 |
| 29 | ... |
| 30 | |
| 31 | The maximum depends on the number of memory map entries provided |
| 32 | by the firmware. The order is just the order that the firmware |
| 33 | provides. |
| 34 | |
| 35 | Each directory contains three files: |
| 36 | |
Mauro Carvalho Chehab | 3443333 | 2020-10-30 08:40:39 +0100 | [diff] [blame] | 37 | ======== ===================================================== |
| 38 | start The start address (as hexadecimal number with the |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 39 | '0x' prefix). |
Mauro Carvalho Chehab | 3443333 | 2020-10-30 08:40:39 +0100 | [diff] [blame] | 40 | end The end address, inclusive (regardless whether the |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 41 | firmware provides inclusive or exclusive ranges). |
Mauro Carvalho Chehab | 3443333 | 2020-10-30 08:40:39 +0100 | [diff] [blame] | 42 | type Type of the entry as string. See below for a list of |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 43 | valid types. |
Mauro Carvalho Chehab | 3443333 | 2020-10-30 08:40:39 +0100 | [diff] [blame] | 44 | ======== ===================================================== |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 45 | |
Mauro Carvalho Chehab | 3443333 | 2020-10-30 08:40:39 +0100 | [diff] [blame] | 46 | So, for example:: |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 47 | |
| 48 | /sys/firmware/memmap/0/start |
| 49 | /sys/firmware/memmap/0/end |
| 50 | /sys/firmware/memmap/0/type |
| 51 | /sys/firmware/memmap/1/start |
| 52 | ... |
| 53 | |
| 54 | Currently following types exist: |
| 55 | |
| 56 | - System RAM |
| 57 | - ACPI Tables |
| 58 | - ACPI Non-volatile Storage |
Jianpeng Ma | 3b1f941 | 2021-06-23 10:31:26 +0800 | [diff] [blame] | 59 | - Unusable memory |
| 60 | - Persistent Memory (legacy) |
| 61 | - Persistent Memory |
| 62 | - Soft Reserved |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 63 | - reserved |
| 64 | |
| 65 | Following shell snippet can be used to display that memory |
Mauro Carvalho Chehab | 3443333 | 2020-10-30 08:40:39 +0100 | [diff] [blame] | 66 | map in a human-readable format:: |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 67 | |
Bernhard Walle | 69ac9cd | 2008-06-27 13:12:54 +0200 | [diff] [blame] | 68 | #!/bin/bash |
| 69 | cd /sys/firmware/memmap |
| 70 | for dir in * ; do |
| 71 | start=$(cat $dir/start) |
| 72 | end=$(cat $dir/end) |
| 73 | type=$(cat $dir/type) |
| 74 | printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type" |
| 75 | done |