WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: dmesg address parser  (Read 85 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11725
dmesg address parser
« on: January 01, 2025, 02:59:29 AM »
Trying to makes sense of some of the entries in dmesg can be
difficult unless you are well versed in dealing with hex numbers.

I created a script that parses the dmesg command (or a file) and
retrieves any line that contains an address range. It then reformats
the output into 4 columns:
Columns 1 and 2 are the start and end addresses converted to decimal.
Column 3 is the size of that address range in decimal.
Column 4 is the line from dmesg spanning multiple lines in column 4 if needed.

Executing the script by itself will cause it to run dmesg for its input.
Executing the script with a file will cause it to scan the file.

This is the help message:
Code: [Select]
tc@E310:~/Scripting/AddressParser$ ./AddressParser.sh -h
Version 0.1 Dec 30, 2024

This script scans dmesg or a file (optional) for hex address ranges.
  Usage:    AddressParser.sh [ -n ] [ File ]
        -n      Do not format column 4 to stay within column 4.

Sample result:
     Start       End      Size  Dmesg
     0.00B   637.99K   638.00K  BIOS-e820: [mem 0x0000000000000000-0x000000000
                                009f7ff] usable
   638.00K   639.99K  2048.00B  BIOS-e820: [mem 0x000000000009f800-0x000000000
                                009ffff] reserved
   256.00B   943.00B   688.00B  pcmcia_socket pcmcia_socket0: cs: IO port prob
                                e 0x100-0x3af:
   368.00B   375.00B     8.00B  excluding 0x170-0x177 0x1f0-0x1f7 0x370-0x377
   496.00B   503.00B     8.00B  excluding 0x170-0x177 0x1f0-0x1f7 0x370-0x377
   880.00B   887.00B     8.00B  excluding 0x170-0x177 0x1f0-0x1f7 0x370-0x377

Columns 1 and 2 are the decimal equivalents for hex addresses.
Column 3 is the size of the address window.
Column 4 is the scanned lines. It wraps within the column if too long.
Lines containing multiple address ranges are listed multiple times.

The script reads the width of the terminal or console and formats the output
to fill the width.

Here's a partial sample TC15 64 bit booting:
Code: [Select]
     Start       End      Size  Dmesg
     0.00B   637.99K   638.00K  [    0.000000] BIOS-e820: [mem 0x0000000000000
                                000-0x000000000009f7ff] usable
   638.00K   639.99K  2048.00B  [    0.000000] BIOS-e820: [mem 0x000000000009f
                                800-0x000000000009ffff] reserved
   880.00K  1023.99K   144.00K  [    0.000000] BIOS-e820: [mem 0x00000000000dc
                                000-0x00000000000fffff] reserved
  1024.00K  3062.81M  3061.81M  [    0.000000] BIOS-e820: [mem 0x0000000000100
                                000-0x00000000bf6cffff] usable
  3062.81M  3062.87M    64.00K  [    0.000000] BIOS-e820: [mem 0x00000000bf6d0
                                000-0x00000000bf6dffff] ACPI data
  3062.87M  3062.88M    12.00K  [    0.000000] BIOS-e820: [mem 0x00000000bf6e0
                                000-0x00000000bf6e2fff] ACPI NVS
  3062.88M  3071.99M  9332.00K  [    0.000000] BIOS-e820: [mem 0x00000000bf6e3
                                000-0x00000000bfffffff] reserved
  3584.00M  3839.99M   256.00M  [    0.000000] BIOS-e820: [mem 0x00000000e0000
                                000-0x00000000efffffff] reserved
  4076.00M  4076.06M    64.00K  [    0.000000] BIOS-e820: [mem 0x00000000fec00
                                000-0x00000000fec0ffff] reserved
  4077.00M  4077.00M  1024.00B  [    0.000000] BIOS-e820: [mem 0x00000000fed00
                                000-0x00000000fed003ff] reserved
  4077.07M  4077.10M    24.00K  [    0.000000] BIOS-e820: [mem 0x00000000fed14
                                000-0x00000000fed19fff] reserved
  4077.10M  4077.56M   464.00K  [    0.000000] BIOS-e820: [mem 0x00000000fed1c
                                000-0x00000000fed8ffff] reserved
  4078.00M  4078.00M  4096.00B  [    0.000000] BIOS-e820: [mem 0x00000000fee00
                                000-0x00000000fee00fff] reserved
  4080.00M  4095.99M    16.00M  [    0.000000] BIOS-e820: [mem 0x00000000ff000
                                000-0x00000000ffffffff] reserved
  4096.00M  5119.99M  1024.00M  [    0.000000] BIOS-e820: [mem 0x0000000100000
                                000-0x000000013fffffff] usable
     0.00B  4095.00B  4096.00B  [    0.005306] e820: update [mem 0x00000000-0x
                                00000fff] usable ==> reserved
   640.00K  1023.99K   384.00K  [    0.005311] e820: remove [mem 0x000a0000-0x
                                000fffff] usable
  3063.00M  4095.99M  1033.00M  [    0.006110] e820: update [mem 0xbf700000-0x
                                ffffffff] usable ==> reserved
   992.14K   992.15K    16.00B  [    0.014355] found SMP MP-table at [mem 0x00
                                0f8090-0x000f809f]
   868.88M   882.41M    13.52M  [    0.015338] RAMDISK: [mem 0x364e3000-0x3726
                                8fff]
  3062.87M  3062.87M   244.00B  [    0.015445] ACPI: Reserving FACP table memo
                                ry at [mem 0xbf6dfc04-0xbf6dfcf7]
  3062.84M  3062.87M    26.36K  [    0.015447] ACPI: Reserving DSDT table memo
                                ry at [mem 0xbf6d9217-0xbf6dfb8f]
  3062.88M  3062.88M    64.00B  [    0.015449] ACPI: Reserving FACS table memo
                                ry at [mem 0xbf6e2fc0-0xbf6e2fff]
  3062.88M  3062.88M    64.00B  [    0.015451] ACPI: Reserving FACS table memo
                                ry at [mem 0xbf6e2fc0-0xbf6e2fff]
  3062.87M  3062.87M   104.00B  [    0.015452] ACPI: Reserving APIC table memo
                                ry at [mem 0xbf6dfcf8-0xbf6dfd5f]
  3062.87M  3062.87M    56.00B  [    0.015454] ACPI: Reserving HPET table memo
                                ry at [mem 0xbf6dfd60-0xbf6dfd97]
  3062.87M  3062.87M    60.00B  [    0.015456] ACPI: Reserving MCFG table memo
                                ry at [mem 0xbf6dfd98-0xbf6dfdd3]
  3062.87M  3062.87M   374.00B  [    0.015458] ACPI: Reserving SLIC table memo
                                ry at [mem 0xbf6dfdd4-0xbf6dff49]
  3062.87M  3062.87M    38.00B  [    0.015459] ACPI: Reserving TMOR table memo
                                ry at [mem 0xbf6dff4a-0xbf6dff6f]
  3062.87M  3062.87M   104.00B  [    0.015461] ACPI: Reserving APIC table memo
                                ry at [mem 0xbf6dff70-0xbf6dffd7]
  3062.87M  3062.87M    40.00B  [    0.015463] ACPI: Reserving BOOT table memo
                                ry at [mem 0xbf6dffd8-0xbf6dffff]
  3062.84M  3062.84M   285.00B  [    0.015465] ACPI: Reserving SSDT table memo
                                ry at [mem 0xbf6d90fa-0xbf6d9216]
  3062.84M  3062.84M   291.00B  [    0.015466] ACPI: Reserving SSDT table memo
                                ry at [mem 0xbf6d8fd7-0xbf6d90f9]
  3062.84M  3062.84M   647.00B  [    0.015468] ACPI: Reserving SSDT table memo
                                ry at [mem 0xbf6d8482-0xbf6d8708]
  3062.84M  3062.84M   180.00B  [    0.015470] ACPI: Reserving SSDT table memo
                                ry at [mem 0xbf6d83ce-0xbf6d8481]
  3062.84M  3062.84M  1332.00B  [    0.015472] ACPI: Reserving SSDT table memo
                                ry at [mem 0xbf6d7e9a-0xbf6d83cd]
  4096.00B    15.99M    15.99M  [    0.015519]   DMA      [mem 0x0000000000001
                                000-0x0000000000ffffff]
    16.00M  4095.99M  4080.00M  [    0.015522]   DMA32    [mem 0x0000000001000
                                000-0x00000000ffffffff]
  4096.00M  5119.99M  1024.00M  [    0.015525]   Normal   [mem 0x0000000100000
                                000-0x000000013fffffff]
  4096.00B   635.99K   632.00K  [    0.015530]   node   0: [mem 0x000000000000
                                1000-0x000000000009efff]
  1024.00K  3062.81M  3061.81M  [    0.015532]   node   0: [mem 0x000000000010
                                0000-0x00000000bf6cffff]
  4096.00M  5119.99M  1024.00M  [    0.015534]   node   0: [mem 0x000000010000
                                0000-0x000000013fffffff]
  4096.00B  5119.99M  5119.99M  [    0.015536] Initmem setup node 0 [mem 0x000
                                0000000001000-0x000000013fffffff]
  3064.00M  3071.99M  8192.00K  [    0.049696] Reserving Intel graphics memory
                                 at [mem 0xbf800000-0xbfffffff]
     0.00B  4095.00B  4096.00B  [    0.050105] PM: hibernation: Registered nos
                                ave memory: [mem 0x00000000-0x00000fff]
   636.00K   639.99K  4096.00B  [    0.050108] PM: hibernation: Registered nos
                                ave memory: [mem 0x0009f000-0x0009ffff]
   640.00K   879.99K   240.00K  [    0.050110] PM: hibernation: Registered nos
                                ave memory: [mem 0x000a0000-0x000dbfff]
   880.00K  1023.99K   144.00K  [    0.050111] PM: hibernation: Registered nos
                                ave memory: [mem 0x000dc000-0x000fffff]
  3062.81M  3062.87M    64.00K  [    0.050113] PM: hibernation: Registered nos
                                ave memory: [mem 0xbf6d0000-0xbf6dffff]
  3062.87M  3062.88M    12.00K  [    0.050115] PM: hibernation: Registered nos
                                ave memory: [mem 0xbf6e0000-0xbf6e2fff]
  3062.88M  3071.99M  9332.00K  [    0.050117] PM: hibernation: Registered nos
                                ave memory: [mem 0xbf6e3000-0xbfffffff]
  3072.00M  3583.99M   512.00M  [    0.050118] PM: hibernation: Registered nos
                                ave memory: [mem 0xc0000000-0xdfffffff]
  3584.00M  3839.99M   256.00M  [    0.050120] PM: hibernation: Registered nos
                                ave memory: [mem 0xe0000000-0xefffffff]
  3840.00M  4075.99M   236.00M  [    0.050121] PM: hibernation: Registered nos
                                ave memory: [mem 0xf0000000-0xfebfffff]
  4076.00M  4076.06M    64.00K  [    0.050123] PM: hibernation: Registered nos
                                ave memory: [mem 0xfec00000-0xfec0ffff]
  4076.06M  4076.99M   960.00K  [    0.050124] PM: hibernation: Registered nos
                                ave memory: [mem 0xfec10000-0xfecfffff]
  4077.00M  4077.07M    80.00K  [    0.050126] PM: hibernation: Registered nos
                                ave memory: [mem 0xfed00000-0xfed13fff]
  4077.07M  4077.10M    24.00K  [    0.050127] PM: hibernation: Registered nos
                                ave memory: [mem 0xfed14000-0xfed19fff]
  4077.10M  4077.10M  8192.00B  [    0.050129] PM: hibernation: Registered nos
                                ave memory: [mem 0xfed1a000-0xfed1bfff]
  4077.10M  4077.56M   464.00K  [    0.050131] PM: hibernation: Registered nos
                                ave memory: [mem 0xfed1c000-0xfed8ffff]
  4077.56M  4077.99M   448.00K  [    0.050132] PM: hibernation: Registered nos
                                ave memory: [mem 0xfed90000-0xfedfffff]
  4078.00M  4078.00M  4096.00B  [    0.050134] PM: hibernation: Registered nos
                                ave memory: [mem 0xfee00000-0xfee00fff]
  4078.00M  4079.99M  2044.00K  [    0.050135] PM: hibernation: Registered nos
                                ave memory: [mem 0xfee01000-0xfeffffff]
  4080.00M  4095.99M    16.00M  [    0.050137] PM: hibernation: Registered nos
                                ave memory: [mem 0xff000000-0xffffffff]
  3072.00M  3583.99M   512.00M  [    0.050140] [mem 0xc0000000-0xdfffffff] ava
                                ilable for PCI devices
  3062.87M  3062.88M    12.00K  [    0.291821] ACPI: PM: Registering ACPI NVS
                                region [mem 0xbf6e0000-0xbf6e2fff] (12288 byte
                                s)
  3584.00M  3839.99M   256.00M  [    0.294577] PCI: MMCONFIG for domain 0000 [
                                bus 00-ff] at [mem 0xe0000000-0xefffffff] (bas
                                e 0xe0000000)
  3584.00M  3839.99M   256.00M  [    0.294585] PCI: MMCONFIG at [mem 0xe000000
                                0-0xefffffff] reserved as E820 entry
     0.00B  3319.00B  3320.00B  [    0.557645] pci_bus 0000:00: root bus resou
                                rce [io  0x0000-0x0cf7 window]
  3328.00B    63.99K    60.75K  [    0.557649] pci_bus 0000:00: root bus resou
                                rce [io  0x0d00-0xffff window]
   640.00K   767.99K   128.00K  [    0.557653] pci_bus 0000:00: root bus resou
                                rce [mem 0x000a0000-0x000bffff window]
   832.00K   879.99K    48.00K  [    0.557662] pci_bus 0000:00: root bus resou
                                rce [mem 0x000d0000-0x000dbfff window]
  3072.00M  3583.99M   512.00M  [    0.557666] pci_bus 0000:00: root bus resou
                                rce [mem 0xc0000000-0xdfffffff window]
  3840.00M  4075.99M   236.00M  [    0.557670] pci_bus 0000:00: root bus resou
                                rce [mem 0xf0000000-0xfebfffff window]
  4032.00M  4032.99M  1024.00K  [    0.557893] pci 0000:00:02.0: reg 0x10: [me
                                m 0xfc000000-0xfc0fffff 64bit]
  3328.00M  3583.99M   256.00M  [    0.557904] pci 0000:00:02.0: reg 0x18: [me
                                m 0xd0000000-0xdfffffff 64bit pref]
  6144.00B  6151.00B     8.00B  [    0.557912] pci 0000:00:02.0: reg 0x20: [io
                                  0x1800-0x1807]

The script is attached.