OCEOS/oceos logging

From wiki
Jump to navigation Jump to search

OCEOS Logging

OCEOS logs time stamped records of anomalies detected during execution.

Logging Introduction

OCEOS logging is structured as a circular buffer, older entries are overwritten by new entries once all entries are in use. System calls are provided to add entries the log, set its maximum size, and return the number of entries, and reset.
It is set up initially as an array of 32-bit words that starts at a 32-bit aligned address provided by the application developer.

OCEOS does not change the log entries after reset, so if log area is located in non-volatile memory, after reset, the application can read to recover possible reasons of failure. Only call to oceos_log_reset() can be used to reset all log entries if desired.

Log directives can be called from main() after oceos_init().

The read and write indices are stored in the log area and if equal indicate that the log is empty.

The application developer can specify a function to be called when 3/4 of log entries are in use. This function is called again only after 3/4 of log entries have been read and the log has again become 3/4 full.
OCEOS will call a user defined function void oceos_on_full_log(void*).

void oceos_on_full_log(void*);
/*
* Create the application configuration structure
*/
struct application_configuration           app_config = {0};
app_config.log_full_function             = &oceos_on_full_log;            // NULL => ignore

Log entry types are defined in system_log.h header file. A log entry type is an 8-bit number. Values from 0 to 127 can be defined by the application developer. Values from 128 to 255 are used by OCEOS as below.

enum LOG_ENTRY_TYPE{
  LOG_SYS_OK = 0x80U,
  LOG_NULL_FATAL,
  LOG_OCEOS_ABORT,
  LOG_INVALID_SYSTEM_STATE,
  LOG_LOG_NOT_VALID_ENTRY,
  LOG_STATUS_INVALID,
  LOG_NULL_POINTER,
  LOG_INIT_FAIL,
  LOG_TIME_INIT_FAIL,
  LOG_TIME_CONFIG_FREEZE_FAIL,
  LOG_TIME_CONFIG_UNFREEZE_FAIL,
  LOG_TIME_RESET_FAIL,
  LOG_TIME_SCALER_FAIL,
  LOG_TIME_RELOAD_FAIL,
  LOG_TIME_COUNTER_FAIL,
  LOG_TIME_CONTROL_FAIL,
  LOG_TIME_POINTER_NULL,
  LOG_TIME_POINTER_LOW_NULL,
  LOG_TIME_START_FAIL,
  LOG_FIXED_INIT_FAIL,
  LOG_DYNAMIC_INIT_FAIL,
  LOG_INIT_TASK_START_FAIL,
  LOG_DEADLINE_MISSED,
  LOG_TASK_DISABLED,
  LOG_TASK_ENABLED,
  LOG_JOB_INVALID,
  LOG_JOB_NONE_FREE,
  LOG_JOB_NOT_EXECUTING,
  LOG_JOB_NOT_ACTIVE,
  LOG_READYQ_TOO_BIG,
  LOG_READYQ_SENTINEL_BAD,
  LOG_READYQ_FULL,
  LOG_READYQ_EMPTY,
  LOG_READYQ_PUT_DISABLED_TASK,
  LOG_READYQ_PUT_FAIL,
  LOG_READYQ_REMOVE_DONE,
  LOG_READYQ_REMOVE_FAIL,
  LOG_PARAM_BAD_ID,
  LOG_PARAM_BAD_TIME,
  LOG_PARAM_ACTION_MISSING,
  LOG_PARAM_JOB_MISSING,
  LOG_MUTEX_BAD_CEILING,
  LOG_MUTEX_ALREADY_HELD,
  LOG_MUTEX_ALREADY_FREE,
  LOG_MUTEX_WRONG_JOB,
  LOG_MUTEX_NESTING_BAD,
  LOG_MUTEX_EXIT_HOLDING,
  LOG_SEMAPHORE_COUNT_EXCEEDED,
  LOG_SEMAPHORE_MAX_ALREADY_REACHED,
  LOG_SEMAPHORE_INVALID_PENDING_JOB,
  LOG_SEMAPHORE_PENDING_REMOVE_FAIL,
  LOG_SEMAPHORE_PENDING_TIMED_REMOVE_FAIL,
  LOG_SEMAPHORE_TRANSFER_READYQ_FAIL,
  LOG_DATAQ_FULL,
  LOG_DATAQ_EMPTY,
  LOG_DATAQ_COUNT_EXCEEDED,
  LOG_DATAQ_PENDING_QUEUE_FULL,
  LOG_DATAQ_INVALID_PENDING_JOB,
  LOG_DATAQ_PENDING_REMOVE_FAIL,
  LOG_DATAQ_TIMED_JOB_REMOVE_FAIL,
  LOG_TIMED_ACTION_TIMER_NULL,
  LOG_TIMED_ACTION_TIMER_STOP_FAIL,
  LOG_TIMED_ACTION_NOT_INIT,
  LOG_TIMED_ACTION_INT_REG_FAILED, // Failed to register timed action interrupt handler
  LOG_TIMED_ACTION_INVALID,
  LOG_TIMED_ACTION_BAD_INDEX,
  LOG_TIMED_ACTION_MISSED,
  LOG_TIMED_ACTION_Q_FULL,
  LOG_TIMED_ACTION_Q_EMPTY,
  LOG_TIMED_ACTION_PUT_FAIL,
  LOG_TIMED_ACTION_REMOVE_FAIL,
  LOG_TIMED_ACTION_BAD_JOB_ID,
  LOG_TIMED_ACTION_DO_FAIL,
  LOG_SYSTEM_ERROR,
  LOG_TIME_BSP_SYSFREQ_NULL,
  LOG_SEMAPHORE_TIMEOUT_NOT_INIT,    // If user wants to use semaphore with timeout without previous initialization of timed actions
  LOG_DATAQ_TIMEOUT_NOT_INIT,       // If user wants to use dataq with timeout without previous initialization of timed actions
  LOG_TIMED_ACTION_START_WHILE_RUNNING,
  LOG_INT_HANDLER_IS_NULL,
  LOG_SET_OCEOS_TRAP_HANDLER_FAILED,
  LOG_INT_CALLED_NO_INIT,
  LOG_FAILED_SET_INT_PRIO,       // Failed to set PendSV priority
  LOG_FAILED_PENDSV_INIT,
  LOG_SYS_TIME_NOT_INIT          // System time is not initialized
};

Logging Configuration

Application defines arrays to hold OCEOS internal data. User must specified array to accommodate all logging information. Please read OCEOS data area layouts

#define LOG_DATA_ARRAY_SIZE_U32S                0x100// Calculated value. Read manual
U32_t log_data[LOG_DATA_ARRAY_SIZE_U32S];
...
/*
 * Create the application configuration structure
 */
struct application_configuration           app_config = {0};
app_config.log_address                   = (adrs_t)log_data;

User must define number of log entries.

API Functions

API Functions
Directive Description main task IRQ handler
oceos_log_add_entry() Add a log entry * * *
oceos_log_remove_entry() Read and remove the oldest unread log entry * * *
oceos_log_get_indexed_entry() Read the log entry at the given index * * *
oceos_log_reset() Clear all log entries and reset to empty * * *
oceos_log_get_size() Get the number of log entries * * *