Compare commits

..

No commits in common. "e2c2586a195451e356eb1459178f5c16ea7a723d" and "519633b769ce9eb2c0abb00f1f117c6f66c66a6f" have entirely different histories.

8 changed files with 5 additions and 111 deletions

12
Cargo.lock generated

@ -2,17 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "async-trait"
version = "0.1.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d1d8ab452a3936018a687b20e6f7cf5363d713b732b8884001317b0e48aa3"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "atomic-polyfill"
version = "0.1.11"
@ -157,7 +146,6 @@ dependencies = [
name = "julios"
version = "0.1.0"
dependencies = [
"async-trait",
"conquer-once",
"crossbeam-queue",
"futures-util",

@ -19,7 +19,6 @@ linked_list_allocator = "0.9.0"
postcard = "1.0.0"
serde = { version = "1.0", default-features = false, features = ["alloc"] }
heapless = "0.7.16"
async-trait = "0.1.60"
[dependencies.lazy_static]
version = "1.0"

@ -8,6 +8,7 @@ use interrupt::{INTERRUPT_FUTURE};
use core::convert::TryInto;
use lazy_static::lazy_static;
use spin::Mutex;
use crate::utils::AsyncMutex;
use x86_64::instructions::port::Port;

@ -1,43 +0,0 @@
use crate::utils::AsyncMutex;
use alloc::{collections::BTreeMap, sync::Arc, boxed::Box};
use async_trait::async_trait;
use core::cell::RefCell;
use lazy_static::lazy_static;
pub type FDt = Arc<RefCell<dyn FileDescriptor>>;
lazy_static! {
pub static ref FD_TABLE: AsyncMutex<FDTable> = {
AsyncMutex::new(FDTable::new())
};
}
pub struct FDId(u64);
impl FDId {
pub fn new() -> Self {
// TODO: search for first available fd
FDId(1)
}
}
pub struct FDTable {
table: BTreeMap<FDId, FDt>,
}
impl FDTable {
pub fn new() -> Self {
FDTable { table: BTreeMap::new() }
}
pub fn register_fd(&mut self, fd: FDt) {
// TODO
}
}
#[async_trait]
pub trait FileDescriptor {
async fn write(&mut self, buf: &[u8], count: usize) -> isize;
async fn read(&mut self, buf: &[u8], count: usize) -> isize;
}

@ -1,30 +0,0 @@
use crate::println;
use crate::fd::{FDId, FileDescriptor, FDt};
use alloc::{sync::Arc, boxed::Box};
use async_trait::async_trait;
use core::cell::RefCell;
pub struct IsoFD {
pub fd: FDId,
}
impl IsoFD {
pub fn new() -> FDt {
Arc::new(RefCell::new(IsoFD {
fd: FDId::new(),
}))
}
}
#[async_trait]
impl FileDescriptor for IsoFD {
async fn write(&mut self, buf: &[u8], count: usize) -> isize {
0
}
async fn read(&mut self, buf: &[u8], count: usize) -> isize {
println!("Read from fd");
0
}
}

@ -3,14 +3,12 @@ const ISO_BLOCK_SIZE: usize = 2048;
// Twin values structs
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub struct MultiEndian32 {
le: u32, // Little endian value
be: u32, // Big endian value
}
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub struct MultiEndian16 {
le: u16, // Little endian value
be: u16, // Big endian value
@ -20,7 +18,6 @@ pub struct MultiEndian16 {
// Path table structure
#[repr(C, packed)]
#[derive(Copy, Clone)]
struct IsoPathTable {
idf_len: u8, // Identifier name length
ext_size: u8, // Extended attribute record length
@ -44,7 +41,6 @@ impl IsoPathTable {
const ISO_DATE_LEN: usize = 7;
#[repr(u8)]
#[derive(Copy, Clone)]
enum IsoFileType {
HIDDEN = 0x1, // Hidden file
ISDIR = 0x2, // Directory
@ -55,7 +51,6 @@ enum IsoFileType {
}
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub struct IsoDir {
dir_size: u8, // Length of directory record
ext_size: u8, // Length of extended attribute record
@ -99,7 +94,6 @@ const ISO_BIBFIL_LEN: usize = 37;
const ISO_LDATE_LEN: usize = 17;
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub struct IsoPrimVolDesc {
pub vol_desc_type: u8, // Volume descripto type (1)
pub std_identifier: [u8; 5], // standard identifier ("CD001")

@ -1,15 +1,11 @@
pub mod iso9660;
mod fd;
use crate::println;
use crate::drivers::atapi::{DRIVE};
use crate::fd::{FD_TABLE, FDt};
use crate::utils::unserialize;
use iso9660::{IsoPrimVolDesc};
use fd::IsoFD;
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
pub async fn init_prim_vol_desc() {
let desc_block = DRIVE
.lock()
.await
@ -17,11 +13,7 @@ pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
.unwrap()
.read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK)
.await;
*unserialize::<IsoPrimVolDesc>(desc_block.as_ptr())
}
let prim_vol_desc: &IsoPrimVolDesc = unserialize::<IsoPrimVolDesc>(desc_block.as_ptr());
pub async fn open() -> FDt {
let fd = IsoFD::new();
FD_TABLE.lock().await.register_fd(fd.clone());
fd
println!("{:?}", alloc::string::String::from_utf8_lossy(&prim_vol_desc.std_identifier));
}

@ -9,7 +9,6 @@ mod memory;
mod task;
mod fs;
mod utils;
mod fd;
//#[macro_use]
extern crate alloc;
@ -58,12 +57,6 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
let mut executor = Executor::new();
executor.spawn(Task::new(drivers::atapi::init()));
executor.spawn(Task::new(keyboard::print_keypresses()));
executor.spawn(Task::new(get_file()));
executor.spawn(Task::new(fs::iso::init_prim_vol_desc()));
executor.run();
}
async fn get_file() {
let fd = fs::iso::open().await;
fd.borrow_mut().read(&[], 0).await;
}