2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
5 Desc: Serial hidd class implementation.
9 #include <proto/exec.h>
10 #include <proto/utility.h>
11 #include <proto/oop.h>
12 #include <exec/libraries.h>
14 #include <utility/tagitem.h>
15 #include <hidd/serial.h>
18 #include "serial_intern.h"
24 #include <aros/debug.h>
28 /*** HIDDSerial::NewUnit() *********************************************************/
30 OOP_Object
*UXSer__Hidd_Serial__NewUnit(OOP_Class
*cl
, OOP_Object
*obj
,
31 struct pHidd_Serial_NewUnit
*msg
)
33 OOP_Object
*su
= NULL
;
34 struct HIDDSerialData
* data
= OOP_INST_DATA(cl
, obj
);
37 EnterFunc(bug("HIDDSerial::NewSerial()\n"));
39 D(bug("Request for unit number %d\n",msg
->unitnum
));
47 unitnum
= msg
->unitnum
;
48 if (0 != (data
->usedunits
& (1 << unitnum
)))
52 case -1: /* search for the next available unit */
55 while (unitnum
< SER_MAX_UNITS
)
57 if (0 == (data
->usedunits
& (1 << unitnum
)))
67 if (unitnum
>= 0 && unitnum
< SER_MAX_UNITS
)
69 struct TagItem tags
[] =
72 {aHidd_SerialUnit_Unit
, unitnum
},
77 su
= OOP_NewObject(NULL
, CLID_Hidd_SerialUnit
, tags
);
78 data
->SerialUnits
[unitnum
] = su
;
82 data
->usedunits
|= (1 << unitnum
);
85 ReturnPtr("HIDDSerial::NewSerial", OOP_Object
*, su
);
89 /*** HIDDSerial::DisposeUnit() ****************************************************/
91 VOID
UXSer__Hidd_Serial__DisposeUnit(OOP_Class
*cl
, OOP_Object
*obj
,
92 struct pHidd_Serial_DisposeUnit
*msg
)
94 OOP_Object
* su
= msg
->unit
;
95 struct HIDDSerialData
* data
= OOP_INST_DATA(cl
, obj
);
97 EnterFunc(bug("HIDDSerial::DisposeUnit()\n"));
103 while (unitnum
< SER_MAX_UNITS
)
105 if (data
->SerialUnits
[unitnum
] == su
)
107 D(bug("Disposing SerialUnit!\n"));
108 OOP_DisposeObject(su
);
109 data
->SerialUnits
[unitnum
] = NULL
;
110 data
->usedunits
&= ~(1 << unitnum
);
119 ReturnVoid("HIDDSerial::DisposeUnit");