bond/include/kernel/ke/status.h

57 lines
1.6 KiB
C
Raw Normal View History

2018-01-26 08:43:22 +00:00
#ifndef _KERNEL_KE_STATUS_H_
#define _KERNEL_KE_STATUS_H_
2016-08-27 05:13:54 +00:00
#include "type.h"
2018-01-26 08:43:22 +00:00
#include "lib/sxtdlib.h"
#include "kernel/hal/status.h"
typedef uint32_t status_t;
2016-08-27 05:13:54 +00:00
//
// 32 bit ints
//
// bits 30 - 31 - Error/Success
// 00 = Success
// 01 = Error
//
// bits 0-14 - Return Code - 32768 in total
// bits 15-29 - Facility 32768 in total
//
#define SX_SUCCESS(status) (((status) >> 30) == 0)
#define SX_RETURN(status) (((status) & ke_bit_field_mask(15,29)) >> 15)
#define SX_FACILITY(status) ((status) & ke_bit_field_mask(0,14))
#define SX_MAKE_STATUS(Severity, Facility, Return) (((Severity) << 30) | ((Facility) << 15) | (Return))
#define SEVERITY_ERROR 0x1
#define SEVERITY_SUCCESS 0x0
#define FACILITY_GENERIC 0
2016-08-28 00:20:38 +00:00
#define FACILITY_REF 1
2016-09-13 04:41:09 +00:00
#define FACILITY_PMM 2
2016-08-27 05:13:54 +00:00
2017-02-01 03:26:08 +00:00
enum _status_t
2016-08-27 05:13:54 +00:00
{
STATUS_SUCCESS = SX_MAKE_STATUS(SEVERITY_SUCCESS, FACILITY_GENERIC, 0),
2016-08-28 09:14:22 +00:00
REF_STATUS_UNINITIALIZED = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_REF, 1),
REF_STATUS_ALLOCATION_FAILED = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_REF, 2),
REF_STATUS_INVALID_ARGUMENTS = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_REF, 1),
REF_STATUS_INVALID_HANDLE = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_REF, 1),
REF_STATUS_DUPLICATED_HANDLE = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_REF, 1),
2016-09-13 04:41:09 +00:00
PMM_STATUS_INVALID_ARGUMENTS = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_PMM, 1),
2016-08-28 09:14:22 +00:00
2016-09-13 04:41:09 +00:00
PMM_STATUS_ALLOCATION_FAILED = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_PMM, 3),
PMM_STATUS_UNINITIALIZED = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_PMM, 4),
PMM_STATUS_NOT_ENOUGH_PAGE = SX_MAKE_STATUS(SEVERITY_ERROR, FACILITY_PMM, 5),
2017-02-01 03:26:08 +00:00
};
2016-08-27 05:13:54 +00:00
#endif