leomseq_tbl.c
7.8 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
/*
* F i l e N a m e : l e o m s e q _ t b l . c
*
****************************************************************************
* (C) Copyright ALPS Electric Co., Ltd. 1995-1996
****************************************************************************
* Version:
*
* ver date
* ---- --------
* 1.05 '96-12-24 Delete SYSTEMWRITE and add #ifdef _LONGCMD for long command. Modefy leoSet_mseq().
* 1.04a '96-10-07 Enable bad-ecc write on tk6 if SYSTEMWRITE is defined.
* 1.04 '96-10-01 Delete OSPiHandle errStatus check .
* 1.03 '96-07-05 Add LEOPiDmaParam initialize for phase1 .
* 1.02 '96-02-27 Rename file name mseq_tbl.c to leomseq_tbl.c .
* 1.01 '95-12-20 Initial Revision.
****************************************************************************
*/
#include "os.h"
#include <ultra64.h>
#include "leodefine.h"
#include "leodrive.h"
#include "leomacro.h"
#ifdef _LONGCMD
#include "leoappli.h"
#include "leospappli.h"
#endif
/*************************************/
/* PROTOTYPE */
/*************************************/
void leoSet_mseq(u16 rwmode);
/*************************************/
/* EXTERNAL RAMS */
/*************************************/
extern u32 LEOasic_seq_ctl_shadow;
extern u8 LEORDGAP_TBL1[ZONES_PER_DRV];
extern u8 LEORDGAP_TBL2[ZONES_PER_DRV];
extern u8 LEOWRGAP_TBL1[ZONES_PER_DRV];
extern u8 LEOWRGAP_TBL2[ZONES_PER_DRV];
extern struct tgt_param_form LEOtgt_param;
extern OSMesgQueue LEOdma_que;
extern OSPiHandle *LEOPiInfo;
extern OSIoMesg LEOPiDmaParam;
extern volatile u16 LEOrw_flags;
#ifdef _LONGCMD
extern OSMesg LEOcur_command;
#define read_long_command ((LEOCmdReadLong *)LEOcur_command)
#endif
/***************************************/
/* Micro Sequencer Address */
/***************************************/
#define MSEQ_RD_GAP1_ADR 1
#define MSEQ_RD_DATA_ADR 4
#define MSEQ_RD_GAP2_ADR 7
#define MSEQ_WR_GAP1_ADR 1
#define MSEQ_WR_DATA_ADR 4
#define MSEQ_WR_GAP2_ADR 8
#define MSEQ_LEN 16
/*************************************/
/* RAM DEFINITIONS */
/*************************************/
static u32 mseq_tbl[MSEQ_LEN]; /* must be top of this file */
/********************************************/
/* SEQUENCER MAP */
/********************************************/
/* read */
static const u32 rd_mseq_code[MSEQ_LEN] = {
0x00010000, /* 00H WAIT */
0x00020200, /* 01H GAP */
0x80030100, /* 02H GAP */
0x82040000, /* 03H AM */
0xa8050000, /* 04H DATA */
0xa0060600, /* 05H C1 */
0x31760000, /* 06H SSP */
0x00020300, /* 07H GAP */
0x00000000, /* 08H NOT USE */
0x00000000, /* 09H NOT USE */
0x00000000, /* 0AH NOT USE */
0x00000000, /* 0BH NOT USE */
0x00000000, /* 0CH NOT USE */
0x00000000, /* 0DH NOT USE */
0x00000000, /* 0EH NOT USE */
0x04060000 }; /* 0FH NEXT */
/* write */
static const u32 wt_mseq_code[MSEQ_LEN] = {
0x40020000, /* 00H WAIT */
0x00020000, /* 01H GAP */
0x40130b00, /* 02H SYNC */
0x42140100, /* 03H AM */
0x68050000, /* 04H DATA */
0x50060600, /* 05H C1 */
0x401702ff, /* 06H PAD */
0x01870000, /* 07H SSP */
0x40020000, /* 08H GAP */
0x00000000, /* 09H NOT USE */
0x00000000, /* 0AH NOT USE */
0x00000000, /* 0BH NOT USE */
0x00000000, /* 0CH NOT USE */
0x00000000, /* 0DH NOT USE */
0x00000000, /* 0EH NOT USE */
0x040f0000 }; /* 0FH DONE */
#ifdef _LONGCMD
/* read long */
static const u32 rlong_mseq_code[MSEQ_LEN] = {
0x00010000, /* 00H */
0x00020200, /* 01H */
0x80030100, /* 02H */
0x82040000, /* 03H */
0x88060000, /* 04H */
0x80060600, /* 05H */
0x01764055, /* 06H */
0x00020300, /* 07H */
0x00000000, /* 08H */
0x00000000, /* 09H */
0x00000000, /* 0AH */
0x00000000, /* 0BH */
0x00000000, /* 0CH */
0x00000000, /* 0DH */
0x00000000, /* 0EH */
0x04060000 }; /* 0FH */
/* write long */
static const u32 wlong_mseq_code[MSEQ_LEN] = {
0x40020000, /* 00H */
0x00020000, /* 01H */
0x40130b00, /* 02H */
0x42140100, /* 03H */
0x48060000, /* 04H */
0x50060600, /* 05H */
0x401702ff, /* 06H */
0x01874054, /* 07H */
0x40020000, /* 08H */
0x00000000, /* 09H */
0x00000000, /* 0AH */
0x00000000, /* 0BH */
0x00000000, /* 0CH */
0x00000000, /* 0DH */
0x00000000, /* 0EH */
0x040f0000 }; /* 0FH */
#endif
/* ==========================================================================
* Function : leoSet_mseq
* --------------------------------------------------------------------------
* Description : WRITE SEQUENCER MAP TO DRIVE
* --------------------------------------------------------------------------
* IN : LEOtgt_param.zone
* OUT : non
* ARG : u16 rw_mode .. read/write
* RET : non
* ==========================================================================
*/
void leoSet_mseq(u16 rwmode)
{
u32 *tbl;
u32 sct_byte_x,sct_byte_u;
u8 i;
leoMicro_pc_disable(); /* SLEEP BM */
/* copy map */
#ifdef _LONGCMD
if (LEOrw_flags & LONG_RW)
{
if (rwmode == W_MODE)
tbl = (u32*)wlong_mseq_code;
else
tbl = (u32*)rlong_mseq_code;
}
else
#endif
{
if (rwmode == W_MODE)
tbl = (u32*)wt_mseq_code;
else
tbl = (u32*)rd_mseq_code;
}
for (i=0; i<MSEQ_LEN; i++)
{
mseq_tbl[i] = *tbl;
++tbl;
}
/* setup map */
#ifdef _LONGCMD
if (LEOrw_flags & FIXSIZE)
{
sct_byte_x = sct_byte_u = read_long_command->size - 1;
if (rwmode == W_MODE)
{
mseq_tbl[6] &= ~0x0000ff00;
mseq_tbl[6] |= ((u32)LEOtgt_param.sec_bytes - sct_byte_u + 1)<<8;
}
}
else
#endif
{
sct_byte_x = sct_byte_u = (u32)LEOtgt_param.sec_bytes - 1;
}
sct_byte_u += C1_LENGTH;
#ifdef _LONGCMD
if (LEOrw_flags & LONG_RW)
{
sct_byte_x = sct_byte_u;
if (LEOtgt_param.start_block)
{
if (rwmode == W_MODE)
mseq_tbl[7] += 90;
else
mseq_tbl[6] += 90;
}
}
#endif
sct_byte_x <<= 8;
mseq_tbl[4] |= sct_byte_x;
osWritebackDCache((void *)mseq_tbl, (s32)(MSEQ_LEN * sizeof(u32)));
/* write map to drive */
LEOPiDmaParam.dramAddr = (void*)mseq_tbl;
LEOPiDmaParam.devAddr = MSEQ_RAM_ADDR;
LEOPiDmaParam.size = (u32)(MSEQ_LEN * sizeof(u32));
LEOPiInfo->transferInfo.cmdType = OS_OTHERS; /* not disk_read, not disk-write, simple DMA */
leoAd16StartDma(OS_WRITE); /* start dma */
/* WAIT DMA DONE */
(void)osRecvMesg(DMA_QUE, NULL, OS_MESG_BLOCK);
/* SET SECTOR AND BYTE NUM */
leoAd16WriteIo(ASIC_SEC_BYTE, (u32)(HALF_SECS_U16 | sct_byte_u) << 16 );
/* SET BYTE NUM */
if (LEOrw_flags & LONG_RW)
sct_byte_x += 0x100;
leoAd16WriteIo(ASIC_HOST_SECBYTE, (sct_byte_x << 8));
leoMicro_pc_enable(); /* WAKEUP BM(NOT START) */
}