Overview

BCD (Boot Configuration Data) is a database system that stores boot configuration information and parameters. It is similar in function to Windows' BCD but designed specifically for FreeWorld OS.

Data Structures

bcd_header_t

Header structure containing BCD metadata:

typedef struct {
    char signature[8];      // "FWBCD\0\0\0"
    uint32_t version;       // BCD version
    uint32_t entry_count;   // Number of boot entries
    uint32_t default_entry; // Default boot entry index
} bcd_header_t;
Field Type Size Description
signature char[8] 8 bytes BCD file signature: "FWBCD\0\0\0"
version uint32_t 4 bytes BCD format version number
entry_count uint32_t 4 bytes Total number of boot entries
default_entry uint32_t 4 bytes Index of default boot entry

bcd_entry_t

Boot entry structure containing boot configuration:

typedef struct {
    char name[64];          // Entry name
    char loader[256];       // Path to loader (e.g., freeload.exe)
    char kernel[256];       // Path to kernel (e.g., fwoskrnl.exe)
    uint32_t flags;         // Boot flags
} bcd_entry_t;
Field Type Size Description
name char[64] 64 bytes Human-readable boot entry name
loader char[256] 256 bytes Path to OS loader executable
kernel char[256] 256 bytes Path to kernel executable
flags uint32_t 4 bytes Boot flags (bit flags for options)

Functions

bcd_init

Initializes a new BCD structure in memory:

int bcd_init(void);

Returns: 0 on success, -1 on failure

Description: Allocates memory for BCD header and initializes it with default values.

bcd_load

Loads BCD data from a file:

int bcd_load(const char* path);

Parameters:

  • path: Path to BCD file

Returns: 0 on success, -1 on failure

Description: Reads BCD header and entries from disk file.

bcd_get_default_entry

Retrieves the default boot entry:

int bcd_get_default_entry(bcd_entry_t* entry);

Parameters:

  • entry: Pointer to bcd_entry_t to fill with default entry data

Returns: 0 on success, -1 on failure

bcd_add_entry

Adds a new boot entry to the BCD:

int bcd_add_entry(const bcd_entry_t* entry);

Parameters:

  • entry: Pointer to bcd_entry_t containing entry data

Returns: 0 on success, -1 on failure

bcd_remove_entry

Removes a boot entry by index:

int bcd_remove_entry(uint32_t index);

Parameters:

  • index: Index of entry to remove

Returns: 0 on success, -1 on failure

Static Variables

Variable Type Scope Description
bcd_header bcd_header_t* static Pointer to BCD header structure
bcd_entries bcd_entry_t* static Pointer to array of boot entries

File Format

BCD files are stored in binary format:

  1. Header (16 bytes): bcd_header_t structure
  2. Entries (variable): Array of bcd_entry_t structures

Total file size = sizeof(bcd_header_t) + (entry_count * sizeof(bcd_entry_t))

Usage Example

#include "BCD.h"

bcd_entry_t entry;
if (bcd_load("BCD") == 0) {
    if (bcd_get_default_entry(&entry) == 0) {
        printf("Boot entry: %s\n", entry.name);
        printf("Kernel: %s\n", entry.kernel);
        printf("Loader: %s\n", entry.loader);
    }
}

Integration Points

  • BOOTMGR: May read BCD to determine boot configuration
  • freeload.exe: Loads BCD to get kernel and loader paths
  • Boot menu: Can display multiple boot entries from BCD