changeset 10:d3fbcdfa1b2f ecos-sw-1999-05-29

Merge from eCos master repository on 1999-05-29-00:13:11-BST
author jlarmour
date Fri, 28 May 1999 16:43:09 +0000
parents 95cc44ea0068
children 0efcb019050f
files packages/ChangeLog packages/compat/uitron/current/ChangeLog packages/compat/uitron/current/tests/testcx7.cxx packages/hal/arm/aeb/current/ChangeLog packages/hal/arm/aeb/current/misc/STUBS_config packages/hal/arm/aeb/current/misc/gdb_module.c packages/hal/arm/aeb/current/src/hal_diag.c packages/hal/arm/arch/current/ChangeLog packages/hal/arm/arch/current/src/vectors.S packages/hal/arm/pid/current/ChangeLog packages/hal/arm/pid/current/src/hal_diag.c packages/hal/common/current/ChangeLog packages/hal/common/current/include/pkgconf/hal.h packages/hal/common/current/src/hal_stub.c packages/hal/common/current/tests/cache.c packages/hal/mips/arch/current/ChangeLog packages/hal/mips/arch/current/include/hal_cache.h packages/hal/mips/arch/current/include/hal_intr.h packages/hal/mips/arch/current/src/hal_misc.c packages/hal/mips/arch/current/src/mips-stub.c packages/hal/mips/arch/current/src/vectors.S packages/hal/mips/jmr3904/current/ChangeLog packages/hal/mips/jmr3904/current/include/plf_intr.h packages/hal/mips/jmr3904/current/src/plf_misc.c packages/hal/mips/tx39/current/ChangeLog packages/hal/mips/tx39/current/src/hal_diag.c packages/hal/powerpc/arch/current/ChangeLog packages/hal/powerpc/arch/current/include/hal_cache.h packages/hal/powerpc/arch/current/include/hal_intr.h packages/hal/powerpc/arch/current/src/vectors.S packages/io/serial/current/ChangeLog packages/io/serial/current/include/pkgconf/io_serial.h packages/io/serial/current/src/PKGconf.mak packages/io/serial/current/src/mn10300/mn10300_serial.c packages/io/serial/current/tests/ser_test_protocol.inl packages/kernel/current/ChangeLog packages/kernel/current/include/kapi.h packages/kernel/current/include/stackmon.hxx packages/kernel/current/include/test/stackmon.h packages/kernel/current/src/common/kapi.cxx packages/kernel/current/src/debug/dbg_gdb.cxx packages/kernel/current/src/intr/intr.cxx packages/kernel/current/tests/except1.cxx packages/kernel/current/tests/intr0.cxx packages/kernel/current/tests/kcache1.c packages/kernel/current/tests/kexcept1.c packages/kernel/current/tests/kintr0.c packages/kernel/current/tests/stress_threads.c packages/kernel/current/tests/tm_basic.cxx packages/language/c/libc/current/ChangeLog packages/language/c/libc/current/tests/signal/signal2.c packages/language/c/libc/current/tests/time/ctime.c packages/language/c/libm/current/ChangeLog packages/language/c/libm/current/src/PKGconf.mak
diffstat 54 files changed, 1038 insertions(+), 494 deletions(-) [+]
line wrap: on
line diff
--- a/packages/ChangeLog
+++ b/packages/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-26  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* NEWS: Added Kernel/Debugging entry.
+
 1999-05-13  Nick Garnett  <nickg@cygnus.co.uk>
 
 	The following changes were made in a branch and imported to the
@@ -81,14 +85,6 @@ 1999-04-14  Bart Veer  <bartv@cygnus.co.
 	Move serial devices to the end of the file so that the reparenting
 	below the HAL packages works as intended.
 
-1999-04-12  John Dallaway  <jld@cygnus.co.uk>
-
-	* pkgrelease.tcl: Report 'not within region' messages.
-
-1999-03-28  John Dallaway  <jld@cygnus.co.uk>
-
-	* pkgrelease.tcl: Supress incomplete NEWS file.
-
 1999-03-22  Jonathan Larmour  <jlarmour@cygnus.co.uk>
 
 	* packages
@@ -173,9 +169,6 @@ 1999-03-04  Bart Veer  <bartv@cygnus.co.
 	pkgconf.tcl to know about or make guesses about the mount
 	table.
 
-	* pkgrelease.tcl:
-	Added NEWS to the list of special files.
-
 1999-03-04  John Dallaway  <jld@cygnus.co.uk>
 
 	* pkgconf.tcl: Point to renamed *.ldi and *.h memory
@@ -214,14 +207,6 @@ 1999-02-19  Mark Galassi  <rosalia@cygnu
 
 	* NEWS: added the NEWS file.  It's rather sparse for now.
 
-1999-02-12  John Dallaway  <jld@cygnus.co.uk>
-
-	* pkgrelease.tcl: Report 'region is full' message count.
-
-1999-02-11  John Dallaway  <jld@cygnus.co.uk>
-
-	* pkgrelease.tcl: Report ignored linker error count.
-
 1999-02-11  John Dallaway  <jld@cygnus.co.uk>
 
 	* pkgconf/makrules.tst: Ignore linker errors while building tests.
@@ -235,10 +220,6 @@ 1999-02-10  Gary Thomas  <gthomas@cygnus
 
 	* targets: Remove options now that math problems have been addressed.
 
-1999-02-10  John Dallaway  <jld@cygnus.co.uk>
-
-	* pkgrelease.tcl: Suppress generation of prebuilts for stubs startup
-
 1999-02-08  John Dallaway  <jld@cygnus.co.uk>
 
 	* packages: Define HAL and RS232 packages in alphabetical order
@@ -259,12 +240,6 @@ 1999-01-21  Jesper Skov  <jskov@cygnus.c
 	* packages:
  	Added FADS entries from Kevin Hester <KHester@opticworks.com>.
 
-1999-01-21  Gary Thomas  <gthomas@cygnus.co.uk>
-
-	* pkgrelease.tcl: Add "--customers_file=xxx" option to allow customer
-	data-base file to be overidden on command line.  This is really just
-	for ease of testing new, exciting customer setups.
-
 1999-01-20  Gary Thomas  <gthomas@cygnus.co.uk>
 
 	* packages: Add ARM/PID serial driver
@@ -513,13 +488,6 @@ Thu Sep  3 15:13:42 1998  Tim Goodwin  <
 
 	s/panx/mn10300/g
 
-1998-09-03  Bart Veer  <bartv@cygnus.co.uk>
-
-	* pkgrelease.tcl:
-	Updated to cope with the HAL packages no longer being special.
-	Also tidied up some of the Tcl code and removed a few references
-	to ecc.
-
 1998-09-02  Bart Veer  <bartv@cygnus.co.uk>
 
 	* packages:
--- a/packages/compat/uitron/current/ChangeLog
+++ b/packages/compat/uitron/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-26  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/testcx7.cxx: Include new stackmon header.
+
 1999-05-20  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* tests/testcx7.cxx (task1): Add some statistics dumping about
--- a/packages/compat/uitron/current/tests/testcx7.cxx
+++ b/packages/compat/uitron/current/tests/testcx7.cxx
@@ -105,7 +105,7 @@
 
 // ============================ END ============================
 
-#include <cyg/kernel/stackmon.hxx>      // stack analysis tools
+#include <cyg/kernel/test/stackmon.h>   // stack analysis tools
 
 #include <cyg/compat/uitron/uit_func.h> // uITRON
 
--- a/packages/hal/arm/aeb/current/ChangeLog
+++ b/packages/hal/arm/aeb/current/ChangeLog
@@ -1,3 +1,11 @@
+1999-05-25  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* misc/gdb_module.c: Fix up symbols for new ABI.
+
+1999-05-24  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* src/hal_diag.c: Clean up direct access code.
+
 1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
 
 	* include/pkgconf/hal_arm_aeb.h: Move RTC setup here.
new file mode 100644
--- /dev/null
+++ b/packages/hal/arm/aeb/current/misc/STUBS_config
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+# Configure ARM/AEB eCos to create AEB-1 GDB stubs
+
+
+tcl $1/pkgconf.tcl                                         \
+   --target=arm --platform=aeb --startup=stubs                         \
+   --disable CYGPKG_KERNEL --disable CYGPKG_UITRON                     \
+   --disable CYGPKG_LIBC --disable CYGPKG_LIBM                         \
+   --disable CYGPKG_ERROR --disable CYGPKG_IO                          \
+   --disable CYGPKG_IO_SERIAL --disable CYGPKG_DEVICES_WALLCLOCK       \
+   --disable CYGPKG_DEVICES_WATCHDOG
+
+patch -p0 <<END_OF_PATCH
+--- pkgconf/hal.h~      Wed Mar 10 13:08:58 1999
++++ pkgconf/hal.h       Thu Mar 11 15:53:16 1999
+@@ -356,9 +356,9 @@
+ 
+    }}CFG_DATA */
+ 
+-#undef   CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
++#define  CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+ #undef   CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
+-#define  CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
++#undef   CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
+ 
+ /*
+  * NOTE:
+
+END_OF_PATCH
--- a/packages/hal/arm/aeb/current/misc/gdb_module.c
+++ b/packages/hal/arm/aeb/current/misc/gdb_module.c
@@ -51,10 +51,10 @@
 #define CHECKSUM 0x0
 #endif
 
-extern char _exception_handlers, _rom_data_end;
+extern char __exception_handlers, __rom_data_end;
 
 const char __title[] = "eCos";
-const char __help[] = "eCos            1.2  (26 Feb 1999) GDB stubs";
+const char __help[] = "eCos            1.2.2 (25 May 1999) GDB stubs";
 
 struct ModuleHeader {
     cyg_uint32    magic;
@@ -85,13 +85,13 @@ const static struct ModuleHeader __hdr =
     1,                              // major
     0,                              // minor
     CHECKSUM,                       // checksum
-    (cyg_uint32) &_exception_handlers,         // start of module (read-only) image
-    (cyg_uint32) &_rom_data_end,    // end of image
+    (cyg_uint32) &__exception_handlers,         // start of module (read-only) image
+    (cyg_uint32) &__rom_data_end,    // end of image
     0,                              // r/w base - unused
     0,                              // bss base - unused
     0,                              // bss limit - unused
     (cyg_uint32) &__hdr,            // self (for module identification)
-    (cyg_uint32) &_exception_handlers,         // startup 
+    (cyg_uint32) &__exception_handlers,         // startup 
     0,                              // init - unused
     0,                              // final - unused
     0,                              // service - unused
--- a/packages/hal/arm/aeb/current/src/hal_diag.c
+++ b/packages/hal/arm/aeb/current/src/hal_diag.c
@@ -143,7 +143,6 @@ void hal_diag_init(void)
 {
     static int init = 0;
     char *msg = "\n\rAEB-1 eCos\n\r";
-#if !defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) || 1
     cyg_uint8 lcr;
     cyg_uint8 dll, dlm;
 
@@ -165,9 +164,6 @@ void hal_diag_init(void)
     lcr &= ~SIO_LCR_DLAB;
     HAL_WRITE_UINT8 (CYG_DEVICE_SERIAL_RS232_16550_LCR, lcr);
     HAL_WRITE_UINT8 (CYG_DEVICE_SERIAL_RS232_16550_FCR, 0x07);  // Enable & clear FIFO
-#else
-    if (init++) return;
-#endif
     while (*msg) hal_diag_write_char(*msg++);
 }
 
@@ -181,7 +177,6 @@ static int diag_bp = 0;
 
 void hal_diag_write_char(char c)
 {
-#if !defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) || 1
     cyg_uint8 lsr;
 
     hal_diag_init();
@@ -191,10 +186,6 @@ void hal_diag_write_char(char c)
 
     HAL_WRITE_UINT8 (CYG_DEVICE_SERIAL_RS232_16550_THR, c);
     HAL_IO_BARRIER ();
-#endif
-#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) && 0
-    hal_output_gdb_string (&c, 1);
-#endif
     diag_buffer[diag_bp++] = c;
     if (diag_bp == DIAG_BUFSIZE) diag_bp = 0;
 }
--- a/packages/hal/arm/arch/current/ChangeLog
+++ b/packages/hal/arm/arch/current/ChangeLog
@@ -1,3 +1,8 @@
+1999-05-25  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* src/vectors.S (_eCos_id): Add version string.  Useful for
+	tracking when a system was configured (especially ROMs).
+
 1999-05-21  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* include/hal_intr.h: Define HAL_INTERRUPT_STACK_BASE and
--- a/packages/hal/arm/arch/current/src/vectors.S
+++ b/packages/hal/arm/arch/current/src/vectors.S
@@ -74,6 +74,7 @@
 // Hardware exception vectors.
 //   This entire section will be copied to location 0x0000 at startup time.
 //
+	.code	32
 	.section ".vectors","ax"
 	.global	__exception_handlers
 __exception_handlers:
@@ -222,6 +223,7 @@ 1:	str	r0,[r1],#4
 	bne	1b
 2:
 
+
 	// Call platform specific hardware initialization
 	bl	hal_hardware_init
 
@@ -236,6 +238,7 @@ 2:
 	bl	cyg_start
 _start_hang:
 	b	_start_hang
+	.code	32
 
 init_done:
 	.long	0xDEADB00B
@@ -244,7 +247,7 @@ init_done:
 // Exception handlers
 // Assmumption: get here from a Supervisor context [mode]
 //
-
+	.code	32
 undefined_instruction:
 	ldr	sp,.__undef_exception_stack	// get good stack
 	sub	lr,lr,#4		// PC at time of interrupt
@@ -287,6 +290,7 @@ 10:
 	mov	v1,#CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION
 	b	call_exception_handler
 
+	.code	32
 software_interrupt:
 	ldr	sp,.__startup_stack	// get good stack
 	sub	lr,lr,#4		// PC at time of interrupt
@@ -318,6 +322,7 @@ software_interrupt:
 	mov	v1,#CYGNUM_HAL_EXCEPTION_INTERRUPT
 	b	call_exception_handler
 
+	.code	32
 abort_prefetch:
 	ldr	sp,.__undef_exception_stack	// get good stack
 	sub	lr,lr,#4		// PC at time of interrupt
@@ -360,6 +365,7 @@ 10:
 	mov	v1,#CYGNUM_HAL_EXCEPTION_CODE_ACCESS
 	b	call_exception_handler
 
+	.code	32
 abort_data:
 	ldr	sp,.__undef_exception_stack	// get good stack
 	sub	lr,lr,#4		// PC at time of interrupt
@@ -402,6 +408,7 @@ 10:
 	mov	v1,#CYGNUM_HAL_EXCEPTION_DATA_ACCESS
 	b	call_exception_handler
 
+	.code	32
 FIQ:
 	ldr	sp,.__startup_stack	// get good stack
 	sub	lr,lr,#4		// PC at time of interrupt
@@ -436,6 +443,7 @@ FIQ:
 //
 // Dispatch an exception handler.
 
+	.code	32
 call_exception_handler:
 	str	v1,[sp,#armreg_vector]
 	mov	r0,sp
@@ -469,6 +477,7 @@ call_exception_handler:
 // This is slightly more complicated than the other exception handlers because
 // it needs to interface with the kernel (if present).
 
+	.code	32
 IRQ:
 	// Note: I use this exception stack while saving the context because
 	// the current SP does not seem to be always valid in this CPU mode.
@@ -565,6 +574,7 @@ 10:
                                 // threads and call scheduler
 #endif
 
+
 //	mov	r0,sp
 //	bl	show_frame_out
 
@@ -671,6 +681,11 @@ PTR(irq_level)
 PTR(__interrupt_stack)
 #endif
 
+//
+// Identification - useful to find out when a system was configured
+_eCos_id:
+	.asciz	"eCos v1.2.1: " __DATE__
+
 
 // -------------------------------------------------------------------------
 // Interrupt vector tables.
--- a/packages/hal/arm/pid/current/ChangeLog
+++ b/packages/hal/arm/pid/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-24  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* src/hal_diag.c: Clean up direct hardware access code.	
+
 1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
 
 	* include/pkgconf/hal_arm_pid.h: Move RTC setup here.
--- a/packages/hal/arm/pid/current/src/hal_diag.c
+++ b/packages/hal/arm/pid/current/src/hal_diag.c
@@ -164,10 +164,8 @@
 
 void hal_diag_init(void)
 {
-#if 1
     static int init = 0;
     char *msg = "\n\rARM eCos\n\r";
-#if !defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) || 1
     cyg_uint8 lcr;
 
     if (init++) return;
@@ -185,12 +183,7 @@ void hal_diag_init(void)
     lcr &= ~SIO_LCR_DLAB;
     HAL_WRITE_UINT8 (CYG_DEVICE_SERIAL_RS232_16550_LCR, lcr);
     HAL_WRITE_UINT8 (CYG_DEVICE_SERIAL_RS232_16550_FCR, 0x07);  // Enable & clear FIFO
-#endif
-#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) && 0
-    if (init++) return;
-#endif    
     while (*msg) hal_diag_write_char(*msg++);
-#endif
 }
 
 #if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
@@ -203,8 +196,6 @@ static int diag_bp = 0;
 
 void hal_diag_write_char(char c)
 {
-#if 1
-#if !defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) || 1
     cyg_uint8 lsr;
 
     hal_diag_init();
@@ -213,15 +204,8 @@ void hal_diag_write_char(char c)
     } while ((lsr & SIO_LSR_THRE) == 0);
 
     HAL_WRITE_UINT8 (CYG_DEVICE_SERIAL_RS232_16550_THR, c);
-#endif
-#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) && 0
-    hal_output_gdb_string (&c, 1);
-#endif
     diag_buffer[diag_bp++] = c;
     if (diag_bp == DIAG_BUFSIZE) diag_bp = 0;
-#else
-    hal_output_gdb_string (&c, 1);
-#endif
 }
 
 void hal_diag_read_char(char *c)
@@ -234,6 +218,7 @@ void hal_diag_read_char(char *c)
 
     HAL_READ_UINT8 (CYG_DEVICE_SERIAL_RS232_16550_RBR, *c);
 }
+
 #else // HAL_DIAG relies on GDB
 
 // Initialize diag port - assume GDB channel is already set up
--- a/packages/hal/common/current/ChangeLog
+++ b/packages/hal/common/current/ChangeLog
@@ -1,3 +1,26 @@
+1999-05-28  Nick Garnett  <nickg@cygnus.co.uk>
+
+	* src/hal_stub.c (initHardware): Added call to
+	HAL_STUB_PLATFORM_INIT if it is defined.
+
+	* include/pkgconf/hal.h: Added a #undef for CYG_HAL_ROM_MONITOR,
+	largely so that a stubrom permutation can define it.
+
+1999-05-27  Nick Garnett  <nickg@cygnus.co.uk>
+
+	* src/hal_stub.c: Do not call HAL_ICACHE_INVALIDATE_ALL() and
+	HAL_DCACHE_INVALIDATE_ALL() in __instruction_cache() and
+	__data_cache() for MIPS targets. These macros are simply
+	duplicates.
+
+1999-05-27  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/cache.c:  Added handling of unified caches.
+
+1999-05-25  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* tests/cache.c: Use HAL_DCACHE_SYNC if available
+
 1999-05-21  Jesper Skov  <jskov@cygnus.co.uk>
 
 	* src/hal_stub.c (__install_traps): Set exit vector to __reset.
--- a/packages/hal/common/current/include/pkgconf/hal.h
+++ b/packages/hal/common/current/include/pkgconf/hal.h
@@ -400,6 +400,17 @@
 #endif
 
 /* ---------------------------------------------------------------------
+ * This option decides whether we are going to BE a ROM monitor. On
+ * some targets and platforms we provide a simple ROM monitor (the GDB
+ * STUBS monitor) by means of a simple configuration of the HAL and
+ * GDB stubs.
+ * This option has no CDL since it is only set by a special configuration
+ * permutation used for building a monitor.
+ */
+
+#undef CYG_HAL_ROM_MONITOR
+
+/* ---------------------------------------------------------------------
  *
  * The section below deals with some inferences about package/feature
  * presence that are not yet supported by the full external configuration
@@ -433,6 +444,7 @@
 # define CYG_HAL_POWERPC_MPC603
 #endif
 
+
 #ifdef CYGPKG_HAL_MIPS
 #include CYGBLD_HAL_TARGET_H
 #endif
--- a/packages/hal/common/current/src/hal_stub.c
+++ b/packages/hal/common/current/src/hal_stub.c
@@ -275,6 +275,11 @@ initHardware (void)
     if (!initialized) {
         initialized = 1;
 
+#ifdef HAL_STUB_PLATFORM_INIT
+        // If the platform defines any initialization code, call it here.
+        HAL_STUB_PLATFORM_INIT();
+#endif        
+                
         // Get serial port initialized.
         HAL_STUB_PLATFORM_INIT_SERIAL();
 
@@ -410,7 +415,11 @@ int
         break;
     case CACHE_FLUSH:
         HAL_ICACHE_SYNC();
+#ifndef CYGPKG_HAL_MIPS
+        // SYNC and INVALIDATE_ALL are the same on the MIPS,
+        // so avoid doing it twice.
         HAL_ICACHE_INVALIDATE_ALL();
+#endif        
         break;
     case CACHE_NOOP:
         /* fall through */
@@ -442,14 +451,17 @@ int
         break;
     case CACHE_FLUSH:
         HAL_DCACHE_SYNC();
+#ifndef CYGPKG_HAL_MIPS
+        // SYNC and INVALIDATE_ALL are the same on the MIPS,
+        // so avoid doing it twice.
         HAL_DCACHE_INVALIDATE_ALL();
+#endif        
         break;
     case CACHE_NOOP:
         /* fall through */
     default:
         break;
     }
-
 #ifdef HAL_DCACHE_IS_ENABLED
     HAL_DCACHE_IS_ENABLED(state);
 #endif
--- a/packages/hal/common/current/tests/cache.c
+++ b/packages/hal/common/current/tests/cache.c
@@ -45,7 +45,11 @@
 // -------------------------------------------------------------------------
 // If the HAL does not supply this, we supply our own version
 
-#ifndef HAL_DCACHE_PURGE_ALL
+#ifdef HAL_DCACHE_SYNC
+
+# define HAL_DCACHE_PURGE_ALL() HAL_DCACHE_SYNC()
+
+#else
 
 static cyg_uint8 dca[HAL_DCACHE_SIZE + HAL_DCACHE_LINE_SIZE*2];
 
@@ -116,6 +120,26 @@ static void entry0( void )
 {
     register CYG_INTERRUPT_STATE oldints;
 
+#ifdef HAL_CACHE_UNIFIED
+
+    HAL_DISABLE_INTERRUPTS(oldints);
+    HAL_DCACHE_PURGE_ALL();             // rely on above definition
+    HAL_UCACHE_INVALIDATE_ALL();
+    HAL_UCACHE_DISABLE();
+    HAL_RESTORE_INTERRUPTS(oldints);
+    CYG_TEST_INFO("Cache off");
+    time1();
+
+    HAL_DISABLE_INTERRUPTS(oldints);
+    HAL_DCACHE_PURGE_ALL();             // rely on above definition
+    HAL_UCACHE_INVALIDATE_ALL();
+    HAL_UCACHE_ENABLE();
+    HAL_RESTORE_INTERRUPTS(oldints);
+    CYG_TEST_INFO("Cache on");
+    time1();
+
+#else // HAL_CACHE_UNIFIED
+
     HAL_DISABLE_INTERRUPTS(oldints);
     HAL_DCACHE_PURGE_ALL();
     HAL_ICACHE_INVALIDATE_ALL();
@@ -166,6 +190,8 @@ static void entry0( void )
     CYG_TEST_INFO("Dcache off Icache off");
     time1();
 
+#endif // HAL_CACHE_UNIFIED
+
     CYG_TEST_PASS_FINISH("End of test");
 }
 
--- a/packages/hal/mips/arch/current/ChangeLog
+++ b/packages/hal/mips/arch/current/ChangeLog
@@ -1,3 +1,32 @@
+1999-05-28  Nick Garnett  <nickg@cygnus.co.uk>
+
+	* src/vectors.S:
+	Removed references to CYG_HAL_STARTUP_STUBS.
+	Removed some defunct code.
+
+	* include/hal_cache.h (HAL_ICACHE_INVALIDATE_ALL): Fixed typo.
+
+1999-05-27  Nick Garnett  <nickg@cygnus.co.uk>
+
+	* src/vectors.S:
+	Move call to hal_diag_intr_start to a more useful place.
+	Added a save of the current state pointer to memory for ctrl-c
+	support. Ensure that exceptions are enabled before calling the ISR
+	to allow breakpoints to function.
+
+	* src/mips-stub.c: Imported asynchronous interrupt support from
+	libstub/cygmon.
+
+	* include/hal_intr.h: Added HAL_DEFAULT_ISR to contain the name of
+	the default ISR.
+
+	* src/hal_misc.c: Added code to call HAL_CTRLC_ISR to default ISR
+	if it is enabled. Added some (disabled) debug code.
+
+	* include/hal_cache.h: Added default implementation of
+	HAL_DCACHE_IS_ENABLED(). Made use of it in some cache macros.
+	Also fixed some typos in some macros.
+
 1999-05-21  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* include/hal_intr.h: Define HAL_INTERRUPT_STACK_BASE and
--- a/packages/hal/mips/arch/current/include/hal_cache.h
+++ b/packages/hal/mips/arch/current/include/hal_cache.h
@@ -93,6 +93,10 @@
 #define HAL_DCACHE_DISABLE()
 #endif
 
+#ifndef HAL_DCACHE_IS_ENABLED_DEFINED
+#define HAL_DCACHE_IS_ENABLED(_state_) (_state_) = 1;
+#endif
+
 // Invalidate the entire cache
 // We simply use HAL_DCACHE_SYNC() to do this. For writeback caches this
 // is not quite what we want, but there is no index-invalidate operation
@@ -109,12 +113,14 @@
     register CYG_ADDRESS _baddr_ = 0x80000000;                          \
     register CYG_ADDRESS _addr_ = 0x80000000;                           \
     register CYG_WORD _size_ = HAL_DCACHE_SIZE;                         \
+    register CYG_WORD _state_;                                          \
+    HAL_DCACHE_IS_ENABLED(_state_);                                     \
     HAL_DCACHE_DISABLE();                                               \
     for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_DCACHE_LINE_SIZE )   \
     {                                                                   \
         asm volatile ("cache 0x01,0(%0)" : : "r"(_addr_) );             \
     }                                                                   \
-    HAL_DCACHE_ENABLE();                                                \
+    if( _state_ ) HAL_DCACHE_ENABLE();                                  \
 }
 #endif
 
@@ -136,12 +142,14 @@ CYG_MACRO_START                         
     register CYG_ADDRESS _baddr_ = (CYG_ADDRESS)(_base_);               \
     register CYG_ADDRESS _addr_ = (CYG_ADDRESS)(_base_);                \
     register CYG_WORD _size_ = (_asize_);                               \
+    register CYG_WORD _state_;                                          \
+    HAL_DCACHE_IS_ENABLED(_state_);                                     \
     HAL_DCACHE_DISABLE();                                               \
     for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_DCACHE_LINE_SIZE )   \
     {                                                                   \
         asm volatile ("cache 0x1d,0(%0)" : : "r"(_addr_) );             \
     }                                                                   \
-    HAL_DCACHE_ENABLE();                                                \
+    if( _state_ ) HAL_DCACHE_ENABLE();                                  \
 CYG_MACRO_END
 #endif
 
@@ -174,12 +182,14 @@ CYG_MACRO_END
     register CYG_ADDRESS _baddr_ = (CYG_ADDRESS)(_base_);               \
     register CYG_ADDRESS _addr_ = (CYG_ADDRESS)(_base_);                \
     register CYG_WORD _size_ = (_asize_);                               \
+    register CYG_WORD _state_;                                          \
+    HAL_DCACHE_IS_ENABLED(_state_);                                     \
     HAL_DCACHE_DISABLE();                                               \
     for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_DCACHE_LINE_SIZE )   \
     {                                                                   \
         asm volatile ("cache 0x15,0(%0)" : : "r"(_addr_) );             \
     }                                                                   \
-    HAL_DCACHE_ENABLE();                                                \
+    if( _state_ ) HAL_DCACHE_ENABLE();                                  \
 }
 #endif
 
@@ -191,12 +201,14 @@ CYG_MACRO_END
     register CYG_ADDRESS _baddr_ = (CYG_ADDRESS)(_base_);               \
     register CYG_ADDRESS _addr_ = (CYG_ADDRESS)(_base_);                \
     register CYG_WORD _size_ = (_asize_);                               \
+    register CYG_WORD _state_;                                          \
+    HAL_DCACHE_IS_ENABLED(_state_);                                     \
     HAL_DCACHE_DISABLE();                                               \
     for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_DCACHE_LINE_SIZE )   \
     {                                                                   \
         asm volatile ("cache 0x11,0(%0)" : : "r"(_addr_) );             \
     }                                                                   \
-    HAL_DCACHE_ENABLE();                                                \
+    if( _state_ ) HAL_DCACHE_ENABLE();                                  \
 }
 #endif
 
@@ -208,12 +220,14 @@ CYG_MACRO_END
     register CYG_ADDRESS _baddr_ = (CYG_ADDRESS)(_base_);               \
     register CYG_ADDRESS _addr_ = (CYG_ADDRESS)(_base_);                \
     register CYG_WORD _size_ = (_asize_);                               \
+    register CYG_WORD _state_;                                          \
+    HAL_DCACHE_IS_ENABLED(_state_);                                     \
     HAL_DCACHE_DISABLE();                                               \
     for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_DCACHE_LINE_SIZE )   \
     {                                                                   \
         asm volatile ("cache 0x19,0(%0)" : : "r"(_addr_) );             \
     }                                                                   \
-    HAL_DCACHE_ENABLE();                                                \
+    if( _state_ ) HAL_DCACHE_ENABLE();                                  \
 }
 #endif
 
@@ -242,6 +256,10 @@ CYG_MACRO_END
 #define HAL_ICACHE_DISABLE()
 #endif
 
+#ifndef HAL_ICACHE_IS_ENABLED_DEFINED
+#define HAL_ICACHE_IS_ENABLED(_state_) (_state_) = 1;
+#endif
+
 // Invalidate the entire cache
 // This uses the index-invalidate cache operation.
 #ifndef HAL_ICACHE_INVALIDATE_ALL_DEFINED
@@ -249,12 +267,14 @@ CYG_MACRO_END
 {                                                                               \
     register CYG_ADDRESS _baddr_ = 0x80000000;                                  \
     register CYG_ADDRESS _addr_ = 0x80000000;                                   \
+    register CYG_WORD _state_;                                                  \
+    HAL_ICACHE_IS_ENABLED(_state_);                                             \
     HAL_ICACHE_DISABLE();                                                       \
     for( ; _addr_ < _baddr_+HAL_ICACHE_SIZE; _addr_ += HAL_ICACHE_LINE_SIZE )   \
     {                                                                           \
         asm volatile ("cache 0x00,0(%0)" : : "r"(_addr_) );                     \
     }                                                                           \
-    HAL_ICACHE_ENABLE();                                                        \
+    if( _state_ ) HAL_ICACHE_ENABLE();                                          \
 }
 #endif
 
@@ -276,12 +296,14 @@ CYG_MACRO_START                         
     register CYG_ADDRESS _baddr_ = (CYG_ADDRESS)(_base_);               \
     register CYG_ADDRESS _addr_ = (CYG_ADDRESS)(_base_);                \
     register CYG_WORD _size_ = (_asize_);                               \
-    HAL_DCACHE_DISABLE();                                               \
+    register CYG_WORD _state_;                                          \
+    HAL_ICACHE_IS_ENABLED(_state_);                                     \
+    HAL_ICACHE_DISABLE();                                               \
     for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_DCACHE_LINE_SIZE )   \
     {                                                                   \
         asm volatile ("cache 0x1c,0(%0)" : : "r"(_addr_) );             \
     }                                                                   \
-    HAL_DCACHE_ENABLE();                                                \
+    if( _state_ ) HAL_ICACHE_ENABLE();                                  \
 CYG_MACRO_END
 #endif
 
@@ -306,12 +328,14 @@ CYG_MACRO_END
     register CYG_ADDRESS _baddr_ = (CYG_ADDRESS)(_base_);               \
     register CYG_ADDRESS _addr_ = (CYG_ADDRESS)(_base_);                \
     register CYG_WORD _size_ = (_asize_);                               \
-    HAL_DCACHE_DISABLE();                                               \
-    for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_DCACHE_LINE_SIZE )   \
+    register CYG_WORD _state_;                                          \
+    HAL_ICACHE_IS_ENABLED(_state_);                                     \
+    HAL_ICACHE_DISABLE();                                               \
+    for( ; _addr_ <= _baddr_+_size_; _addr_ += HAL_ICACHE_LINE_SIZE )   \
     {                                                                   \
         asm volatile ("cache 0x10,0(%0)" : : "r"(_addr_) );             \
     }                                                                   \
-    HAL_DCACHE_ENABLE();                                                \
+    HAL_ICACHE_ENABLE();                                                \
 }
 #endif
 
--- a/packages/hal/mips/arch/current/include/hal_intr.h
+++ b/packages/hal/mips/arch/current/include/hal_intr.h
@@ -168,9 +168,13 @@ externC volatile CYG_ADDRESS    hal_vsr_
 
 //--------------------------------------------------------------------------
 // Default ISR
+// The #define is used to test whether this routine exists, and to allow
+// us to call it.
 
 externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
 
+#define HAL_DEFAULT_ISR hal_default_isr
+
 //--------------------------------------------------------------------------
 // Interrupt state storage
 
@@ -280,7 +284,7 @@ externC void hal_interrupt_stack_call_pe
     cyg_uint32 _index_;                                                   \
     HAL_TRANSLATE_VECTOR ((_vector_), _index_);                           \
                                                                           \
-    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)hal_default_isr ) \
+    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR ) \
         (_state_) = 0;                                                    \
     else                                                                  \
         (_state_) = 1;                                                    \
@@ -291,7 +295,7 @@ externC void hal_interrupt_stack_call_pe
     cyg_uint32 _index_;                                                     \
     HAL_TRANSLATE_VECTOR( _vector_, _index_ );                              \
                                                                             \
-    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)hal_default_isr )   \
+    if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)HAL_DEFAULT_ISR )   \
     {                                                                       \
         hal_interrupt_handlers[_index_] = (CYG_ADDRESS)_isr_;               \
         hal_interrupt_data[_index_] = (CYG_ADDRWORD)_data_;                 \
@@ -306,7 +310,7 @@ externC void hal_interrupt_stack_call_pe
                                                                         \
     if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)_isr_ )         \
     {                                                                   \
-        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)hal_default_isr; \
+        hal_interrupt_handlers[_index_] = (CYG_ADDRESS)HAL_DEFAULT_ISR; \
         hal_interrupt_data[_index_] = 0;                                \
         hal_interrupt_objects[_index_] = 0;                             \
     }                                                                   \
--- a/packages/hal/mips/arch/current/src/hal_misc.c
+++ b/packages/hal/mips/arch/current/src/hal_misc.c
@@ -91,6 +91,18 @@ externC void exception_handler(HAL_Saved
 
 externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
 {
+#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) &&      \
+    defined(CYGHWR_HAL_GDB_PORT_VECTOR) &&              \
+    defined(HAL_CTRLC_ISR)
+
+    if( vector == CYGHWR_HAL_GDB_PORT_VECTOR )
+    {
+        cyg_uint32 result = HAL_CTRLC_ISR( vector, data );
+        if( result != 0 ) return result;
+    }
+    
+#endif
+    
     CYG_TRACE1(true, "Interrupt: %d", vector);
     CYG_FAIL("Spurious Interrupt!!!");
     return 0;
--- a/packages/hal/mips/arch/current/src/mips-stub.c
+++ b/packages/hal/mips/arch/current/src/mips-stub.c
@@ -27,6 +27,50 @@
 #include <cyg/hal/hal_arch.h>
 #include <cyg/hal/mips_opcode.h>
 
+typedef unsigned long t_inst;
+
+/*----------------------------------------------------------------------
+ * Asynchronous interrupt support
+ */
+
+static struct
+{
+  t_inst *targetAddr;
+  t_inst savedInstr;
+} asyncBuffer;
+
+/* Called to asynchronously interrupt a running program.
+   Must be passed address of instruction interrupted.
+   This is typically called in response to a debug port
+   receive interrupt.
+*/
+
+void
+install_async_breakpoint(void *epc)
+{
+  long gp_save;
+
+  /* This may be called from a separately linked program,
+     so we need to save and restore the incoming gp register
+     and setup our stub local gp register. 
+     Alternatively, we could skip this foolishness if we
+     compiled libstub with "-G 0". */
+
+  __asm__ volatile ( "move   %0,$28\n"
+		     ".extern _gp\n"
+		     "la     $28,_gp\n"
+		     : "=r" (gp_save) );
+
+  asyncBuffer.targetAddr = epc;
+  asyncBuffer.savedInstr = *(t_inst *)epc;
+  *(t_inst *)epc = *(t_inst *)_breakinst;
+  __instruction_cache(CACHE_FLUSH);
+  __data_cache(CACHE_FLUSH);
+
+  __asm__  volatile ( "move   $28,%0\n" :: "r"(gp_save) );
+}
+
+/*--------------------------------------------------------------------*/
 /* Given a trap value TRAP, return the corresponding signal. */
 
 int __computeSignal (unsigned int trap_number)
@@ -45,6 +89,15 @@ int __computeSignal (unsigned int trap_n
 
     case EXC_BP:
       /* Break point */
+      if (asyncBuffer.targetAddr != NULL)
+	{
+	  /* BP installed by serial driver to stop running program */
+	  *asyncBuffer.targetAddr = asyncBuffer.savedInstr;
+          __instruction_cache(CACHE_FLUSH);
+          __data_cache(CACHE_FLUSH);
+	  asyncBuffer.targetAddr = NULL;
+	  return SIGINT;
+	}
       return SIGTRAP;
 
     case EXC_OVF:
@@ -104,8 +157,6 @@ void set_pc (target_register_t pc)
 
 /* Saved instruction data for single step support.  */
 
-typedef unsigned long t_inst;
-
 static struct
 {
   t_inst *targetAddr;
--- a/packages/hal/mips/arch/current/src/vectors.S
+++ b/packages/hal/mips/arch/current/src/vectors.S
@@ -164,7 +164,7 @@ FUNC_START(_start)
 	jal     cyg_hal_invoke_constructors
 	nop
 
-#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) && !defined(CYG_HAL_STARTUP_STUBS)
+#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
         .extern initialize_stub
         jal     initialize_stub
         nop
@@ -192,7 +192,6 @@ FUNC_START(__default_exception_vsr)
 	# K0 = vector index
 	# K1 = address of this function
 
-		
 	move	k1,sp			# K1 = original SP
 	
 #ifdef CYG_HAL_ROM_MONITOR
@@ -372,8 +371,6 @@ FUNC_START(__default_interrupt_vsr)
 		
 	# The machine state is now all saved on the stack.
 
-	hal_diag_intr_start
-
 	# Load Global Pointer register.
 	la	gp,_gp
 	
@@ -421,7 +418,9 @@ 8:
 
 	# Here s1 is the number of the vector to be called and s2 is
 	# the number of the interrupt being serviced. 
-	
+
+	hal_diag_intr_start
+		
 #if defined(CYGPKG_KERNEL_INSTRUMENT) && defined(CYGDBG_KERNEL_INSTRUMENT_INTR)
 
 	# Call cyg_instrument to record that this interrupt is being raised.
@@ -432,8 +431,21 @@ 8:
 	xor	a2,a2,a2			# arg2 = 0 (delay slot)
 #endif
 
+#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
+	# If we are supporting Ctrl-C interrupts from GDB, we must squirrel
+	# away a pointer to the save interrupt state here so that we can
+	# plant a breakpoint at some later time.
+	
+	.extern	hal_saved_interrupt_state
+	la	v0,hal_saved_interrupt_state
+	sw	s0,0(v0)
+	
+#endif
+	
 	sll	s1,s1,2				# s1 = byte offset of vector
-	
+
+	hal_cpu_except_enable			# reenable exceptions
+			
 	la	t2,hal_interrupt_handlers	# handler table
 	add	t2,t2,s1			# address of ISR ptr
 	lw	t2,0(t2)			# ISR pointer
@@ -444,8 +456,6 @@ 8:
 
 	move	a0,s2				# pass interrupt number
 
-	move	a2,s0				# arg3 = saved register dump
-		
 	jalr	t2				# call ISR via t2
 	nop					# (delay slot)
 
--- a/packages/hal/mips/jmr3904/current/ChangeLog
+++ b/packages/hal/mips/jmr3904/current/ChangeLog
@@ -1,3 +1,15 @@
+1999-05-27  Nick Garnett  <nickg@cygnus.co.uk>
+
+	* src/plf_misc.c: Reorganized and generally fixed up Ctrl-C
+	handling code.
+
+	* include/plf_intr.h: Added support for Ctrl-C handling.
+
+1999-05-25  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/plf_misc.c: Change CYG_HAL_TX39_JMR3904 to
+	CYG_HAL_MIPS_TX39_JMR3904
+
 1999-05-21  Jonathan Larmour  <jlarmour@cygnus.co.uk>
 
 	* src/hal_diag.c: Delete - this has been moved to hal/mips/tx39
--- a/packages/hal/mips/jmr3904/current/include/plf_intr.h
+++ b/packages/hal/mips/jmr3904/current/include/plf_intr.h
@@ -54,8 +54,18 @@
 #include <cyg/infra/cyg_type.h>
 
 //--------------------------------------------------------------------------
+// Control-C support.
 
-// No platform specific stuff at present.
+#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
+
+# define CYGHWR_HAL_GDB_PORT_VECTOR CYGNUM_HAL_INTERRUPT_SIO_0
+
+externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
+
+# define HAL_CTRLC_ISR hal_ctrlc_isr
+
+#endif
+
 
 //--------------------------------------------------------------------------
 #endif // ifndef CYGONCE_HAL_PLF_INTR_H
--- a/packages/hal/mips/jmr3904/current/src/plf_misc.c
+++ b/packages/hal/mips/jmr3904/current/src/plf_misc.c
@@ -87,18 +87,13 @@ void hal_platform_init(void)
 
 #endif
 
-#if 0
-#if defined(CYG_HAL_USE_ROM_MONITOR)            && \
-    !defined(CYGDBG_INFRA_DIAG_USE_DEVICE)      && \
-        defined(CYG_HAL_TX39_JMR3904)
-
+#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)    
         {
-            static void hal_init_ctrlc_intr(void);
-            hal_init_ctrlc_intr();
+            void hal_ctrlc_isr_init(void);
+            hal_ctrlc_isr_init();
         }
 
 #endif
-#endif
         
 #if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT)   && \
     defined(CYG_HAL_USE_ROM_MONITOR)            && \
@@ -124,38 +119,46 @@ cyg_bool cyg_hal_is_break(char *buf, int
 
 void cyg_hal_user_break( CYG_ADDRWORD *regs )
 {
-#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
+#if defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_CYGMON)
+    // The following code should be at the very start of this function so
+    // that it can access the RA register before it is saved and reused.
+    register CYG_WORD32 ra;
+    asm volatile ( "move %0,$31;" : "=r" (ra) );
+#endif    
+    
+#if defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_CYGMON)
 
-    // Ctrl-C: breakpoint.
-    extern void breakpoint(void);
-    breakpoint();
-
-#elif defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_GDB_STUBS)
+        {
+            typedef void install_bpt_fn(void *epc);
+            CYG_WORD32 pc;
+            HAL_SavedRegisters *sreg = (HAL_SavedRegisters *)regs;
+            install_bpt_fn *ibp = (install_bpt_fn *)hal_vsr_table[35];
 
-    // Ctrl-C: breakpoint.
-    typedef void bpt_fn(void);
-    bpt_fn *bfn = ((bpt_fn **)0x80000100)[61];
-    bfn();
+            if( regs == NULL ) pc = ra;
+            else pc = sreg->pc;
+
+            if( ibp != NULL ) ibp((void *)pc);
+        }
+    
+#elif defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
 
-#elif defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_CYGMON)
+        {
+            extern void breakpoint(void);
+            breakpoint();
+        }
+    
+#else
 
-    // Ctrl-C: breakpoint.
-    typedef void install_bpt_fn(void *epc);
-    HAL_SavedRegisters *sreg = (HAL_SavedRegisters *)regs;
-    install_bpt_fn *ibp = (install_bpt_fn *)hal_vsr_table[35];
-    if( ibp != NULL ) ibp((void *)sreg->pc);
+        HAL_BREAKPOINT(breakinst);
 
 #endif
 
 }
 
 /*------------------------------------------------------------------------*/
-/* This code installs an interrupt handler to capture Ctrl-C.             */
+/* Control C ISR support                                                  */
 
-#if 0
-#if defined(CYG_HAL_USE_ROM_MONITOR) && \
-    !defined(CYGDBG_INFRA_DIAG_USE_DEVICE)    && \
-    defined(CYG_HAL_TX39_JMR3904)
+#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
 
 #define DIAG_BASE       0xfffff300
 #define DIAG_SLCR       (DIAG_BASE+0x00)
@@ -171,11 +174,27 @@ void cyg_hal_user_break( CYG_ADDRWORD *r
 #define BRG_T2          0x0100
 #define BRG_T4          0x0200
 #define BRG_T5          0x0300
+
+struct Hal_SavedRegisters *hal_saved_interrupt_state;
+
+void hal_ctrlc_isr_init(void)
+{
+    CYG_WORD16 dicr;
     
-static cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data, CYG_ADDRWORD regs)
+    HAL_READ_UINT16( DIAG_SLDICR , dicr );
+    dicr = 0x0001;
+    HAL_WRITE_UINT16( DIAG_SLDICR , dicr );
+
+    HAL_INTERRUPT_SET_LEVEL( CYGHWR_HAL_GDB_PORT_VECTOR, 1 );
+    HAL_INTERRUPT_UNMASK( CYGHWR_HAL_GDB_PORT_VECTOR );
+}
+
+cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
 {
     char c;
     CYG_WORD16 disr;
+
+    HAL_INTERRUPT_ACKNOWLEDGE( CYGHWR_HAL_GDB_PORT_VECTOR );
     
     HAL_READ_UINT16( DIAG_SLDISR , disr );
 
@@ -189,28 +208,12 @@ static cyg_uint32 hal_ctrlc_isr(CYG_ADDR
         HAL_WRITE_UINT16( DIAG_SLDISR , disr );
         
         if( cyg_hal_is_break( &c , 1 ) )
-            cyg_hal_user_break( regs );
+            cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
     }
 
     return 0;
 }
 
-    
-static void hal_init_ctrlc_intr(void)
-{
-    CYG_WORD16 dicr;
-    
-    HAL_INTERRUPT_ATTACH( CYGNUM_HAL_INTERRUPT_SIO_0, hal_ctrlc_isr, NULL,
-                          NULL );
-
-    HAL_INTERRUPT_UNMASK( CYGNUM_HAL_INTERRUPT_SIO_0 );
-
-    HAL_READ_UINT16( DIAG_SLDICR , dicr );
-    dicr = 0x0001;
-    HAL_WRITE_UINT16( DIAG_SLDICR , dicr );    
-}
-
-#endif
 #endif
 
 /*------------------------------------------------------------------------*/
--- a/packages/hal/mips/tx39/current/ChangeLog
+++ b/packages/hal/mips/tx39/current/ChangeLog
@@ -1,3 +1,8 @@
+1999-05-27  Nick Garnett  <nickg@cygnus.co.uk>
+
+	* src/hal_diag.c (hal_diag_write_char): Tidied away defunct code
+	and made use of HAL support for user break detection and delivery.
+
 1999-05-14  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* src/var_misc.c: Added definition of hal_interrupt_level[].
--- a/packages/hal/mips/tx39/current/src/hal_diag.c
+++ b/packages/hal/mips/tx39/current/src/hal_diag.c
@@ -246,58 +246,14 @@ void hal_diag_write_char(char c)
             hal_diag_write_char_serial0(hex[(csum>>4)&0xF]);
             hal_diag_write_char_serial0(hex[csum&0xF]);
 
-#if 1
             hal_diag_read_char_serial0( &c1 );
 
             if( c1 == '+' ) break;
 
-            // FIXME: Need to make the following use
-            // cyg_hal_is_break() and cyg_hal_user_break().
-            
-            if( c1 == 3 )
-                HAL_BREAKPOINT(_breakinst);                
-#endif            
-#if 0
-
-            // We must ack the interrupt caused by that read to avoid
-            // confusing the GDB stub ROM.
-//            HAL_INTERRUPT_ACKNOWLEDGE( CYGNUM_HAL_INTERRUPT_SIO_0 );
+            if( cyg_hal_is_break( &c1 , 1 ) )
+                cyg_hal_user_break( NULL );    
             
-            if( c1 == '+' ) break;
-
-#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
-            if( c1 == 3 )
-            {
-                // Ctrl-C: breakpoint.
-                extern void breakpoint();
-                breakpoint();
-                break;
-            }
-#elif defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_GDB_STUBS)
-            if( c1 == 3 )
-            {
-                // Ctrl-C: breakpoint.
-//                HAL_BREAKPOINT(_breakinst);
-                typedef void bpt_fn();
-                bpt_fn *bfn = ((bpt_fn **)0x80000100)[61];
-
-                bfn();
-                
-                break;
-            }
-#elif defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_CYGMON)
-            if( c1 == 3 )
-            {
-                // Ctrl-C: breakpoint.
-                HAL_BREAKPOINT(_breakinst);
-                
-                break;
-            }            
-#endif
-            
-#else
             break;
-#endif
         }
         
         pos = 0;
--- a/packages/hal/powerpc/arch/current/ChangeLog
+++ b/packages/hal/powerpc/arch/current/ChangeLog
@@ -1,3 +1,14 @@
+1999-05-26  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* include/hal_cache.h (HAL_DCACHE_LOCK):
+	Fixed asm constraint.
+
+1999-05-25  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* include/hal_intr.h:
+	* src/vectors.S (hal_interrupt_stack_call_pending_DSRs): 
+	Added call_pending_DSR magic.
+
 1999-05-21  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* include/hal_intr.h: Define HAL_INTERRUPT_STACK_BASE and
--- a/packages/hal/powerpc/arch/current/include/hal_cache.h
+++ b/packages/hal/powerpc/arch/current/include/hal_cache.h
@@ -313,7 +313,7 @@ typedef struct {
                       "sync;"                                                 \
                       "mtspr %2, %4;"                                         \
                       "mtspr %3, %5;"                                         \
-                      : /* %0 */ "=r" (__scratch)                             \
+                      : /* %0 */ "=&r" (__scratch)                            \
                       : /* %1 */ "b" (__base),                                \
                         /* %2 */ "I" (CYGARC_REG_DC_ADR),                     \
                         /* %3 */ "I" (CYGARC_REG_DC_CST),                     \
--- a/packages/hal/powerpc/arch/current/include/hal_intr.h
+++ b/packages/hal/powerpc/arch/current/include/hal_intr.h
@@ -326,7 +326,9 @@ typedef cyg_uint32 CYG_INTERRUPT_STATE;
 //--------------------------------------------------------------------------
 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
 
-// Macro/routine to call DSRs on interrupt stack?
+externC void hal_interrupt_stack_call_pending_DSRs(void);
+#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
+    hal_interrupt_stack_call_pending_DSRs()
 
 // these are offered solely for stack usage testing
 // if they are not defined, then there is no interrupt stack.
--- a/packages/hal/powerpc/arch/current/src/vectors.S
+++ b/packages/hal/powerpc/arch/current/src/vectors.S
@@ -800,6 +800,61 @@ restore_state:
         isync   
         rfi                             # and return
 
+
+
+##-----------------------------------------------------------------------------
+## Execute pending DSRs on the interrupt stack with interrupts enabled.
+## Note: this can only be called from code running on a thread stack
+	
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+	.extern cyg_interrupt_call_pending_DSRs
+
+FUNC_START(hal_interrupt_stack_call_pending_DSRs)
+        # Disable interrupts
+        mfmsr   r4
+        lis     r3,0
+        ori     r3,r3,0x8000
+        andc    r5,r4,r3
+        mtmsr   r5
+
+        # Change to interrupt stack
+        mr      r3,sp
+        lwi     sp,__interrupt_stack
+        stwu    r3,-4(sp)                       # store old stackptr on stack
+        mflr    r3
+        stwu    r3,-4(sp)                       # store lr on stack
+        stwu    r4,-4(sp)                       # store msr values on stack
+        stwu    r5,-4(sp)
+        
+        # Set up stack for calls to C code.
+        subi    sp,sp,12                        # make space on stack
+        li      r0,0
+        stw     r0,0(sp)                        # clear back chain
+        stw     r0,8(sp)                        # zero return pc
+        stwu    sp,-ppc_stack_frame_size(sp)    # create new stack frame
+
+        # Restore interrupt state
+        mtmsr   r4
+
+        # Call into kernel which will execute DSRs
+        bl      cyg_interrupt_call_pending_DSRs
+
+        # Unwind stack and get msr values
+        lwzu    r5,12+ppc_stack_frame_size(sp)
+        lwz     r4,4(sp)
+        lwz     r3,8(sp)
+        mtlr    r3
+
+        # Disable interrupts
+        mtmsr   r5
+
+        # Restore original stack pointer, original interrupt state and return
+        lwz     sp,12(sp)
+        mtmsr   r4
+
+        blr
+#endif		
+        
 #---------------------------------------------------------------------------
 # Code for putting the CPU in a post-reset state; disabling MMU and caches.
 _init_CPU:
--- a/packages/io/serial/current/ChangeLog
+++ b/packages/io/serial/current/ChangeLog
@@ -1,3 +1,29 @@
+1999-05-27  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/ser_test_protocol.inl: Added ability to change options in
+	host software.
+
+1999-05-27  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/mn10300/mn10300_serial.c (mn10300_serial_config_port): 
+	Wait for the serial device to become acquiescent before disabling
+	it. This prevents cygmon's outgoing characters getting corrupted
+	due to transmission being disabled.
+	Fix for PR 20047
+	
+
+
+1999-05-25  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* tests/ser_test_protocol.inl: 
+	Change all mentions of CYGPKG_HAL_TX39_JMR3904 to
+	CYGPKG_HAL_MIPS_TX39_JMR3904
+
+1999-05-25  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/PKGconf.mak (EXTRAS_COMPILE): Change CYG_HAL_TX39 to
+	CYG_HAL_MIPS_TX39
+
 1999-05-18  Jesper Skov  <jskov@cygnus.co.uk>
         PR 19926
 	* src/sparclite/sleb_sdtr.c (sleb_sdtr_rx_DSR): Only read chan if
--- a/packages/io/serial/current/include/pkgconf/io_serial.h
+++ b/packages/io/serial/current/include/pkgconf/io_serial.h
@@ -386,7 +386,6 @@
 
 
 
-
 /* ----------------------------------------------------------------------------
    {{CFG_DATA
    cdl_component CYGPKG_IO_SERIAL_POWERPC_COGENT {
@@ -875,5 +874,6 @@
 #define CYGNUM_IO_SERIAL_MN10300_SERIAL2_BAUD 38400
 #define CYGNUM_IO_SERIAL_MN10300_SERIAL2_BUFSIZE 128
 
+
 #endif  /* CYGONCE_PKGCONF_IO_SERIAL_H */
 /* EOF io_serial.h */
--- a/packages/io/serial/current/src/PKGconf.mak
+++ b/packages/io/serial/current/src/PKGconf.mak
@@ -43,7 +43,7 @@ endif
 ifdef CYG_HAL_MN10300_STDEVAL1
 EXTRAS_COMPILE  += mn10300/mn10300_serial.c
 endif
-ifdef CYG_HAL_TX39
+ifdef CYG_HAL_MIPS_TX39
 EXTRAS_COMPILE  += mips/tx3904_serial.c
 endif
 ifdef CYG_HAL_POWERPC_COGENT
--- a/packages/io/serial/current/src/mn10300/mn10300_serial.c
+++ b/packages/io/serial/current/src/mn10300/mn10300_serial.c
@@ -449,9 +449,18 @@ mn10300_serial_config_port(serial_channe
 {
     mn10300_serial_info *mn10300_chan = (mn10300_serial_info *)chan->dev_priv;
     cyg_uint16 cr = 0;
+    cyg_uint16 sr;
+
+    // wait for the device to become acquiescent. This could take some time
+    // if the device had been transmitting at a low baud rate.
+    do {
+        sr = mn10300_read_sr(mn10300_chan);
+    } while (sr & (SR_RXF|SR_TXF));
 
     // Disable device entirely.
     HAL_WRITE_UINT16(mn10300_chan->base+SERIAL_CTR, 0);
+
+    // Set up the Interrupt Mode Register
     HAL_WRITE_UINT8(mn10300_chan->base+SERIAL_ICR, 0);
 
     // Set up baud rate
--- a/packages/io/serial/current/tests/ser_test_protocol.inl
+++ b/packages/io/serial/current/tests/ser_test_protocol.inl
@@ -90,7 +90,7 @@
 #  define TEST_TTY_DEV CYGDAT_IO_SERIAL_TTY_TTY1_DEV
 # endif
 #endif
-#if defined(CYGPKG_HAL_TX39_JMR3904)                    \
+#if defined(CYGPKG_HAL_MIPS_TX39_JMR3904)               \
     && defined(CYGPKG_IO_SERIAL_TX39_JMR3904)           \
     && defined(CYGPKG_IO_SERIAL_TX39_JMR3904_SERIAL0)
 # define TEST_SER_DEV CYGDAT_IO_SERIAL_TX39_JMR3904_SERIAL0_NAME
@@ -126,7 +126,6 @@
 # endif
 #endif
 
-
 // We can't rely on haldiag for ser_filter detection - it may not define
 // a working character reading function.
 #ifndef   TEST_SER_DEV
@@ -169,12 +168,53 @@ typedef struct ser_cfg {
     // etc...
 } cyg_ser_cfg_t;
 
+typedef enum {
+    OPT_SERIAL_DEBUG = 0,
+    OPT_VERBOSE_LEVEL
+} cyg_option_t;
+
+typedef enum {
+    NONE = 0,
+    PROTOCOL_PROGRESS,
+    PROTOCOL_DATA,
+} cyg_verbosity_level_t;
+
+
+// A few predifined option macros. Use after test_ping().
+#define TEST_OPTIONS(__handle, __array) \
+  test_options(__handle, sizeof(__array)/8, __array)
+
+#define TEST_HOST_DEBUG(__handle)                               \
+    CYG_MACRO_START                                             \
+    cyg_uint32 __options[] = {OPT_SERIAL_DEBUG, 1};             \
+    test_options((__handle), sizeof(__options)/8,               \
+                 __options);                                    \
+    CYG_MACRO_END
+
+#define TEST_HOST_PROGRESS(__handle)                            \
+    CYG_MACRO_START                                             \
+    cyg_uint32 __options[] =                                    \
+        {OPT_SERIAL_DEBUG, 1,                                   \
+         OPT_VERBOSE_LEVEL, PROTOCOL_PROGRESS};                 \
+    test_options((__handle), sizeof(__options)/8,               \
+                 __options);                                    \
+    CYG_MACRO_END
+
+#define TEST_HOST_DATA(__handle)                                \
+    CYG_MACRO_START                                             \
+    cyg_uint32 __options[] =                                    \
+        {OPT_SERIAL_DEBUG, 1,                                   \
+         OPT_VERBOSE_LEVEL, PROTOCOL_DATA};                     \
+    test_options((__handle), sizeof(__options)/8,               \
+                 __options);                                    \
+    CYG_MACRO_END
+
 //----------------------------------------------------------------------------
 // A few predefined configurations. These must all be valid for any
 // given target until change_config is behaving correctly.
 cyg_ser_cfg_t test_configs[] = {
 
-#if !defined(CYGPKG_HAL_TX39_JMR3904) && !defined(CYGPKG_HAL_ARM_PID)
+#if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) && !defined(CYGPKG_HAL_ARM_PID)
     { CYGNUM_SERIAL_BAUD_9600, CYGNUM_SERIAL_WORD_LENGTH_8, 
       CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE },
 #endif
@@ -191,14 +231,14 @@ cyg_ser_cfg_t test_configs[] = {
       CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE },
 #endif
 
-#if !defined(CYGPKG_HAL_TX39_JMR3904) &&        \
+#if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) &&   \
     !defined(CYGPKG_HAL_ARM_AEB) &&             \
     !defined(CYGPKG_HAL_SPARCLITE_SLEB)
     { CYGNUM_SERIAL_BAUD_57600, CYGNUM_SERIAL_WORD_LENGTH_8, 
       CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE },
 #endif
 
-#if !defined(CYGPKG_HAL_TX39_JMR3904) &&        \
+#if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) &&   \
     !defined(CYGPKG_HAL_ARM_PID) &&             \
     !defined(CYGPKG_HAL_ARM_AEB) &&             \
     !defined(CYGPKG_HAL_MN10300_STDEVAL1) &&    \
@@ -207,7 +247,7 @@ cyg_ser_cfg_t test_configs[] = {
       CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE },
 #endif
 
-#if !defined(CYGPKG_HAL_TX39_JMR3904) &&        \
+#if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) &&   \
     !defined(CYGPKG_HAL_ARM_AEB) &&             \
     !defined(CYGPKG_HAL_ARM_PID)
     // One stop bit, even parity
@@ -215,7 +255,7 @@ cyg_ser_cfg_t test_configs[] = {
       CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_EVEN },
 #endif
 
-#if !defined(CYGPKG_HAL_TX39_JMR3904) &&        \
+#if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) &&   \
     !defined(CYGPKG_HAL_ARM_AEB) &&             \
     !defined(CYGPKG_HAL_ARM_PID)
     // Two stop bits, even parity
@@ -223,7 +263,7 @@ cyg_ser_cfg_t test_configs[] = {
       CYGNUM_SERIAL_STOP_2, CYGNUM_SERIAL_PARITY_EVEN },
 #endif
 
-#if !defined(CYGPKG_HAL_TX39_JMR3904)
+#if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904)
     // Two stop bits, no parity
     { CYGNUM_SERIAL_BAUD_19200, CYGNUM_SERIAL_WORD_LENGTH_8, 
       CYGNUM_SERIAL_STOP_2, CYGNUM_SERIAL_PARITY_NONE },
@@ -879,6 +919,46 @@ test_ping(cyg_io_handle_t handle)
     CYG_TEST_NA("No host side testing harness detected.");
 }
 
+
+//---------------------------------------------------------------------------
+// Send OPT to host, setting options in the filter.
+// Format out:
+//  "@OPT:option1,value1:...:optionN,valueN!"
+// Format in:
+//  "OK"
+//
+// Only integer values can be used. Any option not recognized by the
+// filter will be silently ignored.
+void
+test_options(cyg_io_handle_t handle, int count, cyg_uint32* options)
+{
+    const char cmd[] = "@OPT:";
+    int msglen;
+    cyg_uint8 *p1;
+
+    // Prepare and send the command.
+    p1 = &cmd_buffer[0];
+    p1 = strcpy(p1, &cmd[0]);
+    while(count--) {
+        p1 = itoa(p1, *options++);      // option
+        *p1++ = ':';
+        p1 = itoa(p1, *options++);      // value
+        *p1++ = ':';
+    }
+    *(p1-1) = '!';
+    *p1++ = 0;
+
+    CYG_TEST_INFO(&cmd_buffer[1]);
+  
+    msglen = strlen(&cmd_buffer[0]);
+    Tcyg_io_write(handle, &cmd_buffer[0], &msglen);
+
+    // Now read host side's status
+    msglen = 2;
+    Tcyg_io_read(handle, &in_buffer[0], &msglen);
+}
+
+
 //---------------------------------------------------------------------------
 // Some helper functions to get a test started.
 void
--- a/packages/kernel/current/ChangeLog
+++ b/packages/kernel/current/ChangeLog
@@ -1,3 +1,51 @@
+1999-05-27  Nick Garnett  <nickg@cygnus.co.uk>
+
+	* src/intr/intr.cxx (Cyg_Interrupt::chain_isr): Calls
+	HAL_DEFAULT_ISR if it is defined and no chained ISRs have
+	reported that they have handled the interrupt.
+
+	* src/debug/dbg_gdb.cxx (dbg_make_threadref): Fixed this routine
+	so that it copes with a NULL thread object.
+
+1999-05-27  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/stress_threads.c: Output stackmon status
+	occasionally. Output (simple) run time.
+
+1999-05-27  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/kcache1.c: Added handling of unified caches.
+
+1999-05-26  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* include/test/stackmon.h: Fixed some typos and thinkos.
+
+	* tests/tm_basic.cxx: Include new stackmon header.
+
+	* src/common/kapi.cxx: 
+	* include/kapi.h: 
+	Added kapi support for stackmon requirements.
+	
+	* include/stackmon.hxx:    [deleted]
+	* include/test/stackmon.h: [added]
+	Made stackmon safe to use from both C and C++.
+
+1999-05-25  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/stress_threads.c (setup_death_alarm): Only compile when
+	DEATH_TIME_LIMIT is defined.
+
+1999-05-25  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* tests/except1.cxx: 
+	* tests/intr0.cxx (intr0_main): 
+	* tests/kexcept1.c: 
+	* tests/kintr0.c (kintr0_main): 
+	Change all mentions of CYG_HAL_TX39[_JMR3904] to
+	CYG_HAL_MIPS_TX39[_JMR3904]
+	
+	* tests/kcache1.c: Use HAL_DCACHE_SYNC if possible
+
 1999-05-20  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* tests/tm_basic.cxx (run_all_tests): Added some more stack stats
--- a/packages/kernel/current/include/kapi.h
+++ b/packages/kernel/current/include/kapi.h
@@ -159,6 +159,7 @@ void cyg_thread_yield(void);
 
 cyg_handle_t cyg_thread_self(void);
 
+cyg_handle_t cyg_thread_idle_thread(void);
 
 /* Priority manipulation */
 
@@ -176,6 +177,12 @@ void cyg_thread_deadline_wait(
 
 void cyg_thread_delay(cyg_tick_count_t delay);
 
+/* Stack information */
+cyg_addrword_t cyg_thread_get_stack_base(cyg_handle_t thread);
+
+cyg_uint32 cyg_thread_get_stack_size(cyg_handle_t thread);
+
+
 /*---------------------------------------------------------------------------*/
 /* Per-thread Data                                                           */
 
deleted file mode 100644
--- a/packages/kernel/current/include/stackmon.hxx
+++ /dev/null
@@ -1,155 +0,0 @@
-#ifndef CYGONCE_KERNEL_TESTS_STACKMON_H
-#define CYGONCE_KERNEL_TESTS_STACKMON_H
-
-/*=================================================================
-//
-//        stackmon.h
-//
-//        Auxiliary test header file
-//
-//==========================================================================
-//####COPYRIGHTBEGIN####
-//
-// -------------------------------------------
-// The contents of this file are subject to the Cygnus eCos Public License
-// Version 1.0 (the "License"); you may not use this file except in
-// compliance with the License.  You may obtain a copy of the License at
-// http://sourceware.cygnus.com/ecos
-// 
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the
-// License for the specific language governing rights and limitations under
-// the License.
-// 
-// The Original Code is eCos - Embedded Cygnus Operating System, released
-// September 30, 1998.
-// 
-// The Initial Developer of the Original Code is Cygnus.  Portions created
-// by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions.  All Rights Reserved.
-// -------------------------------------------
-//
-//####COPYRIGHTEND####
-//==========================================================================
-//#####DESCRIPTIONBEGIN####
-//
-// Author(s):     hmt
-// Contributors:  hmt
-// Date:          1999-05-20
-// Description:
-//     Defines some convenience functions for stack use output.
-//
-//####DESCRIPTIONEND####
-*/
-
-#include <pkgconf/system.h>
-#include <pkgconf/hal.h>
-#include <cyg/hal/hal_arch.h>
-#include <cyg/hal/hal_intr.h>
-#ifdef CYGPKG_KERNEL
-#include <pkgconf/kernel.h>
-#include <cyg/kernel/sched.hxx>
-#include <cyg/kernel/thread.hxx>
-#include <cyg/kernel/thread.inl>
-#endif
-
-#ifndef STACKMON_PRINTF
-externC void diag_printf(const char *, ...);
-#define STACKMON_PRINTF diag_printf
-#endif
-
-// ------------------------------------------------------------------------
-// Utility function for actually counting a stack
-
-inline void cyg_test_size_a_stack( char *comment, char *format,
-                                   char *base, char *top )
-{
-    register char *p;
-    for ( p = base; p < top; p++ )
-        if ( *p )
-            break;
-    STACKMON_PRINTF( format, comment, top - p, top - base );
-}
-
-// ------------------------------------------------------------------------
-
-inline void cyg_test_dump_stack_stats( char *comment,
-                                       char *base, char *top )
-{
-    cyg_test_size_a_stack( comment, "%31s : stack used %5d size %5d\n",
-                           base, top );
-}
-
-// ------------------------------------------------------------------------
-
-inline void cyg_test_dump_thread_stack_stats( char *comment,
-                                              Cyg_Thread *p )
-{
-    char *base, *top;
-    base = (char *)p->get_stack_base();
-    top =   base + p->get_stack_size();
-    cyg_test_dump_stack_stats( comment, base, top );
-}
-
-// ------------------------------------------------------------------------
-// Print out size of idle thread stack usage since start-of-time.  Only
-// meaningful if there is a scheduler.
-
-inline void cyg_test_dump_idlethread_stack_stats( char *comment )
-{
-#ifdef CYGPKG_KERNEL
-    extern Cyg_Thread idle_thread;
-    // idle thread is not really a plain CygThread; danger.
-    char *ibase  = (char *)idle_thread.get_stack_base();
-    char *istack = ibase + idle_thread.get_stack_size();
-    cyg_test_size_a_stack( comment,
-              "%20s : Idlethread stack used %5d size %5d\n",
-              ibase, istack );
-#endif
-}
-
-// ------------------------------------------------------------------------
-// Print out size of interrupt stack usage since start-of-time or since it
-// was last cleared.  NB on some architectures and configurations, the
-// interrupt stack is the same as the bootup stack, so clear it in the
-// first first thread to execute.  Clearing it before scheduler start would
-// be fatal!
-
-inline void cyg_test_dump_interrupt_stack_stats( char *comment )
-{
-#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
-#ifdef HAL_INTERRUPT_STACK_BASE
-#ifdef HAL_INTERRUPT_STACK_TOP
-    extern char HAL_INTERRUPT_STACK_BASE[];
-    extern char HAL_INTERRUPT_STACK_TOP[];
-    cyg_test_size_a_stack( comment,
-              "%20s :  Interrupt stack used %5d size %5d\n",
-              HAL_INTERRUPT_STACK_BASE, HAL_INTERRUPT_STACK_TOP );
-#endif
-#endif
-#endif
-}
-
-// Clear interrupt stack to reset stats - only after sched has started.
-inline void cyg_test_clear_interrupt_stack( void )
-{
-#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
-#ifdef HAL_INTERRUPT_STACK_BASE
-#ifdef HAL_INTERRUPT_STACK_TOP
-    cyg_uint32  old_intr;
-    extern char HAL_INTERRUPT_STACK_BASE[];
-    extern char HAL_INTERRUPT_STACK_TOP[];
-    register char *p;
-    HAL_DISABLE_INTERRUPTS(old_intr);
-    for ( p = HAL_INTERRUPT_STACK_BASE; p < HAL_INTERRUPT_STACK_TOP; p++ )
-        *p = 0;                         // zero it for checking later
-    HAL_RESTORE_INTERRUPTS(old_intr);
-#endif
-#endif
-#endif
-}
-
-// ------------------------------------------------------------------------
-
-#endif // ifndef CYGONCE_KERNEL_TESTS_STACKMON_H
-
-// EOF stackmon.h
new file mode 100644
--- /dev/null
+++ b/packages/kernel/current/include/test/stackmon.h
@@ -0,0 +1,200 @@
+#ifndef CYGONCE_KERNEL_TEST_STACKMON_H
+#define CYGONCE_KERNEL_TEST_STACKMON_H
+
+/*=================================================================
+//
+//        stackmon.h
+//
+//        Auxiliary test header file
+//
+//==========================================================================
+//####COPYRIGHTBEGIN####
+//
+// -------------------------------------------
+// The contents of this file are subject to the Cygnus eCos Public License
+// Version 1.0 (the "License"); you may not use this file except in
+// compliance with the License.  You may obtain a copy of the License at
+// http://sourceware.cygnus.com/ecos
+// 
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the
+// License for the specific language governing rights and limitations under
+// the License.
+// 
+// The Original Code is eCos - Embedded Cygnus Operating System, released
+// September 30, 1998.
+// 
+// The Initial Developer of the Original Code is Cygnus.  Portions created
+// by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions.  All Rights Reserved.
+// -------------------------------------------
+//
+//####COPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     hmt
+// Contributors:  hmt
+// Date:          1999-05-20
+// Description:
+//     Defines some convenience functions for stack use output.
+// Note:
+//     The functions are defined for both C and C++ usage - with different
+//     argument types.
+//
+//####DESCRIPTIONEND####
+*/
+
+#include <pkgconf/system.h>
+#include <pkgconf/hal.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/hal_intr.h>
+#include <cyg/infra/cyg_type.h>
+#ifdef CYGPKG_KERNEL
+#include <pkgconf/kernel.h>
+# if defined(CYGFUN_KERNEL_API_C)
+#  include <cyg/kernel/kapi.h>
+# endif
+# if defined(__cplusplus)
+#  include <cyg/kernel/sched.hxx>
+#  include <cyg/kernel/thread.hxx>
+#  include <cyg/kernel/thread.inl>
+# endif
+#endif
+
+#ifndef STACKMON_PRINTF
+externC void diag_printf(const char *, ...);
+#define STACKMON_PRINTF diag_printf
+#endif
+
+// ------------------------------------------------------------------------
+// Utility function for actually counting a stack
+
+inline void cyg_test_size_a_stack( char *comment, char *format,
+                                   char *base, char *top )
+{
+    register char *p;
+    for ( p = base; p < top; p++ )
+        if ( *p )
+            break;
+    STACKMON_PRINTF( format, comment, top - p, top - base );
+}
+
+// ------------------------------------------------------------------------
+
+inline void cyg_test_dump_stack_stats( char *comment,
+                                       char *base, char *top )
+{
+    cyg_test_size_a_stack( comment, "%31s : stack used %5d size %5d\n",
+                           base, top );
+}
+
+// ------------------------------------------------------------------------
+
+#ifdef __cplusplus
+
+inline void cyg_test_dump_thread_stack_stats( char *comment,
+                                              Cyg_Thread *p )
+{
+#if defined(CYGPKG_KERNEL)
+    char *base, *top;
+    base = (char *)p->get_stack_base();
+    top =   base + p->get_stack_size();
+    cyg_test_dump_stack_stats( comment, base, top );
+#endif
+}
+
+#else // __cplusplus
+
+inline void cyg_test_dump_thread_stack_stats( char *comment,
+                                              cyg_handle_t p )
+{
+#if defined(CYGPKG_KERNEL) && defined(CYGFUN_KERNEL_API_C)
+    char *base, *top;
+    base = (char *) cyg_thread_get_stack_base( p );
+    top =   base + cyg_thread_get_stack_size( p );
+    cyg_test_dump_stack_stats( comment, base, top );
+#endif
+}
+
+#endif // __cplusplus
+
+// ------------------------------------------------------------------------
+// Print out size of idle thread stack usage since start-of-time.  Only
+// meaningful if there is a scheduler.
+
+#ifdef __cplusplus
+
+inline void cyg_test_dump_idlethread_stack_stats( char *comment )
+{
+#if defined(CYGPKG_KERNEL)
+    extern Cyg_Thread idle_thread;
+    // idle thread is not really a plain CygThread; danger.
+    char *ibase  = (char *)idle_thread.get_stack_base();
+    char *istack = ibase + idle_thread.get_stack_size();
+    cyg_test_size_a_stack( comment,
+              "%20s : Idlethread stack used %5d size %5d\n",
+              ibase, istack );
+#endif
+}
+
+#else // __cplusplus
+
+inline void cyg_test_dump_idlethread_stack_stats( char *comment )
+{
+#if defined(CYGPKG_KERNEL) && defined(CYGFUN_KERNEL_API_C)
+    cyg_handle_t idle_thread = cyg_thread_idle_thread();
+
+    char *ibase  = (char *)cyg_thread_get_stack_base( idle_thread );
+    char *istack = ibase + cyg_thread_get_stack_size( idle_thread );
+    cyg_test_size_a_stack( comment,
+              "%20s : Idlethread stack used %5d size %5d\n",
+              ibase, istack );
+#endif
+}
+
+#endif // __cplusplus
+
+// ------------------------------------------------------------------------
+// Print out size of interrupt stack usage since start-of-time or since it
+// was last cleared.  NB on some architectures and configurations, the
+// interrupt stack is the same as the bootup stack, so clear it in the
+// first first thread to execute.  Clearing it before scheduler start would
+// be fatal!
+
+#if defined(HAL_INTERRUPT_STACK_BASE) && defined(HAL_INTERRUPT_STACK_TOP)
+externC char HAL_INTERRUPT_STACK_BASE[];
+externC char HAL_INTERRUPT_STACK_TOP[];
+#endif
+
+inline void cyg_test_dump_interrupt_stack_stats( char *comment )
+{
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+#if defined(HAL_INTERRUPT_STACK_BASE) && defined(HAL_INTERRUPT_STACK_TOP)
+    cyg_test_size_a_stack( comment,
+              "%20s :  Interrupt stack used %5d size %5d\n",
+              HAL_INTERRUPT_STACK_BASE, HAL_INTERRUPT_STACK_TOP );
+#endif
+#endif
+}
+
+// Clear interrupt stack to reset stats - only after sched has started.
+
+inline void cyg_test_clear_interrupt_stack( void )
+{
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+#if defined(HAL_INTERRUPT_STACK_BASE) && defined(HAL_INTERRUPT_STACK_TOP)
+    cyg_uint32  old_intr;
+    register char *p;
+    HAL_DISABLE_INTERRUPTS(old_intr);
+    for ( p = HAL_INTERRUPT_STACK_BASE; p < HAL_INTERRUPT_STACK_TOP; p++ )
+        *p = 0;                         // zero it for checking later
+    HAL_RESTORE_INTERRUPTS(old_intr);
+#endif
+#endif
+}
+
+// ------------------------------------------------------------------------
+
+#endif // ifndef CYGONCE_KERNEL_TEST_STACKMON_H
+
+// EOF stackmon.h
--- a/packages/kernel/current/src/common/kapi.cxx
+++ b/packages/kernel/current/src/common/kapi.cxx
@@ -200,6 +200,13 @@ externC cyg_handle_t cyg_thread_self()
     return (cyg_handle_t)Cyg_Thread::self();
 }
 
+// idle thread is not really a plain CygThread; danger.
+externC cyg_handle_t cyg_thread_idle_thread()
+{
+    extern Cyg_Thread idle_thread;
+    return (cyg_handle_t)&idle_thread;
+}
+
 /* Priority manipulation */
 externC void cyg_thread_set_priority(
     cyg_handle_t thread, cyg_priority_t priority )
@@ -234,6 +241,18 @@ externC void cyg_thread_delay(cyg_tick_c
     Cyg_Thread::self()->delay(delay);
 }
 
+/* Stack information */
+externC cyg_addrword_t cyg_thread_get_stack_base(cyg_handle_t thread)
+{
+    return ((Cyg_Thread *)thread)->get_stack_base();
+}
+
+externC cyg_uint32 cyg_thread_get_stack_size(cyg_handle_t thread)
+{
+    return ((Cyg_Thread *)thread)->get_stack_size();
+}
+
+
 /*---------------------------------------------------------------------------*/
 /* Per-thread data                                                           */
 
--- a/packages/kernel/current/src/debug/dbg_gdb.cxx
+++ b/packages/kernel/current/src/debug/dbg_gdb.cxx
@@ -99,16 +99,23 @@ externC int dbg_thread_capabilities(stru
 
 static void dbg_make_threadref(Cyg_Thread *thread, threadref *ref )
 {
-    cyg_uint16 id = thread->get_unique_id();
+    if( thread == NULL )                     
+    {
+        ((unsigned long *)ref)[0] = 0;
+        ((unsigned long *)ref)[1] = 0;
+    }
+    else
+    {
+        cyg_uint16 id = thread->get_unique_id();
 
 #if USE_ID
-    ((unsigned long *)ref)[0] = (unsigned long)thread;
-    ((unsigned long *)ref)[1] = (unsigned long)swap32(id);
+        ((unsigned long *)ref)[0] = (unsigned long)thread;
+        ((unsigned long *)ref)[1] = (unsigned long)swap32(id);
 #else    
-    ((unsigned long *)ref)[1] = (unsigned long)thread;
-    ((unsigned long *)ref)[0] = (unsigned long)id;
+        ((unsigned long *)ref)[1] = (unsigned long)thread;
+        ((unsigned long *)ref)[0] = (unsigned long)id;
 #endif
-    
+    }
 }
 
 static Cyg_Thread *dbg_get_thread( threadref *ref)
--- a/packages/kernel/current/src/intr/intr.cxx
+++ b/packages/kernel/current/src/intr/intr.cxx
@@ -322,14 +322,15 @@ cyg_uint32
 Cyg_Interrupt::chain_isr(cyg_vector vector, CYG_ADDRWORD data)
 {
     Cyg_Interrupt *p = *(Cyg_Interrupt **)data;
-
+    register cyg_uint32 isr_ret = 0;
+    
     CYG_INSTRUMENT_INTR(CHAIN_ISR, vector, 0);
 
     while( p != NULL )
     {
         if( p->vector == vector )
         {
-            register cyg_uint32 isr_ret = p->isr(vector, p->data);
+            isr_ret = p->isr(vector, p->data);
 
             if( isr_ret & Cyg_Interrupt::CALL_DSR ) p->post_dsr();
 
@@ -339,6 +340,17 @@ Cyg_Interrupt::chain_isr(cyg_vector vect
         p = p->next;
     }
 
+#ifdef CYG_HAL_DEFAULT_ISR    
+    if( (isr_ret & Cyg_Interrupt::HANDLED) == 0 )
+    {
+        // If we finished the loop for some reason other than that an
+        // ISR has handled the interrupt, call any default ISR to either
+        // report the spurious interrupt, or do some other HAL level processing
+        // such as GDB interrupt detection etc.
+
+        CYG_HAL_DEFAULT_ISR( vector, NULL );
+    }
+#endif    
     return 0;
 }
 
--- a/packages/kernel/current/tests/except1.cxx
+++ b/packages/kernel/current/tests/except1.cxx
@@ -161,7 +161,7 @@ static void entry0( CYG_ADDRWORD data )
     CYG_TEST_FAIL_FINISH("Couldn't cause exception");
 }
 
-#ifdef CYG_HAL_TX39_JMR3904
+#ifdef CYG_HAL_MIPS_TX39_JMR3904
 
 externC cyg_VSR __default_exception_vsr;
 cyg_VSR *old_vsr;
--- a/packages/kernel/current/tests/intr0.cxx
+++ b/packages/kernel/current/tests/intr0.cxx
@@ -158,7 +158,7 @@ void intr0_main( void )
     CHECK( NULL != vsr0 );
 
     cyg_vector v1;
-#ifdef CYGPKG_HAL_TX39    
+#ifdef CYGPKG_HAL_MIPS_TX39    
     // This can be removed when PR 17831 is fixed
     if ( cyg_test_is_simulator )
         v1 = 12 % CYGNUM_HAL_ISR_COUNT;
--- a/packages/kernel/current/tests/kcache1.c
+++ b/packages/kernel/current/tests/kcache1.c
@@ -51,7 +51,11 @@
 // -------------------------------------------------------------------------
 // If the HAL does not supply this, we supply our own version
 
-#ifndef HAL_DCACHE_PURGE_ALL
+#ifdef HAL_DCACHE_SYNC
+
+# define HAL_DCACHE_PURGE_ALL() HAL_DCACHE_SYNC()
+
+#else
 
 static cyg_uint8 dca[HAL_DCACHE_SIZE + HAL_DCACHE_LINE_SIZE*2];
 
@@ -131,6 +135,26 @@ static void entry0( cyg_addrword_t data 
 {
     register CYG_INTERRUPT_STATE oldints;
     
+#ifdef HAL_CACHE_UNIFIED
+
+    HAL_DISABLE_INTERRUPTS(oldints);
+    HAL_DCACHE_PURGE_ALL();             // rely on above definition
+    HAL_UCACHE_INVALIDATE_ALL();
+    HAL_UCACHE_DISABLE();
+    HAL_RESTORE_INTERRUPTS(oldints);
+    CYG_TEST_INFO("Cache off");
+    time1();
+
+    HAL_DISABLE_INTERRUPTS(oldints);
+    HAL_DCACHE_PURGE_ALL();             // rely on above definition
+    HAL_UCACHE_INVALIDATE_ALL();
+    HAL_UCACHE_ENABLE();
+    HAL_RESTORE_INTERRUPTS(oldints);
+    CYG_TEST_INFO("Cache on");
+    time1();
+
+#else // HAL_CACHE_UNIFIED
+
     HAL_DISABLE_INTERRUPTS(oldints);
     HAL_DCACHE_PURGE_ALL();
     HAL_ICACHE_INVALIDATE_ALL();
@@ -182,6 +206,8 @@ static void entry0( cyg_addrword_t data 
     CYG_TEST_INFO("Dcache off Icache off");
     time1();
 
+#endif // HAL_CACHE_UNIFIED
+
     CYG_TEST_PASS_FINISH("End of test");
 }
 
--- a/packages/kernel/current/tests/kexcept1.c
+++ b/packages/kernel/current/tests/kexcept1.c
@@ -169,7 +169,7 @@ static void entry0( CYG_ADDRWORD data )
     CYG_TEST_FAIL_FINISH("Couldn't cause exception");
 }
 
-#ifdef CYG_HAL_TX39_JMR3904
+#ifdef CYG_HAL_MIPS_TX39_JMR3904
 
 extern void __default_exception_vsr(void);
 
--- a/packages/kernel/current/tests/kintr0.c
+++ b/packages/kernel/current/tests/kintr0.c
@@ -115,7 +115,7 @@ void kintr0_main( void )
 
     CYG_TEST_INIT();
  
-#ifdef CYGPKG_HAL_TX39    
+#ifdef CYGPKG_HAL_MIPS_TX39    
     // This can be removed when PR 17831 is fixed
     if ( cyg_test_is_simulator )
         v1 = 12 % CYGNUM_HAL_ISR_COUNT;
--- a/packages/kernel/current/tests/stress_threads.c
+++ b/packages/kernel/current/tests/stress_threads.c
@@ -69,13 +69,15 @@
 #include <math.h>
 #include <assert.h>
 
+#include <cyg/kernel/test/stackmon.h>
+
 #if defined(CYGFUN_KERNEL_THREADS_TIMER)
 #if defined(CYGPKG_LIBC_MALLOC)
 
 /* if TIME_LIMIT is defined, it represents the number of seconds this
    test should last; if it is undefined the test will go forever */
 #define DEATH_TIME_LIMIT 20
-/*  #undef DEATH_TIME_LIMIT */
+/* #undef DEATH_TIME_LIMIT */
 
 #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL)
 #define STACK_SIZE2 (8*1024 + CYGNUM_HAL_STACK_SIZE_TYPICAL)
@@ -133,6 +135,8 @@ int client_makes_request = 0;
 
 /* indicates that it's time to print out a report */
 int time_to_report = 0;
+ /* print status after a delay of this many secs. */
+int time_report_delay;
 
 /*** now application-specific variables ***/
 /* an array that stores whether the handler threads are in use */
@@ -140,15 +144,15 @@ int handler_thread_in_use[MAX_HANDLERS];
 
 /***** statistics-gathering variables *****/
 struct s_statistics {
-  /* store the number of times each handler has been invoked */
-  unsigned long handler_invocation_histogram[MAX_HANDLERS];
+    /* store the number of times each handler has been invoked */
+    unsigned long handler_invocation_histogram[MAX_HANDLERS];
 
-  /* store how many times malloc has been attempted and how many times
-     it has failed */
-  unsigned long malloc_tries, malloc_failures;
+    /* store how many times malloc has been attempted and how many times
+       it has failed */
+    unsigned long malloc_tries, malloc_failures;
 
-  /* how many threads have been created */
-  unsigned long thread_creations, thread_exits;
+    /* how many threads have been created */
+    unsigned long thread_creations, thread_exits;
 };
 
 struct s_statistics statistics;
@@ -171,7 +175,7 @@ void perform_stressful_tasks(void);
 void permute_array(char a[], int size, int seed);
 void setup_death_alarm(cyg_addrword_t data, cyg_handle_t *deathHp,
                        cyg_alarm *death_alarm_p, int *killed_p);
-void print_statistics(void);
+void print_statistics(int print_full);
 
 /* we need to declare the alarm handling function (which is defined
    below), so that we can pass it to cyg_alarm_initialize() */
@@ -254,10 +258,13 @@ void cyg_user_start(void)
                    (cyg_addrword_t) 4000,
                    &report_alarmH, &report_alarm);
   if (cyg_test_is_simulator) {
-    cyg_alarm_initialize(report_alarmH, cyg_current_time()+200, 200);
+      time_report_delay = 2;
   } else {
-    cyg_alarm_initialize(report_alarmH, cyg_current_time()+300, 4000);
+      time_report_delay = 30;
   }
+
+  cyg_alarm_initialize(report_alarmH, cyg_current_time()+200, 
+                       time_report_delay*100);
 }
 
 /* main_program() -- frees resources and prints status. */
@@ -312,13 +319,13 @@ void main_program(cyg_addrword_t data)
         // Print status if time.
         if (time_to_report) {
             time_to_report = 0;
-            print_statistics();
+            print_statistics(0);
         }
 
 #ifdef DEATH_TIME_LIMIT
         // Stop test if time.
         if (is_dead) {
-            print_statistics();
+            print_statistics(1);
             CYG_TEST_PASS_FINISH("Kernel thread stress test OK");
         }
 #endif /* DEATH_TIME_LIMIT */
@@ -522,6 +529,7 @@ void report_alarm_func(cyg_handle_t alar
     time_to_report = 1;
 }
 
+#ifdef DEATH_TIME_LIMIT
 /* this sets up death alarms. it gets the handle and alarm from the
    caller, since they must persist for the life of the alarm */
 void setup_death_alarm(cyg_addrword_t data, cyg_handle_t *deathHp,
@@ -553,6 +561,7 @@ void setup_death_alarm(cyg_addrword_t da
     cyg_alarm_initialize(*deathHp, cyg_current_time() + tick_delay, 0);
   }
 }
+#endif
 
 /* death_alarm_func() is the alarm handler that kills the current
    thread after a specified timeout. It does so by setting a flag the
@@ -583,20 +592,35 @@ void sc_thread_create(
                     stack_base, stack_size, handle, thread);
 }
 
-void print_statistics(void)
+
+void print_statistics(int print_full)
 {
   int i;
+  static int print_count = 0;
+
+  printf("State dump %d (time %02d.%02d.%02d)\n",
+         print_count,
+         print_count*time_report_delay / (60*60),   // hours
+         (print_count*time_report_delay / 60) % 60, // minutes
+         (print_count*time_report_delay ) % 60); // seconds
+  print_count++;
 
   cyg_mutex_lock(&statistics_print_lock); {
-    printf("Handler-invocations: ");
+    printf(" Handler-invocations: ");
     for (i = 0; i < MAX_HANDLERS; ++i) {
       printf("%4lu ", statistics.handler_invocation_histogram[i]);
     }
     printf("\n");
-    printf("malloc()-tries/failures: -- %7lu %7lu\n",
+    printf(" malloc()-tries/failures: -- %7lu %7lu\n",
            statistics.malloc_tries, statistics.malloc_failures);
-    printf("client_makes_request:       %d\n", client_makes_request);
+    printf(" client_makes_request:       %d\n", client_makes_request);
   } cyg_mutex_unlock(&statistics_print_lock);
+
+  // Add: Also occasionally dump individual threads' stack status.
+  if (0 == print_count % 5 || print_full) {
+      cyg_test_dump_interrupt_stack_stats( " Status" );
+      cyg_test_dump_idlethread_stack_stats( " Status" );
+  }
 }
 
 #else /* (CYGNUM_KERNEL_SCHED_PRIORITIES >=    */
--- a/packages/kernel/current/tests/tm_basic.cxx
+++ b/packages/kernel/current/tests/tm_basic.cxx
@@ -49,7 +49,7 @@
 
 #include <cyg/infra/testcase.h>
 
-#include <cyg/kernel/stackmon.hxx>
+#include <cyg/kernel/test/stackmon.h>
 
 // Define this to see the statistics with the first sample datum removed.
 // This can expose the effects of caches on the speed of operations.
--- a/packages/language/c/libc/current/ChangeLog
+++ b/packages/language/c/libc/current/ChangeLog
@@ -1,3 +1,14 @@
+1999-05-27  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/time/ctime.c: Fixed compiler warning.
+
+1999-05-25  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* tests/signal/signal2.c (main): 
+	Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS
+	HAL changes
+	Fix for PR 20116
+
 1999-04-30  Jesper Skov  <jskov@lassi.cygnus.co.uk>
         PR 19945/19946 workaround
 	* tests/signal/signal2.c: Disabled test 3 for PowerPC sim.
--- a/packages/language/c/libc/current/tests/signal/signal2.c
+++ b/packages/language/c/libc/current/tests/signal/signal2.c
@@ -232,7 +232,7 @@ main( int argc, char *argv[] )
 #if 0
 #elif defined(CYGPKG_HAL_MN10300)
     CYG_TEST_PASS("Test 3 not applicable to mn10300");
-#elif defined(CYGPKG_HAL_TX39)
+#elif defined(CYGPKG_HAL_MIPS_TX39)
     CYG_TEST_PASS("Test 3 not applicable to mips-tx39");
 #elif defined(CYGPKG_HAL_SPARCLITE)
     CYG_TEST_PASS("Test 3 not applicable to sparclite");
--- a/packages/language/c/libc/current/tests/time/ctime.c
+++ b/packages/language/c/libc/current/tests/time/ctime.c
@@ -78,7 +78,6 @@ test( CYG_ADDRWORD data )
 {
     time_t t;
     char *ret;
-    char ret2[26];
     
     // make this predictable - independent of the user option
     cyg_libc_time_setzoneoffsets(0, 3600);
@@ -109,9 +108,13 @@ test( CYG_ADDRWORD data )
 
     t = (time_t)915510061;
     
-    ret = ctime_r(&t, ret2);
-    CYG_TEST_PASS_FAIL(!my_strcmp(ret2, "Tue Jan 05 04:21:01 1999\n"),
-                       "ctime_r test #1");
+    {
+        char ret2[26];
+
+        ret = ctime_r(&t, ret2);
+        CYG_TEST_PASS_FAIL(!my_strcmp(ret2, "Tue Jan 05 04:21:01 1999\n"),
+                           "ctime_r test #1");
+    }
 #endif
 
     CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library "
--- a/packages/language/c/libm/current/ChangeLog
+++ b/packages/language/c/libm/current/ChangeLog
@@ -1,3 +1,8 @@
+1999-05-27  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/PKGconf.mak (SPECIAL_FLAGS): Add workaround flags for new
+	toolchains for all targets
+
 1999-05-19  Jonathan Larmour  <jlarmour@cygnus.co.uk>
 
 	* src/PKGconf.mak: Make below workaround be the other way around by
--- a/packages/language/c/libm/current/src/PKGconf.mak
+++ b/packages/language/c/libm/current/src/PKGconf.mak
@@ -71,113 +71,68 @@ OTHER_OBJS    :=
 OTHER_TARGETS :=
 OTHER_CLEAN   :=
 
-ifdef CYG_HAL_ARM
 # Work-around for PR 19698
-s_atan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_ceil.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_copysign.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_expm1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_fabs.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_finite.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_floor.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_frexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_isnan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_ldexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_rint.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_scalbn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_sin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_modf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_tanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_asinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_cbrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_erf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_ilogb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_log1p.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_logb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_nextafter.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_significand.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
 
-e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-w_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_acos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_acosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_asin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_atan2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_atanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_cosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_exp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_hypot.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_j0.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_j1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_jn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_lgamma_r.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_log.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_log10.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_pow.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_rem_pio2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_remainder.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_sinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_sqrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-k_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-k_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-endif
+SPECIAL_FLAGS := -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
 
 ifdef CYG_HAL_SPARCLITE
-# Work-around for PR 19698
-s_atan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_ceil.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_copysign.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_expm1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_fabs.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_finite.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_floor.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_frexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_isnan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_ldexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_rint.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_scalbn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_sin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_modf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_tanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_asinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_cbrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_erf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_ilogb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_log1p.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_logb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_nextafter.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-s_significand.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-
-e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-w_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_acos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_acosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_asin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_atan2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_atanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_cosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_exp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_hypot.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_j0.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_j1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_jn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_lgamma_r.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_log.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_log10.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_pow.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_rem_pio2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_remainder.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_sinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-e_sqrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-k_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
-k_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+SPECIAL_FLAGS += -fdelayed-branch
+endif
+ifdef CYG_HAL_MIPS_TX39
+SPECIAL_FLAGS += -fdelayed-branch
+endif
+ifdef CYG_HAL_POWERPC
+SPECIAL_FLAGS += -fdelayed-branch
 endif
 
+s_atan.c-CFLAGS += $(SPECIAL_FLAGS)
+s_ceil.c-CFLAGS += $(SPECIAL_FLAGS)
+s_copysign.c-CFLAGS += $(SPECIAL_FLAGS)
+s_cos.c-CFLAGS += $(SPECIAL_FLAGS)
+s_expm1.c-CFLAGS += $(SPECIAL_FLAGS)
+s_fabs.c-CFLAGS += $(SPECIAL_FLAGS)
+s_finite.c-CFLAGS += $(SPECIAL_FLAGS)
+s_floor.c-CFLAGS += $(SPECIAL_FLAGS)
+s_frexp.c-CFLAGS += $(SPECIAL_FLAGS)
+s_isnan.c-CFLAGS += $(SPECIAL_FLAGS)
+s_ldexp.c-CFLAGS += $(SPECIAL_FLAGS)
+s_rint.c-CFLAGS += $(SPECIAL_FLAGS)
+s_scalbn.c-CFLAGS += $(SPECIAL_FLAGS)
+s_sin.c-CFLAGS += $(SPECIAL_FLAGS)
+s_tan.c-CFLAGS += $(SPECIAL_FLAGS)
+s_modf.c-CFLAGS += $(SPECIAL_FLAGS)
+s_tanh.c-CFLAGS += $(SPECIAL_FLAGS)
+s_asinh.c-CFLAGS += $(SPECIAL_FLAGS)
+s_cbrt.c-CFLAGS += $(SPECIAL_FLAGS)
+s_erf.c-CFLAGS += $(SPECIAL_FLAGS)
+s_ilogb.c-CFLAGS += $(SPECIAL_FLAGS)
+s_log1p.c-CFLAGS += $(SPECIAL_FLAGS)
+s_logb.c-CFLAGS += $(SPECIAL_FLAGS)
+s_nextafter.c-CFLAGS += $(SPECIAL_FLAGS)
+s_significand.c-CFLAGS += $(SPECIAL_FLAGS)
+e_fmod.c-CFLAGS += $(SPECIAL_FLAGS)
+w_fmod.c-CFLAGS += $(SPECIAL_FLAGS)
+e_acos.c-CFLAGS += $(SPECIAL_FLAGS)
+e_acosh.c-CFLAGS += $(SPECIAL_FLAGS)
+e_asin.c-CFLAGS += $(SPECIAL_FLAGS)
+e_atan2.c-CFLAGS += $(SPECIAL_FLAGS)
+e_atanh.c-CFLAGS += $(SPECIAL_FLAGS)
+e_cosh.c-CFLAGS += $(SPECIAL_FLAGS)
+e_exp.c-CFLAGS += $(SPECIAL_FLAGS)
+e_fmod.c-CFLAGS += $(SPECIAL_FLAGS)
+e_hypot.c-CFLAGS += $(SPECIAL_FLAGS)
+e_j0.c-CFLAGS += $(SPECIAL_FLAGS)
+e_j1.c-CFLAGS += $(SPECIAL_FLAGS)
+e_jn.c-CFLAGS += $(SPECIAL_FLAGS)
+e_lgamma_r.c-CFLAGS += $(SPECIAL_FLAGS)
+e_log.c-CFLAGS += $(SPECIAL_FLAGS)
+e_log10.c-CFLAGS += $(SPECIAL_FLAGS)
+e_pow.c-CFLAGS += $(SPECIAL_FLAGS)
+e_rem_pio2.c-CFLAGS += $(SPECIAL_FLAGS)
+e_remainder.c-CFLAGS += $(SPECIAL_FLAGS)
+e_sinh.c-CFLAGS += $(SPECIAL_FLAGS)
+e_sqrt.c-CFLAGS += $(SPECIAL_FLAGS)
+k_cos.c-CFLAGS += $(SPECIAL_FLAGS)
+k_tan.c-CFLAGS += $(SPECIAL_FLAGS)
+
 include $(COMPONENT_REPOSITORY)/pkgconf/makrules.src
-