2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Code that loads and initializes necessary HIDDs.
11 #include <aros/debug.h>
12 #include <dos/dosextens.h>
13 #include <workbench/icon.h>
14 #include <proto/alib.h>
15 #include <proto/exec.h>
16 #include <proto/dos.h>
17 #include <proto/icon.h>
19 #include <aros/shcommands.h>
24 #define MONITORS_DIR "DEVS:Monitors"
25 #define COMPOSITING_NAME "Compositor"
27 /************************************************************************/
29 /* This code does almost the same thing as C:LoadMonDrvs does on other systems.
30 However, additionally we support priority-based sorting for display drivers.
31 This is needed in order to make monitor ID assignment more predictable */
39 static BYTE
checkIcon(STRPTR name
, struct Library
*IconBase
)
42 struct DiskObject
*dobj
= GetDiskObject(name
);
47 if ((dobj
->do_Type
== WBTOOL
) || (dobj
->do_Type
== WBPROJECT
))
49 const STRPTR
*toolarray
= (const STRPTR
*)dobj
->do_ToolTypes
;
52 if ((s
= FindToolType(toolarray
, "STARTPRI")))
65 static BOOL
findMonitors(struct List
*monitorsList
, struct DosLibrary
*DOSBase
, struct Library
*IconBase
, struct ExecBase
*SysBase
, APTR poolmem
)
69 struct AnchorPath
*ap
= AllocPooled(poolmem
, sizeof(struct AnchorPath
));
71 DB2(bug("[LoadMonDrvs] AnchorPath 0x%p\n", ap
));
74 /* Initialize important fields in AnchorPath, especially
75 ap_Strlen (prevents memory trashing) */
80 error
= MatchFirst("~(#?.info)", ap
);
83 struct MonitorNode
*newnode
;
85 DB2(bug("[LoadMonDrvs] Found monitor name %s\n", ap
->ap_Info
.fib_FileName
));
87 /* Software composition driver was loaded before */
88 if (strcmp(ap
->ap_Info
.fib_FileName
, COMPOSITING_NAME
))
90 newnode
= AllocPooled(poolmem
, sizeof(struct MonitorNode
) + strlen(ap
->ap_Info
.fib_FileName
));
91 DB2(bug("[LoadMonDrvs] Monitor node 0x%p\n", newnode
));
98 strcpy(newnode
->Name
, ap
->ap_Info
.fib_FileName
);
100 newnode
->n
.ln_Pri
= checkIcon(ap
->ap_Info
.fib_FileName
, IconBase
);
102 newnode
->n
.ln_Pri
= 0;
103 Enqueue(monitorsList
, &newnode
->n
);
106 error
= MatchNext(ap
);
109 if (error
!= ERROR_NO_MORE_ENTRIES
)
112 /* FIXME: Why no MatchEnd() in this case?
123 static void loadMonitors(struct List
*monitorsList
, struct DosLibrary
*DOSBase
)
125 struct MonitorNode
*node
;
127 D(bug("[LoadMonDrvs] Loading monitor drivers...\n"));
128 D(bug(" Pri Name\n"));
130 ForeachNode(monitorsList
, node
)
132 D(bug("%4d %s\n", node
->n
.ln_Pri
, node
->Name
));
133 Execute(node
->Name
, BNULL
, BNULL
);
136 D(bug("--------------------------\n"));
139 AROS_SH2H(AROSMonDrvs
, 1.0, "Load AROS Monitor and Compositor drivers",
140 AROS_SHAH(BOOL
, , NOCOMPOSITION
,/S
,FALSE
, "Only load Monitors"),
141 AROS_SHAH(BOOL
, , ONLYCOMPOSITION
,/S
,FALSE
, "Only load Compositor"))
146 struct Library
*IconBase
;
149 IPTR args
[2] = {FALSE
, FALSE
};
151 dir
= Lock(MONITORS_DIR
, SHARED_LOCK
);
152 D(bug("[LoadMonDrvs] Monitors directory 0x%p\n", dir
));
155 olddir
= CurrentDir(dir
);
159 /* Software composition driver is ran first */
160 D(bug("[LoadMonDrvs] Loading composition driver...\n"));
161 Execute(COMPOSITING_NAME
, BNULL
, BNULL
);
166 pool
= CreatePool(MEMF_ANY
, sizeof(struct MonitorNode
) * 10, sizeof(struct MonitorNode
) * 5);
167 DB2(bug("[LoadMonDrvs] Created pool 0x%p\n", pool
));
170 struct List MonitorsList
;
172 NewList(&MonitorsList
);
173 IconBase
= OpenLibrary("icon.library", 0);
176 findMonitors(&MonitorsList
, DOSBase
, IconBase
, SysBase
, pool
);
177 loadMonitors(&MonitorsList
, DOSBase
);
178 CloseLibrary(IconBase
);