From 5490fb7c9fb68f7f8edbcbf99b5408ba3648cf13 Mon Sep 17 00:00:00 2001 From: Ellis Sarza-Nguyen Date: Wed, 15 Apr 2026 11:19:02 -0700 Subject: [PATCH] [protocol] Add the implementation of get mauv This seeks to fill the stub on the function libhoth_get_mauv. We are just trying to get back the MAUV version given a set of parameters. Signed-off-by: Ellis Sarza-Nguyen --- protocol/mauv.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/protocol/mauv.c b/protocol/mauv.c index 40f4bf0..44ab651 100644 --- a/protocol/mauv.c +++ b/protocol/mauv.c @@ -14,9 +14,35 @@ #include "mauv.h" -int libhoth_get_mauv(struct libhoth_device* dev, uint8_t state, - uint8_t category, struct hoth_response_mauv* mauv) { - // TODO: implement this later. For now just return a dummy value. +#include +#include + +#include "protocol/host_cmd.h" + +int libhoth_fetch_mauv(struct libhoth_device* dev, uint8_t state, + uint8_t category, struct hoth_response_mauv* mauv) { + struct mauv_request request = { + .category = category, + .state = state, + .reserved_0 = 0, + }; + + size_t rlen = 0; + int ret = libhoth_hostcmd_exec( + dev, HOTH_CMD_BOARD_SPECIFIC_BASE + EC_PRV_CMD_HAVEN_MAUV, 0, &request, + sizeof(request), mauv, sizeof(*mauv), &rlen); + if (ret != 0) { + return ret; + } + + if (rlen == sizeof(uint32_t)) { + // Old version response: only returns the version number. + return 0; + } + + if (rlen != sizeof(struct hoth_response_mauv)) { + return -1; + } return 0; }