Updated: October 28, 2024 |
(or The Persistence of Memory, with a nod to Salvador Dali)
In the Process Manager chapter of the System Architecture, we looked at how the OS manages memory. This chapter describes how you can work with memory.
Let's start with some definitions. By memory, we mean anything that can be accessed via physical addresses, but there are various classifications of memory:
Non-RAM refers to memory-mapped I/O or memory-mapped devices. For example, some hardware exposes its registers in this way. You can treat non-RAM as RAM, and it behaves somewhat as RAM, but it really isn't.
Non-SYSRAM is whatever RAM isn't included in SYSRAM, including memory that's reserved by startup for memory pools to be used for specific purposes such as USB, graphics, or cameras.
Wired memory is backed as soon as it's allocated.
Let's look at an example. The pidin utility displays (among other things) information about sections of the system page. If you run pidin syspage=asinfo, the output might look like this:
Header size=0x00000108, Total Size=0x00000cd0, #Cpu=2, Type=256 Section:asinfo offset:0x00000710 size:0x00000340 elsize:0x00000020 0000) 0000000000000000-000000000000ffff o:ffff a:0000 p:100 c:0 n:/io 0020) 0000000000000000-000fffffffffffff o:ffff a:0010 p:100 c:0 n:/memory 0040) 0000000000000000-00000000ffffffff o:0020 a:0010 p:100 c:0 n:/memory/below4G 0060) 0000000000000000-0000000000ffffff o:0020 a:0010 p:100 c:0 n:/memory/isa 0080) 0000000006000000-00000000ffefffff o:0020 a:0013 p:100 c:0 n:/memory/device 00a0) 00000000fff00000-00000000ffffffff o:0020 a:0005 p:100 c:0 n:/memory/rom 00c0) 0000000000000000-000000000009f7ff o:0060 a:0017 p:100 c:0 n:/memory/isa/ram 00e0) 0000000000100000-0000000000ffffff o:0060 a:0037 p:100 c:0 n:/memory/isa/ram 0100) 0000000001000000-0000000005ffffff o:0040 a:0037 p:100 c:0 n:/memory/below4G/ram 0120) 0000000006000000-000000003fedffff o:0080 a:0017 p:100 c:0 n:/memory/device/ram 0140) 000000003ff00000-000000003fffffff o:0080 a:0017 p:100 c:0 n:/memory/device/ram 0160) 00000000000f6a00-00000000000f6a23 o:0020 a:0007 p:100 c:0 n:/memory/acpi_rsdp 0180) 00000000fee00000-00000000fee003ef o:0020 a:0003 p:100 c:0 n:/memory/lapic 01a0) 000000000142c038-0000000001c9bb7b o:0020 a:0005 p:100 c:0 n:/memory/imagefs 01c0) 0000000001400f30-000000000142c037 o:0020 a:0007 p:100 c:0 n:/memory/startup 01e0) 000000000142c038-0000000001c9bb7b o:0020 a:0007 p:100 c:0 n:/memory/bootram 0200) 0000000000000000-00000000ffffffff o:ffff a:0010 p:100 c:0 n:/virtual 0220) ffff800000001000-ffff8000000f25d0 o:0200 a:0000 p:100 c:0 n:/virtual/vboot 0240) 0000000000001000-000000000009efff o:00c0 a:0007 p:100 c:0 n:/memory/isa/ram/sysram 0260) 0000000000106000-0000000000108fff o:00e0 a:0007 p:100 c:0 n:/memory/isa/ram/sysram 0280) 000000000010f000-00000000004f6fff o:00e0 a:0007 p:100 c:0 n:/memory/isa/ram/sysram 02a0) 00000000004f8000-0000000000ffffff o:00e0 a:0027 p:100 c:0 n:/memory/isa/ram/sysram 02c0) 0000000001000000-000000000142bfff o:0100 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram 02e0) 0000000001c9c000-0000000005ffffff o:0100 a:0027 p:100 c:0 n:/memory/below4G/ram/sysram 0300) 0000000006000000-000000003f2d4fff o:0120 a:0007 p:100 c:0 n:/memory/device/ram/sysram 0320) 000000003ff00000-000000003fffffff o:0140 a:0007 p:100 c:0 n:/memory/device/ram/sysram
For details about the above information, see the section on asinfo in the System Page chapter of Building Embedded Systems.
The memory regions in this example include the following:
The /virtual and /virtual/vboot regions aren't currently used.