revert between 56095 -> 55830 in arch
[AROS.git] / arch / i386-pc / drivers / parallel.hidd / ParallelClass.c
blob875cd6b7d32ba1f5b94d772b034c82668de0d880
1 /*
2 Copyright © 1995-2017, 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 #undef SDEBUG
23 #undef DEBUG
24 #define SDEBUG 0
25 #define DEBUG 0
26 #include <aros/debug.h>
29 /*static AttrBase HiddGCAttrBase;*/
31 static OOP_AttrBase HiddParallelUnitAB;
33 #if 0
34 static struct OOP_ABDescr attrbases[] =
36 { IID_Hidd_ParallelUnit, &HiddParallelUnitAB },
37 { NULL, NULL }
39 #endif
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);
49 ULONG unitnum = -1;
51 EnterFunc(bug("HIDDParallel::NewParallel()\n"));
53 D(bug("Request for unit number %d\n",msg->unitnum));
55 switch (msg->unitnum) {
56 case 0:
57 case 1:
58 case 2:
59 unitnum = msg->unitnum;
61 if (0 != (data->usedunits & (1 << unitnum))) {
62 unitnum = -1;
65 break;
67 case -1: /* search for the next available unit */
68 unitnum = 0;
70 while (unitnum < PAR_MAX_UNITS) {
71 if (0 == (data->usedunits & (1 << unitnum))) {
72 break;
75 unitnum++;
77 break;
82 if (unitnum >= 0 && unitnum < PAR_MAX_UNITS) {
83 struct TagItem tags[] =
85 {aHidd_ParallelUnit_Unit, unitnum},
86 {TAG_DONE }
89 su = OOP_NewObject(NULL, CLID_Hidd_ParallelUnit, tags);
90 data->ParallelUnits[unitnum] = su;
93 ** Mark it as used
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"));
112 if(pu) {
113 ULONG unitnum = 0;
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);
121 break;
124 unitnum++;
128 ReturnVoid("HIDDParallel::DisposeUnit");