leoreset.c 3.4 KB
/*
 *  F i l e N a m e : l e o r e s e t . c
 *
 ****************************************************************************
 *                   (C) Copyright ALPS Electric Co., Ltd. 1995-1996
 ****************************************************************************
 * Version
 *
 *  ver     date
 *  ----  --------
 *  1.05  '97-02-20   Add leoClr_reset();
 *  1.04  '96-11-05   Add post que handling in leoClr_queue().
 *  1.03  '96-09-18   Delete leoInit_thread(void);
 *  1.02  '96-09-17   Change leoReset() is dummy function .
 *  1.01  '96-02-27   Rename file name reset.c to leoreset.c .
 *  1.00  '95-12-20   Initial Revision.
 ****************************************************************************
*/
#include "os.h"

#include <ultra64.h>
#include "leodefine.h"
#include "leoappli.h"

/******************************/
/* PROTOTYPE                  */
/******************************/
void leoClr_queue(void);
void leoClr_reset(void);

/*************************************/
/* EXTERNALY DEFINED FUNCTIONS       */
/*************************************/
extern void  leoClrUA_RESET(void);
extern u32   leoRetUnit_atten(void);
extern u8    leoAnalize_asic_status(void);

/*************************************/
/* EXTERNAL RAMS                     */
/*************************************/
extern  OSMesgQueue LEOcommand_que;
extern  OSMesg LEOcur_command;

/* =========================================================================
* Function : leoClear_queue
* --------------------------------------------------------------------------
* Description : CLEAR COMMAND QUE
* --------------------------------------------------------------------------
* IN     : qued command
* OUT    : qued command
* ARG    : non
* RET    : non
* ==========================================================================
*/
void leoClr_queue(void)
{
    OSMesg clr_cmd;

    while (!osRecvMesg(COMMAND_QUE, &clr_cmd, OS_MESG_NOBLOCK))
    {
        ((LEOCmdHeader *)clr_cmd)->sense  = LEO_SENSE_COMMAND_TERMINATED;
        ((LEOCmdHeader *)clr_cmd)->status = LEO_STATUS_CHECK_CONDITION;
        if (((LEOCmdHeader *)clr_cmd)->control & LEO_CONTROL_POST)
        {
            /* send post message */
            osSendMesg(((LEOCmdHeader *)clr_cmd)->post,
                                (OSMesg)LEO_SENSE_COMMAND_TERMINATED, OS_MESG_BLOCK);
        }
    }
}
/* =========================================================================
* Function : leoClear_reset
* --------------------------------------------------------------------------
* Description : Clear UA reset condition.
* --------------------------------------------------------------------------
* IN     : qued command
* OUT    : qued command
* ARG    : non
* RET    : non
* ==========================================================================
*/
void leoClr_reset(void)
{
    u32 code;

    code = leoAnalize_asic_status();
    switch (code)
    {
        case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED:
        case LEO_SENSE_COMMAND_PHASE_ERROR:
        case LEO_SENSE_DEVICE_COMMUNICATION_FAILURE:
            ((LEOCmdHeader *)LEOcur_command)->sense  = code;
            ((LEOCmdHeader *)LEOcur_command)->status = LEO_STATUS_CHECK_CONDITION;
            break;
        default:
            ((LEOCmdHeader *)LEOcur_command)->sense  = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION;
            ((LEOCmdHeader *)LEOcur_command)->status = LEO_STATUS_GOOD;
    }
}

/*--------------end of file-------------*/