iplleoread.c 3.68 KB
/*
 *  F i l e N a m e  :  i p l l e o r e a d . c
 *
 ****************************************************************************
 *                   (C) Copyright ALPS Electric Co., Ltd. 1995-1996
 ****************************************************************************
 *  Version
 *
 *  ver     Date
 *  ----  --------
 *  1.06  '96-07-25  Move track/retry operation to iplleoint.c .Add c2-control message.
 *  1.05  '96-05-22  Debug set sensecode in leoChk_disk_err() .
 *  1.04  '96-05-08  Change SC_NO_REFERENCE_POSITION retry .
 *  1.03  '96-04-11  Move retry judgment location .
 *  1.02  '96-02-27  Rename iplread.c to iplleoread.c .
 *  1.01  '96-02-03  Debug.
 *  1.00  '95-12-20  Initial revision .
 ****************************************************************************
*/
#include <ultra64.h>
#include "leodefine.h"
#include "leodrive.h"
#include "iplleomacro.h"
#include "leoappli.h"

/**************************************/
/* PROTOTYPE DEFINITIONS              */
/**************************************/
void leoiplRead_zone0(void);

/**************************************/
/* EXTERNALY DEFINED FUNCTIONS        */
/**************************************/
extern u16  leoiplLba_to_phys(u32 lba);
extern void leoiplSet_mseq(void);
extern int  leoiplC2_Correction(void);

/**************************************/
/* RAM LOCATIONS                      */
/**************************************/

/**************************************/
/* EXTERNALY DEFINED RAM LOCATIONS    */
/**************************************/
extern OSThread    LeoIPLinterruptThread;
extern OSMesg      LeoIPLcur_command;
extern OSMesgQueue LeoIPLcontrol_que;
extern OSMesgQueue LeoIPLc2ctrl_que;

extern struct block_param_form LeoIPLc2_param;
extern struct tgt_param_form   LeoIPLtgt_param;
extern volatile u16 LeoIPLrw_flags;

/*************************************/
/*  MACRO DEFINITIONS                */
/*************************************/
#define    read_command    ((LEOCmdRead *)LeoIPLcur_command)

/**********************************************************
* Function : leoiplRead_common
* ---------------------------------------------------------
* Description : read for zone-0 only
* IN  : LeoIPLcur_command .. command description block pointer
* OUT : *LeoIPLcur_command
* : non
**********************************************************/
void leoiplRead_zone0(void)
{
    u32    tg_lba;
    u32    tg_blocks;
    u32    message;

    tg_lba    = read_command->lba;
    tg_blocks = read_command->xfer_blks;

    LeoIPLtgt_param.lba = tg_lba;
    LeoIPLrw_flags &= ~(LOCK_C2_PARAM+WRITE_MODE); /* clear C2 flag */

    osSendMesg(IPLC2_CTRL_QUE, MES_NONE, OS_MESG_NOBLOCK);

    osStartThread(&LeoIPLinterruptThread);

    for (;;)                 /* track read loop */
    {
        /* wait block read done */
        (void)osRecvMesg(IPLCONTROL_QUE, (OSMesg*)&message, OS_MESG_BLOCK);
        switch (message)
        {
            case (u32)MES_RW_COMPLETE:
                    goto read_complete;
            case (u32)MES_REQ_C2_CORR:
                leoiplC2_Correction();
                LeoIPLrw_flags &= ~LOCK_C2_PARAM;    /* clear flags to indicate new c2_param acceptable */
                osSendMesg(IPLC2_CTRL_QUE, MES_NONE, OS_MESG_NOBLOCK);
                continue;
            default:
                /* error */
                read_command->header.sense  = message;
                read_command->header.status = LEO_STATUS_CHECK_CONDITION;
                return;                             /* stop command */
        }
    }
    /*
    * all block read complete
    */
read_complete:
    read_command->header.sense  = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION;
    read_command->header.status = LEO_STATUS_GOOD;
}