Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / .unmaintained / generic / hidd / serial / serial_init.c
blob276db35b17e73006bbb9eac9af9b811023870ae0
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Serial hidd initialization code.
6 Lang: English.
7 */
8 #include <stddef.h>
9 #include <exec/types.h>
11 #include <proto/exec.h>
13 #include "serial_intern.h"
16 #undef SysBase
18 /* Customize libheader.c */
19 #define LC_SYSBASE_FIELD(lib) (((LIBBASETYPEPTR)(lib))->hdg_SysBase)
20 #define LC_SEGLIST_FIELD(lib) (((LIBBASETYPEPTR)(lib))->hdg_SegList)
21 #define LC_RESIDENTNAME hiddserial_resident
22 #define LC_RESIDENTFLAGS RTF_AUTOINIT
23 #define LC_RESIDENTPRI 0
24 #define LC_LIBBASESIZE sizeof(LIBBASETYPE)
25 #define LC_LIBHEADERTYPEPTR LIBBASETYPEPTR
26 #define LC_LIB_FIELD(lib) (((LIBBASETYPEPTR)(lib))->hdg_LibNode)
28 #define LC_NO_OPENLIB
29 #define LC_NO_CLOSELIB
31 /* to avoid removing the serialhiddclass from memory add #define NOEXPUNGE */
33 #include <libcore/libheader.c>
35 #undef SDEBUG
36 #undef DEBUG
37 #define DEBUG 1
38 #include <aros/debug.h>
40 #define sysBase (LC_SYSBASE_FIELD(lh))
42 struct ExecBase * SysBase;
44 ULONG SAVEDS STDARGS LC_BUILDNAME(L_InitLib) (LC_LIBHEADERTYPEPTR lh)
46 struct class_static_data *csd; /* SerialHidd static data */
48 SysBase = sysBase;
49 EnterFunc(bug("SerialHIDD_Init()\n"));
52 We map the memory into the shared memory space, because it is
53 to be accessed by many processes, eg searching for a HIDD etc.
55 Well, maybe once we've got MP this might help...:-)
57 csd = AllocVec(sizeof(struct class_static_data), MEMF_CLEAR|MEMF_PUBLIC);
58 lh->hdg_csd = csd;
59 if(csd)
61 csd->sysbase = sysBase;
63 D(bug(" Got csd\n"));
65 csd->oopbase = OpenLibrary(AROSOOP_NAME, 0);
66 if (csd->oopbase)
68 D(bug(" Got OOPBase\n"));
69 csd->utilitybase = OpenLibrary("utility.library", 37);
70 if (csd->utilitybase)
72 D(bug(" Got UtilityBase\n"));
74 csd->serialhiddclass = init_serialhiddclass(csd);
76 D(bug(" SerialHiddClass: %p\n", csd->serialhiddclass));
78 if(csd->serialhiddclass)
80 D(bug(" Got SerialHIDDClass\n"));
81 ReturnInt("SerialHIDD_Init", ULONG, TRUE);
84 CloseLibrary(csd->utilitybase);
86 CloseLibrary(csd->oopbase);
89 FreeVec(csd);
90 lh->hdg_csd = NULL;
94 ReturnInt("SerialHIDD_Init", ULONG, FALSE);
99 void SAVEDS STDARGS LC_BUILDNAME(L_ExpungeLib) (LC_LIBHEADERTYPEPTR lh)
101 EnterFunc(bug("SerialHIDD_Expunge()\n"));
103 if(lh->hdg_csd)
105 free_serialhiddclass(lh->hdg_csd);
107 CloseLibrary(lh->hdg_csd->utilitybase);
108 CloseLibrary(lh->hdg_csd->oopbase);
110 FreeVec(lh->hdg_csd);
113 ReturnVoid("SerialHIDD_Expunge");