2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Sets up the ExecBase a bit. (Mostly clearing).
10 #include <exec/types.h>
11 #include <exec/lists.h>
12 #include <exec/memory.h>
13 #include <exec/memheaderext.h>
14 #include <exec/resident.h>
15 #include <exec/execbase.h>
16 #include <exec/libraries.h>
17 #include <aros/arossupportbase.h>
18 #include <aros/asmcall.h>
21 #include <proto/exec.h>
23 #include LC_LIBDEFS_FILE
25 #include "exec_intern.h"
27 #undef kprintf /* This can't be used in the code here */
29 extern void *LIBFUNCTABLE
[];
31 extern struct Library
* PrepareAROSSupportBase (struct ExecBase
*);
32 extern struct Resident Exec_resident
; /* Need this for lib_IdString */
33 extern void AROS_SLIB_ENTRY(CacheClearU
,Exec
)();
34 AROS_UFP1(void, Exec_TrapHandler
,
35 AROS_UFPA(struct ExecBase
*, SysBase
, A6
)
37 AROS_UFP1(void, Exec_TaskFinaliser
,
38 AROS_UFPA(struct ExecBase
*, SysBase
, A6
)
41 extern void AROS_SLIB_ENTRY(TrapHandler
,Exec
)();
42 extern void AROS_SLIB_ENTRY(TaskFinaliser
,Exec
)();
44 static APTR
allocmem(struct MemHeader
*mh
, ULONG size
)
48 if (mh
->mh_Attributes
& MEMF_MANAGED
)
50 struct MemHeaderExt
*mhe
= (struct MemHeaderExt
*)mh
;
52 ret
= mhe
->mhe_Alloc(mhe
, size
, NULL
);
56 size
= (size
+ MEMCHUNK_TOTAL
-1) & ~(MEMCHUNK_TOTAL
-1);
57 ret
= (UBYTE
*)mh
->mh_First
;
59 mh
->mh_First
= (struct MemChunk
*)(ret
+ size
);
60 mh
->mh_First
->mc_Next
= NULL
;
61 mh
->mh_Free
= mh
->mh_First
->mc_Bytes
62 = ((struct MemChunk
*)ret
)->mc_Bytes
- size
;
69 PrepareExecBase() will initialize the ExecBase to default values,
70 and not add anything yet (except for the MemHeader).
74 struct ExecBase
*PrepareExecBase(struct MemHeader
*mh
)
77 VOID
**fp
= LIBFUNCTABLE
;
80 Basically this does not get anything useful, but I still need to have
81 SysBase defined here...
85 /* Calculate the size of the vector table */
86 while (*fp
++ != (VOID
*) -1) negsize
+= LIB_VECTSIZE
;
88 /* Align library base */
89 negsize
= AROS_ALIGN(negsize
);
91 /* Allocate memory for library base */
92 SysBase
= (struct ExecBase
*)
93 ((UBYTE
*)allocmem(mh
, negsize
+ sizeof(struct ExecBase
)) + negsize
);
95 /* Clear the library base */
96 memset(SysBase
, 0, sizeof(struct ExecBase
));
98 /* Setup function vectors */
102 while(*fp
!= (VOID
*) -1)
104 /* Decrement vector pointer by one and install vector */
105 __AROS_INITVEC(SysBase
, i
);
106 if (*fp
!= NULL
) __AROS_SETVECADDR(SysBase
, i
, *fp
);
108 /* Use next array entry */
113 AROS_LC0(void, CacheClearU
,
114 struct ExecBase
*, SysBase
, 106, Exec
);
116 SysBase
->LibNode
.lib_Node
.ln_Type
= NT_LIBRARY
;
117 SysBase
->LibNode
.lib_Node
.ln_Pri
= -100;
118 SysBase
->LibNode
.lib_Node
.ln_Name
= "exec.library";
119 SysBase
->LibNode
.lib_IdString
= Exec_resident
.rt_IdString
;
120 SysBase
->LibNode
.lib_Version
= VERSION_NUMBER
;
121 SysBase
->LibNode
.lib_Revision
= REVISION_NUMBER
;
122 SysBase
->LibNode
.lib_OpenCnt
= 1;
123 SysBase
->LibNode
.lib_NegSize
= negsize
;
124 SysBase
->LibNode
.lib_PosSize
= sizeof(struct ExecBase
);
125 SysBase
->LibNode
.lib_Flags
= 0;
127 NEWLIST(&SysBase
->MemList
);
128 SysBase
->MemList
.lh_Type
= NT_MEMORY
;
129 ADDHEAD(&SysBase
->MemList
, &mh
->mh_Node
);
131 NEWLIST(&SysBase
->ResourceList
);
132 SysBase
->ResourceList
.lh_Type
= NT_RESOURCE
;
134 NEWLIST(&SysBase
->DeviceList
);
135 SysBase
->DeviceList
.lh_Type
= NT_DEVICE
;
137 NEWLIST(&SysBase
->IntrList
);
138 SysBase
->IntrList
.lh_Type
= NT_INTERRUPT
;
140 NEWLIST(&SysBase
->LibList
);
141 SysBase
->LibList
.lh_Type
= NT_LIBRARY
;
142 ADDHEAD(&SysBase
->LibList
, &SysBase
->LibNode
.lib_Node
);
144 NEWLIST(&SysBase
->PortList
);
145 SysBase
->PortList
.lh_Type
= NT_MSGPORT
;
147 NEWLIST(&SysBase
->TaskReady
);
148 SysBase
->TaskReady
.lh_Type
= NT_TASK
;
150 NEWLIST(&SysBase
->TaskWait
);
151 SysBase
->TaskWait
.lh_Type
= NT_TASK
;
153 NEWLIST(&SysBase
->SemaphoreList
);
154 SysBase
->TaskWait
.lh_Type
= NT_SEMAPHORE
;
156 NEWLIST(&SysBase
->ex_MemHandlers
);
158 for (i
= 0; i
< 5; i
++)
160 NEWLIST(&SysBase
->SoftInts
[i
].sh_List
);
161 SysBase
->SoftInts
[i
].sh_List
.lh_Type
= NT_INTERRUPT
;
164 SysBase
->SoftVer
= VERSION_NUMBER
;
166 SysBase
->ColdCapture
= SysBase
->CoolCapture
167 = SysBase
->WarmCapture
170 SysBase
->SysStkUpper
= (APTR
)0xFFFFFFFF;
171 SysBase
->SysStkLower
= (APTR
)0x00000000;
173 SysBase
->MaxLocMem
= (ULONG
)mh
->mh_Upper
;
175 SysBase
->Quantum
= 4;
177 SysBase
->TaskTrapCode
= AROS_SLIB_ENTRY(TrapHandler
,Exec
);
178 SysBase
->TaskExceptCode
= NULL
;
179 SysBase
->TaskExitCode
= AROS_SLIB_ENTRY(TaskFinaliser
,Exec
);
180 SysBase
->TaskSigAlloc
= 0xFFFF;
181 SysBase
->TaskTrapAlloc
= 0;
183 SysBase
->VBlankFrequency
= 50;
184 SysBase
->PowerSupplyFrequency
= 1;
186 SysBase
->DebugAROSBase
= PrepareAROSSupportBase(SysBase
);