changeset 1908:e24eba6542a3

Modify signal handler return sequence to avoid problems with recent kernels. Clean up the clock configuration options.
author bartv
date Fri, 11 Mar 2005 19:04:06 +0000
parents 18ecc5da41f1
children 034abb7b549c
files packages/hal/synth/arch/current/ChangeLog packages/hal/synth/arch/current/cdl/hal_synth.cdl packages/hal/synth/arch/current/include/hal_io.h packages/hal/synth/arch/current/src/synth_intr.c
diffstat 4 files changed, 42 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/synth/arch/current/ChangeLog
+++ b/packages/hal/synth/arch/current/ChangeLog
@@ -1,3 +1,13 @@
+2005-03-11  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/synth_intr.c (synth_hardware_init): allow the platform to
+	customize the sigaction structures.
+
+	* include/hal_io.h: add more signal-related definitions
+
+	* cdl/hal_synth.cdl: change the clock calculations, so that users
+	only need to specify RTC_PERIOD
+
 2004-12-14  Alexander Neundorf <neundorf@kde.org>
 	    Andrew Lunn        <andrew.lunn@ascom.ch>
 
--- a/packages/hal/synth/arch/current/cdl/hal_synth.cdl
+++ b/packages/hal/synth/arch/current/cdl/hal_synth.cdl
@@ -81,25 +81,33 @@ cdl_package CYGPKG_HAL_SYNTH {
     cdl_component CYGNUM_HAL_RTC_CONSTANTS {
         display       "Real-time clock constants."
         description   "
-            These values are used in the usec field of the itimerval structure
-            when using getitimer/setitimer."
+            In the synthetic target the system clock is implemented using
+            Linux setitimer() and a SIGALRM signal. The PERIOD value is the
+            number of microseconds between signals, the usec field of an
+            itimerval structure. It should be a multiple of 10000 because
+            Linux will not generate signals at a finer grain than that.
+            The NUMERATOR and DENOMINATOR are derived from the period."
         flavor        none
     
+        cdl_option CYGNUM_HAL_RTC_PERIOD {
+            display       "Real-time clock period"
+            flavor        data
+            default_value 10000
+	    requires	  { 0 == (CYGNUM_HAL_RTC_PERIOD % 10000) }
+	    description "
+                This option corresponds to the number of microseconds between
+                clock interrupts."
+        }
         cdl_option CYGNUM_HAL_RTC_NUMERATOR {
             display       "Real-time clock numerator"
             flavor        data
-            default_value 1000000000
+            calculated    CYGNUM_HAL_RTC_DENOMINATOR * 1000 * CYGNUM_HAL_RTC_PERIOD
         }
         cdl_option CYGNUM_HAL_RTC_DENOMINATOR {
             display       "Real-time clock denominator"
             flavor        data
             default_value 100
         }
-        cdl_option CYGNUM_HAL_RTC_PERIOD {
-            display       "Real-time clock period"
-            flavor        data
-            default_value 10000
-        }
     }
     # What to do when idling
     cdl_option CYGIMP_HAL_IDLE_THREAD_SPIN {
--- a/packages/hal/synth/arch/current/include/hal_io.h
+++ b/packages/hal/synth/arch/current/include/hal_io.h
@@ -76,6 +76,8 @@
 
 #include <cyg/infra/cyg_type.h>
 
+#include <cyg/hal/var_io.h>     // Variant-specific definitions
+
 //-----------------------------------------------------------------------------
 // IO Register address.
 // This type is for recording the address of an IO register.
@@ -231,8 +233,10 @@ typedef volatile CYG_ADDRWORD HAL_IO_REG
 #define CYG_HAL_SYS_SA_NOCLDSTOP        0x00000001
 #define CYG_HAL_SYS_SA_NOCLDWAIT        0x00000002
 #define CYG_HAL_SYS_SA_SIGINFO          0x00000004
+#define CYG_HAL_SYS_SA_RESTORER         0x04000000
 #define CYG_HAL_SYS_SA_RESTART          0x10000000
 #define CYG_HAL_SYS_SA_NODEFER          0x40000000
+
 #define CYG_HAL_SYS_SIG_BLOCK           0
 #define CYG_HAL_SYS_SIG_UNBLOCK         1
 #define CYG_HAL_SYS_SIG_SETMASK         2
@@ -275,11 +279,17 @@ typedef struct cyg_hal_sys_sigset_t {
 #define CYG_HAL_SYS_SIGISMEMBER(_set_, _bit_)                                                   \
     (0 != ((_set_)->hal_sig_bits[CYG_HAL_SYS__SIGELT(_bit_ - 1)] & CYG_HAL_SYS__SIGMASK(_bit_ - 1)))
 
+// The kernel sigaction structure has changed, to allow for >32
+// signals. This is the old version, i.e. a struct old_sigaction, for
+// use with the sigaction() system call rather than rt_sigaction(). It
+// is preferred to the more modern version because gdb knows about
+// rt_sigaction() and will start intercepting signals, but it seems to
+// ignore sigaction().
 struct cyg_hal_sys_sigaction {
     void        (*hal_handler)(int);
     long        hal_mask;
     int         hal_flags;
-    void        (*hal_bogus)(int);
+    void        (*hal_restorer)(void);
 };
 
 // Time support.
--- a/packages/hal/synth/arch/current/src/synth_intr.c
+++ b/packages/hal/synth/arch/current/src/synth_intr.c
@@ -8,6 +8,7 @@
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2005 eCosCentric Ltd
 // Copyright (C) 2002 Bart Veer
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 //
@@ -1278,8 +1279,11 @@ synth_hardware_init(void)
     // instead of having the signal handler return immediately.
     action.hal_mask     = 0;
     action.hal_flags    = CYG_HAL_SYS_SA_NODEFER;
-    action.hal_bogus    = (void (*)(int)) 0;
     action.hal_handler  = &synth_alrm_sighandler;
+    action.hal_restorer = (void (*)(void)) 0;
+#ifdef CYG_HAL_SYS_SIGACTION_ADJUST
+    CYG_HAL_SYS_SIGACTION_ADJUST(CYG_HAL_SYS_SIGALRM, &action);
+#endif    
     if (0 != cyg_hal_sys_sigaction(CYG_HAL_SYS_SIGALRM, &action, (struct cyg_hal_sys_sigaction*) 0)) {
         CYG_FAIL("Failed to install signal handler for SIGALRM");
     }