Skip to content

Commit

Permalink
Move static init to asm bootstrap code
Browse files Browse the repository at this point in the history
  • Loading branch information
djphoenix committed Nov 9, 2016
1 parent 09b4327 commit 56a68c6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/boot/boot.cpp
Expand Up @@ -23,7 +23,6 @@
#include "processmanager.hpp"

void NORETURN main() {
static_init();
Display::getInstance()->clean();
Pagetable::init();
SMP::init();
Expand Down
18 changes: 18 additions & 0 deletions src/boot/x32to64.s
Expand Up @@ -190,6 +190,24 @@ _efi_start: # EFI
jmp .

x64_entry:
mov $__INIT_LIST__, %rbp
1:
add $8, %rbp
mov (%rbp), %rax
test %rax, %rax
je 2f
callq *%rax
jmp 1b
2:
mov $__CTOR_LIST__, %rbp
3:
add $8, %rbp
mov (%rbp), %rax
test %rax, %rax
je 4f
callq *%rax
jmp 3b
4:
mov %rsp, %rbp
jmp main

Expand Down
2 changes: 0 additions & 2 deletions src/kernlib/include/kernlib/std.hpp
Expand Up @@ -32,8 +32,6 @@ template<typename T> T ABS(T a) { return a > 0 ? a : -a; }

extern "C" {

void static_init();

size_t strlen(const char*, size_t limit = -1);
char* strdup(const char*);
int strcmp(const char*, const char*);
Expand Down
10 changes: 0 additions & 10 deletions src/kernlib/std.cpp
Expand Up @@ -21,16 +21,6 @@ extern "C" {

void __cxa_pure_virtual() {}
int __cxa_atexit(void (*)(void*), void*, void*) { return 0; }

extern void (*__INIT_LIST__)();
extern void (*__CTOR_LIST__)();
}

void static_init() {
for (void (**p)() = &__INIT_LIST__ + 1; *p != 0; ++p)
(*p)();
for (void (**p)() = &__CTOR_LIST__ + 1; *p != 0; ++p)
(*p)();
}

size_t strlen(const char* c, size_t limit) {
Expand Down

0 comments on commit 56a68c6

Please sign in to comment.