|
@@ -78,7 +78,7 @@ char* top_of_stack() {
|
78
|
78
|
}
|
79
|
79
|
|
80
|
80
|
// Count the number of test bytes at the specified location.
|
81
|
|
-int16_t count_test_bytes(const uint8_t * const ptr) {
|
|
81
|
+int16_t count_test_bytes(const char * const ptr) {
|
82
|
82
|
for (uint16_t i = 0; i < 32000; i++)
|
83
|
83
|
if (((char) ptr[i]) != TEST_BYTE)
|
84
|
84
|
return i - 1;
|
|
@@ -100,13 +100,13 @@ int16_t count_test_bytes(const uint8_t * const ptr) {
|
100
|
100
|
* the block. If so, it may indicate memory corruption due to a bad pointer.
|
101
|
101
|
* Unexpected bytes are flagged in the right column.
|
102
|
102
|
*/
|
103
|
|
- void dump_free_memory(const uint8_t *ptr, const uint8_t *sp) {
|
|
103
|
+ void dump_free_memory(const char *ptr, const char *sp) {
|
104
|
104
|
//
|
105
|
105
|
// Start and end the dump on a nice 16 byte boundary
|
106
|
106
|
// (even though the values are not 16-byte aligned).
|
107
|
107
|
//
|
108
|
|
- ptr = (uint8_t *)((uint16_t)ptr & 0xFFF0); // Align to 16-byte boundary
|
109
|
|
- sp = (uint8_t *)((uint16_t)sp | 0x000F); // Align sp to the 15th byte (at or above sp)
|
|
108
|
+ ptr = (char *)((uint16_t)ptr & 0xFFF0); // Align to 16-byte boundary
|
|
109
|
+ sp = (char *)((uint16_t)sp | 0x000F); // Align sp to the 15th byte (at or above sp)
|
110
|
110
|
|
111
|
111
|
// Dump command main loop
|
112
|
112
|
while (ptr < sp) {
|
|
@@ -121,7 +121,7 @@ int16_t count_test_bytes(const uint8_t * const ptr) {
|
121
|
121
|
SERIAL_CHAR('|'); // Point out non test bytes
|
122
|
122
|
for (uint8_t i = 0; i < 16; i++) {
|
123
|
123
|
char ccc = (char)ptr[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
|
124
|
|
- if (&ptr[i] >= command_queue && &ptr[i] < &command_queue[BUFSIZE][MAX_CMD_SIZE]) { // Print out ASCII in the command buffer area
|
|
124
|
+ if (&ptr[i] >= (const char*)command_queue && &ptr[i] < (const char*)(command_queue + sizeof(command_queue))) { // Print out ASCII in the command buffer area
|
125
|
125
|
if (!WITHIN(ccc, ' ', 0x7E)) ccc = ' ';
|
126
|
126
|
}
|
127
|
127
|
else { // If not in the command buffer area, flag bytes that don't match the test byte
|
|
@@ -153,13 +153,13 @@ void M100_dump_routine(const char * const title, const char *start, const char *
|
153
|
153
|
* Return the number of free bytes in the memory pool,
|
154
|
154
|
* with other vital statistics defining the pool.
|
155
|
155
|
*/
|
156
|
|
-void free_memory_pool_report(const char * const ptr, const uint16_t size) {
|
|
156
|
+void free_memory_pool_report(char * const ptr, const uint16_t size) {
|
157
|
157
|
int16_t max_cnt = -1;
|
158
|
158
|
uint16_t block_cnt = 0;
|
159
|
159
|
char *max_addr = NULL;
|
160
|
160
|
// Find the longest block of test bytes in the buffer
|
161
|
161
|
for (uint16_t i = 0; i < size; i++) {
|
162
|
|
- char * const addr = ptr + i;
|
|
162
|
+ char *addr = ptr + i;
|
163
|
163
|
if (*addr == TEST_BYTE) {
|
164
|
164
|
const uint16_t j = count_test_bytes(addr);
|
165
|
165
|
if (j > 8) {
|
|
@@ -209,7 +209,7 @@ void free_memory_pool_report(const char * const ptr, const uint16_t size) {
|
209
|
209
|
* M100 I
|
210
|
210
|
* Init memory for the M100 tests. (Automatically applied on the first M100.)
|
211
|
211
|
*/
|
212
|
|
-void init_free_memory(uint8_t *ptr, int16_t size) {
|
|
212
|
+void init_free_memory(char *ptr, int16_t size) {
|
213
|
213
|
SERIAL_ECHOLNPGM("Initializing free memory block.\n\n");
|
214
|
214
|
|
215
|
215
|
size -= 250; // -250 to avoid interrupt activity that's altered the stack.
|
|
@@ -292,7 +292,7 @@ int check_for_free_memory_corruption(const char * const title) {
|
292
|
292
|
// idle();
|
293
|
293
|
safe_delay(20);
|
294
|
294
|
#ifdef M100_FREE_MEMORY_DUMPER
|
295
|
|
- M100_dump_routine(" Memory corruption detected with sp<Heap\n", (char*)0x1B80, 0x21FF);
|
|
295
|
+ M100_dump_routine(" Memory corruption detected with sp<Heap\n", (char*)0x1B80, (char*)0x21FF);
|
296
|
296
|
#endif
|
297
|
297
|
}
|
298
|
298
|
|