Merge branch 'main' of https://github.com/Horizon-OC/Horizon-OC
This commit is contained in:
commit
ff333977ab
1 file changed
+8
-4
@@ -24,6 +24,7 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <i2c.h>
|
||||
#include <max17050.h>
|
||||
@@ -48,6 +49,8 @@ namespace ipcService {
|
||||
LockableMutex gThreadMutex;
|
||||
IpcServer gServer;
|
||||
|
||||
constexpr size_t gMinContextBufSize = offsetof(HocClkContext, stable) + sizeof(HocClkContext::stable);
|
||||
|
||||
Result GetApiVersion(u32 *out_version) {
|
||||
*out_version = HOCCLK_IPC_API_VERSION;
|
||||
return 0;
|
||||
@@ -60,8 +63,9 @@ namespace ipcService {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result GetCurrentContext(HocClkContext *out_ctx) {
|
||||
*out_ctx = clockManager::GetCurrentContext();
|
||||
Result GetCurrentContext(void *out_buf, size_t bufSize) {
|
||||
HocClkContext ctx = clockManager::GetCurrentContext();
|
||||
memcpy(out_buf, &ctx, bufSize < sizeof(ctx) ? bufSize : sizeof(ctx));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -162,8 +166,8 @@ namespace ipcService {
|
||||
case HocClkIpcCmd_GetCurrentContext:
|
||||
if (r->data.size >= sizeof(std::uint64_t) && r->hipc.meta.num_recv_buffers >= 1) {
|
||||
size_t bufSize = hipcGetBufferSize(r->hipc.data.recv_buffers);
|
||||
if (bufSize >= sizeof(HocClkContext)) {
|
||||
return GetCurrentContext((HocClkContext *)hipcGetBufferAddress(r->hipc.data.recv_buffers));
|
||||
if (bufSize >= gMinContextBufSize) {
|
||||
return GetCurrentContext(hipcGetBufferAddress(r->hipc.data.recv_buffers), bufSize);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user