跳转至

Boot

Minimal boot/bootstrap types and helpers. More...

Classes

Name
struct CFBDBootTuple

Types

Name
typedef void * CFBD_BootArgs
Opaque pointer to bootstrap-specific arguments.
typedef CFBD_Bool(*)(CFBD_BootArgs args) CFBD_BootStrapFunc
Function-pointer type for bootstrap/startup routines.

Detailed Description

Minimal boot/bootstrap types and helpers.

Types used to describe and invoke bootstrap/startup routines.

The CFBD_Boot module provides a generic, extensible mechanism for managing application startup sequences. It decouples initialization logic from the main application, enabling a clean modular architecture where each subsystem (hardware, drivers, services) registers its own bootstrap function.

Types Documentation

typedef CFBD_BootArgs

CFBD_BootArgs;

Opaque pointer to bootstrap-specific arguments.

See:

Since: 0.1

Par: Example - Basic Argument Casting

// Define a boot-time configuration structure
struct MyBootConfig {
    uint32_t clock_frequency;
    uint8_t device_id;
} my_config = { 72000000, 0x01 };

// Cast to generic CFBD_BootArgs
CFBD_BootArgs args = (CFBD_BootArgs)&my_config;

// In the bootstrap function, cast back to concrete type
CFBD_Bool my_bootstrap(CFBD_BootArgs args) {
    struct MyBootConfig *cfg = (struct MyBootConfig *)args;
    initialize_clock(cfg->clock_frequency);
    return CFBD_True;
}

Bootstrap argument containers are intentionally typedeffed to void* to keep the interface generic. Callers should cast to a concrete structure type known to both the caller and the bootstrap function.

typedef CFBD_BootStrapFunc

CFBD_BootStrapFunc;

Function-pointer type for bootstrap/startup routines.

Parameters:

  • args Opaque pointer to bootstrap-specific arguments (may be NULL).

See:

Return: CFBD_Bool Return CFBD_True on success, CFBD_False on failure.

Since: 0.1

Note: The exact concrete type behind CFBD_BootArgs is application specific. Use @ref CFBD_BootArgs casts to access fields.

Par:

  • Example - Simple Bootstrap Function

// Hardware initialization bootstrap function
CFBD_Bool boot_hardware(CFBD_BootArgs args) {
    struct HwConfig *hw_cfg = (struct HwConfig *)args;

    // Initialize clock
    if (!init_system_clock(hw_cfg->clock_freq)) {
        return CFBD_False;
    }

    // Initialize GPIO
    if (!init_gpio_subsystem(hw_cfg->gpio_config)) {
        return CFBD_False;
    }

    return CFBD_True;
}
* Example - Bootstrap Function with Null Arguments

// Application initialization that doesn't need configuration
CFBD_Bool boot_application(CFBD_BootArgs args) {
    (void)args;  // Unused

    app_init_subsystems();
    app_start_scheduler();

    return CFBD_True;
}

Bootstrap functions receive a single opaque argument (CFBD_BootArgs) and return a CFBD_Bool indicating success (CFBD_True) or failure (CFBD_False). Implementations should perform any necessary initialization and return quickly. Long-running tasks or blocking operations should be avoided unless explicitly required by the platform.


Updated on 2026-02-03 at 13:21:55 +0000