home *** CD-ROM | disk | FTP | other *** search
- /* Msg4 and Msg4PPC.elf
- *
- * This test program sends 1000 messages to the M68k 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 PPC 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
- {
- void *MsgPort;
- ULONG MsgCount;
- };
-
- BPTR MyFile;
-
- int main(void)
- {
- struct TagItem MyTags[1];
- struct StartupData *StartupData;
- void *ReplyPort;
- void *M68kPort;
- void *PPCMsg;
- 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 (M68kPort=StartupData->MsgPort)
- {
- D(PPCfprintf(MyFile,"Allocating memory for message body\n"));
- if (Body = PPCAllocVec(sizeof(TEXT), MEMF_PUBLIC))
- {
- D(PPCfprintf(MyFile,"Creating reply port\n"));
- MyTags[0].ti_Tag = TAG_DONE;
- if (ReplyPort = PPCCreatePort(MyTags))
- {
- D(PPCfprintf(MyFile,"Creating message\n"));
- if (PPCMsg = PPCCreateMessage(ReplyPort, sizeof(TEXT)))
- {
- D(PPCfprintf(MyFile,"Obtaining PPC port..."));
-
- strcpy(Body, TEXT);
-
- for (i=0;i<MsgCount;i++)
- {
- PPCSendMessage(M68kPort,
- PPCMsg,
- Body,
- sizeof(TEXT),
- 0x12345678);
- PPCWaitPort(ReplyPort);
- PPCGetMessage(ReplyPort);
- }
-
- D(PPCfprintf(MyFile,"Deleting Message\n"));
- PPCDeleteMessage(PPCMsg);
- }
- else
- {
- D(PPCfprintf(MyFile,"Could not create ppc msg\n"));
- }
-
- D(PPCfprintf(MyFile,"Deleting reply port\n"));
- while (PPCDeletePort(ReplyPort) == FALSE);
- }
- else
- {
- D(PPCfprintf(MyFile,"Could not create reply port\n"));
- }
-
- D(PPCfprintf(MyFile,"Freeing message body memory\n"));
- PPCFreeVec(Body);
- }
- else
- {
- D(PPCfprintf(MyFile,"Could not alloc mem for msg body\n"));
- }
-
- }
- else
- {
- D(PPCfprintf(MyFile,"Could not get a M68k msgport\n"));
- }
-
- D(PPCfprintf(MyFile,"Closing output\n"));
- #if DEBUG
- PPCClose(MyFile);
- }
- #endif
- }
-
-
-