/***************************************************************************/ /***************************************************************************/ /******* *******/ /******* SETUP INFORMATION *******/ /******* *******/ /******* Important : Please read this prior to compilation *******/ /******* *******/ /***************************************************************************/ /***************************************************************************/ /* */ /* BEFORE COMPILATION OF THIS MODULE - SEE FAISWITC.H */ /* */ /***************************************************************************/ /***************************************************************************/ #pragma EJECT /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /***** *****/ /***** D H C - 8 S e r i e s 400 *****/ /***** *****/ /***** F U E L Q U A N T I T Y G A G I N G S Y S T E M *****/ /***** *****/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /* */ /* Program Name : DHC-8 Fuel Quantity Gaging System (FQGS) */ /* Source File Name : fai.c */ /* CPC : Fault Isolation and reporting */ /* Engineer : Linda Jahnke */ /* Criticality Level : Level C */ /* */ /* Contents : fai_initialization */ /* fai_pass_fail_logger */ /* fai_status_reporter */ /* fai_fault_logger */ /* fai_fault_determination */ /* fai_fault_output */ /* fai_kill_fault_list */ /* fai_search_for_fault_in_list */ /* fai_remove_node_from_list */ /* fai_add_node_to_list */ /* fai_current_faults_out */ /* */ /* */ /* Description : This CPC fault isolates, maintains a record and */ /* logs fault in NOVRAM */ /* */ /* Contents of this document are propriety information, property of: */ /* PARKER HANNIFIN CORPORATION */ /* GULL ELECTRONIC SYSTEMS DIVISION */ /* SMITHTOWN, NEW YORK 11787 */ /* Any attempt to copy or use the contents of this document in any manner */ /* whatsoever without express written consent of the owner is prohibited. */ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /* Revision History */ /***************************************************************************/ /* */ /* Date Rev Engineer Description */ /* ------ --- -------- ------------------------------------------------ */ /* 072495 A K Monroe Pr 018 Check if fai_fault_counters indicates */ /* transitioned to fail state for fault */ /* before processing fault upon entering */ /* fai_pass_fail_logger. */ /* */ /* Reset group_failure_status buffer in */ /* fai_kill_fault_list. */ /* */ /* Remove fai_reset_fault_counts because */ /* it is not being used. */ /* */ /***************************************************************************/ #pragma EJECT #pragma noam #pragma DEBUG #pragma LARGE #pragma OBJECTEXTEND #pragma SYMBOLS #include "c:\c51\inc\reg51.h" #include "c:\c51\inc\string.h" #include "defines.h" #define EXTRN extern #define MAIN_FILE 0 #pragma listinclude #include "typedefs.h" #include "globals.h" #include "nvm.h" #include "fai.h" #include "faiswitc.h" /*************************/ /* module level literals */ /*************************/ #define HARD_FAILURE_RECOGNIZED -1 /* used to determine when hard */ /* failure was processed - setting */ /* in fai_fault_counters */ #define TO_PASS_TRANSITION 0x7f /* value used to determine when a */ /* test has transitioned from failed */ /* to a pass condition */ #define FAULT_NOT_CURRENT PASS /* setting of current_fault member */ /* in the FAI_FAULT_LIST_NODE_T typedef */ /* when fault is a stored fault - not current */ #define FAULT_CURRENT FAIL /* setting when fault is current */ #define FAULT_IN_NOVRAM -1 /* used to determine if first occurrence */ /* of fault after power up should be logged */ /* if -1 then no - already logged from previous mission */ /***************************/ /* module level variables */ /***************************/ xdata char fai_fault_counters[FAI_NUM_OF_TESTS]; /* array for each test indicating when a test */ /* is in a failed state - range of values are */ /* as follows - MAX CONSEC FAILURE COUNT for test - 0 */ /* meaning fault detected, HARD_FAILURE_RECOGNIZED (transition */ /* to hard failure processed) */ /* TO_PASS_TRANSITION (status transitioned to pass) */ /*****************************************************************/ /* structure definition for the status */ /*****************************************************************/ /**********************************************************************/ /* fai_group_failure_status : */ /* lower byte : */ /* bit 0 up to 7 each represent a test where a hard fault is detected */ /* the max consecutive failures have been reached for this */ /* test when bit is set */ /* upper byte : */ /* bit 0 up to 7 each represent a test where a failure is detected */ /* but not necessarily a hard failure */ /**********************************************************************/ WORD_BYTE_OVERLAY_T fai_group_failure_status [FAI_NUM_OF_GROUPS]; typedef struct { uchar nvm_location; /* the record position within NOVRAM */ uchar nvm_status; /* status of the data being - good record */ /* no next record or novram record failure */ } FAI_REC_STATUS_T; /************************************************************************/ /* the following typedefs struct definitions make up the representation */ /* of the node maintained in the fault lists */ /************************************************************************/ typedef union { uint whole; // means of accessing the fault code as a whole instead of // as defined below struct { uchar lru; // identifier indicating the LRU where the fault resides uchar error; } part; // identifier indicating the error found with the LRU }FAULT_CODE_UNION_T; // word or byte representation of fault code typedef struct { FAULT_CODE_UNION_T fault_code; // fault code defined above uint num_of_occurrences; // number of times the fault has been detected uint order_of_occurrence; // relative order inwhich it has been detected } FAI_NVM_DATA_T; struct FAULT_LIST_NODE_T { FAI_REC_STATUS_T rec_status; // see FAI_REC_STATUS_T above FAI_NVM_DATA_T nvm_rec; // see FAI_NVM_DATA_T above char current_status; // used to determine if fault is current struct FAULT_LIST_NODE_T xdata *p_next; // points to next node in list struct FAULT_LIST_NODE_T xdata *p_previous; // points to previous node in list }; /*******************************************************************************/ /* The following typdefs/ structures /declarations are for each group's */ /* fault list - pointers to the beginning and end of list for example and */ /* also what is defined below : */ /* */ /* 1. list pointers - pointers to the first and last nodes in list */ /* 2. mem_pool - memory pool large enough to contain the max number */ /* of faults for a group - it is from here that a memory allocation is */ /* made when a fault needs to be added to the list ( acts sort of like */ /* dynamic memory allocation) */ /* 3. pointer to the next avaialbe location in the memory pool */ /* 4. available novram record pool - hold memory locations available */ /* for faults if the end of the fault groups novram block has been */ /* reached - for this to happen locations that contain old faults are */ /* used - treated as a fifo */ /* 5. start and end pointers to avaialble novram record pool fifo */ /* 6. counter for number of nodes in list */ /* */ /*******************************************************************************/ typedef struct FAULT_LIST_NODE_T FAI_FAULT_LIST_NODE_T; typedef struct { FAI_FAULT_LIST_NODE_T xdata *p_list_start; // pointer to the start of list FAI_FAULT_LIST_NODE_T xdata *p_list_end; // pointer to the end of the list } FAI_LIST_PTRS_T; typedef struct { FAI_LIST_PTRS_T list_ptrs; // see 1 above FAI_FAULT_LIST_NODE_T xdata *p_mem_pool; // see 3 above FAI_FAULT_LIST_NODE_T fault_list_mem_pool[MAX_NODES_FOR_NOVRAM_FAULTS]; // see 2 uchar avail_nvm_rec_pool[AVAIL_NOVRAM_RECS_POOL_LEN]; // see 4 uchar xdata *p_start_nvm_rec_pool; // see 5 uchar xdata *p_end_nvm_rec_pool; // see 5 uchar list_node_counter; // see 6 } FAI_NOVRAM_GROUP_LIST_T; FAI_NOVRAM_GROUP_LIST_T fai_nvm_group_fault_list_ptrs [NUM_OF_NOVRAM_GROUPS]; /*************************************************************/ /* below are the data structure used for the list for output */ /*************************************************************/ typedef struct { uint fault_code; uint num_of_occurrences; char current_status; }FAI_OUT_DATA_T; FAI_OUT_DATA_T fai_faults_for_output[MAX_NODES_FOR_OUTPUT]; /************************/ /* FIFO DATA STRUCTURES */ /************************/ typedef struct { uchar fault_id; char current_status; } FAI_FIFO_DATA_T; FAI_FIFO_DATA_T fai_fault_fifo [FAI_MAX_FIFO_SIZE]; FAI_FIFO_DATA_T xdata *p_fai_fifo_end , xdata *p_fai_fifo_start; uint fai_order_of_occurrence; // contains current highest order of occurrence uchar fai_highest_order_novram_group; // contains current active fault group /*******************************/ /* NOVRAM FUNCTIONS PROTOTYPES */ /*******************************/ FAI_FAULT_LIST_NODE_T xdata *nvm_read( uchar, char); FAI_REC_STATUS_T nvm_write (uchar , char ,FAI_NVM_DATA_T xdata *); #pragma eject /************************************************************************/ /* Unit Name : fai_search_for_fault_in_list */ /* Description : Searches through a fault list pointed to by p_group, */ /* for an occurrence of fault code. */ /* */ /* Returns a pointer to the node in the list if found, */ /* otherwise if not found, returns a null pointer. */ /************************************************************************/ FAI_FAULT_LIST_NODE_T xdata * fai_search_for_fault_in_list(FAI_LIST_PTRS_T xdata *p_group, uint fault_code) { /*******************/ /* Local variables */ /*******************/ FAI_FAULT_LIST_NODE_T xdata *p_comp_node; uchar search_flag = FALSE; /*****************************************/ /* search is performed from last node up */ /*****************************************/ p_comp_node = p_group->p_list_end; while ((p_comp_node) && !(p_comp_node->nvm_rec.fault_code.whole == fault_code)){ p_comp_node = p_comp_node->p_previous; } /* end while */ return (p_comp_node); } /* end fai_search_for_fault_in_list */ #pragma eject /************************************************************************/ /* Unit Name : fai_remove_node_from_list */ /* Description : Removes the node pointed to by p_node from list pointed*/ /* to by p_group returns a pointer to the node removed. */ /* */ /* Removing a node involves setting up the next and */ /* previous pointers of the nodes around the removed node */ /* so that it is no longer part of the list. */ /************************************************************************/ FAI_FAULT_LIST_NODE_T xdata * fai_remove_node_from_list(FAI_LIST_PTRS_T xdata *p_group, FAI_FAULT_LIST_NODE_T xdata *p_node) { /*******************/ /* Local variables */ /*******************/ FAI_FAULT_LIST_NODE_T xdata *p_old_node; if (p_group->p_list_start == p_node) { /************************************/ /* remove record from start of list */ /************************************/ p_group->p_list_start = p_node->p_next; p_group->p_list_start.p_previous = NULL; } /* end if */ else { p_node->p_previous.p_next = p_node->p_next; if (p_group->p_list_end == p_node) p_group->p_list_end = p_node->p_previous; else p_node->p_next.p_previous = p_node->p_previous; } /* end else */ return(p_node); } /* end fai_remove_node_from_list */ #pragma eject /************************************************************************/ /* Unit Name : fai_add_node_to_list */ /* Description : This function adds a node, pointed to by p_node, to the*/ /* list, pointed to by p_group, after the node pointed to */ /* by p_place, which if null is the begining of the list */ /************************************************************************/ void fai_add_node_to_list(FAI_LIST_PTRS_T xdata * p_group, FAI_FAULT_LIST_NODE_T xdata * p_node, FAI_FAULT_LIST_NODE_T xdata * p_place) { if ((!p_group->p_list_start) || (!p_place)) { /***************************************/ /* place this node at the beginning of */ /* the list */ /***************************************/ p_node->p_next = p_group->p_list_start; p_group->p_list_start = p_node; p_node->p_previous = NULL; if (p_node->p_next) p_node->p_next.p_previous = p_node; else p_group->p_list_end = p_node; } /* end if */ else { /*****************************/ /* load p_node after p_place */ /*****************************/ p_node->p_previous = p_place; p_node->p_next = p_place->p_next; p_place->p_next = p_node; if (p_node->p_next) /***********************/ /* not the end of list */ /***********************/ p_node->p_next.p_previous = p_node; else p_group->p_list_end = p_node; } /* end else */ } /* end fai_add_node_to_list */ #pragma eject /************************************************************************/ /* Unit Name : fai_initialization */ /* Description : This function is called a start up - all faults are */ /* read from each NOVRAM group that contains faults - a */ /* link list is created for each NOVRAM group containing */ /* the most current faults. */ /************************************************************************/ uchar fai_initialization (void) { /*******************/ /* Local variables */ /*******************/ uchar group_index; FAI_FAULT_LIST_NODE_T xdata *p_fault_record; FAI_NOVRAM_GROUP_LIST_T xdata * p_group_list = fai_nvm_group_fault_list_ptrs; FAI_FAULT_LIST_NODE_T xdata * p_comp_node; FAI_FAULT_LIST_NODE_T xdata * p_node; if (COLD == g_start_status) { /***************************************************************/ /* Initialize fault counters to the max consecutive fail value */ /***************************************************************/ memmove(fai_fault_counters,FAI_MAX_CONSEC_FAILURE, sizeof FAI_MAX_CONSEC_FAILURE); } /* end if */ /******************************/ /* initialize fifo for output */ /******************************/ p_fai_fifo_end = p_fai_fifo_start = fai_fault_fifo; /*****************************************************************/ /* For each NOVRAM fault group, build a link list, representing */ /* the faults in NOVRAM and the order inwhich they were detected */ /*****************************************************************/ for (group_index = 0; group_index < NUM_OF_NOVRAM_GROUPS; group_index++,p_group_list++) { /**************************************************/ /* set up pointers for tables and data structures */ /**************************************************/ p_group_list->p_mem_pool = &p_group_list->fault_list_mem_pool; p_group_list->p_start_nvm_rec_pool = p_group_list->p_end_nvm_rec_pool = p_group_list->avail_nvm_rec_pool; /*******************************/ /* get first fault from novram */ /*******************************/ p_fault_record = nvm_read(group_index,NVM_RESET); while (p_fault_record->rec_status.nvm_status == NVM_GOOD_RECORD) { /***********************************************/ /* first search list to determine if record is */ /* already in the list */ /***********************************************/ p_node = fai_search_for_fault_in_list(&p_group_list->list_ptrs,p_fault_record->nvm_rec.fault_code.whole); if (p_node != NULL) { /***********************************************/ /* fault is already in list. If the previous */ /* fault was detected prior to this one, */ /* remove that fault record so that this one */ /* can be put at the end of the list. */ /* (the location pointed to by p_node will now */ /* be used to load the new node) */ /***********************************************/ p_node = fai_remove_node_from_list(&p_group_list->list_ptrs,p_node); } /* end if */ else if (p_group_list->list_node_counter == MAX_NODES_FOR_NOVRAM_FAULTS) { /**********************************************************/ /* the list already has the max number of nodes ==> */ /* the oldest node needs to be removed to make room for */ /* the new node. But first the NOVRAM location of the */ /* old node is placed in the available NOVRAM record pool */ /* so that it can be used if necessary */ /**********************************************************/ p_node = fai_remove_node_from_list(&p_group_list->list_ptrs,p_group_list->list_ptrs.p_list_start); if (p_node->rec_status.nvm_status == NVM_GOOD_RECORD) { /***********************************************************/ /* the novram location the fault was contained in is valid */ /* add it to the record pool */ /***********************************************************/ *p_group_list->p_start_nvm_rec_pool = p_node->rec_status.nvm_location; if (p_group_list->p_start_nvm_rec_pool == &p_group_list->avail_nvm_rec_pool[AVAIL_NOVRAM_RECS_POOL_LEN-1]) p_group_list->p_start_nvm_rec_pool = p_group_list->avail_nvm_rec_pool; else p_group_list->p_start_nvm_rec_pool++; } /* end if */ } /* end if */ else { /*******************************************************/ /* get the next available location from the fault list */ /* mem pool */ /*******************************************************/ p_group_list->list_node_counter++; p_node =p_group_list->p_mem_pool++; } /* end else */ /***********************************************/ /* load the new fault at the end of the */ /* list and save the latest order of occurence */ /***********************************************/ *p_node = *p_fault_record; /*******************************************/ /* search for location in list for fault - */ /* based on order of occurence */ /*******************************************/ p_comp_node = p_group_list->list_ptrs.p_list_end; while ((p_comp_node) && (p_comp_node->nvm_rec.order_of_occurrence >= p_node->nvm_rec.order_of_occurrence)){ p_comp_node = p_comp_node->p_previous; } /* end while */ fai_add_node_to_list(&p_group_list->list_ptrs,p_node,p_comp_node); if (p_node->nvm_rec.order_of_occurrence > fai_order_of_occurrence) { fai_order_of_occurrence=p_node->nvm_rec.order_of_occurrence; fai_highest_order_novram_group = group_index; } p_node->current_status = FAULT_IN_NOVRAM; /** place fault output information on output fifo ***/ /*** get next fault record ***/ p_fault_record = nvm_read(group_index,NVM_NEXT); } /* while */ } /* for */ return(fai_highest_order_novram_group); } /* fai_initialization */ #pragma eject /***********************************************************************/ /* Unit Name : fai_pass_fail_logger */ /* Description : Decrements /resets fault counters for a test based on */ /* pass fail indicator */ /* Sets up status information for test */ /***********************************************************************/ void fai_pass_fail_logger (uchar test_id, uchar pass_fail_indicator) { /*******************/ /* Local variables */ /*******************/ WORD_BYTE_OVERLAY_T xdata * p_group_access; p_group_access = &fai_group_failure_status[FAI_GROUP_ACCESS[test_id]]; /*******************************************************************/ /* check if this test is in the tranisitioned to fail state */ /* where it has not been processed for fault logging - if so */ /* by-pass processing at this time so that fault can be recognized */ /* Pr 018 */ /*******************************************************************/ if (fai_fault_counters[test_id] != 0){ // Pr 018 if (pass_fail_indicator==FAIL) { /**************************************************************/ /* update the group failure status to reflect a failure state */ /* for this specific failure */ /**************************************************************/ p_group_access->b.hbyte |= FAI_FAILURE_MASK[test_id]; /************************/ /* adjust fault counter */ /************************/ if (fai_fault_counters[test_id] > 0) { /*************************************************************/ /* the test status is not in the fault state yet ( not zero) */ /* decrement fault counters and determine if transition to */ /* to failure state has occurred */ /*************************************************************/ if (fai_fault_counters[test_id] == TO_PASS_TRANSITION) fai_fault_counters[test_id] = FAI_MAX_CONSEC_FAILURE[test_id]-1; else --fai_fault_counters[test_id]; if (!fai_fault_counters[test_id]) { /**********************************************************/ /* failure status is now in the fault state of zero - set */ /* up group fault status for a hard failure and */ /* set the transition flag for the fault */ /**********************************************************/ p_group_access->b.lbyte |= FAI_FAILURE_MASK[test_id]; } } } else { /***************************************************** A pass condition has been sent. Reset the fault counters and group fault status as long as the previous fault detected has been processed *****************************************************/ if ((fai_fault_counters[test_id] != TO_PASS_TRANSITION) && (fai_fault_counters[test_id] != FAI_MAX_CONSEC_FAILURE[test_id])) { fai_fault_counters[test_id] = (fai_fault_counters[test_id] == HARD_FAILURE_RECOGNIZED)? TO_PASS_TRANSITION : FAI_MAX_CONSEC_FAILURE[test_id]; p_group_access->b.hbyte &= ~FAI_FAILURE_MASK[test_id]; p_group_access->b.lbyte &= ~FAI_FAILURE_MASK[test_id]; } } } } /* end fai_pass_fail_logger */ #pragma eject /*********************************************************************/ /* Unit Name : function fai_status_reporter */ /* Description : Returns the hard failure / failure status of a test */ /* or group of tests specified by status id */ /*********************************************************************/ uint fai_status_reporter (uchar status_id) { /*******************/ /* Local variables */ /*******************/ static WORD_BYTE_OVERLAY_T status; /************************************************************* get the return status for the failures requested - based on status_id *************************************************************/ status.w.word = fai_group_failure_status[FAI_GROUP_ACCESS[status_id]].w.word; status.b.hbyte &= FAI_FAILURE_MASK[status_id]; status.b.lbyte &= FAI_FAILURE_MASK[status_id]; return ((uint) status.w.word); } /* end fai_status_reporter */ #pragma eject /**********************************************************************/ /* Unit Name : fai_fault_logger */ /* Description : If the fault status is FAILED ,fai fault logger adds */ /* the fault code for the fault id received along with */ /* the following information to the appropriate fault */ /* list: */ /* */ /* Number of occurrences - set to 1 when fault is */ /* newly logged incremented if fault is already in */ /* list */ /* */ /* Order of occurrence - a running order of */ /* occurrence maintained and included in NOVRAM */ /* record so that the order of occurence of faults */ /* can be determined for NOVRAM faults at power up. */ /* */ /* If the fault is already in the list - the number of */ /* occurences and order of occurrence is updated and the*/ /* node is placed at the end of the list. */ /**********************************************************************/ void fai_fault_logger(uchar group_id,uchar fault_id,char fault_status) { /*******************/ /* Local variables */ /*******************/ FAI_NOVRAM_GROUP_LIST_T xdata *p_group; FAI_FAULT_LIST_NODE_T xdata *p_fault_node; /***************************************/ /* first determine if fault is already */ /* in NOVRAM */ /***************************************/ p_group = &fai_nvm_group_fault_list_ptrs[group_id]; p_fault_node = fai_search_for_fault_in_list(&p_group->list_ptrs,FAI_FAULT_CODES[fault_id]); if (fault_status==FAIL) { /************************************************/ /* if a fail condition determined for the fault */ /* just update the current status */ /************************************************/ if ((p_fault_node) && (p_fault_node->current_status == FAULT_NOT_CURRENT)) { /***************************************************/ /* fault is in NOVRAM remove fault record where it */ /* currently is in list, update the number of */ /* occurances and order of occurrence and re-write */ /* the fault in NOVRAM */ /***************************************************/ p_fault_node->nvm_rec.num_of_occurrences++; p_fault_node->current_status = FAULT_CURRENT; if (p_fault_node != p_group->list_ptrs.p_list_end) { /****************************************************/ /* only update the order of occurrence if it is not */ /* already the last fault */ /****************************************************/ p_fault_node = fai_remove_node_from_list(&p_group->list_ptrs,p_fault_node); p_fault_node->nvm_rec.order_of_occurrence = ++fai_order_of_occurrence; fai_add_node_to_list(&p_group->list_ptrs,p_fault_node,p_group->list_ptrs.p_list_end); } /* end if */ p_fault_node->rec_status = nvm_write(group_id,p_fault_node->rec_status.nvm_location, &p_fault_node->nvm_rec); } /* end if */ else if (!p_fault_node) { /*************************/ /* get location for node */ /*************************/ if (p_group->list_node_counter == MAX_NODES_FOR_NOVRAM_FAULTS) { /**********************************************/ /* the list is full - remove the oldest fault */ /**********************************************/ p_fault_node = fai_remove_node_from_list(&p_group->list_ptrs,p_group->list_ptrs.p_list_start); if (p_fault_node->rec_status.nvm_status == NVM_GOOD_RECORD) { /***********************************************************/ /* the novram location the fault was contained in is valid */ /* add it to the record pool */ /***********************************************************/ *p_group->p_start_nvm_rec_pool = p_fault_node->rec_status.nvm_location; p_group->p_start_nvm_rec_pool = (p_group->p_start_nvm_rec_pool == &p_group->avail_nvm_rec_pool[AVAIL_NOVRAM_RECS_POOL_LEN-1])? p_group->avail_nvm_rec_pool:p_group->p_start_nvm_rec_pool+1; } /* end if */ } /* end if */ else { p_group->list_node_counter++; p_fault_node = p_group->p_mem_pool++; } /* end else */ /*******************************************************/ /* set up the record and write it to a new location in */ /* NOVRAM */ /*******************************************************/ p_fault_node->nvm_rec.num_of_occurrences = 1; p_fault_node->nvm_rec.fault_code.whole = FAI_FAULT_CODES[fault_id]; p_fault_node->nvm_rec.order_of_occurrence = ++fai_order_of_occurrence; p_fault_node->current_status = FAULT_CURRENT; p_fault_node->rec_status = nvm_write(group_id,NVM_NEXT,&p_fault_node->nvm_rec); /**************************************************************/ /* loop until a good novram location has been found for write */ /* or until there are no more locations available from the */ /* novram record pool to write to */ /**************************************************************/ while ((p_fault_node->rec_status.nvm_status != NVM_GOOD_RECORD) && (p_group->p_start_nvm_rec_pool != p_group->p_end_nvm_rec_pool)) { p_fault_node->rec_status = nvm_write(group_id, *p_group->p_end_nvm_rec_pool,&p_fault_node->nvm_rec); /****************************************************/ /* update end ptr to point to next location in pool */ /****************************************************/ p_group->p_end_nvm_rec_pool = (p_group->p_end_nvm_rec_pool == &p_group->avail_nvm_rec_pool[AVAIL_NOVRAM_RECS_POOL_LEN-1])? p_group->avail_nvm_rec_pool : p_group->p_end_nvm_rec_pool+1; } /* while */ /***********************************/ /* add node to the end of the list */ /***********************************/ fai_add_node_to_list(&p_group->list_ptrs,p_fault_node,p_group->list_ptrs.p_list_end); } /* else if */ else p_fault_node.current_status = FAULT_CURRENT; } /* end if */ else if (p_fault_node) { /*********************************************/ /* fault is in list but the status for the */ /* fault has transitioned to pass update the */ /* current status */ /*********************************************/ p_fault_node->current_status = FAULT_NOT_CURRENT; } /* end if */ } /* end fai_fault_logger */ #pragma eject /**********************************************************************/ /* Unit Name : fai_fault_determination */ /* Description : Fault determination looks at all the fault counters */ /* and determines if a fault should be logged in NOVRAM */ /* following the followig criteria : */ /* */ /* 1. The status of the counter transitions to a */ /* failed condition */ /* 2. There are no faults of higher priority to this */ /* fault already logged */ /* */ /* This function calls fai_fault_logger to add it to the*/ /* list and initiate a write to NOVRAM. */ /* */ /* If the fault counter status has transitioned to pass,*/ /* this information is also relayed to fai_fault_logger */ /* so that the list node for the fault can be updated */ /**********************************************************************/ void fai_fault_determination (void) { /*******************/ /* Local variables */ /*******************/ FAI_FIFO_DATA_T xdata *p_tmp_addr; uchar code *p_test_id; uchar group_index; uchar xdata *p_current_test_result = fai_test_results; uchar fault_count; struct FAI_TEST_GROUPINGS_T *p_groupings = FAI_TEST_GROUPINGS; /**********************************/ /* clear out all old test results */ /**********************************/ memset(fai_test_results,RESET,sizeof fai_test_results); /********************************/ /* loop through each test group */ /********************************/ for (group_index = RESET; group_index < sizeof fai_test_results; ++group_index,++p_current_test_result,++p_groupings) { /* loop through each test in a test group */ for (p_test_id = p_groupings->test_codes; // pr 018 *p_test_id != EOT; p_test_id++) { if (!fai_fault_counters[*p_test_id]) { fai_fault_counters[*p_test_id] = HARD_FAILURE_RECOGNIZED; /************************************** this test has just transitioned to a failed condition. Set the test result for the group and if a higher priority fault does not exist, log the fault ***************************************/ *p_current_test_result = SET; if ((!p_groupings->p_pri_test_result) || //no higher pri group OR (!*p_groupings->p_pri_test_result)) { //no fault in higher pri group fai_fault_logger(FAI_NOVRAM_GROUP[*p_test_id],*p_test_id,FAIL); /** add new fault to fault_fifo if fifo no full **/ p_tmp_addr = (((p_fai_fifo_start + 1) == &fai_fault_fifo[FAI_MAX_FIFO_SIZE]) || !p_fai_fifo_start) ? fai_fault_fifo : p_fai_fifo_start+1; if (p_tmp_addr != p_fai_fifo_end) { /***************************** fifo ok to write to ******************************/ p_fai_fifo_start->fault_id = *p_test_id; p_fai_fifo_start->current_status = FAULT_CURRENT; p_fai_fifo_start = p_tmp_addr; } } } else if ((fai_fault_counters[*p_test_id]== HARD_FAILURE_RECOGNIZED) || //a fault exists -already reported OR (p_groupings->p_pri_test_result && //higher priority faults exist AND *p_groupings->p_pri_test_result)) //there is a higher priority fault /***************************************** a failure still exists in group set the failure flag ******************************************/ *p_current_test_result = SET; else if (fai_fault_counters[*p_test_id]== TO_PASS_TRANSITION) { /******************************************************* test has transitioned to pass if yes, load code with pass indication onto fifo (if there is room) **********************************************************/ fai_fault_logger(FAI_NOVRAM_GROUP[*p_test_id],*p_test_id,PASS); p_tmp_addr = (((p_fai_fifo_start + 1) == &fai_fault_fifo[FAI_MAX_FIFO_SIZE]) || !p_fai_fifo_start) ? fai_fault_fifo : p_fai_fifo_start+1; if (p_tmp_addr != p_fai_fifo_end) { /***************************** fifo ok to write to ******************************/ p_fai_fifo_start->fault_id = *p_test_id; p_fai_fifo_start->current_status = FAULT_NOT_CURRENT; p_fai_fifo_start = p_tmp_addr; } fai_fault_counters[*p_test_id] = FAI_MAX_CONSEC_FAILURE[*p_test_id]; } } // for } /* for */ } /* fai fault determination */ #pragma eject /*************************************************************************/ /* Unit Name : function fai_fault_output */ /* Description : This function provides fault data for a specified fault */ /* group one fault at a time with each call. */ /* */ /* When the reset parameter is received, this function */ /* scans through the fault list for the group specified and*/ /* loads an array containing the fault info in where the */ /* newest fault is at the beginning of the list. */ /* */ /* While loading the array - this function groups specific */ /* faults to be represented in more general terms if */ /* necessary. */ /* */ /* With each call to fault output the next fault in the */ /* list is output until the end of the list is reached at */ /* which time a NULL pointer is returned. */ /* */ /* If current faults are requested - only the faults that */ /* are marked as current are output */ /*************************************************************************/ FAI_OUT_DATA_T xdata *fai_fault_output ( uchar group_id,uchar current_faults_requested,uchar reset_list) { /*******************/ /* Local variables */ /*******************/ static xdata uchar save_current_faults_requested; static xdata uchar save_group_id; static FAI_OUT_DATA_T xdata *p_next_out; static FAI_OUT_DATA_T xdata *p_end_out; data uchar lru; data uchar index; FAI_FAULT_LIST_NODE_T xdata *p_node_in; save_group_id = group_id; save_current_faults_requested = current_faults_requested; if (reset_list) { /********************************************/ /* get faults for list and setup for output */ /* starting from the end of list, process */ /* each node in the fault list for this */ /* group */ /********************************************/ p_next_out = p_end_out = fai_faults_for_output; for (p_node_in = fai_nvm_group_fault_list_ptrs[save_group_id].list_ptrs.p_list_end; p_node_in; p_node_in = p_node_in->p_previous) { p_end_out->fault_code = p_node_in->nvm_rec.fault_code.whole; p_end_out->num_of_occurrences = p_node_in->nvm_rec.num_of_occurrences; p_end_out->current_status = p_node_in->current_status; p_end_out++; } /* end for loop */ } /* end if */ while (save_current_faults_requested && (p_next_out != p_end_out) && p_next_out->current_status != FAULT_CURRENT) p_next_out++; if (p_next_out == p_end_out) return(NULL); else { p_next_out++; return(p_next_out-1); } /* end else */ } /* end fai_fault_output */ #pragma EJECT /***************************************************************/ /* Unit Name : fai_kill_fault_list */ /* Description : Should be called whenever an erase of a fault */ /* NOVRAM group is performed - this resets the */ /* corresponding fault list to empty */ /***************************************************************/ void fai_kill_fault_list (uchar group_id) { /*******************/ /* Local variables */ /*******************/ uchar index = 0; FAI_NOVRAM_GROUP_LIST_T *p_nvm_group; FAI_OUT_DATA_T xdata *p_output_list; /****************************************************/ /* reset fault codes to max counts and reset status */ /****************************************************/ memmove(fai_fault_counters,FAI_MAX_CONSEC_FAILURE, sizeof FAI_MAX_CONSEC_FAILURE); memset(fai_group_failure_status,0,FAI_NUM_OF_GROUPS*2); if (group_id == FAI_KILL_ALL_LISTS) { p_nvm_group =&fai_nvm_group_fault_list_ptrs; fai_order_of_occurrence = 0; fai_highest_order_novram_group = 0; group_id = NUM_OF_NOVRAM_GROUPS; index = 0; } /* end if */ else { p_nvm_group = &fai_nvm_group_fault_list_ptrs[group_id]; index = group_id; } /* end else */ do { /******************************************* reset fai_nvm_group_fault_list_ptrs *******************************************/ p_nvm_group->list_ptrs->p_list_start = p_nvm_group->list_ptrs->p_list_end = NULL; memset(&p_nvm_group->fault_list_mem_pool,0,sizeof p_nvm_group->fault_list_mem_pool); p_nvm_group->p_mem_pool = &p_nvm_group->fault_list_mem_pool; p_nvm_group->list_node_counter = 0; p_nvm_group->p_start_nvm_rec_pool=p_nvm_group->p_end_nvm_rec_pool = NULL; p_nvm_group++; } while (++index < group_id); } /* end fai_kill_fault_list */ #pragma EJECT /******************************************************************/ /* Unit Name : fai_reset_fault_counts */ /* Description : Resets fault counters to the maximum values */ /******************************************************************/ // void fai_reset_fault_counts () //{ // // // /******************************************************** // reset fault codes to max counts // *********************************************************/ // // // memmove(fai_fault_counters,FAI_MAX_CONSEC_FAILURE, // sizeof FAI_MAX_CONSEC_FAILURE); // //} #pragma EJECT /***********************************************************************/ /* Unit Name : fai_current_faults_out */ /* Description : This unit gets the fault to output for interprocessor */ /* communications */ /***********************************************************************/ FAI_FIFO_DATA_T xdata *fai_current_faults_out () { /*******************/ /* Local variables */ /*******************/ static FAI_FIFO_DATA_T return_data; if (p_fai_fifo_start != p_fai_fifo_end) { /************************/ /* fifo ok to read from */ /************************/ return_data = *p_fai_fifo_end; p_fai_fifo_end = ((p_fai_fifo_end +1) == &fai_fault_fifo[FAI_MAX_FIFO_SIZE])? fai_fault_fifo : p_fai_fifo_end+1; return(&return_data); } /* end if */ else return(NULL); } /* fai_current_faults_out */