Revert "misc cleanup"
[rpi-open-firmware.git] / arm_chainloader / main.c
1 #include <stdint.h>
2 #include <chainloader.h>
3 #include <hardware.h>
4 #include <stdbool.h>
5
6 extern uintptr_t* _end;
7
8 #define logf(fmt, ...) printf("[BRINGUP:%s]: " fmt, __FUNCTION__, ##__VA_ARGS__);
9
10 static void heap_init() {
11 void* start_of_heap = (void*)MEM_HEAP_START;
12 size_t hs = MEM_HEAP_SIZE;
13
14 logf("Initializing heap at 0x%x with size 0x%x\n", start_of_heap, hs);
15
16 init_memory_pool(hs, start_of_heap);
17 }
18
19 static const char* get_execution_mode_name() {
20 uint32_t cpsr = arm_get_cpsr() & ARM32_MODE_MASK;
21
22 switch (cpsr) {
23 case ARM32_USR:
24 return "User";
25 case ARM32_FIQ:
26 return "FIQ";
27 case ARM32_IRQ:
28 return "IRQ";
29 case ARM32_SVC:
30 return "Supervisor";
31 case ARM32_MON:
32 return "Secure Monitor";
33 case ARM32_ABT:
34 return "Abort";
35 case ARM32_UND:
36 return "Undefined Instruction";
37 case ARM32_HYP:
38 return "Hypervisor";
39 case ARM32_SYS:
40 return "System";
41 default:
42 return "Unknown Mode";
43 }
44 }
45
46 void main(bool security_supported) {
47 /* wait for peripheral access */
48 while(ARM_ID != ARM_IDVAL);
49 udelay(500);
50
51 logf("Started on ARM, continuing boot from here ...\n");
52
53 logf("Firmware data: SDRAM_SIZE=%d, VPU_CPUID=0x%X\n",
54 g_FirmwareData.sdram_size,
55 g_FirmwareData.vpu_cpuid);
56
57 if (security_supported) {
58 logf("Security extensions are supported!\n");
59 }
60
61 logf("Execution mode: %s\n", get_execution_mode_name());
62
63 heap_init();
64
65 /* c++ runtime */
66 __cxx_init();
67
68 panic("Nothing else to do!");
69 }
This page took 0.093647 seconds and 4 git commands to generate.