1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Types and structures for the kernel config.
//!
//! Cargo features are somewhat limited and configuring the size of static
//! arrays is straight forward. The types for the config are put into separate
//! crate to ensure non-cyclic dependencies as the `conf` and `bern_kernel`
//! crate depend on it.
#![no_std]

pub use bern_arch::arch::memory_protection::Size;

/// Task related config
pub struct Task {
    /// The number of tasks that can be allocated in the static pool
    pub pool_size: usize,
    /// The number of different priorities.
    /// Keep the number low as it influences overhead when switching tasks
    pub priorities: u8,
}

/// Event related config
pub struct Event {
    /// The number of events that can be allocated.
    /// An event is used for every mutex, semaphore, flag group and message
    /// queue.
    pub pool_size: usize,
}

/// Definition of a memory section or region
pub struct MemorySection {
    /// Lowest address of the section
    pub start_address: usize,
    /// Section size
    pub size: Size,
}

/// Memory sections
///
/// **Note:** This overlaps with the linker script and must be adjusted
/// manually.
pub struct Memory {
    /// Flash (non-volatile) memory section
    pub flash: MemorySection,
    /// SRAM (volatile) memory section
    pub sram: MemorySection,
    /// Memory mapped peripherals section
    pub peripheral: MemorySection,
    /// Shared memory section
    pub shared: MemorySection,
}

/// Combined config
pub struct Conf {
    pub task: Task,
    pub event: Event,
    pub memory: Memory,
}