From 228b1c5f79749940e11247bd97626e21df7033bd Mon Sep 17 00:00:00 2001 From: Leo C Date: Sun, 8 Apr 2018 14:35:22 +0200 Subject: [PATCH 1/1] Remove extern declarations from command_tbl.c, create .h files for that. --- avr/cmd_attach.c | 4 +--- avr/cmd_boot.c | 3 +-- avr/cmd_date.c | 4 +--- avr/cmd_fat.c | 4 ---- avr/cmd_gpio.c | 5 +---- avr/cmd_loadcpm3.c | 5 +---- avr/cmd_loadihex.c | 5 +---- avr/cmd_misc.c | 3 +-- avr/cmd_run.c | 6 +----- avr/cmd_sd.c | 4 +--- avr/command.c | 2 ++ avr/command_tbl.c | 44 ++++++++++++------------------------------ avr/env.c | 7 +------ avr/eval_arg.c | 4 +--- include/cmd_attach.h | 14 ++++++++++++++ include/cmd_boot.h | 22 +++++++++++++++++++++ include/cmd_date.h | 14 ++++++++++++++ include/cmd_fat.h | 8 +++++++- include/cmd_gpio.h | 15 ++++++++++++++ include/cmd_loadcpm3.h | 14 ++++++++++++++ include/cmd_loadihex.h | 14 ++++++++++++++ include/cmd_mem.h | 1 - include/cmd_misc.h | 15 ++++++++++++++ include/cmd_run.h | 16 +++++++++++++++ include/cmd_sd.h | 16 +++++++++++++++ include/command.h | 2 -- include/common.h | 3 +++ include/debug.h | 15 +++++++++----- include/env.h | 8 ++++++-- 29 files changed, 191 insertions(+), 86 deletions(-) create mode 100644 include/cmd_attach.h create mode 100644 include/cmd_boot.h create mode 100644 include/cmd_date.h create mode 100644 include/cmd_gpio.h create mode 100644 include/cmd_loadcpm3.h create mode 100644 include/cmd_loadihex.h create mode 100644 include/cmd_misc.h create mode 100644 include/cmd_run.h create mode 100644 include/cmd_sd.h diff --git a/avr/cmd_attach.c b/avr/cmd_attach.c index 361ba6d..fcc4f49 100644 --- a/avr/cmd_attach.c +++ b/avr/cmd_attach.c @@ -8,9 +8,7 @@ * attach channels to devices */ -#include "common.h" -#include -#include +#include "cmd_attach.h" #include "command.h" #include "z180-serv.h" diff --git a/avr/cmd_boot.c b/avr/cmd_boot.c index 6e117d9..b4aa5c0 100644 --- a/avr/cmd_boot.c +++ b/avr/cmd_boot.c @@ -10,11 +10,10 @@ /* * Misc boot support */ -#include "common.h" +#include "cmd_boot.h" #include #include -#include "command.h" #include "cli_readline.h" /* console_buffer[] */ #include "cli.h" /* run_command() */ #include "env.h" diff --git a/avr/cmd_date.c b/avr/cmd_date.c index 91a3d44..cbc4a32 100644 --- a/avr/cmd_date.c +++ b/avr/cmd_date.c @@ -10,11 +10,9 @@ /* * RTC, Date & Time support: get and set date & time */ -#include "common.h" -#include +#include "cmd_date.h" #include "time.h" #include "rtc.h" -#include "command.h" /* diff --git a/avr/cmd_fat.c b/avr/cmd_fat.c index 9e3114d..cd35c8a 100644 --- a/avr/cmd_fat.c +++ b/avr/cmd_fat.c @@ -9,11 +9,7 @@ */ #include "cmd_fat.h" -#include "common.h" -#include -#include -#include "command.h" #include "ff.h" #include "z80-if.h" #include "eval_arg.h" diff --git a/avr/cmd_gpio.c b/avr/cmd_gpio.c index 5d7eb6c..8f50ca3 100644 --- a/avr/cmd_gpio.c +++ b/avr/cmd_gpio.c @@ -4,12 +4,9 @@ * SPDX-License-Identifier: GPL-2.0 */ -#include "common.h" -#include -#include +#include "cmd_gpio.h" #include -#include "command.h" #include "print-utils.h" #include "getopt-min.h" #include "env.h" diff --git a/avr/cmd_loadcpm3.c b/avr/cmd_loadcpm3.c index f847290..39e3278 100644 --- a/avr/cmd_loadcpm3.c +++ b/avr/cmd_loadcpm3.c @@ -8,12 +8,9 @@ * See CP/M 3 System Manual, Appendix D: CPM3.SYS File Format */ -#include "common.h" +#include "cmd_loadcpm3.h" #include -#include -#include -#include "command.h" #include "env.h" #include "ff.h" #include "eval_arg.h" diff --git a/avr/cmd_loadihex.c b/avr/cmd_loadihex.c index ee4b40b..2c0fa9e 100644 --- a/avr/cmd_loadihex.c +++ b/avr/cmd_loadihex.c @@ -4,12 +4,9 @@ * SPDX-License-Identifier: GPL-2.0 */ -#include "common.h" -#include +#include "cmd_loadihex.h" #include -#include -#include "command.h" #include "con-utils.h" #include "z80-if.h" #include "debug.h" diff --git a/avr/cmd_misc.c b/avr/cmd_misc.c index a0ee26e..a88ba72 100644 --- a/avr/cmd_misc.c +++ b/avr/cmd_misc.c @@ -7,11 +7,10 @@ * SPDX-License-Identifier: GPL-2.0 */ -#include "common.h" +#include "cmd_misc.h" #include "eval_arg.h" #include -#include "command.h" #include "timer.h" #include "con-utils.h" #include "getopt-min.h" diff --git a/avr/cmd_run.c b/avr/cmd_run.c index 6ad758b..467739c 100644 --- a/avr/cmd_run.c +++ b/avr/cmd_run.c @@ -4,13 +4,9 @@ * SPDX-License-Identifier: GPL-2.0 */ -#include "common.h" -#include -#include +#include "cmd_run.h" #include "ff.h" -#include "config.h" -#include "command.h" #include "cli_readline.h" /* console_buffer[] */ #include "cli.h" /* run_command() */ #include "env.h" diff --git a/avr/cmd_sd.c b/avr/cmd_sd.c index 10b5bb5..e2adbe7 100644 --- a/avr/cmd_sd.c +++ b/avr/cmd_sd.c @@ -4,10 +4,8 @@ * SPDX-License-Identifier: GPL-2.0 */ -#include "common.h" -//#include +#include "cmd_sd.h" -#include "command.h" #include "diskio.h" #include "ff.h" #include "eval_arg.h" diff --git a/avr/command.c b/avr/command.c index 938edc3..b9c5e56 100644 --- a/avr/command.c +++ b/avr/command.c @@ -497,6 +497,8 @@ command_ret_t cmd_call(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * con return result; } +#pragma GCC diagnostic ignored "-Wclobbered" + command_ret_t cmd_process(uint_fast8_t flag, int argc, char * const argv[], uint_fast8_t *repeatable) { diff --git a/avr/command_tbl.c b/avr/command_tbl.c index 6180428..b65db54 100644 --- a/avr/command_tbl.c +++ b/avr/command_tbl.c @@ -7,39 +7,19 @@ #include "common.h" #include "command.h" #include "cmd_mem.h" +#include "cmd_boot.h" +#include "cmd_misc.h" +#include "cmd_date.h" +#include "cmd_run.h" +#include "cmd_loadcpm3.h" +#include "cmd_loadihex.h" +#include "cmd_gpio.h" +#include "cmd_sd.h" +#include "cmd_fat.h" +#include "cmd_attach.h" +#include "env.h" +#include "debug.h" -extern command_ret_t do_echo(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_sleep(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_env_print(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_env_default(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_env_set(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_env_save(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_loadf(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_bootcf(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_loadcpm3(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_loadihex(cmd_tbl_t *, uint_fast8_t, int, char * const []); -#if defined(CONFIG_CMD_LOADB) -extern command_ret_t do_load_serial_bin(cmd_tbl_t *, uint_fast8_t, int, char * const []); -#endif -extern command_ret_t do_go(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_restart(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_console(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_dump_mem(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_mem_mm_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_mem_nm_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_eep_cp(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_busreq_pulse(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_date(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_gpio(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_sd(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_fat(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_run(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_source(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_attach(cmd_tbl_t *, uint_fast8_t, int, char * const []); -extern command_ret_t do_pr_free_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []); - -extern cmd_tbl_t cmd_tbl_fat[]; -extern cmd_tbl_t cmd_tbl_sd[]; cmd_tbl_t cmd_tbl[] = { diff --git a/avr/env.c b/avr/env.c index 39effac..3a12325 100644 --- a/avr/env.c +++ b/avr/env.c @@ -4,18 +4,13 @@ * SPDX-License-Identifier: GPL-2.0 */ -#include "common.h" -#include -#include -#include +#include "env.h" #include #include "config.h" #include "debug.h" #include "xmalloc.h" #include "crc.h" -#include "command.h" -#include "env.h" #define ENV_SIZE (CONFIG_ENV_SIZE - sizeof(uint16_t) -1) diff --git a/avr/eval_arg.c b/avr/eval_arg.c index b931509..fd8b067 100644 --- a/avr/eval_arg.c +++ b/avr/eval_arg.c @@ -5,12 +5,10 @@ */ #include "eval_arg.h" -#include "common.h" -#include +#include "command.h" /* jump_buf */ #include #include #include "print-utils.h" -#include "command.h" /* jump_buf */ static jmp_buf eval_jbuf; static char ch; diff --git a/include/cmd_attach.h b/include/cmd_attach.h new file mode 100644 index 0000000..2bd7363 --- /dev/null +++ b/include/cmd_attach.h @@ -0,0 +1,14 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_ATTACH_H +#define CMD_ATTACH_H + +#include "command.h" + +command_ret_t do_attach(cmd_tbl_t *, uint_fast8_t, int, char * const []); + +#endif /* CMD_ATTACH_H */ diff --git a/include/cmd_boot.h b/include/cmd_boot.h new file mode 100644 index 0000000..015a215 --- /dev/null +++ b/include/cmd_boot.h @@ -0,0 +1,22 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_BOOT_H +#define CMD_BOOT_H + +#include "command.h" + +command_ret_t do_loadf(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_bootcf(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_busreq_pulse(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_go(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_restart(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_reset(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]); +command_ret_t do_console(cmd_tbl_t *, uint_fast8_t, int, char * const []); + + + +#endif /* CMD_BOOT_H */ diff --git a/include/cmd_date.h b/include/cmd_date.h new file mode 100644 index 0000000..cd98f2a --- /dev/null +++ b/include/cmd_date.h @@ -0,0 +1,14 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_DATE_H +#define CMD_DATE_H + +#include "command.h" + +command_ret_t do_date(cmd_tbl_t *, uint_fast8_t, int, char * const []); + +#endif /* CMD_DATE_H */ diff --git a/include/cmd_fat.h b/include/cmd_fat.h index 66be559..ed96a52 100644 --- a/include/cmd_fat.h +++ b/include/cmd_fat.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2014 Leo C. + * (C) Copyright 2014-2018 Leo C. * * SPDX-License-Identifier: GPL-2.0 */ @@ -7,6 +7,12 @@ #ifndef CMD_FAT_H #define CMD_FAT_H +#include "command.h" + +extern cmd_tbl_t cmd_tbl_fat[]; + +command_ret_t do_fat(cmd_tbl_t *, uint_fast8_t, int, char * const []); + void setup_fatfs(void); #endif /* CMD_FAT_H */ diff --git a/include/cmd_gpio.h b/include/cmd_gpio.h new file mode 100644 index 0000000..d2f211d --- /dev/null +++ b/include/cmd_gpio.h @@ -0,0 +1,15 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_GPIO_H +#define CMD_GPIO_H + +#include "command.h" + +command_ret_t do_gpio(cmd_tbl_t *, uint_fast8_t, int, char * const []); + + +#endif /* CMD_GPIO_H */ diff --git a/include/cmd_loadcpm3.h b/include/cmd_loadcpm3.h new file mode 100644 index 0000000..5ef2a9d --- /dev/null +++ b/include/cmd_loadcpm3.h @@ -0,0 +1,14 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_LOADCPM3_H +#define CMD_LOADCPM3_H + +#include "command.h" + +command_ret_t do_loadcpm3(cmd_tbl_t *, uint_fast8_t, int, char * const []); + +#endif /* CMD_LOADCPM3_H */ diff --git a/include/cmd_loadihex.h b/include/cmd_loadihex.h new file mode 100644 index 0000000..7ca53cf --- /dev/null +++ b/include/cmd_loadihex.h @@ -0,0 +1,14 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_LOADIHEX_H +#define CMD_LOADIHEX_H + +#include "command.h" + +command_ret_t do_loadihex(cmd_tbl_t *, uint_fast8_t, int, char * const []); + +#endif /* CMD_LOADIHEX_H */ diff --git a/include/cmd_mem.h b/include/cmd_mem.h index 625ab8d..b019d27 100644 --- a/include/cmd_mem.h +++ b/include/cmd_mem.h @@ -8,7 +8,6 @@ #define CMD_MEM_H #include "command.h" -#include "cmd_mem.h" extern command_ret_t do_mem_md(cmd_tbl_t *, uint_fast8_t, int, char * const []); diff --git a/include/cmd_misc.h b/include/cmd_misc.h new file mode 100644 index 0000000..f0f56a7 --- /dev/null +++ b/include/cmd_misc.h @@ -0,0 +1,15 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_MISC_H +#define CMD_MISC_H + +#include "command.h" + +command_ret_t do_echo(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]); +command_ret_t do_sleep(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]); + +#endif /* CMD_MISC_H */ diff --git a/include/cmd_run.h b/include/cmd_run.h new file mode 100644 index 0000000..4691a55 --- /dev/null +++ b/include/cmd_run.h @@ -0,0 +1,16 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_RUN_H +#define CMD_RUN_H + +#include "command.h" + +command_ret_t do_source(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_run(cmd_tbl_t *, uint_fast8_t, int, char * const []); + + +#endif /* CMD_RUN_H */ diff --git a/include/cmd_sd.h b/include/cmd_sd.h new file mode 100644 index 0000000..0a5f5e5 --- /dev/null +++ b/include/cmd_sd.h @@ -0,0 +1,16 @@ +/* + * (C) Copyright 2018 Leo C. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef CMD_SD_H +#define CMD_SD_H + +#include "command.h" + +extern cmd_tbl_t cmd_tbl_sd[]; + +command_ret_t do_sd(cmd_tbl_t *, uint_fast8_t, int, char * const []); + +#endif /* CMD_SD_H */ diff --git a/include/command.h b/include/command.h index 2ea7505..e44512e 100644 --- a/include/command.h +++ b/include/command.h @@ -124,8 +124,6 @@ static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp UNUSED, const char *cmd extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]); -extern command_ret_t do_reset(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]); - /* * Command Flags: */ diff --git a/include/common.h b/include/common.h index 1064bf3..eb38853 100644 --- a/include/common.h +++ b/include/common.h @@ -9,6 +9,9 @@ #include #include +#include +#include +#include #define GCC_VERSION (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__) diff --git a/include/debug.h b/include/debug.h index 0ee0129..0d60177 100644 --- a/include/debug.h +++ b/include/debug.h @@ -11,7 +11,16 @@ #ifndef DEBUG_H_ #define DEBUG_H_ -#include "common.h" +#include "command.h" + +command_ret_t do_dump_mem(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_mem_mm_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_mem_nm_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_eep_cp(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_pr_free_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []); + +void printfreelist(const char * title); + #ifdef DEBUG #define _DEBUG 1 @@ -43,8 +52,4 @@ #endif #endif /* 0 */ - -void printfreelist(const char * title); - - #endif /* DEBUG_H_ */ diff --git a/include/env.h b/include/env.h index bc44413..1dbe30f 100644 --- a/include/env.h +++ b/include/env.h @@ -7,10 +7,14 @@ #ifndef ENV_H #define ENV_H -#include +#include "command.h" -int env_init(void); +command_ret_t do_env_print(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_env_default(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_env_set(cmd_tbl_t *, uint_fast8_t, int, char * const []); +command_ret_t do_env_save(cmd_tbl_t *, uint_fast8_t, int, char * const []); +int env_init(void); char *getenv_str(const MEMX char *name); unsigned long getenv_ulong(const MEMX char *name, int base, unsigned long default_val); bool getenv_yesno(const MEMX char *name); -- 2.39.2