add common

This commit is contained in:
mii443
2025-07-02 01:17:28 +09:00
parent 8ff258ba38
commit 2bc12cb469
7 changed files with 40 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
nel_os_bootloader/target nel_os_bootloader/target
nel_os_kernel/target nel_os_kernel/target
nel_os_common/target
nel_os_bootloader/fat.img nel_os_bootloader/fat.img
nel_os_bootloader/iso/ nel_os_bootloader/iso/
nel_os_bootloader/nel_os.iso nel_os_bootloader/nel_os.iso

View File

@ -49,10 +49,15 @@ version = "0.1.0"
dependencies = [ dependencies = [
"goblin", "goblin",
"log", "log",
"nel_os_common",
"uefi", "uefi",
"x86", "x86",
] ]
[[package]]
name = "nel_os_common"
version = "0.1.0"
[[package]] [[package]]
name = "plain" name = "plain"
version = "0.2.3" version = "0.2.3"

View File

@ -8,3 +8,4 @@ goblin = { version = "0.10.0", features = ["elf32", "elf64", "endian_fd"], defau
log = "0.4.27" log = "0.4.27"
uefi = { version = "0.35.0", features = ["logger", "panic_handler", "alloc"] } uefi = { version = "0.35.0", features = ["logger", "panic_handler", "alloc"] }
x86 = "0.52.0" x86 = "0.52.0"
nel_os_common = { path = "../nel_os_common" }

7
nel_os_common/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "nel_os_common"
version = "0.1.0"

6
nel_os_common/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "nel_os_common"
version = "0.1.0"
edition = "2024"
[dependencies]

3
nel_os_common/src/lib.rs Normal file
View File

@ -0,0 +1,3 @@
#![no_std]
pub mod memory;

View File

@ -0,0 +1,17 @@
#[repr(C)]
pub struct UsableMemory {
pub ranges: *const Range,
pub len: u64,
}
#[repr(C)]
pub struct Range {
pub start: u64,
pub end: u64,
}
impl UsableMemory {
pub fn ranges(&self) -> &[Range] {
unsafe { core::slice::from_raw_parts(self.ranges, self.len as usize) }
}
}