cargo-fmt
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
juju committed 2022-12-23 20:07:46 +01:00
1 parent b2ffbc34b5
commit 43eec9621c
17 files changed
+112 -132

No files matched your search

+5 -7
View File
@@ -3,26 +3,24 @@ use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
use core::task::{Context, Poll};
use lazy_static::lazy_static;
use futures_util::task::AtomicWaker;
use lazy_static::lazy_static;
lazy_static! {
pub static ref INTERRUPT_FUTURE: InterruptFuture = InterruptFuture::new();
static ref INTERRUPT: AtomicBool = AtomicBool::new(false);
}
static WAKER: AtomicWaker = AtomicWaker::new();
pub(crate) fn mark_interrupt() {
INTERRUPT.store(true, Ordering::Relaxed);
WAKER.wake();
}
#[derive(Copy,Clone)]
#[derive(Copy, Clone)]
pub struct InterruptFuture {
_private:(),
_private: (),
}
impl InterruptFuture {
@@ -51,8 +49,8 @@ impl Future for InterruptFuture {
true => {
WAKER.take();
Poll::Ready(())
},
}
false => Poll::Pending,
}
}
}
}
+15 -18
View File
@@ -1,20 +1,20 @@
mod scsi;
pub mod interrupt;
mod scsi;
use crate::{println, serial_println};
use scsi::{SCSIPacket};
use interrupt::{INTERRUPT_FUTURE};
use interrupt::INTERRUPT_FUTURE;
use scsi::SCSIPacket;
use core::convert::TryInto;
use lazy_static::lazy_static;
use crate::utils::AsyncMutex;
use lazy_static::lazy_static;
use x86_64::instructions::port::Port;
const CD_SECTOR_SIZE: usize = 2048;
// Data buses
const ATA_BUS_PRIMARY: u16= 0x1f0;
const ATA_BUS_PRIMARY: u16 = 0x1f0;
const ATA_BUS_SECONDARY: u16 = 0x170;
// Drives
@@ -54,16 +54,14 @@ static ATAPI_SIG: [u8; 4] = [
ATAPI_SIG_SC,
ATAPI_SIG_LBA_LO,
ATAPI_SIG_LBA_MI,
ATAPI_SIG_LBA_HI
ATAPI_SIG_LBA_HI,
];
lazy_static! {
pub static ref DRIVE: AsyncMutex<Option<ATABus>> = {
AsyncMutex::new(ATABus::discover_atapi_drive())
};
pub static ref DRIVE: AsyncMutex<Option<ATABus>> =
{ AsyncMutex::new(ATABus::discover_atapi_drive()) };
}
pub async fn init() {
println!("Detecting drives");
match DRIVE.lock().await.as_ref() {
@@ -72,12 +70,12 @@ pub async fn init() {
let drive_type = match drive.current_drive {
ATA_DRIVE_MASTER => "master",
ATA_DRIVE_SLAVE => "slave",
_ => "bad"
_ => "bad",
};
let bus = match drive.base_port {
ATA_BUS_PRIMARY => "primary",
ATA_BUS_SECONDARY => "secondary",
_ => "bad"
_ => "bad",
};
println!("Detected {} drive on {} bus", drive_type, bus);
}
@@ -100,7 +98,7 @@ pub struct ATABus {
address3: Port<u8>,
drive_select: Port<u8>,
command: Port<u8>, // write
status: Port<u8>, // read
status: Port<u8>, // read
dcr: Port<u8>,
current_drive: u8,
@@ -153,14 +151,14 @@ impl ATABus {
data: Port::new(port),
features: Port::new(port + 1), // write
error: Port::new(port + 1), // read
error: Port::new(port + 1), // read
sector_count: Port::new(port + 2),
address1: Port::new(port + 3),
address2: Port::new(port + 4),
address3: Port::new(port + 5),
drive_select: Port::new(port + 6),
command: Port::new(port + 7), // write
status: Port::new(port + 7), // read
status: Port::new(port + 7), // read
dcr: Port::new(port + 0x206),
current_drive: 0,
@@ -204,7 +202,7 @@ impl ATABus {
self.wait_packet_request();
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 {
self.data.write(word);
}
@@ -323,9 +321,8 @@ impl ATABus {
}
}
#[allow(dead_code)]
pub async fn print_block(lba: u32) {
let block = DRIVE.lock().await.as_mut().unwrap().read_block(lba).await;
serial_println!("{:x?}", block);
}
}
+4 -4
View File
@@ -1,5 +1,5 @@
use postcard::{to_vec};
use serde::{Serialize, Deserialize};
use postcard::to_vec;
use serde::{Deserialize, Serialize};
#[derive(Default, Serialize, Deserialize, Debug, Eq, PartialEq)]
#[repr(C, packed)]
@@ -15,7 +15,7 @@ pub struct SCSIPacket {
transfer_length_milo: u8,
transfer_length_lo: u8,
flags_hi: u8,
control: u8
control: u8,
}
impl SCSIPacket {
@@ -40,4 +40,4 @@ impl SCSIPacket {
self.transfer_length_mihi = ((l >> 0x10) & 0xff) as u8;
self.transfer_length_hi = ((l >> 0x18) & 0xff) as u8;
}
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
pub mod atapi;
pub mod serial;
pub mod vga;
pub mod atapi;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.