add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / arch / .unmaintained / m68k-pp-native / Drivers / display.hidd / display_init.c
blobbac455818151b1f3a5d2d935997fab50a3fa717e
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: display Hidd for standalone palm AROS
6 Lang: english
7 */
9 #define __OOP_NOATTRBASES__
11 #include <exec/types.h>
12 #include <exec/lists.h>
13 #include <proto/exec.h>
14 #include <proto/oop.h>
15 #include <oop/oop.h>
16 #include <utility/utility.h>
18 #include "display.h"
19 #include "displayclass.h"
21 #undef SysBase
23 /* Customize libheader.c */
24 #define LC_SYSBASE_FIELD(lib) (((LIBBASETYPEPTR )(lib))->sysbase)
25 #define LC_SEGLIST_FIELD(lib) (((LIBBASETYPEPTR )(lib))->seglist)
26 #define LC_RESIDENTNAME displayHidd_resident
27 #define LC_RESIDENTFLAGS RTF_AUTOINIT|RTF_COLDSTART
28 #define LC_RESIDENTPRI 9
29 #define LC_LIBBASESIZE sizeof(LIBBASETYPE)
30 #define LC_LIBHEADERTYPEPTR LIBBASETYPEPTR
31 #define LC_LIB_FIELD(lib) (((LIBBASETYPEPTR)(lib))->library)
33 #define LC_NO_INITLIB
34 #define LC_NO_EXPUNGELIB
35 #define LC_NO_CLOSELIB
38 #define NOEXPUNGE
40 struct displaybase
42 struct Library library;
43 struct ExecBase *sysbase;
44 BPTR seglist;
47 extern struct DisplayModeDesc DisplayDefMode[];
49 #include <libcore/libheader.c>
51 #undef SDEBUG
52 #undef DEBUG
53 #define DEBUG 0
54 #include <aros/debug.h>
56 #define SysBase (LC_SYSBASE_FIELD(lh))
58 //#undef SysBase
59 #undef OOPBase
62 #define OOPBase xsd->oopbase
64 //static OOP_AttrBase HiddPixFmtAttrBase; // = 0;
65 #define AROS_CREATE_ROM_BUG 1
67 #ifndef AROS_CREATE_ROM_BUG
68 static struct OOP_ABDescr abd[] = {
69 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
70 { NULL, NULL }
72 #endif
74 static VOID freeclasses(struct display_staticdata *xsd);
76 static BOOL initclasses(struct display_staticdata *xsd)
79 /* Get some attrbases */
80 __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt);
82 #ifndef AROS_CREATE_ROM_BUG
83 if (!OOP_ObtainAttrBases(abd))
84 goto failure;
85 #endif
87 xsd->displayclass = init_displayclass(xsd);
88 if (NULL == xsd->displayclass)
89 goto failure;
91 xsd->onbmclass = init_onbmclass(xsd);
92 if (NULL == xsd->onbmclass)
93 goto failure;
95 xsd->offbmclass = init_offbmclass(xsd);
96 if (NULL == xsd->offbmclass)
97 goto failure;
99 return TRUE;
101 failure:
102 freeclasses(xsd);
104 return FALSE;
108 static VOID freeclasses(struct display_staticdata *xsd)
110 if (xsd->displayclass)
111 free_displayclass(xsd);
113 if (xsd->offbmclass)
114 free_offbmclass(xsd);
116 if (xsd->onbmclass)
117 free_onbmclass(xsd);
119 #ifndef AROS_CREATE_ROM_BUG
120 OOP_ReleaseAttrBases(abd);
121 #endif
123 return;
127 ULONG SAVEDS STDARGS LC_BUILDNAME(L_OpenLib) (LC_LIBHEADERTYPEPTR lh)
129 struct display_staticdata *xsd;
130 struct displayModeEntry *entry;
131 int i;
133 xsd = AllocMem( sizeof (struct display_staticdata), MEMF_CLEAR|MEMF_PUBLIC );
134 if (xsd)
136 xsd->sysbase = SysBase;
137 xsd->displaybase = lh;
139 InitSemaphore(&xsd->sema);
140 InitSemaphore(&xsd->HW_acc);
141 NEWLIST(&xsd->modelist);
143 /* Insert default videomodes */
145 for (i=0; i<NUM_MODES; i++)
147 entry = AllocMem(sizeof(struct DisplayModeEntry),MEMF_CLEAR|MEMF_PUBLIC);
148 if (entry)
150 // entry->Desc=&(DisplayDefMode[i]);
151 ADDHEAD(&xsd->modelist,entry);
152 D(bug("Added default mode: %s\n", entry->Desc->name));
156 xsd->oopbase = OpenLibrary(AROSOOP_NAME, 0);
157 if (xsd->oopbase)
160 xsd->utilitybase = OpenLibrary(UTILITYNAME, 37);
161 if (xsd->utilitybase)
163 if (initclasses(xsd))
165 D(bug("Everything OK\n"));
166 return TRUE;
168 CloseLibrary(xsd->utilitybase);
170 CloseLibrary(xsd->oopbase);
172 if (entry) FreeMem(entry, sizeof(struct DisplayModeEntry));
173 FreeMem(xsd, sizeof (struct display_staticdata));
175 return FALSE;