# openbmc/libcper architecture

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

- Interactive diagram: https://gitdiagram.com/openbmc/libcper
- Repository: https://github.com/openbmc/libcper

## Overview

CPER is a C library and pair of command-line tools for converting UEFI Common Platform Error Records between binary and structured JSON, plus generating pseudo-random records. The main user workflow is selecting a conversion direction with cper-convert, transforming the record through the library, and receiving the converted representation; cper-generate provides a separate record-generation workflow. The README documents the conversion API and generator capabilities. Some subsystem links are omitted because the sampled excerpts do not show their internal dispatch or call relationships.

Main entry points: [`generator/sections`](https://github.com/openbmc/libcper/tree/main/generator/sections) (Section generators), [`cli-app/cper-convert.c`](https://github.com/openbmc/libcper/blob/main/cli-app/cper-convert.c) (Conversion CLI), [`cper-parse.c`](https://github.com/openbmc/libcper/blob/main/cper-parse.c) (Record parser), [`ir-parse.c`](https://github.com/openbmc/libcper/blob/main/ir-parse.c) (IR conversion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversion["Conversion"]
  node_convert_cli["Conversion CLI<br/>[cper-convert.c]"]
  node_record_parser["Record parser<br/>[cper-parse.c]"]
  node_ir_converter["IR conversion<br/>[ir-parse.c]"]
end

subgraph group_sections["Section codecs"]
  node_section_codecs["Section codecs"]
end

subgraph group_generation["Generation"]
  node_generator_cli["Generator CLI"]
  node_record_generator["Record generator<br/>[cper-generate.c]"]
  node_section_generator["Section generators"]
  node_generator_registry["Generator registry<br/>[gen-section.c]"]
end

subgraph group_formats["CPER formats"]
  node_section_layouts["Section layouts"]
  node_cper_definitions["CPER definitions<br/>[Cper.h]"]
end

node_user(("User"))

node_user -->|"chooses conversion"| node_convert_cli
node_convert_cli -->|"converts records"| node_record_parser
node_record_parser -.->|"uses IR"| node_ir_converter
node_ir_converter -.->|"converts sections"| node_section_codecs
node_section_codecs -.->|"uses layouts"| node_section_layouts
node_section_layouts -.->|"uses definitions"| node_cper_definitions
node_user -->|"requests records"| node_generator_cli
node_generator_cli -->|"generates records"| node_record_generator
node_record_generator -->|"generates sections"| node_section_generator
node_section_generator -.->|"registers generators"| node_generator_registry
node_section_generator -.->|"uses definitions"| node_cper_definitions

click node_convert_cli "https://github.com/openbmc/libcper/blob/main/cli-app/cper-convert.c"
click node_record_parser "https://github.com/openbmc/libcper/blob/main/cper-parse.c"
click node_ir_converter "https://github.com/openbmc/libcper/blob/main/ir-parse.c"
click node_section_codecs "https://github.com/openbmc/libcper/tree/main/sections"
click node_section_layouts "https://github.com/openbmc/libcper/tree/main/include/libcper/sections"
click node_cper_definitions "https://github.com/openbmc/libcper/blob/main/include/libcper/Cper.h"
click node_generator_cli "https://github.com/openbmc/libcper/blob/main/generator/cper-generate-cli.c"
click node_record_generator "https://github.com/openbmc/libcper/blob/main/generator/cper-generate.c"
click node_section_generator "https://github.com/openbmc/libcper/tree/main/generator/sections"
click node_generator_registry "https://github.com/openbmc/libcper/blob/main/generator/sections/gen-section.c"

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_convert_cli,node_record_parser,node_ir_converter,node_user toneBlue
class node_section_codecs toneAmber
class node_generator_cli,node_record_generator,node_section_generator,node_generator_registry toneMint
class node_section_layouts,node_cper_definitions toneRose
```

## Components

### Conversion

- [Conversion CLI](https://github.com/openbmc/libcper/blob/main/cli-app/cper-convert.c): `cli-app/cper-convert.c`
- [Record parser](https://github.com/openbmc/libcper/blob/main/cper-parse.c): `cper-parse.c`
- [IR conversion](https://github.com/openbmc/libcper/blob/main/ir-parse.c): `ir-parse.c`

### Section codecs

- [Section codecs](https://github.com/openbmc/libcper/tree/main/sections): `sections`

### Generation

- [Generator CLI](https://github.com/openbmc/libcper/blob/main/generator/cper-generate-cli.c): `generator/cper-generate-cli.c`
- [Record generator](https://github.com/openbmc/libcper/blob/main/generator/cper-generate.c): `generator/cper-generate.c`
- [Section generators](https://github.com/openbmc/libcper/tree/main/generator/sections): `generator/sections`
- [Generator registry](https://github.com/openbmc/libcper/blob/main/generator/sections/gen-section.c): `generator/sections/gen-section.c`

### CPER formats

- [Section layouts](https://github.com/openbmc/libcper/tree/main/include/libcper/sections): `include/libcper/sections`
- [CPER definitions](https://github.com/openbmc/libcper/blob/main/include/libcper/Cper.h): `include/libcper/Cper.h`

### Other components

- **User**

## Connections

- User → Conversion CLI: chooses conversion
- Conversion CLI → Record parser: converts records
- Record parser → IR conversion: uses IR
- IR conversion → Section codecs: converts sections
- Section codecs → Section layouts: uses layouts
- Section layouts → CPER definitions: uses definitions
- User → Generator CLI: requests records
- Generator CLI → Record generator: generates records (evidence: `generator/cper-generate-cli.c`)
- Record generator → Section generators: generates sections (evidence: `generator/cper-generate.c`)
- Section generators → Generator registry: registers generators
- Section generators → CPER definitions: uses definitions
