📄 davevent.c
字号:
/*## Global Declarations
//#########################*/
BOOLEAN EVT_CheckPageReclaim = FALSE;
EVT_EventElement EVT_EventList[EVT_TotalEvents];
/*## Local Functions
//#########################*/
/*#######################################################################
//### PrintEventMark
//###
*/
void PrintEventMark(BOOLEAN is_set, FILE *fptr)
{
if (is_set)
{
fprintf(fptr, "x ");
}
else
{
fprintf(fptr, " ");
}
}
/*########################################################################
//### SpecialReclaimTest
//###
*/
BOOLEAN SpecialReclaimTest(int test_point_id)
{
if (((ReclaimState.ReclaimType == ReclaimParagraphObjects) &&
EVT_CheckPageReclaim) ||
((ReclaimState.ReclaimType == ReclaimPageObjects) &&
!EVT_CheckPageReclaim))
{
return FALSE;
}
return TRUE;
}
/*### Global Functions
//#########################*/
/*########################################################################
//### EVT_DisplayEvents
//###
*/
void EVT_DisplayEvents(FILE *fptr)
{
int ii;
int test_range;
if (fptr == NULL)
{
fptr = stdout;
}
fprintf(fptr, "Event List:\n");
fprintf(fptr, " D D D T \n");
fprintf(fptr, " Item Event I S S B I R E K \n");
fprintf(fptr, " # Module Count Count D U T P M E X E Id\n");
fprintf(fptr, "======================================================================\n");
for (ii = 0; ii < EVT_TotalEvents; ii++)
{
fprintf(fptr, "%3d ", ii);
if (ii >= EVT_RECLAIM_BEGIN)
{
test_range = 1;
}
if (ii >= EVT_RECRCVR_BEGIN)
{
test_range = 2;
}
if (ii >= EVT_REALLOCATE_BEGIN)
{
test_range = 3;
}
if (ii >= EVT_CONFIG_HDR_BEGIN)
{
test_range = 4;
}
if (ii >= EVT_RECOVER_BEGIN)
{
test_range = 5;
}
if (ii >= EVT_TotalEvents)
{
test_range = 0;
}
#ifdef ENABLE_EVENT_STATISTICS
fprintf(fptr, "%s %07ld %07ld ", event_str[test_range],
EVT_EventList[ii].TestCount, EVT_EventList[ii].EventCount);
#endif
PrintEventMark(EVT_IsDisplayIdEvent(ii), fptr);
PrintEventMark(EVT_IsDisplaySummaryEvent(ii), fptr);
PrintEventMark(EVT_IsDumpStateEvent(ii), fptr);
PrintEventMark(EVT_IsBreakPointEvent(ii), fptr);
PrintEventMark(EVT_IsTimerEvent(ii), fptr);
PrintEventMark(EVT_IsRandomErrorEvent(ii), fptr);
PrintEventMark(EVT_IsExitEvent(ii), fptr);
PrintEventMark(EVT_IsKeepEnabledEvent(ii), fptr);
#ifdef ENABLE_EVENT_STATISTICS
if ((EVT_EventList[ii].EventCount == 0) && EVT_IsEnabled(ii))
{
/* Make a special not of events that are enabled, and */
/* never tested. */
fprintf(fptr, " [%s]\n", event_name[ii]);
}
else
{
fprintf(fptr, " %s\n", event_name[ii]);
}
#endif
}
}
/*########################################################################
//### EVT_SetEvent
//###
*/
void EVT_SetEvent(EVT_TestPointIds test_point_id,
EVT_EventElementPtr event_ptr)
{
*(UINT16_PTR)&(EVT_EventList[test_point_id].Event) =
*(UINT16_PTR)&(event_ptr->Event);
}
/*########################################################################
//### EVT_ClearEvent
//###
*/
void EVT_ClearEvent(EVT_EventElementPtr event_ptr)
{
*(UINT16_PTR)&(event_ptr->Event) = 0;
}
/*########################################################################
//### EVT_InitEvents
//###
*/
void EVT_InitEvents(void)
{
int ii;
for (ii = 0; ii < EVT_TotalEvents; ii++)
{
EVT_ClearEvent(&EVT_EventList[ii]);
}
}
/*########################################################################
//### EVT_SetAllEvents
//###
*/
void EVT_SetAllEvents(EVT_TestPointIds start_id, EVT_TestPointIds end_id,
EVT_EventElementPtr event_ptr)
{
int ii;
for (ii = start_id; ii <= end_id; ii++)
{
EVT_SetEvent(ii, event_ptr);
}
}
/*########################################################################
//### EVT_DisableEvent
//###
*/
BOOLEAN EVT_DisableEvent(EVT_TestPointIds test_point_id)
{
EVT_EventList[test_point_id].Event &= ~EVT_ENABLE;
return TRUE;
}
/*########################################################################
//### EVT_EnableEvent
//###
*/
BOOLEAN EVT_EnableEvent(EVT_TestPointIds test_point_id)
{
EVT_SetEnabled(test_point_id);
return TRUE;
}
void DisplayEventId(EVT_TestPointIds test_point_id)
{
int test_range;
if (test_point_id >= EVT_RECLAIM_BEGIN)
{
test_range = 1;
}
if (test_point_id >= EVT_REALLOCATE_BEGIN)
{
test_range = 2;
}
if (test_point_id >= EVT_CONFIG_HDR_BEGIN)
{
test_range = 3;
}
if (test_point_id >= EVT_RECOVER_BEGIN)
{
test_range = 4;
}
if (test_point_id >= EVT_RECRCVR_BEGIN)
{
test_range = 5;
}
if (test_point_id >= EVT_TotalEvents)
{
test_range = 0;
}
printf("TEST POINT: (0x%02x) %s", test_point_id,
event_str[test_range]);
printf(" %s\n",event_name[test_point_id]);
}
/*########################################################################
//### EVT_TestEvent
//###
*/
BOOLEAN EVT_TestEvent(EVT_TestPointIds test_point_id)
{
BOOLEAN event_actuated;
static BOOLEAN all_events_disabled = FALSE;
static EVT_TestPointIds disabler_event;
#ifdef ENABLE_EVENT_STATISTICS
EVT_EventList[test_point_id].TestCount++;
#endif
if (EVT_IsDisplayIdEvent(test_point_id))
{
DisplayEventId(test_point_id);
}
/* Allow the DisableAll event to turn off all events until */
/* it clears its DisableAll event and calls this function. */
/* This will only allow the caller of the DisableAll to */
/* turn the events back on!!! */
if (all_events_disabled)
{
if (disabler_event == test_point_id)
{
if (!EVT_IsDisableAllEvent(test_point_id))
{
all_events_disabled = FALSE;
}
}
return FALSE;
}
if (!EVT_IsEnabled(test_point_id))
{
return FALSE;
}
#ifdef ENABLE_SPECIAL_RECLAIM_TEST
if ((test_point_id >= EVT_RECLAIM_BEGIN) &&
(test_point_id <= EVT_RECLAIM_END))
{
if (!SpecialReclaimTest(test_point_id))
{
return FALSE;
}
}
#endif
event_actuated = FALSE;
if (EVT_IsDisableAllEvent(test_point_id))
{
all_events_disabled = TRUE;
disabler_event = test_point_id;
event_actuated = TRUE;
}
if (EVT_IsDisplaySummaryEvent(test_point_id))
{
DisplayMem();
}
if (EVT_IsDumpStateEvent(test_point_id))
{
/* Dump an ascii readable version of the flash array */
DumpFlashState("fstate.txt");
/* Dump a reloadable version of the flash array */
SaveFlashState("fstate.bin");
event_actuated = TRUE;
}
if (EVT_IsBreakPointEvent(test_point_id))
{
/* Enable for DOS debug (int 3 is the breakpoint instruction)
asm { int 3 };
*/
event_actuated = TRUE;
}
if (EVT_IsTimerEvent(test_point_id))
{
/* ADD CODE HERE TO START AND STOP TIMER */
}
if (EVT_IsRandomErrorEvent(test_point_id))
{
/* GENERATE A TRUE OR FALSE RANDOMLY */
if (GetRandom(0, EVT_PercentageTRUE) == (EVT_PercentageTRUE / 2))
{
#ifdef EVENT_PRINT_ON
printf("\nRandom Event Triggered: \n");
DisplayEventId(test_point_id);
#endif
event_actuated = TRUE;
}
}
else
{
event_actuated = TRUE;
}
if (EVT_IsExitEvent(test_point_id))
{
printf("\nExit Event...Exiting: \n");
DisplayEventId(test_point_id);
exit(1);
}
#ifdef ENABLE_EVENT_STATISTICS
if (event_actuated)
{
EVT_EventList[test_point_id].EventCount++;
}
#endif
if (!EVT_IsKeepEnabledEvent(test_point_id))
{
EVT_EventList[test_point_id].Event &= ~EVT_ENABLE;
}
return event_actuated;
}
#endif /* end event.c */
#endif /* DIRECT_ACCESS_VOLUME */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -