# gweslab/cerf architecture

> Architecture diagram of the GitHub repository gweslab/cerf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gweslab/cerf
- Repository: https://github.com/gweslab/cerf

## Overview

CERF is a Windows CE emulator. The principal workflow is launching the emulator, selecting a configured device/board and ROM, then running the guest on an emulated platform. Board-specific hardware, SoC and peripheral models support guest execution; host tools and Guest Additions provide management and integration features. The graph combines the sampled entry point, service framework, ROM parser, JIT interface and task-manager paths with README-documented capabilities. Several subsystem links are dashed because their runtime wiring was not shown in the excerpts.

Main entry points: [`cerf/core/cerf_emulator.h`](https://github.com/gweslab/cerf/blob/main/cerf/core/cerf_emulator.h) (Emulator services), [`cerf/jit/guest_engine.h`](https://github.com/gweslab/cerf/blob/main/cerf/jit/guest_engine.h) (Guest CPU engine), [`cerf/boards/board_context.h`](https://github.com/gweslab/cerf/blob/main/cerf/boards/board_context.h) (Board contexts), [`cerf/host/task_manager_window.cpp`](https://github.com/gweslab/cerf/blob/main/cerf/host/task_manager_window.cpp) (Host task manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Emulator runtime"]
  node_main["CLI entry<br/>[main.cpp]"]
  node_emulator["Emulator services<br/>[cerf_emulator.h]"]
  node_rom["ROM parsing"]
  node_engine["Guest CPU engine<br/>[guest_engine.h]"]
  node_armjit["ARM JIT"]
  node_mipsjit["MIPS JIT"]
end

subgraph group_platform["Emulated platform"]
  node_board["Board contexts<br/>[board_context.h]"]
  node_boards["Device models"]
  node_soc["SoC models"]
  node_peripheral["Peripheral models"]
  node_network["Network backend<br/>[slirp_backend.cpp]"]
  node_storage[("Disk images<br/>[disk_image.h]")]
  node_usb["USB mass storage"]
end

subgraph group_integration["Host integration"]
  node_guest["Guest Additions"]
  node_guesttm["Guest task pump"]
  node_hosttm["Host task manager"]
  node_taskview["Task list view"]
end

subgraph group_analysis["Inspection and state"]
  node_state["Save-state stream<br/>[state_stream.h]"]
  node_trace["Trace manager<br/>[trace_manager.cpp]"]
end

node_user(("Operator"))
node_externalrom["ROM image"]

node_user -->|"launches"| node_main
node_main -->|"creates"| node_emulator
node_emulator -.->|"resolves service"| node_rom
node_externalrom -->|"loads"| node_rom
node_board -->|"registers context"| node_emulator
node_board -.->|"selects model"| node_boards
node_boards -.->|"configures hardware"| node_soc
node_soc -.->|"dispatches devices"| node_peripheral
node_engine -.->|"implemented by"| node_armjit
node_engine -.->|"implemented by"| node_mipsjit
node_emulator -.->|"resolves service"| node_engine
node_peripheral -.->|"uses backend"| node_network
node_usb -->|"reads disk image"| node_storage
node_guest -.->|"includes pump"| node_guesttm
node_hosttm -->|"creates view"| node_taskview
node_hosttm -.->|"sends guest commands"| node_guesttm
node_trace -->|"reads guest state"| node_engine
node_emulator -.->|"persists state"| node_state

click node_main "https://github.com/gweslab/cerf/blob/main/cerf/core/main.cpp"
click node_emulator "https://github.com/gweslab/cerf/blob/main/cerf/core/cerf_emulator.h"
click node_rom "https://github.com/gweslab/cerf/blob/main/cerf/boot/rom_parser_service.cpp"
click node_board "https://github.com/gweslab/cerf/blob/main/cerf/boards/board_context.h"
click node_boards "https://github.com/gweslab/cerf/tree/main/cerf/boards"
click node_soc "https://github.com/gweslab/cerf/tree/main/cerf/socs"
click node_peripheral "https://github.com/gweslab/cerf/tree/main/cerf/peripherals"
click node_engine "https://github.com/gweslab/cerf/blob/main/cerf/jit/guest_engine.h"
click node_armjit "https://github.com/gweslab/cerf/blob/main/cerf/jit/arm/arm_emit_services.cpp"
click node_mipsjit "https://github.com/gweslab/cerf/blob/main/cerf/jit/mips/mips_emit_services.cpp"
click node_network "https://github.com/gweslab/cerf/blob/main/cerf/net/slirp_backend.cpp"
click node_storage "https://github.com/gweslab/cerf/blob/main/cerf/storage/disk_image.h"
click node_usb "https://github.com/gweslab/cerf/blob/main/cerf/peripherals/usb/usb_mass_storage_device.cpp"
click node_guest "https://github.com/gweslab/cerf/tree/main/ce_apps/cerf_guest"
click node_guesttm "https://github.com/gweslab/cerf/blob/main/ce_apps/cerf_guest/cerf_task_manager_pump.cpp"
click node_hosttm "https://github.com/gweslab/cerf/blob/main/cerf/host/task_manager_window.cpp"
click node_taskview "https://github.com/gweslab/cerf/blob/main/cerf/host/task_manager_list_view.cpp"
click node_state "https://github.com/gweslab/cerf/blob/main/cerf/state/state_stream.h"
click node_trace "https://github.com/gweslab/cerf/blob/main/cerf/tracing/trace_manager.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_emulator,node_rom,node_engine,node_armjit,node_mipsjit toneBlue
class node_board,node_boards,node_soc,node_peripheral,node_network,node_storage,node_usb toneAmber
class node_guest,node_guesttm,node_hosttm,node_taskview toneMint
class node_state,node_trace toneRose
class node_user,node_externalrom toneIndigo
```

## Components

### Emulator runtime

- [CLI entry](https://github.com/gweslab/cerf/blob/main/cerf/core/main.cpp): `cerf/core/main.cpp`
- [Emulator services](https://github.com/gweslab/cerf/blob/main/cerf/core/cerf_emulator.h): `cerf/core/cerf_emulator.h`
- [ROM parsing](https://github.com/gweslab/cerf/blob/main/cerf/boot/rom_parser_service.cpp): `cerf/boot/rom_parser_service.cpp`
- [Guest CPU engine](https://github.com/gweslab/cerf/blob/main/cerf/jit/guest_engine.h): `cerf/jit/guest_engine.h`
- [ARM JIT](https://github.com/gweslab/cerf/blob/main/cerf/jit/arm/arm_emit_services.cpp): `cerf/jit/arm/arm_emit_services.cpp`
- [MIPS JIT](https://github.com/gweslab/cerf/blob/main/cerf/jit/mips/mips_emit_services.cpp): `cerf/jit/mips/mips_emit_services.cpp`

### Emulated platform

- [Board contexts](https://github.com/gweslab/cerf/blob/main/cerf/boards/board_context.h): `cerf/boards/board_context.h`
- [Device models](https://github.com/gweslab/cerf/tree/main/cerf/boards): `cerf/boards`
- [SoC models](https://github.com/gweslab/cerf/tree/main/cerf/socs): `cerf/socs`
- [Peripheral models](https://github.com/gweslab/cerf/tree/main/cerf/peripherals): `cerf/peripherals`
- [Network backend](https://github.com/gweslab/cerf/blob/main/cerf/net/slirp_backend.cpp): `cerf/net/slirp_backend.cpp`
- [Disk images](https://github.com/gweslab/cerf/blob/main/cerf/storage/disk_image.h): `cerf/storage/disk_image.h`
- [USB mass storage](https://github.com/gweslab/cerf/blob/main/cerf/peripherals/usb/usb_mass_storage_device.cpp): `cerf/peripherals/usb/usb_mass_storage_device.cpp`

### Host integration

- [Guest Additions](https://github.com/gweslab/cerf/tree/main/ce_apps/cerf_guest): `ce_apps/cerf_guest`
- [Guest task pump](https://github.com/gweslab/cerf/blob/main/ce_apps/cerf_guest/cerf_task_manager_pump.cpp): `ce_apps/cerf_guest/cerf_task_manager_pump.cpp`
- [Host task manager](https://github.com/gweslab/cerf/blob/main/cerf/host/task_manager_window.cpp): `cerf/host/task_manager_window.cpp`
- [Task list view](https://github.com/gweslab/cerf/blob/main/cerf/host/task_manager_list_view.cpp): `cerf/host/task_manager_list_view.cpp`

### Inspection and state

- [Save-state stream](https://github.com/gweslab/cerf/blob/main/cerf/state/state_stream.h): `cerf/state/state_stream.h`
- [Trace manager](https://github.com/gweslab/cerf/blob/main/cerf/tracing/trace_manager.cpp): `cerf/tracing/trace_manager.cpp`

### Other components

- **Operator**
- **ROM image**

## Connections

- Operator → CLI entry: launches (evidence: `README.md`)
- CLI entry → Emulator services: creates (evidence: `cerf/core/main.cpp`)
- Emulator services → ROM parsing: resolves service (evidence: `cerf/boot/rom_parser_service.cpp`)
- ROM image → ROM parsing: loads (evidence: `cerf/boot/rom_parser_service.cpp`)
- Board contexts → Emulator services: registers context (evidence: `cerf/boards/board_context.h`)
- Board contexts → Device models: selects model (evidence: `cerf/boards/smdk2410_devemu/devemu_keyboard_controller.cpp`)
- Device models → SoC models: configures hardware (evidence: `cerf/boards/smdk2410_devemu/devemu_keyboard_controller.cpp`)
- SoC models → Peripheral models: dispatches devices (evidence: `cerf/socs/imx31/imx31_cspi_engine.h`)
- Guest CPU engine → ARM JIT: implemented by
- Guest CPU engine → MIPS JIT: implemented by
- Emulator services → Guest CPU engine: resolves service
- Peripheral models → Network backend: uses backend
- USB mass storage → Disk images: reads disk image (evidence: `cerf/peripherals/usb/usb_mass_storage_device.cpp`)
- Guest Additions → Guest task pump: includes pump (evidence: `ce_apps/cerf_guest/cerf_task_manager_pump.cpp`)
- Host task manager → Task list view: creates view (evidence: `cerf/host/task_manager_window.cpp`)
- Host task manager → Guest task pump: sends guest commands
- Trace manager → Guest CPU engine: reads guest state (evidence: `cerf/tracing/trace_manager.cpp`)
- Emulator services → Save-state stream: persists state
