#!KSHELL -p
#
#  This script takes the output from the Timing Test Suite, reorders
#  it, and adds headers so it is in the same order as is printed in
#  the supplement.
#

usage()
{
  echo "${progname} file [more files]"
}

header()
{
  echo
  echo $*
  echo
}

lookup()
{
  grep "$*" $files

}

progname=$0

if [ $# -eq 0 ] ; then
  usage
  exit 0
fi

files=$*

header Context Switch
lookup context switch: self
lookup context switch: to another task
lookup context switch: no floating point contexts
lookup fp context switch: restore 1st FP task
lookup fp context switch: save initialized, restore initialized
lookup fp context switch: save idle, restore initialized
lookup fp context switch: save idle, restore idle

header Task Manager
lookup rtems_task_create
lookup rtems_task_ident
lookup rtems_task_start
lookup rtems_task_restart: calling task
lookup rtems_task_restart: suspended task -- returns to caller
lookup rtems_task_restart: blocked task -- returns to caller
lookup rtems_task_restart: ready task -- returns to caller
lookup rtems_task_restart: suspended task -- preempts caller
lookup rtems_task_restart: blocked task -- preempts caller
lookup rtems_task_restart: ready task -- preempts caller
lookup rtems_task_delete: calling task
lookup rtems_task_delete: suspended task
lookup rtems_task_delete: blocked task
lookup rtems_task_delete: ready task
lookup rtems_task_suspend: calling task
lookup rtems_task_suspend: returns to caller
lookup rtems_task_resume: task readied -- returns to caller
lookup rtems_task_resume: task readied -- preempts caller
lookup rtems_task_set_priority: obtain current priority
lookup rtems_task_set_priority: returns to caller
lookup rtems_task_set_priority: preempts caller
lookup rtems_task_mode: obtain current mode
lookup rtems_task_mode: no reschedule
lookup rtems_task_mode: reschedule -- returns to caller
lookup rtems_task_mode: reschedule -- preempts caller
lookup rtems_task_get_note
lookup rtems_task_set_note
lookup rtems_task_wake_after: yield -- returns to caller
lookup rtems_task_wake_after: yields -- preempts caller
lookup rtems_task_wake_when

header Interrupt Manager
lookup interrupt entry overhead: returns to nested interrupt
lookup interrupt entry overhead: returns to interrupted task
lookup interrupt entry overhead: returns to preempting task
lookup interrupt exit overhead: returns to nested interrupt
lookup interrupt exit overhead: returns to interrupted task
lookup interrupt exit overhead: returns to preempting task

header Clock Manager
lookup rtems_clock_set
lookup rtems_clock_get
lookup rtems_clock_tick

header Timer Manager
lookup rtems_timer_create
lookup rtems_timer_ident
lookup rtems_timer_delete: inactive
lookup rtems_timer_delete: active
lookup rtems_timer_fire_after: inactive
lookup rtems_timer_fire_after: active
lookup rtems_timer_fire_when: inactive
lookup rtems_timer_fire_when: active
lookup rtems_timer_reset: inactive
lookup rtems_timer_reset: active
lookup rtems_timer_cancel: inactive
lookup rtems_timer_cancel: active

header Semaphore Manager
lookup rtems_semaphore_create
lookup rtems_semaphore_ident
lookup rtems_semaphore_delete
lookup rtems_semaphore_obtain: available
lookup rtems_semaphore_obtain: not available -- NO_WAIT
lookup rtems_semaphore_obtain: not available -- caller blocks
lookup rtems_semaphore_release: no waiting tasks
lookup rtems_semaphore_release: task readied -- returns to caller
lookup rtems_semaphore_release: task readied -- preempts caller

header Message Queue Manager
lookup rtems_message_queue_create
lookup rtems_message_queue_ident
lookup rtems_message_queue_delete
lookup rtems_message_queue_send: no waiting tasks
lookup rtems_message_queue_send: task readied -- returns to caller
lookup rtems_message_queue_send: task readied -- preempts caller
lookup rtems_message_queue_urgent: no waiting tasks
lookup rtems_message_queue_urgent: task readied -- returns to caller
lookup rtems_message_queue_urgent: task readied -- preempts caller
lookup rtems_message_queue_broadcast: no waiting tasks
lookup rtems_message_queue_broadcast: task readied -- returns to caller
lookup rtems_message_queue_broadcast: task readied -- preempts caller
lookup rtems_message_queue_receive: available
lookup rtems_message_queue_receive: not available -- NO_WAIT
lookup rtems_message_queue_receive: not available -- caller blocks
lookup rtems_message_queue_flush: no messages flushed
lookup rtems_message_queue_flush: messages flushed

header Event Manager
lookup rtems_event_send: no task readied
lookup rtems_event_send: task readied -- returns to caller
lookup rtems_event_send: task readied -- preempts caller
lookup rtems_event_receive: obtain current events
lookup rtems_event_receive: available
lookup rtems_event_receive: not available -- NO_WAIT
lookup rtems_event_receive: not available -- caller blocks

header Signal Manager
lookup rtems_signal_catch
lookup rtems_signal_send: returns to caller
lookup rtems_signal_send: signal to self
lookup exit ASR overhead: returns to calling task
lookup exit ASR overhead: returns to preempting task

header Partition Manager
lookup rtems_partition_create
lookup rtems_partition_ident
lookup rtems_partition_delete
lookup rtems_partition_get_buffer: available
lookup rtems_partition_get_buffer: not available
lookup rtems_partition_return_buffer

header Region Manager
lookup rtems_region_create
lookup rtems_region_ident
lookup rtems_region_delete
lookup rtems_region_get_segment: available
lookup rtems_region_get_segment: not available -- NO_WAIT
lookup rtems_region_get_segment: not available -- caller blocks
lookup rtems_region_return_segment: no waiting tasks
lookup rtems_region_return_segment: task readied -- returns to caller
lookup rtems_region_return_segment: task readied -- preempts caller

header Dual-Ported Memory Manager
lookup rtems_port_create
lookup rtems_port_ident
lookup rtems_port_delete
lookup rtems_port_internal_to_external
lookup rtems_port_external_to_internal

header IO Manager
lookup rtems_io_initialize
lookup rtems_io_open
lookup rtems_io_close
lookup rtems_io_read
lookup rtems_io_write
lookup rtems_io_control

header Rate Monotonic Manager
lookup rtems_rate_monotonic_create
lookup rtems_rate_monotonic_ident
lookup rtems_rate_monotonic_cancel
lookup rtems_rate_monotonic_delete: active
lookup rtems_rate_monotonic_delete: inactive
lookup rtems_rate_monotonic_period: obtain status
lookup rtems_rate_monotonic_period: initiate period -- returns to caller
lookup rtems_rate_monotonic_period: conclude periods -- caller blocks
exit 0
