base: ABI specific stack creation

ref #1042
This commit is contained in:
Martin Stein 2014-02-21 10:59:39 +01:00 committed by Christian Helmuth
parent 43c73eff13
commit a7dd2b3171
3 changed files with 21 additions and 6 deletions

View File

@ -17,11 +17,17 @@
#include <base/stdint.h>
namespace Abi {
/**
* On ARM a call (or branch) will not change the stack pointer, so we do not
* need stack adjustment
*/
static constexpr Genode::size_t stack_adjustment() { return 0; }
/**
* Do ABI specific initialization to a freshly created stack
*/
inline void init_stack(Genode::addr_t) { }
}
#endif /* _INCLUDE__ARM__CPU__CONSTS_H_ */

View File

@ -39,6 +39,20 @@ namespace Abi {
* On x86 a call will result in a growth of the stack by machine word size
*/
static constexpr Genode::size_t stack_adjustment() { return sizeof(Genode::addr_t); }
/**
* Do ABI specific initialization to a freshly created stack
*
* \param stack_top top of the stack
*/
inline void init_stack(Genode::addr_t const stack_top)
{
/*
* The value at the top of the stack might get interpreted as return
* address of the thread start function by GDB, so we set it to 0.
*/
*(Genode::addr_t *)stack_top = 0;
}
}
#endif /* _INCLUDE__X86__CPU__CONSTS_H_ */

View File

@ -91,12 +91,7 @@ Thread_base::_alloc_context(size_t stack_size, bool main_thread)
context->stack_base = ds_addr;
context->ds_cap = ds_cap;
/*
* The value at the top of the stack might get interpreted as return
* address of the thread start function by GDB, so we set it to 0.
*/
*(addr_t*)context->stack_top() = 0;
Abi::init_stack(context->stack_top());
return context;
}