home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / PowerPC / Dev / PPCRelease / Tools / PPCLoad.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-14  |  975 b   |  53 lines

  1. /*
  2.  * This program does load an Elf Binary and runs it as a PPC Task.
  3.  * It doesn`t return until the Task completes.
  4.  *
  5.  */
  6.  
  7. #include <exec/types.h>
  8. #include <proto/exec.h>
  9. #include <proto/dos.h>
  10. #include <PowerUP/pragmas/ppc_pragmas.h>
  11. #include <PowerUP/clib/ppc_protos.h>
  12. #include "PPCLoad_VERSION.h"
  13.  
  14. UBYTE vers[] = VERSTAG;
  15.  
  16. extern struct ExecBase    *SysBase;
  17. BPTR    stdout;
  18.  
  19. void    main(ULONG argc,char *argv[])
  20. {
  21. struct Library    *PPCLibBase;
  22. ULONG        Result;
  23. APTR        MyObject;
  24.  
  25.   stdout    =    Output();
  26.  
  27.   if (argc != 2L)
  28.   {
  29.     Printf("Usage: ElfFile\n");
  30.   }
  31.   else
  32.   {
  33.     if (PPCLibBase=OpenLibrary("ppc.library",0))
  34.     {
  35.       if (MyObject=PPCLoadObject(argv[1]))
  36.       {
  37.         Result=PPCRunObject(MyObject,NULL);
  38.         Printf("Result:0x%lx\n",Result);
  39.         PPCUnLoadObject(MyObject);
  40.       }
  41.       else
  42.       {
  43.         Printf("Can't load %s\n",argv[1]);
  44.       }
  45.       CloseLibrary(PPCLibBase);
  46.     }
  47.     else
  48.     {
  49.       Printf("Can't open ppc.library\n");
  50.     }
  51.   }
  52. }
  53.