[mammoth] Create a method for getting initial caps.
This commit is contained in:
parent
4c936623b5
commit
528723e490
15 changed files with 108 additions and 22 deletions
22
lib/mammoth/src/port.cpp
Normal file
22
lib/mammoth/src/port.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "mammoth/port.h"
|
||||
|
||||
#include <zcall.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
|
||||
Port::Port(uint64_t port_cap) : port_cap_(port_cap) {}
|
||||
|
||||
z_err_t Port::PollForIntCap(uint64_t *msg, uint64_t *cap) {
|
||||
uint64_t bytes, caps, type;
|
||||
RET_ERR(ZPortPoll(port_cap_, sizeof(uint64_t),
|
||||
reinterpret_cast<uint8_t *>(msg), /* num_caps= */ 1, cap,
|
||||
&type, &bytes, &caps));
|
||||
|
||||
if (bytes != sizeof(uint64_t)) {
|
||||
return Z_ERR_INVALID;
|
||||
}
|
||||
if (caps != 1) {
|
||||
return Z_ERR_INVALID;
|
||||
}
|
||||
return Z_OK;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue