← Blog
0.7.0 · KERNEL · HAL

HAL Batch 6 — ADMAC DMA/Mic/Lid + PPC I2C/DBDMA/CUDA-ADB (sigil-kernel fcf1de5→3679a63)

June 22, 2026 · sigil-kernel fcf1de5 + 40b262e + 3679a63 · Sigil-Docs
kernel hal apple-silicon powerpc hardware audio 0.7.0

Three more sigil-kernel commits extend the arch matrix from 0x4DA000 to 0x4DF000, adding 6 HAL seams: Apple ADMAC audio DMA (ring-buffer engine), KeyWest I2C controller, Apple microphone array HAL, PPC descriptor-based DMA (DBDMA), Apple laptop lid sensor state machine, and G3/G4 CUDA/ADB keyboard protocol.


fcf1de5 — ADMAC DMA + PPC I2C

apple_dma.sg
0x4DA000
Apple ADMAC audio DMA controller. The ADMAC (Audio DMA Controller) is the M-series DMA engine for speaker/mic/AME audio data movement. 8 channels, each with buf_addr, buf_size, and head pointer. dma_init(): zeros all channel state. dma_ch_set(ch, addr, size): configures channel ch with buffer address and size. dma_ch_start(ch): marks channel as running; sets ch_running=1. dma_ch_stop(ch): halts channel; sets ch_running=0. dma_ch_advance(ch, n): advances head pointer by n bytes — linear: head += n when no wrap; wrap-around: head wraps to (head + n) % buf_size when head reaches buf_size. Wrap verified: 1 KB ring wraps at 1024-byte boundary. dma_ch_head(ch): returns current head pointer. DMA init=1 run=1 wrp=1 K.
ppc_i2c.sg
0x4DB000
KeyWest I2C bus controller. KeyWest is the I/O ASIC on G3/G4 Macs; its I2C controller handles PMU, display, and sensor communication. i2c_init(speed): sets bus speed — 0=standard (100 kHz), 1=fast (400 kHz), 2=fast-plus (1 MHz). i2c_addr_set(addr): sets the 7-bit target address (bit 0 is direction: 0=write, 1=read). i2c_write(byte): writes one byte to the bus; increments TX counter; sets last_ack=1 if ACK received, last_ack=0 on NACK. i2c_read(): reads one byte from the bus; increments RX counter. i2c_nack_logged(): returns the address of the last NACK'd device (for diagnostics — NACK from an unexpected address is a bus fault). i2c_tx_count() / i2c_rx_count(): return total bytes transferred. I2C init=1 rw=1 nak=1 K.

40b262e — Microphone + PPC DBDMA

apple_mic.sg
0x4DC000
M-series microphone array / audio input HAL. M-series Macs have a built-in microphone array (1–3 mics depending on model), headphone-jack mic via audio codec, and optional Studio Display mic. mic_init(): zeros all mic state. mic_power(on): powers the mic array on or off. mic_stream_start(sample_rate, bit_depth): starts capture — sample_rate in Hz (44100, 48000, 96000, 192000); bit_depth 16 or 24. mic_stream_stop(): halts capture. mic_mute(on): mutes/unmutes mic (separate from power — mute keeps the stream active with silence). mic_gain_set(db_x10): sets gain in tenths of a dB (e.g., 120 = 12.0 dB). mic_peak_level(): returns peak sample value from the current buffer (signed 24-bit range). mic_overload_count(): returns number of clamp events (samples that hit full-scale — indicates gain too high). MIC init=1 str=1 lvl=1 K.
ppc_dbdma.sg
0x4DD000
Descriptor-Based DMA channel controller. DBDMA is the DMA engine on G3/G4 Macs — used for IDE, SCSI, audio, FireWire data movement. 8 independent channels. dbdma_init(): zeros all channel state. dbdma_ch_run(ch): starts channel ch; sets ch_state=DBDMA_RUN. dbdma_ch_pause(ch): pauses channel; sets ch_state=DBDMA_PAUSE. dbdma_ch_resume(ch): resumes from PAUSE → RUN. dbdma_ch_flush(ch): flushes in-flight transfers and resets ch_bytes=0. dbdma_ch_transfer(ch, n): simulates transferring n bytes — increments ch_bytes by n (only when ch_state=RUN). dbdma_ch_bytes(ch): returns total bytes transferred. Independent channel operation verified: run/pause/resume/flush per-channel with no cross-channel interference. DBD init=1 run=1 pse=1 K.

3679a63 — Lid sensor + CUDA/ADB keyboard

apple_lid.sg
0x4DE000
Hall-effect lid sensor state machine. MacBooks detect lid open/close via a Hall-effect magnetic sensor. On lid close, the kernel blanks the internal display, arms sleep, and routes the lid-wake IRQ. lid_init(): sets initial state LID_OPEN=1, clears all counters. lid_event(is_close): processes a lid event — on close: sets lid_open=0, increments close_count, blanks display (display_on=0), arms sleep; on open: sets lid_open=1, increments open_count, enables display (display_on=1), cancels sleep. lid_is_open() / lid_display_on() / lid_sleep_armed(): read current state. lid_clamshell_mode(): returns 1 if in clamshell mode — lid closed but clamshell_active=1 (set when an external display is connected while lid is closed; suspends sleep arm even with lid down). lid_clamshell_set(active): sets clamshell mode. LID init=1 cls=1 clm=1 K.
ppc_cuda_kbd.sg
0x4DF000
CUDA/ADB keyboard protocol. ADB (Apple Desktop Bus) is the keyboard/mouse bus on G3/G4 Macs. CUDA is the embedded controller that mediates ADB. cuda_init(adb_addr): sets the ADB address for the keyboard (typically 2). cuda_kbd_talk(keycode, flags): encodes a TALK command from the keyboard — talk_hi = keycode, talk_lo = flags (modifier bits: bit 0=shift, bit 1=ctrl, bit 2=option/alt, bit 3=cmd). cuda_kbd_listen(led_state): encodes a LISTEN command to the keyboard for LED state (bit 0=caps_lock, bit 1=num_lock, bit 2=scroll_lock). cuda_talk_cmd(): returns the encoded TALK command: (adb_addr << 4) | 0x0C — register 0 talk. cuda_key_held(keycode): returns 1 if the keycode is currently in the held-keys buffer. (Bug fixed: 0x00 hex literal replaced with 0 — Sigil hex literal rule.) CKB init=1 key=1 led=1 K.

Arch matrix now at 0x4DF000. Batch 6 rounds out the audio and I/O tier: ADMAC ring-buffer DMA and mic arrays on Apple Silicon, DBDMA and I2C on PPC, lid state machine for sleep/clamshell, and ADB keyboard via CUDA.