39 lines
1.0 KiB
Rust
39 lines
1.0 KiB
Rust
use alloc::sync::Arc;
|
|
use mammoth::zion::ZError;
|
|
|
|
use crate::{
|
|
ahci::{AhciController, Command},
|
|
AsyncDenaliServerHandler, ReadManyRequest, ReadRequest, ReadResponse,
|
|
};
|
|
|
|
pub struct DenaliServerImpl {
|
|
ahci_controller: Arc<AhciController>,
|
|
}
|
|
|
|
impl DenaliServerImpl {
|
|
pub fn new(controller: Arc<AhciController>) -> Self {
|
|
DenaliServerImpl {
|
|
ahci_controller: controller,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl AsyncDenaliServerHandler for DenaliServerImpl {
|
|
async fn read(&self, req: ReadRequest) -> Result<ReadResponse, ZError> {
|
|
let mut command = Command::read(req.block.lba, req.block.size as u16)?;
|
|
self.ahci_controller
|
|
.issue_command(req.device_id as usize, &command)
|
|
.await?;
|
|
|
|
Ok(ReadResponse {
|
|
device_id: req.device_id,
|
|
size: req.block.size,
|
|
memory: command.release_mem_cap(),
|
|
})
|
|
}
|
|
|
|
async fn read_many(&self, _req: ReadManyRequest) -> Result<ReadResponse, ZError> {
|
|
Err(ZError::UNIMPLEMENTED)
|
|
}
|
|
}
|