Compare commits
2 Commits
519633b769
...
e2c2586a19
Author | SHA1 | Date | |
---|---|---|---|
e2c2586a19 | |||
ffe889a934 |
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -2,6 +2,17 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
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]]
|
[[package]]
|
||||||
name = "atomic-polyfill"
|
name = "atomic-polyfill"
|
||||||
version = "0.1.11"
|
version = "0.1.11"
|
||||||
@ -146,6 +157,7 @@ dependencies = [
|
|||||||
name = "julios"
|
name = "julios"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
"conquer-once",
|
"conquer-once",
|
||||||
"crossbeam-queue",
|
"crossbeam-queue",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
@ -19,6 +19,7 @@ linked_list_allocator = "0.9.0"
|
|||||||
postcard = "1.0.0"
|
postcard = "1.0.0"
|
||||||
serde = { version = "1.0", default-features = false, features = ["alloc"] }
|
serde = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||||
heapless = "0.7.16"
|
heapless = "0.7.16"
|
||||||
|
async-trait = "0.1.60"
|
||||||
|
|
||||||
[dependencies.lazy_static]
|
[dependencies.lazy_static]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
@ -8,7 +8,6 @@ use interrupt::{INTERRUPT_FUTURE};
|
|||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use spin::Mutex;
|
|
||||||
use crate::utils::AsyncMutex;
|
use crate::utils::AsyncMutex;
|
||||||
use x86_64::instructions::port::Port;
|
use x86_64::instructions::port::Port;
|
||||||
|
|
||||||
|
43
src/fd/mod.rs
Normal file
43
src/fd/mod.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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;
|
||||||
|
}
|
30
src/fs/iso/fd.rs
Normal file
30
src/fs/iso/fd.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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,12 +3,14 @@ const ISO_BLOCK_SIZE: usize = 2048;
|
|||||||
// Twin values structs
|
// Twin values structs
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub struct MultiEndian32 {
|
pub struct MultiEndian32 {
|
||||||
le: u32, // Little endian value
|
le: u32, // Little endian value
|
||||||
be: u32, // Big endian value
|
be: u32, // Big endian value
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub struct MultiEndian16 {
|
pub struct MultiEndian16 {
|
||||||
le: u16, // Little endian value
|
le: u16, // Little endian value
|
||||||
be: u16, // Big endian value
|
be: u16, // Big endian value
|
||||||
@ -18,6 +20,7 @@ pub struct MultiEndian16 {
|
|||||||
// Path table structure
|
// Path table structure
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
struct IsoPathTable {
|
struct IsoPathTable {
|
||||||
idf_len: u8, // Identifier name length
|
idf_len: u8, // Identifier name length
|
||||||
ext_size: u8, // Extended attribute record length
|
ext_size: u8, // Extended attribute record length
|
||||||
@ -41,6 +44,7 @@ impl IsoPathTable {
|
|||||||
const ISO_DATE_LEN: usize = 7;
|
const ISO_DATE_LEN: usize = 7;
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
enum IsoFileType {
|
enum IsoFileType {
|
||||||
HIDDEN = 0x1, // Hidden file
|
HIDDEN = 0x1, // Hidden file
|
||||||
ISDIR = 0x2, // Directory
|
ISDIR = 0x2, // Directory
|
||||||
@ -51,6 +55,7 @@ enum IsoFileType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub struct IsoDir {
|
pub struct IsoDir {
|
||||||
dir_size: u8, // Length of directory record
|
dir_size: u8, // Length of directory record
|
||||||
ext_size: u8, // Length of extended attribute record
|
ext_size: u8, // Length of extended attribute record
|
||||||
@ -94,6 +99,7 @@ const ISO_BIBFIL_LEN: usize = 37;
|
|||||||
const ISO_LDATE_LEN: usize = 17;
|
const ISO_LDATE_LEN: usize = 17;
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub struct IsoPrimVolDesc {
|
pub struct IsoPrimVolDesc {
|
||||||
pub vol_desc_type: u8, // Volume descripto type (1)
|
pub vol_desc_type: u8, // Volume descripto type (1)
|
||||||
pub std_identifier: [u8; 5], // standard identifier ("CD001")
|
pub std_identifier: [u8; 5], // standard identifier ("CD001")
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
pub mod iso9660;
|
pub mod iso9660;
|
||||||
|
mod fd;
|
||||||
|
|
||||||
use crate::println;
|
use crate::println;
|
||||||
use crate::drivers::atapi::{DRIVE};
|
use crate::drivers::atapi::{DRIVE};
|
||||||
|
use crate::fd::{FD_TABLE, FDt};
|
||||||
use crate::utils::unserialize;
|
use crate::utils::unserialize;
|
||||||
use iso9660::{IsoPrimVolDesc};
|
|
||||||
|
|
||||||
pub async fn init_prim_vol_desc() {
|
use iso9660::{IsoPrimVolDesc};
|
||||||
|
use fd::IsoFD;
|
||||||
|
|
||||||
|
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
|
||||||
let desc_block = DRIVE
|
let desc_block = DRIVE
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
@ -13,7 +17,11 @@ pub async fn init_prim_vol_desc() {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK)
|
.read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK)
|
||||||
.await;
|
.await;
|
||||||
let prim_vol_desc: &IsoPrimVolDesc = unserialize::<IsoPrimVolDesc>(desc_block.as_ptr());
|
*unserialize::<IsoPrimVolDesc>(desc_block.as_ptr())
|
||||||
|
}
|
||||||
println!("{:?}", alloc::string::String::from_utf8_lossy(&prim_vol_desc.std_identifier));
|
|
||||||
|
pub async fn open() -> FDt {
|
||||||
|
let fd = IsoFD::new();
|
||||||
|
FD_TABLE.lock().await.register_fd(fd.clone());
|
||||||
|
fd
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ mod memory;
|
|||||||
mod task;
|
mod task;
|
||||||
mod fs;
|
mod fs;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
mod fd;
|
||||||
|
|
||||||
//#[macro_use]
|
//#[macro_use]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
@ -57,6 +58,12 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
|
|||||||
let mut executor = Executor::new();
|
let mut executor = Executor::new();
|
||||||
executor.spawn(Task::new(drivers::atapi::init()));
|
executor.spawn(Task::new(drivers::atapi::init()));
|
||||||
executor.spawn(Task::new(keyboard::print_keypresses()));
|
executor.spawn(Task::new(keyboard::print_keypresses()));
|
||||||
executor.spawn(Task::new(fs::iso::init_prim_vol_desc()));
|
executor.spawn(Task::new(get_file()));
|
||||||
executor.run();
|
executor.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async fn get_file() {
|
||||||
|
let fd = fs::iso::open().await;
|
||||||
|
fd.borrow_mut().read(&[], 0).await;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user