alsa.audio: build the bridge link lib only for linux architecture
[AROS.git] / arch / all-unix / hidd / serial / SerialClass.c
blob8614657b7665773afc85b032a6b43d750b0262f6
1 /*
2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Serial hidd class implementation.
6 Lang: english
7 */
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"
20 #undef SDEBUG
21 #undef DEBUG
22 #define SDEBUG 0
23 #define DEBUG 0
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);
35 ULONG unitnum = -1;
37 EnterFunc(bug("HIDDSerial::NewSerial()\n"));
39 D(bug("Request for unit number %d\n",msg->unitnum));
41 switch (msg->unitnum)
43 case 0:
44 case 1:
45 case 2:
46 case 3:
47 unitnum = msg->unitnum;
48 if (0 != (data->usedunits & (1 << unitnum)))
49 unitnum = -1;
50 break;
52 case -1: /* search for the next available unit */
54 unitnum = 0;
55 while (unitnum < SER_MAX_UNITS)
57 if (0 == (data->usedunits & (1 << unitnum)))
58 break;
59 unitnum++;
62 break;
67 if (unitnum >= 0 && unitnum < SER_MAX_UNITS)
69 struct TagItem tags[] =
71 #define csd CSD(cl)
72 {aHidd_SerialUnit_Unit, unitnum},
73 #undef csd
74 {TAG_DONE }
77 su = OOP_NewObject(NULL, CLID_Hidd_SerialUnit, tags);
78 data->SerialUnits[unitnum] = su;
80 ** Mark it as used
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"));
99 if(su)
101 ULONG unitnum = 0;
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);
111 break;
114 unitnum++;
119 ReturnVoid("HIDDSerial::DisposeUnit");