[Denali] Update the read many request to take a sector count as well.
This greatly reduces the size of the message (we had surpassed the 1 page - 4KiB message limit with the previous method).
This commit is contained in:
parent
9f0e87b51d
commit
41bf78cf98
5 changed files with 71 additions and 22 deletions
|
|
@ -35,28 +35,30 @@ glcr::ErrorCode DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
|||
ReadResponse& resp) {
|
||||
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
||||
|
||||
uint64_t region_paddr;
|
||||
OwnedMemoryRegion region = OwnedMemoryRegion::ContiguousPhysical(
|
||||
req.lba().size() * 512, ®ion_paddr);
|
||||
if (req.lba().size() != req.sector_cnt().size()) {
|
||||
return glcr::INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
auto& vec = req.lba();
|
||||
uint64_t curr_run_start = 0;
|
||||
for (uint64_t i = 0; i < vec.size(); i++) {
|
||||
if (i + 1 < vec.size() && vec.at(i) + 1 == vec.at(i + 1)) {
|
||||
continue;
|
||||
}
|
||||
uint64_t lba = vec.at(curr_run_start);
|
||||
uint64_t size = (i - curr_run_start) + 1;
|
||||
uint64_t paddr = region_paddr + curr_run_start * 512;
|
||||
DmaReadCommand command(lba, size, paddr);
|
||||
uint64_t sector_cnt = 0;
|
||||
for (uint64_t i = 0; i < req.sector_cnt().size(); i++) {
|
||||
sector_cnt += req.sector_cnt().at(i);
|
||||
}
|
||||
uint64_t region_paddr;
|
||||
OwnedMemoryRegion region =
|
||||
OwnedMemoryRegion::ContiguousPhysical(sector_cnt * 512, ®ion_paddr);
|
||||
|
||||
for (uint64_t i = 0; i < req.lba().size(); i++) {
|
||||
uint64_t lba = req.lba().at(i);
|
||||
uint64_t size = req.sector_cnt().at(i);
|
||||
DmaReadCommand command(lba, size, region_paddr);
|
||||
device->IssueCommand(&command);
|
||||
command.WaitComplete();
|
||||
|
||||
curr_run_start = i + 1;
|
||||
region_paddr += size * 512;
|
||||
}
|
||||
|
||||
resp.set_device_id(req.device_id());
|
||||
resp.set_size(req.lba().size());
|
||||
resp.set_size(sector_cnt);
|
||||
resp.set_memory(region.DuplicateCap());
|
||||
return glcr::OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue