Mercurial > ecos
changeset 556:f2b5df359050
Support return to redboot from go
line wrap: on
line diff
--- a/packages/hal/arm/arch/current/ChangeLog +++ b/packages/hal/arm/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2003-01-17 Patrick Doyle <wpd@delcomsys.com> * src/redboot_linux_exec.c (do_exec): Round the length up to a
--- a/packages/hal/arm/arch/current/src/hal_syscall.c +++ b/packages/hal/arm/arch/current/src/hal_syscall.c @@ -106,12 +106,6 @@ hal_syscall_handler(void) else put_register(PC, get_register(LR)); - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/hal/calmrisc16/arch/current/ChangeLog +++ b/packages/hal/calmrisc16/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2002-04-15 Jonathan Larmour <jlarmour@redhat.com> * src/hal_syscall.c (hal_syscall_handler): Add extra sig argument to @@ -25,7 +30,7 @@ 2001-05-03 Mark Salter <msalter@redhat //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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
--- a/packages/hal/calmrisc16/arch/current/src/hal_syscall.c +++ b/packages/hal/calmrisc16/arch/current/src/hal_syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -118,12 +118,6 @@ hal_syscall_handler(void) arg3 = get_register(REG_A10); arg4 = get_register(REG_A11); - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/hal/calmrisc32/arch/current/ChangeLog +++ b/packages/hal/calmrisc32/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2002-04-15 Jonathan Larmour <jlarmour@redhat.com> * src/hal_syscall.c (hal_syscall_handler): Add extra sig argument to @@ -24,7 +29,7 @@ 2001-03-26 Mark Salter <msalter@redhat //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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
--- a/packages/hal/calmrisc32/arch/current/src/hal_syscall.c +++ b/packages/hal/calmrisc32/arch/current/src/hal_syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -103,12 +103,6 @@ hal_syscall_handler(void) set_pc(get_pc()+2); - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/hal/common/current/ChangeLog +++ b/packages/hal/common/current/ChangeLog @@ -1,3 +1,7 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * include/hal_if.h: Add CYGNUM_CALL_IF_MONITOR_RETURN. + 2002-12-04 Gary Thomas <gthomas@ecoscentric.com> * cdl/hal.cdl: RAM applications should not claim (reset) version
--- a/packages/hal/common/current/include/hal_if.h +++ b/packages/hal/common/current/include/hal_if.h @@ -11,7 +11,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // Copyright (C) 2002 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under @@ -365,8 +365,9 @@ static __inline__ _rt_ #define CYGNUM_CALL_IF_DELAY_US 18 #define CYGNUM_CALL_IF_DBG_DATA 19 #define CYGNUM_CALL_IF_FLASH_CFG_OP 20 +#define CYGNUM_CALL_IF_MONITOR_RETURN 21 -#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_FLASH_CFG_OP +#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_MONITOR_RETURN #define CYGNUM_CALL_IF_INSTALL_BPT_FN 35 @@ -424,6 +425,7 @@ typedef void (__call_if_install_bpt_fn_t typedef cyg_bool (__call_if_flash_cfg_op_fn_t)(int __oper, char *__key, void *__val, int __type); typedef char *__call_if_monitor_version_t; +typedef void (__call_if_monitor_return_t)(int status); #ifndef CYGACC_CALL_IF_DEFINED @@ -619,6 +621,12 @@ static __inline__ _rt_ hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_CFG_OP]=(CYG_ADDRWORD)(_x_) #define CYGNUM_CALL_IF_FLASH_CFG_GET (0) +#define CYGACC_CALL_IF_MONITOR_RETURN(_u_) \ + CYGACC_CALL_VV1(__call_if_monitor_return_t*, CYGNUM_CALL_IF_MONITOR_RETURN, (_u_)) +__call_voidVV1(CYGNUM_CALL_IF_MONITOR_RETURN, __call_if_monitor_return_t, void, int) +#define CYGACC_CALL_IF_MONITOR_RETURN_SET(_x_) \ + hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_RETURN]=(CYG_ADDRWORD)(_x_) + // These need to be kept uptodate with the (unadorned) masters // in RedBoot's flash_config.h: #define CYGNUM_FLASH_CFG_OP_CONFIG_EMPTY 0
--- a/packages/hal/frv/arch/current/ChangeLog +++ b/packages/hal/frv/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2002-04-15 Jonathan Larmour <jlarmour@redhat.com> * src/hal_syscall.c (hal_syscall_handler): Add extra sig argument to
--- a/packages/hal/frv/arch/current/src/hal_syscall.c +++ b/packages/hal/frv/arch/current/src/hal_syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -89,12 +89,6 @@ hal_syscall_handler(void) arg3 = get_register(R10); arg4 = get_register(R11); - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/hal/h8300/arch/current/ChangeLog +++ b/packages/hal/h8300/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2002-04-29 Jonathan Larmour <jlarmour@redhat.com> * src/vectors.S: @@ -13,7 +18,7 @@ 2002-04-24 Yoshinori Sato <qzb04471@ni //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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
--- a/packages/hal/h8300/arch/current/src/hal_syscall.c +++ b/packages/hal/h8300/arch/current/src/hal_syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -88,12 +88,6 @@ hal_syscall_handler(void) arg3 = get_register(ER3); arg4 = 0; - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/hal/i386/arch/current/ChangeLog +++ b/packages/hal/i386/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2002-11-28 Nick Garnett <nickg@ecoscentric.com> * src/vectors.S: Added GRUB startup option to tests for IDT
--- a/packages/hal/i386/arch/current/src/hal_syscall.c +++ b/packages/hal/i386/arch/current/src/hal_syscall.c @@ -145,12 +145,6 @@ hal_syscall_handler(void) return SIGTRAP; } - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (__do_syscall(func, arg1, arg2, arg3, arg4, &err, &sig)) { put_register(EAX, err); return (int)sig;
--- a/packages/hal/mips/arch/current/ChangeLog +++ b/packages/hal/mips/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2003-01-09 Tim Michals <t.michals@attbi.com> * src/hal_misc.c (hal_delay_us): Use HAL_CLOCK_READ instead of inline
--- a/packages/hal/mips/arch/current/src/hal_syscall.c +++ b/packages/hal/mips/arch/current/src/hal_syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -91,12 +91,6 @@ hal_syscall_handler(void) put_register(REG_PC, get_register(REG_PC)+4); - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/hal/mn10300/arch/current/ChangeLog +++ b/packages/hal/mn10300/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2002-12-06 Mark Salter <msalter@redhat.com> * cdl/hal_mn10300.cdl: Add CYGINT_HAL_MN10300_MEM_REAL_REGION_TOP.
--- a/packages/hal/mn10300/arch/current/src/hal_syscall.c +++ b/packages/hal/mn10300/arch/current/src/hal_syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -89,12 +89,6 @@ hal_syscall_handler(void) arg3 = get_register(D3); arg4 = 0; - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/hal/sh/arch/current/ChangeLog +++ b/packages/hal/sh/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2003-01-31 Mark Salter <msalter@redhat.com> + + * src/hal_syscall.c (hal_syscall_handler): Let generic syscall code + handle exit. + 2002-08-02 Andrew Lunn <Andrew.Lunn@ascom.ch> * cdl/hal_sh.cdl: The Redboot exec command can now be
--- a/packages/hal/sh/arch/current/src/hal_syscall.c +++ b/packages/hal/sh/arch/current/src/hal_syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -135,12 +135,6 @@ hal_syscall_handler(void) return SIGTRAP; } - if (func == SYS_exit) { - // We want to stop in exit so that the user may poke around - // to see why his app exited. - return SIGTRAP; - } - if (func == SYS_interrupt) { // A console interrupt landed us here. // Invoke the debug agent so as to cause a SIGINT.
--- a/packages/redboot/current/src/main.c +++ b/packages/redboot/current/src/main.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // Copyright (C) 2002 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under @@ -76,6 +76,10 @@ extern void breakpoint(void); // Builtin Self Test (BIST) externC void bist(void); +// Return path for code run from a go command +static void return_to_redboot(int status); + + // CLI command processing (defined in this file) RedBoot_cmd("version", "Display RedBoot version information", @@ -185,6 +189,8 @@ cyg_start(void) // Export version information CYGACC_CALL_IF_MONITOR_VERSION_SET(RedBoot_version); + CYGACC_CALL_IF_MONITOR_RETURN_SET(return_to_redboot); + // Make sure the channels are properly initialized. diag_init_putc(_mon_write_char); hal_if_diag_init(); @@ -378,23 +384,53 @@ do_help(int argc, char *argv[]) return; } +static void * go_saved_context; +static int go_return_status; + +static void +go_trampoline(unsigned long entry) +{ + typedef void code_fun(void); + code_fun *fun = (code_fun *)entry; + unsigned long oldints; + + HAL_DISABLE_INTERRUPTS(oldints); + +#ifdef HAL_ARCH_PROGRAM_NEW_STACK + HAL_ARCH_PROGRAM_NEW_STACK(fun); +#else + (*fun)(); +#endif +} + +static void +return_to_redboot(int status) +{ + CYGARC_HAL_SAVE_GP(); + + go_return_status = status; + HAL_THREAD_LOAD_CONTEXT(&go_saved_context); + // never returns +} + void do_go(int argc, char *argv[]) { - typedef void code_fun(void); unsigned long entry; unsigned long oldints; - code_fun *fun; bool wait_time_set; int wait_time, res; - struct option_info opts[1]; + bool cache_enabled = false; + struct option_info opts[2]; char line[8]; hal_virtual_comm_table_t *__chan = CYGACC_CALL_IF_CONSOLE_PROCS(); 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"); - if (!scan_opts(argc, argv, 1, opts, 1, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address")) + init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG, + (void **)&cache_enabled, (bool *)0, "go with caches enabled"); + if (!scan_opts(argc, argv, 1, opts, 2, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address")) { return; } @@ -419,19 +455,35 @@ do_go(int argc, char *argv[]) } CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_ENABLE_LINE_FLUSH); - fun = (code_fun *)entry; HAL_DISABLE_INTERRUPTS(oldints); HAL_DCACHE_SYNC(); - HAL_ICACHE_DISABLE(); - HAL_DCACHE_DISABLE(); - HAL_DCACHE_SYNC(); + if (!cache_enabled) { + HAL_ICACHE_DISABLE(); + HAL_DCACHE_DISABLE(); + HAL_DCACHE_SYNC(); + } HAL_ICACHE_INVALIDATE_ALL(); HAL_DCACHE_INVALIDATE_ALL(); -#ifdef HAL_ARCH_PROGRAM_NEW_STACK - HAL_ARCH_PROGRAM_NEW_STACK(fun); -#else - (*fun)(); -#endif + + // set up a temporary context that will take us to the trampoline + HAL_THREAD_INIT_CONTEXT((CYG_ADDRESS)workspace_end, entry, go_trampoline, 0); + + // switch context to trampoline + HAL_THREAD_SWITCH_CONTEXT(&go_saved_context, &workspace_end); + + // we get back here by way of return_to_redboot() + + // undo the changes we made before switching context + if (!cache_enabled) { + HAL_ICACHE_ENABLE(); + HAL_DCACHE_ENABLE(); + } + + CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_DISABLE_LINE_FLUSH); + + HAL_RESTORE_INTERRUPTS(oldints); + + diag_printf("\nProgram completed with status %d\n", go_return_status); } #ifdef HAL_PLATFORM_RESET
--- a/packages/redboot/current/src/syscall.c +++ b/packages/redboot/current/src/syscall.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. // // 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 @@ -52,6 +52,7 @@ #include <redboot.h> #include <cyg/hal/hal_intr.h> #include <cyg/hal/drv_api.h> +#include <cyg/hal/hal_stub.h> #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS @@ -223,7 +224,7 @@ sys_timer_isr(cyg_vector_t vector, cyg_a CYGARC_HAL_RESTORE_GP(); } #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF - return 0; + return CYG_ISR_HANDLED; } @@ -629,6 +630,16 @@ CYG_ADDRWORD *(__shared_t **)arg1 = &__shared_data; break; + case SYS_exit: + if (gdb_active) { + *sig = SIGTRAP; + err = func; + } else { + CYGACC_CALL_IF_MONITOR_RETURN(arg1); + // never returns + } + break; + default: return 0; }
