changeset 2595:3ea2b2f69262

* src/thread-packets.c (threadmatch): Silence pointer signedness warning. (threadref_to_int): Ditto. * src/generic-stub.c (__mem2hex): Ditto. (__mem2hex_safe): Ditto. (__hex2mem): Ditto. (__hex2mem_safe): Ditto. * src/hal_if.c (delay_us): Ditto. * include/hal_stub.h (CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION): Instead of using a local variable to avoid compiler reordering when taking the address of a label, instead call an external function. (NB making the variable volatile isn't sufficient). * cdl/hal.cdl: Work around problem with current ARM EABI tools by using /dev/null as linker script. Should be safe with other tools. * src/hal_if.c (delay_us): use HAL_DELAY_US() rather than the fancy implementation if the port cannot provide HAL_CLOCK_READ() * cdl/common.cdl: Add CYGBLD_HAL_LINKER_GROUPED_LIBS to allow CDL setting of libraries used for GROUP() directive in linker script.
author jlarmour
date Tue, 11 Nov 2008 04:28:57 +0000
parents 4ca9d5dac8b0
children 7ad5f3aecbf6
files packages/hal/common/current/ChangeLog packages/hal/common/current/cdl/common.cdl packages/hal/common/current/cdl/hal.cdl packages/hal/common/current/include/hal_stub.h packages/hal/common/current/src/generic-stub.c packages/hal/common/current/src/hal_if.c packages/hal/common/current/src/thread-packets.c
diffstat 7 files changed, 105 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/common/current/ChangeLog
+++ b/packages/hal/common/current/ChangeLog
@@ -1,3 +1,28 @@
+2008-05-20  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* src/thread-packets.c (threadmatch): Silence pointer signedness
+	warning.
+	(threadref_to_int): Ditto.
+	* src/generic-stub.c (__mem2hex): Ditto.
+	(__mem2hex_safe): Ditto.
+	(__hex2mem): Ditto.
+	(__hex2mem_safe): Ditto.
+	* src/hal_if.c (delay_us): Ditto.
+	* include/hal_stub.h (CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION):
+	Instead of using a local variable to avoid compiler reordering
+	when taking the address of a label, instead call an external function.
+	(NB making the variable volatile isn't sufficient).
+
+2008-05-13  Chris Zimman  <czimman@bloomberg.com>
+
+	* cdl/hal.cdl: Work around problem with current ARM EABI tools by
+	using /dev/null as linker script. Should be safe with other tools.
+
+2007-11-27  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/hal_if.c (delay_us): use HAL_DELAY_US() rather than the
+	fancy implementation if the port cannot provide HAL_CLOCK_READ()
+
 2007-09-27  Grant Edwards <grante@visi.com>
 
         * include/hal_endian.h (SWAP16): Fix "return value" so
@@ -35,6 +60,12 @@ 2005-04-27  Enrico Piria <epiria@libero.
 	* src/hal_if.c Added missing declarations of tries when compiling
 	with CYGNUM_HAL_DEBUG_GDB_PROTOCOL_RETRIES != 0.
 
+2005-02-17  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* cdl/common.cdl: Add CYGBLD_HAL_LINKER_GROUPED_LIBS to allow
+	CDL setting of libraries used for GROUP() directive in linker
+	script.
+
 2004-11-20  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* tests/intr.c: Make the ISR call the DSR to make sure this works
--- a/packages/hal/common/current/cdl/common.cdl
+++ b/packages/hal/common/current/cdl/common.cdl
@@ -9,6 +9,7 @@
 ## -------------------------------------------
 ## This file is part of eCos, the Embedded Configurable Operating System.
 ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+## Copyright (C) 2005 eCosCentric Ltd.
 ##
 ## eCos is free software; you can redistribute it and/or modify it under
 ## the terms of the GNU General Public License as published by the Free
@@ -32,9 +33,6 @@
 ##
 ## This exception does not invalidate any other reasons why a work based on
 ## this file might be covered by the GNU General Public License.
-##
-## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
-## at http://sources.redhat.com/ecos/ecos-license/
 ## -------------------------------------------
 #####ECOSGPLCOPYRIGHTEND####
 # ====================================================================
@@ -150,3 +148,46 @@ cdl_component CYGDBG_HAL_DIAG_TO_DEBUG_C
     }
 }
 
+cdl_component CYGBLD_HAL_LINKER_GROUPED_LIBS {
+    display       "Grouped libraries for linking"
+    flavor        data
+    default_value CYGBLD_HAL_LINKER_GROUPED_LIBS_DEFAULT
+    requires      { is_substr(CYGBLD_HAL_LINKER_GROUPED_LIBS, "libtarget.a") }
+    description   "
+                This option provides a list of libraries used to satisfy
+                linker dependencies, but necessary for building eCos. It is passed
+                to a GROUP() directive in the linker script, which is analogous
+                to using the \"-(\" aka \"--start-group\", and \"-)\" aka
+                \"--end-group\" options on the linker command line.
+
+                It provides a similar function to adding \"-llibname\" to the
+                linker, but with the added feature that each library in the group
+                is scanned in turn for unresolved symbols, and this process is
+                repeated until there are no more unresolved symbols. This is important
+                for system libraries as there are often mutual dependencies.
+
+                This option should not be used for adding application specific
+                libraries. That should be done in the application's own makefile
+                or link line.
+        
+                Users wishing to use the GNU Compiler prior to GCC 3.0 will
+                need to remove libsupc++.a from this option.
+
+                Note that libtarget.a is always required to build eCos."
+
+    cdl_option CYGBLD_HAL_LINKER_GROUPED_LIBS_DEFAULT {
+        display       "Default setting"
+        flavor        data
+        default_value { "libtarget.a libgcc.a libsupc++.a" }
+        description   "
+                This option is intended to be used by other eCos packages (including
+                HAL packages) to provide a different default value for
+                CYGBLD_HAL_LINKER_GROUPED_LIBS.
+
+                This is separated into its own option to continue to
+                allow the user to make customisations to the grouped library
+                list."
+    }
+}
+
+# EOF common.cdl
--- a/packages/hal/common/current/cdl/hal.cdl
+++ b/packages/hal/common/current/cdl/hal.cdl
@@ -71,7 +71,7 @@ cdl_package CYGPKG_HAL {
 
     make -priority 250 {
         <PREFIX>/lib/extras.o: <PREFIX>/lib/libextras.a
-        $(CC) $(CFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive -o $@ $<
+        $(CC) $(CFLAGS) -nostdlib -Wl,-r -T /dev/null -Wl,--whole-archive -o $@ $<
     }   
 
 
--- a/packages/hal/common/current/include/hal_stub.h
+++ b/packages/hal/common/current/include/hal_stub.h
@@ -12,6 +12,7 @@
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2008 eCosCentric Limited.
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
@@ -262,6 +263,9 @@ extern volatile int cyg_hal_gdb_running_
 // Use these in hal_diag.c when about to write a whole $O packet to GDB.
 // NB they require __builtin_return_address() to work: if your platform
 // does not support this, use HAL_DISABLE_INTERRUPTS &c instead.
+// These are used to ensure the user's GDB cannot step through the critical
+// region, causing everything to go horribly wrong - particularly likely
+// with watching variables. Instead it will magically skip over the region.
 
 #if 1 // Can use the address of a label: this is more portable
 
@@ -282,9 +286,14 @@ do {                                    
 do {                                                                          \
     cyg_hal_gdb_remove_break( (target_register_t)&&cyg_hal_gdb_break_place ); \
     HAL_RESTORE_INTERRUPTS(_old_);                                            \
-    _old_ = 1; /* actually use the label as a label... */                     \
+    /* The following is solely to provide the label without the compiler      \
+     * optimising it away. By referencing an external function, it can't      \
+     * remove or reorder it. And because we have just called                  \
+     * cyg_hal_gdb_remove_break(), we know cyg_hal_gdb_break_is_set() will    \
+     * return 0.                                                              \
+     */                                                                       \
 cyg_hal_gdb_break_place:;                                                     \
-    if ( (_old_)-- > 0 ) /* ...or the compiler might move it! */              \
+    if ( cyg_hal_gdb_break_is_set() ) /* ...or the compiler might move it! */ \
         goto cyg_hal_gdb_break_place;                                         \
 } while ( 0 )
 #endif
--- a/packages/hal/common/current/src/generic-stub.c
+++ b/packages/hal/common/current/src/generic-stub.c
@@ -548,8 +548,8 @@ char *
      int count;
      int may_fault;
 {
-  hexMemDst      = (unsigned char *) buf;
-  hexMemSrc      = (unsigned char *) mem;
+  hexMemDst      = (char *) buf;
+  hexMemSrc      = (char *) mem;
   hexMemCount    = count;
   may_fault_mode = may_fault;
 #ifdef TARGET_HAS_HARVARD_MEMORY
@@ -577,8 +577,8 @@ char *
 static char *
 __mem2hex_safe (target_addr_t mem, char *buf, int count)
 {
-  hexMemDst      = (unsigned char *) buf;
-  hexMemSrc      = (unsigned char *) TARGET_ADDR_TO_PTR(mem);
+  hexMemDst      = (char *) buf;
+  hexMemSrc      = (char *) TARGET_ADDR_TO_PTR(mem);
   hexMemCount    = count;
   may_fault_mode = 1;
 #ifdef TARGET_HAS_HARVARD_MEMORY
@@ -665,8 +665,8 @@ char *
      int count;
      int may_fault;
 {
-  hexMemSrc      = (unsigned char *) buf;
-  hexMemDst      = (unsigned char *) mem;
+  hexMemSrc      = (char *) buf;
+  hexMemDst      = (char *) mem;
   hexMemCount    = count;
   may_fault_mode = may_fault;
 #ifdef TARGET_HAS_HARVARD_MEMORY
@@ -691,8 +691,8 @@ char *
 char *
 __hex2mem_safe (char *buf, target_addr_t mem, int count)
 {
-  hexMemSrc      = (unsigned char *) buf;
-  hexMemDst      = (unsigned char *) TARGET_ADDR_TO_PTR(mem);
+  hexMemSrc      = (char *) buf;
+  hexMemDst      = (char *) TARGET_ADDR_TO_PTR(mem);
   hexMemCount    = count;
   may_fault_mode = 1;
 #ifdef TARGET_HAS_HARVARD_MEMORY
--- a/packages/hal/common/current/src/hal_if.c
+++ b/packages/hal/common/current/src/hal_if.c
@@ -12,6 +12,7 @@
 // Copyright (C) 2002, 2003 Gary Thomas
 // Copyright (C) 2003 Nick Garnett <nickg@calivar.com>
 // Copyright (C) 2003 Jonathan Larmour <jlarmour@eCosCentric.com>
+// Copyright (C) 2004, 2005, 2006, 2008 eCosCentric Limited
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
@@ -274,9 +275,10 @@ static void
 delay_us(cyg_int32 usecs)
 {
     CYGARC_HAL_SAVE_GP();
-#ifdef CYGPKG_KERNEL
+#if defined(CYGPKG_KERNEL) && defined(HAL_CLOCK_READ)
     {
-        cyg_int32 start, elapsed, elapsed_usec;
+        cyg_uint32 start, elapsed_hal;
+        cyg_int32 elapsed, elapsed_usec;
         cyg_int32 slice;
         cyg_int32 usec_per_period = CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000;
         cyg_int32 ticks_per_usec = CYGNUM_KERNEL_COUNTERS_RTC_PERIOD/usec_per_period;
@@ -311,8 +313,8 @@ delay_us(cyg_int32 usecs)
     
             HAL_CLOCK_READ(&start);
             do {
-                HAL_CLOCK_READ(&elapsed);
-                elapsed = (elapsed - start); // counts up!
+                HAL_CLOCK_READ(&elapsed_hal);
+                elapsed = (elapsed_hal - start); // counts up!
                 if (elapsed < 0)
                     elapsed += CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
             } while (elapsed < slice);
--- a/packages/hal/common/current/src/thread-packets.c
+++ b/packages/hal/common/current/src/thread-packets.c
@@ -9,6 +9,7 @@
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2008 eCosCentric Limited.
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
@@ -403,7 +404,7 @@ static int threadref_to_int(threadref * 
   unsigned char * scan ;
   int i ;
   
-  scan = (char *) ref ;
+  scan = (unsigned char *) ref ;
   scan += 4 ;
   i = 4 ;
   while (i-- > 0) value = (value << 8) | ((*scan++) & 0xff) ;
@@ -428,8 +429,8 @@ int threadmatch(
 {
   unsigned char * srcp, * destp ;
   int i , result ;
-  srcp = (char *) src ;
-  destp = (char *) dest ;
+  srcp = (unsigned char *) src ;
+  destp = (unsigned char *) dest ;
   i = 8 ;
   result = 1 ;
   while (i-- > 0 ) result &= (*srcp++ == *destp++) ? 1 : 0 ;