Get rid of the type field on zmessage
This commit is contained in:
parent
7bd6aa42b0
commit
685070d65e
13 changed files with 35 additions and 53 deletions
|
|
@ -36,13 +36,12 @@ void ZThreadExit();
|
|||
uint64_t* vmmo_size);
|
||||
|
||||
[[nodiscard]] z_err_t ZChannelCreate(z_cap_t* channel1, z_cap_t* channel2);
|
||||
[[nodiscard]] z_err_t ZChannelSend(z_cap_t chan_cap, uint64_t type,
|
||||
uint64_t num_bytes, const uint8_t* bytes,
|
||||
uint64_t num_caps, const z_cap_t* caps);
|
||||
[[nodiscard]] z_err_t ZChannelSend(z_cap_t chan_cap, uint64_t num_bytes,
|
||||
const uint8_t* bytes, uint64_t num_caps,
|
||||
const z_cap_t* caps);
|
||||
[[nodiscard]] z_err_t ZChannelRecv(z_cap_t chan_cap, uint64_t num_bytes,
|
||||
uint8_t* bytes, uint64_t num_caps,
|
||||
z_cap_t* caps, uint64_t* type,
|
||||
uint64_t* actual_bytes,
|
||||
z_cap_t* caps, uint64_t* actual_bytes,
|
||||
uint64_t* actual_caps);
|
||||
|
||||
[[nodiscard]] z_err_t ZPortCreate(z_cap_t* port_cap);
|
||||
|
|
@ -51,12 +50,12 @@ void ZThreadExit();
|
|||
z_cap_t* caps);
|
||||
[[nodiscard]] z_err_t ZPortRecv(z_cap_t port_cap, uint64_t num_bytes,
|
||||
uint8_t* bytes, uint64_t num_caps,
|
||||
z_cap_t* caps, uint64_t* type,
|
||||
uint64_t* actual_bytes, uint64_t* actual_caps);
|
||||
z_cap_t* caps, uint64_t* actual_bytes,
|
||||
uint64_t* actual_caps);
|
||||
[[nodiscard]] z_err_t ZPortPoll(z_cap_t port_cap, uint64_t num_bytes,
|
||||
uint8_t* bytes, uint64_t num_caps,
|
||||
z_cap_t* caps, uint64_t* type,
|
||||
uint64_t* actual_bytes, uint64_t* actual_caps);
|
||||
z_cap_t* caps, uint64_t* actual_bytes,
|
||||
uint64_t* actual_caps);
|
||||
[[nodiscard]] z_err_t ZIrqRegister(uint64_t irq_num, z_cap_t* port_cap);
|
||||
|
||||
[[nodiscard]] z_err_t ZCapDuplicate(z_cap_t cap_in, z_cap_t* cap_out);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ z_err_t Channel::Read(ZMessage& msg) {
|
|||
return Z_ERR_BUFF_SIZE;
|
||||
}
|
||||
|
||||
msg.type = next_msg->type;
|
||||
msg.num_bytes = next_msg->num_bytes;
|
||||
|
||||
for (uint64_t i = 0; i < msg.num_bytes; i++) {
|
||||
|
|
@ -59,7 +58,6 @@ z_err_t Channel::EnqueueMessage(const ZMessage& msg) {
|
|||
}
|
||||
|
||||
auto message = MakeShared<Message>();
|
||||
message->type = msg.type;
|
||||
|
||||
// Copy Message body.
|
||||
message->num_bytes = msg.num_bytes;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ class Channel : public KernelObject {
|
|||
Mutex mutex_{"channel"};
|
||||
|
||||
struct Message {
|
||||
uint64_t type;
|
||||
|
||||
uint64_t num_bytes;
|
||||
uint8_t* bytes;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ z_err_t Port::Write(const ZMessage& msg) {
|
|||
}
|
||||
|
||||
auto message = MakeShared<Message>();
|
||||
message->type = msg.type, message->num_bytes = msg.num_bytes;
|
||||
message->num_bytes = msg.num_bytes;
|
||||
message->bytes = new uint8_t[msg.num_bytes];
|
||||
for (uint64_t i = 0; i < msg.num_bytes; i++) {
|
||||
message->bytes[i] = msg.bytes[i];
|
||||
|
|
@ -54,7 +54,6 @@ z_err_t Port::Read(ZMessage& msg) {
|
|||
return Z_ERR_BUFF_SIZE;
|
||||
}
|
||||
|
||||
msg.type = next_msg->type;
|
||||
msg.num_bytes = next_msg->num_bytes;
|
||||
|
||||
for (uint64_t i = 0; i < msg.num_bytes; i++) {
|
||||
|
|
@ -76,7 +75,6 @@ void Port::WriteKernel(uint64_t init, RefPtr<Capability> cap) {
|
|||
MutexHolder h(mutex_);
|
||||
|
||||
auto msg = MakeShared<Message>();
|
||||
msg->type = 0;
|
||||
msg->bytes = new uint8_t[8];
|
||||
msg->num_bytes = sizeof(init);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Port : public KernelObject {
|
|||
|
||||
private:
|
||||
struct Message {
|
||||
uint64_t type;
|
||||
uint64_t num_bytes;
|
||||
uint8_t* bytes;
|
||||
|
||||
|
|
|
|||
|
|
@ -125,14 +125,12 @@ z_err_t ZChannelCreate(z_cap_t* channel1, z_cap_t* channel2) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
z_err_t ZChannelSend(z_cap_t chan_cap, uint64_t type, uint64_t num_bytes,
|
||||
const uint8_t* bytes, uint64_t num_caps,
|
||||
const z_cap_t* caps) {
|
||||
z_err_t ZChannelSend(z_cap_t chan_cap, uint64_t num_bytes, const uint8_t* bytes,
|
||||
uint64_t num_caps, const z_cap_t* caps) {
|
||||
ZChannelSendReq req{
|
||||
.chan_cap = chan_cap,
|
||||
.message =
|
||||
{
|
||||
.type = type,
|
||||
.num_bytes = num_bytes,
|
||||
.bytes = const_cast<uint8_t*>(bytes),
|
||||
.num_caps = num_caps,
|
||||
|
|
@ -143,13 +141,12 @@ z_err_t ZChannelSend(z_cap_t chan_cap, uint64_t type, uint64_t num_bytes,
|
|||
}
|
||||
|
||||
z_err_t ZChannelRecv(z_cap_t chan_cap, uint64_t num_bytes, uint8_t* bytes,
|
||||
uint64_t num_caps, z_cap_t* caps, uint64_t* type,
|
||||
uint64_t* actual_bytes, uint64_t* actual_caps) {
|
||||
uint64_t num_caps, z_cap_t* caps, uint64_t* actual_bytes,
|
||||
uint64_t* actual_caps) {
|
||||
ZChannelRecvReq req{
|
||||
.chan_cap = chan_cap,
|
||||
.message =
|
||||
{
|
||||
.type = 0,
|
||||
.num_bytes = num_bytes,
|
||||
.bytes = bytes,
|
||||
.num_caps = num_caps,
|
||||
|
|
@ -157,7 +154,6 @@ z_err_t ZChannelRecv(z_cap_t chan_cap, uint64_t num_bytes, uint8_t* bytes,
|
|||
},
|
||||
};
|
||||
z_err_t ret = SysCall1(Z_CHANNEL_RECV, &req);
|
||||
*type = req.message.type;
|
||||
*actual_bytes = req.message.num_bytes;
|
||||
*actual_caps = req.message.num_caps;
|
||||
return ret;
|
||||
|
|
@ -174,7 +170,6 @@ z_err_t ZPortSend(z_cap_t port_cap, uint64_t num_bytes, const uint8_t* bytes,
|
|||
uint64_t num_caps, z_cap_t* caps) {
|
||||
ZPortSendReq req{.port_cap = port_cap,
|
||||
.message = {
|
||||
.type = 0,
|
||||
.num_bytes = num_bytes,
|
||||
.bytes = const_cast<uint8_t*>(bytes),
|
||||
.num_caps = num_caps,
|
||||
|
|
@ -184,13 +179,12 @@ z_err_t ZPortSend(z_cap_t port_cap, uint64_t num_bytes, const uint8_t* bytes,
|
|||
}
|
||||
|
||||
z_err_t ZPortRecv(z_cap_t port_cap, uint64_t num_bytes, uint8_t* bytes,
|
||||
uint64_t num_caps, z_cap_t* caps, uint64_t* type,
|
||||
uint64_t* actual_bytes, uint64_t* actual_caps) {
|
||||
uint64_t num_caps, z_cap_t* caps, uint64_t* actual_bytes,
|
||||
uint64_t* actual_caps) {
|
||||
ZPortRecvReq req{
|
||||
.port_cap = port_cap,
|
||||
.message =
|
||||
{
|
||||
.type = 0,
|
||||
.num_bytes = num_bytes,
|
||||
.bytes = bytes,
|
||||
.num_caps = num_caps,
|
||||
|
|
@ -198,20 +192,18 @@ z_err_t ZPortRecv(z_cap_t port_cap, uint64_t num_bytes, uint8_t* bytes,
|
|||
},
|
||||
};
|
||||
z_err_t ret = SysCall1(Z_PORT_RECV, &req);
|
||||
*type = req.message.type;
|
||||
*actual_bytes = req.message.num_bytes;
|
||||
*actual_caps = req.message.num_caps;
|
||||
return ret;
|
||||
}
|
||||
|
||||
z_err_t ZPortPoll(z_cap_t port_cap, uint64_t num_bytes, uint8_t* bytes,
|
||||
uint64_t num_caps, z_cap_t* caps, uint64_t* type,
|
||||
uint64_t* actual_bytes, uint64_t* actual_caps) {
|
||||
uint64_t num_caps, z_cap_t* caps, uint64_t* actual_bytes,
|
||||
uint64_t* actual_caps) {
|
||||
ZPortRecvReq req{
|
||||
.port_cap = port_cap,
|
||||
.message =
|
||||
{
|
||||
.type = 0,
|
||||
.num_bytes = num_bytes,
|
||||
.bytes = bytes,
|
||||
.num_caps = num_caps,
|
||||
|
|
@ -219,7 +211,6 @@ z_err_t ZPortPoll(z_cap_t port_cap, uint64_t num_bytes, uint8_t* bytes,
|
|||
},
|
||||
};
|
||||
z_err_t ret = SysCall1(Z_PORT_POLL, &req);
|
||||
*type = req.message.type;
|
||||
*actual_bytes = req.message.num_bytes;
|
||||
*actual_caps = req.message.num_caps;
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -69,8 +69,6 @@ struct ZChannelCreateResp {
|
|||
};
|
||||
|
||||
struct ZMessage {
|
||||
uint64_t type;
|
||||
|
||||
uint64_t num_bytes;
|
||||
uint8_t* bytes;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue