📄 ds.c
字号:
/************************************************************************/
/* */
/* Copyright 1990-1992 by Accelerated Technology */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are */
/* governed by the license agreement. The buyer or recipient of this */
/* package, implicitly accepts the terms of the license. */
/* */
/************************************************************************/
/************************************************************************/
/* */
/* FILE DESCRIPTION */
/* */
/* This file contains routines that facilitate system development. */
/* */
/* ROUTINES */
/* */
/* DS_Initialize Initialize development supp */
/* DS_Reset_Performance_Timer Reset a performance timer */
/* DS_Retrieve_Performance_Timer Retrieve performance info */
/* DS_Start_Performance_Timer Start a performance timer */
/* DS_Stop_Performance_Timer Stop a performance timer */
/* DS_Retrieve_Next_History_Entry Retrieve from history log */
/* DS_Make_History_Entry Make an entry in history log*/
/* DS_Start_History_Saving Enable history saving */
/* DS_Stop_History_Saving Disable history saving */
/* */
/* NOTES */
/* */
/* Routines expect that interrupts are locked out upon invocation. */
/* */
/************************************************************************/
/* Define necessary include files. */
#include "nu_defs.h" /* General constants */
#include "cl_extr.h" /* Data structure defns */
#include "sk_extr.h" /* Scheduler routine defs */
#include "ds_defs.h" /* Development structures */
#include "in_extr.h" /* Alloc and error routines */
/* Define global data structures to the development support component. */
/* The pointer "DS_Timer_List" is used to point to the list of
sequentially allocated performance timers. */
struct DS_TASK_TIMERS_STRUCT *DS_Timer_List;
/* Use the conditional compilation construct to avoid allocation of the
history table unless specified. */
#ifdef NU_ENABLE_HISTORY
/* The array of structures, "DS_History," is used to provide a place for
historical system events. */
struct DS_HISTORY_ENTRY_STRUCT DS_History[DS_MAX_HISTORY_ENTRIES];
/* The variable "DS_Hist_Index_Sav" is used to save the first entry
read from. */
signed int DS_Hist_Index_Sav;
/* The variable "DS_Hist_Index" is used to maintain the next entry to
read from/write to. */
signed int DS_Hist_Index;
/* The variable "DS_History_On" is used to determine whether history
saving is necessary. */
signed int DS_History_On;
/* The variable "DS_Hist_Sequence" is used to provide the
calling routine with the sequence number in the history log. */
signed int DS_Hist_Sequence;
#endif
/************************************************************************/
/* */
/* FUNCTION "DS_Initialize" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to allocate and initialize all of the */
/* development system control structures. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* INP_Initialize High level initialization */
/* */
/* ROUTINES CALLED */
/* */
/* INP_Memory_Alloc Allocate initial memory */
/* SKP_Maximum_Tasks Maximum number of tasks */
/* */
/* INPUTS */
/* */
/* Number of Tasks */
/* */
/* OUTPUTS */
/* */
/* DS_Timer_List[] Task timers */
/* DS_History History log */
/* DS_Hist_Write History log write index */
/* DS_Hist_Read History log read index */
/* */
/************************************************************************/
void DS_Initialize()
{
#if defined(NU_ENABLE_TIMING) || defined(NU_ENABLE_HISTORY)
int i; /* Working variable */
#endif
/* Determine if timers are desired. */
#ifdef NU_ENABLE_TIMING
int bytes; /* Number of bytes to alloc */
unsigned int number_of_timers; /* Number of timers */
/* Initialize the development support variables. */
/* Call the scheduler to determine how many task timer sets are
needed. */
number_of_timers = SKP_Maximum_Tasks();
/* If there are any timers specified allocate and initialize the
timers for each task. */
if (number_of_timers)
{
/* Allocate memory for all of the task timers. */
bytes = sizeof(struct DS_TASK_TIMERS_STRUCT) * number_of_timers;
DS_Timer_List = (struct DS_TASK_TIMERS_STRUCT *)
INP_Memory_Alloc(bytes);
}
/* Initialize each timer. */
for (i = 0; i < number_of_timers; i++)
{
/* Initialize the execution time timer. */
DS_Timer_List[i].ds_execution_timer.ds_max_time = 0;
DS_Timer_List[i].ds_execution_timer.ds_min_time = (unsigned int) (-1);
DS_Timer_List[i].ds_execution_timer.ds_timer_stat =
DS_TIMER_NOT_STARTED;
DS_Timer_List[i].ds_execution_timer.ds_accum_time = 0;
DS_Timer_List[i].ds_execution_timer.ds_accum_count = 0;
DS_Timer_List[i].ds_execution_timer.ds_timer_start = 0;
/* Initialize the suspended time timer. */
DS_Timer_List[i].ds_suspended_timer.ds_max_time = 0;
DS_Timer_List[i].ds_suspended_timer.ds_min_time = (unsigned int) (-1);
DS_Timer_List[i].ds_suspended_timer.ds_timer_stat =
DS_TIMER_NOT_STARTED;
DS_Timer_List[i].ds_suspended_timer.ds_accum_time = 0;
DS_Timer_List[i].ds_suspended_timer.ds_accum_count = 0;
DS_Timer_List[i].ds_suspended_timer.ds_timer_start = 0;
/* Initialize the ready but waiting timer. */
DS_Timer_List[i].ds_readywait_timer.ds_max_time = 0;
DS_Timer_List[i].ds_readywait_timer.ds_min_time = (unsigned int) (-1);
DS_Timer_List[i].ds_readywait_timer.ds_timer_stat =
DS_TIMER_NOT_STARTED;
DS_Timer_List[i].ds_readywait_timer.ds_accum_time = 0;
DS_Timer_List[i].ds_readywait_timer.ds_accum_count = 0;
DS_Timer_List[i].ds_readywait_timer.ds_timer_start = 0;
/* Initialize the user's first timer. */
DS_Timer_List[i].ds_user_timer_1.ds_max_time = 0;
DS_Timer_List[i].ds_user_timer_1.ds_min_time = (unsigned int) (-1);
DS_Timer_List[i].ds_user_timer_1.ds_timer_stat =
DS_TIMER_NOT_STARTED;
DS_Timer_List[i].ds_user_timer_1.ds_accum_time = 0;
DS_Timer_List[i].ds_user_timer_1.ds_accum_count = 0;
DS_Timer_List[i].ds_user_timer_1.ds_timer_start = 0;
/* Initialize the user's second timer. */
DS_Timer_List[i].ds_user_timer_2.ds_max_time = 0;
DS_Timer_List[i].ds_user_timer_2.ds_min_time = (unsigned int) (-1);
DS_Timer_List[i].ds_user_timer_2.ds_timer_stat =
DS_TIMER_NOT_STARTED;
DS_Timer_List[i].ds_user_timer_2.ds_accum_time = 0;
DS_Timer_List[i].ds_user_timer_2.ds_accum_count = 0;
DS_Timer_List[i].ds_user_timer_2.ds_timer_start = 0;
/* Initialize the user's third timer. */
DS_Timer_List[i].ds_user_timer_3.ds_max_time = 0;
DS_Timer_List[i].ds_user_timer_3.ds_min_time = (unsigned int) (-1);
DS_Timer_List[i].ds_user_timer_3.ds_timer_stat =
DS_TIMER_NOT_STARTED;
DS_Timer_List[i].ds_user_timer_3.ds_accum_time = 0;
DS_Timer_List[i].ds_user_timer_3.ds_accum_count = 0;
DS_Timer_List[i].ds_user_timer_3.ds_timer_start = 0;
}
/* End of conditional timer compilation. */
#endif
/* Now determine if system history is desired. */
#ifdef NU_ENABLE_HISTORY
/* History enabled, initailize the read/write indices. */
DS_Hist_Index = 0;
DS_Hist_Index_Sav = 0;
/* Initialize the History On/Off flag. */
DS_History_On = NU_TRUE;
/* Walk through the history log and initialize each entry. */
for (i = 0; i < DS_MAX_HISTORY_ENTRIES; i++)
{
/* Initialie the history entry. */
DS_History[i].ds_event_id = NU_NO_EVENT;
DS_History[i].ds_param_1 = 0;
DS_History[i].ds_param_2 = 0;
DS_History[i].ds_time = 0;
}
/* Finished with conditional compilation. */
#endif
} /* end of DS_Initialize */
/* Conditional compile the performance timer routines. */
#ifdef NU_ENABLE_TIMING
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -