comparison packages/redboot/current/src/main.c @ 2257:467fd46113f3

* src/fs/fileio.c (do_list): Use getcwd for current directory, rather than "." which may not be implemented in the FS. * src/parse.c (redboot_exec): Conditionalise use of __mem_fault_handler to only be when stubs are included. (error_handler): Ditto for this function. * src/main.c (cyg_start): Conditionalise use of __mem_fault_handler to only be when stubs are included. (do_go): Ditto. (error_handler): Ditto for this function. * src/fs/fileio.c (do_mkdir, do_deldir, do_del, do_write): Added some extra argument checking to these functions. * src/fs/fileio.c (do_mount): Only support -f with "legacy" flash block devices. Clear mount table on failure. (do_move): Silence rename undefined warning. (do_write): Silence warnings. (do_info): Support longer device names. * src/decompress.c (ZLIB_COMPRESSION_OVERHEAD): Increase substantially if jffs2 is present. * src/fs/fileio.c: Fixed some bugs in handling of mounts. The strings used in the mount table must be copied, otherwise the mount table is corrupted by later commands. Also toughened up some error testing. * doc/redboot_cmds.sgml: Added file mode documentation to load command. * doc/redboot_cmds.sgml: Added documentation of filesystem access commands. * src/fs/fileio.c (do_write): Added O_TRUNC to the open call to ensure that the file is resized to fit the new data. * src/fs/fileio.c: Significantly reorganized to present an interface similar to the fis commands. Added a variety of command to manipulate files and directories in a filesystem. * src/parse.c: Added redboot_exec() to provide an internal interface for executing RedBoot commands. Added err_printf() which allows an error message to be printed before longjumping out to an enclosing call to redboot_exec(). Where redboot_exec() is not involved, it just behaves like diag_printf(). * src/main.c: Removed unnecessary delay during startup. Changed diag_printf() in do_go() into err_printf(). * src/load.c: Changed some calls to diag_printf() to err_printf(). * src/net/net_io.c: Changed init priority to RedBoot_INIT_NET. * include/redboot.h: Added some extra initialization priorities. Added prototypes for redboot_exec() and err_printf().
author jlarmour
date Thu, 20 Jul 2006 20:27:47 +0000
parents 5c5e93c863ac
children 6cbecf3cc2e4
comparison
equal deleted inserted replaced
2256:9838a9103c2a 2257:467fd46113f3
8 //####ECOSGPLCOPYRIGHTBEGIN#### 8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // ------------------------------------------- 9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System. 10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
12 // Copyright (C) 2002, 2003, 2004 Gary Thomas 12 // Copyright (C) 2002, 2003, 2004 Gary Thomas
13 // Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited
13 // 14 //
14 // eCos is free software; you can redistribute it and/or modify it under 15 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free 16 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version. 17 // Software Foundation; either version 2 or (at your option) any later version.
17 // 18 //
31 // License. However the source code for this file must still be made available 32 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License. 33 // in accordance with section (3) of the GNU General Public License.
33 // 34 //
34 // This exception does not invalidate any other reasons why a work based on 35 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License. 36 // this file might be covered by the GNU General Public License.
36 //
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // ------------------------------------------- 37 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND#### 38 //####ECOSGPLCOPYRIGHTEND####
41 //========================================================================== 39 //==========================================================================
42 //#####DESCRIPTIONBEGIN#### 40 //#####DESCRIPTIONBEGIN####
43 // 41 //
44 // Author(s): gthomas 42 // Author(s): gthomas
45 // Contributors: gthomas, tkoeller 43 // Contributors: gthomas, tkoeller, eCosCentric
46 // Date: 2000-07-14 44 // Date: 2000-07-14
47 // Purpose: 45 // Purpose:
48 // Description: 46 // Description:
49 // 47 //
50 // This code is part of RedBoot (tm). 48 // This code is part of RedBoot (tm).
176 174
177 diag_printf(version); 175 diag_printf(version);
178 #ifdef HAL_PLATFORM_CPU 176 #ifdef HAL_PLATFORM_CPU
179 diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA); 177 diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA);
180 #endif 178 #endif
181 diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n\n"); 179 diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n");
180 diag_printf("Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited\n\n");
182 diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)ram_end); 181 diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)ram_end);
183 diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end); 182 diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end);
184 diag_printf(" available\n"); 183 diag_printf(" available\n");
185 #if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1 184 #if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
186 for (seg = 1; seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS; seg++) { 185 for (seg = 1; seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS; seg++) {
225 // 224 //
226 // Handle illegal memory accesses (and other abort conditions) 225 // Handle illegal memory accesses (and other abort conditions)
227 // 226 //
228 static hal_jmp_buf error_jmpbuf; 227 static hal_jmp_buf error_jmpbuf;
229 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS 228 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
230 externC 229 __externC void* volatile __mem_fault_handler;
231 #endif
232 void* volatile __mem_fault_handler;
233 230
234 static void error_handler(void) 231 static void error_handler(void)
235 { 232 {
236 hal_longjmp(error_jmpbuf, 1); 233 hal_longjmp(error_jmpbuf, 1);
237 } 234 }
235 #endif
238 236
239 237
240 // 238 //
241 // This is the main entry point for RedBoot 239 // This is the main entry point for RedBoot
242 // 240 //
272 CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL); 270 CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
273 #ifdef CYGPKG_REDBOOT_ANY_CONSOLE 271 #ifdef CYGPKG_REDBOOT_ANY_CONSOLE
274 console_selected = false; 272 console_selected = false;
275 #endif 273 #endif
276 console_echo = true; 274 console_echo = true;
277 CYGACC_CALL_IF_DELAY_US((cyg_int32)2*100000);
278 275
279 ram_start = (unsigned char *)CYGMEM_REGION_ram; 276 ram_start = (unsigned char *)CYGMEM_REGION_ram;
280 ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE); 277 ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE);
281 #ifdef HAL_MEM_REAL_REGION_TOP 278 #ifdef HAL_MEM_REAL_REGION_TOP
282 { 279 {
420 } 417 }
421 } else { 418 } else {
422 while (strlen(command) > 0) { 419 while (strlen(command) > 0) {
423 if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) { 420 if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) {
424 // Try to handle aborts - messy because of the stack unwinding... 421 // Try to handle aborts - messy because of the stack unwinding...
422 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
425 __mem_fault_handler = error_handler; 423 __mem_fault_handler = error_handler;
424 #endif
426 if (hal_setjmp(error_jmpbuf)) { 425 if (hal_setjmp(error_jmpbuf)) {
427 diag_printf("** command abort - illegal memory access?\n"); 426 diag_printf("** command abort - illegal memory access?\n");
428 } else { 427 } else {
429 (cmd->fun)(argc, argv); 428 (cmd->fun)(argc, argv);
430 } 429 }
430 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
431 __mem_fault_handler = 0; 431 __mem_fault_handler = 0;
432 #endif
432 } else { 433 } else {
433 diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]); 434 diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]);
434 } 435 }
435 } 436 }
436 } 437 }
525 #endif 526 #endif
526 struct option_info opts[3]; 527 struct option_info opts[3];
527 char line[8]; 528 char line[8];
528 hal_virtual_comm_table_t *__chan; 529 hal_virtual_comm_table_t *__chan;
529 530
531 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
530 __mem_fault_handler = 0; // Let GDB handle any faults directly 532 __mem_fault_handler = 0; // Let GDB handle any faults directly
533 #endif
531 entry = entry_address; // Default from last 'load' operation 534 entry = entry_address; // Default from last 'load' operation
532 init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM, 535 init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM,
533 (void *)&wait_time, (bool *)&wait_time_set, "wait timeout"); 536 (void *)&wait_time, (bool *)&wait_time_set, "wait timeout");
534 init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG, 537 init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG,
535 (void *)&cache_enabled, (bool *)0, "go with caches enabled"); 538 (void *)&cache_enabled, (bool *)0, "go with caches enabled");
545 if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address")) 548 if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address"))
546 { 549 {
547 return; 550 return;
548 } 551 }
549 if (entry == (unsigned long)NO_MEMORY) { 552 if (entry == (unsigned long)NO_MEMORY) {
550 diag_printf("No entry point known - aborted\n"); 553 err_printf("No entry point known - aborted\n");
551 return; 554 return;
552 } 555 }
553 if (wait_time_set) { 556 if (wait_time_set) {
554 int script_timeout_ms = wait_time * 1000; 557 int script_timeout_ms = wait_time * 1000;
555 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG 558 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG