18 #ifdef POK_NEEDS_ARINC653_ERROR
21 #include <arinc653/types.h>
22 #include <arinc653/error.h>
23 #include <core/error.h>
24 #include <core/syscall.h>
25 #include <libc/string.h>
69 #define CONVERT_ERROR_POK_TO_ARINC(pok_error,arinc_error) \
71 case POK_ERROR_KIND_DEADLINE_MISSED: \
72 arinc_error = DEADLINE_MISSED; \
74 case POK_ERROR_KIND_APPLICATION_ERROR: \
75 arinc_error = APPLICATION_ERROR; \
77 case POK_ERROR_KIND_NUMERIC_ERROR: \
78 arinc_error = NUMERIC_ERROR; \
80 case POK_ERROR_KIND_ILLEGAL_REQUEST: \
81 arinc_error = ILLEGAL_REQUEST; \
83 case POK_ERROR_KIND_STACK_OVERFLOW: \
84 arinc_error = STACK_OVERFLOW; \
86 case POK_ERROR_KIND_MEMORY_VIOLATION: \
87 arinc_error = MEMORY_VIOLATION; \
89 case POK_ERROR_KIND_HARDWARE_FAULT: \
90 arinc_error = HARDWARE_FAULT; \
92 case POK_ERROR_KIND_POWER_FAIL: \
93 arinc_error = POWER_FAIL; \
102 void REPORT_APPLICATION_MESSAGE (MESSAGE_ADDR_TYPE MESSAGE,
103 MESSAGE_SIZE_TYPE LENGTH,
104 RETURN_CODE_TYPE *RETURN_CODE )
108 *RETURN_CODE = INVALID_PARAM;
112 pok_error_raise_application_error ((
char*) MESSAGE, LENGTH);
114 *RETURN_CODE = NO_ERROR;
117 void CREATE_ERROR_HANDLER (SYSTEM_ADDRESS_TYPE ENTRY_POINT,
118 STACK_SIZE_TYPE STACK_SIZE,
119 RETURN_CODE_TYPE *RETURN_CODE)
122 core_ret = pok_syscall2 (POK_SYSCALL_ERROR_HANDLER_CREATE, (uint32_t)STACK_SIZE, (uint32_t)ENTRY_POINT);
123 if (core_ret == POK_ERRNO_OK)
125 *RETURN_CODE = NO_ERROR;
130 *RETURN_CODE = INVALID_CONFIG;
135 RETURN_CODE_TYPE *RETURN_CODE )
145 core_ret = pok_error_get (&core_status);
147 if (core_ret != POK_ERRNO_OK)
149 *RETURN_CODE = NO_ACTION;
153 CONVERT_ERROR_POK_TO_ARINC (core_status.error_kind, ERROR_STATUS->ERROR_CODE);
154 ERROR_STATUS->LENGTH = core_status.msg_size;
155 memcpy (ERROR_STATUS->MESSAGE, core_status.msg, MAX_ERROR_MESSAGE_SIZE);
156 ERROR_STATUS->FAILED_PROCESS_ID = core_status.failed_thread;
157 ERROR_STATUS->FAILED_ADDRESS = (SYSTEM_ADDRESS_TYPE)core_status.failed_addr;
161 void RAISE_APPLICATION_ERROR (ERROR_CODE_TYPE ERROR_CODE,
162 MESSAGE_ADDR_TYPE MESSAGE,
163 ERROR_MESSAGE_SIZE_TYPE LENGTH,
164 RETURN_CODE_TYPE *RETURN_CODE)
168 *RETURN_CODE = INVALID_PARAM;
172 if ( (ERROR_CODE != APPLICATION_ERROR))
174 *RETURN_CODE = INVALID_PARAM;
178 pok_error_raise_application_error ((
char*) MESSAGE, LENGTH);
180 *RETURN_CODE = NO_ERROR;