2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 #include <aros/config.h>
10 #include <exec/types.h>
11 #include <exec/nodes.h>
12 #include <exec/memory.h>
13 #include <exec/resident.h>
14 #include <exec/libraries.h>
15 #include <exec/execbase.h>
16 #include <proto/oop.h>
17 #include <proto/exec.h>
19 #include <devices/keyboard.h>
20 #define mybug(col,var) __asm__ __volatile__("move.l #"#col",0xf9002000+"#var"" :: );
21 //#define mybug(col,var)
23 #include <aros/debug.h>
24 #include <aros/core.h>
25 #include <asm/registers.h>
35 #include "exec_intern.h"
45 #define rkprintf(x...) scr_RawPutChars(tab, snprintf(tab,126, x))
47 extern void scr_RawPutChars(char *chr
, int lim
);
49 extern unsigned long _end
;
50 struct mac68k_init_stuff init_stuff
;
51 //extern struct init_stuff init_stuff;
53 extern struct ExecBase
* PrepareExecBase(struct MemHeader
*);
54 extern void switch_to_user_mode(void *, ULONG
*);
55 extern void main_init_cont(void);
56 extern struct MemHeader
* detect_memory(void);
57 extern void screen_init(void);
58 extern void fontinit(void);
59 void get_initial_epinfo(void);
62 unsigned long address
;
67 * Just to be sure all of these modules get linked into the
68 * final module, this structure should stay here, because
69 * otherwise the linker might not take it if there is no
70 * reference to a certain module at all.
72 extern const struct Resident
73 // Expansion_resident,
80 Mathieeesingbas_resident
,
92 hiddgraphics_resident
,
104 con_handler_resident
,
108 /* This list MUST be in the correct order (priority). */
109 static const struct Resident
*romtagList
[] =
111 // &Expansion_resident,
116 &Mathieeesingbas_resident
,
130 &hiddgraphics_resident
,
131 &displayHidd_resident
,
132 &hiddserial_resident
,
139 &con_handler_resident
143 /************************************************************************************/
145 void processor_init(void)
148 /************ CPU setup *******************/
149 /* switch to supervisor, Emile/Penguin already does it for us ? */
151 __asm__
__volatile__("oriw #0x0700,%%sr" :: );
155 __asm__
__volatile__ ( \
156 "move.l #0xf9000080,%%a0\n" \
158 "move.l 0x00ff00ff,(%%a0)+\n" \
164 /************************************************************************************/
165 extern ULONG initial_ssp
;
170 struct ExecBase
*SysBase
= NULL
;
172 UWORD
* rom_ranges
[] = {(UWORD
*)0x1000 , (UWORD
*)&_end
, (UWORD
*)~0};
173 struct MemHeader
* mh
= NULL
;
174 char *Processor_type
[] = { "68020", "68030", "68040", "68060" };
178 get_initial_epinfo();
181 rkprintf("AROS - The AROS Research OS - Mac68k\nCompiled %s\n\n",__DATE__
);
182 rkprintf("CPU: %s, MEM: %ld\n", Processor_type
[init_stuff
.cpu
], init_stuff
.mem
);
183 rkprintf("MacModel: %ld\nVidBase: 0x%lx, VidDepth: %ld, ScreenWidth: %ld, ScreenHeight: %ld\n", \
184 init_stuff
.model
, init_stuff
.vidaddr
, init_stuff
.viddepth
, init_stuff
.vidwidth
, init_stuff
.vidheight
);
194 * create entry for first chunk of system mem with information from the bootloader
197 #define MEM_START ((unsigned long)&_end + 0x10000)
199 rkprintf("MEM_START: 0x%lx\n, memchunksize[0]: 0x%lx\n", MEM_START
, init_stuff
.memchunksize
[0]);
201 mh
=(struct MemHeader
*)MEM_START
;
202 mh
->mh_Node
.ln_Succ
= NULL
;
203 mh
->mh_Node
.ln_Pred
= NULL
;
204 mh
->mh_Node
.ln_Type
= NT_MEMORY
;
205 mh
->mh_Node
.ln_Name
= "chip memory";
206 mh
->mh_Node
.ln_Pri
= -5;
207 mh
->mh_Attributes
= MEMF_CHIP
| MEMF_PUBLIC
| MEMF_LOCAL
| MEMF_24BITDMA
|
209 mh
->mh_First
= (struct MemChunk
*)((UBYTE
*)mh
+MEMHEADER_TOTAL
);
210 mh
->mh_First
->mc_Next
= NULL
;
211 mh
->mh_First
->mc_Bytes
= ((ULONG
) init_stuff
.memchunksize
[0] - MEM_START
) - MEMHEADER_TOTAL
;
213 mh
->mh_Lower
= mh
->mh_First
;
214 mh
->mh_Upper
= (APTR
)(init_stuff
.memchunksize
[0]);
215 mh
->mh_Free
= mh
->mh_First
->mc_Bytes
;
218 We have to put somewhere in this function checking for ColdStart,
219 CoolStart and many other Exec vectors!
223 It is OK to place ExecBase here. Remember that interrupt table starts
224 at 0x0100UL address, so 4UL is quite safe.
225 Even with MP this addr is OK for ExecBase. We may write an int handler
226 which detects "read from 4UL" commands.
229 rkprintf("PrepareExecBase\n");
230 SysBase
= (struct ExecBase
*)PrepareExecBase(mh
);
231 rkprintf("SysBase = 4\n");
232 *(APTR
*)0x4 = SysBase
;
235 Setup ChkBase (checksum for base ptr), ChkSum (for library)
236 SysBase+ChkBase should be -1 otherwise somebody has destroyed ExecBase!
238 SysBase
->ChkBase
=~(ULONG
)SysBase
;
239 #warning TODO: SysBase->ChkSum=.....
241 if(NULL
== AllocAbs(&_end
-0x1000+0x10000,(APTR
)0x1000))
243 rkprintf("Kernel protection failed !!\n");
246 if (NULL
== (m68k_USP
=(ULONG
*)AllocMem(AROS_STACKSIZE
,MEMF_PUBLIC
))) {
249 m68k_USP
= (ULONG
*)(((ULONG
)m68k_USP
) + AROS_STACKSIZE
);
250 rkprintf("USP alloc\n");
253 * Allocate memory for the SSP. The SSP is already set
254 * but I need to AllocAbs() it so nobody else will step on this
258 if (NULL
== AllocAbs(AROS_STACKSIZE
,
259 (APTR
)(initial_ssp
+sizeof(ULONG
)-AROS_STACKSIZE
))) {
260 D(bug("Alloc for SSP failed!\n"));
262 D(bug("SSP: %x\n",initial_ssp
));
264 //SysBase->ResModules=Exec_RomTagScanner(SysBase, rom_ranges);
266 rkprintf("init core\n");
271 rkprintf("Init traps\n");
274 * This is the last place where I am in supervisor mode.
275 * so let me switch into user mode and continue there.
276 * The user mode function will then call main_init_cont.
278 rkprintf("going to UserMode\n");
279 switch_to_user_mode(main_init_cont
, m68k_USP
);
282 void get_initial_epinfo(void)
284 struct ep_entry
*epinfo
= (struct ep_entry
*)&_end
;
287 while(epinfo
->tag
!= EP_LAST
)
292 init_stuff
.vidaddr
= epinfo
->data
[0];
295 init_stuff
.viddepth
= epinfo
->data
[0];
298 init_stuff
.vidrow
= epinfo
->data
[0];
301 init_stuff
.vidwidth
= epinfo
->data
[0] & 0xffff;
302 init_stuff
.vidheight
= epinfo
->data
[0] >> 16;
305 init_stuff
.model
= epinfo
->data
[0];
308 init_stuff
.cpu
= epinfo
->data
[0];
311 init_stuff
.mem
= epinfo
->data
[0];
314 init_stuff
.memchunk
[memchunks
] = epinfo
->data
[0];
315 init_stuff
.memchunksize
[memchunks
] = epinfo
->data
[1];
321 epinfo
= (struct ep_entry
*)((unsigned long)epinfo
+epinfo
->size
);
325 * The following function will be executed when AROS is in user mode
327 void main_init_cont(void)
329 InitCode(RTF_SINGLETASK
, 0);
332 All done. In normal cases CPU should never reach this point
335 *(ULONG
*)0xc0debad0 = 0;