5#ifndef OPENTITAN_SW_DEVICE_LIB_BASE_INTERNAL_STATUS_H_
6#define OPENTITAN_SW_DEVICE_LIB_BASE_INTERNAL_STATUS_H_
8#ifndef USING_INTERNAL_STATUS
9#error "Do not include internal/status.h directly. Include status.h instead."
13#define USING_ABSL_STATUS
14#include "sw/device/lib/base/internal/absl_status.h"
15#undef USING_ABSL_STATUS
50#define STATUS_FIELD_CODE ((bitfield_field32_t){.mask = 0x1f, .index = 0})
51#define STATUS_FIELD_ARG ((bitfield_field32_t){.mask = 0x7ff, .index = 5})
52#define STATUS_FIELD_MODULE_ID \
53 ((bitfield_field32_t){.mask = 0x7fff, .index = 16})
54#define STATUS_BIT_ERROR 31
62#define MAKE_MODULE_ID(a, b, c) \
63 (uint32_t)(((((a)&0xff) << 16) | (((b)&0xff) << 8) | ((c)&0xff)))
65static inline uint8_t __status_ascii_5bit(uint8_t c) {
66 if (c >=
'@' && c <=
'_') {
68 }
else if (c >=
'`' && c <=
'z') {
84static inline uint32_t status_encode_module_id(uint32_t module_id) {
85 return (uint32_t)__status_ascii_5bit((uint8_t)(module_id >> 16)) |
86 ((uint32_t)__status_ascii_5bit((uint8_t)(module_id >> 8)) << 5) |
87 ((uint32_t)__status_ascii_5bit((uint8_t)module_id) << 10);