diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-08-02 17:31:38 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-08-02 17:33:25 +0300 |
commit | 1d5b2d438a06649a1e2dbd78ec46bd47c99d4db3 (patch) | |
tree | 09f42b7ad63efccc61c7f02804769af3245ace9b /src/Platform | |
parent | a12ad9479783cd95da65cfa1f427f19c1cbad730 (diff) |
Fixed allocation of NVM buffer during software reset
Diffstat (limited to 'src/Platform')
-rw-r--r-- | src/Platform/Tasks.cpp | 7 | ||||
-rw-r--r-- | src/Platform/Tasks.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/Platform/Tasks.cpp b/src/Platform/Tasks.cpp index 0f8eb0c9..86ce172c 100644 --- a/src/Platform/Tasks.cpp +++ b/src/Platform/Tasks.cpp @@ -103,13 +103,14 @@ extern "C" void ReleaseMallocMutex() noexcept // We don't want to use a static buffer because that is wasteful of RAM, given that only the crash handler uses it, we have interrupts disabled while we use it, // and we reset immediately afterwards. // Instead we use either the bottom or top of the main task stack. -// Parameter 'stk' is the stack we are interested in, which we must not overwrite. The caller is either using the same stack a little lower, or the exception stack. -void *Tasks::GetNVMBuffer(const uint32_t *stk) noexcept +// Parameter 'stk' is the stack we are interested in, which we must not overwrite; or null. +// If it is not null then the caller is either using the same stack a little lower, or the exception stack. +void *Tasks::GetNVMBuffer(const uint32_t *_ecv_array null stk) noexcept { constexpr size_t stackAllowance = 128; static_assert((sizeof(NonVolatileMemory) & 3) == 0); static_assert(MainTaskStackWords * 4 >= 2 * sizeof(NonVolatileMemory) + stackAllowance + 4); - const char * const cStack = reinterpret_cast<const char*>(stk); + const char * const cStack = reinterpret_cast<const char*>((stk == nullptr) ? GetStackPointer() : stk); // See if we can use the bottom of the main task stack char *ret = (char *)&mainTask + sizeof(TaskBase); diff --git a/src/Platform/Tasks.h b/src/Platform/Tasks.h index 8d9c3ae4..d3bc0c2d 100644 --- a/src/Platform/Tasks.h +++ b/src/Platform/Tasks.h @@ -20,7 +20,7 @@ namespace Tasks void *AllocPermanent(size_t sz, std::align_val_t align = (std::align_val_t)__STDCPP_DEFAULT_NEW_ALIGNMENT__) noexcept; const char* GetHeapTop() noexcept; Mutex *GetI2CMutex() noexcept; - void *GetNVMBuffer(const uint32_t *stk) noexcept; + void *GetNVMBuffer(const uint32_t *_ecv_array null stk) noexcept; } #if SUPPORT_CAN_EXPANSION |