forked from koniifer/ableos
various QOL updates
This commit is contained in:
parent
5b4ee4f986
commit
59aaa9622b
|
@ -15,6 +15,7 @@ pub struct BinaryData {
|
||||||
pub enum HandleResource {
|
pub enum HandleResource {
|
||||||
Channel(Channel),
|
Channel(Channel),
|
||||||
// Device
|
// Device
|
||||||
|
/// Used for things like files or images or the like
|
||||||
BinaryData(BinaryData),
|
BinaryData(BinaryData),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use core::fmt::Error;
|
use core::fmt::Error;
|
||||||
|
|
||||||
// use crate::aalloc::aalloc;
|
// use crate::aalloc::aalloc;
|
||||||
use crate::arch::generate_process_pass;
|
|
||||||
use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2};
|
use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2};
|
||||||
|
use crate::arch::{generate_process_pass, shutdown};
|
||||||
use crate::channels::{Channel, ChannelPermission};
|
use crate::channels::{Channel, ChannelPermission};
|
||||||
use crate::devices::pci;
|
use crate::devices::pci;
|
||||||
use crate::filesystem::FILE_SYSTEM;
|
use crate::filesystem::FILE_SYSTEM;
|
||||||
|
@ -15,8 +15,12 @@ use acpi::{AcpiTables, PlatformInfo};
|
||||||
use alloc::collections::{vec_deque, VecDeque};
|
use alloc::collections::{vec_deque, VecDeque};
|
||||||
use cpuio::inb;
|
use cpuio::inb;
|
||||||
use cpuio::outb;
|
use cpuio::outb;
|
||||||
use genfs::Fs;
|
use ext2::fs::sync::{DirectoryEntry, Synced};
|
||||||
|
use ext2::fs::Ext2;
|
||||||
|
use ext2::sector::Size1024;
|
||||||
|
use ext2::sys::inode;
|
||||||
use genfs::OpenOptions;
|
use genfs::OpenOptions;
|
||||||
|
use genfs::{DirEntry, Fs};
|
||||||
use kernel::proccess::PID;
|
use kernel::proccess::PID;
|
||||||
use vga::writers::GraphicsWriter;
|
use vga::writers::GraphicsWriter;
|
||||||
|
|
||||||
|
@ -68,13 +72,13 @@ pub fn scratchpad() {
|
||||||
}";
|
}";
|
||||||
let axel = axel::parse(axel_raw.to_string());
|
let axel = axel::parse(axel_raw.to_string());
|
||||||
|
|
||||||
let xyz = pci::brute_force_scan();
|
// let xyz = pci::brute_force_scan();
|
||||||
for dev in xyz {
|
// for dev in xyz {
|
||||||
trace!("{:?}", dev);
|
// trace!("{:?}", dev);
|
||||||
dev.bars.iter().for_each(|bar| {
|
// dev.bars.iter().for_each(|bar| {
|
||||||
trace!("{:?}", bar);
|
// trace!("{:?}", bar);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
for node in axel {
|
for node in axel {
|
||||||
info!("{:?}", node);
|
info!("{:?}", node);
|
||||||
|
@ -97,16 +101,6 @@ pub fn scratchpad() {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let home_path = Path::new("/home/able".to_string());
|
|
||||||
|
|
||||||
let mut chan = Channel::new();
|
|
||||||
|
|
||||||
let ret = chan.read();
|
|
||||||
|
|
||||||
let chan_handle = Handle::from_channel(chan);
|
|
||||||
|
|
||||||
println!("{}", chan_handle);
|
|
||||||
|
|
||||||
real_shell();
|
real_shell();
|
||||||
}
|
}
|
||||||
use crate::graphics::VgaBuffer;
|
use crate::graphics::VgaBuffer;
|
||||||
|
@ -174,21 +168,35 @@ pub fn command_parser(user: String, command: String) {
|
||||||
let fs = &*FILE_SYSTEM.lock();
|
let fs = &*FILE_SYSTEM.lock();
|
||||||
let mut iter = command.split_whitespace();
|
let mut iter = command.split_whitespace();
|
||||||
|
|
||||||
|
// TODO: update the open() function to take either a ableOS path or a b"/" type path
|
||||||
|
let current_path = Path::new("/home/able".to_string());
|
||||||
|
trace!("Current path: {:?}", current_path);
|
||||||
|
let current_path = b"/home/able/";
|
||||||
|
|
||||||
let bin_name = iter.next().unwrap();
|
let bin_name = iter.next().unwrap();
|
||||||
|
|
||||||
if bin_name == "rhai" {
|
match bin_name {
|
||||||
|
"rhai" => {
|
||||||
drop(fs);
|
drop(fs);
|
||||||
shell();
|
shell();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
"list" | "ls" => {
|
||||||
|
for dir_entry in list_files_in_dir(fs, current_path) {
|
||||||
|
println!("{}", dir_entry.file_name_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"quit" => shutdown(),
|
||||||
|
|
||||||
|
_ => {
|
||||||
let home_exec_path = format!("/home/{}/bins/{}.wasm", user, bin_name);
|
let home_exec_path = format!("/home/{}/bins/{}.wasm", user, bin_name);
|
||||||
let shared_exec_path = format!("/shared/bins/{}.wasm", bin_name);
|
let shared_exec_path = format!("/shared/bins/{}.wasm", bin_name);
|
||||||
let system_exec_path = format!("/system/bins/{}.wasm", bin_name);
|
let system_exec_path = format!("/system/bins/{}.wasm", bin_name);
|
||||||
|
|
||||||
let home_exec_file = fs.open(&home_exec_path.as_bytes(), OpenOptions::new().read(true));
|
let home_exec_file = fs.open(&home_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||||
let shared_exec_file = fs.open(&shared_exec_path.as_bytes(), OpenOptions::new().read(true));
|
let shared_exec_file =
|
||||||
let system_exec_file = fs.open(&system_exec_path.as_bytes(), OpenOptions::new().read(true));
|
fs.open(&shared_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||||
|
let system_exec_file =
|
||||||
|
fs.open(&system_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||||
|
|
||||||
let mut in_home = false;
|
let mut in_home = false;
|
||||||
let mut in_shared = false;
|
let mut in_shared = false;
|
||||||
|
@ -238,6 +246,8 @@ pub fn command_parser(user: String, command: String) {
|
||||||
error!("No such binary: {}", bin_name);
|
error!("No such binary: {}", bin_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn sound(n_frequency: u32) {
|
pub fn sound(n_frequency: u32) {
|
||||||
let div: u32;
|
let div: u32;
|
||||||
|
@ -264,3 +274,14 @@ pub fn sound_off() {
|
||||||
};
|
};
|
||||||
reset_pit_for_cpu();
|
reset_pit_for_cpu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn list_files_in_dir(fs: &Synced<Ext2<Size1024, Vec<u8>>>, path: &[u8]) -> Vec<DirectoryEntry> {
|
||||||
|
let mut entry_list = vec![];
|
||||||
|
|
||||||
|
let dirr = fs.read_dir(b"/").unwrap();
|
||||||
|
for dir_entry in dirr {
|
||||||
|
entry_list.push(dir_entry.unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
entry_list
|
||||||
|
}
|
||||||
|
|
|
@ -710,6 +710,17 @@ impl DirEntry for DirectoryEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DirectoryEntry {
|
||||||
|
/// Turns a filename into a string for display
|
||||||
|
pub fn file_name_string(&self) -> String {
|
||||||
|
let mut filename = String::new();
|
||||||
|
for ch in &self.name {
|
||||||
|
filename.push(*ch as char);
|
||||||
|
}
|
||||||
|
filename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
Loading…
Reference in a new issue