readwritelong.c
1.43 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
#include <ultra64.h>
#ifndef _LONGCMD
#include <leo.h>
#else
#include <leosp.h>
#endif
extern s32 __leoActive;
s32 LeoReadWriteLong(LEOCmd *cmdBlock, s32 direction,
s32 LBA, void *vAddr, u32 nLBAs,
u32 secSize, OSMesgQueue *mq)
{
/*
* Check for existence of Leo Manager
*/
if (!__leoActive) {
return(-1);
}
/*
* Fill up command block
*/
if (direction == OS_READ)
cmdBlock->header.command = LEO_COMMAND_READ_LONG;
else
cmdBlock->header.command = LEO_COMMAND_WRITE_LONG;
cmdBlock->header.reserve1 = 0;
/*
* if mq == null, message will not be sent.
*/
if (mq != NULL)
cmdBlock->header.control = LEO_CONTROL_POST;
else
cmdBlock->header.control = 0;
cmdBlock->header.reserve3 = 0;
cmdBlock->header.post = mq;
cmdBlock->data.readwrite.lba = LBA;
cmdBlock->data.readwrite.xfer_blks = nLBAs;
cmdBlock->data.readwrite.buff_ptr = vAddr;
/*
* If secSize = 0, do long read (read the blocks and its
* C1 data(+8 bytes)), otherwise, read the specified
* size of each sector.
*/
if (secSize == 0)
cmdBlock->header.control |= LEO_CONTROL_LONG;
else
cmdBlock->data.readwrite.size = secSize;
/*
* If the read/write is to system blocks, enable
* "No Defect" flag.
*/
if (LBA < 0)
cmdBlock->header.control |= LEO_CONTROL_ND;
leoCommand((void *)cmdBlock);
return 0; /* For now, simply returns 0 */
} /* LeoSysReadWrite */