|
|
@ -51,7 +51,7 @@
|
|
|
|
* Also, there are two support functions that can be called from a developer's C code.
|
|
|
|
* Also, there are two support functions that can be called from a developer's C code.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start);
|
|
|
|
* uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start);
|
|
|
|
* void M100_dump_routine(PGM_P const title, char *start, char *end);
|
|
|
|
* void M100_dump_routine(PGM_P const title, const char * const start, const char * const end);
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Initial version by Roxy-3D
|
|
|
|
* Initial version by Roxy-3D
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -151,8 +151,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
|
|
|
|
// Start and end the dump on a nice 16 byte boundary
|
|
|
|
// Start and end the dump on a nice 16 byte boundary
|
|
|
|
// (even though the values are not 16-byte aligned).
|
|
|
|
// (even though the values are not 16-byte aligned).
|
|
|
|
//
|
|
|
|
//
|
|
|
|
start_free_memory = (char*)((ptr_int_t)((uint32_t)start_free_memory & 0xFFFFFFF0)); // Align to 16-byte boundary
|
|
|
|
start_free_memory = (char*)(ptr_int_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary
|
|
|
|
end_free_memory = (char*)((ptr_int_t)((uint32_t)end_free_memory | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
|
|
|
|
end_free_memory = (char*)(ptr_int_t(uint32_t(end_free_memory) | 0xFUL)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
|
|
|
|
|
|
|
|
|
|
|
|
// Dump command main loop
|
|
|
|
// Dump command main loop
|
|
|
|
while (start_free_memory < end_free_memory) {
|
|
|
|
while (start_free_memory < end_free_memory) {
|
|
|
@ -177,15 +177,16 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void M100_dump_routine(PGM_P const title, char *start, char *end) {
|
|
|
|
void M100_dump_routine(PGM_P const title, const char * const start, const char * const end) {
|
|
|
|
serialprintPGM(title);
|
|
|
|
serialprintPGM(title);
|
|
|
|
SERIAL_EOL();
|
|
|
|
SERIAL_EOL();
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Round the start and end locations to produce full lines of output
|
|
|
|
// Round the start and end locations to produce full lines of output
|
|
|
|
//
|
|
|
|
//
|
|
|
|
start = (char*)((ptr_int_t)((uint32_t)start & 0xFFFFFFF0)); // Align to 16-byte boundary
|
|
|
|
dump_free_memory(
|
|
|
|
end = (char*)((ptr_int_t)((uint32_t)end | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
|
|
|
|
(char*)(ptr_int_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary
|
|
|
|
dump_free_memory(start, end);
|
|
|
|
(char*)(ptr_int_t(uint32_t(end) | 0xFUL)) // Align end_free_memory to the 15th byte (at or above end_free_memory)
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // M100_FREE_MEMORY_DUMPER
|
|
|
|
#endif // M100_FREE_MEMORY_DUMPER
|
|
|
@ -211,7 +212,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) {
|
|
|
|
// idle();
|
|
|
|
// idle();
|
|
|
|
serial_delay(20);
|
|
|
|
serial_delay(20);
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_DUMPER)
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_DUMPER)
|
|
|
|
M100_dump_routine(PSTR(" Memory corruption detected with end_free_memory<Heap\n"), (char*)0x1B80, (char*)0x21FF);
|
|
|
|
M100_dump_routine(PSTR(" Memory corruption detected with end_free_memory<Heap\n"), (const char*)0x1B80, (const char*)0x21FF);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|