home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / PowerPC / Dev / PPCRelease / Examples / IPC / Msg5PPC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-06  |  1.9 KB  |  94 lines

  1. /* Msg5 and Msg5PPC.elf
  2.  *
  3.  * This test program sends 1000 messages to the PPC and
  4.  * shows how long this takes.
  5.  * The Messages are send asynchron and it`s not waited
  6.  * for the reply...until all messages are send
  7.  * Each Message has the Body "Text sent by M68k processor\n"
  8.  */
  9.  
  10. #include <exec/types.h>
  11. #include <exec/nodes.h>
  12. #include <exec/lists.h>
  13. #include <exec/memory.h>
  14. #include <utility/tagitem.h>
  15. #include <powerup/ppclib/interface.h>
  16. #include <powerup/ppclib/message.h>
  17. #include <powerup/ppclib/tasks.h>
  18. #include <powerup/gcclib/powerup_protos.h>
  19.  
  20. #define    DEBUG    0
  21.  
  22. #if DEBUG
  23. #define    D(x)    x;
  24. #else
  25. #define    D(x)    ;
  26. #endif
  27.  
  28. #define text    "Text sent by PPC processor\n"
  29.  
  30. struct StartupData
  31. {
  32.     ULONG    MsgCount;
  33. };
  34.  
  35. BPTR    MyFile;
  36.  
  37.  
  38. int    main(void)
  39. {
  40. struct StartupData    *StartupData;
  41. void            *PPCPort;
  42. void            *ReplyPort;
  43. void            *PPCMsg;
  44. void            *M68kMsg;
  45. void            *Body;
  46. ULONG            result;
  47. ULONG            MsgCount;
  48. ULONG            i;
  49.  
  50.   StartupData    =(struct StartupData *) PPCGetTaskAttr(PPCTASKTAG_STARTUP_MSGDATA);
  51.  
  52.   MsgCount    =    StartupData->MsgCount;
  53.  
  54. #if DEBUG
  55.   if (MyFile = PPCOpen("con:0/0/640/200/MessageDemo - PPC output/CLOSE", MODE_NEWFILE))
  56.   {
  57. #endif
  58.     D(PPCfprintf(MyFile,"Creating message port\n"));
  59.  
  60.     if (PPCPort=(void*) PPCGetTaskAttr(PPCTASKTAG_MSGPORT))
  61.     {
  62.  
  63.       D(PPCfprintf(MyFile,"Waiting for M68k message\n"));
  64.  
  65.       i    =    0;
  66.       while (i<MsgCount)
  67.       {
  68.         PPCWaitPort(PPCPort);
  69.  
  70.         D(PPCfprintf(MyFile,"Getting message\n"));
  71.  
  72.         while (i<MsgCount && (M68kMsg = PPCGetMessage(PPCPort)))
  73.         {
  74.           D(PPCfprintf(MyFile,"Message: %s\n",
  75.                        PPCGetMessageAttr(M68kMsg, PPCMSGTAG_DATA)));
  76.           PPCReplyMessage(M68kMsg);
  77.           i++;
  78.         }
  79.       }
  80.  
  81.     }
  82.     else
  83.     {
  84.       D(PPCfprintf(MyFile,"Could not find PPC Task`s msgport\n"));
  85.     }
  86.  
  87.     D(PPCfprintf(MyFile,"Closing output\n"));
  88. #if DEBUG
  89.     PPCClose(MyFile);
  90.   }
  91. #endif
  92. }
  93.  
  94.