This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

checked in patches from Pierre Habraken


Index: hal/arm/arch/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/ChangeLog,v
retrieving revision 1.89
diff -u -p -5 -r1.89 ChangeLog
--- hal/arm/arch/current/ChangeLog	30 Apr 2003 20:02:41 -0000	1.89
+++ hal/arm/arch/current/ChangeLog	6 May 2003 20:14:43 -0000
@@ -1,5 +1,23 @@
+2003-05-06  Pierre Habraken  <Pierre.Habraken@imag.fr>
+
+	* src/arm_stub.c (target_ins, target_thumb_ins): Added code to
+	enable stepping into swi instructions.
+	
+	* cdl/hal_arm.cdl: Added option CYGOPT_HAL_ARM_PRESERVE_SVC_SPSR for
+	securing exception and breakpoint processing triggered during
+	execution of application specific SWI handlers. Added option
+	CYGOPT_HAL_ARM_WITH_USER_MODE for supporting programs running in
+	user mode.
+	* src/vectors.S (return_from_exception): Added code to exception
+	handling for preserving svc spsr before returning to svc mode.
+	Added code to allow exceptions in user mode.
+	(call_exception_handler, handle_IRQ_or_FIQ): Added code to allow
+	exceptions in user mode.
+	* include/hal_arch.h: Defined CPSR_USER_MODE.
+	* src/hal_mk_defs.c.: Added definition for CPSR_USER_MODE.
+
 2003-04-30  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* src/vectors.S (handle_IRQ_or_FIQ): Tweak below to be conditional on
 	__thumb__.
 
Index: hal/arm/arch/current/cdl/hal_arm.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/cdl/hal_arm.cdl,v
retrieving revision 1.12
diff -u -p -5 -r1.12 hal_arm.cdl
--- hal/arm/arch/current/cdl/hal_arm.cdl	6 Aug 2002 14:34:04 -0000	1.12
+++ hal/arm/arch/current/cdl/hal_arm.cdl	6 May 2003 20:14:43 -0000
@@ -210,10 +210,26 @@ cdl_package CYGPKG_HAL_ARM {
 	    The ARM HAL provides the macro for 'gprof' callbacks from RedBoot
 	    to acquire the interrupt-context PC and SP, when this option is
             active."
     }
 
+    cdl_option CYGOPT_HAL_ARM_WITH_USER_MODE {
+        display          "Accept exceptions and irq's occurring in user mode"
+        default_value    0
+        description      "
+            For standalone Redboot based programs running in user mode."
+    }
+
+    cdl_option CYGOPT_HAL_ARM_PRESERVE_SVC_SPSR {
+        display          "Preserve svc spsr before returning to svc mode"
+        default_value    0
+        description      "
+            This option secures exception and breakpoint processing
+            triggered during execution of application specific SWI
+            handlers."
+    }
+
     cdl_component CYGPKG_REDBOOT_ARM_OPTIONS {
         display       "Redboot for ARM options"
         flavor        none
         no_define
         parent        CYGPKG_REDBOOT
Index: hal/arm/arch/current/include/hal_arch.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/include/hal_arch.h,v
retrieving revision 1.20
diff -u -p -5 -r1.20 hal_arch.h
--- hal/arm/arch/current/include/hal_arch.h	22 Aug 2002 12:24:20 -0000	1.20
+++ hal/arm/arch/current/include/hal_arch.h	6 May 2003 20:14:43 -0000
@@ -9,11 +9,11 @@
 //
 //==========================================================================
 //####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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -62,10 +62,11 @@
 //
 
 #define CPSR_IRQ_DISABLE	0x80	// IRQ disabled when =1
 #define CPSR_FIQ_DISABLE	0x40	// FIQ disabled when =1
 #define CPSR_THUMB_ENABLE	0x20	// Thumb mode when =1
+#define CPSR_USER_MODE		0x10
 #define CPSR_FIQ_MODE		0x11
 #define CPSR_IRQ_MODE		0x12
 #define CPSR_SUPERVISOR_MODE	0x13
 #define CPSR_UNDEF_MODE		0x1B
 
Index: hal/arm/arch/current/src/arm_stub.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/src/arm_stub.c,v
retrieving revision 1.26
diff -u -p -5 -r1.26 arm_stub.c
--- hal/arm/arch/current/src/arm_stub.c	12 Nov 2002 21:50:39 -0000	1.26
+++ hal/arm/arch/current/src/arm_stub.c	6 May 2003 20:14:44 -0000
@@ -6,11 +6,11 @@
 //
 //========================================================================
 //####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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -526,11 +526,16 @@ target_ins(unsigned long *pc, unsigned l
                 // Falls through
                 return (pc+1);
             }
         }
     case 0x3:  // Coprocessor & SWI
-        return (pc+1);
+        if (((ins & 0x03000000) == 0x03000000) && ins_will_execute(ins)) {
+           // SWI
+           return (CYGNUM_HAL_VECTOR_SOFTWARE_INTERRUPT * 4);
+        } else {
+           return (pc+1);
+        }
     default:
         // Never reached - but fixes compiler warning.
         return 0;
     }
 }
@@ -568,14 +573,17 @@ target_thumb_ins(unsigned long pc, unsig
             if (!v5T_semantics())
                 new_pc = MAKE_THUMB_ADDR(new_pc);
         }
         break;
     case 0xd:
-        // Bcc
+        // Bcc | SWI
         // Use ARM function to check condition
         arm_ins = ((unsigned long)(ins & 0x0f00)) << 20;
-        if (ins_will_execute(arm_ins)) {
+        if ((arm_ins & 0xF0000000) == 0xF0000000) {
+            // SWI
+            new_pc = CYGNUM_HAL_VECTOR_SOFTWARE_INTERRUPT * 4;
+        } else if (ins_will_execute(arm_ins)) {
             offset = (ins & 0x00FF) << 1;
             if (ins & 0x0080) offset |= 0xFFFFFE00;  // sign extend
             new_pc = MAKE_THUMB_ADDR((unsigned long)(pc+4) + offset);
         }
         break;
Index: hal/arm/arch/current/src/hal_mk_defs.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/src/hal_mk_defs.c,v
retrieving revision 1.11
diff -u -p -5 -r1.11 hal_mk_defs.c
--- hal/arm/arch/current/src/hal_mk_defs.c	23 May 2002 23:01:42 -0000	1.11
+++ hal/arm/arch/current/src/hal_mk_defs.c	6 May 2003 20:14:44 -0000
@@ -6,11 +6,11 @@
 //
 //==========================================================================
 //####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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -107,10 +107,11 @@ main(void)
     DEFINE(RAISE_INTR, CYG_INSTRUMENT_CLASS_INTR|CYG_INSTRUMENT_EVENT_INTR_RAISE);
 #endif
     DEFINE(CPSR_IRQ_DISABLE, CPSR_IRQ_DISABLE);
     DEFINE(CPSR_FIQ_DISABLE, CPSR_FIQ_DISABLE);
     DEFINE(CPSR_THUMB_ENABLE, CPSR_THUMB_ENABLE);
+    DEFINE(CPSR_USER_MODE, CPSR_USER_MODE);
     DEFINE(CPSR_IRQ_MODE, CPSR_IRQ_MODE);
     DEFINE(CPSR_FIQ_MODE, CPSR_FIQ_MODE);
     DEFINE(CPSR_SUPERVISOR_MODE, CPSR_SUPERVISOR_MODE);
     DEFINE(CPSR_UNDEF_MODE, CPSR_UNDEF_MODE);
     DEFINE(CPSR_MODE_BITS, CPSR_MODE_BITS);
Index: hal/arm/arch/current/src/vectors.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/src/vectors.S,v
retrieving revision 1.50
diff -u -p -5 -r1.50 vectors.S
--- hal/arm/arch/current/src/vectors.S	30 Apr 2003 20:02:41 -0000	1.50
+++ hal/arm/arch/current/src/vectors.S	6 May 2003 20:14:45 -0000
@@ -6,11 +6,11 @@
 // #
 // #========================================================================
 //####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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -488,10 +488,12 @@ init_done:
         .long   0xDEADB00B
 
 //
 // Exception handlers
 // Assumption: get here from a non-user context [mode]
+//             except in case of standalone app. running in user mode
+//             (CYGOPT_HAL_ARM_WITH_USER_MODE should have been defined)
 //
         .code   32
 undefined_instruction:
         ldr     sp,.__undef_exception_stack     // get good stack
         stmfd   sp!,{r0-r5}                     // save some supervisor regs
@@ -580,20 +582,31 @@ call_exception_handler:
         // r4 holds original svc lr, which must also be preserved
         //
 
         stmfd   sp!,{r0-r2,r4,r5}       // push svc_sp, svc_lr, vector, psr, pc
         
+#ifdef CYGOPT_HAL_ARM_WITH_USER_MODE
+        // did exception occur in user mode ?
+        and     r2, r1, #CPSR_MODE_BITS
+        cmp     r2, #CPSR_USER_MODE
+        bne     1f
+        stmfd   sp, {r8-r12, sp, lr}^   // get user mode regs
+	nop
+        sub     sp, sp, #4*7
+        bal     2f
+1:
+#endif
         // switch to pre-exception mode to get banked regs
         mov     r0,sp                   // r0 survives mode switch
         mrs     r2,cpsr                 // Save current psr for return
         orr     r1,r1,#CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE
         bic     r1,r1,#CPSR_THUMB_ENABLE
         msr     cpsr,r1
         stmfd   r0!,{r8-r12,sp,lr}
         msr     cpsr,r2                 // back to svc mode
         mov     sp,r0                   // update stack pointer
-
+2:
         // now save pre-exception r0-r7 on current stack
         ldmfd   r3,{r0-r5}
         stmfd   sp!,{r0-r7}
 
         // SP needs fixing if exception occured in SVC mode.
@@ -634,25 +647,54 @@ return_from_exception:
         msr     spsr,r0
 
         // return to supervisor mode is simple
         and     r1,r0,#CPSR_MODE_BITS
         cmp     r1,#CPSR_SUPERVISOR_MODE
-        ldmeqfd sp,{r0-r14,pc}^
 
+#ifndef CYGOPT_HAL_ARM_PRESERVE_SVC_SPSR
+        msr     spsr,r0
+        ldmeqfd sp,{r0-r14,pc}^
+#else
+        // we must take care of not corrupting the current (svc)
+        // spsr which happens to be also the pre-exception spsr
+        bne     1f
+        // we are returning to svc mode thus we must restore the
+        // pre-exception cpsr before returning to interrupted code
+        msr     cpsr, r0
+        ldmfd   sp, {r0-r14, pc}
+1:
+        // we are not returning to svc mode thus we can safely restore
+        // svc spsr
+        msr     spsr, r0
+#endif
+
+#ifdef CYGOPT_HAL_ARM_WITH_USER_MODE
+        // are we returning to user mode ?
+        and     r2, r1, #CPSR_MODE_BITS
+        cmp     r2, #CPSR_USER_MODE
+        add     r2, sp, #armreg_r8
+        bne     1f
+        ldmfd   r2, {r8-r14}^           // restore user mode regs
+	nop
+        bal     2f
+1:
+#else
+        add     r2, sp, #armreg_r8
+#endif
         //
         // return to other non-user modes is a little trickier
         //
 
         // switch to pre-exception mode and restore r8-r14
-        add     r2,sp,#armreg_r8
         mrs     r1,cpsr
         orr     r0,r0,#CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE
         bic     r0,r0,#CPSR_THUMB_ENABLE
         msr     cpsr,r0
         ldmfd   r2,{r8-r14}
         msr     cpsr, r1        // back to svc mode
 
+2:	
         // move sp,lr and pc for final load
         ldr     r0,[sp,#armreg_svcsp]
         str     r0,[sp,#armreg_r8]
         ldr     r0,[sp,#armreg_svclr]	
         str     r0,[sp,#armreg_r9]
@@ -674,10 +716,12 @@ __dump_procs:
 
 
 // Handle device interrupts
 // This is slightly more complicated than the other exception handlers because
 // it needs to interface with the kernel (if present).
+// Assumption: can get here from any mode, including user mode
+// (spurious interrupt while standalone app. is running in user mode)
 
         .code   32
 FIQ:
         // We can get here from any non-user mode.
         mrs     r8,spsr                 // CPSR at time of interrupt
@@ -721,20 +765,32 @@ handle_IRQ_or_FIQ:
 
         mov     r5,sp                   // save original svc sp
 	mov	r4,lr			// save original svc lr
         stmfd   sp!,{r0-r2,r4,r5}       // push svc_sp, svc_lr, vector, psr, pc
 		
+#ifdef CYGOPT_HAL_ARM_WITH_USER_MODE
+        // did exception occur in user mode ?
+        and     r2, r1, #CPSR_MODE_BITS
+        cmp     r2, #CPSR_USER_MODE
+        bne     1f
+        stmfd   sp, {r8-r12, sp, lr}^   // get user mode regs
+	nop
+        sub     sp, sp, #4*7
+        bal     2f
+1:
+#endif
         // switch to pre-exception mode to get banked regs
         mov     r0,sp                   // r0 survives mode switch
         mrs     r2,cpsr                 // Save current psr for return
         orr     r1,r1,#CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE
         bic     r1,r1,#CPSR_THUMB_ENABLE
         msr     cpsr,r1
         stmfd   r0!,{r8-r12,sp,lr}
         msr     cpsr,r2                 // back to svc mode
         mov     sp,r0                   // update stack pointer
 	
+2:
         // now save pre-exception r0-r7 on current stack
         ldmfd   r3,{r0-r5}
         stmfd   sp!,{r0-r7}
 
         // sp needs fixing if exception occured in SVC mode.
Index: hal/common/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/ChangeLog,v
retrieving revision 1.91
diff -u -p -5 -r1.91 ChangeLog
--- hal/common/current/ChangeLog	8 Apr 2003 17:14:58 -0000	1.91
+++ hal/common/current/ChangeLog	6 May 2003 20:14:48 -0000
@@ -1,5 +1,15 @@
+2003-05-06  Mark Salter  <msalter@redhat.com>
+
+	* src/hal_stub.c (handle_exception_exit): Call sys_profile_reset from
+	here. Setup to return through return_from_stub() when appropriate.
+	(return_from_stub): New function to call CYGACC_CALL_IF_MONITOR_RETURN
+	from thread context.
+
+	* src/generic-stub.c (__handle_exception): Call exit_vec if
+	hal_syscall_handler returns negative number.
+
 2003-04-08  Mark Salter  <msalter@redhat.com>
 
 	* src/hal_misc.c (hal_default_isr): Allow HAL to override default
 	GDB vector matching test.
 
Index: hal/common/current/src/generic-stub.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/src/generic-stub.c,v
retrieving revision 1.31
diff -u -p -5 -r1.31 generic-stub.c
--- hal/common/current/src/generic-stub.c	8 Apr 2003 01:13:15 -0000	1.31
+++ hal/common/current/src/generic-stub.c	6 May 2003 20:15:00 -0000
@@ -905,12 +905,15 @@ __handle_exception (void)
 #if defined(CYGSEM_REDBOOT_BSP_SYSCALLS)
   // Temporary support for gnupro bsp SWIs
   if (__is_bsp_syscall())
   {
       sigval = hal_syscall_handler();
-      if (0 == sigval)
+      if (sigval <= 0)
       {
+	  if (sigval < 0)
+	      __process_exit_vec ();
+
 	  if (__init_vec != NULL)
               __init_vec ();
 	  return;
       }
   }
@@ -1434,16 +1437,10 @@ __process_packet (char *packet)
       /* fall through */
     case 'k' :      /* kill the program */
 #ifdef __ECOS__
       hal_flush_output();
 #endif
-#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
-      {   // Reset the timer to default and cancel any callback
-          extern void sys_profile_reset(void);
-          sys_profile_reset();
-      }
-#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
       __process_exit_vec ();
       return -1;
 
     case 'r':           /* Reset */
       /* With the next 'k' packet, reset the board */
Index: hal/common/current/src/hal_stub.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/src/hal_stub.c,v
retrieving revision 1.37
diff -u -p -5 -r1.37 hal_stub.c
--- hal/common/current/src/hal_stub.c	23 May 2002 23:02:49 -0000	1.37
+++ hal/common/current/src/hal_stub.c	6 May 2003 20:15:01 -0000
@@ -6,11 +6,11 @@
 //
 //=============================================================================
 //####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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -95,11 +95,13 @@
 // Saved registers.
 HAL_SavedRegisters *_hal_registers;
 target_register_t registers[HAL_STUB_REGISTERS_SIZE];
 target_register_t alt_registers[HAL_STUB_REGISTERS_SIZE] ;  // Thread or saved process state
 target_register_t * _registers = registers;                 // Pointer to current set of registers
+#ifndef CYGPKG_REDBOOT
 target_register_t orig_registers[HAL_STUB_REGISTERS_SIZE];  // Registers to get back to original state
+#endif
 
 #if defined(HAL_STUB_HW_WATCHPOINT) || defined(HAL_STUB_HW_BREAKPOINT)
 static int  _hw_stop_reason;   // Reason we were stopped by hw.
 
 //#define HAL_STUB_HW_SEND_STOP_REASON_TEXT
@@ -376,43 +378,66 @@ interruptible(int state)
 
 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
 int cyg_hal_gdb_break;
 #endif
 
+#ifdef CYGPKG_REDBOOT
+// Trampoline for returning to RedBoot from exception/stub code
+static void
+return_from_stub(int exit_status)
+{
+    CYGACC_CALL_IF_MONITOR_RETURN(exit_status);
+}
+#endif
+
 // Called at stub *kill*
 static void 
 handle_exception_exit( void )
 {
+#ifdef CYGPKG_REDBOOT
+#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+    {   // Reset the timer to default and cancel any callback
+	extern void sys_profile_reset(void);
+	sys_profile_reset();
+    }
+#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
+    set_pc((target_register_t)return_from_stub);
+#else
     int i;
 
     for (i = 0; i < (sizeof(registers)/sizeof(registers[0])); i++)
 	registers[i] = orig_registers[i];
+#endif
 }
 
 // Called at stub *entry*
 static void 
 handle_exception_cleanup( void )
 {
+#ifndef CYGPKG_REDBOOT
     static int orig_registers_set = 0;
+#endif
 
     interruptible(0);
 
     // Expand the HAL_SavedRegisters structure into the GDB register
     // array format.
     HAL_GET_GDB_REGISTERS(&registers[0], _hal_registers);
     _registers = &registers[0];
 
+#ifndef CYGPKG_REDBOOT
     if (!orig_registers_set) {
 	int i;
 	for (i = 0; i < (sizeof(registers)/sizeof(registers[0])); i++)
 	    orig_registers[i] = registers[i];
 	_registers = &orig_registers[0];
 	if (__is_breakpoint_function ())
 	    __skipinst ();
 	_registers = &registers[0];
 	orig_registers_set = 1;
     }
+#endif
 	
 #ifdef HAL_STUB_PLATFORM_STUBS_FIXUP
     // Some architectures may need to fix the PC in case of a partial
     // or fully executed trap instruction. GDB only takes correct action
     // when the PC is pointing to the breakpoint instruction it set.
Index: redboot/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.107
diff -u -p -5 -r1.107 ChangeLog
--- redboot/current/ChangeLog	24 Apr 2003 03:33:04 -0000	1.107
+++ redboot/current/ChangeLog	6 May 2003 20:15:20 -0000
@@ -1,5 +1,28 @@
+2003-05-06  Mark Salter  <msalter@redhat.com>
+
+	* src/main.c (cyg_start): Clear gdb_active when returning from stub.
+
+2003-05-06  Pierre Habraken  <Pierre.Habraken@imag.fr>
+
+	* cdl/redboot.cdl: Added option
+	CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP for enabling (possibly
+	single shot) programs to exit and return a termination status as
+	their normal behavior (i.e. without raising a SIGTRAP).
+	* src/syscall.c (__do_syscall): Added conditionally compiled code
+	to SYS_exit for returning to RedBoot main loop without raising a
+	SIGTRAP, even when the calling program is not being debugged.
+	* src/main.c (cyg_start): Added code (following Jonathan Larmour's
+	and Mark Salter's suggestions) to RedBoot main loop: a (context)
+	savepoint is created before the thread of control is transferred to
+	gdb stubs (through a trampoline procedure). This savepoint enables
+	the stubs to return control back to the main loop by calling the
+	return_to_redboot procedure (macro CYGACC_CALL_IF_MONITOR_RETURN).
+	Procedure go_trampoline and variables go_saved_context and
+	go_return_status have been respectively renamed	to trampoline,
+	saved_context and return_status.
+
 2003-04-23  Chris Garry <cgarry@sweeneydesign.co.uk>
 	
 	* src/flash.c: Only perform RAM check in fis load command when 
 	CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS = 1
 
Index: redboot/current/cdl/redboot.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.47
diff -u -p -5 -r1.47 redboot.cdl
--- redboot/current/cdl/redboot.cdl	28 Mar 2003 13:49:32 -0000	1.47
+++ redboot/current/cdl/redboot.cdl	6 May 2003 20:15:20 -0000
@@ -859,10 +859,19 @@ cdl_package CYGPKG_REDBOOT {
     
             cdl_interface CYGINT_REDBOOT_BSP_SYSCALLS_GPROF_SUPPORT {
                 display	"Does the HAL support 'gprof' profiling?"
                 no_define
             }
+
+            cdl_option CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP {
+                display "Do not raise SIGTRAP when program exits"
+                default_value 0
+                description "
+                    For some (single shot) newlib based programs,
+                    exiting and returning a termination status may be
+                    the normal expected behavior."
+            }
         }
     
         cdl_component CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER {
             display     	"Use a common buffer for Zlib and FIS"
             flavor	    	bool
Index: redboot/current/src/main.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.44
diff -u -p -5 -r1.44 main.c
--- redboot/current/src/main.c	8 Apr 2003 05:09:06 -0000	1.44
+++ redboot/current/src/main.c	6 May 2003 20:15:20 -0000
@@ -78,13 +78,23 @@ extern void breakpoint(void);
 #endif
 
 // Builtin Self Test (BIST)
 externC void bist(void);
 
-// Return path for code run from a go command
+// Path to code run from a go command or to GDB stubs
+static void trampoline(unsigned long entry);
+
+// Return path for code run from a go command or for GDB stubs
 static void return_to_redboot(int status);
 
+// Address of area where current context is saved before executing
+// trampoline procedure
+static void * saved_context;
+
+// Status returned after trampoline execution
+static int return_status;
+ 
 
 // CLI command processing (defined in this file)
 RedBoot_cmd("version", 
             "Display RedBoot version information",
             "",
@@ -314,15 +324,20 @@ cyg_start(void)
                     __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
                     CYGACC_COMM_IF_CONTROL( *__chan, __COMMCTL_IRQ_DISABLE );
                 }
     
                 CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
-#ifdef HAL_ARCH_PROGRAM_NEW_STACK
-                HAL_ARCH_PROGRAM_NEW_STACK(breakpoint);
-#else
-                breakpoint();  // Get GDB stubs started, with a proper environment, etc.
-#endif
+
+                // set up a temporary context that will take us to the trampoline
+                HAL_THREAD_INIT_CONTEXT((CYG_ADDRESS)workspace_end,
+                                        breakpoint, trampoline, 0);
+
+                // switch context to trampoline (get GDB stubs started)
+                HAL_THREAD_SWITCH_CONTEXT(&saved_context, &workspace_end);
+
+                gdb_active = false;
+
 		dbgchan = CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
 		CYGACC_CALL_IF_SET_CONSOLE_COMM(dbgchan);
             } else 
 #endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
             {
@@ -386,15 +401,12 @@ do_help(int argc, char *argv[])
     cmd = __RedBoot_CMD_TAB__;
     show_help(cmd, &__RedBoot_CMD_TAB_END__, which, "");
     return;
 }
 
-static void * go_saved_context;
-static int go_return_status;
-
 static void
-go_trampoline(unsigned long entry)
+trampoline(unsigned long entry)
 {
     typedef void code_fun(void);
     code_fun *fun = (code_fun *)entry;
     unsigned long oldints;
 
@@ -403,19 +415,21 @@ go_trampoline(unsigned long entry)
 #ifdef HAL_ARCH_PROGRAM_NEW_STACK
     HAL_ARCH_PROGRAM_NEW_STACK(fun);
 #else
     (*fun)();
 #endif
+
+    HAL_THREAD_LOAD_CONTEXT(&saved_context);
 }
 
 static void
 return_to_redboot(int status)
 {
     CYGARC_HAL_SAVE_GP();
 
-    go_return_status = status;
-    HAL_THREAD_LOAD_CONTEXT(&go_saved_context);
+    return_status = status;
+    HAL_THREAD_LOAD_CONTEXT(&saved_context);
     // never returns
 
     // need this to balance above CYGARC_HAL_SAVE_GP on
     // some platforms. It will never run, though.
     CYGARC_HAL_RESTORE_GP();
@@ -498,14 +512,14 @@ do_go(int argc, char *argv[])
     }
     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_ADDRESS)workspace_end, entry, go_trampoline, 0);
+    HAL_THREAD_INIT_CONTEXT((CYG_ADDRESS)workspace_end, entry, trampoline, 0);
 
     // switch context to trampoline
-    HAL_THREAD_SWITCH_CONTEXT(&go_saved_context, &workspace_end);
+    HAL_THREAD_SWITCH_CONTEXT(&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) {
@@ -515,11 +529,11 @@ do_go(int argc, char *argv[])
 
     CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_DISABLE_LINE_FLUSH);
 
     HAL_RESTORE_INTERRUPTS(oldints);
 
-    diag_printf("\nProgram completed with status %d\n", go_return_status);
+    diag_printf("\nProgram completed with status %d\n", return_status);
 }
 
 #ifdef HAL_PLATFORM_RESET
 void
 do_reset(int argc, char *argv[])
Index: redboot/current/src/syscall.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/syscall.c,v
retrieving revision 1.9
diff -u -p -5 -r1.9 syscall.c
--- redboot/current/src/syscall.c	31 Jan 2003 16:46:01 -0000	1.9
+++ redboot/current/src/syscall.c	6 May 2003 20:15:20 -0000
@@ -629,16 +629,20 @@ __do_syscall(CYG_ADDRWORD func,         
       case __GET_SHARED:
         *(__shared_t **)arg1 = &__shared_data;
         break;
 
       case SYS_exit:
+	*sig = -1;    // signal exit
+	err = arg1;
+
 	if (gdb_active) {
+#ifdef CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP
+	    __send_exit_status((int)arg1);
+#else
 	    *sig = SIGTRAP;
 	    err = func;
-	} else {
-	    CYGACC_CALL_IF_MONITOR_RETURN(arg1);
-	    // never returns
+#endif // CYGOPT_REDBOOT_BSP_SYSCALLS_EXIT_WITHOUT_TRAP
 	}
 	break;
 
       default:
         return 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]