home *** CD-ROM | disk | FTP | other *** search
- /* Msg3 and Msg3PPC.elf
- *
- * This test program sends 1000 messages to the PPC and
- * shows how long this takes.
- * The Messages are send synchron and every msg must
- * be replied after another.
- * Each Message has the Body "Text sent by M68k processor\n"
- */
-
- #include <exec/types.h>
- #include <exec/nodes.h>
- #include <exec/lists.h>
- #include <exec/memory.h>
- #include <utility/tagitem.h>
- #include <powerup/ppclib/interface.h>
- #include <powerup/ppclib/message.h>
- #include <powerup/ppclib/tasks.h>
- #include <powerup/gcclib/powerup_protos.h>
-
- #define DEBUG 0
-
- #if DEBUG
- #define D(x) x;
- #else
- #define D(x) ;
- #endif
-
- #define text "Text sent by PPC processor\n"
-
- struct StartupData
- {
- ULONG MsgCount;
- };
-
- BPTR MyFile;
-
- int main(void)
- {
- struct TagItem MyTags[10];
- struct StartupData *StartupData;
- void *PPCPort;
- void *ReplyPort;
- void *M68kMsg;
- void *Body;
- ULONG result;
- ULONG MsgCount;
- ULONG i;
-
- StartupData =(struct StartupData *) PPCGetTaskAttr(PPCTASKTAG_STARTUP_MSGDATA);
-
- MsgCount = StartupData->MsgCount;
-
- #if DEBUG
- if (MyFile = PPCOpen("con:0/0/640/200/MessageDemo - PPC output/CLOSE", MODE_NEWFILE))
- {
- #endif
-
- if (PPCPort=(void*) PPCGetTaskAttr(PPCTASKTAG_MSGPORT))
- {
- D(PPCfprintf(MyFile,"Waiting for M68k message\n"));
-
- for (i=0;i<MsgCount;i++)
- {
- PPCWaitPort(PPCPort);
-
- D(PPCfprintf(MyFile,"Getting message\n"));
-
- if (M68kMsg = PPCGetMessage(PPCPort))
- {
- D(PPCfprintf(MyFile,"Message: %s\n",
- PPCGetMessageAttr(M68kMsg, PPCMSGTAG_DATA)));
- PPCReplyMessage(M68kMsg);
- }
- else
- {
- D(PPCfprintf(MyFile,"Did not get m68k msg\n"));
- }
- }
- }
- else
- {
- D(PPCfprintf(MyFile,"Could not find PPC Task`s msgport\n"));
- }
-
- D(PPCfprintf(MyFile,"Closing output\n"));
- #if DEBUG
- PPCClose(MyFile);
- }
- #endif
- }
-
-