Files
geramyloveless 66593d0727 Driver events read in the unified log; Stop and power changes are events
Upstream errors (printk level 3 and worse) went to the unified log as
IOLog("mac.linuxgpu: EVENT %s"), and the DMA seam's events as IOLog("%s"):
both arrive as <private>. They now go through os_log with %{public}s, as
MACLINUXGPU_EVENT already did. printk.c cannot include os/log.h next to
the Linux headers, so the dext registers the sink (klog_set_event_sink)
from a constructor; the level filter is unchanged, so nothing new reaches
the unified log in release beyond events. dext_close's refusal is logged
with literal text instead of a %s argument.

New events, each rare: the driver's Stop (DriverKit has no willTerminate;
Stop is how the driver learns that it or its PCI provider is being
terminated) with the session state, FinishStop letting go of the provider,
and every SetPowerState with the power state it arrived in. A device that
left the bus was already an event.

test-klog registers a sink as the dext does; the session-shutdown fixture's
Stop section bound grows by ten lines for the Stop event.
2026-10-06 13:16:52 -07:00

35 lines
1.6 KiB
C

#ifndef LINUXU_RT_KLOG_H
#define LINUXU_RT_KLOG_H
#include <stddef.h>
#include <stdint.h>
#define LINUXU_KLOG_CAPACITY (16u * 1024u)
#define LINUXU_KLOG_MESSAGE_CAPACITY 2048u
#ifdef __cplusplus
extern "C" {
#endif
/* Read retained printk bytes without changing the log. *cursor is the next
* byte requested and advances past the bytes returned; *end receives the
* snapshot's exclusive end sequence (if nonnull). Neither output is a C
* string. A stale cursor clamps to the oldest retained byte; a future cursor
* clamps to end. The caller detects clamping by comparing the original cursor
* with (*cursor - returned_length). With capacity zero, out may be NULL and
* the cursor is clamped without consuming bytes. NULL cursor, or NULL out with
* nonzero capacity, returns zero without changing outputs. No log reset occurs
* during driver probe or cleanup. Messages exceeding the per-record capacity
* end in an explicit truncation marker. */
size_t klog_read(uint64_t *cursor, char *out, size_t capacity, uint64_t *end);
/* Append already formatted bytes without invoking a platform log sink or the
* printk level filter. The caller supplies a readable range; no terminator is
* required or added. Oversized input retains its final ring-capacity bytes.
* This is safe for platform log helpers whose sinks can reenter diagnostics. */
void klog_write(const char *text, size_t length);
/* DriverKit build only: where errors and worse also go (the unified log,
* registered by the dext before any driver code runs). */
void klog_set_event_sink(void (*sink)(const char *text));
#ifdef __cplusplus
}
#endif
#endif