kccb.c — Kernel CCB and firmware CCB

The Kernel CCB (host to firmware) and the Firmware CCB (firmware to host).

Both are rings of fixed-size commands with a control block of read and write offsets and a wrap mask. The firmware owns the KCCB read offset and the FWCCB write offset.

static void clock_change(void)

Handle CORECLKSPEEDCHANGE.

Takes the new clock from the runtime configuration, recomputes the timer rates and re-correlates the GPU and host time. A zero clock is ignored.

static uint32_t kccb_handle(const struct kccb_cmd *cmd)

Execute one Kernel CCB command.

Commands without the ROGUE_CMD_MAGIC_DWORD in the upper half of cmd_type are traced and skipped. Kicks, cleanups, MMU and SLC cache operations, power requests, force updates, clock changes, state-flag changes and free-list grow updates are handled; the other known commands are acknowledged without action.

Parameters:
  • cmd – The command.

Returns:

KCCB_RTN_CMD_EXECUTED, plus the flags the handler adds (for example KCCB_RTN_CLEANUP_BUSY).

Return type:

The return-slot value

void kccb_process(void)

Execute every pending Kernel CCB command.

Runs with interrupts masked. For each command it writes the return slot, counts it in osdata, and advances the read offset after a write barrier. Stops early once a command powers the firmware off. Interrupts the host once if any command was executed.

bool fwccb_send(const struct fwccb_cmd *cmd)

Send a command to the host through the Firmware CCB.

When the ring is full it interrupts the host and waits (10 µs at a time) until the host has read an entry.

Parameters:
  • cmd – The command to copy into the ring.

Returns:

true when sent, false when the FWCCB is not known yet.