[yellowstone] Add yellowstone server for endpoint registration.

This commit is contained in:
Drew Galbraith 2023-06-22 02:19:16 -07:00
parent 8dcb1ddabd
commit a46694d0f7
13 changed files with 248 additions and 31 deletions

View file

@ -5,8 +5,23 @@
#include "mammoth/debug.h"
glcr::ErrorOr<Port> Port::Create() {
z_cap_t port;
RET_ERR(ZPortCreate(&port));
return Port(port);
}
Port::Port(uint64_t port_cap) : port_cap_(port_cap) {}
glcr::ErrorCode Port::RecvCap(uint64_t *num_bytes, char *msg, uint64_t *cap) {
uint64_t caps = 1;
RET_ERR(ZPortRecv(port_cap_, num_bytes, reinterpret_cast<uint8_t *>(msg),
&caps, cap));
if (caps != 1) {
return glcr::FAILED_PRECONDITION;
}
return glcr::OK;
}
z_err_t Port::PollForIntCap(uint64_t *msg, uint64_t *cap) {
uint64_t bytes = sizeof(uint64_t);
uint64_t caps = 1;
@ -21,3 +36,10 @@ z_err_t Port::PollForIntCap(uint64_t *msg, uint64_t *cap) {
}
return glcr::OK;
}
glcr::ErrorCode Port::WriteString(glcr::String str, uint64_t cap) {
return ZPortSend(port_cap_, str.length() + 1, str.cstr(), 1, &cap);
}
glcr::ErrorCode Port::Duplicate(uint64_t *new_cap) {
return ZCapDuplicate(port_cap_, new_cap);
}