revert between 56095 -> 55830 in arch
[AROS.git] / arch / arm-efika / kernel / kernel_startup.c
blob93c2174b7eb6ce3c9ebaad9492e527ce1cc5a103
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <utility/tagitem.h>
10 #include <proto/arossupport.h>
11 #include <strings.h>
12 #include <inttypes.h>
14 #include <string.h>
16 #include <aros/arm/cpucontext.h>
17 #include <aros/arm/cpu.h>
19 #include <kernel_base.h>
20 #include <kernel_debug.h>
22 #define D(x) x
24 #define _STR(x) #x
25 #define STR(x) _STR(x)
27 #define SYS_STACK_SIZE (16384)
29 extern void start();
31 asm(".section .aros.init,\"ax\"\n\t"
32 ".globl start\n\t"
33 ".type start,%function\n"
34 "start: ldr r1, early_mmu_ptr \n" // Get early mmu map pointer
35 " ldr r2, [r1] \n" // Load pointer to MMU map
36 " cmp r2, #0 \n" // Is the pointer set?
37 " mcrne p15, 0, r2, c2, c0, 0\n" // Yes, load the mmu map
38 " mrceq p15, 0, r2, c2, c0, 0\n" // No, read address of currently used mmu ap
39 " streq r2, [r1] \n" // and conditionally store it in early map pointer
40 " ldr sp, tmp_stack_end \n" // Load address of top of stack pointer
41 " mov r4, r0 \n"
42 " bl clear_bss \n" // clear bss regions
43 " mov r0, r4 \n" // restore boot msg parameter
44 " cps #" STR(CPUMODE_SYSTEM) "\n" // Enter System mode
45 " ldr sp, sys_stack_end \n" // Load system mode stack
46 " cps #" STR(CPUMODE_IRQ) "\n"
47 " ldr sp, irq_stack_end \n"
48 " cps #" STR(CPUMODE_ABORT) "\n"
49 " ldr sp, abt_stack_end \n"
50 " cps #" STR(CPUMODE_SUPERVISOR) "\n"
51 " ldr sp, svc_stack_end \n"
52 " ldr pc, 2f \n" // jump to the kernel
53 "1: b 1b \n" // we never return from here
54 "2: .word startup \n"
55 "tmp_stack_end: .word temporary + " STR(127*4) "\n"
56 "sys_stack_end: .word sys_stack + " STR((SYS_STACK_SIZE - 4)) "\n"
57 "svc_stack_end: .word svc_stack + " STR((SYS_STACK_SIZE - 4)) "\n"
58 "irq_stack_end: .word irq_stack + " STR((SYS_STACK_SIZE - 4)) "\n"
59 "abt_stack_end: .word abt_stack + " STR((SYS_STACK_SIZE - 4)) "\n"
60 "early_mmu_ptr: .word early_mmu\n"
63 static uintptr_t early_mmu __attribute__((used, section(".data"))) = 0;
66 * Temporary stack for very early init. It's used only during clearing of
67 * .bss sections in all modules. Rest of this space is occupied by TagItem
68 * boot message. prepared by the bootstrap.
70 static union {
71 uint32_t stack[128];
72 struct TagItem tags[64];
73 } temporary __attribute__((aligned(32),used,section(".data")));
75 static uint8_t sys_stack[SYS_STACK_SIZE] __attribute__((used,aligned(16)));
76 static uint8_t svc_stack[SYS_STACK_SIZE] __attribute__((used,aligned(16)));
77 static uint8_t abt_stack[SYS_STACK_SIZE] __attribute__((used,aligned(16)));
78 static uint8_t irq_stack[SYS_STACK_SIZE] __attribute__((used,aligned(16)));
80 static char CmdLine[200] __attribute__((used, section(".data")));
82 __attribute__((section(".data"))) struct ExecBase *SysBase = NULL;
84 struct TagItem *BootMsg;
86 static void __used __attribute__((section(".aros.init"))) clear_bss(struct TagItem *msg)
88 struct TagItem *tag = LibFindTagItem(KRN_KernelBss, msg);
90 if (tag)
92 struct KernelBSS *bss = (struct KernelBSS *)tag->ti_Data;
94 if (bss)
96 __clear_bss(bss);
101 void startup(struct TagItem *tags)
103 bug("\n[KRN] AROS for EfikaMX built on %s starting...\n", __DATE__);
104 bug("[KRN] BootMsg @ %08x\n", tags);
105 bug("[KRN] Kernel entry @ %08x\n", start);
106 bug("[KRN] Early MMU @ %08x\n", early_mmu);
108 /* Check if the taglist is copied into safe place */
109 if (tags != temporary.tags)
111 /* Nope, copy taglist... */
112 struct TagItem *msg = tags;
113 struct TagItem *tmp = temporary.tags;
115 while(msg->ti_Tag != TAG_DONE)
117 /* Copy the tag */
118 *tmp = *msg;
120 if (tmp->ti_Tag == KRN_CmdLine)
122 strcpy(CmdLine, (char*) msg->ti_Data);
123 tmp->ti_Data = (STACKIPTR) CmdLine;
124 D(bug("[KRN] CmdLine: %s\n", tmp->ti_Data));
126 else if (tmp->ti_Tag == KRN_MEMLower)
128 D(bug("[KRN] MemLower: %08x\n", tmp->ti_Data));
130 else if (tmp->ti_Tag == KRN_MEMUpper)
132 D(bug("[KRN] MemUpper: %08x\n", tmp->ti_Data));
135 else if (tmp->ti_Tag == KRN_KernelLowest)
137 D(bug("[KRN] KernelLowest: %08x\n", tmp->ti_Data));
140 else if (tmp->ti_Tag == KRN_KernelHighest)
142 D(bug("[KRN] KernelHighest: %08x\n", tmp->ti_Data));
145 else if (tmp->ti_Tag == KRN_KernelBss)
147 D(bug("[KRN] kernelBSS: %08x\n", tmp->ti_Data));
150 tmp++;
151 msg++;
156 while(1);