Run denali server thread.

This commit is contained in:
Drew Galbraith 2025-02-01 12:11:59 -08:00
parent 10e536acab
commit a5cdd23f0b
7 changed files with 104 additions and 19 deletions

View file

@ -0,0 +1,38 @@
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)
}
}