17 #ifdef POK_NEEDS_ERROR_HANDLING
30 pok_thread_attr_t attr;
35 attr.priority = POK_THREAD_MAX_PRIORITY;
37 attr.time_capacity = 10000;
39 ret = pok_partition_thread_create (&tid, &attr, POK_SCHED_CURRENT_PARTITION);
41 POK_CURRENT_PARTITION.thread_error = tid;
43 pok_sched_activate_error_thread ();
54 void pok_error_declare (
const uint8_t error)
61 if (POK_CURRENT_PARTITION.thread_error != 0)
63 POK_CURRENT_PARTITION.error_status.error_kind = error;
64 POK_CURRENT_PARTITION.error_status.failed_thread = POK_SCHED_CURRENT_THREAD - POK_CURRENT_PARTITION.thread_index_low;
65 POK_CURRENT_PARTITION.error_status.msg_size = 0;
76 pok_partition_error (POK_SCHED_CURRENT_PARTITION, error);
80 void pok_error_ignore ()
86 #ifndef POK_USE_GENERATED_KERNEL_ERROR_HANDLER
87 void pok_kernel_error (
uint32_t error)
89 #ifdef POK_NEEDS_DEBUG
90 printf (
"[KERNEL] [WARNING] Error %d was raised by the kernel but no error recovery was set\n", error);
98 #ifdef POK_NEEDS_PARTITIONS
99 #ifndef POK_USE_GENERATED_PARTITION_ERROR_HANDLER
102 #ifdef POK_NEEDS_DEBUG
103 printf (
"[KERNEL] [WARNING] Error %d was raised by partition %d but no error recovery was set\n", error, partition);
114 #ifndef POK_USE_GENERATED_KERNEL_ERROR_CALLBACK
115 void pok_error_kernel_callback ()
117 #ifdef POK_NEEDS_DEBUG
118 printf (
"[KERNEL] [WARNING] Kernel calls callback function but nothing was defined by the user\n");
119 printf (
"[KERNEL] [WARNING] You MUST define the pok_error_partition_callback function\n");
126 #ifdef POK_NEEDS_PARTITIONS
127 #ifndef POK_USE_GENERATED_PARTITION_ERROR_CALLBACK
128 void pok_error_partition_callback (
uint32_t partition)
130 #ifdef POK_NEEDS_DEBUG
131 printf (
"[KERNEL] [WARNING] Partition %d calls callback function but nothing was defined by the user\n", partition);
132 printf (
"[KERNEL] [WARNING] You MUST define the pok_error_partition_callback function\n");
141 void pok_error_raise_application_error (
char* msg,
uint32_t msg_size)
143 if (msg_size > POK_ERROR_MAX_MSG_SIZE)
145 msg_size = POK_ERROR_MAX_MSG_SIZE;
148 pok_error_status_t* status;
149 status = &pok_partitions[pok_current_partition].error_status;
150 status->error_kind = POK_ERROR_KIND_APPLICATION_ERROR;
151 status->failed_thread = POK_SCHED_CURRENT_THREAD - POK_CURRENT_PARTITION.thread_index_low;
152 status->msg_size = msg_size;
154 memcpy (status->msg, msg, msg_size);
156 pok_sched_activate_error_thread ();
159 pok_ret_t pok_error_get (pok_error_status_t* status)
161 if (POK_CURRENT_PARTITION.error_status.error_kind != POK_ERROR_KIND_INVALID)
164 status->error_kind = POK_CURRENT_PARTITION.error_status.error_kind;
165 status->failed_thread = POK_CURRENT_PARTITION.error_status.failed_thread;
166 status->failed_addr = POK_CURRENT_PARTITION.error_status.failed_addr;
167 status->msg_size = POK_CURRENT_PARTITION.error_status.msg_size;
168 memcpy (status->msg, POK_CURRENT_PARTITION.error_status.msg, POK_CURRENT_PARTITION.error_status.msg_size);