// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
// Copyright (C) 2002, 2003, 2004 Gary Thomas
+// Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
-//
-// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
-// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): gthomas
-// Contributors: gthomas, tkoeller
+// Contributors: gthomas, tkoeller, eCosCentric
// Date: 2000-07-14
// Purpose:
// Description:
#ifdef HAL_PLATFORM_CPU
diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA);
#endif
- diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n\n");
+ diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n");
+ diag_printf("Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited\n\n");
diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)ram_end);
diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end);
diag_printf(" available\n");
//
static hal_jmp_buf error_jmpbuf;
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
-externC
-#endif
- void* volatile __mem_fault_handler;
+__externC void* volatile __mem_fault_handler;
static void error_handler(void)
{
hal_longjmp(error_jmpbuf, 1);
}
+#endif
//
console_selected = false;
#endif
console_echo = true;
- CYGACC_CALL_IF_DELAY_US((cyg_int32)2*100000);
ram_start = (unsigned char *)CYGMEM_REGION_ram;
ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE);
workspace_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE);
#endif
- if ( ram_end < workspace_end ) {
+ if (ram_end < workspace_end) {
// when *less* SDRAM is installed than the possible maximum,
// but the heap1 region remains greater...
workspace_end = ram_end;
}
+ workspace_end_init=workspace_end;
+
// Nothing has ever been loaded into memory
entry_address = (unsigned long)NO_MEMORY;
script_timeout = CYGNUM_REDBOOT_BOOT_SCRIPT_DEFAULT_TIMEOUT;
#endif
- for (init_entry = __RedBoot_INIT_TAB__; init_entry != &__RedBoot_INIT_TAB_END__; init_entry++) {
+ for (init_entry = __RedBoot_INIT_TAB__; init_entry != &__RedBoot_INIT_TAB_END__; init_entry++) {
(*init_entry->fun)();
}
#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
# ifdef CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT
if (!script) {
- script = CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT;
+ script = CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT;
}
# endif
if (script) {
- // Give the guy a chance to abort any boot script
- unsigned char *hold_script = script;
- int script_timeout_ms = script_timeout * CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION;
- diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
- script_timeout_ms/1000, script_timeout_ms%1000);
- script = (unsigned char *)0;
- res = _GETS_CTRLC; // Treat 0 timeout as ^C
- while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
- res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
- if (res >= _GETS_OK) {
- diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
- script_timeout_ms/1000, script_timeout_ms%1000);
- continue; // Ignore anything but ^C
- }
- if (res != _GETS_TIMEOUT) break;
- script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
- }
- if (res == _GETS_CTRLC) {
- script = (unsigned char *)0; // Disable script
- } else {
- script = hold_script; // Re-enable script
- }
+ // Give the guy a chance to abort any boot script
+ unsigned char *hold_script = script;
+ int script_timeout_ms = script_timeout * CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION;
+ diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
+ script_timeout_ms / 1000, script_timeout_ms % 1000);
+ script = NULL;
+ res = _GETS_CTRLC; // Treat 0 timeout as ^C
+ while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
+ res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
+ if (res >= _GETS_OK) {
+ diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
+ script_timeout_ms / 1000, script_timeout_ms % 1000);
+ } else if (res != _GETS_TIMEOUT) {
+ break;
+ }
+ script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
+ }
+ if (res == _GETS_CTRLC) {
+ script = NULL; // Disable script
+ } else {
+ script = hold_script; // Re-enable script
+ }
}
#endif
-
+ CYG_ASSERT(workspace_start < workspace_end,
+ "negative workspace size");
while (true) {
if (prompt) {
diag_printf("RedBoot> ");
CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
// set up a temporary context that will take us to the trampoline
- HAL_THREAD_INIT_CONTEXT((CYG_ADDRWORD)workspace_end,
+ HAL_THREAD_INIT_CONTEXT(workspace_end,
breakpoint, trampoline,0);
// switch context to trampoline (get GDB stubs started)
#endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
{
expand_aliases(line, sizeof(line));
- command = (char *)&line;
+ command = line;
if ((*command == '#') || (*command == '=')) {
// Special cases
if (*command == '=') {
}
} else {
while (strlen(command) > 0) {
- if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) {
+ if ((cmd = parse(&command, &argc, &argv[0])) != NULL) {
// Try to handle aborts - messy because of the stack unwinding...
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
__mem_fault_handler = error_handler;
+#endif
if (hal_setjmp(error_jmpbuf)) {
diag_printf("** command abort - illegal memory access?\n");
} else {
(cmd->fun)(argc, argv);
}
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
__mem_fault_handler = 0;
+#endif
} else {
diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]);
}
}
if (show) {
diag_printf("%s\n %s %s %s\n", cmd->help, pre, cmd->str, cmd->usage);
- if ((cmd->sub_cmds != (struct cmd *)0) && (which != (char *)0)) {
+ if ((cmd->sub_cmds != NULL) && (which != NULL)) {
show_help(cmd->sub_cmds, cmd->sub_cmds_end, 0, cmd->str);
}
}
do_help(int argc, char *argv[])
{
struct cmd *cmd;
- char *which = (char *)0;
+ char *which = NULL;
- if (!scan_opts(argc, argv, 1, 0, 0, (void *)&which, OPTION_ARG_TYPE_STR, "<topic>")) {
+ if (!scan_opts(argc, argv, 1, 0, 0, &which, OPTION_ARG_TYPE_STR, "<topic>")) {
diag_printf("Invalid argument\n");
return;
}
void
do_go(int argc, char *argv[])
{
- int i, cur, num_options;
+ int i, cur, num_options = 0;
unsigned long entry;
unsigned long oldints;
bool wait_time_set;
char line[8];
hal_virtual_comm_table_t *__chan;
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
__mem_fault_handler = 0; // Let GDB handle any faults directly
+#endif
entry = entry_address; // Default from last 'load' operation
- init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM,
- (void *)&wait_time, (bool *)&wait_time_set, "wait timeout");
- init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG,
- (void *)&cache_enabled, (bool *)0, "go with caches enabled");
- num_options = 2;
+ init_opts(&opts[num_options++], 'w', true, OPTION_ARG_TYPE_NUM,
+ &wait_time, &wait_time_set, "wait timeout");
+ init_opts(&opts[num_options++], 'c', false, OPTION_ARG_TYPE_FLG,
+ &cache_enabled, NULL, "go with caches enabled");
#ifdef CYGPKG_IO_ETH_DRIVERS
- init_opts(&opts[2], 'n', false, OPTION_ARG_TYPE_FLG,
- (void *)&stop_net, (bool *)0, "go with network driver stopped");
- num_options++;
+ init_opts(&opts[num_options++], 'n', false, OPTION_ARG_TYPE_FLG,
+ &stop_net, NULL, "go with network driver stopped");
#endif
CYG_ASSERT(num_options <= NUM_ELEMS(opts), "Too many options");
- if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address"))
- {
+ if (!scan_opts(argc, argv, 1, opts, num_options, &entry,
+ OPTION_ARG_TYPE_NUM, "starting address")) {
return;
}
if (entry == (unsigned long)NO_MEMORY) {
- diag_printf("No entry point known - aborted\n");
+ err_printf("No entry point known - aborted\n");
return;
}
if (wait_time_set) {
int script_timeout_ms = wait_time * 1000;
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
unsigned char *hold_script = script;
- script = (unsigned char *)0;
+ script = NULL;
#endif
diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
(void *)entry, wait_time);
HAL_ICACHE_INVALIDATE_ALL();
HAL_DCACHE_INVALIDATE_ALL();
// set up a temporary context that will take us to the trampoline
- HAL_THREAD_INIT_CONTEXT((CYG_ADDRWORD)workspace_end,
+ HAL_THREAD_INIT_CONTEXT(workspace_end,
entry, trampoline, 0);
// switch context to trampoline
#endif
init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
- (void *)&new_rate, (bool *)&new_rate_set, "new baud rate");
+ &new_rate, &new_rate_set, "new baud rate");
if (!scan_opts(argc, argv, 1, opts, 1, 0, 0, "")) {
return;
}
}
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
opt.type = CONFIG_INT;
- opt.enable = (char *)0;
+ opt.enable = NULL;
opt.enable_sense = 1;
opt.key = "console_baud_rate";
opt.dflt = new_rate;
int seg;
for (seg = 0; seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS; seg++) {
- if (mem_segments[seg].start != NO_MEMORY) {
+ if (mem_segments[seg].start != NO_MEMORY) {
if ((addr >= mem_segments[seg].start) && (addr < mem_segments[seg].end)) {
return true;
}