00001 /******************************************************************************* 00002 ** MessageQueue Manager 00003 ** 00004 ** Created April 12, 2007 00005 ** Jim Patchell 00006 ** 00007 *******************************************************************************/ 00008 00009 #ifndef MESSAGEQUEUE__H 00010 #define MESSAGEQUEUE__H 00011 00012 #include "task.h" 00013 00014 typedef struct _msg{ 00015 short int MsgCmd; //message command 00016 short int PayloadSize; //size of payload 00017 short int MaxPayload; //max size of payload 00018 short int ReplyCmd; //command to use to reply 00019 int Handle; //handle of port to send message out of... 00020 void *ReplyHandle; //handle of (pointer to Message queue) reply 00021 struct _msg *next; //used for message management 00022 char Payload[1]; //payload data...word...but can be any size 00023 }MSG; 00024 00025 typedef struct _msgqueue { 00026 ECB *Sem; //counting Semaphore 00027 int Head; //head pointer 00028 int Tail; //tail pointer 00029 int nMsg; //number of messages 00030 int Size; //maximum number of messages 00031 MSG **b; //message buffer 00032 }MESSAGE_QUEUE; 00033 00034 extern MESSAGE_QUEUE *MqInit(int size,char *name); 00035 extern void MqPut(MESSAGE_QUEUE *mq,MSG *m); 00036 extern MSG *MqGet(MESSAGE_QUEUE *mq); 00037 extern MSG *NewMSG(int payloadSize); 00038 extern void DeleteMSG(MSG *m); 00039 extern void InitMessageQueueManager(void); 00040 00041 extern int MsgAllocCount; 00042 00043 #endif