revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-amiga / hidd / parallel / ParallelClass.c
blob7c71892744e2227929815d1e1d6f62fe232428ee
1 /*
2 Copyright © 1995-2015, 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>
20 #include "parallel_intern.h"
22 #include <aros/debug.h>
25 /*static AttrBase HiddGCAttrBase;*/
27 static OOP_AttrBase HiddParallelUnitAB;
29 /*** HIDDParallel::NewUnit() *********************************************************/
32 OOP_Object *AmigaPar__Hidd_Parallel__NewUnit(OOP_Class *cl, OOP_Object *obj,
33 struct pHidd_Parallel_NewUnit *msg)
35 OOP_Object *su = NULL;
36 struct HIDDParallelData * data = OOP_INST_DATA(cl, obj);
37 ULONG unitnum = -1;
39 EnterFunc(bug("HIDDParallel::NewParallel()\n"));
41 D(bug("Request for unit number %d\n",msg->unitnum));
43 if (msg->unitnum >= 0 && msg->unitnum < PAR_MAX_UNITS) {
44 unitnum = msg->unitnum;
46 if (0 != (data->usedunits & (1 << unitnum))) {
47 unitnum = -1;
49 } else if (msg->unitnum == -1) {
50 /* search for the next available unit */
51 unitnum = 0;
53 while (unitnum < PAR_MAX_UNITS) {
54 if (0 == (data->usedunits & (1 << unitnum))) {
55 break;
58 unitnum++;
62 if (unitnum >= 0 && unitnum < PAR_MAX_UNITS) {
63 struct TagItem tags[] =
65 {aHidd_ParallelUnit_Unit, unitnum},
66 {TAG_DONE }
69 su = OOP_NewObject(NULL, CLID_Hidd_ParallelUnit, tags);
70 data->ParallelUnits[unitnum] = su;
73 ** Mark it as used
75 data->usedunits |= (1 << unitnum);
78 ReturnPtr("HIDDParallel::NewParallel", OOP_Object *, su);
82 /*** HIDDParallel::DisposeUnit() ****************************************************/
84 VOID AmigaPar__Hidd_Parallel__DisposeUnit(OOP_Class *cl, OOP_Object *obj,
85 struct pHidd_Parallel_DisposeUnit *msg)
87 OOP_Object * pu = msg->unit;
88 struct HIDDParallelData * data = OOP_INST_DATA(cl, obj);
90 EnterFunc(bug("HIDDParallel::DisposeUnit()\n"));
92 if(pu) {
93 ULONG unitnum = 0;
95 while (unitnum < PAR_MAX_UNITS) {
96 if (data->ParallelUnits[unitnum] == pu) {
97 D(bug("Disposing ParallelUnit!\n"));
98 OOP_DisposeObject(pu);
99 data->ParallelUnits[unitnum] = NULL;
100 data->usedunits &= ~(1 << unitnum);
101 break;
104 unitnum++;
108 ReturnVoid("HIDDParallel::DisposeUnit");