# rhboot/efivar architecture

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

- Interactive diagram: https://gitdiagram.com/rhboot/efivar
- Repository: https://github.com/rhboot/efivar

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Library Components:
- EFI Variable Management (libefivar)
- EFI Boot Management (libefiboot)
- EFI Security Management (libefisec)

b) Utility Components:
- Command Line Tools
- Variable Storage Interface
- Platform-Specific Implementations

**┌─────────────────────────────────────────┐**
- Command Line Tools           │
- (efivar, efisecdb utilities)    │
- ┤
- Public API Layer              │
- ┬───────────┬────────────┤
- libefivar   │ libefiboot│ libefisec  │
- (Variable   │  (Boot    │ (Security  │
- Management) │  Services) │  Services) │
- ┴───────────┴────────────┤
- Platform Abstraction Layer      │
- ┤
- Hardware/Firmware Interface Layer    │
- (UEFI Variables)             │
- ┘

##### Component Relationships

- Data flow between components
- Dependency relationships
- API calls
- Variable access patterns

##### Specific elements

a) Variable Management:
- GUID handling
- Variable storage
- Data formatting
- Security attributes

b) Platform Support:
- Linux-specific implementations
- Hardware device support
- File system interfaces

c) Security Features:
- Secure Boot variables
- Authentication
- Key management

##### Implementation Details

Implementation aspects:
- File system interactions (efivarfs)
- Device protocols (disk, nvme, scsi)
- Security database handling
- Boot option management

##### External Interfaces

Interfaces with:
- UEFI firmware
- Operating system
- Security services
- Storage devices

This architecture reflects the project's focus on providing a robust interface for EFI variable manipulation while maintaining security and platform independence.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["Command Line Tools"]
        direction TB
        EFIVAR["efivar utility"]:::cli
        EFISECDB["efisecdb utility"]:::cli
    end

    subgraph API["Public API Layer"]
        direction TB
        LIBEFIVAR["libefivar<br/>(Variable Management)"]:::lib
        LIBEFIBOOT["libefiboot<br/>(Boot Services)"]:::lib
        LIBEFISEC["libefisec<br/>(Security Services)"]:::lib
    end

    subgraph PAL["Platform Abstraction Layer"]
        direction TB
        VARSTORE["Variable Storage<br/>Interface"]:::pal
        GUID["GUID<br/>Management"]:::pal
        DEVPATH["Device Path<br/>Handling"]:::pal
    end

    subgraph PLATFORM["Platform-Specific Layer"]
        direction TB
        LINUX["Linux Core"]:::platform
        ACPI["ACPI Support"]:::platform
        STORAGE["Storage Protocols<br/>(NVME/SCSI/SATA)"]:::platform
        PCI["PCI Support"]:::platform
    end

    subgraph HW["Hardware/Firmware Interface"]
        direction TB
        UEFI["UEFI Variables"]:::hw
    end

    %% Relationships
    EFIVAR --> LIBEFIVAR
    EFISECDB --> LIBEFISEC
    LIBEFIVAR --> VARSTORE
    LIBEFIBOOT --> DEVPATH
    LIBEFISEC --> GUID
    VARSTORE --> LINUX
    DEVPATH --> LINUX
    LINUX --> ACPI
    LINUX --> STORAGE
    LINUX --> PCI
    LINUX --> UEFI
    STORAGE --> UEFI

    %% Click Events
    click EFIVAR "https://github.com/rhboot/efivar/blob/main/src/efivar.c"
    click EFISECDB "https://github.com/rhboot/efivar/blob/main/src/efisecdb.c"
    click LIBEFIVAR "https://github.com/rhboot/efivar/blob/main/src/efivar.h"
    click LIBEFIBOOT "https://github.com/rhboot/efivar/blob/main/src/efiboot.h"
    click LIBEFISEC "https://github.com/rhboot/efivar/blob/main/src/efisec.h"
    click VARSTORE "https://github.com/rhboot/efivar/blob/main/src/efivarfs.c"
    click GUID "https://github.com/rhboot/efivar/blob/main/src/guid.c"
    click DEVPATH "https://github.com/rhboot/efivar/blob/main/src/dp.c"
    click LINUX "https://github.com/rhboot/efivar/blob/main/src/linux.c"
    click ACPI "https://github.com/rhboot/efivar/blob/main/src/linux-acpi.c"
    click STORAGE "https://github.com/rhboot/efivar/blob/main/src/linux-nvme.c"
    click PCI "https://github.com/rhboot/efivar/blob/main/src/linux-pci.c"

    %% Styles
    classDef cli fill:#4B89DC,color:white
    classDef lib fill:#37BC9B,color:white
    classDef pal fill:#F6BB42,color:black
    classDef platform fill:#967ADC,color:white
    classDef hw fill:#AAB2BD,color:white

    %% Legend
    subgraph Legend
        CLI_L["Command Line Tools"]:::cli
        LIB_L["Core Libraries"]:::lib
        PAL_L["Platform Abstraction"]:::pal
        PLAT_L["Platform-Specific"]:::platform
        HW_L["Hardware Interface"]:::hw
    end
```
