piacs.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
90
91
92
93
94
95
96
97
98
99
100
101
/**************************************************************************
* *
* 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. *
* *
**************************************************************************/
/**************************************************************************
*
* Module: iopiacs.c
*
* $Revision: 1.1.1.2 $
* $Date: 2002/10/29 08:06:43 $
* $Author: blythe $
* $Source: /root/leakn64/depot/rf/sw/bbplayer/libultra/nintendo/pi/piacs.c,v $
*
* Description:
* This file contains routines to get access to the PI device.
*
**************************************************************************/
#include "osint.h"
#include "rcp.h"
#define NUM_ACCESS_MESG 1
/* Access queue used for mutual exclusion on PI */
static OSMesg piAccessBuf[NUM_ACCESS_MESG];
int __osPiAccessQueueEnabled = 0;
OSMesgQueue __osPiAccessQueue;
/*
* Name: __osPiCreateAccessQueue
*
* Description:
*
*
* Globals Referenced:
* None
*/
void
__osPiCreateAccessQueue(void)
{
__osPiAccessQueueEnabled = 1;
osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, NUM_ACCESS_MESG);
/* Initialize the access queue with a resource token */
(void)osSendMesg(&__osPiAccessQueue, (OSMesg)0, OS_MESG_NOBLOCK);
}
/*
* Name: __osPiGetAccess
*
* Description:
* Get the access right to PI by blocking on the access queue.
*
* Globals Referenced:
* __osPiAccessQueue
*/
void
__osPiGetAccess(void)
{
OSMesg dummyMesg;
/* Create access message queue if haven't done so */
if (!__osPiAccessQueueEnabled) {
__osPiCreateAccessQueue();
}
(void)osRecvMesg(&__osPiAccessQueue, &dummyMesg, OS_MESG_BLOCK);
}
/*
* Name: __osPiRelAccess
*
* Description:
* Release the access right to PI by sending a mesg to the access queue.
*
* Globals Referenced:
* __osPiAccessQueue
*/
void
__osPiRelAccess(void)
{
(void)osSendMesg(&__osPiAccessQueue, (OSMesg)0, OS_MESG_NOBLOCK);
}