Solved /proc/iomem equivalent in FreeBSD

What I'm looking for is how to display memory range information in FreeBSD.

In Linux there is an entry in the /proc filesystem called iomem which displays memory regions, reservation and usage, etc. As you know memory is not just a flat block of RAM, though it is presented that way to applications - the reality is that memory address space is partitioned into various regions, sometimes including a 384k hole, another one from 15-16Mb, shadow BIOS copy, the PCI and PCIe address space, AGP aperture, shared video ram, etc. An example of /proc/iomem looks something like this:

Code:
00000000-0009fbff : System RAM
0009fc00-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-07ffffff : System RAM
  00100000-00291ba8 : Kernel code
  00291ba9-002e09cb : Kernel data
e0000000-e3ffffff : VIA Technologies, Inc. VT82C597 [Apollo VP3]
e4000000-e7ffffff : PCI Bus #01
  e4000000-e4003fff : Matrox Graphics, Inc. MGA G200 AGP
  e5000000-e57fffff : Matrox Graphics, Inc. MGA G200 AGP
e8000000-e8ffffff : PCI Bus #01
  e8000000-e8ffffff : Matrox Graphics, Inc. MGA G200 AGP
ea000000-ea00007f : Digital Equipment Corporation DECchip 21140 [FasterNet]
  ea000000-ea00007f : tulip
ffff0000-ffffffff : reserved

which clearly breaks down the address space into reservations and gives detail of which subsystem is holding which regions.

This post, "MMIO in FreeBSD", was made last year and asks a similar question - but the poster abandoned the question once they realized they were asking for "before POST" instead of "after boot". I have the second question now :) So far, the closest two options I've found have are:

* The freebsd-memory.sh script (available here: https://github.com/ocochard/myscripts/blob/master/FreeBSD/freebsd-memory.sh), which parses output from sysctl(8) to display some tables of RAM information... while it does show "reserved", "free" etc. it is not broken down by region.

* memcontrol(8), which allows the user to view and edit MTRR settings - this does allow manipulating memory regions, but it's for changing cache settings and stuff. Not really the same thing.

If no equivalent exists, but someone has tips on where the information might be stored in the kernel, I wouldn't mind getting my hands dirty to produce some kind of tool to provide a similar report.
 
I did not see much either. muse was broke and vmstat is pretty limited. sysinfo mem showed some basic stuff.
dmidecode -t memory shows information about the memory modules.

Not much showing memory stack allocation
 
Hornpipe2 Maybe devinfo(8) is what you're looking for ? devinfo -r lists the io memory addresses too.

Ah, this is it - but the better way to display it is devinfo -u, which groups the listings into categories. The header for "I/O memory addresses" looks like this on my system:
Code:
I/O memory addresses:
    0x0-0x9fbff (ram0)
    0x9fc00-0x9ffff (root0)
    0xa0000-0xaffff (vtvga0)
    0xb0000-0xbffff (root0)
    0xc0000-0xdffff (acpi0)
    0xe0000-0xfffff (acpi0)
    0x100000-0xcfe2f7ff (ram0)
    0xcfe2f800-0xd79fffff (root0)
    0xd7a00000-0xd7afffff (pcib6)
    0xd7b00000-0xd7bfffff (pcib2)
    0xd7c00000-0xd7cfffff (pcib3)
    0xd7d00000-0xd7dfffff (pcib4)
    0xd7e00000-0xd7efffff (pcib5)
    0xd7f00000-0xd7ffffff (pcib1)
    0xd8000000-0xdfffffff (vgapci0)
    0xe0000000-0xefffffff (acpi0)
    0xf0000000-0xfebfffff (root0)
    0xfec00000-0xfec00fff (acpi0)
    0xfec01000-0xfed12fff (root0)
    0xfed13000-0xfed13fff (acpi0)
    0xfed14000-0xfed17fff (acpi0)
    0xfed18000-0xfed18fff (acpi0)
    0xfed19000-0xfed19fff (acpi0)
    0xfed1a000-0xfed1bfff (root0)
    0xfed1c000-0xfed1ffff (acpi0)
    0xfed20000-0xfed9ffff (acpi0)
    0xfeda0000-0xfedfffff (root0)
    0xfee00000-0xfee00fff (acpi0)
    0xfee01000-0xff43ffff (root0)
    0xff440000-0xff47ffff (vgapci0)
    0xff480000-0xff4fffff (vgapci0)
    0xff500000-0xff5fffff (pcib6)
    0xff600000-0xff6fffff (pcib2)
    0xff700000-0xff7fffff (pcib3)
    0xff800000-0xff8fffff (pcib4)
    0xff900000-0xff9fffff (pcib5)
    0xffa00000-0xffafffff (pcib1)
    0xffb00000-0xffb7ffff (root0)
    0xffb80000-0xffbfffff ----
    0xffc00000-0xfff7ffff (root0)
    0xfff80000-0xffffffff ----

showing which areas are reserved by which device, and most of the space taken by ram0 (my system RAM).
 
It shows the address space as used by the hardware.
But which address space is used by the kernel?
And which address space is used by which process ?
 
Alain De Vos OP's question was to find the /proc/iomem alternative in FreeBSD. That's what devinfo does. These addresses are memory mapped IO addresses. They are physical addresses. They are used in ring0.

Now I have less knowledge about FreeBSD than of Linux when it comes to these internals but Linux does map portion of the kernel 1:1 to physical (or with given offset to calculate physical address easily). kldstat does show where the kernel is loaded (virtual).

Process (userland) address space uses virtual addresses so it doesn't concern this thread at all. I'm not aware of any tool showing the physical addresses usage by a given process. You could maybe walk the page tables and process structures using /dev/{k,}mem to achieve that.
 
Back
Top