Cleaning up structure
This commit is contained in:
parent
96dbb8afdc
commit
5af0c919f4
36
Cargo.lock
generated
36
Cargo.lock
generated
@ -8,6 +8,12 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
|
||||
[[package]]
|
||||
name = "flagset"
|
||||
version = "0.4.6"
|
||||
@ -19,9 +25,30 @@ name = "gila"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"flagset",
|
||||
"lazy_static",
|
||||
"limine",
|
||||
"spin",
|
||||
"talc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
dependencies = [
|
||||
"spin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "limine"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ca87cab008b8efeebdbe037cd4d1438037d48c5cb6fed939ffa5aa06315a321"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
@ -38,6 +65,15 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "talc"
|
||||
version = "4.4.2"
|
||||
|
@ -5,6 +5,9 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
flagset = "0.4.6"
|
||||
lazy_static = { version = "1.5.0", features = ["spin_no_std"] }
|
||||
limine = "0.3.1"
|
||||
spin = "0.9.8"
|
||||
talc = "4.4.2"
|
||||
|
||||
[[bin]]
|
||||
|
@ -1,4 +0,0 @@
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use talc::*;
|
||||
use core::alloc::{Allocator, Layout};
|
5
src/boot.rs
Normal file
5
src/boot.rs
Normal file
@ -0,0 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use limine::BaseRevision;
|
||||
|
||||
static BASE: BaseRevision = limine::BaseRevision::new();
|
10
src/lib.rs
10
src/lib.rs
@ -1,7 +1,13 @@
|
||||
#![no_std]
|
||||
#![feature(allocator_api)]
|
||||
|
||||
/// Process representation.
|
||||
pub mod process;
|
||||
/// Memory regions, allocation, flags, and whatnot.
|
||||
pub mod memory;
|
||||
pub mod alloc;
|
||||
pub mod panic;
|
||||
/// Panic handling function logic.
|
||||
pub mod panic;
|
||||
/// Boot services, handled by the Limine boot protocol.
|
||||
pub mod boot;
|
||||
/// Resources accessible from many parts of the code.
|
||||
pub mod resources;
|
@ -1,13 +1,15 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#![feature(allocator_api)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use gila::process;
|
||||
use gila::memory;
|
||||
use gila::alloc;
|
||||
use gila::panic;
|
||||
|
||||
fn main() {
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn main() {
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,26 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use flagset::flags;
|
||||
|
||||
use talc::*;
|
||||
use spin;
|
||||
use core::alloc::{Allocator, Layout};
|
||||
|
||||
static mut ARENA: [u8; 10000] = [0; 10000];
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOCATOR: Talck<spin::Mutex<()>, ClaimOnOom> = Talc::new(unsafe {
|
||||
// if we're in a hosted environment, the Rust runtime may allocate before
|
||||
// main() is called, so we need to initialize the arena automatically
|
||||
ClaimOnOom::new(Span::from_array(core::ptr::addr_of!(ARENA).cast_mut()))
|
||||
}).lock();
|
||||
|
||||
|
||||
pub struct MemoryRegion {
|
||||
start_address: usize,
|
||||
end_address: usize,
|
||||
|
||||
flags: MemoryRegionFlags,
|
||||
}
|
||||
|
||||
flags! {
|
||||
|
@ -1,19 +1,37 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use crate::memory::MemoryRegion;
|
||||
|
||||
use lazy_static;
|
||||
|
||||
extern crate alloc;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::string::String;
|
||||
|
||||
pub struct ProcessTable {}
|
||||
|
||||
pub struct Process {
|
||||
/// Unique process ID.
|
||||
proc_id: u32,
|
||||
/// ID of the parent process.
|
||||
parent_proc_id: u32,
|
||||
/// List of all child processes.
|
||||
child_proc_ids: Vec<u32>,
|
||||
/// Human readable name of the process, should be the command.
|
||||
name: String,
|
||||
/// The base address of the process stack within its memory region.
|
||||
stack_base_addr: usize,
|
||||
stack_ptr_addr: usize,
|
||||
mem_regions: Vec<MemoryRegion>,
|
||||
/// The length of the stack. This, plus the start address, is the stack size.
|
||||
stack_length: usize,
|
||||
/// The stack pointer, which is relative to the memory region start.
|
||||
stack_ptr: usize,
|
||||
/// The region of memory allocated to the process.
|
||||
mem_region: MemoryRegion,
|
||||
/// Process priority. Lower number is higher priority.
|
||||
prio: u16,
|
||||
/// Which semaphor the process is waiting on.
|
||||
semaphor_wait: Option<u32>,
|
||||
}
|
||||
|
||||
pub enum ProcessState {
|
||||
|
0
src/resources.rs
Normal file
0
src/resources.rs
Normal file
Loading…
Reference in New Issue
Block a user