Flash 35 lines
// Type-position `align(N)`: the alignment guarantee rides the pointer or
// slice TYPE, so every consumer keeps it — `[]align(16) u8`,
// `*align(4) mut T` — composing with `mut`/`volatile`/sentinels (Zig's
// slot: directly after the prefix, before the qualifiers). The file-scope
// bind `align(N)` lands with it (`var pool [N]u8 align(4096) = …` — the
// array-repetition example's dropped qualifier, now spellable).
//
// Lives in examples/register/ (post-v0.5 grammar — the frozen stage0
// bootstrap compiler cannot parse it; gated by `zig build fixpoint`).
pub const PAGE usize = 4096
// The kernel page pool: page-aligned storage, alignment pinned at the bind.
var pool [16 * PAGE]u8 align(4096) = undefined
// A linker-script symbol whose alignment the script guarantees.
extern var _vectors u8 align(2048)
// The guarantee in type position: a page handed out keeps its alignment.
pub fn page(idx usize) *align(4096) mut [PAGE]u8 {
return #ptrCast(#alignCast(&pool[idx * PAGE]))
}
// An MMIO window: aligned AND volatile — the align precedes the qualifiers.
pub fn mmio(base usize) [*]align(16) mut volatile u32 {
return #ptrFromInt(base)
}
// A cache-line-aligned destination, the alignment enforced on every caller.
pub fn zero(buf []align(64) mut u8) {
for *b in buf {
b.* = 0
}
}