mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[ion] Set stack pointer when testing as well
Change-Id: Ibeae7961535208c224f9ac51f4cf33e3978665b3
This commit is contained in:
committed by
Émilie Feral
parent
e199143412
commit
688394abce
@@ -2,19 +2,6 @@
|
||||
#include "global_preferences.h"
|
||||
#include <poincare/init.h>
|
||||
|
||||
#if PLATFORM_DEVICE
|
||||
// On device, stack start address is always known. TODO : Factorize address
|
||||
static void * s_stackStart = reinterpret_cast<void *>(0x20000000 + 256*1024);
|
||||
#else
|
||||
// Stack start will be defined in ion_main.
|
||||
static void * s_stackStart = nullptr;
|
||||
#endif
|
||||
|
||||
void * Ion::stackStart() {
|
||||
assert(s_stackStart != nullptr);
|
||||
return s_stackStart;
|
||||
}
|
||||
|
||||
#define DUMMY_MAIN 0
|
||||
#if DUMMY_MAIN
|
||||
|
||||
@@ -80,7 +67,7 @@ void ion_main(int argc, const char * const argv[]) {
|
||||
* example, stack pointer could go backward after initialization and allocated
|
||||
* memory pointers could be overlooked during mark procedure. */
|
||||
volatile int stackTop;
|
||||
s_stackStart = (void *)(&stackTop);
|
||||
Ion::setStackStart((void *)(&stackTop));
|
||||
#endif
|
||||
|
||||
AppsContainer::sharedAppsContainer()->run();
|
||||
|
||||
@@ -31,6 +31,7 @@ ion_src += $(addprefix ion/src/shared/, \
|
||||
events_keyboard.cpp \
|
||||
events_modifier.cpp \
|
||||
platform_info.cpp \
|
||||
stack_position.cpp \
|
||||
storage.cpp \
|
||||
unicode/utf8_decoder.cpp\
|
||||
unicode/utf8_helper.cpp\
|
||||
|
||||
@@ -46,8 +46,9 @@ uint32_t random();
|
||||
// Decompress data
|
||||
void decompress(const uint8_t * src, uint8_t * dst, int srcSize, int dstSize);
|
||||
|
||||
// Returns address to the first object that can be allocated on stack
|
||||
// Sets and returns address to the first object that can be allocated on stack
|
||||
void * stackStart();
|
||||
void setStackStart(void *);
|
||||
// Tells whether the stack pointer is within acceptable bounds
|
||||
bool stackSafe();
|
||||
|
||||
|
||||
22
ion/src/shared/stack_position.cpp
Normal file
22
ion/src/shared/stack_position.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <ion.h>
|
||||
|
||||
namespace Ion {
|
||||
|
||||
#if PLATFORM_DEVICE
|
||||
// On device, stack start address is always known. TODO : Factorize address
|
||||
static void * s_stackStart = reinterpret_cast<void *>(0x20000000 + 256*1024);
|
||||
#else
|
||||
// Stack start will be defined in ion_main.
|
||||
static void * s_stackStart = nullptr;
|
||||
#endif
|
||||
|
||||
void * stackStart() {
|
||||
assert(s_stackStart != nullptr);
|
||||
return s_stackStart;
|
||||
}
|
||||
|
||||
void setStackStart(void * pointer) {
|
||||
assert(pointer != nullptr);
|
||||
s_stackStart = pointer;
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,16 @@ static inline void ion_main_inner() {
|
||||
|
||||
|
||||
void ion_main(int argc, const char * const argv[]) {
|
||||
// Initialize the backlight
|
||||
Ion::Backlight::init();
|
||||
// Initialize Poincare::TreePool::sharedPool
|
||||
Poincare::Init();
|
||||
Poincare::Init(); // Initialize Poincare::TreePool::sharedPool
|
||||
#if !PLATFORM_DEVICE
|
||||
/* s_stackStart must be defined as early as possible to ensure that there
|
||||
* cannot be allocated memory pointers before. Otherwise, with MicroPython for
|
||||
* example, stack pointer could go backward after initialization and allocated
|
||||
* memory pointers could be overlooked during mark procedure. */
|
||||
volatile int stackTop;
|
||||
Ion::setStackStart((void *)(&stackTop));
|
||||
#endif
|
||||
|
||||
Poincare::ExceptionCheckpoint ecp;
|
||||
if (ExceptionRun(ecp)) {
|
||||
|
||||
Reference in New Issue
Block a user