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

  1. /* Msg7 and Msg7PPC.elf
  2.  *
  3.  * This test program sends 1000 messages to the PPC and
  4.  * shows how long this takes.
  5.  * The Messages are send synchron and every msg must
  6.  * be replied after another.
  7.  * Each Message has a Body with the size of 3747 bytes
  8.  * and the PPC side checks if the msg is received correctly.
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <exec/nodes.h>
  13. #include <exec/lists.h>
  14. #include <exec/memory.h>
  15. #include <utility/tagitem.h>
  16. #include <powerup/ppclib/interface.h>
  17. #include <powerup/ppclib/message.h>
  18. #include <powerup/ppclib/tasks.h>
  19. #include <powerup/gcclib/powerup_protos.h>
  20.  
  21. #define    DEBUG    0
  22.  
  23. #if DEBUG
  24. #define    D(x)    x;
  25. #else
  26. #define    D(x)    ;
  27. #endif
  28.  
  29. #define TEXT    "Text sent by PPC processor\n"
  30.  
  31. BPTR    MyFile;
  32.  
  33.  
  34. struct StartupData
  35. {
  36.     ULONG    MsgCount;
  37. };
  38.  
  39. #define    BODYSIZE    3747
  40.  
  41. int    main(void)
  42. {
  43. struct StartupData    *StartupData;
  44. void        *PPCPort;
  45. void        *ReplyPort;
  46. void        *M68kPort;
  47. void        *PPCMsg;
  48. void        *M68kMsg;
  49. UBYTE        *Body;
  50. ULONG           result;
  51. ULONG        MsgCount;
  52. ULONG        i,j;
  53.  
  54.  
  55.   StartupData    =(struct StartupData *) PPCGetTaskAttr(PPCTASKTAG_STARTUP_MSGDATA);
  56.  
  57.   MsgCount    =    StartupData->MsgCount;
  58.  
  59. #if DEBUG
  60.   if (MyFile = PPCOpen("con:0/0/640/200/MessageDemo - PPC output/CLOSE", MODE_NEWFILE))
  61.   {
  62. #endif
  63.     D(PPCfprintf(MyFile,"Creating message port\n"));
  64.  
  65.  
  66.     if (PPCPort =(void*) PPCGetTaskAttr(PPCTASKTAG_MSGPORT))
  67.     {
  68.  
  69.       D(PPCfprintf(MyFile,"Waiting for M68k message\n"));
  70.  
  71.       for (i=0;i<MsgCount;i++)
  72.       {
  73.         PPCWaitPort(PPCPort);
  74.  
  75.         D(PPCfprintf(MyFile,"Getting message\n"));
  76.  
  77.         while (M68kMsg = PPCGetMessage(PPCPort))
  78.         {
  79.           Body    =(UBYTE*) PPCGetMessageAttr(M68kMsg, PPCMSGTAG_DATA);
  80.  
  81.           for (j=0;j<BODYSIZE;j++)
  82.           {
  83.             if (Body[j]    != ((i+j) & 0xff))
  84.             {
  85.               D(PPCfprintf(MyFile,"MsgBody is wrong\n"));
  86.             }
  87.           }
  88.           PPCReplyMessage(M68kMsg);
  89.         }
  90.       }
  91.  
  92.     }
  93.     else
  94.     {
  95.       D(PPCfprintf(MyFile,"Could not find PPC Task's msgport\n"));
  96.     }
  97.  
  98.     D(PPCfprintf(MyFile,"Closing output\n"));
  99. #if DEBUG
  100.     PPCClose(MyFile);
  101.   }
  102. #endif
  103. }
  104.  
  105.