revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-unix / hidd / parallel / ParallelClass.c
blob327a570c4c018d18d21026e0672c3d96fed9dd3a
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Parallel hidd class implementation.
6 Lang: english
7 */
9 #define __OOP_NOATTRBASES__
11 #include <proto/exec.h>
12 #include <proto/utility.h>
13 #include <proto/oop.h>
14 #include <exec/libraries.h>
16 #include <utility/tagitem.h>
17 #include <hidd/parallel.h>
19 #include <aros/symbolsets.h>
22 #include "parallel_intern.h"
24 #include LC_LIBDEFS_FILE
26 #undef SDEBUG
27 #undef DEBUG
28 #define SDEBUG 1
29 #define DEBUG 1
30 #include <aros/debug.h>
33 /*static AttrBase HiddGCAttrBase;*/
35 static OOP_AttrBase HiddParallelUnitAB;
37 static struct OOP_ABDescr attrbases[] =
39 { IID_Hidd_ParallelUnit, &HiddParallelUnitAB },
40 { NULL, NULL }
43 /*** HIDDParallel::NewUnit() *********************************************************/
46 OOP_Object *UXPar__Hidd_Parallel__NewUnit(OOP_Class *cl, OOP_Object *obj,
47 struct pHidd_Parallel_NewUnit *msg)
49 OOP_Object *su = NULL;
50 struct HIDDParallelData * data = OOP_INST_DATA(cl, obj);
51 ULONG unitnum = -1;
53 EnterFunc(bug("HIDDParallel::NewParallel()\n"));
55 D(bug("Request for unit number %d\n",msg->unitnum));
57 switch (msg->unitnum)
59 case 0:
60 case 1:
61 case 2:
62 unitnum = msg->unitnum;
64 if (0 != (data->usedunits & (1 << unitnum)))
66 unitnum = -1;
69 break;
71 case -1: /* search for the next available unit */
72 unitnum = 0;
74 while (unitnum < PAR_MAX_UNITS)
76 if (0 == (data->usedunits & (1 << unitnum)))
78 break;
81 unitnum++;
83 break;
88 if (unitnum >= 0 && unitnum < PAR_MAX_UNITS)
90 struct TagItem tags[] =
92 {aHidd_ParallelUnit_Unit, unitnum},
93 {TAG_DONE }
96 su = OOP_NewObject(NULL, CLID_Hidd_ParallelUnit, tags);
97 data->ParallelUnits[unitnum] = su;
100 ** Mark it as used
102 data->usedunits |= (1 << unitnum);
105 ReturnPtr("HIDDParallel::NewParallel", OOP_Object *, su);
109 /*** HIDDParallel::DisposeUnit() ****************************************************/
111 VOID UXPar__Hidd_Parallel__DisposeUnit(OOP_Class *cl, OOP_Object *obj,
112 struct pHidd_Parallel_DisposeUnit *msg)
114 OOP_Object * pu = msg->unit;
115 struct HIDDParallelData * data = OOP_INST_DATA(cl, obj);
117 EnterFunc(bug("HIDDParallel::DisposeUnit()\n"));
119 if(pu)
121 ULONG unitnum = 0;
123 while (unitnum < PAR_MAX_UNITS)
125 if (data->ParallelUnits[unitnum] == pu)
127 D(bug("Disposing ParallelUnit!\n"));
128 OOP_DisposeObject(pu);
129 data->ParallelUnits[unitnum] = NULL;
130 data->usedunits &= ~(1 << unitnum);
131 break;
134 unitnum++;
138 ReturnVoid("HIDDParallel::DisposeUnit");
143 /*************************** Classes *****************************/
145 static int UXPar_InitAttrBases(LIBBASETYPEPTR LIBBASE)
147 return OOP_ObtainAttrBases(attrbases);
150 static int UXPar_ExpungeAttrBases(LIBBASETYPEPTR LIBBASE)
152 OOP_ReleaseAttrBases(attrbases);
153 return TRUE;
156 ADD2INITLIB(UXPar_InitAttrBases, 0)
157 ADD2EXPUNGELIB(UXPar_ExpungeAttrBases, 0)
159 ADD2LIBS("Devs:Drivers/unixio.hidd", 42, struct Library *, UnixIOBase)