2 Copyright © 1995-2012, 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)", 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
)
164 struct MonitorNode
*node
;
166 D(bug("[LoadMonDrvs] Loading monitor drivers...\n"));
167 D(bug(" Pri Name\n"));
169 ForeachNode(monitorsList
, node
)
171 D(bug("%4d %s\n", node
->n
.ln_Pri
, node
->Name
));
172 Execute(node
->Name
, BNULL
, BNULL
);
175 D(bug("--------------------------\n"));
178 AROS_SH2H(AROSMonDrvs
, 1.0, "Load AROS Monitor and Compositor drivers",
179 AROS_SHAH(BOOL
, , NOCOMPOSITION
,/S
,FALSE
, "Only load Monitors"),
180 AROS_SHAH(BOOL
, , ONLYCOMPOSITION
,/S
,FALSE
, "Only load Compositor"))
185 struct Library
*IconBase
;
189 dir
= Lock(MONITORS_DIR
, SHARED_LOCK
);
190 D(bug("[LoadMonDrvs] Monitors directory 0x%p\n", dir
));
193 olddir
= CurrentDir(dir
);
195 if (!SHArg(NOCOMPOSITION
))
197 /* Software composition driver is ran first */
198 D(bug("[LoadMonDrvs] Loading composition driver...\n"));
199 Execute(COMPOSITING_NAME
, BNULL
, BNULL
);
202 if (!SHArg(ONLYCOMPOSITION
))
204 pool
= CreatePool(MEMF_ANY
, sizeof(struct MonitorNode
) * 10, sizeof(struct MonitorNode
) * 5);
205 DB2(bug("[LoadMonDrvs] Created pool 0x%p\n", pool
));
208 struct List MonitorsList
;
210 NewList(&MonitorsList
);
211 IconBase
= OpenLibrary("icon.library", 0);
214 findMonitors(&MonitorsList
, DOSBase
, IconBase
, SysBase
, pool
);
215 loadMonitors(&MonitorsList
, DOSBase
);
216 CloseLibrary(IconBase
);