From: kettenis Date: Tue, 6 Dec 2022 23:18:54 +0000 (+0000) Subject: Add support for additional RTKit endpoint advertised by NVMe firmware that X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2ed3dc7b4786140b95b6392404c4b99bb5852d7d;p=openbsd Add support for additional RTKit endpoint advertised by NVMe firmware that comes with newer macOS releases. ok patrick@ --- diff --git a/sys/arch/arm64/dev/rtkit.c b/sys/arch/arm64/dev/rtkit.c index 96741760d56..682dfa15a6f 100644 --- a/sys/arch/arm64/dev/rtkit.c +++ b/sys/arch/arm64/dev/rtkit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtkit.c,v 1.10 2022/12/03 13:42:23 kettenis Exp $ */ +/* $OpenBSD: rtkit.c,v 1.11 2022/12/06 23:18:54 kettenis Exp $ */ /* * Copyright (c) 2021 Mark Kettenis * @@ -35,6 +35,8 @@ #define RTKIT_EP_SYSLOG 2 #define RTKIT_EP_DEBUG 3 #define RTKIT_EP_IOREPORT 4 +#define RTKIT_EP_OSLOG 8 +#define RTKIT_EP_UNKNOWN 10 #define RTKIT_MGMT_TYPE(x) (((x) >> 52) & 0xff) #define RTKIT_MGMT_TYPE_SHIFT 52 @@ -74,6 +76,11 @@ #define RTKIT_IOREPORT_UNKNOWN1 8 #define RTKIT_IOREPORT_UNKNOWN2 12 +#define RTKIT_OSLOG_TYPE(x) (((x) >> 56) & 0xff) +#define RTKIT_OSLOG_TYPE_SHIFT 56 +#define RTKIT_OSLOG_INIT 1ULL +#define RTKIT_OSLOG_ACK 3ULL + /* Versions we support. */ #define RTKIT_MINVER 11 #define RTKIT_MAXVER 12 @@ -228,10 +235,13 @@ rtkit_handle_mgmt(struct rtkit_state *state, struct aplmbox_msg *msg) case RTKIT_EP_SYSLOG: case RTKIT_EP_DEBUG: case RTKIT_EP_IOREPORT: + case RTKIT_EP_OSLOG: error = rtkit_start(state, endpoint); if (error) return error; break; + case RTKIT_EP_UNKNOWN: + break; default: printf("%s: skipping endpoint %d\n", __func__, endpoint); @@ -373,6 +383,28 @@ rtkit_handle_ioreport(struct rtkit_state *state, struct aplmbox_msg *msg) return 0; } +int +rtkit_handle_oslog(struct rtkit_state *state, struct aplmbox_msg *msg) +{ + struct mbox_channel *mc = state->mc; + int error; + + switch (RTKIT_OSLOG_TYPE(msg->data0)) { + case RTKIT_OSLOG_INIT: + error = rtkit_send(mc, RTKIT_EP_OSLOG, + 0, RTKIT_OSLOG_ACK << RTKIT_OSLOG_TYPE_SHIFT); + if (error) + return error; + break; + default: + printf("%s: unhandled oslog event 0x%016llx\n", + __func__, msg->data0); + return EIO; + } + + return 0; +} + int rtkit_poll(struct rtkit_state *state) { @@ -409,6 +441,11 @@ rtkit_poll(struct rtkit_state *state) if (error) return error; break; + case RTKIT_EP_OSLOG: + error = rtkit_handle_oslog(state, &msg); + if (error) + return error; + break; default: if (endpoint >= 32 && endpoint < 64 && state->callback[endpoint - 32]) {