# psp-archive/pspboot architecture

> Architecture diagram of the GitHub repository psp-archive/pspboot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/psp-archive/pspboot
- Repository: https://github.com/psp-archive/pspboot

## Overview

##### Project Type and Purpose
- This is a low-level, firmware/bootloader project designed to safely transfer into kernel mode without risking overwrite of running prx code.
- Its core purpose is to initialize a new kernel mode environment for the PSP by reading configuration settings (from pspboot.conf) and executing boot code.
- The README and file tree show that it is not a full-stack web application but a specialized tool for the PSP hardware.

##### Key Components
a. Bootloader Core:
- Represented by main.c, this is the primary entry point for the boot process.
- It manages the boot procedure and invokes functionalities provided by the kmodlib.

b. Kernel Module Library (kmodlib):
- This directory contains the support library for kernel-specific operations.
- Components:
- kmodlib.h – the header declaring the API.
- kmodlib_impl.c – the implementation.
- kmodlib.exp – export definitions, which likely interface with the kernel.
- That this library is modular and interacts with the bootloader core.

c. Configuration Component:
- pspboot.conf is the configuration file that defines the boot parameters.
- It as an external input feeding into the bootloader, influencing boot behavior.

d. Build and Versioning:
- Makefile at the top level and another within the kmodlib directory.
- Although not runtime components, these illustrate how the project is built, compiled, and integrated.

##### Relationships and Interactions
- The Bootloader Core (main.c) reads configuration data from pspboot.conf and then utilizes the kernel functionalities provided by kmodlib.
- Optionally, indicate the build process by showing how the Makefiles compile the components together into the final kernel image.

##### Architectural Patterns and Principles
- Modularity: The separation between the core bootloader (main.c) and the kernel module library (kmodlib) shows a modular design.
- Configuration Driven: The use of pspboot.conf suggests that the system behavior can be tweaked without code changes.
- Low-Level Hardware Interaction: While not depicted in source code, the overall design is geared towards safe transitions into kernel mode.

##### Summary
- An external configuration component feeding into the bootloader.
- Detail the modular design by linking the Bootloader Core to the Kernel Module Library.
- Since it is a low-level system tool rather than a client-server application, emphasize the tight integration between code modules and low-level hardware interaction, as well as the safe transition into kernel mode.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Boot Process Subgraph
    subgraph "Boot Process"
        conf["Configuration File (pspboot.conf)"]:::config
        core["Bootloader Core (main.c)"]:::boot
        lib["Kernel Module Library (kmodlib)"]:::lib
        
        conf -->|"reads"| core
        core -->|"calls"| lib
    end

    %% Build Process Subgraph
    subgraph "Build Process"
        topMake["Top-level Makefile"]:::build
        kmodMake["kmodlib/Makefile"]:::build
    end

    topMake -->|"builds"| core
    kmodMake -->|"builds"| lib

    %% Click Events
    click conf "https://github.com/psp-archive/pspboot/blob/main/pspboot.conf"
    click core "https://github.com/psp-archive/pspboot/blob/main/main.c"
    click lib "https://github.com/psp-archive/pspboot/tree/main/kmodlib/"
    click topMake "https://github.com/psp-archive/pspboot/tree/main/Makefile"
    click kmodMake "https://github.com/psp-archive/pspboot/tree/main/kmodlib/Makefile"

    %% Styles
    classDef boot fill:#bbd8ff,stroke:#333,stroke-width:2px;
    classDef lib fill:#ffcc80,stroke:#333,stroke-width:2px;
    classDef config fill:#c3f3c3,stroke:#333,stroke-width:2px;
    classDef build fill:#ffb3b3,stroke:#333,stroke-width:2px;
```
