leord_diskid.c
3.77 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
/*
* F i l e N a m e : l e o r d _ d i s k i d . c
*
****************************************************************************
* (C) Copyright ALPS Electric Co., Ltd. 1995-1996
****************************************************************************
* Version
*
* ver Date
* ---- --------
* 1.00 '96-08-26 Initial revision .
****************************************************************************
*/
#include <ultra64.h>
#include "leodefine.h"
#include "leodrive.h"
#include "leomacro.h"
#include "leoappli.h"
/**************************************/
/* PROTOTYPE DEFINITIONS */
/**************************************/
void leoReadDiskId(void);
/**************************************/
/* EXTERNALY DEFINED FUNCTIONS */
/**************************************/
extern void leoRead_common(unsigned int);
/**************************************/
/* RAM LOCATIONS */
/**************************************/
/**************************************/
/* EXTERNALY DEFINED RAM LOCATIONS */
/**************************************/
extern OSMesg LEOcur_command;
extern u16 LEOrw_flags;
extern u8 LEO_TempBuffer[((SEC_SIZE_ZONE0 + 16)/16)*16];
/*************************************/
/* MACRO DEFINITIONS */
/*************************************/
#define readid_cmd ((LEOCmdReadDiskId *)LEOcur_command)
/**********************************************************
* Function : leoRead
* ---------------------------------------------------------
* Description : read
* IN : non
* OUT : non
**********************************************************/
const static LEOCmdRead read_id_cmd =
{ { LEO_COMMAND_READ, /* COMMAND */
0x00, /* RESERVE */
0x00, /* CONTROL */
0x00, /* RESERVE */
0x00, /* STATUS */
0x00, /* SENSE */
0x00, /* RESERVE */
0x00, /* RESERVE */
NULL /* POST QUEUE */
},
DISK_ID_LBA1, /* LBA */
0x01, /* BLOCKS */
(u64*)LEO_TempBuffer, /* BUFFER POINTER */
0x00 /* READ BYTES */
};
const static u8 leo_disk_id_lba[2] = {DISK_ID_LBA1,DISK_ID_LBA2};
void leoReadDiskId(void)
{
LEOCmdRead dummy_cmd;
u8 *temp_pointer;
u32 cntr;
/* back up current command */
temp_pointer = (u8*)LEOcur_command;
/* read ID data */
LEOcur_command = (OSMesg)&dummy_cmd;
cntr = 0;
do
{
LEOrw_flags = SECTOR_READ;
dummy_cmd = read_id_cmd;
dummy_cmd.lba = leo_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
leoRead_common(0);
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 */
LEOcur_command = (OSMesg)temp_pointer;
/* copy 32bytes ID data to buffer */
temp_pointer = (u8*)readid_cmd->buffer_pointer;
for (cntr = 0; cntr < 32; cntr += sizeof(int))
{
*(int*)temp_pointer = *((int*)&LEO_TempBuffer[cntr]);
temp_pointer += sizeof(int);
}
/* end of command */
readid_cmd->header.sense = dummy_cmd.header.sense;
readid_cmd->header.status = dummy_cmd.header.status;
}