Compare commits

..

No commits in common. "ab79782a7863fbea44458830eeb044c65cadffa1" and "af9a7aa7124300882f023c33d1b9e01f5a78c22c" have entirely different histories.

4 changed files with 14 additions and 18 deletions

@ -9,7 +9,6 @@ use core::convert::TryInto;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use spin::Mutex; use spin::Mutex;
use crate::utils::AsyncMutex;
use x86_64::instructions::port::Port; use x86_64::instructions::port::Port;
const CD_SECTOR_SIZE: usize = 2048; const CD_SECTOR_SIZE: usize = 2048;
@ -59,15 +58,15 @@ static ATAPI_SIG: [u8; 4] = [
]; ];
lazy_static! { lazy_static! {
pub static ref DRIVE: AsyncMutex<Option<ATABus>> = { pub static ref DRIVE: Mutex<Option<ATABus>> = {
AsyncMutex::new(ATABus::discover_atapi_drive()) Mutex::new(ATABus::discover_atapi_drive())
}; };
} }
pub async fn init() { pub fn init() {
println!("Detecting drives"); println!("Detecting drives");
match DRIVE.lock().await.as_ref() { match DRIVE.lock().as_ref() {
None => println!("No drive detected :("), None => println!("No drive detected :("),
Some(drive) => { Some(drive) => {
let drive_type = match drive.current_drive { let drive_type = match drive.current_drive {
@ -323,6 +322,6 @@ impl ATABus {
pub async fn print_block() { pub async fn print_block() {
let block = DRIVE.lock().await.as_mut().unwrap().read_block(500).await; DRIVE.lock().as_mut().unwrap().read_block(500).await;
serial_println!("{:x?}", block); serial_println!("{:x?}", DRIVE.lock().as_mut().unwrap().block);
} }

@ -1,6 +1,6 @@
pub mod iso9660; pub mod iso9660;
use crate::println; use crate::serial_println;
use crate::drivers::atapi::{DRIVE}; use crate::drivers::atapi::{DRIVE};
use crate::utils::unserialize; use crate::utils::unserialize;
use iso9660::{IsoPrimVolDesc}; use iso9660::{IsoPrimVolDesc};
@ -8,12 +8,11 @@ use iso9660::{IsoPrimVolDesc};
pub async fn init_prim_vol_desc() { pub async fn init_prim_vol_desc() {
let desc_block = DRIVE let desc_block = DRIVE
.lock() .lock()
.await
.as_mut() .as_mut()
.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()); let prim_vol_desc: &IsoPrimVolDesc = unserialize::<IsoPrimVolDesc>(desc_block.as_ptr());
println!("{:?}", alloc::string::String::from_utf8_lossy(&prim_vol_desc.std_identifier)); serial_println!("{:?}", prim_vol_desc.std_identifier);
} }

@ -43,6 +43,7 @@ pub fn init(boot_info: &BootInformation) {
memory::init(boot_info); memory::init(boot_info);
memory::gdt::init_gdt(); memory::gdt::init_gdt();
interrupts::init_idt(); interrupts::init_idt();
drivers::atapi::init();
vga::change_color(ColorCode::new(Color::LightGreen, Color::Black)); vga::change_color(ColorCode::new(Color::LightGreen, Color::Black));
} }
@ -55,7 +56,6 @@ pub extern "C" fn julios_main(multiboot_info_addr: usize) -> ! {
serial_println!("Hello serial"); serial_println!("Hello serial");
let mut executor = Executor::new(); let mut executor = Executor::new();
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(fs::iso::init_prim_vol_desc()));
executor.run(); executor.run();

@ -4,14 +4,14 @@ use core::cell::UnsafeCell;
use core::ops::{Deref, DerefMut, Drop}; use core::ops::{Deref, DerefMut, Drop};
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 alloc::rc::Rc;
use futures_util::task::AtomicWaker; use futures_util::task::AtomicWaker;
#[derive(Clone)] #[derive(Clone)]
struct Lock { struct Lock {
lock: Arc<AtomicBool>, lock: Rc<AtomicBool>,
waker: Arc<AtomicWaker>, waker: Rc<AtomicWaker>,
} }
pub struct AsyncMutex<T> { pub struct AsyncMutex<T> {
@ -29,8 +29,8 @@ where
impl Lock { impl Lock {
fn new() -> Self { fn new() -> Self {
Lock { Lock {
lock: Arc::new(AtomicBool::new(false)), lock: Rc::new(AtomicBool::new(false)),
waker: Arc::new(AtomicWaker::new()), waker: Rc::new(AtomicWaker::new()),
} }
} }
@ -86,8 +86,6 @@ impl<T> AsyncMutex<T> {
} }
} }
unsafe impl<T> Send for AsyncMutex<T> {}
unsafe impl<T> Sync for AsyncMutex<T> {}
impl<T> Drop for AsyncMutexGuard<'_, T> { impl<T> Drop for AsyncMutexGuard<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {