home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- $CRT 17 Mar 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>Dev.c<< 19 Dec 1996 11:51:52 - (C) ProDAD
- *******************************************************************/
-
- //##private
-
- // mcpp:cppc -gs -o pos:pos/Devs/my.device p:pLib/DevCode.o p:pCom/_Example/Dev/Dev.c p:pLib/pLinkLib.o
-
- /***********************************************************
- pOS programing example - Copyright (C) 1995-97 proDAD
-
- This code was written as an easy to understand example,
- how to program pOS features. It is provided 'as-is',
- without any express or implied warranty.
-
- Permission is hereby granted to use, copy and modify
- this source code for any purpose, without fee, subject
- to the following conditions:
-
- (1) This notice may not be removed or altered from any
- source distribution.
-
- (2) Altered source versions must be plainly marked as
- such, and must not be misrepresented as being
- the original source code.
-
- (3) If only executable code is distributed, then the
- accompanying documentation have to state that
- "this software is based in part on examples of
- the pOS developer packet".
-
- (4) Permission for use of this code is granted only
- if the user accepts full responsibility for any
- undesirable consequences. proDAD accept NO LIABILITY
- for damages of any kind.
-
- ©proDAD
- ***********************************************************/
-
- #define __COMPUTER_AMIGA 1
- #define NOMYDEBUG
-
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
-
- #include "p:pExec/Device.h"
- #include "p:pExec/Resident.h"
- #include "p:pUtil/TagItem.h"
- #include "p:pDOS/Segment.h"
- #include "p:pExec/Diagnos.h"
- #include "p:pExec/TstTags.h"
-
-
- #ifdef _____ME_____
- #include "grund/inc_string.h"
- #include "grund/inc_limits.h"
- #else
- extern "C" {
- #include <string.h>
- #include <limits.h>
- }
- #endif
-
- struct MY_Dev
- {
- pOS_Device my_Dev;
- };
-
-
- extern ULONG *FuncTable[];
- extern BOOL pDevMain(_R_LB pOS_ExecBase*,_R_A0 MY_Dev*);
-
- const CHAR DeviceName[] ="my.device";
- const CHAR DeviceIDName[]="my.device 1.0 ("__DATE2__")";
-
- const pOS_TagItem DeviceDescribe[]=
- {
- EXTSTTAG_MainOSID, pOS_MAINOSID,
- TAG_END
- };
-
-
-
- pOS_ResidentLibInit InitTable=
- {
- sizeof(MY_Dev),
- FuncTable,
- NULL,
- (BOOL(*)(_R_LB pOS_ExecBase*,_R_A0 pOS_Library*))pDevMain
- };
-
-
- /*----------------------------------
- -----------------------------------*/
- static BOOL Open_func(MY_Dev* dev,pOS_IOStdReq* io,ULONG unit,ULONG flags)
- {
- //PRINT("MY_Dev: Open()\n");
- return(1);
- }
-
- static VOID Close_func(MY_Dev* lib,pOS_IOStdReq* io)
- {
- //PRINT("MY_Dev: Close()\n");
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- static pOS_SegmentLst* Expunge_func(MY_Dev* lib)
- {
- lib->my_Dev.dd_Library.lib_Flags |= LIBF_DELEXP;
- if(lib->my_Dev.dd_Library.lib_OpenCnt==0) {
- pOS_SegmentLst* Seg=lib->my_Dev.dd_Library.lib_Segm;
-
- pOS_ListRemove(&lib->my_Dev.dd_Library.lib_Node);
- _pOS_FreeLibraryMem2(&lib->my_Dev.dd_Library);
- //PRINT("MY_Dev: Expunge+Remove()\n");
- return(Seg);
- }
- return(0);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- static ULONG Reserved_func(MY_Dev* lib)
- {
- //PRINT("MY_Dev: Reserved()\n");
- return(0);
- }
-
-
-
- ULONG *FuncTable[]=
- {
- (ULONG*)Open_func,
- (ULONG*)Close_func,
- (ULONG*)Expunge_func,
- // ------------
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- // ------------
- (ULONG*)AudioBegin_func,
- (ULONG*)AudioAbort_func,
- // ------------
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- (ULONG*)Reserved_func,
- // ------------
-
- (ULONG*)ULONG_MAX
- };
-
-
-
-
- /*----------------------------------
- -----------------------------------*/
- BOOL pDevMain(_R_LB pOS_ExecBase* exec,_R_A0 MY_Dev* lib)
- {
- #ifdef __pOS_EXECPRECODE
- gb_ExecBase=(struct pOS_ExecBase*)exec;
- gb_ExecLib=*((struct pOS_ExecLibFunction**)
- lib->my_Dev.dd_Library.lib_Segm->sel_Seg.seg_Reserved2);
- // PRINT("MY_Dev: pDevMain( )\n");
- #else
- #error hier fehlt etwas
- #endif
- return(TRUE);
- }
-