Skip to main content

bsp_define/
lib.rs

1//! 系统必须的配置项定义
2#![no_std]
3
4pub mod clocksource;
5pub mod console;
6pub mod irqchip;
7pub mod memrange;
8pub mod smp;
9
10/// 系统`Bsp`定义
11pub trait BspDefine<C, I, CLK>
12where
13    C: console::ConsoleImpl,
14    I: irqchip::IrqchipImpl,
15    CLK: clocksource::ClockImpl,
16{
17    /// 定义系统多核信息
18    const DEFINE_SMP: smp::SmpDefine = smp::SmpDefine::create(
19        smp::PsciCompatible::Psci0_1,
20        smp::PsciEnableMethod::Hvc,
21        0,
22        [0; smp::NR_CPUS],
23        1,
24    );
25
26    /// 定义系统内存域信息
27    const DEFINE_MEMS: memrange::MemDefine;
28
29    /// 定义系统控制台信息
30    const DEFINE_CONSOLE: C;
31
32    /// 定义系统中断控制器信息
33    const DEFINE_IRQCHIP: I;
34
35    /// 定义系统时钟源信息
36    const DEFINE_CLOCK: CLK;
37
38    /// 定义系统心跳周期(默认 5ms)
39    const DEFINE_SYSTEM_TICK: usize = 5;
40
41    /// 系统启动前期调用, 用于时钟等板级系统初始化
42    fn early_init(&self) {}
43
44    /// 系统启动后期调用, 主要完成最终板级初始化和加载APP
45    fn late_init(&self);
46
47    /// 从核启动后期调用
48    fn secondary_init(&self) {}
49}