Working AHCI DMA IPC from yellowstone to denali.
We have a weird bug in context switching where a process's rsp0 ends up pointing at the wrong value sometimes which crashes the OS.
This commit is contained in:
parent
ccfe1b15ab
commit
e5da93757a
11 changed files with 171 additions and 84 deletions
|
|
@ -3,8 +3,17 @@
|
|||
#include <mammoth/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace {
|
||||
DenaliServer* gServer = nullptr;
|
||||
void HandleResponse(uint64_t lba, uint64_t size, uint64_t cap) {
|
||||
gServer->HandleResponse(lba, size, cap);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DenaliServer::DenaliServer(uint64_t channel_cap, AhciDriver& driver)
|
||||
: channel_cap_(channel_cap), driver_(driver) {}
|
||||
: channel_cap_(channel_cap), driver_(driver) {
|
||||
gServer = this;
|
||||
}
|
||||
|
||||
z_err_t DenaliServer::RunServer() {
|
||||
while (true) {
|
||||
|
|
@ -20,12 +29,7 @@ z_err_t DenaliServer::RunServer() {
|
|||
case DENALI_READ: {
|
||||
DenaliRead* read_req = reinterpret_cast<DenaliRead*>(read_buffer_);
|
||||
uint64_t memcap = 0;
|
||||
DenaliReadResponse resp;
|
||||
RET_ERR(HandleRead(*read_req, resp, memcap));
|
||||
uint64_t caps_len = memcap ? 1 : 0;
|
||||
RET_ERR(ZChannelSend(channel_cap_, 0, sizeof(DenaliReadResponse),
|
||||
reinterpret_cast<uint8_t*>(&resp), caps_len,
|
||||
&memcap));
|
||||
RET_ERR(HandleRead(*read_req));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -35,10 +39,22 @@ z_err_t DenaliServer::RunServer() {
|
|||
}
|
||||
}
|
||||
|
||||
z_err_t DenaliServer::HandleRead(const DenaliRead& read,
|
||||
DenaliReadResponse& resp, uint64_t& memcap) {
|
||||
AhciDevice device;
|
||||
RET_ERR(driver_.GetDevice(read.device_id, device));
|
||||
z_err_t DenaliServer::HandleRead(const DenaliRead& read) {
|
||||
AhciDevice* device;
|
||||
RET_ERR(driver_.GetDevice(read.device_id, &device));
|
||||
|
||||
device->IssueCommand(
|
||||
new DmaReadCommand(read.lba, read.size, ::HandleResponse));
|
||||
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
void DenaliServer::HandleResponse(uint64_t lba, uint64_t size, uint64_t cap) {
|
||||
DenaliReadResponse resp{
|
||||
.device_id = 0,
|
||||
.lba = lba,
|
||||
.size = size,
|
||||
};
|
||||
check(ZChannelSend(channel_cap_, DENALI_READ, sizeof(resp),
|
||||
reinterpret_cast<uint8_t*>(&resp), 1, &cap));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue