2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: Code that loads and initializes necessary HIDDs.
9 /******************************************************************************
18 NOCOMPOSITION/S,ONLYCOMPOSITION/S
26 This command does almost the same thing as C:LoadMonDrvs does on
27 other systems. However, additionally we support priority-based
28 sorting for display drivers. This is needed in order to make monitor
29 ID assignment more predictable.
33 NOCOMPOSITION -- Only load Monitors
34 ONLYCOMPOSITION -- Only load Compositor
50 ******************************************************************************/
54 #include <aros/debug.h>
55 #include <dos/dosextens.h>
56 #include <workbench/icon.h>
57 #include <proto/alib.h>
58 #include <proto/exec.h>
59 #include <proto/dos.h>
60 #include <proto/icon.h>
62 #include <aros/shcommands.h>
67 #define MONITORS_DIR "DEVS:Monitors"
68 #define COMPOSITING_NAME "Compositor"
70 /************************************************************************/
78 static BYTE
checkIcon(STRPTR name
, struct Library
*IconBase
)
81 struct DiskObject
*dobj
= GetDiskObject(name
);
86 if ((dobj
->do_Type
== WBTOOL
) || (dobj
->do_Type
== WBPROJECT
))
88 const STRPTR
*toolarray
= (const STRPTR
*)dobj
->do_ToolTypes
;
91 if ((s
= FindToolType(toolarray
, "STARTPRI")))
104 static BOOL
findMonitors(struct List
*monitorsList
, struct DosLibrary
*DOSBase
, struct Library
*IconBase
, struct ExecBase
*SysBase
, APTR poolmem
)
106 BOOL retvalue
= TRUE
;
108 struct AnchorPath
*ap
= AllocPooled(poolmem
, sizeof(struct AnchorPath
));
110 DB2(bug("[LoadMonDrvs] AnchorPath 0x%p\n", ap
));
113 /* Initialize important fields in AnchorPath, especially
114 ap_Strlen (prevents memory trashing) */
117 ap
->ap_BreakBits
= 0;
119 error
= MatchFirst("~((#?.info)|(#?.dbg))", ap
);
122 struct MonitorNode
*newnode
;
124 DB2(bug("[LoadMonDrvs] Found monitor name %s\n", ap
->ap_Info
.fib_FileName
));
126 /* Software composition driver was loaded before */
127 if (strcmp(ap
->ap_Info
.fib_FileName
, COMPOSITING_NAME
))
129 newnode
= AllocPooled(poolmem
, sizeof(struct MonitorNode
) + strlen(ap
->ap_Info
.fib_FileName
));
130 DB2(bug("[LoadMonDrvs] Monitor node 0x%p\n", newnode
));
137 strcpy(newnode
->Name
, ap
->ap_Info
.fib_FileName
);
139 newnode
->n
.ln_Pri
= checkIcon(ap
->ap_Info
.fib_FileName
, IconBase
);
141 newnode
->n
.ln_Pri
= 0;
142 Enqueue(monitorsList
, &newnode
->n
);
145 error
= MatchNext(ap
);
148 if (error
!= ERROR_NO_MORE_ENTRIES
)
151 /* FIXME: Why no MatchEnd() in this case?
162 static void loadMonitors(struct List
*monitorsList
, struct DosLibrary
*DOSBase
,
163 struct ExecBase
*SysBase
)
165 struct MonitorNode
*node
;
167 D(bug("[LoadMonDrvs] Loading monitor drivers...\n"));
168 D(bug(" Pri Name\n"));
170 ForeachNode(monitorsList
, node
)
172 D(bug("%4d %s\n", node
->n
.ln_Pri
, node
->Name
));
173 Execute(node
->Name
, BNULL
, BNULL
);
176 D(bug("--------------------------\n"));
179 AROS_SH2H(AROSMonDrvs
, 1.0, "Load AROS Monitor and Compositor drivers",
180 AROS_SHAH(BOOL
, , NOCOMPOSITION
,/S
,FALSE
, "Only load Monitors"),
181 AROS_SHAH(BOOL
, , ONLYCOMPOSITION
,/S
,FALSE
, "Only load Compositor"))
186 struct Library
*IconBase
;
190 dir
= Lock(MONITORS_DIR
, SHARED_LOCK
);
191 D(bug("[LoadMonDrvs] Monitors directory 0x%p\n", dir
));
194 olddir
= CurrentDir(dir
);
196 if (!SHArg(NOCOMPOSITION
))
198 /* Software composition driver is run first */
199 D(bug("[LoadMonDrvs] Loading composition driver...\n"));
200 Execute(COMPOSITING_NAME
, BNULL
, BNULL
);
203 if (!SHArg(ONLYCOMPOSITION
))
205 pool
= CreatePool(MEMF_ANY
, sizeof(struct MonitorNode
) * 10, sizeof(struct MonitorNode
) * 5);
206 DB2(bug("[LoadMonDrvs] Created pool 0x%p\n", pool
));
209 struct List MonitorsList
;
211 NewList(&MonitorsList
);
212 IconBase
= OpenLibrary("icon.library", 0);
215 findMonitors(&MonitorsList
, DOSBase
, IconBase
, SysBase
, pool
);
216 loadMonitors(&MonitorsList
, DOSBase
, SysBase
);
217 CloseLibrary(IconBase
);