ulxdevcmd.c 14.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
/*
 *  F i l e N a m e  :  U L X D E V C M D . C
 *
 ****************************************************************************
 *                   (C) CopyRight ALPS Electric Co., Ltd. 1996
 ****************************************************************************
 *  Version
 *
 *  ver     Date
 *  ----  --------
 *  1.02  '96.08.26  Add Read ID command.
 *  1.01  '96.03.06  "TEST UNIT READY"コマンドのSS,REビットに対応
 *                   システム情報の画面表示機能を追加
 *  1.00  '95.12.20  Initial revision .
 ****************************************************************************
*/
/*===========================================*/
/* レオドライブ用テストソフトのコマンド発行ルーチン           */
/*===========================================*/

#include <ultra64.h>
#include "ulxmain.h"
#include "ulxlib.h"
#include "ulxutil.h"

#include "leodefine.h"
#include "leodrive.h"

extern union  leo_sys_form LEO_sys_data;
extern struct tgt_param_form LEOtgt_param;

u8   leoSend_asic_cmd_w(u32 asic_cmd, u32 asic_data);
void bufhandle( void ) ;


/*==========================================================*/

void clear_line(u16 ypos)
{
    ulxPrint0(0 , ypos, WHITE, "                                   ");
}

void dispsense(u32 sense)
{
    u16 xpos=2, ypos=13;

    clear_line(ypos);
    ulxPrint1(xpos, ypos, WHITE, "SENSE:%02d", sense);
}

void dispsts( void )
{
    u16 xpos=2, ypos=13;

    clear_line(ypos);
    ulxPrint2(xpos, ypos, WHITE,"STATUS:%02d  SENSE:%02d", Status, SCode);
}


void dispinquiry( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    sprintf( STR, "TYPE:%X VER:%X DEV:%X D_VER:%X", TAG02.dev_type, TAG02.version, TAG02.dev_num, TAG02.leo_bios_ver );
    ulxPrint0(xpos, ypos, WHITE, STR);
}


void disptestunit( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    ulxPrint3(xpos, ypos, WHITE, "SS:%X   RE:%X   MR:%X ",
                                    ((TAG03.test & LEO_TEST_UNIT_SS) >> 2),
                                    ((TAG03.test & LEO_TEST_UNIT_RE) >> 1),
                                     (TAG03.test & LEO_TEST_UNIT_MR)     );
}

void dispreadcmd( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    ulxPrint3(xpos,   ypos,  WHITE, "LBA:%04XH BLK:%02XH BYTES:%06XH",
                             TAG05.lba, TAG05.xfer_blks, TAG05.rw_bytes );
#ifdef _B084
    ulxPrint1(xpos+21,ypos-1,WHITE, "BYTE7:%02XH", TAG05.header.reserve7);
#endif
}

void dispwritecmd( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    ulxPrint3(xpos,   ypos,  WHITE, "LBA:%04XH BLK:%02XH BYTES:%06XH",
                             TAG06.lba, TAG06.xfer_blks, TAG06.rw_bytes );
#ifdef _B084
    ulxPrint1(xpos+21,ypos-1,WHITE, "BYTE7:%02XH", TAG06.header.reserve7);
#endif
}

void dispseekcmd( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    ulxPrint3(xpos, ypos, WHITE, "LBA:%04XH = CYL:%04XH HD:%02XH",
                          TAG07.lba, LEOtgt_param.cylinder, LEOtgt_param.head );
}

void disprdcapacity( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    ulxPrint3(xpos, ypos, WHITE, "START:%04XH END:%04XH BYTE:%07XH",
                          TAG09.start_lba, TAG09.end_lba, TAG09.capa_bytes );
}

void disptranslate( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    ulxPrint3(xpos, ypos, WHITE, "LBA:%04XH IN:%07XH OUT:%07XH",
                          TAG0A.start_lba, TAG0A.in_param, TAG0A.out_param );
}

void dispreaddiskid( void )
{
    u16 xpos=0, ypos=14;

    clear_line(ypos);
    sprintf( STR, "'%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
                                  RDB[ 0],RDB[ 1],RDB[ 2],RDB[ 3],RDB[ 4],RDB[ 5],RDB[ 6],RDB[ 7],
                                  RDB[ 8],RDB[ 9],RDB[10],RDB[11],RDB[12],RDB[13],RDB[14],RDB[15],
                                  RDB[16],RDB[17],RDB[18],RDB[19],RDB[20],RDB[21],RDB[22],RDB[23],
                                  RDB[24],RDB[25],RDB[26],RDB[27],RDB[28],RDB[29],RDB[30],RDB[31] );
    ulxPrint0(xpos, ypos, WHITE, STR);
    ulxPrint0(xpos+33, ypos, WHITE, "'");
}

void dispreadtimer( void )
{
    u16 xpos=2, ypos=14;

    clear_line(ypos);
    sprintf( STR, "Timer: %02XH-%02XH-%02XH %02XH:%02XH:%02XH",
                   TAG0D.year, TAG0D.month , TAG0D.day,
                   TAG0D.hour, TAG0D.minute, TAG0D.second );
    ulxPrint0(xpos, ypos, WHITE, STR);
}

void disp_leosys_data( void )
{
    u8 i;

    ClrDisp();
    ulxPrint0( 0, 0, GREEN, "COUNTRY : ");
    ulxPrint0( 0, 1, GREEN, "IPL BLK : ");
    ulxPrint0(19, 0, GREEN, "FMT. TYPE : ");
    ulxPrint0(19, 1, GREEN, "DISK TYPE : ");
    ulxPrint0( 0, 2, GREEN, "ZONE DEFECT: ");
    ulxPrint0( 0, 4, GREEN, "DEFECT DATA: ");

    ulxPrint1(10, 0, WHITE, "%08X", LEO_sys_data.param.country);
    ulxPrint1(10, 1, WHITE, "%04X", LEO_sys_data.param.ipl_load_len);
    ulxPrint1(31, 0, WHITE, "%02X", LEO_sys_data.param.fmt_type);
    ulxPrint1(31, 1, WHITE, "%02X", LEO_sys_data.param.disk_type);

    sprintf( STR, "%01X %01X %01X %01X %01X %01X %01X %01X   ",
                   (u8)(LEO_sys_data.param.defect_num[0]),
                   (u8)(LEO_sys_data.param.defect_num[1] - LEO_sys_data.param.defect_num[0]),
                   (u8)(LEO_sys_data.param.defect_num[2] - LEO_sys_data.param.defect_num[1]),
                   (u8)(LEO_sys_data.param.defect_num[3] - LEO_sys_data.param.defect_num[2]),
                   (u8)(LEO_sys_data.param.defect_num[4] - LEO_sys_data.param.defect_num[3]),
                   (u8)(LEO_sys_data.param.defect_num[5] - LEO_sys_data.param.defect_num[4]),
                   (u8)(LEO_sys_data.param.defect_num[6] - LEO_sys_data.param.defect_num[5]),
                   (u8)(LEO_sys_data.param.defect_num[7] - LEO_sys_data.param.defect_num[6]) );
    ulxPrint0(13, 2, WHITE, STR);

    sprintf( STR, "  %01X %01X %01X %01X %01X %01X %01X %01X ",(u8)(LEO_sys_data.param.defect_num[ 8] - LEO_sys_data.param.defect_num[ 7]),
                   (u8)(LEO_sys_data.param.defect_num[ 9] - LEO_sys_data.param.defect_num[ 8]),
                   (u8)(LEO_sys_data.param.defect_num[10] - LEO_sys_data.param.defect_num[ 9]),
                   (u8)(LEO_sys_data.param.defect_num[11] - LEO_sys_data.param.defect_num[10]),
                   (u8)(LEO_sys_data.param.defect_num[12] - LEO_sys_data.param.defect_num[11]),
                   (u8)(LEO_sys_data.param.defect_num[13] - LEO_sys_data.param.defect_num[12]),
                   (u8)(LEO_sys_data.param.defect_num[14] - LEO_sys_data.param.defect_num[13]),
                   (u8)(LEO_sys_data.param.defect_num[15] - LEO_sys_data.param.defect_num[14]) );
    ulxPrint0(13, 3, WHITE, STR);

    for (i=0; i<12; i++)
    {
        sprintf( STR, " %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
                   LEO_sys_data.param.defect_data[i*16+ 0],LEO_sys_data.param.defect_data[i*16+ 1],
                   LEO_sys_data.param.defect_data[i*16+ 2],LEO_sys_data.param.defect_data[i*16+ 3],
                   LEO_sys_data.param.defect_data[i*16+ 4],LEO_sys_data.param.defect_data[i*16+ 5],
                   LEO_sys_data.param.defect_data[i*16+ 6],LEO_sys_data.param.defect_data[i*16+ 7],
                   LEO_sys_data.param.defect_data[i*16+ 8],LEO_sys_data.param.defect_data[i*16+ 9],
                   LEO_sys_data.param.defect_data[i*16+10],LEO_sys_data.param.defect_data[i*16+11],
                   LEO_sys_data.param.defect_data[i*16+12],LEO_sys_data.param.defect_data[i*16+13],
                   LEO_sys_data.param.defect_data[i*16+14],LEO_sys_data.param.defect_data[i*16+15] );
        ulxPrint0(0, 5+i, WHITE, STR);
    }
    GetChr();
}


#define col_l 11
#define col_r 10

void    commandtest( void )
{
    u8  invalid_opcode = 0;
    u16 num=1, xpos=2 ,ypos=13 ,clr=YELLOW ;
    u16 x_l= 2, y_l=1;
    u16 x_r=18, y_r=1;
    u8  *left_d[col_l+col_r] = {
                        "CLEAR QUE      ",
                        "INQUIRY        ",
                        "TEST UNIT READY",
                        "REZERO UNIT    ",
                        "READ           ",
                        "WRITE          ",
                        "SEEK           ",
                        "START/STOP     ",
                        "READ CAPACITY  ",
                        "TRANSLATE      ",
                        "MODE SELECT    ",
                        "READ DISK ID   ",
                        "READ TIMER     ",
                        "SET  TIMER     ",
                        "LeoResetClear()",
                        "leoSetReset()  ",
                        "               ",
                        "Set control bits",
                        "DISP SYS. DATA ",
                        "BUFFER HANDLE  ",
                        "EXIT           "
                      };
static u8  stbyflg, stby, sleep, sta, wrt, tbl;
static u8  thex, tyear, tmonth, tdate, thour, tminute, tsecond;
static u8  on_time, off_time;
static u32 slba, elba, blk, inb;
static u32 longbit, sctsize;

    tmonth = tdate           = 0x01;
    tyear  = thour = tminute = 0x00;
    slba   = blk   = (u32)0x00;
    inb    = (u32)0x01;

    do
    {
        ClrDisp();
        ulxPrint0(0, 0, CYAN, "COMMAND TEST MENU " );

        ListDisp( x_l, y_l, col_l, left_d, x_r, y_r, col_r, &left_d[col_l], GREEN );
        num = SelStr2( x_l, y_l, col_l, left_d, x_r, y_r, col_r, &left_d[col_l], num, GREEN );

        if (num == ESC) return;

        switch( num )
        {
            case 1:
                ClearQue() ;
                dispsts();
                break;

            case 2:
                Inquiry() ;
                dispsts();
                dispinquiry();
                break;

            case 3:
                TestUnit() ;
                dispsts();
                disptestunit();
                break;

            case 4:
                RezeroUnit() ;
                dispsts();
                break;

            case 5:
                slba = GetNum32( slba , "Input LBA      ", xpos, ypos, clr );
                Disp_Ready(2, 14, WHITE);
                sprintf( STR, "Software Limit = 20H[BLK]" );
                Disp_Fin();

                blk  = GetNum32( blk  , "Input BLOCK    ", xpos, ypos, clr );
                if (blk > 0x20)
                    blk = 0x20;

                ReadDrive( slba, blk, RDB );
                dispsts();
                dispreadcmd();
                break;

            case 6:
                slba = GetNum32( slba , "Input LBA      ", xpos, ypos, clr );
                Disp_Ready(2, 14, WHITE);
                sprintf( STR, "Software Limit = 20H[BLK]" );
                Disp_Fin();

                blk  = GetNum32( blk  , "Input BLOCK    ", xpos, ypos, clr );
                if (blk > 0x20)
                    blk = 0x20;

                WriteDrive( slba, blk, WDB ) ;
                dispsts();
                dispwritecmd();
                break;

            case 7:
                slba = GetNum32( slba , "Input LBA      ", xpos, ypos, clr );
                SeekDrive( slba ) ;
                dispsts();
                dispseekcmd();
                break;

            case 8:
                stbyflg = GetNumFlg( stbyflg, "Input STBY     ", xpos, ypos, clr ); 
                sta     = GetNumFlg( sta    , "Input STA      ", xpos, ypos, clr ) ; 
                StartStop( stbyflg, sta ) ;
                dispsts();
                break;

            case 9:
                wrt  = GetNumFlg( wrt , "Input WRT      ", xpos, ypos, clr ); 
                ReadCapa( wrt, slba, elba ) ;
                dispsts();
                disprdcapacity();
                break;

            case 10:
                tbl  = GetNumFlg( tbl , "Input TBL       ", xpos, ypos, clr ); 
                slba = GetNum32( slba , "Input START LBA ", xpos, ypos, clr );
                if (tbl)
                    inb = GetNum32( inb,"Input BYTES.    ", xpos, ypos, clr );
                else
                    inb = GetNum32( inb,"Input BLOCKS.   ", xpos, ypos, clr );
                Translate( tbl, slba, inb ) ;
                dispsts();
                disptranslate();
                break;

            case 11:
                stby     = GetNum8A( stby    , "Input STANDBY TIMER ", xpos, ypos, clr );
                sleep    = GetNum8A( sleep   , "Input SLEEP   TIMER ", xpos, ypos, clr );
                on_time  = GetNum8A( on_time , "Input LED-ON  TIME  ", xpos, ypos, clr );
                off_time = GetNum8A( off_time, "Input LED-OFF TIME  ", xpos, ypos, clr );
                ModeSelect( stby, sleep, on_time, off_time ) ;
                dispsts();
                break;

            case 12:
                ReadDiskID( RDB );
                dispsts();
                dispreaddiskid();
                break;

            case 13:
                /*thex     = GetNumFlg(thex    , "HEX mode ? (yes=1) ", xpos, ypos, clr ); */
                ReadTimer(thex);
                dispsts();
                dispreadtimer();
                break;

            case 14:
                tyear    = GetNum8A( tyear   , "Input TIMER YEAR   ", xpos, ypos, clr );
                tmonth   = GetNum8A( tmonth  , "Input TIMER MONTH  ", xpos, ypos, clr );
                tdate    = GetNum8A( tdate   , "Input TIMER DAY    ", xpos, ypos, clr );
                thour    = GetNum8A( thour   , "Input TIMER HOUR   ", xpos, ypos, clr );
                tminute  = GetNum8A( tminute , "Input TIMER MINUTE ", xpos, ypos, clr );
                tsecond  = GetNum8A( tsecond , "Input TIMER SECOND ", xpos, ypos, clr );
                SetTimer(tyear, tmonth, tdate, thour, tminute, tsecond, thex);
                dispsts();
                break;

            case 15:
                dispsense(ClrUAReset());
                break;

            case 16:
                Resetleo();
                break;

            case 17:
                break;

            case 18:
                /* set control bits */
                Post     = GetNumFlg( Post     , "Input POST bit     ", xpos, ypos, clr ); 
                Verify   = GetNumFlg( Verify   , "Input VERIFY bit   ", xpos, ypos, clr ); 
                break;

            case 19:
                disp_leosys_data();
                break;

            case 20:
                bufhandle();
                break;

            case 21:
                /* exit */
                return;

            default:
                break;
        }
        if (num < 16)
            GetChr();

    } while( num != ESC );
}