comparison packages/redboot/current/src/flash.c @ 117:bd1a71e3e476 ecos-sw-2000-08-25

Merge from eCos master repository on 2000-08-25-19:22:58-BST
author jlarmour
date Fri, 25 Aug 2000 19:17:22 +0000
parents 6ed91473a1cd
children 77cec8369160
comparison
equal deleted inserted replaced
116:a0f9581a3a09 117:bd1a71e3e476
61 RedBoot_cmd("fis", 61 RedBoot_cmd("fis",
62 "Manage FLASH images", 62 "Manage FLASH images",
63 "{cmds}", 63 "{cmds}",
64 do_fis 64 do_fis
65 ); 65 );
66 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
66 RedBoot_cmd("fconfig", 67 RedBoot_cmd("fconfig",
67 "Manage configuration kept in FLASH memory", 68 "Manage configuration kept in FLASH memory",
68 "", 69 "[-l]",
69 do_flash_config 70 do_flash_config
70 ); 71 );
72 #endif
71 73
72 // Internal commands 74 // Internal commands
73 local_cmd_entry("init", 75 local_cmd_entry("init",
74 "Initialize FLASH Image System [FIS]", 76 "Initialize FLASH Image System [FIS]",
75 "", 77 "[-f]",
76 fis_init, 78 fis_init,
77 FIS_cmds 79 FIS_cmds
78 ); 80 );
79 local_cmd_entry("list", 81 local_cmd_entry("list",
80 "Display contents of FLASH Image System [FIS]", 82 "Display contents of FLASH Image System [FIS]",
139 void *fis_base, *err_addr; 141 void *fis_base, *err_addr;
140 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG 142 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
141 void *cfg_base; 143 void *cfg_base;
142 #endif 144 #endif
143 bool full_init = false; 145 bool full_init = false;
144 146 struct option_info opts[1];
145 if (argc > 2) { 147
146 if (strcmp(argv[2], "-f") != 0) { 148 init_opts(&opts[0], 'f', false, OPTION_ARG_TYPE_FLG,
147 fis_usage("bad parameter"); 149 (void **)&full_init, (bool *)0, "full initialization, erases all of flash");
148 return; 150 if (!scan_opts(argc, argv, 2, opts, 1, 0, 0, ""))
149 } 151 {
150 full_init = true; 152 return;
151 } 153 }
154
152 if (!verify_action("About to initialize [format] FLASH image system")) { 155 if (!verify_action("About to initialize [format] FLASH image system")) {
153 printf("** Aborted\n"); 156 printf("** Aborted\n");
154 return; 157 return;
155 } 158 }
156 printf("*** Initialize FLASH Image System\n"); 159 printf("*** Initialize FLASH Image System\n");
330 { 333 {
331 fis_usage("invalid arguments"); 334 fis_usage("invalid arguments");
332 return; 335 return;
333 } 336 }
334 337
335
336 if (!mem_addr_set || !length_set || !name) { 338 if (!mem_addr_set || !length_set || !name) {
337 fis_usage("required parameter missing"); 339 fis_usage("required parameter missing");
338 return; 340 return;
339 } 341 }
340 if (flash_addr_set && 342 if (flash_addr_set &&
644 CYG_HAL_TABLE_END( __CONFIG_options_TAB_END__, RedBoot_config_options); 646 CYG_HAL_TABLE_END( __CONFIG_options_TAB_END__, RedBoot_config_options);
645 647
646 extern struct config_option __CONFIG_options_TAB__[], __CONFIG_options_TAB_END__[]; 648 extern struct config_option __CONFIG_options_TAB__[], __CONFIG_options_TAB_END__[];
647 649
648 static int 650 static int
649 get_config(struct config_option *opt, int offset) 651 get_config(struct config_option *opt, int offset, bool list_only)
650 { 652 {
651 char line[80], *sp, *lp; 653 char line[80], *sp, *lp;
652 int ret; 654 int ret;
653 bool hold_bool_val, enable; 655 bool hold_bool_val, enable;
654 unsigned long hold_int_val; 656 unsigned long hold_int_val;
701 *lp++ = '\n'; 703 *lp++ = '\n';
702 sp = lp; 704 sp = lp;
703 } 705 }
704 break; 706 break;
705 } 707 }
708 if (list_only) {
709 printf("\n");
710 return CONFIG_OK;
711 }
706 if (opt->type != CONFIG_SCRIPT) { 712 if (opt->type != CONFIG_SCRIPT) {
707 ret = gets(line, sizeof(line), 0); 713 ret = gets(line, sizeof(line), 0);
708 if (ret < 0) return CONFIG_ABORT; 714 if (ret < 0) return CONFIG_ABORT;
709 if (strlen(line) == 0) return CONFIG_OK; // Just a CR - leave value untouched 715 if (strlen(line) == 0) return CONFIG_OK; // Just a CR - leave value untouched
710 if (line[0] == '.') return CONFIG_DONE; 716 if (line[0] == '.') return CONFIG_DONE;
840 struct config_option *optbeg = __CONFIG_options_TAB__; 846 struct config_option *optbeg = __CONFIG_options_TAB__;
841 struct config_option *optend = __CONFIG_options_TAB_END__; 847 struct config_option *optend = __CONFIG_options_TAB_END__;
842 struct config_option *opt = __CONFIG_options_TAB__; 848 struct config_option *opt = __CONFIG_options_TAB__;
843 struct _config hold_config; 849 struct _config hold_config;
844 int offset = sizeof(unsigned long); 850 int offset = sizeof(unsigned long);
851 struct option_info opts[1];
852 bool list_only;
845 853
846 if (!do_flash_init()) return; 854 if (!do_flash_init()) return;
847 memcpy(&hold_config, &config, sizeof(config)); 855 memcpy(&hold_config, &config, sizeof(config));
848 script = (unsigned char *)0; 856 script = (unsigned char *)0;
849 857
858 init_opts(&opts[0], 'l', false, OPTION_ARG_TYPE_FLG,
859 (void **)&list_only, (bool *)0, "list configuration only");
860 if (!scan_opts(argc, argv, 1, opts, 1, 0, 0, ""))
861 {
862 return;
863 }
864
850 while (opt != optend) { 865 while (opt != optend) {
851 ret = get_config(opt, offset); 866 ret = get_config(opt, offset, list_only);
852 switch (ret) { 867 switch (ret) {
853 case CONFIG_DONE: 868 case CONFIG_DONE:
854 goto done; 869 goto done;
855 case CONFIG_ABORT: 870 case CONFIG_ABORT:
856 memcpy(&config, &hold_config, sizeof(config)); 871 memcpy(&config, &hold_config, sizeof(config));