added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / dos / dos_init.c
blob59cc130b3c8afeacafe02ee82fc68de7c9284d98
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 extern void DOSBoot(struct ExecBase *, struct DosLibrary *);
30 static int DosInit(LIBBASETYPEPTR LIBBASE)
32 D(bug("DosInit\n"));
34 __AROS_SETVECADDR(LIBBASE, 15, __AROS_GETVECADDR(LIBBASE, 6));
35 __AROS_SETVECADDR(LIBBASE, 62, __AROS_GETVECADDR(LIBBASE, 16));
36 __AROS_SETVECADDR(LIBBASE, 65, __AROS_GETVECADDR(LIBBASE, 17));
37 __AROS_SETVECADDR(LIBBASE, 68, __AROS_GETVECADDR(LIBBASE, 67));
39 ULONG * taskarray;
40 struct DosInfo *dosinfo;
42 LIBBASE->dl_Root = (struct RootNode *)AllocMem(sizeof(struct RootNode),
43 MEMF_PUBLIC|MEMF_CLEAR);
44 dosinfo = AllocMem(sizeof(struct DosInfo), MEMF_PUBLIC|MEMF_CLEAR);
46 /* Init the RootNode structure */
47 taskarray = (ULONG *)AllocMem(sizeof(ULONG) + sizeof(APTR), MEMF_CLEAR);
48 taskarray[0] = 1;
49 LIBBASE->dl_Root->rn_TaskArray = MKBADDR(taskarray);
50 LIBBASE->dl_Root->rn_Info= MKBADDR(dosinfo);
52 NEWLIST((struct List *)&LIBBASE->dl_Root->rn_CliList);
53 InitSemaphore(&LIBBASE->dl_Root->rn_RootLock);
55 InitSemaphore(&dosinfo->di_DevLock);
56 InitSemaphore(&dosinfo->di_EntryLock);
57 InitSemaphore(&dosinfo->di_DeleteLock);
59 /* Initialize for the fools that illegally used this field */
60 LIBBASE->dl_UtilityBase = (struct Library*) UtilityBase;
62 LIBBASE->dl_IntuitionBase = NULL;
64 #if AROS_MODULES_DEBUG
66 extern struct MinList debug_seglist, free_debug_segnodes;
68 static struct debug_segnode debug_segnode_array[4096];
69 int i;
71 NEWLIST(&free_debug_segnodes);
72 NEWLIST(&debug_seglist);
74 for (i = 0; i < sizeof(debug_segnode_array)/sizeof(debug_segnode_array[0]); i++)
76 ADDTAIL(&free_debug_segnodes, &debug_segnode_array[i]);
79 #endif
82 /* iaint:
83 I know this is bad, but I also know that the timer.device
84 will never go away during the life of dos.library. I also
85 don't intend to make any I/O calls using this.
87 I also know that timer.device does exist in the device list
88 at this point in time.
90 I can't allocate a timerequest/MsgPort pair here anyway,
91 because I need a separate one for each caller to Delay()
94 struct MsgPort timermp;
96 timermp.mp_Node.ln_Succ = NULL;
97 timermp.mp_Node.ln_Pred = NULL;
98 timermp.mp_Node.ln_Type = NT_MSGPORT;
99 timermp.mp_Node.ln_Pri = 0;
100 timermp.mp_Node.ln_Name = NULL;
101 timermp.mp_Flags = PA_SIGNAL;
102 timermp.mp_SigBit = SIGB_SINGLE;
103 timermp.mp_SigTask = FindTask(NULL);
104 NEWLIST(&timermp.mp_MsgList);
106 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Succ = NULL;
107 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Pred = NULL;
108 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
109 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Pri = 0;
110 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Node.ln_Name = NULL;
111 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_ReplyPort = &timermp;
112 LIBBASE->dl_TimerIO.tr_node.io_Message.mn_Length = sizeof(struct timerequest);
115 SetSignal(0, SIGF_SINGLE);
117 if(OpenDevice("timer.device", UNIT_VBLANK,
118 &LIBBASE->dl_TimerIO.tr_node, 0) == 0)
120 LIBBASE->dl_TimerBase = LIBBASE->dl_TimerIO.tr_node.io_Device;
122 AddLibrary((struct Library *)LIBBASE);
124 /* This is where we start the RTC_AFTERDOS residents */
125 InitCode(RTF_AFTERDOS, 0);
128 Here we have to get the first node of the mountlist,
129 and we try and boot from it, (assign it to SYS:).
131 DOSBoot(SysBase, DOSBase);
133 /* We now restart the multitasking - this is done
134 automatically by RemTask() when it switches.
136 RemTask(NULL);
138 Alert(AT_DeadEnd | AG_OpenDev | AN_DOSLib | AO_TimerDev);
141 return FALSE;
144 ADD2INITLIB(DosInit, 0);