Eliminate firmware rendezvous
[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*)MEM_HEAP_START;
26 size_t hs = MEM_HEAP_SIZE;
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 /* wait for peripheral access */
35 while(ARM_ID != ARM_IDVAL);
36
37 logf("Started on ARM, continuing boot from here ...\n");
38
39 heap_init();
40
41 /* c++ runtime */
42 cxx_init();
43
44 panic("Nothing else to do!");
45
46 #if 0
47 printf("Done ");
48 for(;;) {
49 printf(".");
50 udelay(1000000);
51 }
52 #endif
53 }
This page took 0.06507 seconds and 4 git commands to generate.