2 Copyright © 1995-2017, 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>
20 #include "parallel_intern.h"
26 #include <aros/debug.h>
29 /*static AttrBase HiddGCAttrBase;*/
31 static OOP_AttrBase HiddParallelUnitAB
;
34 static struct OOP_ABDescr attrbases
[] =
36 { IID_Hidd_ParallelUnit
, &HiddParallelUnitAB
},
41 /*** HIDDParallel::NewUnit() *********************************************************/
44 OOP_Object
*PCPar__Hidd_Parallel__NewUnit(OOP_Class
*cl
, OOP_Object
*obj
,
45 struct pHidd_Parallel_NewUnit
*msg
)
47 OOP_Object
*su
= NULL
;
48 struct HIDDParallelData
* data
= OOP_INST_DATA(cl
, obj
);
51 EnterFunc(bug("HIDDParallel::NewParallel()\n"));
53 D(bug("Request for unit number %d\n",msg
->unitnum
));
55 switch (msg
->unitnum
) {
59 unitnum
= msg
->unitnum
;
61 if (0 != (data
->usedunits
& (1 << unitnum
))) {
67 case -1: /* search for the next available unit */
70 while (unitnum
< PAR_MAX_UNITS
) {
71 if (0 == (data
->usedunits
& (1 << unitnum
))) {
82 if (unitnum
>= 0 && unitnum
< PAR_MAX_UNITS
) {
83 struct TagItem tags
[] =
85 {aHidd_ParallelUnit_Unit
, unitnum
},
89 su
= OOP_NewObject(NULL
, CLID_Hidd_ParallelUnit
, tags
);
90 data
->ParallelUnits
[unitnum
] = su
;
95 data
->usedunits
|= (1 << unitnum
);
98 ReturnPtr("HIDDParallel::NewParallel", OOP_Object
*, su
);
102 /*** HIDDParallel::DisposeUnit() ****************************************************/
104 VOID
PCPar__Hidd_Parallel__DisposeUnit(OOP_Class
*cl
, OOP_Object
*obj
,
105 struct pHidd_Parallel_DisposeUnit
*msg
)
107 OOP_Object
* pu
= msg
->unit
;
108 struct HIDDParallelData
* data
= OOP_INST_DATA(cl
, obj
);
110 EnterFunc(bug("HIDDParallel::DisposeUnit()\n"));
115 while (unitnum
< PAR_MAX_UNITS
) {
116 if (data
->ParallelUnits
[unitnum
] == pu
) {
117 D(bug("Disposing ParallelUnit!\n"));
118 OOP_DisposeObject(pu
);
119 data
->ParallelUnits
[unitnum
] = NULL
;
120 data
->usedunits
&= ~(1 << unitnum
);
128 ReturnVoid("HIDDParallel::DisposeUnit");