iplleord_diskid.c
3.99 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
/*
* F i l e N a m e : i p l l e o r d _ d i s k i d . c
*
****************************************************************************
* (C) Copyright ALPS Electric Co., Ltd. 1995-1996
****************************************************************************
* Version
*
* ver Date
* ---- --------
* 1.01 '96-11-22 Add _ERRCHK definition to be enable to return code in
* cdb for sense-code.
* 1.00 '96-08-26 Initial revision .
****************************************************************************
*/
#include <ultra64.h>
#include "leodefine.h"
#include "leodrive.h"
#include "iplleomacro.h"
#include "leoappli.h"
/**************************************/
/* PROTOTYPE DEFINITIONS */
/**************************************/
u8 leoiplReadDiskId(void);
/**************************************/
/* EXTERNALY DEFINED FUNCTIONS */
/**************************************/
extern void leoiplRead_zone0(void);
/**************************************/
/* RAM LOCATIONS */
/**************************************/
/**************************************/
/* EXTERNALY DEFINED RAM LOCATIONS */
/**************************************/
extern OSMesg LeoIPLcur_command;
extern u16 LeoIPLrw_flags;
extern u8 LeoIPL_c2temp[((SEC_SIZE_ZONE0 + 16)/16)*16];
extern union leo_sys_form LeoIPL_sys_data;
/*************************************/
/* MACRO DEFINITIONS */
/*************************************/
#define iplreadid_cmd ((LEOCmdReadDiskId *)LeoIPLcur_command)
/**********************************************************
* Function : leoiplReadDiskID
* ---------------------------------------------------------
* Description : read disk ID parameter .
* IN : non
* OUT : non
**********************************************************/
const static LEOCmdRead read_id_cmd =
{ { LEO_COMMAND_READ, /* COMMAND */
0x00, /* RESERVE1 */
0x00, /* CONTROL */
0x00, /* RESERVE3 */
0x00, /* STATUS */
0x00, /* SENSE */
0x00, /* RESERVE6 */
0x00, /* RESERVE7 */
NULL /* POST QUEUE */
},
DISK_ID_LBA1, /* LBA */
0x01, /* BLOCKS */
(u64*)LeoIPL_c2temp, /* BUFFER POINTER */
0x00 /* READ BYTES */
};
const static u8 iplleo_disk_id_lba[2] = {DISK_ID_LBA1,DISK_ID_LBA2};
u8 leoiplReadDiskId(void)
{
LEOCmdRead dummy_cmd;
u8 *temp_pointer;
u32 cntr;
/* back up current command */
temp_pointer = (u8*)LeoIPLcur_command;
/* read ID data */
LeoIPLcur_command = (OSMesg)&dummy_cmd;
cntr = 0;
LeoIPL_sys_data.param.defect_num[0] = 0;
do
{
LeoIPLrw_flags = SECTOR_READ;
dummy_cmd = read_id_cmd;
dummy_cmd.lba = iplleo_disk_id_lba[cntr];
#ifdef _ERRCHK
dummy_cmd.header.reserve1 = ((LEOCmdReadDiskId *)temp_pointer)->header.reserve1;
dummy_cmd.header.reserve3 = ((LEOCmdReadDiskId *)temp_pointer)->header.reserve3;
#endif
leoiplRead_zone0();
if (dummy_cmd.header.sense != LEO_SENSE_UNRECOVERED_READ_ERROR)
break;
} while (++cntr < 2);
#ifdef _ERRCHK
((LEOCmdReadDiskId *)temp_pointer)->header.reserve7 = dummy_cmd.header.reserve7;
#endif
/* restore current command */
LeoIPLcur_command = (OSMesg)temp_pointer;
/* copy 32bytes ID data to buffer */
temp_pointer = (u8*)iplreadid_cmd->buffer_pointer;
for (cntr = 0; cntr < 32; cntr += sizeof(int))
{
*(int*)temp_pointer = *((int*)&LeoIPL_c2temp[cntr]);
temp_pointer += sizeof(int);
}
/* end of command */
return (iplreadid_cmd->header.sense = dummy_cmd.header.sense );
}