qemu-peripheral-modeling
Skill57 starsChanged 4 months agoMITView on GitHub
Use for QEMU peripheral, accelerator, MMIO, qdev, or SysBusDevice modeling with register contracts, an explicit register framework decision, and qtest-backed verification.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- qemu-agent-feedbackSkill
- qemu-board-modelingSkill
- qemu-boot-runSkill
- qemu-buildSkill
- qemu-debugSkill
- qemu-imageSkill
- qemu-kernel-buildSkill
- qemu-linux-bootSkill
- qemu-model-verificationSkill
- qemu-qtestSkill
- qemu-register-extractionSkill
- qemu-rst-documentationSkill
- qemu-tcg-backendSkill
- qemu-tcg-frontendSkill
- qemu-uboot-buildSkill
- qemu-workflowSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
30 rules. About 0 are common, 19 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 24
Before changing source or mutable artifacts, record the workspace root, revision, git status --short, pre-existing changes, goal, scope, …
- Very specific: line 31
Keep QEMU builds under source-root builds/build-<target>/.
- Distinctive: line 42
When facts come from drivers, datasheets, firmware, or regfiles, extract a source-cited register contract before modeling.
- Distinctive: line 47
Use traces or workload evidence for integration claims and state what remains unproven.
- Distinctive: line 74
When the source of truth is external to QEMU, do not begin modeling from memory or from a partial driver skim.
- Distinctive: line 78
Default shape unless nearby code uses a clearer convention:
- Distinctive: line 87
Do not put register side effects in board files.
- Distinctive: line 91
Before designing a guest-visible control/status register bank:
- Distinctive: line 93
Read applicable policy files present in the target QEMU workspace.
- Distinctive: line 94
If they do not decide, use the user's explicit compatible framework direction.
- Distinctive: line 96
If neither decides, inspect nearby devices in the same subsystem for a clear maintained convention.
- Very specific: line 101
Stop at the first decisive input.
- Very specific: line 109
read include/hw/core/register.h for the current RegisterAccessInfo, RegisterInfo, RegisterInfoArray, and register_init_block* API.
- Very specific: line 110
read include/hw/core/registerfields.h for the current register/field macros.
- Very specific: line 111
search the checked-out tree for RegisterAccessInfo, register_init_block8, register_init_block32, register_init_block64, …
- Distinctive: line 112
prefer examples in the same subsystem or nearby architecture before using generic examples.
- Distinctive: line 113
if a named reference path is absent in another QEMU version, re-search by symbol instead of assuming the old path.
- Very specific: line 135
Do not put register offsets, field macros, RegisterAccessInfo tables, backing storage, RegisterInfo arrays, or register semantics in a …
- Very specific: line 141
When using RegisterInfo, use its hooks deliberately:
- Distinctive: line 143
use pre-write hooks to filter or transform a write before storage.
- Very specific: line 144
use post-write hooks for IRQ/status/timer/DMA side effects after storage.
- Distinctive: line 145
use post-read hooks only for guest-visible read side effects.
- Very specific: line 148
When the decision selects RegisterInfo, a separate custom handler is permitted for a non-register data aperture such as a FIFO data port, …
- Distinctive: line 156
Use constants/macros for offsets, masks, shifts, reset values, and IDs.
- Distinctive: line 157
Keep normal read/write callbacks allocation-free.
- Distinctive: line 162
Update status before raising/lowering IRQ.
- Distinctive: line 163
Keep long-running work out of MMIO callbacks.
- Very specific: line 165
Never edit generated files under builds/build-<target>/.
- Distinctive: line 170
Every material peripheral change should have narrow qtest coverage for:
- Distinctive: line 173
read/write masks and reserved bits.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
QEMU Peripheral Modeling
Audit workflow
For non-trivial workspace writes, use a stable
.oh-my-qemu/<task-slug>/ directory and create only needed entries:
.oh-my-qemu/<task-slug>/
├── audit.md # Baseline, scope, decisions, evidence, verification, and gaps
├── commands.md # Redacted commands, working directories, and results
├── logs/ # Decisive build, test, runtime, or diagnostic logs
├── scripts/ # Temporary scripts, probes, parsers, and harnesses
└── output/ # Generated deliverables, dependencies, and non-QEMU binariesBefore changing source or mutable artifacts, record the workspace root,
revision, git status --short, pre-existing changes, goal, scope, and
acceptance checks in audit.md. Log exact redacted commands and results in
commands.md; record revisions, configurations, tool versions, and hashes when
they affect reproducibility. Separate observations from inferences and edit
source only when requested.
Keep QEMU builds under source-root builds/build-<target>/; put third-party
dependencies and non-QEMU binaries in task output/. Before writing audit
artifacts or configuring QEMU in a Git worktree, add .agents/,
.oh-my-qemu/, and builds/ to the repository-local file from
git rev-parse --git-path info/exclude; preserve existing entries and avoid
duplicates. Never stage or commit those directories. At handoff, verify them
absent from git status --short. Report the task directory and unresolved gaps.
Workflow
- Freeze the register, IRQ, DMA, reset, migration, and allowed-path contract.
- When facts come from drivers, datasheets, firmware, or regfiles, extract a source-cited register contract before modeling; do not fill gaps from memory.
- Work in small reviewable source-change rounds and record each round's paths,
verification, review result, and gaps in
audit.md. - Build the affected target and map each modeled behavior to focused qtests.
- Use traces or workload evidence for integration claims and state what remains unproven.
QEMU upstream boundary
QEMU's official GitLab and mailing lists are upstream project channels. A
patch becomes an upstream contribution when sent to the mailing-list recipients
selected through MAINTAINERS; do not prepare or send agent-generated patches
for that submission. Local branches, commits, patch files, pushes, and pull
requests are not by themselves QEMU upstream contributions. Perform those Git
actions only when requested and follow the workspace's Git policy.
Device modeling contract
A real hardware block should be a first-class device. Board code wires topology; device code owns behavior.
For each device, define in audit.md:
- MMIO base(s), size(s), endianness, and accepted access widths;
- register reset values, masks, read/write behavior, W1C bits, aliases, and reserved-bit behavior;
- cross-register dependencies, feature flows, and register-bit combinations needed to enable or observe a function;
- IRQ outputs and level/edge semantics;
- timer, clock, reset, DMA, and bus dependencies;
- migration-visible state vs local caches;
- existing stub/unimplemented boundary;
- reference evidence: datasheet, SDK driver, firmware trace, sibling QEMU device.
When the source of truth is external to QEMU, do not begin modeling from memory or from a partial driver skim. Require a source-cited register contract with register facts, cross-register dependencies, behavioral sequences, conflicts, confidence levels, and qtest candidates.
QEMU object shape
Default shape unless nearby code uses a clearer convention:
SysBusDeviceor the subsystem's existing base class;- one owned
MemoryRegionper register window; - explicit
qemu_irqoutputs; - reset/realize hooks in the local style;
VMStateDescriptionfor guest-visible migratable state;- named properties only for real board/SoC variation.
Do not put register side effects in board files.
Register bank framework decision
Before designing a guest-visible control/status register bank:
- Read applicable policy files present in the target QEMU workspace.
- If they do not decide, use the user's explicit compatible framework direction.
- If neither decides, inspect nearby devices in the same subsystem for a clear maintained convention.
- Select
RegisterInfoor manual MMIO callbacks and record the evidence and rationale in.oh-my-qemu/<task-slug>/audit.md.
Stop at the first decisive input. Use RegisterInfo from the checked-out QEMU
tree as the default when none decides. Manual MMIO callbacks are permitted when
this decision gate justifies them; they are not a failure merely because they
do not use RegisterInfo.
For the RegisterInfo path, use the current tree rather than remembered API
signatures. QEMU versions can differ, so inspect the local implementation:
- read
include/hw/core/register.hfor the currentRegisterAccessInfo,RegisterInfo,RegisterInfoArray, andregister_init_block*API; - read
include/hw/core/registerfields.hfor the current register/field macros; - search the checked-out tree for
RegisterAccessInfo,register_init_block8,register_init_block32,register_init_block64,register_read_memory,register_write_memory,register_reset, andregister_array_get_owner; - prefer examples in the same subsystem or nearby architecture before using generic examples;
- if a named reference path is absent in another QEMU version, re-search by symbol instead of assuming the old path.
Current-tree reference families to inspect first:
- simple register bank with callbacks and VMState:
hw/dma/xlnx-zynq-devcfg.c; inspect its header only for public declarations, not as a location for new register definitions; - IRQ/status register side effects:
hw/intc/xlnx-zynqmp-ipi.c; - wrapped read/write handlers that still delegate to
RegisterInfo:hw/misc/xlnx-versal-trng.c; - broader Xilinx-style banks: search
hw/misc,hw/dma,hw/intc,hw/nvram, andhw/rtcforregister_init_block32.
For either framework, keep the complete register definition in the device .c
file:
- register offset and field definitions from the registerfields macros;
- register storage sized from the register map;
- a matching
RegisterInfoarray andRegisterAccessInfotable when selected; - the manual read/write callbacks and
MemoryRegionOpswhen selected; - register-local read, write, and reset hooks;
- reset logic appropriate to the selected framework;
- VMState for guest-visible register storage and other migratable state.
Do not put register offsets, field macros, RegisterAccessInfo tables,
backing storage, RegisterInfo arrays, or register semantics in a header. A
header may expose only non-register-layout declarations genuinely required
outside the device translation unit, such as a public QOM type or cross-unit
helper prototype.
When using RegisterInfo, use its hooks deliberately:
- use pre-write hooks to filter or transform a write before storage;
- use post-write hooks for IRQ/status/timer/DMA side effects after storage;
- use post-read hooks only for guest-visible read side effects;
- remember that register reset can call write hooks in this framework, so callbacks must be reset-safe.
When the decision selects RegisterInfo, a separate custom handler is
permitted for a non-register data aperture such as a FIFO data port, streaming
window, or RAM/ROM window. Record the reason; control/status registers in or
beside that window still delegate to RegisterInfo.
MMIO rules
- Implement every control/status register through the selected framework.
- Use constants/macros for offsets, masks, shifts, reset values, and IDs.
- Keep normal read/write callbacks allocation-free.
- Represent RO, W1C, reserved, clear-on-read, and unimplemented bits without duplicating their semantics across callbacks.
- With
RegisterInfo, useRegisterAccessInfoand hooks when the current API supports the required behavior. - Update status before raising/lowering IRQ.
- Keep long-running work out of MMIO callbacks; use timers, bottom halves, workers, or staged execution.
- Validate guest DMA addresses with QEMU address-space/DMA helpers.
- Never edit generated files under
builds/build-<target>/; fix register definitions or source inputs instead.
qtest expectations
Every material peripheral change should have narrow qtest coverage for:
- reset values;
- read/write masks and reserved bits;
- unsupported access widths when guest-visible;
- W1C/status clear behavior;
- IRQ assert/deassert paths;
- virtual clock behavior for timers;
- DMA memory effects when applicable.
- selected-framework reset and side-effect callback behavior.
Accelerator addendum
For command-stream or accelerator blocks:
- separate descriptor parsing from execution;
- record command ranges, DMA windows, and output buffers;
- validate skipped/unknown operation counts;
- correlate trace milestones with guest-visible output;
- record image hashes under
.oh-my-qemu/<task-slug>/audit.md.
Anti-patterns
- Generic scratch register banks for real devices.
- Selecting a register framework without recording the decision gate evidence.
- Manual MMIO callbacks with no target-workspace, user, or nearby-subsystem justification.
- Copying stale
RegisterInfofunction signatures from memory when that framework is selected. - Register definitions, field macros, backing storage, access tables, or
register hooks in a header instead of the device
.cfile. - Fake success paths that only make firmware boot.
- Board-specific behavior hidden in MMIO callbacks.
- Trace-count-only success claims.
- Logging or allocation on every normal MMIO access.
Upstream references
- QEMU code provenance and AI policy:
docs/devel/code-provenance.rst. - QOM and qdev conventions: QEMU
docs/devel/and nearbyhw/*devices. - RegisterInfo API:
include/hw/core/register.h. - Register field macros:
include/hw/core/registerfields.h. - Tracing:
docs/devel/tracing.rst.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

