Add new strings.
[AROS.git] / rom / dos / dos_init.c
blobf38df7f5adfe5df5223e06d7e4e2bc67b5b4311b
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Header for dos.library
6 Lang: english
7 */
10 #include <exec/types.h>
11 #include <exec/execbase.h>
12 #include <exec/libraries.h>
13 #include <exec/alerts.h>
14 #include <exec/memory.h>
15 #include <exec/resident.h>
16 #include <proto/exec.h>
17 #include <aros/symbolsets.h>
18 #include <dos/dosextens.h>
19 #include <dos/dostags.h>
20 #include <proto/dos.h>
21 #include <proto/alib.h>
22 #include <proto/utility.h>
23 #include <utility/tagitem.h>
24 #include <aros/debug.h>
25 #include LC_LIBDEFS_FILE
26 #include "dos_intern.h"
28 static int DosInit(LIBBASETYPEPTR LIBBASE)
30 D(bug("DosInit\n"));
32 __AROS_SETVECADDR(LIBBASE, 15, __AROS_GETVECADDR(LIBBASE, 6));
33 __AROS_SETVECADDR(LIBBASE, 62, __AROS_GETVECADDR(LIBBASE, 16));
34 __AROS_SETVECADDR(LIBBASE, 65, __AROS_GETVECADDR(LIBBASE, 17));
35 __AROS_SETVECADDR(LIBBASE, 68, __AROS_GETVECADDR(LIBBASE, 67));
37 ULONG * taskarray;
38 struct DosInfo *dosinfo;
40 LIBBASE->dl_Root = (struct RootNode *)AllocMem(sizeof(struct RootNode),
41 MEMF_PUBLIC|MEMF_CLEAR);
42 dosinfo = AllocMem(sizeof(struct DosInfo), MEMF_PUBLIC|MEMF_CLEAR);
44 /* Init the RootNode structure */
45 taskarray = (ULONG *)AllocMem(sizeof(ULONG) + sizeof(APTR), MEMF_CLEAR);
46 taskarray[0] = 1;
47 LIBBASE->dl_Root->rn_TaskArray = MKBADDR(taskarray);
48 LIBBASE->dl_Root->rn_Info= MKBADDR(dosinfo);
50 NEWLIST((struct List *)&LIBBASE->dl_Root->rn_CliList);
51 InitSemaphore(&LIBBASE->dl_Root->rn_RootLock);
53 InitSemaphore(&dosinfo->di_DevLock);
54 InitSemaphore(&dosinfo->di_EntryLock);
55 InitSemaphore(&dosinfo->di_DeleteLock);
57 /* Initialize for the fools that illegally used this field */
58 LIBBASE->dl_UtilityBase = (struct Library*) UtilityBase;
60 LIBBASE->dl_IntuitionBase = NULL;
62 #if AROS_MODULES_DEBUG
64 extern struct MinList debug_seglist, free_debug_segnodes;
66 static struct debug_segnode debug_segnode_array[4096];
67 int i;
69 NEWLIST(&free_debug_segnodes);
70 NEWLIST(&debug_seglist);
72 for (i = 0; i < sizeof(debug_segnode_array)/sizeof(debug_segnode_array[0]); i++)
74 ADDTAIL(&free_debug_segnodes, &debug_segnode_array[i]);
77 #endif
80 /* iaint:
81 I know this is bad, but I also know that the timer.device
82 will never go away during the life of dos.library. I also
83 don't intend to make any I/O calls using this.
85 I also know that timer.device does exist in the device list
86 at this point in time.
88 I can't allocate a timerequest/MsgPort pair here anyway,
89 because I need a separate one for each caller to Delay()
92 struct MsgPort timermp;
94 timermp.mp_Node.ln_Succ = NULL;
95 timermp.mp_Node.ln_Pred = NULL;
96 timermp.mp_Node.ln_Type = NT_MSGPORT;
97 timermp.mp_Node.ln_Pri = 0;
98 timermp.mp_Node.ln_Name = NULL;
99 timermp.mp_Flags = PA_SIGNAL;
100 timermp.mp_SigBit = SIGB_SINGLE;
101 timermp.mp_SigTask = FindTask(NULL);
102 NEWLIST(&timermp.mp_MsgList);
104 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Succ = NULL;
105 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Pred = NULL;
106 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
107 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Pri = 0;
108 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Name = NULL;
109 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_ReplyPort = &timermp;
110 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Length = sizeof(struct timerequest);
113 SetSignal(0, SIGF_SINGLE);
115 if(OpenDevice("timer.device", UNIT_VBLANK,
116 &LIBBASE->dl_TimerIO.tr_node, 0) == 0)
118 LIBBASE->dl_TimerBase = LIBBASE->dl_TimerIO.tr_node.io_Device;
120 AddLibrary((struct Library *)LIBBASE);
122 /* This is where we start the RTC_AFTERDOS residents */
123 bug("[DOS] DosInit: InitCode(RTF_AFTERDOS)\n");
124 InitCode(RTF_AFTERDOS, 0);
126 /* We now restart the multitasking - this is done
127 automatically by RemTask() when it switches.
129 RemTask(NULL);
131 Alert(AT_DeadEnd | AG_OpenDev | AN_DOSLib | AO_TimerDev);
134 return FALSE;
137 ADD2INITLIB(DosInit, 0);