diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2010-05-19 21:50:57 -0500 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2010-05-19 21:50:57 -0500 |
commit | 27503f42c300f6ba65ff6cc06290696fe6153b7f (patch) | |
tree | 6bf7fbd6b14eceaacdd17c05b979a929c469667d | |
parent | b0e457a7589a0ee6b78ed676566c6410da371570 (diff) | |
download | talos-hostboot-27503f42c300f6ba65ff6cc06290696fe6153b7f.tar.gz talos-hostboot-27503f42c300f6ba65ff6cc06290696fe6153b7f.zip |
Call default constructors.
-rw-r--r-- | src/kernel.ld | 5 | ||||
-rw-r--r-- | src/kernel/kernel.C | 33 |
2 files changed, 33 insertions, 5 deletions
diff --git a/src/kernel.ld b/src/kernel.ld index dc433807a..01fad2522 100644 --- a/src/kernel.ld +++ b/src/kernel.ld @@ -17,6 +17,10 @@ SECTIONS *(.text._*) *(.rodata) *(.rodata.*) + . = ALIGN(0x8); + ctor_start = .; + *(.ctors) + ctor_end = .; } @@ -45,6 +49,7 @@ SECTIONS /DISCARD/ : { *(.comment) *(.gnu.attributes) + *(.dtors) } } diff --git a/src/kernel/kernel.C b/src/kernel/kernel.C index 2d97204e1..d44095719 100644 --- a/src/kernel/kernel.C +++ b/src/kernel/kernel.C @@ -1,14 +1,37 @@ #include <stdint.h> #include <kernel/console.H> +#include <util/singleton.H> + +class Kernel +{ + public: + void cppBootstrap(); + + protected: + Kernel() {}; +}; int main() { printk("Booting Chenoo kernel...\n"); - printk("Testing a character %c %c %c\n", 'a', 'b', 'c'); - printk("Testing numbers %hhd %hu %x %lx %lld\n", - (char)-1, (short)1234, 0xabcdef12, 0xdeadbeef, - 0x0123456789abcdef); - while(1); + + Kernel& kernel = Singleton<Kernel>::instance(); + kernel.cppBootstrap(); + while(1); return 0; } + +void Kernel::cppBootstrap() +{ + // Call default constructors for any static objects. + extern void (*ctor_start)(); + extern void (*ctor_end)(); + void(**ctors)() = &ctor_start; + while(ctors != &ctor_end) + { + (*ctors)(); + ctors++; + } +} + |