/*
 * Copyright (C) 2022 Apple Inc. All rights reserved.
 *
 * This document is the property of Apple Inc.
 * It is considered confidential and proprietary.
 *
 * This document may not be reproduced or transmitted in any form,
 * in whole or in part, without the express written permission of
 * Apple Inc.
 */

#pragma once

#include <stdint.h>

/* identifier of endpoint capability to forward ipc message to */
#define XNUPROXY_CR_ENDPOINT_ID(ipcb) ((ipcb)->scr[2])
/* badge value receieved from upcall */
#define XNUPROXY_CR_UPCALL_BADGE(ipcb) ((ipcb)->scr[3])
/* flag that indicates whether the message is a reply or upcall */
#define XNUPROXY_CR_STATUS(ipcb) ((ipcb)->dcr[2])
/* return value of the endpoint message forwarding call */
#define XNUPROXY_CR_RETVAL(ipcb) ((ipcb)->dcr[3])

/**
 * @typedef  xnuproxy_msg_status_t
 * @abstract Message status types
 *
 * @const XNUPROXY_MSG_STATUS_NONE
 * There is no message to be processed.
 *
 * @const XNUPROXY_MSG_STATUS_PROCESSING
 * The message is being processed.
 *
 * @const XNUPROXY_MSG_STATUS_REPLY
 * The message is a reply.
 *
 * @const XNUPROXY_MSG_STATUS_UPCALL
 * The message is an upcall.
 *
 * @const XNUPROXY_MSG_STATUS_TERMINATE
 * The thread should terminate.
 */
typedef enum : uint8_t {
    XNUPROXY_MSG_STATUS_NONE = 0,
    XNUPROXY_MSG_STATUS_PROCESSING = 1,
    XNUPROXY_MSG_STATUS_REPLY = 2,
    XNUPROXY_MSG_STATUS_UPCALL = 3,
    XNUPROXY_MSG_STATUS_TERMINATE = 4,
} xnuproxy_msg_status_t;
