#ifndef __API_TYPES_H
#define __API_TYPES_H
#include <config.h>
#include <stdint.h>
#include <util.h>
#include <mode/api/shared_types_gen.h>
#include <arch/api/types.h>
#include <arch/types.h>
#include <api/macros.h>
#include <api/constants.h>
#include <api/shared_types.h>
typedef word_t prio_t;
enum domainConstants {
minDom = 0,
maxDom = CONFIG_NUM_DOMAINS - 1
};
struct cap_transfer {
cptr_t ctReceiveRoot;
cptr_t ctReceiveIndex;
word_t ctReceiveDepth;
};
typedef struct cap_transfer cap_transfer_t;
enum ctLimits {
capTransferDataSize = 3
};
static inline seL4_CapRights_t CONST
rightsFromWord(word_t w)
{
seL4_CapRights_t seL4_CapRights;
seL4_CapRights.words[0] = w;
return seL4_CapRights;
}
static inline word_t CONST
wordFromRights(seL4_CapRights_t seL4_CapRights)
{
return seL4_CapRights.words[0] & MASK(3);
}
static inline cap_transfer_t PURE
capTransferFromWords(word_t *wptr)
{
cap_transfer_t transfer;
transfer.ctReceiveRoot = (cptr_t)wptr[0];
transfer.ctReceiveIndex = (cptr_t)wptr[1];
transfer.ctReceiveDepth = wptr[2];
return transfer;
}
static inline seL4_MessageInfo_t CONST
messageInfoFromWord_raw(word_t w)
{
seL4_MessageInfo_t mi;
mi.words[0] = w;
return mi;
}
static inline seL4_MessageInfo_t CONST
messageInfoFromWord(word_t w)
{
seL4_MessageInfo_t mi;
word_t len;
mi.words[0] = w;
len = seL4_MessageInfo_get_length(mi);
if (len > seL4_MsgMaxLength) {
mi = seL4_MessageInfo_set_length(mi, seL4_MsgMaxLength);
}
return mi;
}
static inline word_t CONST
wordFromMessageInfo(seL4_MessageInfo_t mi)
{
return mi.words[0];
}
static inline seL4_PrioProps_t CONST
prioPropsFromWord(word_t w)
{
seL4_PrioProps_t pp;
pp.words[0] = w;
return pp;
}
#ifdef CONFIG_PRINTING
#ifdef CONFIG_COLOUR_PRINTING
#define ANSI_RESET "\033[0m"
#define ANSI_GREEN ANSI_RESET "\033[32m"
#define ANSI_DARK ANSI_RESET "\033[30;1m"
#else
#define ANSI_RESET ""
#define ANSI_GREEN ANSI_RESET ""
#define ANSI_DARK ANSI_RESET ""
#endif
#ifdef CONFIG_DEBUG_BUILD
#define THREAD_NAME NODE_STATE(ksCurThread)->tcbName
#else
#define THREAD_NAME ""
#endif
#define userError(...) \
do { \
printf(ANSI_DARK "<<" ANSI_GREEN "seL4(CPU %lu)" ANSI_DARK \
" [%s/%d T%p \"%s\" @%lx]: ", \
SMP_TERNARY(getCurrentCPUIndex(), 0lu), \
__func__, __LINE__, NODE_STATE(ksCurThread), \
THREAD_NAME, \
(word_t)getRestartPC(NODE_STATE(ksCurThread))); \
printf(__VA_ARGS__); \
printf(">>" ANSI_RESET "\n"); \
} while (0)
#else
#define userError(...)
#endif
#endif