b29371b2696206b808800b7ae999d5fd2f4fc5bd
[rpi-open-firmware.git] / arm_chainloader / main.c
1 #include <stdint.h>
2 #include <chainloader.h>
3 #include <hardware.h>
4
5 extern uintptr_t* __init_array_start;
6 extern uintptr_t* __init_array_end;
7 extern uintptr_t* _end;
8
9 #define logf(fmt, ...) printf("[BRINGUP:%s]: " fmt, __FUNCTION__, ##__VA_ARGS__);
10
11 static void cxx_init() {
12 unsigned ctor_count = (unsigned)(&__init_array_end - &__init_array_start);
13 void (*static_ctor)();
14
15 logf("calling %d static constructors (0x%X - 0x%X) ...\n", ctor_count, &__init_array_start, &__init_array_end);
16
17 for (unsigned i = 0; i < ctor_count; i++) {
18 uintptr_t* ptr = (((uintptr_t*)&__init_array_start) + i);
19 static_ctor = (void*)*ptr;
20 static_ctor();
21 }
22 }
23
24 static void heap_init() {
25 void* start_of_heap = (void*)&_end;
26 size_t hs = 0x100000;
27
28 logf("Initializing heap at 0x%x with size 0x%x\n", start_of_heap, hs);
29
30 init_memory_pool(hs, start_of_heap);
31 }
32
33 void main() {
34 logf("Started on ARM, continuing boot from here ...\n", __FUNCTION__);
35
36 heap_init();
37
38 /* poke the VPU */
39 printf("\nPoking the VPU....\n");
40 mmio_write32(0x7E00B8A0, 0xA1755A01);
41
42 /* c++ runtime */
43 cxx_init();
44
45 panic("Nothing else to do!");
46
47 #if 0
48 printf("Done ");
49 for(;;) {
50 printf(".");
51 udelay(1000000);
52 }
53 #endif
54 }
This page took 0.064957 seconds and 3 git commands to generate.