-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4148c6
commit 637fd80
Showing
9 changed files
with
160 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
#![no_std] | ||
|
||
use core::num::NonZero; | ||
|
||
pub use self::env::*; | ||
|
||
mod env; | ||
|
||
/// Information about the boot environment. | ||
/// Contains information about the boot environment. | ||
#[repr(C)] | ||
pub enum BootEnv { | ||
Vm(Vm), | ||
} | ||
|
||
/// Runtime configurations for the kernel. | ||
#[repr(C)] | ||
pub struct Config { | ||
pub max_cpu: NonZero<usize>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
use core::ptr::null; | ||
use macros::elf_note; | ||
use obconf::BootEnv; | ||
use obconf::{BootEnv, Config}; | ||
|
||
#[cfg(target_arch = "aarch64")] | ||
pub use self::aarch64::*; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use self::x86_64::*; | ||
pub use self::arch::*; | ||
|
||
#[cfg(target_arch = "aarch64")] | ||
mod aarch64; | ||
#[cfg(target_arch = "x86_64")] | ||
mod x86_64; | ||
#[cfg_attr(target_arch = "aarch64", path = "aarch64.rs")] | ||
#[cfg_attr(target_arch = "x86_64", path = "x86_64.rs")] | ||
mod arch; | ||
|
||
pub fn boot_env() -> &'static BootEnv { | ||
// SAFETY: This is safe because the set_boot_env() requirements. | ||
// SAFETY: This is safe because the setup() requirements. | ||
unsafe { &*BOOT_ENV } | ||
} | ||
|
||
pub fn config() -> &'static Config { | ||
// SAFETY: This is safe because the setup() requirements. | ||
unsafe { &*CONFIG } | ||
} | ||
|
||
/// # Safety | ||
/// This function must be called immediately in the kernel entry point. After that it must never | ||
/// be called again. | ||
pub unsafe fn set_boot_env(env: &'static BootEnv) { | ||
pub unsafe fn setup(env: &'static BootEnv, conf: &'static Config) { | ||
BOOT_ENV = env; | ||
CONFIG = conf; | ||
} | ||
|
||
static mut BOOT_ENV: *const BootEnv = null(); | ||
static mut CONFIG: *const Config = null(); | ||
|
||
#[elf_note(section = ".note.obkrnl.page-size", name = "obkrnl", ty = 0)] | ||
static NOTE_PAGE_SIZE: [u8; size_of::<usize>()] = PAGE_SIZE.to_ne_bytes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters