gila/src/kernel/constants.rs
August 386852263a
All checks were successful
Continuous Integration / Check (push) Successful in 58s
Continuous Integration / Clippy (push) Successful in 1m6s
Remove unneeded CI jobs
2025-10-10 23:38:31 -04:00

105 lines
2.5 KiB
Rust

// Copyright (c) 2025 shibedrill
// SPDX-License-Identifier: MIT
use enumflags2::{BitFlags, bitflags};
use lazy_static::lazy_static;
use crate::format;
use crate::log::LogLevel;
use crate::memory::alloc::string::String;
#[bitflags]
#[repr(u8)]
#[derive(Debug, Clone, Copy)]
pub enum Features {
Acpi,
Dtb,
Compression,
Uefi,
}
lazy_static! {
#[derive(Debug)]
pub static ref FEATURE_FLAGS: BitFlags<Features> = {
let mut temp_flags = BitFlags::<Features>::empty();
#[cfg(feature = "acpi")]
temp_flags.insert(Features::Acpi);
#[cfg(feature = "dtb")]
temp_flags.insert(Features::Dtb);
#[cfg(feature = "compression")]
temp_flags.insert(Features::Compression);
#[cfg(feature = "uefi")]
temp_flags.insert(Features::Uefi);
temp_flags
};
}
#[allow(dead_code)]
pub static INITRAMFS_DEFAULT_PATH: &str = if cfg!(feature = "compression") {
"/boot/initramfs.tar.lzma"
} else {
"/boot/initramfs.tar"
};
pub static LOG_DEFAULT_LEVEL: LogLevel = LogLevel::Info;
pub static KERNEL_BUILD_PROFILE: &str = {
if cfg!(debug_assertions) {
"debug"
} else {
"release"
}
};
pub static KERNEL_ARCH: &str = {
if cfg!(target_arch = "x86_64") {
"x86_64"
} else if cfg!(target_arch = "aarch64") {
"aarch64"
} else if cfg!(target_arch = "loongarch64") {
"loongarch64"
} else if cfg!(target_arch = "riscv64") {
"riscv64"
} else {
"unsupported"
}
};
pub fn kernel_version_string() -> String {
format!(
"{KERNEL_VERSION_MAJOR}.{KERNEL_VERSION_MINOR}.{KERNEL_VERSION_PATCH}-{KERNEL_ARCH}-{KERNEL_BUILD_PROFILE}"
)
}
pub static ASCII_LOGO: [&str; 6] = [
" _ __ ",
" ____ _(_) /___ _",
" / __ `/ / / __ `/",
"/ /_/ / / / /_/ / ",
"\\__, /_/_/\\__,_/ ",
"/____/ ",
];
// FUCKING ADD CONST UNWRAP!!!
pub static KERNEL_VERSION_MAJOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MAJOR"), 10)
{
Ok(ver) => ver,
Err(_) => {
panic!("Invalid major version number ")
}
};
pub static KERNEL_VERSION_MINOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MINOR"), 10)
{
Ok(ver) => ver,
Err(_) => {
panic!("Invalid minor version number ")
}
};
pub static KERNEL_VERSION_PATCH: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_PATCH"), 10)
{
Ok(ver) => ver,
Err(_) => {
panic!("Invalid patch version number ")
}
};