home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / SampleDev / Dev.c
Encoding:
C/C++ Source or Header  |  1997-03-18  |  4.2 KB  |  185 lines

  1. /*******************************************************************
  2.  $CRT 17 Mar 1996 : hb
  3.  
  4.  $AUT Holger Burkarth
  5.  $DAT >>Dev.c<<   19 Dec 1996    11:51:52 - (C) ProDAD
  6. *******************************************************************/
  7.  
  8. //##private
  9.  
  10. // mcpp:cppc -gs -o pos:pos/Devs/my.device p:pLib/DevCode.o p:pCom/_Example/Dev/Dev.c p:pLib/pLinkLib.o
  11.  
  12. /***********************************************************
  13.   pOS programing example - Copyright (C) 1995-97 proDAD
  14.  
  15.   This code was written as an easy to understand example,
  16.   how to program pOS features. It is provided 'as-is',
  17.   without any express or implied warranty.
  18.  
  19.   Permission is hereby granted to use, copy and modify
  20.   this source code for any purpose, without fee, subject
  21.   to the following conditions:
  22.  
  23.     (1) This notice may not be removed or altered from any
  24.         source distribution.
  25.  
  26.     (2) Altered source versions must be plainly marked as
  27.         such, and must not be misrepresented as being
  28.         the original source code.
  29.  
  30.     (3) If only executable code is distributed, then the
  31.         accompanying documentation have to state that
  32.         "this software is based in part on examples of
  33.         the pOS developer packet".
  34.  
  35.     (4) Permission for use of this code is granted only
  36.         if the user accepts full responsibility for any
  37.         undesirable consequences. proDAD accept NO LIABILITY
  38.         for damages of any kind.
  39.  
  40.   ©proDAD
  41. ***********************************************************/
  42.  
  43. #define __COMPUTER_AMIGA 1
  44. #define NOMYDEBUG
  45.  
  46. #include "p:proto/pLibExt.h"
  47. #include "p:proto/pExec2.h"
  48.  
  49. #include "p:pExec/Device.h"
  50. #include "p:pExec/Resident.h"
  51. #include "p:pUtil/TagItem.h"
  52. #include "p:pDOS/Segment.h"
  53. #include "p:pExec/Diagnos.h"
  54. #include "p:pExec/TstTags.h"
  55.  
  56.  
  57. #ifdef _____ME_____
  58.   #include "grund/inc_string.h"
  59.   #include "grund/inc_limits.h"
  60. #else
  61.  extern "C" {
  62.   #include <string.h>
  63.   #include <limits.h>
  64.  }
  65. #endif
  66.  
  67. struct MY_Dev
  68. {
  69.   pOS_Device my_Dev;
  70. };
  71.  
  72.  
  73. extern ULONG *FuncTable[];
  74. extern BOOL pDevMain(_R_LB pOS_ExecBase*,_R_A0 MY_Dev*);
  75.  
  76. const CHAR DeviceName[]  ="my.device";
  77. const CHAR DeviceIDName[]="my.device 1.0 ("__DATE2__")";
  78.  
  79. const pOS_TagItem DeviceDescribe[]=
  80. {
  81.   EXTSTTAG_MainOSID, pOS_MAINOSID,
  82.   TAG_END
  83. };
  84.  
  85.  
  86.  
  87. pOS_ResidentLibInit InitTable=
  88. {
  89.   sizeof(MY_Dev),
  90.   FuncTable,
  91.   NULL,
  92.   (BOOL(*)(_R_LB pOS_ExecBase*,_R_A0 pOS_Library*))pDevMain
  93. };
  94.  
  95.  
  96. /*----------------------------------
  97. -----------------------------------*/
  98. static BOOL Open_func(MY_Dev* dev,pOS_IOStdReq* io,ULONG unit,ULONG flags)
  99. {
  100. //PRINT("MY_Dev: Open()\n");
  101.   return(1);
  102. }
  103.  
  104. static VOID Close_func(MY_Dev* lib,pOS_IOStdReq* io)
  105. {
  106. //PRINT("MY_Dev: Close()\n");
  107. }
  108.  
  109.  
  110. /*----------------------------------
  111. -----------------------------------*/
  112. static pOS_SegmentLst* Expunge_func(MY_Dev* lib)
  113. {
  114.   lib->my_Dev.dd_Library.lib_Flags |= LIBF_DELEXP;
  115.   if(lib->my_Dev.dd_Library.lib_OpenCnt==0) {
  116.     pOS_SegmentLst* Seg=lib->my_Dev.dd_Library.lib_Segm;
  117.  
  118.     pOS_ListRemove(&lib->my_Dev.dd_Library.lib_Node);
  119.     _pOS_FreeLibraryMem2(&lib->my_Dev.dd_Library);
  120. //PRINT("MY_Dev: Expunge+Remove()\n");
  121.     return(Seg);
  122.   }
  123.   return(0);
  124. }
  125.  
  126.  
  127. /*----------------------------------
  128. -----------------------------------*/
  129. static ULONG Reserved_func(MY_Dev* lib)
  130. {
  131. //PRINT("MY_Dev: Reserved()\n");
  132.   return(0);
  133. }
  134.  
  135.  
  136.  
  137. ULONG *FuncTable[]=
  138. {
  139.  (ULONG*)Open_func,
  140.  (ULONG*)Close_func,
  141.  (ULONG*)Expunge_func,
  142. // ------------
  143.  (ULONG*)Reserved_func,
  144.  (ULONG*)Reserved_func,
  145.  (ULONG*)Reserved_func,
  146.  (ULONG*)Reserved_func,
  147.  (ULONG*)Reserved_func,
  148.  (ULONG*)Reserved_func,
  149.  (ULONG*)Reserved_func,
  150.  (ULONG*)Reserved_func,
  151. // ------------
  152.  (ULONG*)AudioBegin_func,
  153.  (ULONG*)AudioAbort_func,
  154. // ------------
  155.  (ULONG*)Reserved_func,
  156.  (ULONG*)Reserved_func,
  157.  (ULONG*)Reserved_func,
  158.  (ULONG*)Reserved_func,
  159.  (ULONG*)Reserved_func,
  160.  (ULONG*)Reserved_func,
  161.  (ULONG*)Reserved_func,
  162.  (ULONG*)Reserved_func,
  163. // ------------
  164.  
  165.  (ULONG*)ULONG_MAX
  166. };
  167.  
  168.  
  169.  
  170.  
  171. /*----------------------------------
  172. -----------------------------------*/
  173. BOOL pDevMain(_R_LB pOS_ExecBase* exec,_R_A0 MY_Dev* lib)
  174. {
  175. #ifdef __pOS_EXECPRECODE
  176.   gb_ExecBase=(struct pOS_ExecBase*)exec;
  177.   gb_ExecLib=*((struct pOS_ExecLibFunction**)
  178.                lib->my_Dev.dd_Library.lib_Segm->sel_Seg.seg_Reserved2);
  179. // PRINT("MY_Dev: pDevMain( )\n");
  180. #else
  181.  #error hier fehlt etwas
  182. #endif
  183.   return(TRUE);
  184. }
  185.