I am trying to get the physical address range of all the available ram in the system inside a linux kernel module.
I saw cat /proc/iomem and saw that the physical memory is itself not contiguous.
I understand that for 32bit systems compatibility there is PCI and other peripheral memory need to be inside the 4GB address range. also the 640 kB initial for DOS. below output is from x86_64 system
00000000-00000fff : reserved
00001000-0009d7ff : System RAM //640kB here
0009d800-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
000c0000-000cedff : Video ROM
000e0000-000fffff : reserved
000f0000-000fffff : System ROM
00100000-daa85fff : System RAM //~3.5 gb here
01000000-0177acb8 : Kernel code
0177acb9-01d1b53f : Kernel data
01e79000-01fbdfff : Kernel bss
daa86000-daa87fff : reserved
daa88000-dad0efff : System RAM //some RAM here
dad0f000-dae75fff : reserved
dae76000-dae95fff : ACPI Non-volatile Storage
dae96000-daf1efff : reserved
daf1f000-daf9efff : ACPI Non-volatile Storage
daf9f000-daffefff : ACPI Tables
dafff000-daffffff : System RAM //some RAM here
db000000-df9fffff : reserved
dba00000-df9fffff : Graphics Stolen Memory
dfa00000-feafffff : PCI Bus 0000:00
e0000000-efffffff : 0000:00:02.0
f0000000-f03fffff : 0000:00:02.0
f0400000-f04fffff : PCI Bus 0000:02
f0400000-f0403fff : 0000:02:00.0
f0400000-f0403fff : r8169
f0404000-f0404fff : 0000:02:00.0
f0404000-f0404fff : r8169
f0500000-f05fffff : PCI Bus 0000:01
f0500000-f0503fff : 0000:01:00.0
f0500000-f0503fff : bcma-pci-bridge
f0600000-f0603fff : 0000:00:1b.0
f0600000-f0603fff : ICH HD audio
f0604000-f06040ff : 0000:00:1f.3
f0605000-f060500f : 0000:00:16.0
f0605000-f060500f : mei_me
f0608000-f06087ff : 0000:00:1f.2
f0608000-f06087ff : ahci
f0609000-f06093ff : 0000:00:1d.0
f0609000-f06093ff : ehci_hcd
f060a000-f060a3ff : 0000:00:1a.0
f060a000-f060a3ff : ehci_hcd
f8000000-fbffffff : PCI MMCONFIG 0000 [bus 00-3f]
f8000000-fbffffff : reserved
f8000000-fbffffff : pnp 00:05
fec00000-fec00fff : reserved
fec00000-fec003ff : IOAPIC 0
fed00000-fed003ff : HPET 0
fed00000-fed003ff : PNP0103:00
fed08000-fed08fff : reserved
fed10000-fed19fff : reserved
fed10000-fed17fff : pnp 00:05
fed18000-fed18fff : pnp 00:05
fed19000-fed19fff : pnp 00:05
fed1c000-fed1ffff : reserved
fed1c000-fed1ffff : pnp 00:05
fed1f410-fed1f414 : iTCO_wdt
fed20000-fed3ffff : pnp 00:05
fed40000-fed44fff : PCI Bus 0000:00
fed45000-fed8ffff : pnp 00:05
fed90000-fed93fff : pnp 00:05
fee00000-fee00fff : Local APIC
fee00000-fee00fff : reserved
ff000000-ffffffff : INT0800:00
ffd80000-ffffffff : reserved
100000000-15fdfffff : System RAM //~1.5 gB here
15fe00000-15fffffff : RAM buffer
My Question is . 1. how to get all of the RAM which can be used for DMA, using kernel code. 2. why is there extra RAM regions. ? also why the RAM is not split at some proper boundary for ex. 2GB +3GB. 3. will only the 3.5GB of area will be used for DMA or higher 1.5 GB can also be used for DMA. in linux.
There are a few commands that can be used from the linux terminal for this. Both will show the physical memory address range in your linux system.
cat /proc/meminfo: This will print the value in terminal as:
MemTotal: 8027952 kB
MemFree: 3893748 kB
Buffers: 132208 kB
Cached: 1666864 kB
SwapCached: 226556 kB
Active: 1979556 kB
Inactive: 1849480 kB
Active(anon): 1592580 kB
Inactive(anon): 886080 kB
Active(file): 386976 kB
Inactive(file): 963400 kB
Unevictable: 68 kB
Mlocked: 68 kB
SwapTotal: 15624188 kB
SwapFree: 15050964 kB
Dirty: 172 kB
Writeback: 0 kB
AnonPages: 1907548 kB
Mapped: 223484 kB
Shmem: 448696 kB
Slab: 140444 kB
SReclaimable: 101456 kB
SUnreclaim: 38988 kB
KernelStack: 4960 kB
PageTables: 53108 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 19638164 kB
Committed_AS: 7822876 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 567356 kB
VmallocChunk: 34359151824 kB
or vmstat -s: This will print value as:
8027952 K total memory
4114688 K used memory
1960100 K active memory
1849792 K inactive memory
3913264 K free memory
132240 K buffer memory
1667108 K swap cache
15624188 K total swap
573224 K used swap
15050964 K free swap
931285 non-nice user cpu ticks
6391 nice user cpu ticks
152567 system cpu ticks
7019826 idle cpu ticks
181109 IO-wait cpu ticks
19 IRQ cpu ticks
2262 softirq cpu ticks
There is one more command using dmidecode
: you can use sudo dmidecode -t memory
to check the details of ram in your linux system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With