leorezero.c 3.18 KB
/*
 *  F i l e N a m e  : l e o r e z e r o .c
 *
 ****************************************************************************
 *                   (C) Copyright ALPS Electric Co., Ltd. 1995-1996
 ****************************************************************************
 *   Version:
 *
 *  ver       date
 *  ----   ---------
 *  1.05   '97-01-10  Move retry definition to leodrive.h .
 *  1.04   '96-10-30  Change rezero operation call leoRecal_w() function.
 *  1.03   '96-10-25  Change rezero command retry count (16 -> 8) .
 *  1.02   '96-07-25  Delete leoClear_mecha_int() macro.
 *  1.01   '96-02-27  Rename file name rezero.c to leorezero.c
 *  1.00   '95-12-20  Initial Revision.
 ****************************************************************************
*/
#include <ultra64.h>
#include "leodefine.h"
#include "leodrive.h"
#include "leomacro.h"
#include "leoappli.h"

/*************************************/
/* PROTOTYPE                         */
/*************************************/
void leoRezero(void);

/*************************************/
/* EXTERNALY FUNCTIONS               */
/*************************************/

/*************************************/
/* EXTERNALY RAMS                    */
/*************************************/
extern OSMesg      LEOcur_command;
extern struct tgt_param_form LEOtgt_param;

/*************************************/
/*  MACRO                            */
/*************************************/
#define rezero_cmd  ((LEOCmdRezero *)LEOcur_command)

/*==========================================================================
* Function : leoRezero
* --------------------------------------------------------------------------
* Description : EXECUTE REZERO COMMAND
* --------------------------------------------------------------------------
* IN      : LEOcur_command
* OUT     : *LEOcur_command, tgt_param.cylinder, tgt_param.head, tgt_param.zone
* ARG     : NON
* RET     : NON
* ==========================================================================
*/
void leoRezero(void)
{
    u8 sense_code;
    u8 retry_cntr;

    retry_cntr = MAX_REZERO_RETRY;

    do
    {
        if (!(sense_code = leoRecal_w()) )
        {
            LEOtgt_param.cylinder = (u16)0x00;
            LEOtgt_param.head     = (u8 )0x00;
            LEOtgt_param.zone     = (u8 )0x00;
#ifdef _ERRCHK
            sense_code = rezero_cmd->header.reserve1;
            if (((MAX_REZERO_RETRY - retry_cntr) >= rezero_cmd->header.reserve3 ) &&
                (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) )
            {
                rezero_cmd->header.reserve7 = (MAX_REZERO_RETRY - retry_cntr);
                rezero_cmd->header.sense    = sense_code;
                rezero_cmd->header.status   = LEO_STATUS_GOOD;
                return;
            }
#else
            rezero_cmd->header.status = LEO_STATUS_GOOD;
            return;
#endif
        }
        /* RETRY ? */
        if (leoChk_err_retry(sense_code))
            break;
    } while (retry_cntr--);

    /* ERROR */
#ifdef _ERRCHK
    rezero_cmd->header.reserve7 = (MAX_REZERO_RETRY - retry_cntr);
#endif
    rezero_cmd->header.sense  = sense_code;
    rezero_cmd->header.status = LEO_STATUS_CHECK_CONDITION;
    return;
}