-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathfirmware_memmap.c
More file actions
36 lines (34 loc) · 1.63 KB
/
Copy pathfirmware_memmap.c
File metadata and controls
36 lines (34 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// This file is part of KASLD - https://github.com/bcoles/kasld
//
// Emit the firmware System RAM map (/sys/firmware/memmap) as PHYS RAM extents
// (pos=extent), one per System RAM span. This is the authoritative, COMPLETE
// physical memory topology; firmware_memmap_holes and ram_map_phys_exclude read
// it from the engine's coverings[] — a per-source store the cross-source merge
// bypasses, so the gaps between extents are preserved faithfully. Both rules
// key on this component's origin, so the binary name ("firmware_memmap") is
// load-bearing. As a covering source the WHOLE map must be emitted: a partial
// map would synthesize false gaps between extents.
// ---
// <bcoles@gmail.com>
#include "include/kasld/firmware_memmap.h"
#include "include/kasld/api.h"
KASLD_EXPLAIN("Reads /sys/firmware/memmap (the authoritative firmware System "
"RAM map) and emits each System RAM span as a PHYS RAM extent. "
"firmware_memmap_holes keys on this component's origin. "
"World-readable, no privileges.");
KASLD_META("method:parsed\n"
"phase:inference\n"
"discloses:physical\n");
int main(void) {
struct kasld_ram_extent ext[128];
int n = kasld_load_ram_extents(ext, 128);
/* n < 0: the map could not be captured completely (overflow, parse failure,
* or word truncation). A partial covering would fabricate false gaps that
* gap-carving rules turn into unsound exclusions, so emit nothing. */
if (n < 0)
return 0;
for (int i = 0; i < n; i++)
kasld_result_extent(KASLD_TYPE_PHYS, REGION_RAM, ext[i].lo, ext[i].hi, NULL,
CONF_PARSED);
return 0;
}