Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / workbench / workbench_init.c
blobd4232230dd21a5b331a82aa6d178cab3ad47c2d9
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 Initialization of workbench.library.
6 */
8 #define DEBUG 0
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
15 #include "handler.h"
16 #include "support.h"
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));
45 return TRUE;
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
61 cli->cli_CommandDir
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 },
71 {TAG_DONE , 0 }
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);
80 else
82 // FIXME: free resources
83 return FALSE;
86 WorkbenchBase->wb_Initialized = TRUE;
89 ReleaseSemaphore(&(WorkbenchBase->wb_InitializationSemaphore));
91 return TRUE;
92 } /* L_OpenLib */
94 ADD2INITLIB(WBInit, 0);
95 ADD2OPENLIB(WBOpen, 0);