Compare commits
13 Commits
e5eb05eb3d
...
184030a45e
Author | SHA1 | Date | |
---|---|---|---|
184030a45e | |||
23184f56a3 | |||
eb5a3a6635 | |||
446aff49ef | |||
40b4191d2d | |||
2e7415e1e6 | |||
0ad8ba9adb | |||
d4add50d82 | |||
91095b7d08 | |||
43eec9621c | |||
b2ffbc34b5 | |||
8518982932 | |||
b9e49dd946 |
@ -170,7 +170,7 @@ p2_table:
|
|||||||
resb 4096
|
resb 4096
|
||||||
|
|
||||||
stack_bottom:
|
stack_bottom:
|
||||||
resb 4 * 4096
|
resb 100 * 4096
|
||||||
stack_top:
|
stack_top:
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,26 +3,24 @@ use core::pin::Pin;
|
|||||||
use core::sync::atomic::{AtomicBool, Ordering};
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
use core::task::{Context, Poll};
|
use core::task::{Context, Poll};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use futures_util::task::AtomicWaker;
|
use futures_util::task::AtomicWaker;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref INTERRUPT_FUTURE: InterruptFuture = InterruptFuture::new();
|
pub static ref INTERRUPT_FUTURE: InterruptFuture = InterruptFuture::new();
|
||||||
|
|
||||||
static ref INTERRUPT: AtomicBool = AtomicBool::new(false);
|
static ref INTERRUPT: AtomicBool = AtomicBool::new(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WAKER: AtomicWaker = AtomicWaker::new();
|
static WAKER: AtomicWaker = AtomicWaker::new();
|
||||||
|
|
||||||
|
|
||||||
pub(crate) fn mark_interrupt() {
|
pub(crate) fn mark_interrupt() {
|
||||||
INTERRUPT.store(true, Ordering::Relaxed);
|
INTERRUPT.store(true, Ordering::Relaxed);
|
||||||
WAKER.wake();
|
WAKER.wake();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy,Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct InterruptFuture {
|
pub struct InterruptFuture {
|
||||||
_private:(),
|
_private: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InterruptFuture {
|
impl InterruptFuture {
|
||||||
@ -51,8 +49,8 @@ impl Future for InterruptFuture {
|
|||||||
true => {
|
true => {
|
||||||
WAKER.take();
|
WAKER.take();
|
||||||
Poll::Ready(())
|
Poll::Ready(())
|
||||||
},
|
}
|
||||||
false => Poll::Pending,
|
false => Poll::Pending,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
mod scsi;
|
|
||||||
pub mod interrupt;
|
pub mod interrupt;
|
||||||
|
mod scsi;
|
||||||
|
|
||||||
use crate::{println, serial_println};
|
use crate::{println, serial_println};
|
||||||
use scsi::{SCSIPacket};
|
use interrupt::INTERRUPT_FUTURE;
|
||||||
use interrupt::{INTERRUPT_FUTURE};
|
use scsi::SCSIPacket;
|
||||||
|
|
||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use crate::utils::AsyncMutex;
|
use crate::utils::AsyncMutex;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
use x86_64::instructions::port::Port;
|
use x86_64::instructions::port::Port;
|
||||||
|
|
||||||
const CD_SECTOR_SIZE: usize = 2048;
|
const CD_SECTOR_SIZE: usize = 2048;
|
||||||
|
|
||||||
// Data buses
|
// Data buses
|
||||||
const ATA_BUS_PRIMARY: u16= 0x1f0;
|
const ATA_BUS_PRIMARY: u16 = 0x1f0;
|
||||||
const ATA_BUS_SECONDARY: u16 = 0x170;
|
const ATA_BUS_SECONDARY: u16 = 0x170;
|
||||||
|
|
||||||
// Drives
|
// Drives
|
||||||
@ -54,16 +54,13 @@ static ATAPI_SIG: [u8; 4] = [
|
|||||||
ATAPI_SIG_SC,
|
ATAPI_SIG_SC,
|
||||||
ATAPI_SIG_LBA_LO,
|
ATAPI_SIG_LBA_LO,
|
||||||
ATAPI_SIG_LBA_MI,
|
ATAPI_SIG_LBA_MI,
|
||||||
ATAPI_SIG_LBA_HI
|
ATAPI_SIG_LBA_HI,
|
||||||
];
|
];
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref DRIVE: AsyncMutex<Option<ATABus>> = {
|
pub static ref DRIVE: AsyncMutex<Option<ATABus>> = AsyncMutex::new(ATABus::discover_atapi_drive());
|
||||||
AsyncMutex::new(ATABus::discover_atapi_drive())
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn init() {
|
pub async fn init() {
|
||||||
println!("Detecting drives");
|
println!("Detecting drives");
|
||||||
match DRIVE.lock().await.as_ref() {
|
match DRIVE.lock().await.as_ref() {
|
||||||
@ -72,12 +69,12 @@ pub async fn init() {
|
|||||||
let drive_type = match drive.current_drive {
|
let drive_type = match drive.current_drive {
|
||||||
ATA_DRIVE_MASTER => "master",
|
ATA_DRIVE_MASTER => "master",
|
||||||
ATA_DRIVE_SLAVE => "slave",
|
ATA_DRIVE_SLAVE => "slave",
|
||||||
_ => "bad"
|
_ => "bad",
|
||||||
};
|
};
|
||||||
let bus = match drive.base_port {
|
let bus = match drive.base_port {
|
||||||
ATA_BUS_PRIMARY => "primary",
|
ATA_BUS_PRIMARY => "primary",
|
||||||
ATA_BUS_SECONDARY => "secondary",
|
ATA_BUS_SECONDARY => "secondary",
|
||||||
_ => "bad"
|
_ => "bad",
|
||||||
};
|
};
|
||||||
println!("Detected {} drive on {} bus", drive_type, bus);
|
println!("Detected {} drive on {} bus", drive_type, bus);
|
||||||
}
|
}
|
||||||
@ -100,7 +97,7 @@ pub struct ATABus {
|
|||||||
address3: Port<u8>,
|
address3: Port<u8>,
|
||||||
drive_select: Port<u8>,
|
drive_select: Port<u8>,
|
||||||
command: Port<u8>, // write
|
command: Port<u8>, // write
|
||||||
status: Port<u8>, // read
|
status: Port<u8>, // read
|
||||||
dcr: Port<u8>,
|
dcr: Port<u8>,
|
||||||
|
|
||||||
current_drive: u8,
|
current_drive: u8,
|
||||||
@ -153,14 +150,14 @@ impl ATABus {
|
|||||||
|
|
||||||
data: Port::new(port),
|
data: Port::new(port),
|
||||||
features: Port::new(port + 1), // write
|
features: Port::new(port + 1), // write
|
||||||
error: Port::new(port + 1), // read
|
error: Port::new(port + 1), // read
|
||||||
sector_count: Port::new(port + 2),
|
sector_count: Port::new(port + 2),
|
||||||
address1: Port::new(port + 3),
|
address1: Port::new(port + 3),
|
||||||
address2: Port::new(port + 4),
|
address2: Port::new(port + 4),
|
||||||
address3: Port::new(port + 5),
|
address3: Port::new(port + 5),
|
||||||
drive_select: Port::new(port + 6),
|
drive_select: Port::new(port + 6),
|
||||||
command: Port::new(port + 7), // write
|
command: Port::new(port + 7), // write
|
||||||
status: Port::new(port + 7), // read
|
status: Port::new(port + 7), // read
|
||||||
dcr: Port::new(port + 0x206),
|
dcr: Port::new(port + 0x206),
|
||||||
|
|
||||||
current_drive: 0,
|
current_drive: 0,
|
||||||
@ -204,7 +201,7 @@ impl ATABus {
|
|||||||
self.wait_packet_request();
|
self.wait_packet_request();
|
||||||
|
|
||||||
for i in (0..raw_packet.len()).step_by(2) {
|
for i in (0..raw_packet.len()).step_by(2) {
|
||||||
let word = u16::from_le_bytes(raw_packet[i..i+2].try_into().unwrap());
|
let word = u16::from_le_bytes(raw_packet[i..i + 2].try_into().unwrap());
|
||||||
unsafe {
|
unsafe {
|
||||||
self.data.write(word);
|
self.data.write(word);
|
||||||
}
|
}
|
||||||
@ -323,9 +320,12 @@ impl ATABus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn print_block(lba: u32) {
|
pub async fn print_block(lba: u32) {
|
||||||
let block = DRIVE.lock().await.as_mut().unwrap().read_block(lba).await;
|
let block = DRIVE.lock().await.as_mut().unwrap().read_block(lba).await;
|
||||||
serial_println!("{:x?}", block);
|
serial_println!("{:x?}", block);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn read_block(lba: u32) -> [u8; CD_SECTOR_SIZE] {
|
||||||
|
DRIVE.lock().await.as_mut().unwrap().read_block(lba).await
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
use postcard::{to_vec};
|
use postcard::to_vec;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Debug, Eq, PartialEq)]
|
#[derive(Default, Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
@ -15,7 +15,7 @@ pub struct SCSIPacket {
|
|||||||
transfer_length_milo: u8,
|
transfer_length_milo: u8,
|
||||||
transfer_length_lo: u8,
|
transfer_length_lo: u8,
|
||||||
flags_hi: u8,
|
flags_hi: u8,
|
||||||
control: u8
|
control: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SCSIPacket {
|
impl SCSIPacket {
|
||||||
@ -40,4 +40,4 @@ impl SCSIPacket {
|
|||||||
self.transfer_length_mihi = ((l >> 0x10) & 0xff) as u8;
|
self.transfer_length_mihi = ((l >> 0x10) & 0xff) as u8;
|
||||||
self.transfer_length_hi = ((l >> 0x18) & 0xff) as u8;
|
self.transfer_length_hi = ((l >> 0x18) & 0xff) as u8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
|
pub mod atapi;
|
||||||
pub mod serial;
|
pub mod serial;
|
||||||
pub mod vga;
|
pub mod vga;
|
||||||
pub mod atapi;
|
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
use crate::println;
|
use crate::println;
|
||||||
use crate::utils::AsyncMutex;
|
use crate::utils::AsyncMutex;
|
||||||
|
|
||||||
use alloc::{collections::BTreeMap, sync::Arc, boxed::Box};
|
use alloc::{boxed::Box, collections::BTreeMap, sync::Arc};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
use core::sync::atomic::{AtomicU32, Ordering};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
pub type FDt = Arc<RefCell<dyn FileDescriptor>>;
|
pub type FDt = Arc<RefCell<dyn FileDescriptor>>;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref FD_TABLE: AsyncMutex<FDTable> = {
|
pub static ref FD_TABLE: AsyncMutex<FDTable> = AsyncMutex::new(FDTable::new());
|
||||||
AsyncMutex::new(FDTable::new())
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct FDId(u64);
|
pub struct FDId(u32);
|
||||||
|
|
||||||
impl FDId {
|
impl FDId {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
// TODO: search for first available fd
|
// TODO: search for first available fd
|
||||||
FDId(1)
|
static NEXT_ID: AtomicU32 = AtomicU32::new(0);
|
||||||
|
FDId(NEXT_ID.fetch_add(1, Ordering::Relaxed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,13 +30,25 @@ pub struct FDTable {
|
|||||||
|
|
||||||
impl FDTable {
|
impl FDTable {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
FDTable { table: BTreeMap::new() }
|
FDTable {
|
||||||
|
table: BTreeMap::new(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn register_fd(&mut self, fd: FDt) {
|
pub fn unregister_fd(&mut self, fd: &dyn FileDescriptor) {
|
||||||
// TODO
|
self.table.remove(&fd.get_fd());
|
||||||
|
println!(
|
||||||
|
"Unregistered fd: {:?}",
|
||||||
|
fd.get_fd()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn register_fd(&mut self, fd: FDt) {
|
||||||
self.table.insert(fd.borrow().get_fd(), fd.clone());
|
self.table.insert(fd.borrow().get_fd(), fd.clone());
|
||||||
println!("Registered fd: {:?}", self.table.get(&FDId(1)).unwrap().borrow().get_fd());
|
println!(
|
||||||
|
"Registered fd: {:?}",
|
||||||
|
self.table.get(&FDId(0)).unwrap().borrow().get_fd()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,5 +56,7 @@ impl FDTable {
|
|||||||
pub trait FileDescriptor {
|
pub trait FileDescriptor {
|
||||||
fn get_fd(&self) -> FDId;
|
fn get_fd(&self) -> FDId;
|
||||||
async fn write(&mut self, buf: &[u8], count: usize) -> isize;
|
async fn write(&mut self, buf: &[u8], count: usize) -> isize;
|
||||||
async fn read(&mut self, buf: &[u8], count: usize) -> isize;
|
async fn read(&mut self, buf: &mut [u8], count: usize) -> isize;
|
||||||
}
|
async fn close(&mut self);
|
||||||
|
async fn lseek(&mut self, offset: i32, whence: u32) -> i32;
|
||||||
|
}
|
||||||
|
@ -1,19 +1,30 @@
|
|||||||
use crate::println;
|
use crate::drivers::atapi::read_block;
|
||||||
use crate::fd::{FDId, FileDescriptor, FDt};
|
use crate::fd::{FDId, FDt, FileDescriptor, FD_TABLE};
|
||||||
|
|
||||||
use alloc::{sync::Arc, boxed::Box};
|
use super::iso9660::{IsoDir, ISO_BLOCK_SIZE};
|
||||||
|
|
||||||
|
use alloc::{boxed::Box, sync::Arc};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
pub struct IsoFD {
|
pub struct IsoFD {
|
||||||
pub fd: FDId,
|
pub fd: FDId,
|
||||||
|
offset: u32,
|
||||||
|
lba: u32,
|
||||||
|
size: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IsoFD {
|
impl IsoFD {
|
||||||
pub fn new() -> FDt {
|
pub async fn new(entry: &IsoDir) -> FDt {
|
||||||
Arc::new(RefCell::new(IsoFD {
|
let fd = Arc::new(RefCell::new(IsoFD {
|
||||||
fd: FDId::new(),
|
fd: FDId::new(),
|
||||||
}))
|
offset: 0,
|
||||||
|
lba: entry.data_blk.le,
|
||||||
|
size: entry.file_size.le,
|
||||||
|
}));
|
||||||
|
|
||||||
|
FD_TABLE.lock().await.register_fd(fd.clone());
|
||||||
|
fd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,12 +34,45 @@ impl FileDescriptor for IsoFD {
|
|||||||
self.fd
|
self.fd
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn write(&mut self, buf: &[u8], count: usize) -> isize {
|
async fn write(&mut self, _buf: &[u8], _count: usize) -> isize {
|
||||||
0
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn read(&mut self, buf: &[u8], count: usize) -> isize {
|
#[allow(unaligned_references)]
|
||||||
println!("Read from fd");
|
async fn read(&mut self, buf: &mut [u8], count: usize) -> isize {
|
||||||
0
|
let mut block_offset = self.offset / ISO_BLOCK_SIZE;
|
||||||
|
let mut content = read_block(self.lba + block_offset).await;
|
||||||
|
let mut read: isize = 0;
|
||||||
|
for _ in 0..count {
|
||||||
|
if self.offset >= self.size {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf[read as usize] = content[(self.offset % ISO_BLOCK_SIZE) as usize];
|
||||||
|
read += 1;
|
||||||
|
self.offset += 1;
|
||||||
|
|
||||||
|
if self.offset % ISO_BLOCK_SIZE == 0 {
|
||||||
|
block_offset += 1;
|
||||||
|
content = read_block(self.lba + block_offset).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
read
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
async fn close(&mut self) {
|
||||||
|
FD_TABLE.lock().await.unregister_fd(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn lseek(&mut self, offset: i32, whence: u32) -> i32 {
|
||||||
|
use crate::syscalls::io::*;
|
||||||
|
match whence {
|
||||||
|
w if w == SEEK_SET => self.offset = offset as u32,
|
||||||
|
w if w == SEEK_CUR => self.offset = (self.offset as i32 + offset) as u32,
|
||||||
|
w if w == SEEK_END => self.offset = (self.size as i32 + offset) as u32,
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
self.offset as i32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,87 +1,100 @@
|
|||||||
const ISO_BLOCK_SIZE: usize = 2048;
|
pub const ISO_BLOCK_SIZE: u32 = 2048;
|
||||||
|
|
||||||
// Twin values structs
|
// Twin values structs
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct MultiEndian32 {
|
pub struct MultiEndian32 {
|
||||||
le: u32, // Little endian value
|
pub le: u32, // Little endian value
|
||||||
be: u32, // Big endian value
|
pub be: u32, // Big endian value
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct MultiEndian16 {
|
pub struct MultiEndian16 {
|
||||||
le: u16, // Little endian value
|
pub le: u16, // Little endian value
|
||||||
be: u16, // Big endian value
|
pub be: u16, // Big endian value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Path table structure
|
// Path table structure
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone)]
|
#[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
|
||||||
data_blk: u8, // File data block index
|
data_blk: u8, // File data block index
|
||||||
parent_dir: u16, // Number of the parent dir
|
parent_dir: u16, // Number of the parent dir
|
||||||
idf: [u8; 0] // Directory name, of size Self::idf_len
|
idf: [u8; 0], // Directory name, of size Self::idf_len
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl IsoPathTable {
|
impl IsoPathTable {
|
||||||
#[allow(unaligned_references)]
|
#[allow(unaligned_references)]
|
||||||
pub fn get_idf(&self) -> &[u8] {
|
pub fn get_idf(&self) -> &[u8] {
|
||||||
unsafe {
|
unsafe { core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize) }
|
||||||
core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Directory structure
|
// Directory structure
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
const ISO_MAX_DIR_DEPTH: usize = 8;
|
||||||
const ISO_DATE_LEN: usize = 7;
|
const ISO_DATE_LEN: usize = 7;
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
enum IsoFileType {
|
#[allow(dead_code)]
|
||||||
HIDDEN = 0x1, // Hidden file
|
pub enum IsoFileType {
|
||||||
ISDIR = 0x2, // Directory
|
HIDDEN = 0x1, // Hidden file
|
||||||
ASSOCIAT = 0x4, // Associated
|
ISDIR = 0x2, // Directory
|
||||||
USEEXT = 0x8, //
|
ASSOCIAT = 0x4, // Associated
|
||||||
USEPERM = 0x10, //
|
USEEXT = 0x8, //
|
||||||
MULTIDIR = 0x80 //
|
USEPERM = 0x10, //
|
||||||
|
MULTIDIR = 0x80, //
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct IsoDir {
|
pub struct IsoDir {
|
||||||
dir_size: u8, // Length of directory record
|
pub dir_size: u8, // Length of directory record
|
||||||
ext_size: u8, // Length of extended attribute record
|
pub ext_size: u8, // Length of extended attribute record
|
||||||
data_blk: MultiEndian32, // File data block index
|
pub data_blk: MultiEndian32, // File data block index
|
||||||
file_size: MultiEndian32, // File size
|
pub file_size: MultiEndian32, // File size
|
||||||
date: [u8; ISO_DATE_LEN],
|
pub date: [u8; ISO_DATE_LEN],
|
||||||
file_type: IsoFileType,
|
pub file_type: IsoFileType,
|
||||||
|
|
||||||
unit_size: u8,
|
pub unit_size: u8,
|
||||||
gap_size: u8,
|
pub gap_size: u8,
|
||||||
|
|
||||||
vol_seq: MultiEndian16,
|
pub vol_seq: MultiEndian16,
|
||||||
|
|
||||||
idf_len: u8, // File name length
|
pub idf_len: u8, // File name length
|
||||||
idf: [u8; 0], // File name
|
pub idf: [u8; 0], // File name
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IsoDir {
|
impl IsoDir {
|
||||||
#[allow(unaligned_references)]
|
#[allow(unaligned_references)]
|
||||||
pub fn get_idf(&self) -> &[u8] {
|
pub fn get_idf(&self) -> &[u8] {
|
||||||
unsafe {
|
let mut len: usize = self.idf_len as usize;
|
||||||
core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize)
|
unsafe {
|
||||||
|
let mut idf = core::slice::from_raw_parts(self.idf.as_ptr(), len as usize);
|
||||||
|
if len > 2 && idf[len - 2] == b';' && idf[len - 1] == b'1' {
|
||||||
|
len -= 2;
|
||||||
|
idf = core::slice::from_raw_parts(self.idf.as_ptr(), len as usize);
|
||||||
|
}
|
||||||
|
idf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
pub fn next_entry(&self) -> &IsoDir {
|
||||||
|
crate::utils::ref_raw_offset(self, self.dir_size as isize)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn matches(&self, path: &str) -> bool {
|
||||||
|
self.get_idf() == path.as_bytes()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Primary volume descriptor structure
|
// Primary volume descriptor structure
|
||||||
|
|
||||||
@ -101,9 +114,9 @@ const ISO_LDATE_LEN: usize = 17;
|
|||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone)]
|
#[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")
|
||||||
pub vol_desc_version: u8, // Volume descriptor version (1)
|
pub vol_desc_version: u8, // Volume descriptor version (1)
|
||||||
|
|
||||||
pub _unused1: u8,
|
pub _unused1: u8,
|
||||||
|
|
||||||
@ -117,12 +130,12 @@ pub struct IsoPrimVolDesc {
|
|||||||
pub _unused3: [u8; 32],
|
pub _unused3: [u8; 32],
|
||||||
|
|
||||||
pub vol_set_size: MultiEndian16, // The Volume Set size of the volume
|
pub vol_set_size: MultiEndian16, // The Volume Set size of the volume
|
||||||
pub vol_seq_num: MultiEndian16, // The number of the volume in the set
|
pub vol_seq_num: MultiEndian16, // The number of the volume in the set
|
||||||
pub vol_blk_size: MultiEndian16, // The size in bytes of a logical block
|
pub vol_blk_size: MultiEndian16, // The size in bytes of a logical block
|
||||||
|
|
||||||
pub path_table_size: MultiEndian32, // Length in bytes of the path table
|
pub path_table_size: MultiEndian32, // Length in bytes of the path table
|
||||||
pub le_path_table_blk: u32, // Path table block index little endian
|
pub le_path_table_blk: u32, // Path table block index little endian
|
||||||
pub le_opt_path_table_blk: u32, // Optionnal path table block index little endian
|
pub le_opt_path_table_blk: u32, // Optionnal path table block index little endian
|
||||||
pub be_path_table_blk: u32,
|
pub be_path_table_blk: u32,
|
||||||
pub be_opt_path_table_blk: u32,
|
pub be_opt_path_table_blk: u32,
|
||||||
|
|
||||||
@ -131,17 +144,17 @@ pub struct IsoPrimVolDesc {
|
|||||||
pub _unused4: [u8; 34 - core::mem::size_of::<IsoDir>()], // Padding
|
pub _unused4: [u8; 34 - core::mem::size_of::<IsoDir>()], // Padding
|
||||||
|
|
||||||
pub volset_idf: [u8; ISO_VOLSET_LEN], // name of the multiple volume set
|
pub volset_idf: [u8; ISO_VOLSET_LEN], // name of the multiple volume set
|
||||||
pub pub_idf: [u8; ISO_PUBIDF_LEN], // Publisher name
|
pub pub_idf: [u8; ISO_PUBIDF_LEN], // Publisher name
|
||||||
pub dprep_idf: [u8; ISO_DPREP_LEN], // Data preparer name
|
pub dprep_idf: [u8; ISO_DPREP_LEN], // Data preparer name
|
||||||
pub app_idf: [u8; ISO_APP_LEN], // Application name
|
pub app_idf: [u8; ISO_APP_LEN], // Application name
|
||||||
|
|
||||||
pub copyright_file: [u8; ISO_CPRFIL_LEN], // Copyright file name in root dir
|
pub copyright_file: [u8; ISO_CPRFIL_LEN], // Copyright file name in root dir
|
||||||
pub abstract_file: [u8; ISO_ABSFIL_LEN], // Abstract file name in root dir
|
pub abstract_file: [u8; ISO_ABSFIL_LEN], // Abstract file name in root dir
|
||||||
pub bibli_file: [u8; ISO_BIBFIL_LEN], // Bibliograpgic file name in root dir
|
pub bibli_file: [u8; ISO_BIBFIL_LEN], // Bibliograpgic file name in root dir
|
||||||
pub date_creat: [u8; ISO_LDATE_LEN], // Creation date
|
pub date_creat: [u8; ISO_LDATE_LEN], // Creation date
|
||||||
pub date_modif: [u8; ISO_LDATE_LEN], // Modification date
|
pub date_modif: [u8; ISO_LDATE_LEN], // Modification date
|
||||||
pub date_expir: [u8; ISO_LDATE_LEN], // Expiration date
|
pub date_expir: [u8; ISO_LDATE_LEN], // Expiration date
|
||||||
pub date_effect: [u8; ISO_LDATE_LEN], // Effective date
|
pub date_effect: [u8; ISO_LDATE_LEN], // Effective date
|
||||||
|
|
||||||
pub file_struct_version: u8, // File structure version (1)
|
pub file_struct_version: u8, // File structure version (1)
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,83 @@
|
|||||||
pub mod iso9660;
|
|
||||||
mod fd;
|
mod fd;
|
||||||
|
pub mod iso9660;
|
||||||
|
|
||||||
use crate::println;
|
use crate::drivers::atapi::read_block;
|
||||||
use crate::drivers::atapi::{DRIVE};
|
use crate::fd::{FDt};
|
||||||
use crate::fd::{FD_TABLE, FDt};
|
|
||||||
use crate::utils::unserialize;
|
use crate::utils::unserialize;
|
||||||
|
|
||||||
use iso9660::{IsoPrimVolDesc, IsoDir};
|
use super::FileSystem;
|
||||||
use fd::IsoFD;
|
use fd::IsoFD;
|
||||||
|
use iso9660::{IsoDir, IsoPrimVolDesc};
|
||||||
|
|
||||||
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
|
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||||
let desc_block = DRIVE
|
use async_trait::async_trait;
|
||||||
.lock()
|
|
||||||
.await
|
pub struct IsoFS {}
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
#[async_trait(?Send)]
|
||||||
.read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK)
|
#[allow(unaligned_references)]
|
||||||
.await;
|
impl FileSystem for IsoFS {
|
||||||
*unserialize::<IsoPrimVolDesc>(desc_block.as_ptr())
|
async fn open(&mut self, path: &str, flags: u32) -> Option<FDt> {
|
||||||
|
// ISO is a read only file system
|
||||||
|
if flags != crate::syscalls::io::O_RDONLY {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let voldesc = get_prim_vol_desc().await;
|
||||||
|
|
||||||
|
// Invalid ISO
|
||||||
|
if voldesc.std_identifier != "CD001".as_bytes() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let root: &IsoDir = &voldesc.root_dir;
|
||||||
|
let mut curr_entry_block: [u8; iso9660::ISO_BLOCK_SIZE as usize] = read_block(root.data_blk.le).await;
|
||||||
|
|
||||||
|
let mut curr_entry: &IsoDir = unserialize(curr_entry_block.as_ptr());
|
||||||
|
|
||||||
|
let path_s: String = String::from(path);
|
||||||
|
let path_split: Vec<&str> = path_s.split("/").collect();
|
||||||
|
let path_it = path_s
|
||||||
|
.split("/")
|
||||||
|
.filter(|p| p != &"");
|
||||||
|
|
||||||
|
for path_component in path_it {
|
||||||
|
let mut found = false;
|
||||||
|
while curr_entry.idf_len != 0 {
|
||||||
|
|
||||||
|
// Found entry
|
||||||
|
if curr_entry.matches(path_component) {
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
// Not the last component, go 1 directory deeper
|
||||||
|
if path_component != path_split[path_split.len() - 1] {
|
||||||
|
// Not a directory
|
||||||
|
if curr_entry.file_type != iso9660::IsoFileType::ISDIR {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
// Deeper entries
|
||||||
|
curr_entry_block = read_block(curr_entry.data_blk.le).await;
|
||||||
|
curr_entry = unserialize(curr_entry_block.as_ptr());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next entry
|
||||||
|
curr_entry = curr_entry.next_entry();
|
||||||
|
}
|
||||||
|
|
||||||
|
// File not found
|
||||||
|
if !found {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(IsoFD::new(curr_entry).await)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn open(path: &str, flags: u32) -> Option<FDt> {
|
|
||||||
if flags != crate::syscalls::io::O_RDONLY {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let voldesc = get_prim_vol_desc().await;
|
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
|
||||||
|
let desc_block = read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK).await;
|
||||||
if voldesc.std_identifier != "CD001".as_bytes() {
|
*unserialize::<IsoPrimVolDesc>(desc_block.as_ptr())
|
||||||
return None;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let fd = IsoFD::new();
|
|
||||||
FD_TABLE.lock().await.register_fd(fd.clone()).await;
|
|
||||||
Some(fd)
|
|
||||||
}
|
|
||||||
|
@ -1 +1,39 @@
|
|||||||
pub mod iso;
|
pub mod iso;
|
||||||
|
|
||||||
|
use crate::fd::FDt;
|
||||||
|
use crate::utils::mutex::AsyncMutex;
|
||||||
|
|
||||||
|
use alloc::{boxed::Box, sync::Arc};
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use core::cell::RefCell;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
|
pub type FSt = Arc<RefCell<dyn FileSystem>>;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref VIRTUAL_FS: AsyncMutex<VirtualFS> = AsyncMutex::new(VirtualFS::new());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait(?Send)]
|
||||||
|
pub trait FileSystem {
|
||||||
|
async fn open(&mut self, path: &str, flags: u32) -> Option<FDt>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct VirtualFS {
|
||||||
|
fs: FSt,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VirtualFS {
|
||||||
|
fn new() -> Self {
|
||||||
|
VirtualFS {
|
||||||
|
fs: Arc::new(RefCell::new(iso::IsoFS {})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait(?Send)]
|
||||||
|
impl FileSystem for VirtualFS {
|
||||||
|
async fn open(&mut self, path: &str, flags: u32) -> Option<FDt> {
|
||||||
|
self.fs.borrow_mut().open(path, flags).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,12 +4,8 @@ use crate::memory::gdt;
|
|||||||
use crate::println;
|
use crate::println;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use pic::{
|
use pic::{
|
||||||
init_pic,
|
disk1_interrupt_handler, disk2_interrupt_handler, init_pic, keyboard_interrupt_handler,
|
||||||
keyboard_interrupt_handler,
|
timer_interrupt_handler, InterruptIndex,
|
||||||
timer_interrupt_handler,
|
|
||||||
disk1_interrupt_handler,
|
|
||||||
disk2_interrupt_handler,
|
|
||||||
InterruptIndex
|
|
||||||
};
|
};
|
||||||
use x86_64::structures::idt::PageFaultErrorCode;
|
use x86_64::structures::idt::PageFaultErrorCode;
|
||||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use crate::println;
|
use crate::println;
|
||||||
|
pub use disk::{disk1_interrupt_handler, disk2_interrupt_handler};
|
||||||
pub use keyboard::keyboard_interrupt_handler;
|
pub use keyboard::keyboard_interrupt_handler;
|
||||||
use pic8259::ChainedPics;
|
use pic8259::ChainedPics;
|
||||||
pub use pit::timer_interrupt_handler;
|
pub use pit::timer_interrupt_handler;
|
||||||
pub use disk::{disk1_interrupt_handler, disk2_interrupt_handler};
|
|
||||||
|
|
||||||
|
pub mod disk;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
pub mod pit;
|
pub mod pit;
|
||||||
pub mod disk;
|
|
||||||
|
|
||||||
pub const PIC_1_OFFSET: u8 = 32;
|
pub const PIC_1_OFFSET: u8 = 32;
|
||||||
pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
|
pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
|
||||||
@ -35,7 +35,7 @@ pub static PICS: spin::Mutex<ChainedPics> =
|
|||||||
|
|
||||||
pub fn init_pic() {
|
pub fn init_pic() {
|
||||||
println!("Initializing PIC");
|
println!("Initializing PIC");
|
||||||
unsafe {
|
unsafe {
|
||||||
PICS.lock().initialize();
|
PICS.lock().initialize();
|
||||||
PICS.lock().write_masks(0b10111000, 0b00001110);
|
PICS.lock().write_masks(0b10111000, 0b00001110);
|
||||||
};
|
};
|
||||||
|
32
src/lib.rs
32
src/lib.rs
@ -4,18 +4,19 @@
|
|||||||
#![feature(alloc_error_handler)]
|
#![feature(alloc_error_handler)]
|
||||||
|
|
||||||
mod drivers;
|
mod drivers;
|
||||||
|
mod fd;
|
||||||
|
mod fs;
|
||||||
mod interrupts;
|
mod interrupts;
|
||||||
mod memory;
|
mod memory;
|
||||||
mod task;
|
|
||||||
mod fs;
|
|
||||||
mod utils;
|
|
||||||
mod fd;
|
|
||||||
mod syscalls;
|
mod syscalls;
|
||||||
|
mod task;
|
||||||
|
mod utils;
|
||||||
|
|
||||||
//#[macro_use]
|
//#[macro_use]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate multiboot2;
|
extern crate multiboot2;
|
||||||
|
|
||||||
|
use crate::fs::FileSystem;
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
use drivers::vga::{self, Color, ColorCode};
|
use drivers::vga::{self, Color, ColorCode};
|
||||||
use multiboot2::BootInformation;
|
use multiboot2::BootInformation;
|
||||||
@ -63,8 +64,23 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
|
|||||||
executor.run();
|
executor.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn get_file() {
|
async fn get_file() {
|
||||||
let fd = fs::iso::open("test", syscalls::io::O_RDONLY).await.unwrap();
|
let fd = fs::VIRTUAL_FS
|
||||||
fd.borrow_mut().read(&[], 0).await;
|
.lock()
|
||||||
}
|
.await
|
||||||
|
.open("///boot/grub//grub.cfg", syscalls::io::O_RDONLY)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let mut buf: [u8; 100] = [0; 100];
|
||||||
|
let read = fd.borrow_mut().read(&mut buf, 100).await;
|
||||||
|
|
||||||
|
serial_println!("{:?}", read);
|
||||||
|
serial_println!("{}", alloc::str::from_utf8(&buf).unwrap());
|
||||||
|
|
||||||
|
fd.borrow_mut().lseek(10, syscalls::io::SEEK_SET).await;
|
||||||
|
|
||||||
|
fd.borrow_mut().read(&mut buf, 100).await;
|
||||||
|
serial_println!("{}", alloc::str::from_utf8(&buf).unwrap());
|
||||||
|
|
||||||
|
fd.borrow_mut().close().await;
|
||||||
|
}
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
pub const O_RDONLY: u32 = 0;
|
pub const O_RDONLY: u32 = 0;
|
||||||
|
|
||||||
// seek flags
|
// seek flags
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const SEEK_SET: u32 = 0;
|
pub const SEEK_SET: u32 = 0;
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const SEEK_CUR: u32 = 1;
|
pub const SEEK_CUR: u32 = 1;
|
||||||
#[allow(dead_code)]
|
pub const SEEK_END: u32 = 2;
|
||||||
pub const SEEK_END: u32 = 2;
|
|
||||||
|
@ -1 +1 @@
|
|||||||
pub mod io;
|
pub mod io;
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
pub mod serialize;
|
|
||||||
pub mod mutex;
|
pub mod mutex;
|
||||||
|
pub mod serialize;
|
||||||
|
|
||||||
|
pub use mutex::AsyncMutex;
|
||||||
pub use serialize::unserialize;
|
pub use serialize::unserialize;
|
||||||
pub use mutex::AsyncMutex;
|
|
||||||
|
pub fn ref_offset<T>(r: &T, off: isize) -> &T {
|
||||||
|
let ref_ptr: *const T = r;
|
||||||
|
unsafe {
|
||||||
|
return &*ref_ptr.offset(off);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ref_raw_offset<T>(r: &T, off: isize) -> &T {
|
||||||
|
let ref_ptr: *const T = r;
|
||||||
|
unsafe {
|
||||||
|
return &*ref_ptr.cast::<u8>().offset(off).cast::<T>();
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
use core::future::Future;
|
use alloc::sync::Arc;
|
||||||
use core::pin::Pin;
|
|
||||||
use core::cell::UnsafeCell;
|
use core::cell::UnsafeCell;
|
||||||
|
use core::future::Future;
|
||||||
use core::ops::{Deref, DerefMut, Drop};
|
use core::ops::{Deref, DerefMut, Drop};
|
||||||
|
use core::pin::Pin;
|
||||||
use core::sync::atomic::{AtomicBool, Ordering};
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
use core::task::{Context, Poll};
|
use core::task::{Context, Poll};
|
||||||
use alloc::sync::Arc;
|
|
||||||
|
|
||||||
use futures_util::task::AtomicWaker;
|
use futures_util::task::AtomicWaker;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ struct Lock {
|
|||||||
waker: Arc<AtomicWaker>,
|
waker: Arc<AtomicWaker>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AsyncMutex<T> {
|
pub struct AsyncMutex<T: ?Sized> {
|
||||||
lock: Lock,
|
lock: Lock,
|
||||||
inner: UnsafeCell<T>,
|
inner: UnsafeCell<T>,
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ pub struct AsyncMutexGuard<'a, T>
|
|||||||
where
|
where
|
||||||
T: 'a,
|
T: 'a,
|
||||||
{
|
{
|
||||||
mutex: &'a AsyncMutex<T>
|
mutex: &'a AsyncMutex<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Lock {
|
impl Lock {
|
||||||
@ -58,7 +58,7 @@ impl Future for Lock {
|
|||||||
false => {
|
false => {
|
||||||
self.waker.take();
|
self.waker.take();
|
||||||
Poll::Ready(())
|
Poll::Ready(())
|
||||||
},
|
}
|
||||||
true => Poll::Pending,
|
true => Poll::Pending,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,16 +98,12 @@ impl<T> Drop for AsyncMutexGuard<'_, T> {
|
|||||||
impl<T> Deref for AsyncMutexGuard<'_, T> {
|
impl<T> Deref for AsyncMutexGuard<'_, T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
unsafe {
|
unsafe { &*self.mutex.inner.get() }
|
||||||
&*self.mutex.inner.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> DerefMut for AsyncMutexGuard<'_, T> {
|
impl<T> DerefMut for AsyncMutexGuard<'_, T> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
unsafe {
|
unsafe { &mut *self.mutex.inner.get() }
|
||||||
&mut *self.mutex.inner.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
pub fn unserialize<T>(ptr: *const u8) -> &'static T {
|
pub fn unserialize<T>(ptr: *const u8) -> &'static T {
|
||||||
let path_table_ptr: *const T = ptr as *const T;
|
let path_table_ptr: *const T = ptr as *const T;
|
||||||
unsafe {
|
unsafe { &*path_table_ptr }
|
||||||
&*path_table_ptr
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user