add basic secure monitor code for armv7+, for some reason sdram security does not...
[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: return "User";
24 case ARM32_FIQ: return "FIQ";
25 case ARM32_IRQ: return "IRQ";
26 case ARM32_SVC: return "Supervisor";
27 case ARM32_MON: return "Secure Monitor";
28 case ARM32_ABT: return "Abort";
29 case ARM32_UND: return "Undefined Instruction";
30 case ARM32_HYP: return "Hypervisor";
31 case ARM32_SYS: return "System";
32 default: return "Unknown Mode";
33 }
34 }
35
36 void main(bool security_supported)
37 {
38 /* wait for peripheral access */
39 while(ARM_ID != ARM_IDVAL);
40 udelay(500);
41
42 logf("Started on ARM, continuing boot from here ...\n");
43
44 logf("Firmware data: SDRAM_SIZE=%d, VPU_CPUID=0x%X\n",
45 g_FirmwareData.sdram_size,
46 g_FirmwareData.vpu_cpuid);
47
48 if (security_supported) {
49 logf("Security extensions are supported!\n");
50 }
51
52 logf("Execution mode: %s\n", get_execution_mode_name());
53
54 heap_init();
55
56 /* c++ runtime */
57 __cxx_init();
58
59 panic("Nothing else to do!");
60 }
This page took 0.07674 seconds and 4 git commands to generate.