xref: /DragonOS/kernel/src/init/mod.rs (revision c566df451ce6dbf2af684333e68b39fdfff86498)
1 use crate::{
2     driver::{
3         tty::init::tty_early_init,
4         video::{fbdev::base::BootTimeScreenInfo, VideoRefreshManager},
5     },
6     libs::{lib_ui::screen_manager::scm_init, rwlock::RwLock},
7 };
8 
9 mod c_adapter;
10 
11 pub mod initcall;
12 pub mod initial_kthread;
13 
14 /// 启动参数
15 static BOOT_PARAMS: RwLock<BootParams> = RwLock::new(BootParams::new());
16 
17 #[inline(always)]
18 pub fn boot_params() -> &'static RwLock<BootParams> {
19     &BOOT_PARAMS
20 }
21 
22 fn init_intertrait() {
23     intertrait::init_caster_map();
24 }
25 
26 /// 在内存管理初始化之前,执行的初始化
27 pub fn init_before_mem_init() {
28     tty_early_init().expect("tty early init failed");
29     let video_ok = unsafe { VideoRefreshManager::video_init().is_ok() };
30     scm_init(video_ok);
31 }
32 
33 #[derive(Debug)]
34 pub struct BootParams {
35     pub screen_info: BootTimeScreenInfo,
36 }
37 
38 impl BootParams {
39     const DEFAULT: Self = BootParams {
40         screen_info: BootTimeScreenInfo::DEFAULT,
41     };
42 
43     const fn new() -> Self {
44         Self::DEFAULT
45     }
46 }
47