Docs / Architecture

Architecture

Overview

bedrock[RTOS] is a nanokernel real-time operating system. It is a platform, not a library — the kernel owns the boot process, the scheduler, and the hardware abstraction layer. Application code runs as tasks managed by the kernel.

Directory Structure

bedrock-core/
├── kernel/              Scheduler, task management, time, IPC
├── include/bedrock/     Public API headers
├── arch/                HAL implementations per architecture
│   └── arm-cortex-m/    ARM Cortex-M3 reference port
├── boards/              Board-specific linker scripts and configs
│   └── qemu-cortex-m3/
├── lib/                 Static pool allocator, utilities
├── examples/            Application templates
├── docs/                Documentation (EN / RU)
├── 3rd/tools/chorus     Build system (git submodule)
├── Kconfig              Kernel configuration
└── chorus.build         Build configuration

Kernel Components

Scheduler (kernel/br_sched.c)

Priority-based preemptive scheduler with round-robin at equal priority levels.

Task Management (kernel/br_task.c)

Static TCB pool — no dynamic allocation.

Time Services (kernel/br_time.c)

Tickless design — no periodic timer interrupts.

IPC (kernel/br_ipc.c)

Three synchronization primitives:

All wait queues are priority-ordered.

Hardware Abstraction Layer

The kernel never accesses hardware directly. All platform interaction goes through the HAL interface defined in include/bedrock/br_hal.h.

CategoryFunctions
Timerbr_hal_timer_init, br_hal_timer_get_us, br_hal_timer_set_alarm, br_hal_timer_cancel_alarm
Interruptsbr_hal_irq_disable, br_hal_irq_restore, br_hal_in_isr
Contextbr_hal_stack_init, br_hal_context_switch, br_hal_start_first_task
Boardbr_hal_board_init

Adding a new architecture requires implementing these functions in arch/<arch_name>/. Zero kernel changes needed. See the Porting Guide.

Memory Model

Boot Sequence

  1. Reset_Handler — copies .data, zeros .bss, calls main()
  2. main() calls br_kernel_init():
    • Zeros TCB pool
    • Calls br_hal_board_init() and br_hal_timer_init()
    • Initializes scheduler
    • Creates idle task
  3. Application creates tasks via br_task_create()
  4. br_kernel_start() — picks the highest-priority ready task and starts it (never returns)

Context Switch (ARM Cortex-M)