forked from AbleOS/ableos_userland
Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
able | 6c38f2b2f1 | ||
able | 5be66ba32e | ||
able | 6df69e2f1a | ||
able | a7414ca01a | ||
able | 917ca121e3 | ||
able | 48ca72e613 | ||
able | 138428fac3 | ||
Able | ca80c17819 | ||
Able | be96cb797a | ||
Able | 9239fe7f9e | ||
Able | 7881ee2881 | ||
Able | e75565d7ef | ||
Able | 6b63d00de0 | ||
Able | 824697aa7c | ||
Able | a2bca6f901 |
103
Cargo.lock
generated
103
Cargo.lock
generated
|
@ -6,6 +6,8 @@ version = 3
|
||||||
name = "able_graphics_library"
|
name = "able_graphics_library"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"embedded-graphics",
|
||||||
|
"log",
|
||||||
"versioning",
|
"versioning",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ dependencies = [
|
||||||
name = "aidl"
|
name = "aidl"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos 0.13.0",
|
"logos",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -76,6 +78,12 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
name = "axel2wat"
|
name = "axel2wat"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "az"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
|
@ -98,6 +106,12 @@ version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
@ -110,7 +124,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.13.1",
|
"hashbrown 0.13.1",
|
||||||
"log",
|
"log",
|
||||||
"toml 0.5.9 (git+https://git.ablecorp.us/theoddgarlic/toml-rs)",
|
"toml 0.5.9 (git+https://git.ablecorp.us/asya/toml-rs)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -139,6 +153,38 @@ dependencies = [
|
||||||
name = "derelict_microarchitecture"
|
name = "derelict_microarchitecture"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-graphics"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "750082c65094fbcc4baf9ba31583ce9a8bb7f52cadfb96f6164b1bc7f922f32b"
|
||||||
|
dependencies = [
|
||||||
|
"az",
|
||||||
|
"byteorder",
|
||||||
|
"embedded-graphics-core",
|
||||||
|
"float-cmp",
|
||||||
|
"micromath",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-graphics-core"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8b1239db5f3eeb7e33e35bd10bd014e7b2537b17e071f726a09351431337cfa"
|
||||||
|
dependencies = [
|
||||||
|
"az",
|
||||||
|
"byteorder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "float-cmp"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1267f4ac4f343772758f7b1bdcbe767c218bbab93bb432acbf5162bbf85a6c4"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
@ -225,22 +271,13 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "logos"
|
|
||||||
version = "0.12.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1"
|
|
||||||
dependencies = [
|
|
||||||
"logos-derive 0.12.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos"
|
name = "logos"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1"
|
checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos-derive 0.13.0",
|
"logos-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -257,20 +294,6 @@ dependencies = [
|
||||||
"syn 2.0.15",
|
"syn 2.0.15",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "logos-derive"
|
|
||||||
version = "0.12.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"
|
|
||||||
dependencies = [
|
|
||||||
"beef",
|
|
||||||
"fnv",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"regex-syntax",
|
|
||||||
"syn 1.0.105",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos-derive"
|
name = "logos-derive"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
|
@ -295,10 +318,25 @@ dependencies = [
|
||||||
"versioning",
|
"versioning",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "micromath"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "no_video"
|
name = "no_video"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "number_prefix"
|
name = "number_prefix"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -520,7 +558,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.5.9"
|
version = "0.5.9"
|
||||||
source = "git+https://git.ablecorp.us/theoddgarlic/toml-rs#34db433429f3ad38921d13ac9aba74c8a706f376"
|
source = "git+https://git.ablecorp.us/asya/toml-rs#34db433429f3ad38921d13ac9aba74c8a706f376"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.12.3",
|
"hashbrown 0.12.3",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -590,7 +628,7 @@ checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
||||||
name = "uri"
|
name = "uri"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos 0.13.0",
|
"logos",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -606,6 +644,13 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vfs"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"std",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vgable"
|
name = "vgable"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -631,7 +676,7 @@ dependencies = [
|
||||||
name = "wat2wasm"
|
name = "wat2wasm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos 0.12.1",
|
"logos",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -11,6 +11,8 @@ members = [
|
||||||
"drivers/graphics/novideo",
|
"drivers/graphics/novideo",
|
||||||
"drivers/graphics/vgable",
|
"drivers/graphics/vgable",
|
||||||
|
|
||||||
|
"drivers/vfs",
|
||||||
|
|
||||||
"drivers/keyboards/ps2_keyboard",
|
"drivers/keyboards/ps2_keyboard",
|
||||||
"drivers/mice/ps2_mouse",
|
"drivers/mice/ps2_mouse",
|
||||||
|
|
||||||
|
|
9
drivers/vfs/Cargo.toml
Normal file
9
drivers/vfs/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "vfs"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# std = { path = "../../libraries/std" }
|
42
drivers/vfs/src/cache.rs
Normal file
42
drivers/vfs/src/cache.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
pub struct Cache {
|
||||||
|
// A limit on how many open files can be in this cache
|
||||||
|
// Usefull to prevent hundreds of processes caching thousands of files
|
||||||
|
// 0 == No Limit
|
||||||
|
file_id_limit: u64,
|
||||||
|
|
||||||
|
// Total bytes allowed to be cached before a file is pushed out of the cache
|
||||||
|
total_byte_size: u64,
|
||||||
|
current_byte_size: u64,
|
||||||
|
cache: Vec<(FileID, Vec<u8>)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cache {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
file_id_limit: 1024,
|
||||||
|
total_byte_size: 1024 * 16,
|
||||||
|
current_byte_size: 0,
|
||||||
|
cache: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn recalculate_cache(&mut self) {
|
||||||
|
let mut current: u64 = 0;
|
||||||
|
for (_, file) in &self.cache {
|
||||||
|
current += file.len() as u64;
|
||||||
|
}
|
||||||
|
self.current_byte_size = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn recalc_cache_test() {
|
||||||
|
let mut cache = Cache::default();
|
||||||
|
let mut temp_file_vec: Vec<u8> = Vec::new();
|
||||||
|
for x in 0u64..=10 {
|
||||||
|
temp_file_vec.push(x.try_into().unwrap());
|
||||||
|
let file = (x, temp_file_vec.clone());
|
||||||
|
cache.cache.push(file);
|
||||||
|
}
|
||||||
|
cache.recalculate_cache();
|
||||||
|
assert_eq!(cache.current_byte_size, 66);
|
||||||
|
}
|
105
drivers/vfs/src/main.rs
Normal file
105
drivers/vfs/src/main.rs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
// #![no_std]
|
||||||
|
#![feature(async_fn_in_trait)]
|
||||||
|
|
||||||
|
pub mod cache;
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
pub type Path = String;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let vfs = VFS::new();
|
||||||
|
// TODO: load config for the vfs
|
||||||
|
|
||||||
|
// advertise the VFS service
|
||||||
|
// wait on proccesses to subscribe and send messages
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: in the implementation this should be a basevalue of some randomized value to
|
||||||
|
// prevent the ability to check how many files are open on the system
|
||||||
|
pub type FileID = u64;
|
||||||
|
|
||||||
|
pub trait FileIO {
|
||||||
|
// Store the FileID in the VFS to allow multiple programs to have a FileID without conflicting
|
||||||
|
fn s_open(path: Path) -> Result<FileID, FileIOError>;
|
||||||
|
async fn a_open(path: Path) -> Result<FileID, FileIOError>;
|
||||||
|
|
||||||
|
// Close the file and flush changes to disk
|
||||||
|
fn s_close(file_id: FileID) -> Result<(), FileIOError>;
|
||||||
|
async fn a_close(file_id: FileID) -> Result<(), FileIOError>;
|
||||||
|
|
||||||
|
// Offset into the file to allow for things like reading a specific value
|
||||||
|
// Length from the offset
|
||||||
|
fn s_read(file_id: FileID, offset: usize, length: u64) -> Result<Vec<u8>, FileIOError>;
|
||||||
|
async fn a_read(file_id: FileID, offset: usize, length: u64) -> Result<Vec<u8>, FileIOError>;
|
||||||
|
|
||||||
|
// Offset into the file to allow for things like reading a specific value
|
||||||
|
fn s_write(file_id: FileID, offset: usize, data: Vec<u8>) -> Result<(), FileIOError>;
|
||||||
|
async fn a_write(file_id: FileID, offset: usize, data: Vec<u8>) -> Result<(), FileIOError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum FileIOError {
|
||||||
|
NoMountPoint,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MountPoint {
|
||||||
|
mount: Path,
|
||||||
|
// Use this to send the file requests to the right filesystem driver
|
||||||
|
filesystem_proc_id: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct VFS {
|
||||||
|
// If a file is used twice move it from first cache to second cache
|
||||||
|
// This is under the assumption that if you write to a file twice you will write again
|
||||||
|
first_layer: Cache,
|
||||||
|
second_layer: Cache,
|
||||||
|
mount_point_list: Vec<MountPoint>,
|
||||||
|
}
|
||||||
|
impl VFS {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
first_layer: Cache::default(),
|
||||||
|
second_layer: Cache::default(),
|
||||||
|
mount_point_list: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_mountpoint(self, path: Path) -> Result<MountPoint, FileIOError> {
|
||||||
|
return Err(FileIOError::NoMountPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FileIO for VFS {
|
||||||
|
fn s_open(path: Path) -> Result<FileID, FileIOError> {
|
||||||
|
// Break up the path into a mountpoint and a path fragment
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn a_open(path: Path) -> Result<FileID, FileIOError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn s_close(file_id: FileID) -> Result<(), FileIOError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn a_close(file_id: FileID) -> Result<(), FileIOError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn s_read(file_id: FileID, offset: usize, length: u64) -> Result<Vec<u8>, FileIOError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn a_read(file_id: FileID, offset: usize, length: u64) -> Result<Vec<u8>, FileIOError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn s_write(file_id: FileID, offset: usize, data: Vec<u8>) -> Result<(), FileIOError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn a_write(file_id: FileID, offset: usize, data: Vec<u8>) -> Result<(), FileIOError> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,3 +7,5 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
versioning = { path = "../versioning" }
|
versioning = { path = "../versioning" }
|
||||||
|
embedded-graphics = "0.7.1"
|
||||||
|
log = "*"
|
||||||
|
|
|
@ -6,8 +6,6 @@ use alloc::vec::Vec;
|
||||||
|
|
||||||
use super::error::GPUError;
|
use super::error::GPUError;
|
||||||
|
|
||||||
pub type VertexBuffer = Vec<u8>;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct XYZ {
|
pub struct XYZ {
|
||||||
x: f64,
|
x: f64,
|
||||||
|
@ -22,28 +20,3 @@ pub struct XYZW {
|
||||||
z: f64,
|
z: f64,
|
||||||
w: f64,
|
w: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GraphicsEngine {
|
|
||||||
vertex_buffer_attributes_editable: bool,
|
|
||||||
vertex_buffer: VertexBuffer,
|
|
||||||
vertex_size: usize,
|
|
||||||
}
|
|
||||||
impl GraphicsEngine {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
vertex_buffer_attributes_editable: true,
|
|
||||||
vertex_buffer: Vec::new(),
|
|
||||||
vertex_size: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn append_vertex(&mut self, mut vertex: Vec<u8>) -> Result<(), GPUError> {
|
|
||||||
if self.vertex_buffer_attributes_editable {
|
|
||||||
return Err(GPUError::EngineNotInitialized);
|
|
||||||
}
|
|
||||||
if !vertex.len() == self.vertex_size {
|
|
||||||
return Err(GPUError::ImproperVertexSize);
|
|
||||||
}
|
|
||||||
self.vertex_buffer.append(&mut vertex);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
pub struct Color3 {
|
|
||||||
pub r: u8,
|
|
||||||
pub g: u8,
|
|
||||||
pub b: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Color3 {
|
|
||||||
/// Usage
|
|
||||||
/// The alpha value is a number between 0.0 and 1.0, which represents the transparency
|
|
||||||
/// or translucency of the other color.
|
|
||||||
pub fn blend(&self, other: &Self, alpha: f32) -> Self {
|
|
||||||
let r = (1.0 - alpha) * f32::from(self.r) + alpha * f32::from(other.r);
|
|
||||||
let g = (1.0 - alpha) * f32::from(self.g) + alpha * f32::from(other.g);
|
|
||||||
let b = (1.0 - alpha) * f32::from(self.b) + alpha * f32::from(other.b);
|
|
||||||
Self {
|
|
||||||
r: r as u8,
|
|
||||||
g: g as u8,
|
|
||||||
b: b as u8,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
use alloc::vec::Vec;
|
|
||||||
|
|
||||||
pub enum DisplayError {
|
|
||||||
InvalidFormat,
|
|
||||||
InvalidWidth,
|
|
||||||
InvalidHeight,
|
|
||||||
InvalidBPP,
|
|
||||||
InvalidFPS,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_display_string(s: &str) -> Result<(u32, u32, u32, u32), DisplayError> {
|
|
||||||
let parts: Vec<&str> = s.split('x').collect();
|
|
||||||
if parts.len() != 3 {
|
|
||||||
return Err(DisplayError::InvalidFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
let width = parts[0]
|
|
||||||
.parse::<u32>()
|
|
||||||
.map_err(|_| DisplayError::InvalidWidth)?;
|
|
||||||
let height = parts[1]
|
|
||||||
.parse::<u32>()
|
|
||||||
.map_err(|_| DisplayError::InvalidHeight)?;
|
|
||||||
let bits: Vec<&str> = parts[2].split('@').collect();
|
|
||||||
if bits.len() != 2 {
|
|
||||||
return Err(DisplayError::InvalidFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
let bpp = bits[0]
|
|
||||||
.parse::<u32>()
|
|
||||||
.map_err(|_| DisplayError::InvalidBPP)?;
|
|
||||||
let fps = bits[1]
|
|
||||||
.parse::<u32>()
|
|
||||||
.map_err(|_| DisplayError::InvalidFPS)?;
|
|
||||||
Ok((width, height, bpp, fps))
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
pub enum GPUError {
|
|
||||||
ImproperVertexSize = 10,
|
|
||||||
EngineNotInitialized = 100,
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
use core::ptr;
|
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
|
|
||||||
use super::color::Color3;
|
|
||||||
/// NOTE: Assumes the layout of RGBA
|
|
||||||
pub struct FrameBuffer {
|
|
||||||
pub width: u32,
|
|
||||||
pub height: u32,
|
|
||||||
pub data: Vec<u32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FrameBuffer {
|
|
||||||
pub fn new(width: u32, height: u32) -> Self {
|
|
||||||
let data = vec![0; (width * height) as usize];
|
|
||||||
FrameBuffer {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// WARNING: Slow
|
|
||||||
pub fn set_pixel(&mut self, x: u32, y: u32, color: u32) {
|
|
||||||
let index = (y * self.width + x) as usize;
|
|
||||||
self.data[index] = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// WARNING: Slow
|
|
||||||
pub fn get_pixel(&self, x: u32, y: u32) -> u32 {
|
|
||||||
let index = (y * self.width + x) as usize;
|
|
||||||
self.data[index]
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Quickly writes the provided color to the whole framebuffer
|
|
||||||
pub fn clear(&mut self, color: Color3) {
|
|
||||||
unsafe {
|
|
||||||
// TODO: properly clear instead of only copying red
|
|
||||||
ptr::write_bytes(self.data.as_mut_ptr(), color.r, self.data.len());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(Able): Test preformance of clear2
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn clear2(&mut self, color: u32) {
|
|
||||||
self.data.fill(color);
|
|
||||||
}
|
|
||||||
/// Check the size of one framebuffer vs the other.
|
|
||||||
/// NOTE: Just because this returns false does not mean that something is wrong
|
|
||||||
/// there are cases that this makes sense
|
|
||||||
pub fn check_size(&self, other: &FrameBuffer) -> bool {
|
|
||||||
self.width == other.width && self.height == other.height
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1 @@
|
||||||
pub mod buffer;
|
pub mod vertex;
|
||||||
pub mod color;
|
|
||||||
pub mod display;
|
|
||||||
pub mod error;
|
|
||||||
pub mod framebuffer;
|
|
||||||
|
|
48
libraries/able_graphics_library/src/engine3d/vertex.rs
Normal file
48
libraries/able_graphics_library/src/engine3d/vertex.rs
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
pub type VertexBuffer = Vec<u8>;
|
||||||
|
|
||||||
|
pub struct GraphicsEngine {
|
||||||
|
vertex_buffer_attributes_editable: bool,
|
||||||
|
vertex_buffer: VertexBuffer,
|
||||||
|
vertex_size: usize,
|
||||||
|
}
|
||||||
|
impl GraphicsEngine {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
vertex_buffer_attributes_editable: true,
|
||||||
|
vertex_buffer: Vec::new(),
|
||||||
|
vertex_size: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn append_vertex(&mut self, mut vertex: Vec<u8>) -> Result<(), GPUError> {
|
||||||
|
if self.vertex_buffer_attributes_editable {
|
||||||
|
return Err(GPUError::EngineNotInitialized);
|
||||||
|
}
|
||||||
|
if !vertex.len() == self.vertex_size {
|
||||||
|
return Err(GPUError::ImproperVertexSize);
|
||||||
|
}
|
||||||
|
self.vertex_buffer.append(&mut vertex);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct XYZ {
|
||||||
|
x: f64,
|
||||||
|
y: f64,
|
||||||
|
z: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct XYZW {
|
||||||
|
x: f64,
|
||||||
|
y: f64,
|
||||||
|
z: f64,
|
||||||
|
w: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum GPUError {
|
||||||
|
ImproperVertexSize,
|
||||||
|
EngineNotInitialized,
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod x86;
|
|
@ -0,0 +1,90 @@
|
||||||
|
use embedded_graphics::{
|
||||||
|
pixelcolor::Rgb888,
|
||||||
|
prelude::{DrawTarget, IntoStorage, OriginDimensions, PixelColor, Point, Size},
|
||||||
|
primitives::{Line, Primitive, PrimitiveStyle},
|
||||||
|
Drawable, Pixel,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Display {
|
||||||
|
pub fb: *mut u32,
|
||||||
|
// Back buffer
|
||||||
|
pub bb: *mut u32,
|
||||||
|
pub size: Size,
|
||||||
|
pub color: Rgb888,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display {
|
||||||
|
pub fn set_color(&mut self, color: Rgb888) {
|
||||||
|
self.color = color;
|
||||||
|
}
|
||||||
|
pub fn swap_buffers(&mut self) {
|
||||||
|
let size: usize = (self.size.height * self.size.width).try_into().unwrap();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let dst_ptr = self.fb;
|
||||||
|
let src_ptr = self.bb;
|
||||||
|
core::ptr::copy_nonoverlapping(src_ptr, dst_ptr, size);
|
||||||
|
}
|
||||||
|
log::trace!("Update");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn line(
|
||||||
|
&mut self,
|
||||||
|
x1: i32,
|
||||||
|
y1: i32,
|
||||||
|
x2: i32,
|
||||||
|
y2: i32,
|
||||||
|
thickness: u32,
|
||||||
|
) -> Result<(), BlitOutOfBoundsError> {
|
||||||
|
let color = self.color;
|
||||||
|
let style = PrimitiveStyle::with_stroke(color, thickness);
|
||||||
|
|
||||||
|
Line::new(Point::new(x1, y1), Point::new(x2, y2))
|
||||||
|
.into_styled(style)
|
||||||
|
.draw(&mut *self)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl Send for Display {}
|
||||||
|
impl DrawTarget for Display {
|
||||||
|
type Color = Rgb888;
|
||||||
|
type Error = BlitOutOfBoundsError;
|
||||||
|
|
||||||
|
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = Pixel<Self::Color>>,
|
||||||
|
{
|
||||||
|
for Pixel(pos, rgb) in pixels {
|
||||||
|
let pos_x = u32::try_from(pos.x).map_err(|_| BlitOutOfBoundsError)?;
|
||||||
|
let pos_y = u32::try_from(pos.y).map_err(|_| BlitOutOfBoundsError)?;
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
if pos_x >= self.size.width || pos_y >= self.size.height {
|
||||||
|
return Err(BlitOutOfBoundsError);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.bb
|
||||||
|
.add(
|
||||||
|
(pos_y * self.size.width + pos_x)
|
||||||
|
.try_into()
|
||||||
|
.map_err(|_| BlitOutOfBoundsError)?,
|
||||||
|
)
|
||||||
|
.write_volatile(rgb.into_storage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OriginDimensions for Display {
|
||||||
|
#[inline]
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
self.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct BlitOutOfBoundsError;
|
|
@ -1,18 +1,9 @@
|
||||||
|
mod arch;
|
||||||
|
|
||||||
|
use core::fmt::Error;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
pub struct Color {
|
pub use arch::x86::Display;
|
||||||
r: u8,
|
|
||||||
g: u8,
|
|
||||||
b: u8,
|
|
||||||
a: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct PixelBuffer {
|
use self::arch::x86::BlitOutOfBoundsError;
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
data: Vec<Color>,
|
|
||||||
}
|
|
||||||
impl PixelBuffer {
|
|
||||||
pub fn xy_calc(x: usize, y: isize) {}
|
|
||||||
pub fn blit(&mut self, x: isize, y: isize, buff: PixelBuffer) {}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
Type Coordinate = i32;
|
||||||
|
Type Coordinates = (Coordinate, Coordinate);
|
||||||
|
|
||||||
|
|
||||||
|
Function line Takes(Coordinates, Coordinates) Returns(Nothing);
|
|
@ -15,7 +15,7 @@ hashbrown = "*"
|
||||||
|
|
||||||
|
|
||||||
[dependencies.toml]
|
[dependencies.toml]
|
||||||
git = "https://git.ablecorp.us:443/theoddgarlic/toml-rs"
|
git = "https://git.ablecorp.us:443/asya/toml-rs"
|
||||||
# version = "0.5.8"
|
# version = "0.5.8"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
|
|
|
@ -24,3 +24,7 @@ pub struct Result<T> {
|
||||||
pub ok: T,
|
pub ok: T,
|
||||||
pub err: ExternErrors,
|
pub err: ExternErrors,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Path {
|
||||||
|
parts: OSString,
|
||||||
|
}
|
||||||
|
|
16
libraries/std/src/allocator.rs
Normal file
16
libraries/std/src/allocator.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
use alloc::alloc::{GlobalAlloc, Layout};
|
||||||
|
|
||||||
|
struct MyAllocator;
|
||||||
|
|
||||||
|
unsafe impl GlobalAlloc for MyAllocator {
|
||||||
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
|
panic!();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
|
||||||
|
panic!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[global_allocator]
|
||||||
|
static GLOBAL: MyAllocator = MyAllocator;
|
|
@ -1,12 +1,3 @@
|
||||||
pub enum IOErrors {
|
pub enum IOErrors {
|
||||||
UnknownError,
|
UnknownError,
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub struct Port<T> {
|
|
||||||
// inner: T,
|
|
||||||
// }
|
|
||||||
// impl<T> Port<T> {
|
|
||||||
// pub fn read(&self) -> Result<T, IOErrors> {
|
|
||||||
// Ok(self.inner)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub mod env;
|
||||||
pub mod exit;
|
pub mod exit;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
|
|
||||||
|
pub mod allocator;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
pub mod panic;
|
pub mod panic;
|
||||||
|
|
||||||
|
@ -23,6 +24,8 @@ pub mod prelude;
|
||||||
|
|
||||||
use versioning::Version;
|
use versioning::Version;
|
||||||
|
|
||||||
|
pub mod path;
|
||||||
|
|
||||||
pub const VERSION: Version = Version::new(0, 1, 0);
|
pub const VERSION: Version = Version::new(0, 1, 0);
|
||||||
|
|
||||||
// extern crate alloc;
|
// extern crate alloc;
|
||||||
|
|
18
libraries/std/src/path.rs
Normal file
18
libraries/std/src/path.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
use alloc::string::{String, ToString};
|
||||||
|
|
||||||
|
pub struct Path {
|
||||||
|
pub path: Vec<String>,
|
||||||
|
}
|
||||||
|
impl Path {
|
||||||
|
pub fn new(path: String) -> Self {
|
||||||
|
let mut path_vec_string = alloc::vec![];
|
||||||
|
|
||||||
|
for part in path.split(&['\\', '/'][..]) {
|
||||||
|
path_vec_string.push(part.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
Path {
|
||||||
|
path: path_vec_string,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,3 +6,6 @@ pub use crate::print_char;
|
||||||
pub use core::panic;
|
pub use core::panic;
|
||||||
|
|
||||||
pub use versioning;
|
pub use versioning;
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
pub use alloc::vec::Vec;
|
||||||
|
|
|
@ -47,16 +47,18 @@ enum Token {
|
||||||
|
|
||||||
#[regex(r"//[ a-zA-Z!-+]+", |lex| lex.slice().parse().ok())]
|
#[regex(r"//[ a-zA-Z!-+]+", |lex| lex.slice().parse().ok())]
|
||||||
Comment(String),
|
Comment(String),
|
||||||
|
|
||||||
|
#[regex("[0-9]+", |lex| lex.slice().parse().ok())]
|
||||||
|
Number(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut lex = Token::lexer(include_str!("../../../programs/aidl/assets/vfs.idl"));
|
let mut lex = Token::lexer(include_str!("../../../programs/aidl/assets/vfs.idl"));
|
||||||
|
|
||||||
for token in lex {
|
for token in lex {
|
||||||
// let ok_token = token.ok();
|
let ok_token = token.ok();
|
||||||
// if ok_token.is_some() {
|
if ok_token.is_some() {
|
||||||
// println!("{:?}", ok_token.unwrap());
|
println!("{:?}", ok_token.unwrap());
|
||||||
// }
|
}
|
||||||
println!("{:?}", token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
0
programs/std_test/run.sh
Executable file → Normal file
0
programs/std_test/run.sh
Executable file → Normal file
|
@ -20,37 +20,42 @@ resolution = "1024x768x24"
|
||||||
core = "https://git.ablecorp.us/AbleOS/core"
|
core = "https://git.ablecorp.us/AbleOS/core"
|
||||||
userspace = "https://git.ablecorp.us/AbleOS/ableos_userland"
|
userspace = "https://git.ablecorp.us/AbleOS/ableos_userland"
|
||||||
|
|
||||||
[packages]
|
[apps]
|
||||||
[packages.list_files]
|
[apps.list_files]
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
hash = ""
|
hash = ""
|
||||||
repo = "userspace"
|
repo = "userspace"
|
||||||
authors = []
|
|
||||||
|
|
||||||
[packages.list_files.configuration]
|
|
||||||
|
|
||||||
[users]
|
|
||||||
[users.able]
|
[users.able]
|
||||||
home = "/home/able/"
|
|
||||||
password_hash = "abc123"
|
password_hash = "abc123"
|
||||||
|
|
||||||
[users.able.repositories]
|
[users.able.repositories]
|
||||||
able_repo = "https://git.ablecorp.us/able/ableos_packages"
|
able_repo = "https://git.ablecorp.us/able/ableos_apps"
|
||||||
[users.able.packages]
|
|
||||||
[users.able.packages.ablecraft]
|
|
||||||
|
[users.able.apps]
|
||||||
|
[users.able.apps.able_editor]
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
[users.able.apps.able_editor.plugins.rustfmt]
|
||||||
|
version = "1.0"
|
||||||
|
hash = ""
|
||||||
|
repo = "default"
|
||||||
|
[users.able.apps.able_editor.plugins.repositories]
|
||||||
|
default = ["https://github.com/able_editor/plugins"]
|
||||||
|
|
||||||
|
|
||||||
|
[users.able.apps.ablecraft]
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
hash = ""
|
hash = ""
|
||||||
repo = "able_repo"
|
repo = "able_repo"
|
||||||
|
|
||||||
[users.able.packages.ablecraft.configuration]
|
# [users.able.apps.ablecraft.configuration]
|
||||||
[users.able.packages.list_files.configuration]
|
[users.able.apps.list_files.configuration]
|
||||||
use_color = true
|
use_color = true
|
||||||
|
|
||||||
[users.able.packages.list_files.permissions]
|
[users.able.apps.list_files.permissions]
|
||||||
file_paths = ["/"]
|
file_paths = ["/"]
|
||||||
|
|
||||||
[users.chad]
|
[users.chad]
|
||||||
home = "/chad/"
|
|
||||||
password_hash = "abc123"
|
password_hash = "abc123"
|
||||||
[users.chad.repositories]
|
|
||||||
[users.chad.packages]
|
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
use std::{
|
use {
|
||||||
|
std::{
|
||||||
env,
|
env,
|
||||||
error::Error,
|
error::Error,
|
||||||
fmt::format,
|
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
path,
|
},
|
||||||
|
toml::{self, Table, Value},
|
||||||
};
|
};
|
||||||
use toml::Table;
|
|
||||||
use toml::{self, Value};
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let mut args: Vec<String> = env::args().collect();
|
let mut args: Vec<String> = env::args().collect();
|
||||||
|
// #[cfg(target_os="linux")]
|
||||||
|
|
||||||
|
if args.len() == 1 {
|
||||||
|
println!("Pass a file");
|
||||||
|
}
|
||||||
args.remove(0);
|
args.remove(0);
|
||||||
let file_path = &args[0];
|
let file_path = &args[0];
|
||||||
println!("{}", file_path);
|
println!("configuration path - {}", file_path);
|
||||||
|
|
||||||
let mut file = File::open(file_path).expect("Unable to open the file");
|
let mut file = File::open(file_path).unwrap(); //.expect("Unable to open the file");
|
||||||
|
|
||||||
let mut contents = String::new();
|
let mut contents = String::new();
|
||||||
file.read_to_string(&mut contents)
|
file.read_to_string(&mut contents)
|
||||||
|
@ -28,7 +33,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// HANDLE repolist
|
// HANDLE repolist
|
||||||
{
|
{
|
||||||
let repolist = value.get("repositories").unwrap();
|
let repolist = value.get("repositories").unwrap();
|
||||||
let ret = make_repolist("repolist.toml".to_string(), repolist);
|
fs::create_dir("disk/System")?;
|
||||||
|
let ret = make_repolist("System/repolist.toml".to_string(), repolist);
|
||||||
println!("making repolist {:?}", ret);
|
println!("making repolist {:?}", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +61,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
for user in users_table.keys() {
|
for user in users_table.keys() {
|
||||||
let ut = users_table.get(user).unwrap();
|
let ut = users_table.get(user).unwrap();
|
||||||
let home_path = ut.get("home").unwrap();
|
// let home_path = ut.get("home").unwrap();
|
||||||
|
let home_path = format!("/Users/{}", user);
|
||||||
let pass_hash = ut.get("password_hash").unwrap();
|
let pass_hash = ut.get("password_hash").unwrap();
|
||||||
|
|
||||||
passhash_list.push((user.to_string(), pass_hash.to_string()));
|
passhash_list.push((user.to_string(), pass_hash.to_string()));
|
||||||
|
@ -63,27 +70,32 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let ret = make_user(home_path.to_string());
|
let ret = make_user(home_path.to_string());
|
||||||
println!("making user return {:?}", ret);
|
println!("making user return {:?}", ret);
|
||||||
// Handle homepath generation of USER
|
// Handle homepath generation of USER
|
||||||
{
|
|
||||||
let mut hp = home_path.clone().to_string();
|
|
||||||
hp.remove(0);
|
|
||||||
hp.remove(0);
|
|
||||||
hp.remove(hp.len() - 1);
|
|
||||||
hp.remove(hp.len() - 1);
|
|
||||||
for package in ut.get("packages").unwrap().as_table().unwrap().keys() {
|
|
||||||
let pack_folder: String = format!("disk/{}/{}", hp, package);
|
|
||||||
let pack_config: String = format!("disk/{}/{}/config.toml", hp, package);
|
|
||||||
|
|
||||||
fs::create_dir(pack_folder)?;
|
{
|
||||||
|
let hp = home_path.clone().to_string();
|
||||||
|
let apps = ut.get("apps");
|
||||||
|
fs::create_dir_all(format!("disk/{}/Apps/", hp))?;
|
||||||
|
|
||||||
|
println!("ok");
|
||||||
|
if apps.is_some() {
|
||||||
|
let apps = apps.unwrap();
|
||||||
|
for app in apps.as_table().unwrap().keys() {
|
||||||
|
let pack_folder: String = format!("disk/{}/Apps/{}", hp, app);
|
||||||
|
let pack_config: String = format!("disk/{}/Apps/{}/config.toml", hp, app);
|
||||||
|
|
||||||
|
fs::create_dir_all(pack_folder)?;
|
||||||
let mut file = File::create(pack_config)?;
|
let mut file = File::create(pack_config)?;
|
||||||
// repo_list_str.as_bytes()
|
// repo_list_str.as_bytes()
|
||||||
let abc = ut
|
let abc = apps.get(app).unwrap().get("configuration");
|
||||||
.get("packages")
|
let tab = match abc {
|
||||||
.unwrap()
|
Some(val) => val.clone(),
|
||||||
.get(package)
|
None => {
|
||||||
.unwrap()
|
let tab = Table::new();
|
||||||
.get("configuration")
|
Value::Table(tab)
|
||||||
.unwrap();
|
}
|
||||||
let mut abc = abc.to_string();
|
};
|
||||||
|
// .unwrap_or(&Value::Table(Table::new()));
|
||||||
|
let mut abc = tab.to_string();
|
||||||
if abc.len() > 2 {
|
if abc.len() > 2 {
|
||||||
abc.remove(0);
|
abc.remove(0);
|
||||||
abc.remove(0);
|
abc.remove(0);
|
||||||
|
@ -98,26 +110,33 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
file.write_all(abc.as_bytes())?;
|
file.write_all(abc.as_bytes())?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
}
|
||||||
let repolist = ut.get("repositories").unwrap();
|
|
||||||
|
|
||||||
let mut hp = home_path.clone().to_string();
|
|
||||||
hp.remove(0);
|
|
||||||
hp.remove(0);
|
|
||||||
hp.remove(hp.len() - 1);
|
|
||||||
hp.remove(hp.len() - 1);
|
|
||||||
|
|
||||||
|
let repolist = ut.get("repositories");
|
||||||
|
let hp = home_path.clone().to_string();
|
||||||
let user_path_repolist = format!("{}/repolist.toml", hp.to_string());
|
let user_path_repolist = format!("{}/repolist.toml", hp.to_string());
|
||||||
println!("{}", user_path_repolist);
|
println!("{}", user_path_repolist);
|
||||||
|
match repolist {
|
||||||
|
Some(repolist) => {
|
||||||
let ret = make_repolist(user_path_repolist, repolist);
|
let ret = make_repolist(user_path_repolist, repolist);
|
||||||
println!("making repolist {:?}", ret);
|
println!("making repolist {:?}", ret);
|
||||||
}
|
}
|
||||||
|
None => {
|
||||||
|
let repolist = Table::new();
|
||||||
|
|
||||||
|
let ret = make_repolist(user_path_repolist, &Value::Table(repolist));
|
||||||
|
println!("making repolist {:?}", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ret = generate_password_hashlist(passhash_list);
|
let ret = generate_password_hashlist(passhash_list);
|
||||||
println!("making password hashlist {:?}", ret);
|
println!("making password hashlist {:?}", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Handle system wide things like repolist and Apps/
|
||||||
|
{}
|
||||||
|
|
||||||
// let mut file = File::create("disk/foo.txt")?;
|
// let mut file = File::create("disk/foo.txt")?;
|
||||||
// file.write_all(b"Hello, world!")?;
|
// file.write_all(b"Hello, world!")?;
|
||||||
|
|
||||||
|
@ -192,10 +211,7 @@ TERM_BACKDROP={}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_user(mut home_path: String) -> std::io::Result<()> {
|
pub fn make_user(home_path: String) -> std::io::Result<()> {
|
||||||
home_path.remove(0);
|
|
||||||
home_path.remove(home_path.len() - 1);
|
|
||||||
|
|
||||||
let path = format!("disk/{}", home_path);
|
let path = format!("disk/{}", home_path);
|
||||||
fs::create_dir_all(path)?;
|
fs::create_dir_all(path)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -203,6 +219,7 @@ pub fn make_user(mut home_path: String) -> std::io::Result<()> {
|
||||||
|
|
||||||
pub fn make_repolist(path: String, repolist: &Value) -> std::io::Result<()> {
|
pub fn make_repolist(path: String, repolist: &Value) -> std::io::Result<()> {
|
||||||
let path = format!("disk/{}", path);
|
let path = format!("disk/{}", path);
|
||||||
|
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
let mut repo_list_str = String::new();
|
let mut repo_list_str = String::new();
|
||||||
for (repo_name, repo_url) in repolist.as_table().unwrap() {
|
for (repo_name, repo_url) in repolist.as_table().unwrap() {
|
||||||
|
|
3
rustfmt.toml
Normal file
3
rustfmt.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
hex_literal_case = "Upper"
|
||||||
|
imports_granularity = "One"
|
||||||
|
struct_field_align_threshold = 5
|
31
shell.nix
Normal file
31
shell.nix
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
pkgs.mkShell rec {
|
||||||
|
buildInputs = with pkgs; [ clang llvmPackages.bintools rustup ];
|
||||||
|
RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain;
|
||||||
|
# https://github.com/rust-lang/rust-bindgen#environment-variables
|
||||||
|
LIBCLANG_PATH =
|
||||||
|
pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
|
||||||
|
shellHook = ''
|
||||||
|
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
|
||||||
|
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
|
||||||
|
'';
|
||||||
|
# Add precompiled library to rustc search path
|
||||||
|
RUSTFLAGS = (builtins.map (a: "-L ${a}/lib") [
|
||||||
|
# add libraries here (e.g. pkgs.libvmi)
|
||||||
|
]);
|
||||||
|
# Add glibc, clang, glib and other headers to bindgen search path
|
||||||
|
BINDGEN_EXTRA_CLANG_ARGS =
|
||||||
|
# Includes with normal include path
|
||||||
|
(builtins.map (a: ''-I"${a}/include"'') [
|
||||||
|
# add dev libraries here (e.g. pkgs.libvmi.dev)
|
||||||
|
pkgs.glibc.dev
|
||||||
|
])
|
||||||
|
# Includes with special directory paths
|
||||||
|
++ [
|
||||||
|
''
|
||||||
|
-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
|
||||||
|
''-I"${pkgs.glib.dev}/include/glib-2.0"''
|
||||||
|
"-I${pkgs.glib.out}/lib/glib-2.0/include/"
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue