Merge pull request #5 from bobbybee/master
[rpi-open-firmware.git] / arm_chainloader / main.c
old mode 100755 (executable)
new mode 100644 (file)
index c6903e1..4106fdd
@@ -2,6 +2,49 @@
 #include <chainloader.h>\r
 #include <hardware.h>\r
 \r
+extern uintptr_t* __init_array_start;\r
+extern uintptr_t* __init_array_end;\r
+extern uintptr_t* _end;\r
+\r
+#define logf(fmt, ...) printf("[BRINGUP:%s]: " fmt, __FUNCTION__, ##__VA_ARGS__);\r
+\r
+static void cxx_init() {\r
+       unsigned ctor_count = (unsigned)(&__init_array_end - &__init_array_start);\r
+       void (*static_ctor)();\r
+\r
+       logf("calling %d static constructors (0x%X - 0x%X) ...\n", ctor_count, &__init_array_start, &__init_array_end);\r
+\r
+       for (unsigned i = 0; i < ctor_count; i++) {\r
+               uintptr_t* ptr = (((uintptr_t*)&__init_array_start) + i);\r
+               static_ctor = (void*)*ptr;\r
+               static_ctor();\r
+       }\r
+}\r
+\r
+static void heap_init() {\r
+       void* start_of_heap = (void*)&_end;\r
+       size_t hs = 0x100000;\r
+\r
+       logf("Initializing heap at 0x%x with size 0x%x\n", start_of_heap, hs);\r
+\r
+       init_memory_pool(hs, start_of_heap);\r
+}\r
+\r
 void main() {\r
-       printf("%s: arm_chainloader started on ARM, continuing boot from here ...\n", __FUNCTION__);\r
+       logf("Started on ARM, continuing boot from here ...\n", __FUNCTION__);\r
+\r
+       heap_init();\r
+\r
+       /* c++ runtime */\r
+       cxx_init();\r
+\r
+       panic("Nothing else to do!");\r
+\r
+#if 0\r
+       printf("Done ");\r
+       for(;;) {\r
+               printf(".");\r
+               udelay(1000000);\r
+       }\r
+#endif\r
 }
\ No newline at end of file
This page took 0.024281 seconds and 4 git commands to generate.