1pub use self::dipsw::*;
2pub use self::param1::*;
3
4use alloc::boxed::Box;
5use alloc::sync::Arc;
6use config::{ConsoleId, ProductId, QaFlags};
7use core::num::NonZero;
8use macros::elf_note;
9
10mod dipsw;
11mod param1;
12
13pub const PAGE_SHIFT: usize = 14; pub const PAGE_SIZE: NonZero<usize> = NonZero::new(1 << PAGE_SHIFT).unwrap();
15pub const PAGE_MASK: NonZero<usize> = NonZero::new(PAGE_SIZE.get() - 1).unwrap();
16
17pub struct Config {
19 cpu_count: NonZero<u8>,
20 unknown_dmem1: u8, idps: &'static ConsoleId,
22 qa: bool,
23 qa_flags: &'static QaFlags,
24 env_vars: Box<[(&'static str, &'static str)]>, }
26
27impl Config {
28 pub fn new(src: &'static ::config::Config) -> Arc<Self> {
29 let env_vars = Self::load_env(src);
30
31 Arc::new(Self {
32 cpu_count: src.cpu_count,
33 unknown_dmem1: 0,
34 idps: &src.idps,
35 qa: src.qa,
36 qa_flags: &src.qa_flags,
37 env_vars,
38 })
39 }
40
41 pub fn cpu_count(&self) -> NonZero<u8> {
48 self.cpu_count
49 }
50
51 pub fn unknown_dmem1(&self) -> u8 {
52 self.unknown_dmem1
53 }
54
55 pub fn idps(&self) -> &'static ConsoleId {
56 self.idps
57 }
58
59 pub fn env(&self, name: &str) -> Option<&'static str> {
66 for &(k, v) in &self.env_vars {
67 if k == name {
68 return Some(v);
69 }
70 }
71
72 None
73 }
74
75 pub fn is_allow_disabling_aslr(&self) -> bool {
82 self.qa && self.qa_flags.internal_dev()
83 }
84
85 pub fn is_devkit(&self) -> bool {
92 self.idps.product == ProductId::DEVKIT
93 }
94
95 pub fn is_testkit(&self) -> bool {
102 self.idps.product == ProductId::TESTKIT
103 }
104
105 pub fn dipsw(&self, _: Dipsw) -> bool {
112 if !self.is_testkit() {
113 if !self.is_devkit() {
114 return false;
115 }
116 } else {
117 todo!()
118 }
119
120 todo!()
121 }
122
123 fn load_env(config: &'static ::config::Config) -> Box<[(&'static str, &'static str)]> {
130 config.env().collect()
131 }
132}
133
134#[elf_note(section = ".note.obkrnl.page-size", name = "obkrnl", ty = 0)]
135static NOTE_PAGE_SIZE: [u8; size_of::<usize>()] = PAGE_SIZE.get().to_ne_bytes();