2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Parallel hidd class implementation.
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
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
},
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
);
53 EnterFunc(bug("HIDDParallel::NewParallel()\n"));
55 D(bug("Request for unit number %d\n",msg
->unitnum
));
62 unitnum
= msg
->unitnum
;
64 if (0 != (data
->usedunits
& (1 << unitnum
)))
71 case -1: /* search for the next available unit */
74 while (unitnum
< PAR_MAX_UNITS
)
76 if (0 == (data
->usedunits
& (1 << unitnum
)))
88 if (unitnum
>= 0 && unitnum
< PAR_MAX_UNITS
)
90 struct TagItem tags
[] =
92 {aHidd_ParallelUnit_Unit
, unitnum
},
96 su
= OOP_NewObject(NULL
, CLID_Hidd_ParallelUnit
, tags
);
97 data
->ParallelUnits
[unitnum
] = su
;
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"));
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
);
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
);
156 ADD2INITLIB(UXPar_InitAttrBases
, 0)
157 ADD2EXPUNGELIB(UXPar_ExpungeAttrBases
, 0)
159 ADD2LIBS("Devs:Drivers/unixio.hidd", 42, struct Library
*, UnixIOBase
)