Implement read_many for denali.
This commit is contained in:
parent
5ec05f9a88
commit
49c3ff8499
|
@ -285,6 +285,16 @@ impl Command {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn read_manual(lba: u64, lba_count: u16, paddr: u64) -> Self {
|
||||||
|
Self {
|
||||||
|
command: SataCommand::DmaReadExt,
|
||||||
|
lba,
|
||||||
|
sector_cnt: lba_count,
|
||||||
|
paddr: paddr,
|
||||||
|
memory_region: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn release_mem_cap(&mut self) -> u64 {
|
pub fn release_mem_cap(&mut self) -> u64 {
|
||||||
self.memory_region.take().unwrap().release()
|
self.memory_region.take().unwrap().release()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
use mammoth::zion::ZError;
|
use mammoth::{syscall, zion::ZError};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ahci::{AhciController, Command},
|
ahci::{AhciController, Command},
|
||||||
|
@ -32,7 +32,30 @@ impl AsyncDenaliServerHandler for DenaliServerImpl {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn read_many(&self, _req: ReadManyRequest) -> Result<ReadResponse, ZError> {
|
async fn read_many(&self, req: ReadManyRequest) -> Result<ReadResponse, ZError> {
|
||||||
Err(ZError::UNIMPLEMENTED)
|
let total_sector_cnt = req.blocks.iter().map(|b| b.size).sum();
|
||||||
|
|
||||||
|
// FIXME: Don't hardcode this.
|
||||||
|
let sector_size = 512;
|
||||||
|
|
||||||
|
let (mem_cap, mut paddr) =
|
||||||
|
syscall::memory_object_contiguous_physical(sector_size * total_sector_cnt)?;
|
||||||
|
|
||||||
|
for block in req.blocks {
|
||||||
|
let command = Command::read_manual(block.lba, block.size as u16, paddr);
|
||||||
|
|
||||||
|
// TODO: We should actually be able to read all of these in parallel.
|
||||||
|
self.ahci_controller
|
||||||
|
.issue_command(req.device_id as usize, &command)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
paddr += block.size * sector_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(ReadResponse {
|
||||||
|
device_id: req.device_id,
|
||||||
|
size: total_sector_cnt,
|
||||||
|
memory: mem_cap.release(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue