Created
May 13, 2014 18:57
-
-
Save CrackerJackMack/a2316bc0a0472c242879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_regions(datafile): | |
regions = [] | |
for line in datafile.readlines(): | |
fields = line.strip().split(' ') | |
if not fields or not fields[0]: | |
continue | |
if fields[3] == '[mem': | |
start, end = fields[4].split('-') | |
state = ' '.join(fields[5:]) | |
elif fields[2] == 'e820:' and fields[-1][-1] == ']': | |
state = ' '.join(fields[3:5]) | |
start, end = fields[7].split('-') | |
elif fields[2] == 'e820:' and fields[3] == 'update': | |
state = fields[-1] | |
start, end = fields[5].split('-') | |
else: | |
continue | |
regions.append((int(start, 16), int(end[:-1], 16), state)) | |
return tuple(regions) | |
def to_mb(byte): | |
return float(byte)/1024/1024 | |
def main(*args): | |
source = args[1] | |
with open(source, 'r') as datafile: | |
regions = read_regions(datafile) | |
for segment in regions: | |
print("{start:.2f}MB through {end:.2f}MB ({total:.2f}MB) is {state}" | |
.format(start=to_mb(segment[0]), | |
end=to_mb(segment[1]), | |
state=segment[2], | |
total=to_mb(segment[1]-segment[0]))) | |
total = 0.0 | |
for segment in [seg for seg in regions if seg[2] == 'usable']: | |
total += to_mb(segment[1] - segment[0]) | |
print("\n\ntotal addressable memory from e820 map: {0:.2f}".format(total)) | |
if __name__ == "__main__": | |
import sys | |
main(*sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ 0.000000] e820: BIOS-provided physical RAM map: | |
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009bbff] usable | |
[ 0.000000] BIOS-e820: [mem 0x000000000009bc00-0x000000000009ffff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000ae491fff] usable | |
[ 0.000000] BIOS-e820: [mem 0x00000000ae492000-0x00000000ae4e6fff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000ae4e7000-0x00000000ae8d9fff] ACPI NVS | |
[ 0.000000] BIOS-e820: [mem 0x00000000ae8da000-0x00000000aee2cfff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000aee2d000-0x00000000aee2dfff] usable | |
[ 0.000000] BIOS-e820: [mem 0x00000000aee2e000-0x00000000af033fff] ACPI NVS | |
[ 0.000000] BIOS-e820: [mem 0x00000000af034000-0x00000000af451fff] usable | |
[ 0.000000] BIOS-e820: [mem 0x00000000af452000-0x00000000af7f2fff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000af7f3000-0x00000000af7fffff] usable | |
[ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000fec10000-0x00000000fec10fff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000fec20000-0x00000000fec20fff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000fed00000-0x00000000fed00fff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000fed61000-0x00000000fed70fff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000fed80000-0x00000000fed8ffff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x00000000fef00000-0x00000000ffffffff] reserved | |
[ 0.000000] BIOS-e820: [mem 0x0000000100001000-0x000000064effffff] usable | |
[ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved | |
[ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable | |
[ 0.000000] e820: last_pfn = 0x64f000 max_arch_pfn = 0x400000000 | |
[ 0.000000] e820: update [mem 0xaf800000-0xffffffff] usable ==> reserved | |
[ 0.000000] e820: last_pfn = 0xaf800 max_arch_pfn = 0x400000000 | |
[ 0.000000] e820: [mem 0xaf800000-0xfebfffff] available for PCI devices | |
[ 0.000000] Aperture pointing to e820 RAM. Ignoring. | |
[ 0.443638] e820: reserve RAM buffer [mem 0x0009bc00-0x0009ffff] | |
[ 0.443640] e820: reserve RAM buffer [mem 0xae492000-0xafffffff] | |
[ 0.443642] e820: reserve RAM buffer [mem 0xaee2e000-0xafffffff] | |
[ 0.443643] e820: reserve RAM buffer [mem 0xaf452000-0xafffffff] | |
[ 0.443644] e820: reserve RAM buffer [mem 0xaf800000-0xafffffff] | |
[ 0.443646] e820: reserve RAM buffer [mem 0x64f000000-0x64fffffff] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.00MB through 0.61MB (0.61MB) is usable | |
0.61MB through 0.62MB (0.02MB) is reserved | |
0.88MB through 1.00MB (0.12MB) is reserved | |
1.00MB through 2788.57MB (2787.57MB) is usable | |
2788.57MB through 2788.90MB (0.33MB) is reserved | |
2788.90MB through 2792.85MB (3.95MB) is ACPI NVS | |
2792.85MB through 2798.18MB (5.32MB) is reserved | |
2798.18MB through 2798.18MB (0.00MB) is usable | |
2798.18MB through 2800.20MB (2.02MB) is ACPI NVS | |
2800.20MB through 2804.32MB (4.12MB) is usable | |
2804.32MB through 2807.95MB (3.63MB) is reserved | |
2807.95MB through 2808.00MB (0.05MB) is usable | |
4076.00MB through 4076.00MB (0.00MB) is reserved | |
4076.06MB through 4076.07MB (0.00MB) is reserved | |
4076.12MB through 4076.13MB (0.00MB) is reserved | |
4077.00MB through 4077.00MB (0.00MB) is reserved | |
4077.38MB through 4077.44MB (0.06MB) is reserved | |
4077.50MB through 4077.56MB (0.06MB) is reserved | |
4079.00MB through 4096.00MB (17.00MB) is reserved | |
4096.00MB through 25840.00MB (21744.00MB) is usable | |
0.00MB through 0.00MB (0.00MB) is reserved | |
2808.00MB through 4096.00MB (1288.00MB) is reserved | |
2808.00MB through 4076.00MB (1268.00MB) is available for PCI devices | |
0.61MB through 0.62MB (0.02MB) is reserve RAM | |
2788.57MB through 2816.00MB (27.43MB) is reserve RAM | |
2798.18MB through 2816.00MB (17.82MB) is reserve RAM | |
2804.32MB through 2816.00MB (11.68MB) is reserve RAM | |
2808.00MB through 2816.00MB (8.00MB) is reserve RAM | |
25840.00MB through 25856.00MB (16.00MB) is reserve RAM | |
total addressable memory from e820 map: 24536.35 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment