]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Reduce static RAM usage
authorLeo C <erbl259-lmu@yahoo.de>
Mon, 20 Aug 2018 01:11:20 +0000 (03:11 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Mon, 20 Aug 2018 01:11:20 +0000 (03:11 +0200)
avr/cmd_fat.c
avr/cmd_loadcpm3.c
avr/main.c
avr/print-utils.c
avr/z180-serv.c

index 60102ed87df35a2d402d81f06a9d7f60bb667f5a..c1d3770096e3acfa196aae45431bd2d9e73625cf 100644 (file)
@@ -131,7 +131,6 @@ command_ret_t do_pwd(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc
        buf = (char *) malloc(BUFFER_SIZE);
        if (buf == NULL) {
                printf_P(PSTR("pwd: Out of Memory!\n"));
-               free(buf);
                return CMD_RET_FAILURE;
        }
 
index 39e3278eee9def269fd31e3892ee5438a70c0ae6..6ccb3f9597245f05081747187b59ebf9c837da26 100644 (file)
@@ -71,7 +71,7 @@ command_ret_t do_loadcpm3(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char *
        uint32_t banked_base;
        char *fname;
        FIL File;
-       char default_fname[] = CONFIG_CPM3_SYSFILE;
+       char default_fname[strlen_P(PSTR(CONFIG_CPM3_SYSFILE)) + 1];
        unsigned int br;                                        /* bytes read */
        uint8_t buffer[RS];
        int res;
@@ -90,11 +90,13 @@ command_ret_t do_loadcpm3(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char *
                common_base = eval_arg(argv[2], NULL);
 
        fname = getenv_str(PSTR(ENV_CPM3_SYSFILE));
+       if (fname == NULL || *fname == '\0') {
+               strcpy_P(default_fname, PSTR(CONFIG_CPM3_SYSFILE));
+               fname = default_fname;
+       }
        if (argc > 1) {
                fname = argv[1];
        }
-       if (fname == NULL || *fname == '\0')
-               fname = default_fname;
 
        res = f_open(&File, fname, FA_READ );
        if (res) {
index 450e2bad324b08161c55e47baed790ee4d706bca..1fba3cbfcea8031a6b16e034f800aa6f5b44eec4 100644 (file)
@@ -67,15 +67,17 @@ void print_reset_reason(void)
        uint8_t r = mcusr & 0x1f;
        const FLASH char * const FLASH *p = rreasons;
 
-       printf_P(PSTR("### Reset reason(s): %s"), r ? "" : "none");
+       my_puts_P(PSTR("### Reset reason(s): "));
+       if (r == 0)
+               my_puts_P(PSTR("none"));
        for ( ; r; p++, r >>= 1) {
                if (r & 1) {
                        my_puts_P(*p);
                        if (r & ~1)
-                               printf_P(PSTR(", "));
+                               my_puts_P(PSTR(", "));
                }
        }
-       printf_P(PSTR(".\n"));
+       my_puts_P(PSTR(".\n"));
 }
 
 #endif
@@ -223,7 +225,7 @@ const char *bootdelay_process(void)
 static
 void autoboot_command(const char *s)
 {
-       debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
+       debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "");
        _delay_ms(20);
 
        if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) {
index 83f86a91fe36cf5c4c0ce3030d20932bc28141a2..b8100a0411b870bb2d2280acc479f25d60012dc9 100644 (file)
@@ -42,7 +42,6 @@ int dump_mem(uint32_t address, uint32_t offset, uint32_t len,
                int (*readfkt)(uint8_t *, uint32_t, uint8_t), char *title)
 {
        uint8_t buf[16];
-       char *indent = NULL;
        uint8_t llen = 16;
        uint8_t pre = offset % 16;
        offset = offset & ~0x0f;
@@ -51,7 +50,6 @@ int dump_mem(uint32_t address, uint32_t offset, uint32_t len,
 
        if (title && *title) {
                printf_P(PSTR("%s\n"),title);
-               indent = "    ";
        }
 
        while (len) {
@@ -60,7 +58,9 @@ int dump_mem(uint32_t address, uint32_t offset, uint32_t len,
                if (readfkt(buf, address, llen - pre) != 0)
                        return -2; /* TODO: Error codes */
 
-               printf_P(PSTR("%s%.5lx:"),indent, offset);
+               if (title)
+                       print_blanks(4);
+               printf_P(PSTR("%.5lx:"),offset);
                for (i = 0; i < llen; i++) {
                        if ((i % 8) == 0)
                                putchar(' ');
index d1f52ddbac19f42e46b43e75bcd4ff679c66458f..ac57645c7318f4e401df7de0b09c25720503f00d 100644 (file)
@@ -240,8 +240,9 @@ int drv_list(void)
        for (uint8_t i = 0; i < CONFIG_CPM_MAX_DRIVE; i++) {
                struct cpm_drive_s * p = &drv_table[i];
                if (p->img_name) {
-                       printf_P(PSTR("  dsk%d: %2s %3s attached to %s\n"), i,
-                                       p->opt&DRV_OPT_RO ? "RO":"RW", p->opt&DRV_OPT_DEBUG ? "DBG":"",
+                       printf_P(PSTR("  dsk%d: %2S %3S attached to %s\n"), i,
+                                       p->opt&DRV_OPT_RO ? PSTR("RO") : PSTR("RW"),
+                                       p->opt&DRV_OPT_DEBUG ? PSTR("DBG") : PSTR(""),
                                        p->img_name);
                }
        }