From b5a694a126e9de62abe1dd89a040b27b05cb2337 Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 29 Sep 2023 15:45:38 -0500 Subject: [PATCH] Commit work --- .cargo/config.toml | 6 +--- 2 | 61 ---------------------------------------- Cargo.toml | 2 +- src/ext2.rs | 3 +- src/main.rs | 32 ++++++++++++--------- x86_64-unknown-none.json | 14 --------- 6 files changed, 23 insertions(+), 95 deletions(-) delete mode 100644 2 delete mode 100644 x86_64-unknown-none.json diff --git a/.cargo/config.toml b/.cargo/config.toml index 62d96b1..a7cfd25 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,9 +1,5 @@ -[unstable] -build-std-features = ["compiler-builtins-mem"] -build-std = ["core", "compiler_builtins", "alloc"] - [build] -target = "x86_64-unknown-none.json" +target = "x86_64-unknown-none" [install] root = "../kernel/sysroot" diff --git a/2 b/2 deleted file mode 100644 index 58ba175..0000000 --- a/2 +++ /dev/null @@ -1,61 +0,0 @@ -#![no_std] -#![no_main] -#![feature(int_roundings)] -#![deny(unsafe_op_in_unsafe_fn)] - -use ext2::Ext2; -use std::fmt::Debug; -use std::loader::{Binary, Loader}; -use std::path::Path; -use std::syscalls::{get_initrd, new_process}; -use std::{ipc, prelude::*, str}; -use tar_no_std::TarArchiveRef; - -use ata::PRIMARY_SLAVE; - -mod ata; -mod ext2; - -main!({ - let primary_slave = PRIMARY_SLAVE.unwrap(); - let fs = Ext2::new(primary_slave).unwrap(); - print_all_files("/", &fs); - println!("Hello, syscall format world!"); - let initrd = TarArchiveRef::new(get_initrd()); - let test_proc = Binary::new( - initrd - .entries() - .find(|entry| entry.filename() == *"bin/test_proc") - .expect("test_proc not found") - .data(), - ) - .expect("test_proc not an ELF binary"); - let space = Loader::load(&test_proc); - let pid = new_process(test_proc.entry_point(), space).expect("Failed to create process"); - ipc::base::allow_protocol(0); - let id = ipc::rpc::send_call(pid, 0, 0, "Hello, RPC call world".as_bytes()); - let ret = loop { - ipc::rpc::process_messages(); - if let Some(ret) = ipc::rpc::get_return(id) { - dbg!(); - break ret; - } - }; - dbg!(&ret.retval); - println!("{}", str::from_utf8(&ret.retval).unwrap()); - loop {} -}); - -fn print_all_files + Debug>(path: P, fs: &Ext2) { - for entry in fs.read_dir(path).unwrap() { - let entry = entry.unwrap(); - if entry.metadata().file_type().is_dir() { - print_all_files(entry.path(), fs); - } else { - let mut file = fs.open(entry.path()).unwrap(); - let mut buf = String::new(); - file.read_to_string(&mut buf).unwrap(); - print!("{:?}:\n{}", entry.path(), buf); - } - } -} diff --git a/Cargo.toml b/Cargo.toml index 9eb6c49..ae35284 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ std = { path = "../std" } bitflags = "1.3.2" spin = "0.9.4" tap = "1.0.1" -x86_64 = { git = "https://github.com/pjht/x86_64", features = ["experimental"] } +x86_64 = { git = "https://gitea.pterpstra.com/mikros/x86_64", features = ["experimental"] } binread = { version = "2.2.0", path = "../binread/binread", default-features = false } itertools = { version = "0.10.3", default-features = false, features = ["use_alloc"] } serde = { version = "1.0.144", default-features = false, features = ["alloc", "derive"] } diff --git a/src/ext2.rs b/src/ext2.rs index 1a69128..143efd7 100644 --- a/src/ext2.rs +++ b/src/ext2.rs @@ -7,6 +7,7 @@ mod structs; use block_group_table::BlockGroupDescriptorTable; use block_reader::BlockReader; +use std::dbg; use std::io::{self, Read}; use std::path::{Component, Path}; use std::string::{String, ToString}; @@ -29,7 +30,7 @@ impl Ext2 { let superblock = Superblock::read_from_disk(&mut disk)?; let reader = BlockReader::new(disk, &superblock); Ok(Self { - descriptor_table: BlockGroupDescriptorTable::new(&superblock, &reader)?, + descriptor_table: dbg!(BlockGroupDescriptorTable::new(&superblock, &reader)?), reader, }) } diff --git a/src/main.rs b/src/main.rs index 9f53c14..0363757 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,10 @@ mod ata; mod ext2; main!({ + dbg!(); // let primary_slave = PRIMARY_SLAVE.unwrap(); let initrd = TarArchiveRef::new(get_initrd()); + dbg!(); let test_proc = Binary::new( initrd .entries() @@ -26,30 +28,34 @@ main!({ .data(), ) .expect("test_proc not an ELF binary"); + dbg!(); let space = Loader::load(&test_proc); + dbg!(); let pid = new_process(test_proc.entry_point(), space).expect("Failed to create process"); + dbg!(); let client = dev_driver_rpc::Client::new(pid); + dbg!(); let fd = client.open("sdb").unwrap(); + dbg!(); let sdb = File::from_pid_fd(pid, fd); + dbg!(); let fs = Ext2::new(sdb).unwrap(); - // dbg!(); + dbg!(); print_all_files("/", &fs); + dbg!(); }); fn print_all_files + Debug>(path: P, fs: &Ext2) { - // dbg!(); for entry in fs.read_dir(path).unwrap() { - // dbg!(); let entry = entry.unwrap(); - if entry.metadata().file_type().is_dir() { - print_all_files(entry.path(), fs); - } else { - // dbg!(); - let mut file = fs.open(entry.path()).unwrap(); - // dbg!(); - let mut buf = String::new(); - file.read_to_string(&mut buf).unwrap(); - print!("{:?}:\n{}", entry.path(), buf); - } + println!("{:?}", entry.path()); + // if entry.metadata().file_type().is_dir() { + // // print_all_files(entry.path(), fs); + // } else { + // // let mut file = fs.open(entry.path()).unwrap(); + // // let mut buf = String::new(); + // // file.read_to_string(&mut buf).unwrap(); + // // print!("{:?}:\n{}", entry.path(), buf); + // } } } diff --git a/x86_64-unknown-none.json b/x86_64-unknown-none.json deleted file mode 100644 index 74696c7..0000000 --- a/x86_64-unknown-none.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "llvm-target": "x86_64-unknown-none", - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", - "arch": "x86_64", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "os": "none", - "executables": true, - "linker-flavor": "ld.lld", - "linker": "rust-lld", - "panic-strategy": "abort", - "features": "-mmx,-sse,+soft-float" -}