Reorganize, process capabilities
This commit is contained in:
parent
a68019ee31
commit
6829ef55fc
62
Cargo.lock
generated
62
Cargo.lock
generated
@ -58,6 +58,26 @@ version = "1.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "enumflags2"
|
||||||
|
version = "0.7.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147"
|
||||||
|
dependencies = [
|
||||||
|
"enumflags2_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "enumflags2_derive"
|
||||||
|
version = "0.7.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flagset"
|
name = "flagset"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
@ -72,9 +92,10 @@ checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gila"
|
name = "gila"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"acpi",
|
"acpi",
|
||||||
|
"enumflags2",
|
||||||
"flagset",
|
"flagset",
|
||||||
"limine",
|
"limine",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
@ -85,9 +106,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limine"
|
name = "limine"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ca87cab008b8efeebdbe037cd4d1438037d48c5cb6fed939ffa5aa06315a321"
|
checksum = "6e6cb7fd182815ec1ea9e26061418ac37c3eebea47a14e773c563533f277bcef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.0",
|
"bitflags 2.9.0",
|
||||||
]
|
]
|
||||||
@ -133,6 +154,24 @@ version = "1.11.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
|
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.94"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.20"
|
version = "1.0.20"
|
||||||
@ -163,6 +202,17 @@ dependencies = [
|
|||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "talc"
|
name = "talc"
|
||||||
version = "4.4.2"
|
version = "4.4.2"
|
||||||
@ -172,6 +222,12 @@ dependencies = [
|
|||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vga"
|
name = "vga"
|
||||||
version = "0.2.9"
|
version = "0.2.9"
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gila"
|
name = "gila"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
acpi = "5.1.0"
|
acpi = "5.1.0"
|
||||||
|
enumflags2 = "0.7.11"
|
||||||
flagset = "0.4.6"
|
flagset = "0.4.6"
|
||||||
limine = "0.3.1"
|
limine = "0.4.0"
|
||||||
once_cell = { version = "1.20.3", default-features = false, features = ["alloc", "critical-section"] }
|
once_cell = { version = "1.20.3", default-features = false, features = ["alloc", "critical-section"] }
|
||||||
spin = "0.9.8"
|
spin = "0.9.8"
|
||||||
talc = "4.4.2"
|
talc = "4.4.2"
|
||||||
@ -15,8 +16,8 @@ talc = "4.4.2"
|
|||||||
vga = "0.2.9"
|
vga = "0.2.9"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "gila"
|
name = "kernel"
|
||||||
path = "src/main.rs"
|
path = "src/kernel/main.rs"
|
||||||
test = false
|
test = false
|
||||||
doctest = false
|
doctest = false
|
||||||
bench = false
|
bench = false
|
||||||
|
43
Makefile
43
Makefile
@ -7,7 +7,7 @@ LIMINEDIR ?= "/usr/share/limine"
|
|||||||
# QEMU system is set accordingly and automatically
|
# QEMU system is set accordingly and automatically
|
||||||
qemu = "qemu-system-x86_64"
|
qemu = "qemu-system-x86_64"
|
||||||
# List of required BIOS files
|
# List of required BIOS files
|
||||||
limine-files = limine-bios.sys limine-bios-cd.bin limine-bios-uefi-cd.bin
|
limine-files = limine-bios.sys limine-bios-cd.bin limine-bios-uefi-cd.bin BOOTX64.EFI BOOTIA32.EFI BOOTAA64.EFI BOOTLOONGARCH64.EFI BOOTRISCV64.EFI
|
||||||
|
|
||||||
# Properly set QEMU command
|
# Properly set QEMU command
|
||||||
ifeq ($(TARGET),x86_64-unknown-none)
|
ifeq ($(TARGET),x86_64-unknown-none)
|
||||||
@ -24,7 +24,7 @@ endif
|
|||||||
|
|
||||||
executables = rustup xorriso limine $(qemu)
|
executables = rustup xorriso limine $(qemu)
|
||||||
|
|
||||||
all: gila iso run
|
all: kernel iso run
|
||||||
|
|
||||||
checkenv:
|
checkenv:
|
||||||
|
|
||||||
@ -42,37 +42,50 @@ prepare: checkenv
|
|||||||
rustup target add $(TARGET)
|
rustup target add $(TARGET)
|
||||||
|
|
||||||
# Run the ISO in an emulator.
|
# Run the ISO in an emulator.
|
||||||
run: build/gila.iso
|
run: iso
|
||||||
|
|
||||||
$(qemu) -drive file=build/gila.iso,format=raw,index=0,media=disk
|
$(qemu) -drive file=build/gila.iso,format=raw,index=0,media=disk
|
||||||
|
|
||||||
# Build the bootable kernel image.
|
# Build the bootable kernel image.
|
||||||
.PHONY: build/iso/gila
|
.PHONY: build/kernel
|
||||||
gila: prepare $(shell find src -type f -name *.rs) $(shell find src -type f -name linker.ld)
|
kernel: prepare $(shell find src/kernel/ -type f -name *.rs) $(shell find src/kernel/ -type f -name linker.ld)
|
||||||
|
|
||||||
mkdir -p build/iso/
|
cargo build --bin kernel --release -Zunstable-options --artifact-dir=build
|
||||||
cargo build --release -Z unstable-options --target=$(TARGET) --artifact-dir build/iso/
|
|
||||||
|
|
||||||
# Build a bootable ISO and install Limine.
|
# Build a bootable ISO and install Limine.
|
||||||
.PHONY: build/gila.iso
|
.PHONY: build/gila.iso
|
||||||
iso: build/iso/gila limine.conf
|
iso: kernel limine.conf
|
||||||
|
|
||||||
mkdir -p build/iso/limine
|
mkdir -p build/iso/boot/limine
|
||||||
mkdir -p build/iso/EFI/BOOT
|
mkdir -p build/iso/EFI/BOOT
|
||||||
|
|
||||||
|
# Copy Limine files
|
||||||
cp ./limine.conf build/iso/
|
cp ./limine.conf build/iso/
|
||||||
cp $(LIMINEDIR)/limine-bios.sys build/iso/limine/
|
cp $(LIMINEDIR)/limine-bios.sys build/iso/boot/limine/
|
||||||
cp $(LIMINEDIR)/limine-bios-cd.bin build/iso/limine/
|
cp $(LIMINEDIR)/limine-bios-cd.bin build/iso/boot/limine/
|
||||||
cp $(LIMINEDIR)/limine-uefi-cd.bin build/iso/limine/
|
cp $(LIMINEDIR)/limine-uefi-cd.bin build/iso/boot/limine/
|
||||||
|
cp $(LIMINEDIR)/BOOTX64.EFI build/iso/EFI/BOOT/
|
||||||
|
cp $(LIMINEDIR)/BOOTIA32.EFI build/iso/EFI/BOOT/
|
||||||
|
cp $(LIMINEDIR)/BOOTAA64.EFI build/iso/EFI/BOOT/
|
||||||
|
cp $(LIMINEDIR)/BOOTLOONGARCH64.EFI build/iso/EFI/BOOT
|
||||||
|
cp $(LIMINEDIR)/BOOTRISCV64.EFI build/iso/EFI/BOOT
|
||||||
|
|
||||||
tree build/iso/
|
# Copy kernel
|
||||||
|
mv build/kernel build/iso/boot/
|
||||||
|
|
||||||
xorriso -as mkisofs -b limine/limine-bios-cd.bin -no-emul-boot \
|
# Build filesystem tree
|
||||||
|
mkdir -p build/iso/system/bin
|
||||||
|
mkdir -p build/iso/system/tmp
|
||||||
|
mkdir -p build/iso/system/cfg
|
||||||
|
|
||||||
|
xorriso -as mkisofs -b boot/limine/limine-bios-cd.bin -no-emul-boot \
|
||||||
-boot-load-size 4 -boot-info-table --efi-boot \
|
-boot-load-size 4 -boot-info-table --efi-boot \
|
||||||
limine/limine-uefi-cd.bin -efi-boot-part --efi-boot-image \
|
boot/limine/limine-uefi-cd.bin -efi-boot-part --efi-boot-image \
|
||||||
--protective-msdos-label build/iso -o build/gila.iso
|
--protective-msdos-label build/iso -o build/gila.iso
|
||||||
limine bios-install build/gila.iso
|
limine bios-install build/gila.iso
|
||||||
|
|
||||||
|
tree build/iso/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
cargo clean
|
cargo clean
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
# Gila v0.2.2 - a Rust Microkernel
|
# Gila v0.2.3 - a Rust Microkernel
|
||||||
|
|
||||||
Gila is a Rust microkernel OS, inspired by the Xinu embedded OS, as well as Linux. I aim to implement multitasking and different users for processes, and eventually a filesystem. I do not aim to make it POSIX-compatible, but it will likely end up sharing many features with POSIX operating systems.
|
Gila is a Rust microkernel OS, inspired by the Xinu embedded OS, as well as Linux. I aim to implement multitasking and different users for processes, and eventually a filesystem. I do not aim to make it POSIX-compatible, but it will likely end up sharing many features with POSIX operating systems.
|
||||||
|
|
||||||
|
4
build.rs
4
build.rs
@ -1,7 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||||
// Tell cargo to pass the linker script to the linker..
|
// Tell cargo to pass the linker script to the linker..
|
||||||
println!("cargo:rustc-link-arg=-Tsrc/arch/{arch}/linker.ld");
|
println!("cargo:rustc-link-arg=-Tsrc/kernel/arch/{arch}/linker.ld");
|
||||||
// ..and to re-run if it changes.
|
// ..and to re-run if it changes.
|
||||||
println!("cargo:rerun-if-changed=src/arch/{arch}linker.ld");
|
println!("cargo:rerun-if-changed=src/kernel/arch/{arch}linker.ld");
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,5 @@ timeout: 5
|
|||||||
|
|
||||||
/Gila
|
/Gila
|
||||||
protocol: limine
|
protocol: limine
|
||||||
kernel_path: boot():/gila
|
kernel_path: boot():/boot/kernel
|
||||||
cmdline: -loglevel=INFO -logdev=display,serial
|
cmdline: -loglevel=INFO -logdev=display,serial
|
||||||
|
@ -12,10 +12,10 @@ static _END_MARKER: RequestsEndMarker = RequestsEndMarker::new();
|
|||||||
pub static BASE_REVISION: BaseRevision = limine::BaseRevision::new();
|
pub static BASE_REVISION: BaseRevision = limine::BaseRevision::new();
|
||||||
#[used]
|
#[used]
|
||||||
#[unsafe(link_section = ".requests")]
|
#[unsafe(link_section = ".requests")]
|
||||||
pub static SMP_REQUEST: SmpRequest = limine::request::SmpRequest::new();
|
pub static MP_REQUEST: MpRequest = limine::request::MpRequest::new();
|
||||||
#[used]
|
#[used]
|
||||||
#[unsafe(link_section = ".requests")]
|
#[unsafe(link_section = ".requests")]
|
||||||
pub static FILE_REQUEST: KernelFileRequest = limine::request::KernelFileRequest::new();
|
pub static FILE_REQUEST: ExecutableFileRequest = limine::request::ExecutableFileRequest::new();
|
||||||
#[used]
|
#[used]
|
||||||
#[unsafe(link_section = ".requests")]
|
#[unsafe(link_section = ".requests")]
|
||||||
pub static RSDP_REQUEST: RsdpRequest = limine::request::RsdpRequest::new();
|
pub static RSDP_REQUEST: RsdpRequest = limine::request::RsdpRequest::new();
|
@ -27,8 +27,8 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up some stuff based on kernel params if we get any
|
// Set up some stuff based on kernel params if we get any
|
||||||
if let Some(kernel_file_response) = FILE_REQUEST.get_response() {
|
if let Some(executable_file_response) = FILE_REQUEST.get_response() {
|
||||||
let kernel_parameters = get_kernel_params(kernel_file_response.file().cmdline());
|
let kernel_parameters = get_kernel_params(limine::file::File::string(executable_file_response.file()).to_bytes());
|
||||||
|
|
||||||
// Set up logging level from params
|
// Set up logging level from params
|
||||||
if let Some(level) = kernel_parameters.get("-loglevel") {
|
if let Some(level) = kernel_parameters.get("-loglevel") {
|
||||||
@ -51,14 +51,14 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
&format!(
|
&format!(
|
||||||
"Boot: Kernel cmdline: {}",
|
"Boot: Kernel cmdline: {}",
|
||||||
String::from_utf8_lossy(kernel_file_response.file().cmdline())
|
String::from_utf8_lossy(limine::file::File::string(executable_file_response.file()).to_bytes())
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
log(
|
log(
|
||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
&format!(
|
&format!(
|
||||||
"Boot: Kernel file path: {}",
|
"Boot: Kernel file path: {}",
|
||||||
String::from_utf8_lossy(kernel_file_response.file().path())
|
String::from_utf8_lossy(executable_file_response.file().path().to_bytes())
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -68,20 +68,20 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
);
|
);
|
||||||
log(LogLevel::Info, "Boot: Trans Rights!");
|
log(LogLevel::Info, "Boot: Trans Rights!");
|
||||||
|
|
||||||
let _smp_response = SMP_REQUEST.get_response();
|
let _smp_response = MP_REQUEST.get_response();
|
||||||
match _smp_response {
|
match _smp_response {
|
||||||
None => log(
|
None => log(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
"SMP: bootloader response not received. Multiprocessing is disabled.",
|
"MP: bootloader response not received. Multiprocessing is disabled.",
|
||||||
),
|
),
|
||||||
Some(resp) => {
|
Some(resp) => {
|
||||||
log(
|
log(
|
||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
"SMP: bootloader response received. Multiprocessing enabled.",
|
"MP: bootloader response received. Multiprocessing enabled.",
|
||||||
);
|
);
|
||||||
log(
|
log(
|
||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
&format!("SMP: {} CPUs found.", resp.cpus().len()),
|
&format!("MP: {} CPUs found.", resp.cpus().len()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
|
use enumflags2::{bitflags, make_bitflags, BitFlags};
|
||||||
|
|
||||||
use crate::memory::MemoryRegion;
|
use crate::memory::MemoryRegion;
|
||||||
|
|
||||||
use crate::memory::alloc;
|
use crate::memory::alloc;
|
||||||
@ -31,6 +33,8 @@ pub struct Process {
|
|||||||
prio: u16,
|
prio: u16,
|
||||||
/// Which semaphor the process is waiting on.
|
/// Which semaphor the process is waiting on.
|
||||||
semaphor_wait: Option<u32>,
|
semaphor_wait: Option<u32>,
|
||||||
|
/// What capabilities the process has
|
||||||
|
capabilities: BitFlags<ProcessCapabilities>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -50,3 +54,26 @@ pub enum ProcessState {
|
|||||||
Sleeping,
|
Sleeping,
|
||||||
Suspended,
|
Suspended,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[bitflags]
|
||||||
|
#[repr(u32)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub enum ProcessCapabilities {
|
||||||
|
// Process capabilities
|
||||||
|
ProcessEnum, // Enumerate running process IDs and names
|
||||||
|
ProcessRead, // Read information from a process struct
|
||||||
|
ProcessKill, // Kill any process
|
||||||
|
ProcessSpawn, // Create a new process
|
||||||
|
ProcessExec, // Replace self with new process image
|
||||||
|
// File system capabilities
|
||||||
|
FileEnum, // Enumerate directories and files
|
||||||
|
FileRead, // Read files
|
||||||
|
FileWrite, // Write to files
|
||||||
|
FilePermission, // Modify file permissions
|
||||||
|
FileCreate, // Create files
|
||||||
|
FileDelete, // Delete files
|
||||||
|
FileSystem, // Mount, unmount, and modify filesystems
|
||||||
|
// Kernel config capabilities
|
||||||
|
KernelCfgRead, // Read kernel configurations
|
||||||
|
KernelCfgWrite, // Modify kernel configurations
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user