Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-08-02 17:31:38 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-08-02 17:33:25 +0300
commit1d5b2d438a06649a1e2dbd78ec46bd47c99d4db3 (patch)
tree09f42b7ad63efccc61c7f02804769af3245ace9b
parenta12ad9479783cd95da65cfa1f427f19c1cbad730 (diff)
Fixed allocation of NVM buffer during software reset
-rw-r--r--src/Hardware/ExceptionHandlers.cpp2
-rw-r--r--src/Hardware/ExceptionHandlers.h2
-rw-r--r--src/Platform/Tasks.cpp7
-rw-r--r--src/Platform/Tasks.h2
4 files changed, 7 insertions, 6 deletions
diff --git a/src/Hardware/ExceptionHandlers.cpp b/src/Hardware/ExceptionHandlers.cpp
index 38be6c22..f2ecc122 100644
--- a/src/Hardware/ExceptionHandlers.cpp
+++ b/src/Hardware/ExceptionHandlers.cpp
@@ -24,7 +24,7 @@
#endif
// Perform a software reset. 'stk' points to the exception stack (r0 r1 r2 r3 r12 lr pc xPSR) if the cause is an exception, otherwise it is nullptr.
-[[noreturn]] void SoftwareReset(SoftwareResetReason initialReason, const uint32_t *stk) noexcept
+[[noreturn]] void SoftwareReset(SoftwareResetReason initialReason, const uint32_t *_ecv_array null stk) noexcept
{
IrqDisable(); // disable interrupts before we call any flash functions. We don't enable them again.
WatchdogReset(); // kick the watchdog
diff --git a/src/Hardware/ExceptionHandlers.h b/src/Hardware/ExceptionHandlers.h
index e5141f71..ab27b999 100644
--- a/src/Hardware/ExceptionHandlers.h
+++ b/src/Hardware/ExceptionHandlers.h
@@ -10,7 +10,7 @@
#include "SoftwareReset.h"
-[[noreturn]] void SoftwareReset(SoftwareResetReason initialReason, const uint32_t *stk = nullptr) noexcept;
+[[noreturn]] void SoftwareReset(SoftwareResetReason initialReason, const uint32_t *_ecv_array null stk = nullptr) noexcept;
[[noreturn]] void OutOfMemoryHandler() noexcept;
#endif /* SRC_HARDWARE_EXCEPTIONHANDLERS_H_ */
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