removing init heartbeat in releases
This commit is contained in:
@@ -194,8 +194,9 @@ fn addKernel(
|
|||||||
/// Assemble the bootable FAT32 image (the in-repo Python builder) holding what
|
/// Assemble the bootable FAT32 image (the in-repo Python builder) holding what
|
||||||
/// the firmware and loader need off the ESP: the EFI stub, `kernel`, `init`, and
|
/// the firmware and loader need off the ESP: the EFI stub, `kernel`, `init`, and
|
||||||
/// the initial-ramdisk. Factored so the serial-enabled `run-x86-64` variant can
|
/// the initial-ramdisk. Factored so the serial-enabled `run-x86-64` variant can
|
||||||
/// bundle its own kernel while sharing the (serial-independent) loader, init, and
|
/// bundle its own serial kernel while sharing the loader, init, and ramdisk — all
|
||||||
/// ramdisk. Returns the image's LazyPath.
|
/// built once per invocation (the loader's boot breadcrumbs and init's heartbeat
|
||||||
|
/// both follow the top-level -Dserial). Returns the image's LazyPath.
|
||||||
fn addBootImage(
|
fn addBootImage(
|
||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
kernel_bin: std.Build.LazyPath,
|
kernel_bin: std.Build.LazyPath,
|
||||||
@@ -463,6 +464,14 @@ pub fn build(b: *std.Build) void {
|
|||||||
// linked into the kernel's user region against the `runtime` runtime library, and
|
// linked into the kernel's user region against the `runtime` runtime library, and
|
||||||
// started in ring 3 by the kernel's user-ELF loader.
|
// started in ring 3 by the kernel's user-ELF loader.
|
||||||
const init_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "init", "system/services/init/init.zig");
|
const init_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "init", "system/services/init/init.zig");
|
||||||
|
// init reads the same `serial` flag the kernel does: its liveness heartbeat is a
|
||||||
|
// serial/test-build diagnostic (the QEMU harness's init tests assert on it, and
|
||||||
|
// -Dserial images emit it), so a flashable image runs a purely event-driven PID 1
|
||||||
|
// that wakes only for real work. The test harness builds with -Dserial=true, so
|
||||||
|
// the heartbeat stays present under test.
|
||||||
|
const init_options = b.addOptions();
|
||||||
|
init_options.addOption(bool, "serial", serial);
|
||||||
|
programModule(init_exe).addImport("build_options", init_options.createModule());
|
||||||
const init_install = b.addInstallArtifact(init_exe, .{ .dest_dir = .{ .override = .{ .custom = "system/services" } } });
|
const init_install = b.addInstallArtifact(init_exe, .{ .dest_dir = .{ .override = .{ .custom = "system/services" } } });
|
||||||
b.getInstallStep().dependOn(&init_install.step);
|
b.getInstallStep().dependOn(&init_install.step);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const runtime = @import("runtime");
|
const runtime = @import("runtime");
|
||||||
const power = runtime.power_protocol;
|
const power = runtime.power_protocol;
|
||||||
|
const build_options = @import("build_options");
|
||||||
|
|
||||||
/// Where the kernel boot log is persisted on the USB FAT volume — an 8.3 name at
|
/// Where the kernel boot log is persisted on the USB FAT volume — an 8.3 name at
|
||||||
/// the mount root (see system/services/log-flush). init writes it at shutdown;
|
/// the mount root (see system/services/log-flush). init writes it at shutdown;
|
||||||
@@ -90,10 +91,13 @@ pub fn main() void {
|
|||||||
// triggers the same shutdown path.
|
// triggers the same shutdown path.
|
||||||
subscribePower();
|
subscribePower();
|
||||||
|
|
||||||
// A re-arming timer drives the liveness heartbeat: proof PID 1 is alive
|
// A re-arming timer drives the liveness heartbeat — proof PID 1 is alive (the
|
||||||
// (the init test's marker) while the loop stays free to receive signals,
|
// init test's marker) and a -Dserial diagnostic. It is a serial/test-build-only
|
||||||
// power events, and children's exit notifications.
|
// concern: a flashable (serial-off) image runs a purely event-driven PID 1 that
|
||||||
_ = runtime.system.timerOnce(supervision_endpoint, 1000);
|
// wakes only for real work (signals, power events, children's exits), never for a
|
||||||
|
// periodic beat. `build_options.serial` is comptime, so the heartbeat — its timer
|
||||||
|
// and the handler below — folds away entirely when serial is off.
|
||||||
|
if (build_options.serial) _ = runtime.system.timerOnce(supervision_endpoint, 1000);
|
||||||
|
|
||||||
var receive: [power.message_maximum]u8 = undefined;
|
var receive: [power.message_maximum]u8 = undefined;
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -102,7 +106,7 @@ pub fn main() void {
|
|||||||
if (signals.has(.terminate)) shutDown();
|
if (signals.has(.terminate)) shutDown();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (got.isTimer()) {
|
if (build_options.serial and got.isTimer()) {
|
||||||
_ = runtime.system.write("/system/services/init: heartbeat\n");
|
_ = runtime.system.write("/system/services/init: heartbeat\n");
|
||||||
_ = runtime.system.timerOnce(supervision_endpoint, 1000);
|
_ = runtime.system.timerOnce(supervision_endpoint, 1000);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user