⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

veridian_kernel/utils/
version.rs

1//! Kernel version information
2//!
3//! Provides compile-time version metadata including semantic version,
4//! git hash, and build timestamp. Accessible via the `SYS_VERSION` syscall.
5
6#[derive(Debug, Clone, Copy)]
7#[repr(C)]
8pub struct KernelVersionInfo {
9    pub major: u16,
10    pub minor: u16,
11    pub patch: u16,
12    pub git_hash: [u8; 40],
13    pub build_timestamp: u64,
14    pub supported_archs: u64,
15}
16
17/// Returns the kernel version information.
18pub fn get_version_info() -> KernelVersionInfo {
19    // These values would typically be populated by the build script.
20    let git_hash_str = env!("GIT_HASH", "0000000000000000000000000000000000000000");
21    let mut git_hash = [0u8; 40];
22    git_hash.copy_from_slice(git_hash_str.as_bytes());
23
24    KernelVersionInfo {
25        major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap_or(0),
26        minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap_or(0),
27        patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap_or(0),
28        git_hash,
29        build_timestamp: env!("BUILD_TIMESTAMP").parse().unwrap_or(0),
30        supported_archs: (1 << 0) | (1 << 1) | (1 << 2), // x86_64, AArch64, RISC-V
31    }
32}