Get rid of the type field on zmessage

This commit is contained in:
Drew Galbraith 2023-06-17 02:01:21 -07:00
parent 7bd6aa42b0
commit 685070d65e
13 changed files with 35 additions and 53 deletions

View file

@ -140,8 +140,8 @@ void AhciDriver::DumpPorts() {
void AhciDriver::InterruptLoop() {
dbgln("Starting interrupt loop");
while (true) {
uint64_t type, bytes, caps;
check(ZPortRecv(irq_port_cap_, 0, 0, 0, 0, &type, &bytes, &caps));
uint64_t bytes, caps;
check(ZPortRecv(irq_port_cap_, 0, 0, 0, 0, &bytes, &caps));
for (uint64_t i = 0; i < 32; i++) {
if (devices_[i] != nullptr && devices_[i]->IsInit() &&
(ahci_hba_->interrupt_status & (1 << i))) {

View file

@ -19,9 +19,13 @@ z_err_t DenaliServer::RunServer() {
while (true) {
uint64_t buff_size = kBuffSize;
uint64_t cap_size = 0;
uint64_t type = DENALI_INVALID;
RET_ERR(ZChannelRecv(channel_cap_, buff_size, read_buffer_, 0, nullptr,
&type, &buff_size, &cap_size));
&buff_size, &cap_size));
if (buff_size < sizeof(uint64_t)) {
dbgln("Skipping invalid message");
continue;
}
uint64_t type = *reinterpret_cast<uint64_t*>(read_buffer_);
switch (type) {
case Z_INVALID:
dbgln(reinterpret_cast<char*>(read_buffer_));
@ -55,6 +59,6 @@ void DenaliServer::HandleResponse(uint64_t lba, uint64_t size, uint64_t cap) {
.lba = lba,
.size = size,
};
check(ZChannelSend(channel_cap_, DENALI_READ, sizeof(resp),
check(ZChannelSend(channel_cap_, sizeof(resp),
reinterpret_cast<uint8_t*>(&resp), 1, &cap));
}

View file

@ -6,6 +6,7 @@
#define DENALI_READ 100
struct DenaliRead {
uint64_t request_type = DENALI_READ;
uint64_t device_id;
uint64_t lba;

View file

@ -22,17 +22,15 @@ uint64_t main(uint64_t port_cap) {
.lba = 0,
.size = 1,
};
check(ZChannelSend(local.cap(), DENALI_READ, sizeof(DenaliRead),
check(ZChannelSend(local.cap(), sizeof(DenaliRead),
reinterpret_cast<uint8_t*>(&read), 0, nullptr));
DenaliReadResponse resp;
uint64_t mem_cap, type, bytes, caps;
uint64_t mem_cap, bytes, caps;
check(ZChannelRecv(local.cap(), sizeof(resp),
reinterpret_cast<uint8_t*>(&resp), 1, &mem_cap, &type,
&bytes, &caps));
dbgln("Resp: %u", type);
reinterpret_cast<uint8_t*>(&resp), 1, &mem_cap, &bytes,
&caps));
check(ZAddressSpaceMap(gSelfVmasCap, 0, mem_cap, &vaddr));
uint32_t* mbr = reinterpret_cast<uint32_t*>(vaddr + 0x1FE);