[Denali] Use semaphores for DMA callback signaling.
This commit is contained in:
parent
4c2492e985
commit
2b8ae027df
4 changed files with 19 additions and 22 deletions
|
|
@ -15,19 +15,15 @@ glcr::ErrorOr<glcr::UniquePtr<DenaliServer>> DenaliServer::Create(
|
|||
glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
||||
ReadResponse& resp) {
|
||||
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
||||
ASSIGN_OR_RETURN(Mutex mutex, Mutex::Create());
|
||||
RET_ERR(mutex.Lock());
|
||||
|
||||
uint64_t paddr;
|
||||
OwnedMemoryRegion region =
|
||||
OwnedMemoryRegion::ContiguousPhysical(req.size() * 512, &paddr);
|
||||
|
||||
DmaReadCommand command(req.lba(), req.size(), paddr, mutex);
|
||||
DmaReadCommand command(req.lba(), req.size(), paddr);
|
||||
device->IssueCommand(&command);
|
||||
|
||||
// Wait for read operation to complete.
|
||||
RET_ERR(mutex.Lock());
|
||||
RET_ERR(mutex.Release());
|
||||
command.WaitComplete();
|
||||
|
||||
resp.set_device_id(req.device_id());
|
||||
resp.set_size(req.size());
|
||||
|
|
@ -38,8 +34,6 @@ glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
|||
glcr::ErrorCode DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
||||
ReadResponse& resp) {
|
||||
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
||||
ASSIGN_OR_RETURN(Mutex mutex, Mutex::Create());
|
||||
RET_ERR(mutex.Lock());
|
||||
|
||||
uint64_t region_paddr;
|
||||
OwnedMemoryRegion region = OwnedMemoryRegion::ContiguousPhysical(
|
||||
|
|
@ -54,11 +48,9 @@ glcr::ErrorCode DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
|||
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, mutex);
|
||||
DmaReadCommand command(lba, size, paddr);
|
||||
device->IssueCommand(&command);
|
||||
|
||||
// Wait for read operation to complete.
|
||||
RET_ERR(mutex.Lock());
|
||||
command.WaitComplete();
|
||||
|
||||
curr_run_start = i + 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue