contreset.c
2.52 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
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#include "osint.h"
#include "controller.h"
#include "siint.h"
/*
* This call issues a reset command to controllers to return joystick
* back to neutral position.
* A value of 0 is returned if the calls succeed, otherwise
* -1 is returned
*/
s32
osContReset(OSMesgQueue *mq, OSContStatus *data)
{
u8 pattern;
s32 ret;
/* Block to get resource token */
__osSiGetAccess();
if (CONT_RESET != __osContLastCmd) {
/* Set up request command format for all channels */
#if !defined(_HW_VERSION_1) && !defined(BBPLAYER)
__osPackResetData();
ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam);
(void)osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
(void)osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
#endif
__osPackRequestData(CONT_RESET);
ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam);
(void)osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
/*
* Always make the last command an illegal one, so we never optimize
* out the DMA write
*/
__osContLastCmd = CONT_SETCH - 1;
}
/* trigger pifmacro */
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
(void)osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
/* reformat the 64 bytes RAM data and save in data array */
__osContGetInitData(&pattern, data);
/* Return resource token */
__osSiRelAccess();
return(ret);
}
#ifndef _HW_VERSION_1
void
__osPackResetData(void)
{
u8 *ptr;
int i;
/* set format flag */
__osContPifRam.pifstatus = CONT_FORMAT;
ptr = (u8 *)(&__osContPifRam);
/* Setup reset format for each channel */
for (i = 0; i < MAXCONTROLLERS; i++) {
*ptr++ = CHANNEL_RESET;
}
*((u8 *)ptr) = FORMAT_END;
}
#endif