home *** CD-ROM | disk | FTP | other *** search
-
- /*
- **
- ** $VER: msg9ppc.c 46.1 (3.6.98)
- ** Msg9 46.1
- **
- ** ppc side of Msg9
- **
- ** Written 1997/1998 by Roland Mainz (gisburn@w-specht.rhein-ruhr.de)
- **
- */
-
- /* amiga includes */
- #include <exec/types.h>
- #include <exec/nodes.h>
- #include <exec/lists.h>
- #include <exec/memory.h>
- #include <utility/tagitem.h>
-
- /* ppc includes */
- #include <powerup/ppclib/interface.h>
- #include <powerup/ppclib/message.h>
- #include <powerup/ppclib/tasks.h>
-
- /* ppc prototypes */
- #include <powerup/gcclib/powerup_protos.h>
-
- /* ANSI C includes */
- #include <string.h>
-
- /* protject includes */
- #include "msg9.h"
-
- /******************************************************************************/
-
- #if USE_PPC_STDIO
- #define printf PPCprintf
- #else
- BPTR MyFile = NULL;
-
- static void printf( char *s ) { PPCWrite( MyFile, s, (ULONG)strlen( s ) ); }
- #endif /* USE_PPC_STDIO */
-
- /******************************************************************************/
-
- /* ppc code entry */
- int main( void )
- {
- struct StartupData *StartupData;
- ULONG BodySize;
-
- StartupData = (struct StartupData *)PPCGetTaskAttr( PPCTASKTAG_STARTUP_MSGDATA );
-
- BodySize = StartupData -> BodySize;
-
- #if USE_PPC_STDIO == 0
- if( MyFile = PPCOpen( "CON:////MessageDemo 9 - PPC output/CLOSE/AUTO/WAIT/INACTIVE", MODE_NEWFILE ) )
- #endif /* USE_PPC_STDIO == 0 */
- {
- APTR PPCPort;
-
- printf( "Creating message port\n" );
-
- if( PPCPort = (APTR)PPCGetTaskAttr( PPCTASKTAG_MSGPORT ) )
- {
- ULONG which = 0UL;
- BOOL done = FALSE;
-
- printf( "Waiting for M68k message\n" );
-
- while( !done )
- {
- APTR M68kMsg;
-
- PPCWaitPort( PPCPort );
-
- while( M68kMsg = PPCGetMessage( PPCPort ) )
- {
- ULONG sum,
- i;
- ULONG id = PPCGetMessageAttr( M68kMsg, PPCMSGTAG_MSGID );
- ULONG MsgLen = PPCGetMessageAttr( M68kMsg, PPCMSGTAG_DATALENGTH );
- UBYTE *Body = (UBYTE *)PPCGetMessageAttr( M68kMsg, PPCMSGTAG_DATA );
-
- which++;
-
- /* Calc checksum... */
- for( sum = 0UL, i = 0UL ; i < MsgLen ; i++ )
- {
- sum += Body[ i ];
- }
-
- /* ...and check if the m68k side has the same result. */
- if( sum != id )
- {
- #if USE_PPC_STDIO
- printf( "Checksum error %lu\n", which );
- #else
- char buffer[ 256 ];
-
- PPCsprintf( buffer, "Checksum error %lu\n", which );
-
- printf( buffer );
- #endif /* USE_PPC_STDIO */
- }
-
- if( BodySize != MsgLen )
- {
- done = TRUE;
- }
-
- PPCReplyMessage( M68kMsg );
- }
- }
- }
- else
- {
- printf( "Could not find PPC Task's msgport\n" );
- }
-
- #if USE_PPC_STDIO == 0
- printf( "Closing output\n" );
- PPCClose( MyFile );
- #endif /* USE_PPC_STDIO == 0 */
- }
-
- return( RETURN_OK );
- }
-
-
-
-