-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.zig
More file actions
32 lines (25 loc) · 1.13 KB
/
Copy pathexample.zig
File metadata and controls
32 lines (25 loc) · 1.13 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
//! A tiny demonstration: build a hardware-reduced ACPI table set with the
//! producer API, then discover and read it back through the consumer API.
const std = @import("std");
const almanac = @import("almanac");
pub fn main(init: std.process.Init) !void {
const io = init.io;
var buf: [1024]u8 align(16) = undefined;
var b = almanac.Builder.init(&buf, @intFromPtr(&buf));
const fadt_phys = try b.fadt(.{ .dsdt_phys = 0x2_0000, .hw_reduced = true, .sci_int = 9 });
const xsdt_phys = try b.xsdt(&.{fadt_phys});
const rsdp_phys = try b.rsdp(xsdt_phys);
const Tables = almanac.TablesGeneric(almanac.OffsetMapper);
const tabs = try Tables.init(.{ .offset = 0 }, rsdp_phys);
var stdout_buf: [256]u8 = undefined;
var stdout = std.Io.File.stdout().writer(io, &stdout_buf);
const w = &stdout.interface;
try w.print("discovered {d} table(s) via {s}\n", .{
tabs.count(),
if (tabs.usesXsdt()) "XSDT" else "RSDT",
});
if (try tabs.findAs(almanac.Fadt)) |fadt| {
try w.print("FADT: hw_reduced={}, dsdt=0x{x}\n", .{ fadt.isHwReduced(), fadt.preferredDsdt() });
}
try w.flush();
}