1/*====================================================================2* os_message.h3*4* Copyright 1995, Silicon Graphics, Inc.5* All Rights Reserved.6*7* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,8* Inc.; the contents of this file may not be disclosed to third9* parties, copied or duplicated in any form, in whole or in part,10* without the prior written permission of Silicon Graphics, Inc.11*12* RESTRICTED RIGHTS LEGEND:13* Use, duplication or disclosure by the Government is subject to14* restrictions as set forth in subdivision (c)(1)(ii) of the Rights15* in Technical Data and Computer Software clause at DFARS16* 252.227-7013, and/or in similar or successor clauses in the FAR,17* DOD or NASA FAR Supplement. Unpublished - rights reserved under the18* Copyright Laws of the United States.19*====================================================================*/2021/*---------------------------------------------------------------------*22Copyright (C) 1998 Nintendo. (Originated by SGI)2324$RCSfile: os_message.h,v $25$Revision: 1.1 $26$Date: 1998/10/09 08:01:15 $27*---------------------------------------------------------------------*/2829#ifndef _OS_MESSAGE_H_30#define _OS_MESSAGE_H_3132#ifdef _LANGUAGE_C_PLUS_PLUS33extern "C" {34#endif3536#include <PR/ultratypes.h>37#include <PR/os_thread.h>3839#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)4041/**************************************************************************42*43* Type definitions44*45*/4647typedef u32 OSEvent;4849/*50* Structure for message51*/52typedef void * OSMesg;5354/*55* Structure for message queue56*/57typedef struct OSMesgQueue_s {58OSThread *mtqueue; /* Queue to store threads blocked59on empty mailboxes (receive) */60OSThread *fullqueue; /* Queue to store threads blocked61on full mailboxes (send) */62s32 validCount; /* Contains number of valid message */63s32 first; /* Points to first valid message */64s32 msgCount; /* Contains total # of messages */65OSMesg *msg; /* Points to message buffer array */66} OSMesgQueue;676869#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */7071/**************************************************************************72*73* Global definitions74*75*/7677/* Events */78#ifdef _FINALROM79#define OS_NUM_EVENTS 1580#else81#define OS_NUM_EVENTS 2382#endif8384#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */85#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */86#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */87#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */88#define OS_EVENT_SP 4 /* SP task done interrupt */89#define OS_EVENT_SI 5 /* SI (controller) interrupt */90#define OS_EVENT_AI 6 /* AI interrupt */91#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */92#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */93#define OS_EVENT_DP 9 /* DP full sync interrupt */94#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */95#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */96#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */97#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */98#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */99#ifndef _FINALROM100#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */101#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */102#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */103#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */104#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */105#define OS_EVENT_RDB_DBG_DONE 20106#define OS_EVENT_RDB_FLUSH_PROF 21107#define OS_EVENT_RDB_ACK_PROF 22108#endif109110/* Flags to turn blocking on/off when sending/receiving message */111112#define OS_MESG_NOBLOCK 0113#define OS_MESG_BLOCK 1114115116#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)117118/**************************************************************************119*120* Macro definitions121*122*/123124/* Get count of valid messages in queue */125#define MQ_GET_COUNT(mq) ((mq)->validCount)126127/* Figure out if message queue is empty or full */128#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0)129#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount)130131132/**************************************************************************133*134* Extern variables135*136*/137138139/**************************************************************************140*141* Function prototypes142*143*/144145/* Message operations */146147extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32);148extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32);149extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32);150extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32);151152/* Event operations */153154extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg);155156157#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */158159#ifdef _LANGUAGE_C_PLUS_PLUS160}161#endif162163#endif /* !_OS_MESSAGE_H_ */164165166