2023-11-22 13:41:14 -08:00
|
|
|
#include "ipc/port_client.h"
|
2023-06-26 08:59:28 -07:00
|
|
|
|
|
|
|
#include <glacier/status/error.h>
|
|
|
|
#include <zcall.h>
|
|
|
|
|
2023-11-22 14:39:27 -08:00
|
|
|
#include "util/debug.h"
|
2023-06-26 08:59:28 -07:00
|
|
|
|
2023-11-22 14:59:41 -08:00
|
|
|
namespace mmth {
|
|
|
|
|
2023-06-26 08:59:28 -07:00
|
|
|
PortClient PortClient::AdoptPort(z_cap_t cap) { return PortClient(cap); }
|
|
|
|
PortClient::PortClient(z_cap_t port_cap) : port_cap_(port_cap) {}
|
|
|
|
|
|
|
|
glcr::ErrorCode PortClient::WriteString(glcr::String str, z_cap_t cap) {
|
2023-11-02 21:55:12 -07:00
|
|
|
return static_cast<glcr::ErrorCode>(
|
|
|
|
ZPortSend(port_cap_, str.length() + 1, str.cstr(), 1, &cap));
|
2023-06-26 08:59:28 -07:00
|
|
|
}
|
2023-11-22 14:59:41 -08:00
|
|
|
|
2023-11-25 13:08:30 -08:00
|
|
|
glcr::ErrorCode PortClient::WriteByte(uint8_t byte) {
|
|
|
|
return static_cast<glcr::ErrorCode>(
|
|
|
|
ZPortSend(port_cap_, 1, &byte, 0, nullptr));
|
|
|
|
}
|
2023-11-22 14:59:41 -08:00
|
|
|
} // namespace mmth
|