boolean _watchdog_stop ( void ) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; TD_STRUCT_PTR td_ptr; _GET_KERNEL_DATA(kernel_data); _KLOGE1(KLOG_watchdog_stop); td_ptr = kernel_data->ACTIVE_PTR; if (td_ptr->FLAGS & TASK_WATCHDOG_STARTED) { _INT_DISABLE(); /* Start CR 333 */ /* td_ptr->FLAGS &= ~(TASK_WATCHDOG_STARTED | TASK_WATCHDOG_RUNNING); */ td_ptr->FLAGS &= ~TASK_WATCHDOG_RUNNING; /* End CR 333 */ _INT_ENABLE(); _KLOGX2(KLOG_watchdog_stop, TRUE); return(TRUE); } /* Endif */ _KLOGX2(KLOG_watchdog_stop, FALSE); return(FALSE); } /* Endbody */
_mqx_uint _partition_create_component ( void ) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; PARTITION_COMPONENT_STRUCT_PTR part_component_ptr; _GET_KERNEL_DATA(kernel_data); _KLOGE1(KLOG_partition_create_component); #if MQX_CHECK_ERRORS if (kernel_data->IN_ISR) { _KLOGX2(KLOG_partition_create_component, MQX_CANNOT_CALL_FUNCTION_FROM_ISR); return(MQX_CANNOT_CALL_FUNCTION_FROM_ISR); } /* Endif */ #endif _lwsem_wait((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); #if MQX_CHECK_ERRORS if (kernel_data->KERNEL_COMPONENTS[KERNEL_PARTITIONS] != NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_partition_create_component, MQX_OK); return(MQX_OK); } /* Endif */ #endif part_component_ptr = _mem_alloc_system_zero( (_mem_size)sizeof(PARTITION_COMPONENT_STRUCT)); #if MQX_CHECK_MEMORY_ALLOCATION_ERRORS if (part_component_ptr == NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_partition_create_component, MQX_OUT_OF_MEMORY); return(MQX_OUT_OF_MEMORY); } /* Endif */ #endif _mem_set_type(part_component_ptr, MEM_TYPE_PARTITION_COMPONENT); kernel_data->KERNEL_COMPONENTS[KERNEL_PARTITIONS] = part_component_ptr; /* START CR 308 */ part_component_ptr->VALID = PARTITION_VALID; /* END CR 308 */ _QUEUE_INIT(&part_component_ptr->PARTITIONS, 0); #if MQX_COMPONENT_DESTRUCTION kernel_data->COMPONENT_CLEANUP[KERNEL_PARTITIONS] = _partition_cleanup; #endif _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_partition_create_component, MQX_OK); return(MQX_OK); } /* Endbody */
void _task_stop_preemption ( void ) { /* Body */ register KERNEL_DATA_STRUCT_PTR kernel_data; TD_STRUCT_PTR td_ptr; _GET_KERNEL_DATA(kernel_data); _KLOGE1(KLOG_task_stop_preemption); td_ptr = kernel_data->ACTIVE_PTR; _int_disable(); td_ptr->FLAGS |= TASK_PREEMPTION_DISABLED; _int_enable(); _KLOGX1(KLOG_task_stop_preemption); } /* Endbody */
void _task_start_preemption ( void ) { /* Body */ register KERNEL_DATA_STRUCT_PTR kernel_data; TD_STRUCT_PTR td_ptr; _GET_KERNEL_DATA(kernel_data); _KLOGE1(KLOG_task_start_preemption); td_ptr = kernel_data->ACTIVE_PTR; _int_disable(); td_ptr->FLAGS &= ~TASK_PREEMPTION_DISABLED; _CHECK_RUN_SCHEDULER(); /* Allow higher priority tasks to run */ _int_enable(); _KLOGX1(KLOG_task_start_preemption); } /* Endbody */
/*! * \brief Gets mask of event bits in the lwevent which unblocked the most recent * wait call executed by the current task. * * If _lwevent_wait_xxx(...) was recently called in a task, the subsequent call of * _lwevent_get_signalled returns the mask of bit(s) that unblocked the wait call. * User can expect valid data only when the recent _lwevent_wait_xxx(...) operation * did not return LWEVENT_WAIT_TIMEOUT or an error value. This is useful primarily * for events that are cleared automatically and thus the corresponding value in the * LWEVENT_STRUCT was automatically reset and holds new value. * * \return bit_mask Bit mask of the last task's lwevent_wait_xxx call that * unblocked the task. * * \see _lwevent_create * \see _lwevent_destroy * \see _lwevent_set * \see _lwevent_set_auto_clear * \see _lwevent_clear * \see _lwevent_wait_for * \see _lwevent_wait_ticks * \see _lwevent_wait_until */ _mqx_uint _lwevent_get_signalled(void) { KERNEL_DATA_STRUCT_PTR kernel_data; _mqx_uint value; #if MQX_ENABLE_USER_MODE && MQX_ENABLE_USER_STDAPI if (MQX_RUN_IN_USER_MODE) { return _usr_lwevent_get_signalled(); } #endif _GET_KERNEL_DATA(kernel_data); _KLOGE1(KLOG_lwevent_get_signalled); value = kernel_data->ACTIVE_PTR->LWEVENT_BITS; _KLOGX2(KLOG_lwevent_get_signalled, value); return (value); }
/*! * \brief Creates the message component. * * The function uses fields in the MQX initialization structure to create the * number of message pools (MAX_MSGPOOLS) and message queues (MAX_MSGQS). MQX * creates the message component if it is not created when an application calls * one of: * \li _msgpool_create() * \li _msgpool_create_system() * \li _msgq_open() * \li _msgq_open_system() * * \return MQX_OK * \return MQX_OUT_OF_MEMORY (MQX is out of memory.) * \return MSGPOOL_POOL_NOT_CREATED (MQX cannot allocate the data structures for * message pools.) * \return MSGQ_TOO_MANY_QUEUES (MQX cannot allocate the data structures for * message queues.) * \return MQX_CANNOT_CALL_FUNCTION_FROM_ISR (Function cannot be called from an ISR.) * \return MQX_INVALID_LWSEM (Sem_ptr is for a lightweight semaphore that is not * longer valid.) * \return MQX_LWSEM_WAIT_TIMEOUT (Timeout expired before the task could get the * lightweight semaphore.) */ _mqx_uint _msg_create_component(void) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; register MSG_COMPONENT_STRUCT_PTR msg_component_ptr; pointer pools_ptr; pointer msgqs_ptr; _mqx_uint error; _GET_KERNEL_DATA(kernel_data); _KLOGE1(KLOG_msg_create_component); error = _lwsem_wait((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); #if MQX_CHECK_ERRORS if (error != MQX_OK) { _KLOGX2(KLOG_msg_create_component, error); return(error); } /* Endif */ #endif if (kernel_data->KERNEL_COMPONENTS[KERNEL_MESSAGES] != NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_msg_create_component, MQX_OK); return(MQX_OK); } /* Endif */ msg_component_ptr = (MSG_COMPONENT_STRUCT_PTR) _mem_alloc_system_zero((_mem_size)sizeof(MSG_COMPONENT_STRUCT)); #if MQX_CHECK_MEMORY_ALLOCATION_ERRORS if (msg_component_ptr == NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_msg_create_component, MQX_OUT_OF_MEMORY); return(MQX_OUT_OF_MEMORY); } /* Endif */ #endif _mem_set_type(msg_component_ptr, MEM_TYPE_MESSAGE_COMPONENT); if (kernel_data->INIT.MAX_MSGPOOLS == 0) { kernel_data->INIT.MAX_MSGPOOLS = 1; } /* Endif */ pools_ptr = _mem_alloc_system_zero((_mem_size)(kernel_data->INIT.MAX_MSGPOOLS * sizeof(MSGPOOL_STRUCT))); #if MQX_CHECK_MEMORY_ALLOCATION_ERRORS if (pools_ptr == NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _KLOGX2(KLOG_msg_create_component, MSGPOOL_POOL_NOT_CREATED); return MSGPOOL_POOL_NOT_CREATED; }/* Endif */ #endif _mem_set_type(pools_ptr, MEM_TYPE_MESSAGE_POOLS); if (kernel_data->INIT.MAX_MSGQS >= MAX_UINT_16) { kernel_data->INIT.MAX_MSGQS = MAX_UINT_16 - 1; } else if (kernel_data->INIT.MAX_MSGQS < 1) { kernel_data->INIT.MAX_MSGQS = 1; } /* Endif */ msgqs_ptr = _mem_alloc_system_zero( (_mem_size)((kernel_data->INIT.MAX_MSGQS + 1) * sizeof(MSGQ_STRUCT))); #if MQX_CHECK_MEMORY_ALLOCATION_ERRORS if (msgqs_ptr == NULL) { _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); _mem_free(pools_ptr); _KLOGX2(KLOG_msg_create_component, MSGQ_TOO_MANY_QUEUES); return MSGQ_TOO_MANY_QUEUES; } /* Endif */ #endif _mem_set_type(msgqs_ptr, MEM_TYPE_MESSAGE_QUEUES); if (msg_component_ptr->MSGPOOLS_PTR == NULL) { msg_component_ptr->MAX_MSGPOOLS_EVER = 0; msg_component_ptr->SMALLEST_MSGPOOL_PTR = NULL; msg_component_ptr->LARGEST_MSGPOOL_PTR = NULL; msg_component_ptr->MAX_MSGPOOLS = kernel_data->INIT.MAX_MSGPOOLS; msg_component_ptr->MAX_MSGQS = kernel_data->INIT.MAX_MSGQS; msg_component_ptr->MSGPOOLS_PTR = (MSGPOOL_STRUCT_PTR)pools_ptr; pools_ptr = NULL; msg_component_ptr->MSGQS_PTR = (MSGQ_STRUCT_PTR)msgqs_ptr; msgqs_ptr = NULL; }/* Endif */ msg_component_ptr->VALID = MESSAGE_VALID; kernel_data->KERNEL_COMPONENTS[KERNEL_MESSAGES] = msg_component_ptr; #if MQX_COMPONENT_DESTRUCTION kernel_data->COMPONENT_CLEANUP[KERNEL_MESSAGES] = _msg_cleanup; #endif _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM); if (pools_ptr) { _mem_free(pools_ptr); }/* Endif */ if (msgqs_ptr) { _mem_free(msgqs_ptr); }/* Endif */ _KLOGX2(KLOG_msg_create_component, MQX_OK); return MQX_OK; } /* Endbody */