# danmilea/open-amp architecture

> Architecture diagram of the GitHub repository danmilea/open-amp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danmilea/open-amp
- Repository: https://github.com/danmilea/open-amp

## Overview

##### Project Type and Purpose
- This is a C-language middleware library (OpenAMP) plus demonstration applications for Asymmetric Multiprocessing (AMP) systems.
- Purpose: provide a hardware-agnostic framework for remote processor lifecycle management and inter-processor communication (IPC) via virtio/rpmsg stacks, compatible with both baremetal and Linux hosts/remotes.

##### File Structure Analysis
- Top level:
- `lib/` – core library code subdivided into `virtio/`, `rpmsg/`, `remoteproc/`, `proxy/`, plus service and utils.
- `apps/` (mentioned in README) – sample/demo applications.
- `cmake/` and `CMakeLists.txt` – build system and platform toolchain support.
- `doc/` – design docs and graph sources.
- `scripts/` – contributor tooling (checkpatch, linter).
- `.github/` – CI workflows and GitHub Actions.
- Key patterns:
- Layered architecture (hardware abstraction, core IPC layers, application layer).
- Plugin points via libmetal for system/memory/irq primitives.
- CMake options control inclusion of proxy, virtio driver/device, apps, static/shared builds.

##### README Insights
- Confirms layered structure: libmetal (system layer) beneath OpenAMP core.
- Core APIs: remoteproc (manage remote contexts), virtio (vdev/vdrv), rpmsg (message queues), proxy (file-API forwarding).
- Supported configurations: Linux↔baremetal, baremetal↔Linux, Linux userspace↔Linux userspace.
- Build flow: CMake toolchains for cross-compilation, options to toggle components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Host Stack
    subgraph "Host (Linux/Baremetal)"
        subgraph "Application Layer"
            HostApps["Demo Apps"]:::app
        end
        subgraph "OpenAMP Core"
            HostRP["remoteproc"]:::core
            HostVT["virtio"]:::core
            HostRPMSG["rpmsg"]:::core
            HostPRX["proxy"]:::core
        end
        HostLib["libmetal"]:::abst
        subgraph "Hardware Layer"
            HostMem["Shared Memory & VRings"]:::hw
            HostIPI["IPI/Mailbox & MMIO"]:::hw
        end
    end

    %% Remote Stack
    subgraph "Remote (Linux/Baremetal)"
        subgraph "Application Layer"
            RemoteApps["Demo Apps"]:::app
        end
        subgraph "OpenAMP Core"
            RemoteRP["remoteproc"]:::core
            RemoteVT["virtio"]:::core
            RemoteRPMSG["rpmsg"]:::core
            RemotePRX["proxy"]:::core
        end
        RemoteLib["libmetal"]:::abst
        subgraph "Hardware Layer"
            RemoteMem["Shared Memory & VRings"]:::hw
            RemoteIPI["IPI/Mailbox & MMIO"]:::hw
        end
    end

    %% Build & CI
    subgraph "Build & CI"
        CMakeList["Top-level CMakeLists.txt"]:::build
        CMakeMods["cmake/modules"]:::build
        Platforms["cmake/platforms"]:::build
        Workflows[".github/workflows"]:::build
        ScriptsNode["scripts"]:::build
    end

    %% Connections Host Stack
    HostApps -->|API calls| HostRPMSG
    HostApps -->|API calls| HostRP
    HostRPMSG -->|uses virtio vrings| HostVT
    HostRP -->|sets up transport| HostVT
    HostVT -->|maps memory/reg| HostLib
    HostRP -->|uses mem/irq APIs| HostLib
    HostRPMSG -->|uses mem/irq APIs| HostLib
    HostLib -->|allocates/maps| HostMem
    HostLib -->|registers| HostIPI
    HostVT -->|writes to| HostMem
    HostVT -->|signals via| HostIPI

    %% Connections Remote Stack
    RemoteApps -->|API calls| RemoteRPMSG
    RemoteApps -->|API calls| RemoteRP
    RemoteRPMSG -->|uses virtio vrings| RemoteVT
    RemoteRP -->|sets up transport| RemoteVT
    RemoteVT -->|maps memory/reg| RemoteLib
    RemoteRP -->|uses mem/irq APIs| RemoteLib
    RemoteRPMSG -->|uses mem/irq APIs| RemoteLib
    RemoteLib -->|allocates/maps| RemoteMem
    RemoteLib -->|registers| RemoteIPI
    RemoteVT -->|writes to| RemoteMem
    RemoteVT -->|signals via| RemoteIPI

    %% Cross-processor links
    HostMem ---|shared| RemoteMem
    HostIPI ---|interrupt| RemoteIPI

    %% Build & CI connections
    CMakeList --- CMakeMods
    CMakeList --- Platforms
    CMakeList --- ScriptsNode
    CMakeList --- Workflows

    %% Click Events
    click HostRP "https://github.com/danmilea/open-amp/tree/main/lib/remoteproc/"
    click HostVT "https://github.com/danmilea/open-amp/tree/main/lib/virtio/"
    click HostRPMSG "https://github.com/danmilea/open-amp/tree/main/lib/rpmsg/"
    click HostPRX "https://github.com/danmilea/open-amp/tree/main/lib/proxy/"
    click RemoteRP "https://github.com/danmilea/open-amp/tree/main/lib/remoteproc/"
    click RemoteVT "https://github.com/danmilea/open-amp/tree/main/lib/virtio/"
    click RemoteRPMSG "https://github.com/danmilea/open-amp/tree/main/lib/rpmsg/"
    click RemotePRX "https://github.com/danmilea/open-amp/tree/main/lib/proxy/"
    click CMakeList "https://github.com/danmilea/open-amp/blob/main/CMakeLists.txt"
    click CMakeMods "https://github.com/danmilea/open-amp/blob/main/cmake/modules/FindLibmetal.cmake"
    click Platforms "https://github.com/danmilea/open-amp/tree/main/cmake/platforms/"
    click Workflows "https://github.com/danmilea/open-amp/tree/main/.github/workflows/"
    click ScriptsNode "https://github.com/danmilea/open-amp/tree/main/scripts/"

    %% Styles
    classDef hw fill:#dddddd,stroke:#888888,stroke-width:1px;
    classDef abst fill:#add8e6,stroke:#1f77b4,stroke-width:1px;
    classDef core fill:#90ee90,stroke:#228B22,stroke-width:1px;
    classDef app fill:#ffcc99,stroke:#ff8c00,stroke-width:1px;
    classDef build fill:#f0e68c,stroke:#b8860b,stroke-width:1px;
```
