home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / test / devicetest.c next >
Encoding:
C/C++ Source or Header  |  1996-10-24  |  2.4 KB  |  90 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: devicetest.c,v 1.3 1996/09/13 17:57:10 digulla Exp $
  4.     $Log: devicetest.c,v $
  5.     Revision 1.3  1996/09/13 17:57:10  digulla
  6.     Use IPTR
  7.  
  8.     Revision 1.2  1996/08/01 17:41:38  digulla
  9.     Added standard header for all files
  10.  
  11.     Desc:
  12.     Lang:
  13. */
  14. #include <exec/resident.h>
  15. #include <exec/execbase.h>
  16. #include <exec/io.h>
  17. #include <aros/libcall.h>
  18. #include <clib/exec_protos.h>
  19. #include <stdio.h>
  20. #include "dummydev_gcc.h"
  21.  
  22. extern const struct Resident resident;
  23. extern struct ExecBase *SysBase;
  24.  
  25. int main(void)
  26. {
  27.     int r1=0,r2=0,r3=0,e1=0,e2=0,e31=0,e32=0;
  28.     struct dummybase *dummy;
  29.  
  30.     if(!(resident.rt_Flags&RTF_AUTOINIT))
  31.     return 20;
  32.     dummy=(struct dummybase *)MakeLibrary(((APTR *)resident.rt_Init)[1],
  33.                       ((APTR *)resident.rt_Init)[2],
  34.                       ((APTR *)resident.rt_Init)[3],
  35.                       (IPTR)((APTR *)resident.rt_Init)[0],1);
  36.     if(dummy!=NULL)
  37.     {
  38.     Forbid();
  39.     if(FindName(&SysBase->DeviceList,(STRPTR)&dummy->device.dd_Library.lib_Node.ln_Name)==NULL)
  40.     {
  41.         AddDevice(&dummy->device);
  42.         {
  43.         struct MsgPort *port;
  44.         struct dummyrequest *dr;
  45.  
  46.         port=CreateMsgPort();
  47.         if(port!=NULL)
  48.         {
  49.             dr=(struct dummyrequest *)CreateIORequest(port,sizeof(struct dummyrequest));
  50.             if(dr!=NULL)
  51.             {
  52.             if(!OpenDevice("dummy.device",0,(struct IORequest *)dr,0))
  53.             {
  54.                 dr->iorequest.io_Command=0x1;
  55.                 DoIO((struct IORequest *)dr);
  56.                 r1=dr->id;
  57.                 e1=dr->iorequest.io_Error;
  58.                 dr->iorequest.io_Command=0x1;
  59.                 SendIO((struct IORequest *)dr);
  60.                 WaitIO((struct IORequest *)dr);
  61.                 r2=dr->id;
  62.                 e2=dr->iorequest.io_Error;
  63.                 dr->iorequest.io_Command=0x1;
  64.                 SendIO((struct IORequest *)dr);
  65.                 e31=AbortIO((struct IORequest *)dr);
  66.                 WaitIO((struct IORequest *)dr);
  67.                 r3=dr->id;
  68.                 e32=dr->iorequest.io_Error;
  69.  
  70.                 CloseDevice((struct IORequest *)dr);
  71.             }
  72.             DeleteIORequest((struct IORequest *)dr);
  73.             }
  74.             DeleteMsgPort(port);
  75.         }
  76.         }
  77.         /* Don't use RemLibrary() - it calls UnLoadSeg(). */
  78.         Remove(&dummy->device.dd_Library.lib_Node);
  79.     }
  80.     Permit();
  81.     FreeMem((char *)dummy-dummy->device.dd_Library.lib_NegSize,
  82.         dummy->device.dd_Library.lib_NegSize+dummy->device.dd_Library.lib_PosSize);
  83.  
  84.     printf("Synchronous:\t%d (%d)\n",r1,e1);
  85.     printf("Asynchronous:\t%d (%d)\n",r2,e2);
  86.     printf("Aborted:\t%d (%d,%d)\n",r3,e31,e32);
  87.     }
  88.     return 0;
  89. }
  90.