2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
5 Initialization of workbench.library.
9 #include <aros/debug.h>
10 #include <aros/atomic.h>
11 #include <aros/symbolsets.h>
13 #include "workbench_intern.h"
14 #include LC_LIBDEFS_FILE
18 static int WBInit(LIBBASETYPEPTR LIBBASE
)
20 /* Make sure that the libraries are opened in L_OpenLib() --------------*/
21 WorkbenchBase
->wb_Initialized
= FALSE
;
23 /* Initialize our private lists ----------------------------------------*/
24 NEWLIST(&(WorkbenchBase
->wb_AppWindows
));
25 NEWLIST(&(WorkbenchBase
->wb_AppIcons
));
26 NEWLIST(&(WorkbenchBase
->wb_AppMenuItems
));
27 NEWLIST(&(WorkbenchBase
->wb_HiddenDevices
));
29 /* Initialize our semaphores -------------------------------------------*/
30 InitSemaphore(&(WorkbenchBase
->wb_WorkbenchPortSemaphore
));
31 InitSemaphore(&(WorkbenchBase
->wb_InitializationSemaphore
));
32 InitSemaphore(&(WorkbenchBase
->wb_BaseSemaphore
));
34 /* Initialize handler message port -------------------------------------*/
35 WorkbenchBase
->wb_HandlerPort
.mp_SigBit
= SIGBREAKB_CTRL_F
;
36 WorkbenchBase
->wb_HandlerPort
.mp_SigTask
= NULL
;
37 WorkbenchBase
->wb_HandlerPort
.mp_Flags
= PA_IGNORE
;
38 NEWLIST(&(WorkbenchBase
->wb_HandlerPort
.mp_MsgList
));
40 #warning "TODO: DefaultStackSize should differ depending on the platform AROS is compiled for"
41 /* Initialize miscellanous variables -----------------------------------*/
42 WorkbenchBase
->wb_DefaultStackSize
= 1024 * 32; /* 32kiB */ // FIXME: also read from preferences */
43 D(bug("[WBLIB] WBInit: Using %d Bytes for DefaultStackSize\n", WorkbenchBase
->wb_DefaultStackSize
));
48 static int WBOpen(LIBBASETYPEPTR LIBBASE
)
50 ObtainSemaphore(&(WorkbenchBase
->wb_InitializationSemaphore
));
52 if (!(WorkbenchBase
->wb_Initialized
))
54 struct CommandLineInterface
*cli
;
56 /* Duplicate the search path ---------------------------------------*/
57 if ((cli
= Cli()) != NULL
)
59 WorkbenchBase
->wb_SearchPath
= DuplicateSearchPath
65 const struct TagItem tags
[]=
67 {NP_Entry
, (IPTR
)WorkbenchHandler
},
68 {NP_Name
, (IPTR
)"Workbench Handler" },
69 {NP_UserData
, (IPTR
)WorkbenchBase
},
70 {NP_StackSize
, 8129 },
74 /* Start workbench handler -----------------------------------------*/
75 if ((CreateNewProc(tags
)) != NULL
)
77 /* Prevent expunging while the handler is running */
78 AROS_ATOMIC_INC(WorkbenchBase
->LibNode
.lib_OpenCnt
);
82 // FIXME: free resources
86 WorkbenchBase
->wb_Initialized
= TRUE
;
89 ReleaseSemaphore(&(WorkbenchBase
->wb_InitializationSemaphore
));
94 ADD2INITLIB(WBInit
, 0);
95 ADD2OPENLIB(WBOpen
, 0);