os_message.h (5798B)
1 2 /*==================================================================== 3 * os_message.h 4 * 5 * Copyright 1995, Silicon Graphics, Inc. 6 * All Rights Reserved. 7 * 8 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 * Inc.; the contents of this file may not be disclosed to third 10 * parties, copied or duplicated in any form, in whole or in part, 11 * without the prior written permission of Silicon Graphics, Inc. 12 * 13 * RESTRICTED RIGHTS LEGEND: 14 * Use, duplication or disclosure by the Government is subject to 15 * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 * in Technical Data and Computer Software clause at DFARS 17 * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 * Copyright Laws of the United States. 20 *====================================================================*/ 21 22 /*---------------------------------------------------------------------* 23 Copyright (C) 1998 Nintendo. (Originated by SGI) 24 25 $RCSfile: os_message.h,v $ 26 $Revision: 1.1 $ 27 $Date: 1998/10/09 08:01:15 $ 28 *---------------------------------------------------------------------*/ 29 30 #ifndef _OS_MESSAGE_H_ 31 #define _OS_MESSAGE_H_ 32 33 #ifdef _LANGUAGE_C_PLUS_PLUS 34 extern "C" { 35 #endif 36 37 #include <PR/ultratypes.h> 38 #include <PR/os_thread.h> 39 40 #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 41 42 /************************************************************************** 43 * 44 * Type definitions 45 * 46 */ 47 48 typedef u32 OSEvent; 49 50 /* 51 * Structure for message 52 */ 53 typedef void * OSMesg; 54 55 /* 56 * Structure for message queue 57 */ 58 typedef struct OSMesgQueue_s { 59 OSThread *mtqueue; /* Queue to store threads blocked 60 on empty mailboxes (receive) */ 61 OSThread *fullqueue; /* Queue to store threads blocked 62 on full mailboxes (send) */ 63 s32 validCount; /* Contains number of valid message */ 64 s32 first; /* Points to first valid message */ 65 s32 msgCount; /* Contains total # of messages */ 66 OSMesg *msg; /* Points to message buffer array */ 67 } OSMesgQueue; 68 69 70 #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 71 72 /************************************************************************** 73 * 74 * Global definitions 75 * 76 */ 77 78 /* Events */ 79 80 #ifdef BBPLAYER 81 #define OS_NUM_EVENTS 31 82 #elif defined(_FINALROM) 83 #define OS_NUM_EVENTS 15 84 #else 85 #define OS_NUM_EVENTS 23 86 #endif 87 88 #define OS_EVENT_SW1 0 /* CPU SW1 interrupt */ 89 #define OS_EVENT_SW2 1 /* CPU SW2 interrupt */ 90 #define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */ 91 #define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */ 92 #define OS_EVENT_SP 4 /* SP task done interrupt */ 93 #define OS_EVENT_SI 5 /* SI (controller) interrupt */ 94 #define OS_EVENT_AI 6 /* AI interrupt */ 95 #define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */ 96 #define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */ 97 #define OS_EVENT_DP 9 /* DP full sync interrupt */ 98 #define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */ 99 #define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */ 100 #define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */ 101 #define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ 102 #define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ 103 #ifndef _FINALROM 104 #define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */ 105 #define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */ 106 #define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */ 107 #define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */ 108 #define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */ 109 #define OS_EVENT_RDB_DBG_DONE 20 110 #define OS_EVENT_RDB_FLUSH_PROF 21 111 #define OS_EVENT_RDB_ACK_PROF 22 112 #endif 113 #ifdef BBPLAYER 114 #define OS_EVENT_FLASH 23 /* NAND flash operation complete */ 115 #define OS_EVENT_AES 24 /* AES */ 116 #define OS_EVENT_IDE 25 /* IDE? */ 117 #define OS_EVENT_PI_ERR 26 /* PI Error? */ 118 #define OS_EVENT_USB0 27 /* USB Controller 0 */ 119 #define OS_EVENT_USB1 28 /* USB Controller 1 */ 120 #define OS_EVENT_UNK_29 29 /* TODO does this exist at all */ 121 #define OS_EVENT_MD 30 /* Related to card */ 122 #endif 123 124 /* Flags to turn blocking on/off when sending/receiving message */ 125 126 #define OS_MESG_NOBLOCK 0 127 #define OS_MESG_BLOCK 1 128 129 130 #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 131 132 /************************************************************************** 133 * 134 * Macro definitions 135 * 136 */ 137 138 /* Get count of valid messages in queue */ 139 #define MQ_GET_COUNT(mq) ((mq)->validCount) 140 141 /* Figure out if message queue is empty or full */ 142 #define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0) 143 #define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount) 144 145 146 /************************************************************************** 147 * 148 * Extern variables 149 * 150 */ 151 152 153 /************************************************************************** 154 * 155 * Function prototypes 156 * 157 */ 158 159 /* Message operations */ 160 161 extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32); 162 extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32); 163 extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32); 164 extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32); 165 166 /* Event operations */ 167 168 extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg); 169 170 171 #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 172 173 #ifdef _LANGUAGE_C_PLUS_PLUS 174 } 175 #endif 176 177 #endif /* !_OS_MESSAGE_H_ */