aboutsummaryrefslogtreecommitdiff
path: root/src/hwinfo.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/hwinfo.zig')
-rw-r--r--src/hwinfo.zig13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/hwinfo.zig b/src/hwinfo.zig
index 8e937c2..649f7c6 100644
--- a/src/hwinfo.zig
+++ b/src/hwinfo.zig
@@ -42,6 +42,16 @@ pub const DevKind = enum(u32) {
else => false,
};
}
+
+ pub fn isMemoryMapped(self: DevKind) bool {
+ return switch (self) {
+ .cpus => false,
+ .plic => true,
+ .pcie => true,
+ .pci => true,
+ _ => false,
+ };
+ }
};
pub const Dev = extern struct {
@@ -132,6 +142,7 @@ pub fn byAddress(reg_addr: usize, only_user_manageable: bool) !?Dev {
var it = try iterator();
while (it.next()) |device| {
const authorized = !only_user_manageable or device.kind.isUserManageable();
- if (device.reg.addr == reg_addr and authorized) return device;
+ const eligible = device.kind.isMemoryMapped() and authorized;
+ if (device.reg.addr == reg_addr and eligible) return device;
} else return null;
}