2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 #include <aros/config.h>
11 #include <exec/types.h>
12 #include <exec/nodes.h>
13 #include <exec/memory.h>
14 #include <exec/resident.h>
15 #include <exec/libraries.h>
16 #include <exec/execbase.h>
17 #include <proto/oop.h>
18 #include <proto/exec.h>
20 #include <devices/keyboard.h>
23 #include <aros/debug.h>
24 #include <aros/core.h>
25 #include <asm/registers.h>
32 #include "exec_intern.h"
35 #include "arm_exec_internal.h"
39 * local static functions.
41 static void main_init_cont(void);
45 * Just to be sure all of these modules get linked into the
46 * final module, this structure should stay here, because
47 * otherwise the linker might not take it if there is no
48 * reference to a certain module at all.
50 extern const struct Resident
57 Mathieeesingbas_resident
,
69 hiddgraphics_resident
,
84 cram_handler_resident
,
89 /* This list MUST be in the correct order (priority). */
90 static const struct Resident
*romtagList
[] =
96 &Mathieeesingbas_resident
,
102 &Timer_resident
, // CRASHES
108 &Input_resident
, // CRASHES
109 &Intuition_resident
, // CRASHES
110 // &hiddgraphics_resident,
111 // &displayHidd_resident,
112 &hiddserial_resident
,
113 // &Console_resident, // CRASHES
119 &con_handler_resident
,
120 &ram_handler_resident
,
121 &nil_handler_resident
,
122 // &cram_handler_resident
125 /************************************************************************************/
127 void processor_init(void)
129 /************ CPU setup *******************/
131 /*** Turn MMU off *************************/
133 /* cannot do that... */
134 __asm__
__volatile__ ("mov %%r0,#(0x2|0x10|0x20)\n\t
135 mrc p15,0,%%r1,c1,c0,0\n\t
137 mcr p15,0,%%r1,c1,c0,0\n\t" \
142 /*** Turn caching off (for now) ***********/
143 __asm__
__volatile__ ("nop \n\t
144 mrc p15,0,r0,c1,c0,0\n\t
146 mcr p15,0,r0,c1,c0,0\n\t" \
150 /*** Do not allow interrupts */
152 /************ LCD Controller **************/
154 * Turn the LCD controller on
157 /************* Interrupt Controller **********/
162 /************** OS Timer *********************/
164 WREG_L(OSMR0
) = 3686400 / 2 ;
169 WREG_L(OIER
) = 0x0; // disable timers
172 /************* Memory Controller *************/
175 /************************************************************************************/
177 #define DO_SERIAL_DEBUG
179 #ifdef DO_SERIAL_DEBUG
180 static void init_serial(void)
183 * Set the UART3 to 115200 baud
195 /*static*/ void print_ser(char * string
)
198 while (0 != string
[i
]) {
200 volatile ULONG utsr1
;
202 utsr1
= RREG_L(UTSR1
);
204 } while ((0 == (utsr1
& 0x04)) && (j
< 1000000));
205 WREG_L(UTDR
) = (ULONG
)string
[i
];
210 void print_serial(char * string
)
217 /************************************************************************************/
219 void mmu_lookup(ULONG addr
, struct ExecBase
* SysBase
)
221 ULONG
* ttb
= (ULONG
*)(get_cp15_r2() & 0xffffc000);
223 D(bug("translation table base at %p\n",ttb
));
224 ttb
= (ULONG
*)((ULONG
)ttb
| ((addr
& 0xfff00000) >> 18));
225 D(bug("first level descriptor for address %p at %p (%p)\n",addr
,*ttb
,ttb
));
227 D(bug("Content of first level descriptor: %x\n",*fld
));
228 if (0x2 == ((*fld
) & 0x2)) {
229 D(bug("This is a section entry!\n"));
230 D(bug("B : %x\n",(*fld
>> 2) & 1 ));
231 D(bug("C : %x\n",(*fld
>> 3) & 1 ));
232 D(bug("AP: %x\n",(*fld
>> 10) & 3 ));
233 D(bug("Section base address: %x\n",(*fld
) & 0xfff00000 ));
234 } else if (0x1 == ((*fld
) & 0x2)) {
235 D(bug("This is a page entry\n"));
237 D(bug("Wrong entry!?\n"));
241 /************************************************************************************/
242 extern ULONG initial_ssp
;
244 extern ULONG _binary_rom_disk_start
;
249 ULONG
* arm_SP_User
= 0xbad0c0de;
250 ULONG
* arm_SP_IRQ
= 0xbad0c0de;
251 ULONG
* arm_SP_FIQ
= 0xbad0c0de;
252 ULONG
* arm_SP_Abort
= 0xbad0c0de;
253 ULONG
* arm_SP_Undef
= 0xbad0c0de;
255 UWORD
* rom_ranges
[] = {(UWORD
*)0xc0000000 , (UWORD
*)0xc0000000 + (2 * 1024 * 1024),
258 UWORD
* rom_ranges
[] = {(UWORD
*)0x90000 , (UWORD
*)0xfff00,
261 #define MAX_MEM_HEADERS 10
262 struct MemHeader
* mh
= NULL
;
265 #ifdef DO_SERIAL_DEBUG
267 print_serial("Serial Port initialized!\n");
271 * detect memory of the system
273 print_serial("Detecting memory now\n");
274 mh
= detect_memory();
277 We have to put somewhere in this function checking for ColdStart,
278 CoolStart and many other Exec vectors!
282 It is OK to place ExecBase here. Remember that interrupt table starts
283 at 0x0100UL address, so 4UL is quite safe.
284 Even with MP this addr is OK for ExecBase. We may write an int handler
285 which detects "read from 4UL" commands.
287 print_serial("preparing execbase now\n");
289 PrepareExecBase(mh
, NULL
);
290 *(APTR
*)0x4 = SysBase
;
292 * Detect the rest of the memory...
294 print_serial("detecting rest of memory now\n");
295 detect_memory_rest(SysBase
);
298 Setup ChkBase (checksum for base ptr), ChkSum (for library)
299 SysBase+ChkBase should be -1 otherwise somebody has destroyed ExecBase!
301 SysBase
->ChkBase
=~(ULONG
)SysBase
;
302 #warning TODO: SysBase->ChkSum=.....
304 if (NULL
== (arm_SP_User
=(ULONG
*)AllocMem(AROS_STACKSIZE
,MEMF_PUBLIC
))) {
307 arm_SP_User
= (ULONG
*)(((ULONG
)arm_SP_User
) + AROS_STACKSIZE
);
310 * Allocate memory for the SSP. The SSP is already set
311 * but I need to AllocAbs() it so nobody else will step on this
315 if (NULL
== AllocAbs(AROS_STACKSIZE
,
316 (APTR
)(initial_ssp
+sizeof(ULONG
)-AROS_STACKSIZE
))) {
317 D(bug("Alloc for SSP failed!\n"));
319 D(bug("SSP: %x\n",initial_ssp
));
321 D(bug("Now running the romtagscanner!\n"));
322 SysBase
->ResModules
=Exec_RomTagScanner(SysBase
, rom_ranges
);
327 D(bug("init core now\n"));
330 // D(bug("init traps now\n"));
333 if (NULL
== (arm_SP_IRQ
=(ULONG
*)AllocMem(AROS_STACKSIZE
,MEMF_PUBLIC
))) {
336 arm_SP_IRQ
= (ULONG
*)(((ULONG
)arm_SP_IRQ
) + AROS_STACKSIZE
- sizeof(ULONG
));
337 D(bug("Now setting IRQ Stackpointer! %x\n",arm_SP_IRQ
));
338 set_sp_mode(arm_SP_IRQ
, MODE_IRQ
);
340 if (NULL
== (arm_SP_FIQ
=(ULONG
*)AllocMem(AROS_STACKSIZE
,MEMF_PUBLIC
))) {
343 arm_SP_FIQ
= (ULONG
*)(((ULONG
)arm_SP_FIQ
) + AROS_STACKSIZE
- sizeof(ULONG
));
344 D(bug("Now setting FIQ Stackpointer! %x\n",arm_SP_FIQ
));
345 set_sp_mode(arm_SP_FIQ
, MODE_FIQ
);
347 if (NULL
== (arm_SP_Abort
=(ULONG
*)AllocMem(AROS_STACKSIZE
,MEMF_PUBLIC
))) {
350 arm_SP_Abort
= (ULONG
*)(((ULONG
)arm_SP_Abort
) + AROS_STACKSIZE
- sizeof(ULONG
));
351 D(bug("Now setting Abort Stackpointer! %x\n",arm_SP_Abort
));
352 set_sp_mode(arm_SP_Abort
, MODE_ABORT
);
354 if (NULL
== (arm_SP_Undef
=(ULONG
*)AllocMem(AROS_STACKSIZE
,MEMF_PUBLIC
))) {
357 arm_SP_Undef
= (ULONG
*)(((ULONG
)arm_SP_Undef
) + AROS_STACKSIZE
- sizeof(ULONG
));
358 D(bug("Now setting Undef Stackpointer! %x\n",arm_SP_Undef
));
359 set_sp_mode(arm_SP_Undef
, MODE_UNDEF
);
362 D(bug("cp15 register 0: 0x%x\n",get_cp15_r0()));
363 D(bug("cp15 register 1: 0x%x\n",get_cp15_r1()));
364 D(bug("cp15 register 2: 0x%x\n",get_cp15_r2()));
365 mmu_lookup(0x0,SysBase
);
366 mmu_lookup(0xc0000000,SysBase
);
368 * This is the last place where I am in supervisor mode.
369 * so let me switch into user mode and continue there.
370 * The user mode function will then call main_init_cont.
372 D(bug("switching to user mode now\n"));
373 switch_to_user_mode(main_init_cont
, arm_SP_User
);
377 * The following function will be executed whan AROS is in user mode
379 static void main_init_cont(void)
381 D(bug("!!!!! in user mode now !!!!\n"));
382 InitCode(RTF_SINGLETASK
, 0);
383 D(bug("Ooops, should never get here!\n"));
387 All done. In normal cases CPU should never reach this point