/*! * \brief Creates the lightweight log at the specified location. * * Each entry in the log is the same size and contains a sequence number, a timestamp, * and a seven-element array of application-defined data. * \n Use _lwlog_calculate_size() to determine amount of memory needed to create * log with requested number of entries. * * \param[in] log_number Log number to create ( 1 through 15; 0 is reserved for * kernel log). * \param[in] max_size Maximum number of entries in the log. * \param[in] flags LOG_OVERWRITE (when the log is full, write new entries * over oldest ones), NULL (when the log is full, do not write entries; the default * behavior). * \param[in] where Where to create the lightweight log. * * \return MQX_OK * \return LOG_EXISTS (Lightweight log with log number log_number exists.) * \return LOG_INVALID (Log_number is out of range.) * \return LOG_INVALID_SIZE (Max_size is 0.) * \return MQX_INVALID_POINTER (Where is NULL.) * \return MQX_INVALID_COMPONENT_BASE (Data for the lightweight log component is * not valid.) * \return MQX_OUT_OF_MEMORY (MQX is out of memory.) * \return MQX_CANNOT_CALL_FUNCTION_FROM_ISR (Function cannot be called from an ISR.) * * \warning Creates the lightweight log component if it was not created. * * \see _lwlog_create * \see _lwlog_create_component * \see _klog_create * \see _klog_create_at */ _mqx_uint _lwlog_create_at ( _mqx_uint log_number, _mqx_uint max_size, _mqx_uint flags, void *where ) { /* Body */ LWLOG_HEADER_STRUCT_PTR log_header_ptr = (LWLOG_HEADER_STRUCT_PTR) where; _mqx_uint result; #if MQX_CHECK_ERRORS if (max_size == 0) { return (LOG_INVALID_SIZE); } /* Endif */ if (where == NULL) { return (MQX_INVALID_POINTER); } /* Endif */ #endif result = _lwlog_create_internal(log_number, max_size, flags, log_header_ptr); if (result == MQX_OK) { log_header_ptr->TYPE = LWLOG_STATIC; } /* Endif */ return (result); } /* Endbody */
/*! * \brief Creates the lightweight log. * * Each entry in the log is the same size and contains a sequence number, a timestamp, * and a seven-element array of application-defined data. * * \param[in] log_number Log number to create ( 1 through 15; 0 is reserved for * kernel log). * \param[in] max_size Maximum number of entries in the log. * \param[in] flags LOG_OVERWRITE (when the log is full, write new entries * over oldest ones), NULL (when the log is full, do not write entries; the default * behavior). * * \return MQX_OK * \return LOG_EXISTS (Lightweight log with log number log_number exists.) * \return LOG_INVALID (Log_number is out of range.) * \return LOG_INVALID_SIZE (Max_size is 0.) * \return MQX_INVALID_COMPONENT_BASE (Data for the lightweight log component is * not valid.) * \return MQX_OUT_OF_MEMORY (MQX is out of memory.) * \return MQX_CANNOT_CALL_FUNCTION_FROM_ISR (Function cannot be called from an ISR.) * * \warning Creates the lightweight log component if it was not created. * * \see _lwlog_create_at * \see _lwlog_create_component * \see _klog_create * \see _klog_create_at */ _mqx_uint _lwlog_create ( _mqx_uint log_number, _mqx_uint max_size, _mqx_uint flags ) { /* Body */ LWLOG_HEADER_STRUCT_PTR log_header_ptr; _mqx_uint result; #if MQX_CHECK_ERRORS if (max_size == 0) { return LOG_INVALID_SIZE; } /* Endif */ #endif log_header_ptr = _mem_alloc_system_zero((_mem_size) sizeof(LWLOG_HEADER_STRUCT) + (_mem_size) (max_size - 1) * (_mem_size) sizeof(LWLOG_ENTRY_STRUCT)); #if MQX_CHECK_MEMORY_ALLOCATION_ERRORS if (log_header_ptr == NULL) { return (MQX_OUT_OF_MEMORY); } /* Endif */ #endif _mem_set_type(log_header_ptr, MEM_TYPE_LWLOG); result = _lwlog_create_internal(log_number, max_size, flags, log_header_ptr); if (result == MQX_OK) { log_header_ptr->TYPE = LWLOG_DYNAMIC; } else { _mem_free(log_header_ptr); } /* Endif */ return (result); } /* Endbody */
_mqx_uint _lwlog_create_at ( /* [IN] the log number to be used */ _mqx_uint log_number, /* [IN] the maximum number of entries */ _mqx_uint max_size, /* [IN] flags about the properties of the log */ _mqx_uint flags, /* [IN] where the log should be created */ pointer where ) { /* Body */ LWLOG_HEADER_STRUCT_PTR log_header_ptr = (LWLOG_HEADER_STRUCT_PTR)where; _mqx_uint result; #if MQX_CHECK_ERRORS if (max_size == 0) { return(LOG_INVALID_SIZE); } /* Endif */ if (where == NULL) { return(MQX_INVALID_POINTER); } /* Endif */ #endif result = _lwlog_create_internal(log_number, max_size, flags, log_header_ptr); if (result == MQX_OK) { log_header_ptr->TYPE = LWLOG_STATIC; } /* Endif */ return(result); } /* Endbody */