| Crates.io | userspace_build |
| lib.rs | userspace_build |
| version | 0.1.128 |
| created_at | 2025-08-31 16:55:51.564874+00 |
| updated_at | 2025-09-22 19:34:02.155936+00 |
| description | userspace_build library |
| homepage | https://userspace.builders |
| repository | https://github.com/ze-gois/rust_userspace_build |
| max_upload_size | |
| id | 1818695 |
| size | 185,335 |
Userspace is a Rust implementation of a standard library for userspace applications, designed to work without depending on the Rust standard library (no_std). It provides safe abstractions for low-level operations, architecture-specific functionality, memory management, and executable file format handling.
no_std environmentsuserspace/
โโโ src/
โ โโโ file/ # File format handling (ELF)
โ โโโ macros/ # Utility macros
โ โโโ memory/ # Memory management
โ โ โโโ alloc/ # Allocation functionality
โ โ โโโ page/ # Page management
โ โ โโโ stack/ # Stack handling
โ โโโ target/ # Architecture abstractions
โ โ โโโ architecture/ # CPU architecture specifics
โ โ โโโ operating_system/ # OS abstractions
โ โโโ traits/ # Common interfaces
โ โโโ types/ # Library-specific types
โ โโโ entry.rs # Binary entry point
โ โโโ library.rs # Main library definition
โ โโโ panic.rs # Panic handler
โ โโโ result.rs # Error handling
โโโ Cargo.toml # Project configuration
โโโ build.rs # Build script
Add this to your Cargo.toml:
[dependencies]
userspace = { git = "https://github.com/ze-gois/rust_userspace" }
// Create a no_std binary
#![no_std]
#![no_main]
use userspace;
#[unsafe(no_mangle)]
pub extern "C" fn entry(stack_pointer: userspace::target::arch::PointerType) -> ! {
// Convert raw stack pointer to a safe abstraction
let stack = userspace::memory::Stack::from_pointer(
userspace::target::arch::Pointer(stack_pointer)
);
// Access command-line arguments
if let Some(arg) = stack.arguments.get(0) {
userspace::info!("Program name: {:?}", arg);
}
// Work with the ELF format
if let Some(arg0) = stack.arguments.get(0) {
if !arg0.pointer.0.is_null() {
unsafe {
let cstr = core::ffi::CStr::from_ptr(arg0.pointer.0 as *mut i8);
let path = cstr.to_str().unwrap();
let elf = userspace::file::format::elf::header::Identifier::from_path(path);
userspace::info!("ELF identifier: {:?}", elf);
}
}
}
loop {}
}
Userspace is designed with a layered architecture:
Each layer builds upon the previous ones, providing increasingly higher-level abstractions while maintaining safety and performance.
The memory subsystem provides:
The target subsystem abstracts architecture details:
Currently focused on x86_64, but designed to be extensible to other architectures.
Userspace uses several experimental Rust features:
#![feature(generic_const_exprs)]
#![feature(generic_const_items)]
These enable advanced type-level programming required for zero-cost abstractions across architectures.
For more detailed documentation:
cargo doc --open
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -am 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the terms found in the LICENSE file.