Mercurial > flash_v2
changeset 94:4642a6d35749 ecos-sw-2000-06-02
Merge from eCos master repository on 2000-06-02-07:47:04-BST
line wrap: on
line diff
--- a/host/tools/ecostest/common/eCosTestDownloadFilter.cpp +++ b/host/tools/ecostest/common/eCosTestDownloadFilter.cpp @@ -53,7 +53,7 @@ #include "eCosStd.h" #include "eCosTrace.h" -#define DL_FILTER_VER "$Id: eCosTestDownloadFilter.cpp,v 1.9 2000/05/26 13:46:34 jlarmour Exp $" +#define DL_FILTER_VER "$Id: eCosTestDownloadFilter.cpp,v 1.10 2000/06/02 17:35:00 jlarmour Exp $" #include "eCosTestDownloadFilter.h" CeCosTestDownloadFilter::CeCosTestDownloadFilter():
--- a/host/tools/ecostest/common/eCosTestMonitorFilter.cpp +++ b/host/tools/ecostest/common/eCosTestMonitorFilter.cpp @@ -45,7 +45,7 @@ #include "eCosStd.h" -#define SER_FILTER_VER "$Id: eCosTestMonitorFilter.cpp,v 1.8 2000/05/26 13:46:34 jlarmour Exp $" +#define SER_FILTER_VER "$Id: eCosTestMonitorFilter.cpp,v 1.9 2000/06/02 17:35:00 jlarmour Exp $" #include "eCosTestMonitorFilter.h" CeCosTestMonitorFilter::CeCosTestMonitorFilter():
--- a/host/tools/ecostest/common/eCosTestSerialFilter.cpp +++ b/host/tools/ecostest/common/eCosTestSerialFilter.cpp @@ -51,7 +51,7 @@ #include "eCosStd.h" -#define SER_FILTER_VER "$Id: eCosTestSerialFilter.cpp,v 1.9 2000/05/26 13:46:34 jlarmour Exp $" +#define SER_FILTER_VER "$Id: eCosTestSerialFilter.cpp,v 1.10 2000/06/02 17:35:00 jlarmour Exp $" #include "eCosTestSerialFilter.h" #include "eCosThreadUtils.h"
--- a/packages/ChangeLog +++ b/packages/ChangeLog @@ -1,3 +1,19 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * ecos.db: Added CqREEK platform HAL (contributed by Haruki + Kashiwaya). + +2000-05-31 Jesper Skov <jskov@redhat.com> + + * ecos.db: Moved watchdog drivers around. Common code in + io/watchdog, low-level drivers in devs/watchdog/<arch>. + CYGPKG_DEVICES_WATCHDOG is now called CYGPKG_IO_WATCHDOG and + targets include individual hardware drivers. + +2000-05-26 Jesper Skov <jskov@redhat.com> + + * ecos.db: Added dallas 1742 wallclock driver package. + 2000-04-11 Hugo Tyson <hmt@cygnus.co.uk> * ecos.db: CYGPKG_IO_SERIAL should not be "hardware" now that it
--- a/packages/NEWS +++ b/packages/NEWS @@ -1,3 +1,8 @@ +* Hitachi SH3 CqREEK (cq7708) platform HAL support added + Contributed by Haruki Kashiwaya [Still untested, serial not imported] +* Watchdog reworked much like wallclock. + Common code and API in io/watchdog, simpler (smaller) low-level drivers in + devs/watchdog/<arch>. * IO serial driver The common serial driver has been extended with a configurable option for a non-blocking read/write mode. It has also been given some new callbacks
new file mode 100644 --- /dev/null +++ b/packages/devs/wallclock/dallas/ds1742/current/ChangeLog @@ -0,0 +1,29 @@ +2000-05-26 Jesper Skov <jskov@redhat.com> + * wallclock_ds1742.cdl: + Parent under IO/Wallclock. + +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### + +
new file mode 100644 --- /dev/null +++ b/packages/devs/wallclock/dallas/ds1742/current/ds1742.inl @@ -0,0 +1,174 @@ +//========================================================================== +// +// devs/wallclock/ds1742.inl +// +// Wallclock implementation for Dallas 1742 +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors: jskov +// Date: 2000-05-25 +// Purpose: Wallclock driver for Dallas 1742 +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef DS_BASE +# error "Need to know base of DS1742 RAM" +#endif + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/hal/hal_io.h> // IO macros + +// Offsets from DS_BASE +#define DS_SECONDS 0x7f9 // control bit! +#define DS_SECONDS_MASK 0x7f +#define DS_MINUTES 0x7fa +#define DS_HOUR 0x7fb +#define DS_DAY 0x7fc // control bits +#define DS_DAY_MASK 0x07 +#define DS_DATE 0x7fd +#define DS_MONTH 0x7fe +#define DS_YEAR 0x7ff +#define DS_CENTURY 0x7f8 // control bits! +#define DS_CENTURY_MASK 0x3f + +// Control bits +#define DS_SECONDS_OSC 0x80 // set to stop oscillator (power save) +#define DS_CENTURY_READ 0x40 // set during read +#define DS_CENTURY_WRITE 0x80 // set during write +#define DS_DAY_BF 0x80 // battery flag +#define DS_DAY_FT 0x40 // frequency test + + +// Make sure test modes are disabled and that clock is running. +static void +init_ds_hwclock(void) +{ + cyg_uint8 _tmp; + + // Enable clock + HAL_READ_UINT8(DS_BASE+DS_SECONDS, _tmp); + _tmp &= ~DS_SECONDS_OSC; + HAL_WRITE_UINT8(DS_BASE+DS_SECONDS, _tmp); + + // clear frequency test + HAL_READ_UINT8(DS_BASE+DS_DAY, _tmp); + _tmp &= ~DS_DAY_FT; + HAL_WRITE_UINT8(DS_BASE+DS_DAY, _tmp); +} + + +static void +set_ds_hwclock(cyg_uint32 year, cyg_uint32 month, cyg_uint32 mday, + cyg_uint32 hour, cyg_uint32 minute, cyg_uint32 second) +{ + cyg_uint8 _tmp; + // Init write operation + HAL_READ_UINT8(DS_BASE+DS_CENTURY, _tmp); + _tmp &= ~(DS_CENTURY_WRITE|DS_CENTURY_READ); + _tmp |= DS_CENTURY_WRITE; + HAL_WRITE_UINT8(DS_BASE+DS_CENTURY, _tmp); + + // Entries with control bits + HAL_READ_UINT8(DS_BASE+DS_CENTURY, _tmp); + _tmp &= ~DS_CENTURY_MASK; + _tmp |= TO_BCD(year/100) & DS_CENTURY_MASK; + HAL_WRITE_UINT8(DS_BASE+DS_CENTURY, _tmp); + + HAL_READ_UINT8(DS_BASE+DS_SECONDS, _tmp); + _tmp &= ~DS_SECONDS_MASK; + _tmp |= TO_BCD(second) & DS_SECONDS_MASK; + HAL_WRITE_UINT8(DS_BASE+DS_SECONDS, _tmp); + + HAL_READ_UINT8(DS_BASE+DS_DAY, _tmp); + _tmp &= ~DS_DAY_FT; // clear frequency test + HAL_WRITE_UINT8(DS_BASE+DS_DAY, _tmp); + + + // Dedicated entries + HAL_WRITE_UINT8(DS_BASE+DS_YEAR, TO_BCD(year % 100)); + HAL_WRITE_UINT8(DS_BASE+DS_MONTH, TO_BCD(month)); + HAL_WRITE_UINT8(DS_BASE+DS_DATE, TO_BCD(mday)); + HAL_WRITE_UINT8(DS_BASE+DS_HOUR, TO_BCD(hour)); + HAL_WRITE_UINT8(DS_BASE+DS_MINUTES, TO_BCD(minute)); + + // Enable clock + HAL_READ_UINT8(DS_BASE+DS_SECONDS, _tmp); + _tmp &= ~DS_SECONDS_OSC; + HAL_WRITE_UINT8(DS_BASE+DS_SECONDS, _tmp); + + // Finish write operation + HAL_READ_UINT8(DS_BASE+DS_CENTURY, _tmp); + _tmp &= ~(DS_CENTURY_WRITE|DS_CENTURY_READ); + HAL_WRITE_UINT8(DS_BASE+DS_CENTURY, _tmp); +} + +static void +get_ds_hwclock(cyg_uint32* year, cyg_uint32* month, cyg_uint32* mday, + cyg_uint32* hour, cyg_uint32* minute, cyg_uint32* second) +{ + cyg_uint8 _tmp; + + // Init read operation + HAL_READ_UINT8(DS_BASE+DS_CENTURY, _tmp); + _tmp &= ~(DS_CENTURY_WRITE|DS_CENTURY_READ); + _tmp |= DS_CENTURY_READ; + HAL_WRITE_UINT8(DS_BASE+DS_CENTURY, _tmp); + + // Entries with control bits + HAL_READ_UINT8(DS_BASE+DS_CENTURY, _tmp); + _tmp &= DS_CENTURY_MASK; + *year = 100*TO_DEC(_tmp); + + HAL_READ_UINT8(DS_BASE+DS_SECONDS, _tmp); + _tmp &= DS_SECONDS_MASK; + *second = TO_DEC(_tmp); + + // Dedicated entries + HAL_READ_UINT8(DS_BASE+DS_YEAR, _tmp); + *year += TO_DEC(_tmp); + HAL_READ_UINT8(DS_BASE+DS_MONTH, _tmp); + *month = TO_DEC(_tmp); + HAL_READ_UINT8(DS_BASE+DS_DATE, _tmp); + *mday = TO_DEC(_tmp); + HAL_READ_UINT8(DS_BASE+DS_HOUR, _tmp); + *hour = TO_DEC(_tmp); + HAL_READ_UINT8(DS_BASE+DS_MINUTES, _tmp); + *minute = TO_DEC(_tmp); + + // Finish read operation + HAL_READ_UINT8(DS_BASE+DS_CENTURY, _tmp); + _tmp &= ~(DS_CENTURY_WRITE|DS_CENTURY_READ); + HAL_WRITE_UINT8(DS_BASE+DS_CENTURY, _tmp); +} + +//----------------------------------------------------------------------------- +// End of devs/wallclock/ds1742.inl
new file mode 100644 --- /dev/null +++ b/packages/devs/wallclock/dallas/ds1742/current/wallclock_ds1742.cdl @@ -0,0 +1,51 @@ +# ==================================================================== +# +# wallclock_ds1742.cdl +# +# eCos configuration data for Dallas 1742 +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Contributors: jskov +# Date: 2000-05-26 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS1742 { + parent CYGPKG_IO_WALLCLOCK + active_if CYGPKG_IO_WALLCLOCK + display "Wallclock device driver for Dallas 1742" + include_dir cyg/io/wallclock + include_files ds1742.inl + description " + This package provides a file with init, get and set functions + for the Dallas 1742 clock part." +}
--- a/packages/devs/wallclock/sh3/current/ChangeLog +++ b/packages/devs/wallclock/sh3/current/ChangeLog @@ -1,3 +1,10 @@ +2000-05-26 Jesper Skov <jskov@redhat.com> + + * cdl/wallclock_sh3.cdl: CYGSEM_WALLCLOCK_SET_GET_MODE moved to IO + package. + + * src/wallclock_sh3.cxx: Get helpers from new file. + 2000-04-06 Jesper Skov <jskov@redhat.com> * cdl/wallclock_sh3.cdl: Only active when wallclock is.
--- a/packages/devs/wallclock/sh3/current/cdl/wallclock_sh3.cdl +++ b/packages/devs/wallclock/sh3/current/cdl/wallclock_sh3.cdl @@ -47,9 +47,6 @@ cdl_package CYGPKG_DEVICES_WALLCLOCK_SH3 requires CYGPKG_HAL_SH hardware compile wallclock_sh3.cxx - define_proc { - puts $::cdl_header "#undef CYGSEM_WALLCLOCK_SET_GET_MODE" - } implements CYGINT_WALLCLOCK_HW_IMPLEMENTATIONS active_if CYGIMP_WALLCLOCK_HARDWARE
--- a/packages/devs/wallclock/sh3/current/src/wallclock_sh3.cxx +++ b/packages/devs/wallclock/sh3/current/src/wallclock_sh3.cxx @@ -43,15 +43,14 @@ #include <pkgconf/kernel.h> // Kernel config #include <pkgconf/wallclock.h> // Wallclock device config +#include <cyg/hal/hal_io.h> // IO macros #include <cyg/infra/cyg_type.h> // Common type definitions and support -#define __CYGBLD_DRIVER_PRIVATE #include <cyg/io/wallclock.hxx> // The WallClock API +#include <cyg/io/wallclock/wallclock.inl> // Helpers #include <cyg/hal/sh_regs.h> // RTC register definitions -#include <cyg/hal/hal_io.h> // IO macros - #include <cyg/infra/diag.h> // For debugging
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/arm/aeb/current/ChangeLog @@ -0,0 +1,35 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * cdl/watchdog_aeb.cdl: + * src/watchdog_aeb.cxx: + Driver moved to devs/watchdog/arm/aeb. Stripped out + unrelated ChangeLog entries. + +1999-09-07 Jesper Skov <jskov@cygnus.co.uk> + + * src/aeb1.cxx: [added] + Added watchdog driver for AEB-1 board. + +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND####
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/arm/aeb/current/cdl/watchdog_aeb.cdl @@ -0,0 +1,93 @@ +# ==================================================================== +# +# watchdog_aeb.cdl +# +# eCos watchdog for ARM/AEB driver configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Contributors: jskov +# Date: 2000-05-31 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVICES_WATCHDOG_ARM_AEB { + parent CYGPKG_IO_WATCHDOG + active_if CYGPKG_IO_WATCHDOG + display "AEB watchdog driver" + requires CYGPKG_HAL_ARM_AEB + requires CYGPKG_KERNEL + hardware + compile watchdog_aeb.cxx + implements CYGINT_WATCHDOG_HW_IMPLEMENTATIONS + implements CYGINT_WATCHDOG_RESETS_ON_TIMEOUT + active_if CYGIMP_WATCHDOG_HARDWARE + + cdl_option CYGIMP_WATCHDOG_HARDWARE { + parent CYGPKG_IO_WATCHDOG_IMPLEMENTATION + display "Hardware watchdog" + default_value 1 + implements CYGINT_WATCHDOG_IMPLEMENTATIONS + } + + cdl_component CYGPKG_DEVICES_WATCHDOG_ARM_AEB_OPTIONS { + display "AEB watchdog build options" + flavor none + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_DEVICES_WATCHDOG_ARM_AEB_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_DEVICES_WATCHDOG_ARM_AEB_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are removed from + the set of global flags if present." + } + + } +}
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/arm/aeb/current/src/watchdog_aeb.cxx @@ -0,0 +1,152 @@ +//========================================================================== +// +// devs/watchdog/arm/aeb/watchdog_aeb.cxx +// +// Watchdog implementation for ARM AEB1 board (SHARP LH77790 CPU) +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors: jskov +// Date: 1999-09-01 +// Purpose: Watchdog class implementation +// Description: Contains an implementation of the Watchdog class for use +// with the SHARP LH77790 watchdog timer. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> // system configuration file +#include <pkgconf/watchdog.h> // configuration for this package +#include <pkgconf/kernel.h> // kernel config + +#include <cyg/infra/cyg_trac.h> // tracing macros +#include <cyg/kernel/instrmnt.h> // instrumentation + +#include <cyg/hal/hal_io.h> // IO register access + +#include <cyg/io/watchdog.hxx> // watchdog API + +// ------------------------------------------------------------------------- +// Register definitions +#define CYGARC_REG_WATCHDOG_BASE 0xFFFFAC00 +#define CYGARC_REG_WATCHDOG_WDCTLR (CYGARC_REG_WATCHDOG_BASE+0x30) +#define CYGARC_REG_WATCHDOG_WDCNTR (CYGARC_REG_WATCHDOG_BASE+0x34) + +// Control register bits +#define CYGARC_REG_WATCHDOG_WDCTLR_EN 0x01 // enable +#define CYGARC_REG_WATCHDOG_WDCTLR_RSP_NMF 0x00 // non-maskable fiq +#define CYGARC_REG_WATCHDOG_WDCTLR_RSP_ER 0x04 // external reset +#define CYGARC_REG_WATCHDOG_WDCTLR_RSP_SR 0x06 // system reset +#define CYGARC_REG_WATCHDOG_WDCTLR_FRZ 0x08 // lock enable bit +#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_MASK 0x70 // time out period + +#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_17 0x00 // 2^17 +#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_17_P 5242880 // = 5.2ms + +#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_25 0x40 // 2^25 +#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_25_P 1342177300 // = 1.3421773s + + +// ------------------------------------------------------------------------- +// Constructor + +void +Cyg_Watchdog::init_hw(void) +{ + CYG_REPORT_FUNCTION(); + + // No HW init. + + resolution = CYGARC_REG_WATCHDOG_WDCTLR_TOP_25_P; + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Start the watchdog running. + +void +Cyg_Watchdog::start() +{ + CYG_REPORT_FUNCTION(); + + // Clear the watchdog counter. + HAL_WRITE_UINT32(CYGARC_REG_WATCHDOG_WDCNTR, 0); + + // Enable the watchdog (and lock/FRZ it). + HAL_WRITE_UINT8(CYGARC_REG_WATCHDOG_WDCTLR, + (CYGARC_REG_WATCHDOG_WDCTLR_TOP_25 + | CYGARC_REG_WATCHDOG_WDCTLR_FRZ + | CYGARC_REG_WATCHDOG_WDCTLR_RSP_SR + | CYGARC_REG_WATCHDOG_WDCTLR_EN)); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Reset watchdog timer. This needs to be called regularly to prevent +// the watchdog firing. + +void +Cyg_Watchdog::reset() +{ + CYG_REPORT_FUNCTION(); + + HAL_WRITE_UINT32(CYGARC_REG_WATCHDOG_WDCNTR, 0); + + CYG_REPORT_RETURN(); +} + +#if 0 +// ------------------------------------------------------------------------- +// Action which will do a board reset. Application can register this +// action to get a board reset on watchdog timeout. + +void +Cyg_Watchdog::reset_action(void) +{ + CYG_REPORT_FUNCTION(); + + // Clear the watchdog counter. + HAL_WRITE_UINT32(CYGARC_REG_WATCHDOG_WDCNTR, 0); + + // Enable the watchdog with the smallest timeout. + HAL_WRITE_UINT8(CYGARC_REG_WATCHDOG_WDCTLR, + (CYGARC_REG_WATCHDOG_WDCTLR_TOP_17 + | CYGARC_REG_WATCHDOG_WDCTLR_FRZ + | CYGARC_REG_WATCHDOG_WDCTLR_RSP_SR + | CYGARC_REG_WATCHDOG_WDCTLR_EN)); + + CYG_REPORT_RETURN(); +} +#endif + +// ------------------------------------------------------------------------- +// EOF watchdog_aeb.cxx
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/arm/ebsa285/current/ChangeLog @@ -0,0 +1,35 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * cdl/watchdog_ebsa285.cdl: + * src/watchdog_ebsa285.cxx: + Driver moved to devs/watchdog/arm/ebsa285. Stripped out + unrelated ChangeLog entries. + +1999-08-27 Jesper Skov <jskov@cygnus.co.uk> + + * src/ebsa285.cxx: + Added watchdog device for 21285. + +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND####
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/arm/ebsa285/current/cdl/watchdog_ebsa285.cdl @@ -0,0 +1,93 @@ +# ==================================================================== +# +# watchdog_ebsa285.cdl +# +# eCos watchdog for ARM/EBSA285 driver configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Contributors: jskov +# Date: 2000-05-31 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285 { + parent CYGPKG_IO_WATCHDOG + active_if CYGPKG_IO_WATCHDOG + display "EBSA285 watchdog driver" + requires CYGPKG_HAL_ARM_EBSA285 + requires CYGPKG_KERNEL + hardware + compile watchdog_ebsa285.cxx + implements CYGINT_WATCHDOG_HW_IMPLEMENTATIONS + implements CYGINT_WATCHDOG_RESETS_ON_TIMEOUT + active_if CYGIMP_WATCHDOG_HARDWARE + + cdl_option CYGIMP_WATCHDOG_HARDWARE { + parent CYGPKG_IO_WATCHDOG_IMPLEMENTATION + display "Hardware watchdog" + default_value 1 + implements CYGINT_WATCHDOG_IMPLEMENTATIONS + } + + cdl_component CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285_OPTIONS { + display "EBSA285 watchdog build options" + flavor none + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are removed from + the set of global flags if present." + } + + } +}
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/arm/ebsa285/current/src/watchdog_ebsa285.cxx @@ -0,0 +1,142 @@ +//========================================================================== +// +// watchdog/ebsa285.cxx +// +// Watchdog implementation for Intel EBSA-285 StronARM board +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov (based on the MN10300 watchdog code by nickg) +// Contributors: jskov, nickg +// Date: 1999-08-26 +// Purpose: Watchdog class implementation +// Description: Contains an implementation of the Watchdog class for use +// with the EBSA285/21285 hardware watchdog timer. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> // system configuration file +#include <pkgconf/watchdog.h> // configuration for this package +#include <pkgconf/kernel.h> // kernel config + +#include <cyg/infra/cyg_trac.h> // tracing macros +#include <cyg/kernel/instrmnt.h> // instrumentation + +#include <cyg/hal/hal_io.h> // IO register access + +#include <cyg/io/watchdog.hxx> // watchdog API + +// ------------------------------------------------------------------------- +// 21285 watchdog works by letting timer4 run; if it ever underflows, +// it resets the system. +// Timer 4 is set to run at fclk_in/16 = 50MHz/16 = 3.125MHz +// The timer register is 24 bits, so it can easily hold a value that +// gives a 1s timeout. +#define WATCHDOG_TIMER_TICKS 3125000 +#define WATCHDOG_RESOLUTION (1000000000) + +// ------------------------------------------------------------------------- +// Constructor + +void +Cyg_Watchdog::init_hw(void) +{ + CYG_REPORT_FUNCTION(); + + // HW doesn't need init + + resolution = WATCHDOG_RESOLUTION; + + CYG_REPORT_RETURN(); +} + + + +// ------------------------------------------------------------------------- +// Start the watchdog running. + +void +Cyg_Watchdog::start(void) +{ + CYG_REPORT_FUNCTION(); + + // Init the watchdog timer. + HAL_WRITE_UINT32(SA110_TIMER4_LOAD, WATCHDOG_TIMER_TICKS); + HAL_WRITE_UINT32(SA110_TIMER4_CLEAR, 0); + HAL_WRITE_UINT32(SA110_TIMER4_CONTROL, + SA110_TIMER_CONTROL_ENABLE|SA110_TIMER_CONTROL_SCALE_16); + // Enable the watchdog. + cyg_uint32 ctrl; + HAL_READ_UINT32(SA110_CONTROL, ctrl); + ctrl |= SA110_CONTROL_WATCHDOG; + HAL_WRITE_UINT32(SA110_CONTROL, ctrl); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Reset watchdog timer. This needs to be called regularly to prevent +// the watchdog firing. + +void +Cyg_Watchdog::reset() +{ + CYG_REPORT_FUNCTION(); + + HAL_WRITE_UINT32(SA110_TIMER4_LOAD, WATCHDOG_TIMER_TICKS); + + CYG_REPORT_RETURN(); +} + +#if 0 +// ------------------------------------------------------------------------- +// Trigger the watchdog as if the timer had expired. + +void +Cyg_Watchdog::reset_action(void) +{ + CYG_REPORT_FUNCTION(); + + // Init the watchdog timer. + HAL_WRITE_UINT32(SA110_TIMER4_LOAD, 1); + HAL_WRITE_UINT32(SA110_TIMER4_CONTROL, SA110_TIMER_CONTROL_ENABLE); + // Enable the watchdog. + cyg_uint32 ctrl; + HAL_READ_UINT32(SA110_CONTROL, ctrl); + ctrl |= SA110_CONTROL_WATCHDOG; + HAL_WRITE_UINT32(SA110_CONTROL, ctrl); + + CYG_REPORT_RETURN(); +} +#endif + + +// ------------------------------------------------------------------------- +// EOF watchdog_ebsa285.cxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/ChangeLog +++ /dev/null @@ -1,255 +0,0 @@ -2000-01-31 Simon FitzMaurice <sdf@cygnus.co.uk> - * cdl/watchdog.cdl: - - Adjust help URLs in line with new doc layout. - -2000-01-28 Simon FitzMaurice <sdf@cygnus.co.uk> - * cdl/watchdog.cdl: - - Adjust help URLs in line with new doc layout. - -2000-01-19 Hugo Tyson <hmt@cygnus.co.uk> - - * cdl/*.cdl: Add descriptions to a number of options &c which were - lacking same, also tidied up other typos as noticed en passant. - -1999-11-03 John Dallaway <jld@cygnus.co.uk> - - * cdl/watchdog.cdl: Define build options. - -1999-09-09 Jonathan Larmour <jlarmour@cygnus.co.uk> - - * include/pkgconf/watchdog.h: Rename CYGPKG_HAL_MN10300_SIM to - CYGPKG_HAL_MN10300_AM31_SIM - -1999-09-07 Jesper Skov <jskov@cygnus.co.uk> - - * include/pkgconf/watchdog.h: - * src/aeb1.cxx: [added] - * src/PKGconf.mak: - * tests/PKGconf.mak: - Added watchdog driver for AEB-1 board. - -1999-09-07 Jesper Skov <jskov@cygnus.co.uk> - PRs 20427, 20428, 20432 - * tests/PKGconf.mak (TESTS): Clear on targets that reset the - board. - -1999-09-01 Jesper Skov <jskov@cygnus.co.uk> - * cdl/watchdog.cdl: - * include/pkgconf/watchdog.h: - * src/PKGconf.mak: - * src/sh.cxx: - Added watchdog driver for SH. - -1999-08-27 Jesper Skov <jskov@cygnus.co.uk> - * include/pkgconf/watchdog.h: - * src/PKGconf.mak: - * src/ebsa285.cxx: - Added watchdog device for 21285. - - * tests/watchdog_reset.cxx: - * tests/PKGconf.mak (TESTS): - Added test for watchdog devices that reset the board. - -1999-08-24 Nick Garnett <nickg@cygnus.co.uk> - - * src/mn10300.cxx: Turn watchdog off in Cyg_Watchdog::trigger() to - prevent it repeating. - -1999-08-18 Nick Garnett <nickg@cygnus.co.uk> - - * include/pkgconf/watchdog.h: Made test for use of a non-emulated - watchdog more generic for MN10300 targets. - - * src/emulate.cxx: - * include/watchdog.hxx (class Cyg_Watchdog): - Added get_resolution() to return maximum time, in nanoseconds, - between calls to reset(). - - * tests/watchdog.cxx: - Modified to use the value returned from get_resolution() to - control the timing of reset() calls. - - * src/mn10300.cxx: - Added support for AM33 variant. Since the AM33 can only provide a - maximum watchdog cycle time of 621ms, this has motiviated the - addition of the get_resolution() call described above. -1999-07-14 Jesper Skov <jskov@cygnus.co.uk> - - * src/mn10300.cxx: - * src/emulate.cxx: - Include pkgconf/kernel.h. - -1999-04-21 Gary Thomas <gthomas@cygnus.co.uk> - - * tests/watchdog.cxx: The 'keep alive' message was interfering - with the watchdog measurement. Some rearrangement fixes this. - -1999-04-20 Jonathan Larmour <jlarmour@cygnus.co.uk> - - * tests/watchdog.cxx: - Restrict number of loops, and number of seconds per loop when we - detect we are in a simulator. Do this instead of changing the - value of one_sec in the simulator, since this invalidates the test - somewhat. - Output occasional messages to reassure the user that the test is - still running. - Fix for PR 19865 - -1999-04-14 Jesper Skov <jskov@cygnus.co.uk> - - * tests/watchdog.cxx (cyg_start): Added workaround for PR 17974. - -1999-04-12 John Dallaway <jld@cygnus.co.uk> - - * include/pkgconf/watchdog.h: Add cdl_package doc attribute. - -1999-04-08 Gary Thomas <gthomas@cygnus.co.uk> - - * tests/watchdog.cxx: PR 19773 - Loop over first test for better - coverage. Print some additional messages, especially if failure - detected. Reset watchdog after installing handler. - (watchdog_thread): Capture fail time before printing message. - -1999-04-07 Jesper Skov <jskov@cygnus.co.uk> - PR 19667 - * tests/watchdog.cxx (cyg_start): - Changed to use the new Cyg_Thread constructor. - -1999-03-22 Hugo Tyson <hmt@cygnus.co.uk> - - * tests/watchdog.cxx: - Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of - CYGNUM_HAL_MINIMUM_STACK_SIZE. - -1999-03-12 Hugo Tyson <hmt@cygnus.co.uk> - - * tests/watchdog.cxx: - Deal with CYGNUM_HAL_MINIMUM_STACK_SIZE requirement. - -1999-03-04 Gary Thomas <gthomas@cygnus.co.uk> - - * include/pkgconf/watchdog.h: Make package stand-alone (no "DEVICES") - -1999-02-20 Jonathan Larmour <jlarmour@cygnus.co.uk> - - * src/mn10300.cxx: - Change CYG_VECTOR_WATCHDOG to CYGNUM_HAL_INTERRUPT_WATCHDOG in line - with HAL changes. - General QA improvements - -1999-02-03 Jesper Skov <jskov@cygnus.co.uk> - PR 19034 - * tests/watchdog.cxx: Reduced run-time on SIM. - -1998-12-17 Jesper Skov <jskov@cygnus.co.uk> - - * tests/watchdog.cxx: Do NOP test if kernel RTC disabled. - -1998-10-23 Jesper Skov <jskov@cygnus.co.uk> - - * tests/watchdog.cxx (cyg_start): Reduce test time on TX39 SIM. - - * include/pkgconf/watchdog.h: Use emulatation code for MN10300 - SIM. - -Tue Oct 20 15:52:46 1998 Jonathan Larmour <jlarmour@cygnus.co.uk> - - * src/mn10300.cxx: - Include <pkgconf/watchdog.h> so that we get CYGIMP_WATCHDOG_EMULATE - defined appropriately - - * src/PKGconf.mak: - Remove unnecessary override of PKGCONF_CXXFLAGS - -1998-09-26 Bart Veer <bartv@cygnus.co.uk> - - * include/pkgconf/watchdog.h: - PR17501: When using the emulation there is a requirement on the - kernel clock. This has been added to the configuration data. The - mn10300 hardware implementation does not have this requirement, - but there is no easy way to express this at present. - -1998-09-12 Bart Veer <bartv@cygnus.co.uk> - - * include/pkgconf/watchdog.h: - Added missing descriptions (PR 17184) - -1998-09-02 Bart Veer <bartv@cygnus.co.uk> - - * include/pkgconf/watchdog.h: - Added minimal configuration data. - -1998-09-01 Nick Garnett <nickg@cygnus.co.uk> - - * src/mn10300.cxx: - Added include for <cyg/kernel/sched.inl>, for scheduler lock and - unlock functions. - - * src/PKGconf.mak: - Added mn10300.cxx to COMPILE for mn10300. - - * include/pkgconf/watchdog.h: - Default to using real hardware on MN10300. - -Fri Aug 28 09:42:26 1998 Jonathan Larmour <jlarmour@cygnus.co.uk> - - * tests/watchdog.cxx: - Rename int main(argc, argv) to void cyg_start( void ) under the - new entry point system. Therefore also remove return code. - -Tue Aug 18 16:51:24 1998 Jonathan Larmour <jlarmour@cygnus.co.uk> - - * tests/watchdog.cxx: - Move inclusion of thread.inl to before sched.hxx to prevent inline - warnings - -1998-08-14 Nick Garnett <nickg@cygnus.co.uk> - - * src/emulate.cxx: - Added include for cyg/kernel/sched.inl. - -1998-07-31 Nick Garnett <nickg@cygnus.co.uk> - - * src/PKGconf.mak: - Added mn10300.cxx to COMPILE list. - - * src/mn10300.cxx: - Completed implementation using MN10300 watchdog timer. - - * include/watchdog.hxx: - Renamed 'register' functions to 'install'. Added install() and - uninstall() to Cyg_Watchdog_Action class. - - * include/pkgconf/watchdog.h: - Added this file to contain watchdog config options. - -1998-07-29 Nick Garnett <nickg@cygnus.co.uk> - - * include/watchdog.hxx, src/emulate.cxx: - Created initial versions of watchdog device. - -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND####
deleted file mode 100644 --- a/packages/devs/watchdog/current/cdl/watchdog.cdl +++ /dev/null @@ -1,115 +0,0 @@ -# ==================================================================== -# -# watchdog.cdl -# -# eCos watchdog configuration data -# -# ==================================================================== -#####COPYRIGHTBEGIN#### -# -# ------------------------------------------- -# The contents of this file are subject to the Red Hat eCos Public License -# Version 1.1 (the "License"); you may not use this file except in -# compliance with the License. You may obtain a copy of the License at -# http://www.redhat.com/ -# -# 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 Configurable Operating System, -# released September 30, 1998. -# -# The Initial Developer of the Original Code is Red Hat. -# Portions created by Red Hat are -# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -# All Rights Reserved. -# ------------------------------------------- -# -#####COPYRIGHTEND#### -# ==================================================================== -######DESCRIPTIONBEGIN#### -# -# Author(s): jskov -# Original data: nickg -# Contributors: -# Date: 1999-07-13 -# -#####DESCRIPTIONEND#### -# -# ==================================================================== - -cdl_package CYGPKG_DEVICES_WATCHDOG { - display "Watchdog device" - requires CYGVAR_KERNEL_COUNTERS_CLOCK - define_header watchdog.h - include_dir cyg/devs - description " - The watchdog device allows applications to make use of a - timer facility. First the application should register an - action routine with the watchdog device, and start the - watchdog running. After this the application must call a - watchdog reset function at regular intervals, or else the - device will cause the installed action routine to be - invoked. The assumption is that the watchdog timer should - never trigger unless there has been a serious fault in - either the hardware or the software, and the application's - action routine should perform an appropriate reset - operation." - - compile emulate.cxx - compile mn10300.cxx - compile ebsa285.cxx - compile sh.cxx - - # FIXME: should only be editable when there are HW alternatives. - cdl_option CYGIMP_WATCHDOG_EMULATE { - display "Watchdog emulator" - default_value 1 - description " - When this option is enabled, a watchdog will be emulated using - the kernel real-time clock." - } - - cdl_component CYGPKG_DEVICES_WATCHDOG_OPTIONS { - display "Watchdog build options" - flavor none - description " - Package specific build options including control over - compiler flags used only in building this package, - and details of which tests are built." - - - cdl_option CYGPKG_DEVICES_WATCHDOG_CFLAGS_ADD { - display "Additional compiler flags" - flavor data - no_define - default_value { "" } - description " - This option modifies the set of compiler flags for - building the watchdog device. These flags are used in addition - to the set of global flags." - } - - cdl_option CYGPKG_DEVICES_WATCHDOG_CFLAGS_REMOVE { - display "Suppressed compiler flags" - flavor data - no_define - default_value { "" } - description " - This option modifies the set of compiler flags for - building the watchdog device. These flags are removed from - the set of global flags if present." - } - - cdl_option CYGPKG_DEVICES_WATCHDOG_TESTS { - display "Watchdog tests" - flavor data - no_define - calculated { "tests/watchdog" } - description " - This option specifies the set of tests for the watchdog device." - } - } -}
deleted file mode 100644 --- a/packages/devs/watchdog/current/include/watchdog.hxx +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef CYGONCE_DEVS_WATCHDOG_HXX -#define CYGONCE_DEVS_WATCHDOG_HXX - -//========================================================================== -// -// watchdog.hxx -// -// Watchdog interface declaration -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): nickg -// Contributors: nickg -// Date: 1998-07-14 -// Purpose: Watchdog declarations -// Description: This file defines the interface to the watchdog device -// that provides timer based recovery from software and -// hardware faults. -// Usage: #include <cyg/devs/watchdog.hxx> -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include <cyg/kernel/ktypes.h> -#include <cyg/infra/cyg_ass.h> // assertion macros - -class Cyg_Watchdog_Action; - -// ------------------------------------------------------------------------- -// Watchdog class - -class Cyg_Watchdog -{ - - Cyg_Watchdog_Action *action_list; - - cyg_uint64 resolution; - -public: - - Cyg_Watchdog(); - - // Return time interval allowed between resets before watchdog - // triggers, in nanoseconds. - cyg_uint64 get_resolution(); - - // Start the watchdog running. - void start(); - - // Reset watchdog timer. This needs to be called regularly to prevent - // the watchdog firing. - void reset(); - - // Trigger the watchdog as if the timer had expired. - void trigger(); - - // Register an action routine that will be called when the timer - // triggers. - void install_action( Cyg_Watchdog_Action *wdaction ); - - // Deregister a previously registered action routine. - void uninstall_action( Cyg_Watchdog_Action *wdaction ); - - // A static instance of the single system defined watchdog device. - static Cyg_Watchdog watchdog; - -}; - -// ------------------------------------------------------------------------- -// Watchdog action class - -class Cyg_Watchdog_Action -{ - friend class Cyg_Watchdog; - - Cyg_Watchdog_Action *next; // link in chain - - void (*action)( CYG_ADDRWORD data ); // action function - - CYG_ADDRWORD data; // data argument - -public: - - Cyg_Watchdog_Action( - void (*action)( CYG_ADDRWORD data ), - CYG_ADDRWORD data - ); - - ~Cyg_Watchdog_Action(); - - void install(); - - void uninstall(); -}; - -// ------------------------------------------------------------------------- -// Cyg_Watchdog_Action inlines - -inline Cyg_Watchdog_Action::Cyg_Watchdog_Action( - void (*action_arg)( CYG_ADDRWORD data ), - CYG_ADDRWORD data_arg - ) -{ - next = NULL; - action = action_arg; - data = data_arg; -} - -inline Cyg_Watchdog_Action::~Cyg_Watchdog_Action() -{ - Cyg_Watchdog::watchdog.uninstall_action( this ); -} - -inline void Cyg_Watchdog_Action::install() -{ - Cyg_Watchdog::watchdog.install_action( this ); -} - -inline void Cyg_Watchdog_Action::uninstall() -{ - Cyg_Watchdog::watchdog.uninstall_action( this ); -} - -// ------------------------------------------------------------------------- -#endif // ifndef CYGONCE_DEVS_WATCHDOG_HXX -// EOF watchdog.hxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/src/aeb1.cxx +++ /dev/null @@ -1,196 +0,0 @@ -//========================================================================== -// -// watchdog/aeb1.cxx -// -// Watchdog implementation for ARM AEB1 board (SHARP LH77790 CPU) -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): jskov -// Contributors: jskov -// Date: 1999-09-01 -// Purpose: Watchdog class implementation -// Description: Contains an implementation of the Watchdog class for use -// with the SHARP LH77790 watchdog timer. -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include <pkgconf/system.h> // system configuration file -#include <pkgconf/watchdog.h> // configuration for this package - -#if defined(CYGPKG_HAL_ARM_AEB) && !defined(CYGIMP_WATCHDOG_EMULATE) - -#include <cyg/infra/cyg_trac.h> // tracing macros -#include <cyg/infra/cyg_ass.h> // assertion macros -#include <cyg/kernel/instrmnt.h> // instrumentation - -#include <cyg/hal/hal_io.h> // IO register access - -#include <cyg/devs/watchdog.hxx> // my header - -// ------------------------------------------------------------------------- -// Register definitions -#define CYGARC_REG_WATCHDOG_BASE 0xFFFFAC00 -#define CYGARC_REG_WATCHDOG_WDCTLR (CYGARC_REG_WATCHDOG_BASE+0x30) -#define CYGARC_REG_WATCHDOG_WDCNTR (CYGARC_REG_WATCHDOG_BASE+0x34) - -// Control register bits -#define CYGARC_REG_WATCHDOG_WDCTLR_EN 0x01 // enable -#define CYGARC_REG_WATCHDOG_WDCTLR_RSP_NMF 0x00 // non-maskable fiq -#define CYGARC_REG_WATCHDOG_WDCTLR_RSP_ER 0x04 // external reset -#define CYGARC_REG_WATCHDOG_WDCTLR_RSP_SR 0x06 // system reset -#define CYGARC_REG_WATCHDOG_WDCTLR_FRZ 0x08 // lock enable bit -#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_MASK 0x70 // time out period - -#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_17 0x00 // 2^17 -#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_17_P 5242880 // = 5.2ms - -#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_25 0x40 // 2^25 -#define CYGARC_REG_WATCHDOG_WDCTLR_TOP_25_P 1342177300 // = 1.3421773s - - -// ------------------------------------------------------------------------- -// Statics -// A static pointer to the single system defined watchdog device. -Cyg_Watchdog Cyg_Watchdog::watchdog; - -// ------------------------------------------------------------------------- -// Constructor - - -Cyg_Watchdog::Cyg_Watchdog() -{ - CYG_REPORT_FUNCTION(); - - action_list = 0; - - resolution = CYGARC_REG_WATCHDOG_WDCTLR_TOP_25_P; - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Return reset resolution - -cyg_uint64 Cyg_Watchdog::get_resolution() -{ - return resolution; -} - - -// ------------------------------------------------------------------------- -// Start the watchdog running. - -void -Cyg_Watchdog::start() -{ - CYG_REPORT_FUNCTION(); - - // Clear the watchdog counter. - HAL_WRITE_UINT32(CYGARC_REG_WATCHDOG_WDCNTR, 0); - - // Enable the watchdog (and lock/FRZ it). - HAL_WRITE_UINT8(CYGARC_REG_WATCHDOG_WDCTLR, - (CYGARC_REG_WATCHDOG_WDCTLR_TOP_25 - | CYGARC_REG_WATCHDOG_WDCTLR_FRZ - | CYGARC_REG_WATCHDOG_WDCTLR_RSP_SR - | CYGARC_REG_WATCHDOG_WDCTLR_EN)); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Reset watchdog timer. This needs to be called regularly to prevent -// the watchdog firing. - -void -Cyg_Watchdog::reset() -{ - CYG_REPORT_FUNCTION(); - - HAL_WRITE_UINT32(CYGARC_REG_WATCHDOG_WDCNTR, 0); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Trigger the watchdog as if the timer had expired. - -void -Cyg_Watchdog::trigger() -{ - CYG_REPORT_FUNCTION(); - - // Clear the watchdog counter. - HAL_WRITE_UINT32(CYGARC_REG_WATCHDOG_WDCNTR, 0); - - // Enable the watchdog with the smallest timeout. - HAL_WRITE_UINT8(CYGARC_REG_WATCHDOG_WDCTLR, - (CYGARC_REG_WATCHDOG_WDCTLR_TOP_17 - | CYGARC_REG_WATCHDOG_WDCTLR_FRZ - | CYGARC_REG_WATCHDOG_WDCTLR_RSP_SR - | CYGARC_REG_WATCHDOG_WDCTLR_EN)); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Register an action routine that will be called when the timer -// triggers. - -void -Cyg_Watchdog::install_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - // Not implemented. Possible to select a FIQ interrupt instead of reset. - CYG_FAIL("Not implemented."); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Deregister a previously registered action routine. - -void -Cyg_Watchdog::uninstall_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - // Not implemented. Possible to select a FIQ interrupt instead of reset. - CYG_FAIL("Not implemented."); - - CYG_REPORT_RETURN(); -} - -#endif // defined(CYGPKG_HAL_ARM_AEB) && - // !defined(CYGIMP_WATCHDOG_EMULATE) -// ------------------------------------------------------------------------- -// EOF watchdog/aeb1.cxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/src/ebsa285.cxx +++ /dev/null @@ -1,185 +0,0 @@ -//========================================================================== -// -// watchdog/ebsa285.cxx -// -// Watchdog implementation for Intel EBSA-285 StronARM board -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): jskov (based on the MN10300 watchdog code by nickg) -// Contributors: jskov, nickg -// Date: 1999-08-26 -// Purpose: Watchdog class implementation -// Description: Contains an implementation of the Watchdog class for use -// with the EBSA285/21285 hardware watchdog timer. -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include <pkgconf/system.h> // system configuration file -#include <pkgconf/watchdog.h> // configuration for this package - -#if defined(CYGPKG_HAL_ARM_EBSA285) && !defined(CYGIMP_WATCHDOG_EMULATE) - -#include <cyg/infra/cyg_trac.h> // tracing macros -#include <cyg/infra/cyg_ass.h> // assertion macros -#include <cyg/kernel/instrmnt.h> // instrumentation - -#include <cyg/hal/hal_io.h> // IO register access - -#include <cyg/devs/watchdog.hxx> // my header - -// ------------------------------------------------------------------------- -// 21285 watchdog works by letting timer4 run; if it ever underflows, -// it resets the system. -// Timer 4 is set to run at fclk_in/16 = 50MHz/16 = 3.125MHz -// The timer register is 24 bits, so it can easily hold a value that -// gives a 1s timeout. -#define WATCHDOG_TIMER_TICKS 3125000 -#define WATCHDOG_RESOLUTION (1000000000) - -// ------------------------------------------------------------------------- -// Statics - -// A static pointer to the single system defined watchdog device. -Cyg_Watchdog Cyg_Watchdog::watchdog; - -// ------------------------------------------------------------------------- -// Constructor - - -Cyg_Watchdog::Cyg_Watchdog() -{ - CYG_REPORT_FUNCTION(); - - action_list = 0; - - resolution = WATCHDOG_RESOLUTION; - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Return reset resolution - -cyg_uint64 Cyg_Watchdog::get_resolution() -{ - return resolution; -} - - -// ------------------------------------------------------------------------- -// Start the watchdog running. - -void -Cyg_Watchdog::start() -{ - CYG_REPORT_FUNCTION(); - - // Init the watchdog timer. - HAL_WRITE_UINT32(SA110_TIMER4_LOAD, WATCHDOG_TIMER_TICKS); - HAL_WRITE_UINT32(SA110_TIMER4_CLEAR, 0); - HAL_WRITE_UINT32(SA110_TIMER4_CONTROL, - SA110_TIMER_CONTROL_ENABLE|SA110_TIMER_CONTROL_SCALE_16); - // Enable the watchdog. - cyg_uint32 ctrl; - HAL_READ_UINT32(SA110_CONTROL, ctrl); - ctrl |= SA110_CONTROL_WATCHDOG; - HAL_WRITE_UINT32(SA110_CONTROL, ctrl); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Reset watchdog timer. This needs to be called regularly to prevent -// the watchdog firing. - -void -Cyg_Watchdog::reset() -{ - CYG_REPORT_FUNCTION(); - - HAL_WRITE_UINT32(SA110_TIMER4_LOAD, WATCHDOG_TIMER_TICKS); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Trigger the watchdog as if the timer had expired. - -void -Cyg_Watchdog::trigger() -{ - CYG_REPORT_FUNCTION(); - - // Init the watchdog timer. - HAL_WRITE_UINT32(SA110_TIMER4_LOAD, 1); - HAL_WRITE_UINT32(SA110_TIMER4_CONTROL, SA110_TIMER_CONTROL_ENABLE); - // Enable the watchdog. - cyg_uint32 ctrl; - HAL_READ_UINT32(SA110_CONTROL, ctrl); - ctrl |= SA110_CONTROL_WATCHDOG; - HAL_WRITE_UINT32(SA110_CONTROL, ctrl); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Register an action routine that will be called when the timer -// triggers. - -void -Cyg_Watchdog::install_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - // Can't be done. If the time expires the board resets. End of story. - CYG_FAIL("It's not possible to register actions for the EBSA watchdog"); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Deregister a previously registered action routine. - -void -Cyg_Watchdog::uninstall_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - // Can't be done. If the time expires the board resets. End of story. - CYG_FAIL("It's not possible to deregister actions for the EBSA watchdog"); - - CYG_REPORT_RETURN(); -} - -#endif // defined(CYGPKG_HAL_ARM_EBSA285) && - // !defined(CYGIMP_WATCHDOG_EMULATE) -// ------------------------------------------------------------------------- -// EOF watchdog/ebsa285.cxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/src/emulate.cxx +++ /dev/null @@ -1,225 +0,0 @@ -//========================================================================== -// -// watchdog/emulate.cxx -// -// Watchdog implementation emulation -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): nickg -// Contributors: nickg -// Date: 1998-07-29 -// Purpose: Watchdog class implementation -// Description: Contains an implementation of the Watchdog class for use -// when there is no hardware watchdog timer. Instead it is -// emulated using an Alarm object. -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include <pkgconf/watchdog.h> // watchdog configuration file - -#ifdef CYGIMP_WATCHDOG_EMULATE - -#include <pkgconf/kernel.h> // Kernel config - -#include <cyg/kernel/ktypes.h> // base kernel types -#include <cyg/infra/cyg_trac.h> // tracing macros -#include <cyg/infra/cyg_ass.h> // assertion macros -#include <cyg/kernel/instrmnt.h> // instrumentation - -#include <cyg/kernel/clock.hxx> // clock and alarm -#include <cyg/kernel/sched.hxx> // scheduler - -#include <cyg/devs/watchdog.hxx> // my header - -#include <cyg/kernel/sched.inl> // scheduler inlines - -// ------------------------------------------------------------------------- -// Forward definitions - -static cyg_alarm_fn watchdog_alarm; - -// ------------------------------------------------------------------------- -// Statics - -// A static pointer to the single system defined watchdog device. -Cyg_Watchdog Cyg_Watchdog::watchdog; - -static Cyg_Alarm alarm( Cyg_Clock::real_time_clock, watchdog_alarm, 0 ); - -// One second's worth of ticks. -static cyg_tick_count one_sec; - -// ------------------------------------------------------------------------- -// Constructor - -Cyg_Watchdog::Cyg_Watchdog() -{ - CYG_REPORT_FUNCTION(); - - action_list = 0; - - Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); - - one_sec = ( res.divisor * 1000000000LL ) / res.dividend ; - - resolution = 1000000000LL; - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Return reset resolution - -cyg_uint64 Cyg_Watchdog::get_resolution() -{ - return resolution; -} - -// ------------------------------------------------------------------------- -// Start the watchdog running. - -void Cyg_Watchdog::start() -{ - CYG_REPORT_FUNCTION(); - - Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); - - // Set alarm to a one second single-shot trigger - alarm.initialize( Cyg_Clock::real_time_clock->current_value() + one_sec, 0 ); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Reset watchdog timer. This needs to be called regularly to prevent -// the watchdog firing. - -void Cyg_Watchdog::reset() -{ - CYG_REPORT_FUNCTION(); - - Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); - - Cyg_Scheduler::lock(); - - // Set alarm to a one second single-shot trigger - alarm.initialize( Cyg_Clock::real_time_clock->current_value() + one_sec, 0 ); - - Cyg_Scheduler::unlock(); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Trigger the watchdog as if the timer had expired. - -void Cyg_Watchdog::trigger() -{ - CYG_REPORT_FUNCTION(); - - Cyg_Scheduler::lock(); - - // Disable alarm just in case - alarm.disable(); - - Cyg_Watchdog_Action *act = action_list; - - while( 0 != act ) - { - act->action( act->data ); - - act = act->next; - } - - Cyg_Scheduler::unlock(); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Register an action routine that will be called when the timer -// triggers. - -void Cyg_Watchdog::install_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - Cyg_Scheduler::lock(); - - action->next = action_list; - action_list = action; - - Cyg_Scheduler::unlock(); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Deregister a previously registered action routine. - -void Cyg_Watchdog::uninstall_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - Cyg_Scheduler::lock(); - - Cyg_Watchdog_Action **act_ptr = &action_list; - - while( 0 != *act_ptr ) - { - Cyg_Watchdog_Action *a = *act_ptr; - - if( a == action ) - { - *act_ptr = a->next; - break; - } - act_ptr = &a->next; - } - - Cyg_Scheduler::unlock(); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Alarm function - -void watchdog_alarm( Cyg_Alarm *a, CYG_ADDRWORD data) -{ - CYG_REPORT_FUNCTION(); - - Cyg_Watchdog::watchdog.trigger(); -} - -#endif // CYGIMP_WATCHDOG_EMULATE -// ------------------------------------------------------------------------- -// EOF watchdog/emulate.cxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/src/mn10300.cxx +++ /dev/null @@ -1,290 +0,0 @@ -//========================================================================== -// -// watchdog/mn10300.cxx -// -// Watchdog implementation for MN10300 -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): nickg -// Contributors: nickg -// Date: 1999-02-18 -// Purpose: Watchdog class implementation -// Description: Contains an implementation of the Watchdog class for use -// with the MN10300 hardware watchdog timer. -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include <pkgconf/system.h> // system configuration file -#include <pkgconf/watchdog.h> // configuration for this package - -#if defined(CYGPKG_HAL_MN10300) && !defined(CYGIMP_WATCHDOG_EMULATE) - -#include <pkgconf/kernel.h> // Kernel config - -#include <cyg/kernel/ktypes.h> // base kernel types -#include <cyg/infra/cyg_trac.h> // tracing macros -#include <cyg/infra/cyg_ass.h> // assertion macros -#include <cyg/kernel/instrmnt.h> // instrumentation - -#include <cyg/hal/hal_io.h> // IO register access - -#include <cyg/kernel/sched.hxx> // scheduler -#include <cyg/kernel/intr.hxx> // interrupts - -#include <cyg/kernel/sched.inl> // scheduler inlines - -#include <cyg/devs/watchdog.hxx> // my header - -// ------------------------------------------------------------------------- -// MN10300 watchdog timer registers - -#if defined(CYGPKG_HAL_MN10300_AM31) - -#define WATCHDOG_BASE 0x34004000 -#define WATCHDOG_COUNTER (WATCHDOG_BASE) -#define WATCHDOG_CONTROL (WATCHDOG_BASE+2) -#define WATCHDOG_RESET (WATCHDOG_BASE+4) - -#define WATCHDOG_WDCK0 0x07 -#define WATCHDOG_WDCK0_DEFAULT 0x04 // 1016.801ms cycle -#define WATCHDOG_WDRST 0x40 -#define WATCHDOG_WDCNE 0x80 - -#define WATCHDOG_RESOLUTION 1016801000 // cycle time in nanoseconds - -#elif defined(CYGPKG_HAL_MN10300_AM33) - -#define WATCHDOG_BASE 0xC0001000 -#define WATCHDOG_COUNTER (WATCHDOG_BASE) -#define WATCHDOG_CONTROL (WATCHDOG_BASE+2) -#define WATCHDOG_RESET (WATCHDOG_BASE+4) - -#define WATCHDOG_WDCK0 0x07 -#define WATCHDOG_WDCK0_DEFAULT 0x04 // 621.387ms cycle -#define WATCHDOG_WDRST 0x40 -#define WATCHDOG_WDCNE 0x80 - -#define WATCHDOG_RESOLUTION 621387000 // cycle time in nanoseconds - -#else - -#error Unsupported MN10300 variant - -#endif - -// ------------------------------------------------------------------------- -// Forward definitions - -static cyg_ISR watchdog_isr; -static cyg_DSR watchdog_dsr; - -// ------------------------------------------------------------------------- -// Statics - -// A static pointer to the single system defined watchdog device. -Cyg_Watchdog Cyg_Watchdog::watchdog; - -// Interrupt object -static Cyg_Interrupt interrupt( - CYGNUM_HAL_INTERRUPT_WATCHDOG, - 0, - 0, - watchdog_isr, - watchdog_dsr - ); - -// ------------------------------------------------------------------------- -// Constructor - - -Cyg_Watchdog::Cyg_Watchdog() -{ - CYG_REPORT_FUNCTION(); - - action_list = 0; - - resolution = WATCHDOG_RESOLUTION; - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Return reset resolution - -cyg_uint64 Cyg_Watchdog::get_resolution() -{ - return resolution; -} - - -// ------------------------------------------------------------------------- -// Start the watchdog running. - -void -Cyg_Watchdog::start() -{ - CYG_REPORT_FUNCTION(); - - interrupt.attach(); - - HAL_WRITE_UINT8( WATCHDOG_COUNTER, 0 ); - - // Set overflow cycle - // Enable and reset counter - HAL_WRITE_UINT8( WATCHDOG_CONTROL, - WATCHDOG_WDCK0_DEFAULT|WATCHDOG_WDCNE|WATCHDOG_WDRST); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Reset watchdog timer. This needs to be called regularly to prevent -// the watchdog firing. - -void -Cyg_Watchdog::reset() -{ - CYG_REPORT_FUNCTION(); - - cyg_uint8 ctrl; - - HAL_READ_UINT8( WATCHDOG_CONTROL, ctrl ); - - ctrl |= WATCHDOG_WDRST; - - HAL_WRITE_UINT8( WATCHDOG_CONTROL, ctrl ); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Trigger the watchdog as if the timer had expired. - -void -Cyg_Watchdog::trigger() -{ - CYG_REPORT_FUNCTION(); - - Cyg_Scheduler::lock(); - - // Disable interrupt just in case - interrupt.detach(); - - // Turn watchdog off to prevent it re-triggering. - HAL_WRITE_UINT8( WATCHDOG_CONTROL, 0 ); - - Cyg_Watchdog_Action *act = action_list; - - while( 0 != act ) - { - act->action( act->data ); - - act = act->next; - } - - Cyg_Scheduler::unlock(); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Register an action routine that will be called when the timer -// triggers. - -void -Cyg_Watchdog::install_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - Cyg_Scheduler::lock(); - - action->next = action_list; - action_list = action; - - Cyg_Scheduler::unlock(); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Deregister a previously registered action routine. - -void -Cyg_Watchdog::uninstall_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - Cyg_Scheduler::lock(); - - Cyg_Watchdog_Action **act_ptr = &action_list; - - while( 0 != *act_ptr ) - { - Cyg_Watchdog_Action *a = *act_ptr; - - if( a == action ) - { - *act_ptr = a->next; - break; - } - act_ptr = &a->next; - } - - Cyg_Scheduler::unlock(); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// ISR and DSR - -cyg_uint32 -watchdog_isr( cyg_vector vector, CYG_ADDRWORD data) -{ - CYG_REPORT_FUNCTION(); - - Cyg_Watchdog::watchdog.trigger(); - - CYG_REPORT_RETURN(); - - // FIXME: why is this 0??? why not Cyg_Interrupt::HANDLED? - Jifl - return 0; -} - -void -watchdog_dsr(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data) -{ -} - -#endif // defined(CYGPKG_HAL_MN10300) && - // !defined(CYGIMP_WATCHDOG_EMULATE) -// ------------------------------------------------------------------------- -// EOF watchdog/mn10300.cxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/src/sh.cxx +++ /dev/null @@ -1,177 +0,0 @@ -//========================================================================== -// -// watchdog/sh.cxx -// -// Watchdog implementation for Hitachi SH CPUs -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): jskov -// Contributors: jskov -// Date: 1999-09-01 -// Purpose: Watchdog class implementation -// Description: Contains an implementation of the Watchdog class for use -// with the Hitachi SH watchdog timer. -// -//####DESCRIPTIONEND#### -// -//========================================================================== - -#include <pkgconf/system.h> // system configuration file -#include <pkgconf/watchdog.h> // configuration for this package - -#if defined(CYGPKG_HAL_SH) && !defined(CYGIMP_WATCHDOG_EMULATE) - -#include <cyg/infra/cyg_trac.h> // tracing macros -#include <cyg/infra/cyg_ass.h> // assertion macros -#include <cyg/kernel/instrmnt.h> // instrumentation - -#include <cyg/hal/hal_io.h> // IO register access -#include <cyg/hal/sh_regs.h> // watchdog register definitions - -#include <cyg/devs/watchdog.hxx> // my header - -// ------------------------------------------------------------------------- -// Statics -// A static pointer to the single system defined watchdog device. -Cyg_Watchdog Cyg_Watchdog::watchdog; - -// ------------------------------------------------------------------------- -// Constructor - - -Cyg_Watchdog::Cyg_Watchdog() -{ - CYG_REPORT_FUNCTION(); - - action_list = 0; - - resolution = CYGARC_REG_WTCSR_PERIOD; - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Return reset resolution - -cyg_uint64 Cyg_Watchdog::get_resolution() -{ - return resolution; -} - - -// ------------------------------------------------------------------------- -// Start the watchdog running. - -void -Cyg_Watchdog::start() -{ - CYG_REPORT_FUNCTION(); - - // Init the watchdog timer (note: 8 bit reads, 16 bit writes) - cyg_uint16 csr; - // First disable without changing other bits. - HAL_READ_UINT8(CYGARC_REG_WTCSR, csr); - csr |= CYGARC_REG_WTCSR_WRITE; - csr &= ~CYGARC_REG_WTCSR_TME; - HAL_WRITE_UINT16(CYGARC_REG_WTCSR, csr); - // Then set control bits and clear counter. - csr = (CYGARC_REG_WTCSR_WRITE - |CYGARC_REG_WTCSR_WT_IT - |CYGARC_REG_WTCSR_CKSx_SETTING); - HAL_WRITE_UINT16(CYGARC_REG_WTCSR, csr); - HAL_WRITE_UINT16(CYGARC_REG_WTCNT, CYGARC_REG_WTCNT_WRITE); - // Finally enable timer. - csr |= CYGARC_REG_WTCSR_TME; - HAL_WRITE_UINT16(CYGARC_REG_WTCSR, csr); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Reset watchdog timer. This needs to be called regularly to prevent -// the watchdog firing. - -void -Cyg_Watchdog::reset() -{ - CYG_REPORT_FUNCTION(); - - HAL_WRITE_UINT16(CYGARC_REG_WTCNT, CYGARC_REG_WTCNT_WRITE); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Trigger the watchdog as if the timer had expired. - -void -Cyg_Watchdog::trigger() -{ - CYG_REPORT_FUNCTION(); - - start(); - - HAL_WRITE_UINT16(CYGARC_REG_WTCNT, CYGARC_REG_WTCNT_WRITE|0xfe); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Register an action routine that will be called when the timer -// triggers. - -void -Cyg_Watchdog::install_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - // Can't be done. If the time expires the board resets. End of story. - CYG_FAIL("It's not possible to register actions for the SH watchdog"); - - CYG_REPORT_RETURN(); -} - -// ------------------------------------------------------------------------- -// Deregister a previously registered action routine. - -void -Cyg_Watchdog::uninstall_action( Cyg_Watchdog_Action *action ) -{ - CYG_REPORT_FUNCTION(); - - // Can't be done. If the time expires the board resets. End of story. - CYG_FAIL("It's not possible to deregister actions for the SH watchdog"); - - CYG_REPORT_RETURN(); -} - -#endif // defined(CYGPKG_HAL_SH) && - // !defined(CYGIMP_WATCHDOG_EMULATE) -// ------------------------------------------------------------------------- -// EOF watchdog/sh.cxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/tests/watchdog.cxx +++ /dev/null @@ -1,230 +0,0 @@ -//========================================================================== -// -// watchdog.cxx -// -// Watchdog test -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): nickg -// Contributors: nickg -// Date: 1998-07-20 -// Description: Tests the Kernel Wall Clock -// This test exercises the Watchdog class and checks that it -// works as advertised. -//####DESCRIPTIONEND#### -// ------------------------------------------------------------------------- - -#include <pkgconf/kernel.h> - -#include <cyg/kernel/thread.hxx> -#include <cyg/kernel/thread.inl> -#include <cyg/kernel/sched.hxx> -#include <cyg/kernel/mutex.hxx> -#include <cyg/kernel/sema.hxx> -#include <cyg/kernel/clock.hxx> - -#include <cyg/kernel/diag.h> - -#include <cyg/devs/watchdog.hxx> - -#include <cyg/infra/testcase.h> -#include <cyg/infra/diag.h> - -#if defined(CYGFUN_KERNEL_THREADS_TIMER) && \ - defined(CYGVAR_KERNEL_COUNTERS_CLOCK) - -#include <cyg/kernel/sched.inl> - -// ------------------------------------------------------------------------- -// Data for the test - -#ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL -#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL -#else -#define STACKSIZE (2*1024) // size of thread stack -#endif - -char thread_stack[STACKSIZE]; - -inline void *operator new(size_t size, void *ptr) { return ptr; }; - -// array of threads. -char thread[sizeof(Cyg_Thread)]; - -Cyg_Thread *th; - -//cyg_tick_count one_sec; -cyg_tick_count watchdog_delay; -volatile bool watchdog_fired; -volatile cyg_tick_count watchdog_time; - -#define WATCHDOG_LOOPS_HW 5 -#define WATCHDOG_LOOPS_SIM 1 -#define WATCHDOG_CYCLES_PER_LOOP_HW 10 -#define WATCHDOG_CYCLES_PER_LOOP_SIM 2 -#define WATCHDOG_TICKS_TILL_TIMEOUT 10 - -// ------------------------------------------------------------------------- -// Action functions: - -void watchdog_action1( CYG_ADDRWORD data ) -{ - watchdog_fired = true; - watchdog_time = Cyg_Clock::real_time_clock->current_value(); -} - -void watchdog_action2( CYG_ADDRWORD data ) -{ - CYG_TEST_PASS_FINISH("Watchdog OK"); -} - -// ------------------------------------------------------------------------- -// Thread body - - -void watchdog_thread( CYG_ADDRWORD id ) -{ - cyg_tick_count watchdog_start_time; - cyg_tick_count thread_start_time, thread_end_time; - cyg_ucount8 watchdog_loops, watchdog_cycles_per_loop; - - if (cyg_test_is_simulator) { - watchdog_loops = WATCHDOG_LOOPS_SIM; - watchdog_cycles_per_loop = WATCHDOG_CYCLES_PER_LOOP_SIM; - } else { - watchdog_loops = WATCHDOG_LOOPS_HW; - watchdog_cycles_per_loop = WATCHDOG_CYCLES_PER_LOOP_HW; - } - - watchdog_fired = false; - Cyg_Watchdog::watchdog.start(); - - CYG_TEST_INFO("Testing that watchdog does not fire early"); - - for (cyg_ucount8 tries = 0; tries < watchdog_loops; tries++) { - diag_printf("Iteration #%d (testing over %d cycles)\n", - tries, watchdog_cycles_per_loop); - - // First test that the watchdog does not trigger when being reset. - Cyg_Watchdog_Action wdaction( watchdog_action1, 0 ); - - wdaction.install(); - Cyg_Watchdog::watchdog.reset(); - - watchdog_start_time = Cyg_Clock::real_time_clock->current_value(); - watchdog_fired = false; - - for( cyg_ucount8 i = 0; i < watchdog_cycles_per_loop; i++ ) { - thread_start_time = Cyg_Clock::real_time_clock->current_value(); - th->delay( watchdog_delay-2 ); - Cyg_Watchdog::watchdog.reset(); - if (watchdog_fired) { - thread_end_time = Cyg_Clock::real_time_clock->current_value(); - diag_printf("Watchdog fired prematurely after %d ticks\n", - (int)(watchdog_time - watchdog_start_time)); - diag_printf(" Thread slept for %d ticks, loop #%d\n", - (int)(thread_end_time - thread_start_time), i); - CYG_TEST_FAIL_FINISH("Watchdog triggered unexpectedly"); - break; - } else { - CYG_TEST_STILL_ALIVE(i, "Resetting watchdog..."); - Cyg_Watchdog::watchdog.reset(); - watchdog_fired = false; - watchdog_start_time = Cyg_Clock::real_time_clock->current_value(); - } - } - } - - // Now check that it triggers when not reset - CYG_TEST_INFO("Testing that watchdog fires"); - { - Cyg_Watchdog_Action wdaction( watchdog_action2, 0 ); - - wdaction.install(); - - Cyg_Watchdog::watchdog.reset(); - - th->delay( watchdog_delay*WATCHDOG_TICKS_TILL_TIMEOUT ); - } - - CYG_TEST_FAIL_FINISH("Watchdog failed to trigger"); -} - -// ------------------------------------------------------------------------- - - -externC void -cyg_start( void ) -{ - CYG_TEST_INIT(); - -#if !defined(CYGIMP_WATCHDOG_EMULATE) && defined(CYGPKG_HAL_MN10300_STDEVAL1) - // Workaround for PR 17974 - if( cyg_test_is_simulator ) - CYG_TEST_NA("Watchdog device not implemented in MN10300 simulator."); -#endif - - - Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); - - cyg_uint64 wres = Cyg_Watchdog::watchdog.get_resolution(); - - // Calculate how many clock ticks there are in a watchdog cycle. - - watchdog_delay = ((cyg_tick_count)wres * (cyg_tick_count)res.divisor ); - watchdog_delay /= res.dividend; - - th = new((void *)&thread) Cyg_Thread(CYG_SCHED_DEFAULT_INFO, - watchdog_thread, - 0, - "watchdog_thread", - (CYG_ADDRESS)thread_stack, - STACKSIZE - ); - - th->resume(); - - // Get the world going - Cyg_Scheduler::scheduler.start(); - -} - -#else // if defined(CYGFUN_KERNEL_THREADS_TIMER) etc... - -externC void -cyg_start( void ) -{ - CYG_TEST_INIT(); - CYG_TEST_NA("Kernel real-time clock/threads timer disabled"); -} - -#endif // if defined(CYGFUN_KERNEL_THREADS_TIMER) etc... - -// ------------------------------------------------------------------------- -// EOF watchdog.cxx
deleted file mode 100644 --- a/packages/devs/watchdog/current/tests/watchdog_reset.cxx +++ /dev/null @@ -1,175 +0,0 @@ -//========================================================================== -// -// watchdog_reset.cxx -// -// Watchdog reset test -// -//========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// 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 Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//========================================================================== -//#####DESCRIPTIONBEGIN#### -// -// Author(s): jskov (based on watchdog.cxx) -// Contributors: jskov, nickg -// Date: 1999-08-27 -// Description: Tests that the watchdog timer resets the board. -// This test needs to be run by an operator - automatic -// testing not possible. -//####DESCRIPTIONEND#### -// ------------------------------------------------------------------------- - -#include <pkgconf/system.h> - -#include <cyg/infra/testcase.h> -#include <cyg/infra/diag.h> - -// Package requirements -#if defined(CYGPKG_KERNEL) - -#include <pkgconf/kernel.h> - -// Package option requirements -#if defined(CYGFUN_KERNEL_THREADS_TIMER) && \ - defined(CYGVAR_KERNEL_COUNTERS_CLOCK) - - -#include <cyg/kernel/thread.inl> - -#include <cyg/hal/hal_cache.h> - -#include <cyg/devs/watchdog.hxx> - - -// ------------------------------------------------------------------------- -// Data for the test - -#ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL -#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL -#else -#define STACKSIZE (2*1024) // size of thread stack -#endif - -char thread_stack[STACKSIZE]; - -inline void *operator new(size_t size, void *ptr) { return ptr; }; - -// array of threads. -char thread[sizeof(Cyg_Thread)]; - -Cyg_Thread *th; - -//cyg_tick_count one_sec; -cyg_tick_count watchdog_delay; - -// ------------------------------------------------------------------------- -// Thread body - -volatile int watchdog_accuracy = 50; - -void watchdog_thread( CYG_ADDRWORD id ) -{ - diag_printf("Test of watchdog timer accuracy. Expect the test to run\n" - "for at least 10 times the watchdog timeout time. After\n" - "that time you may have to reset the board manually and/or\n" - "restart GDB which tends to get a little confused.\n"); - diag_printf("When you get contact with the board again, read the value\n" - "in watchdog_accuracy - it should be close to 100 if the\n" - "watchdog timer is accurate.\n"); - - // Disable data cache so the variable in memory gets updated. - HAL_DCACHE_SYNC(); - HAL_DCACHE_DISABLE(); - - Cyg_Watchdog::watchdog.start(); - Cyg_Watchdog::watchdog.reset(); - - while (watchdog_accuracy < 400) { - Cyg_Watchdog::watchdog.reset(); - th->delay( watchdog_delay*watchdog_accuracy/100 ); - watchdog_accuracy += 5; - } - - CYG_TEST_FAIL_FINISH("Watchdog failed to reset board. " - "Timer value is off by at least a factor of 4!"); -} - -// ------------------------------------------------------------------------- - - -externC void -cyg_start( void ) -{ - CYG_TEST_INIT(); - -#if !defined(CYGIMP_WATCHDOG_EMULATE) && defined(CYGPKG_HAL_MN10300_STDEVAL1) - // Workaround for PR 17974 - if( cyg_test_is_simulator ) - CYG_TEST_NA("Watchdog device not implemented in MN10300 simulator."); -#endif - - - Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); - - cyg_uint64 wres = Cyg_Watchdog::watchdog.get_resolution(); - - // Calculate how many clock ticks there are in a watchdog cycle. - - watchdog_delay = ((cyg_tick_count)wres * (cyg_tick_count)res.divisor ); - watchdog_delay /= res.dividend; - - th = new((void *)&thread) Cyg_Thread(CYG_SCHED_DEFAULT_INFO, - watchdog_thread, - 0, - "watchdog_thread", - (CYG_ADDRESS)thread_stack, - STACKSIZE - ); - - th->resume(); - - // Get the world going - Cyg_Scheduler::scheduler.start(); - -} - -#else // CYGFUN_KERNEL_THREADS_TIMER etc... -#define N_A_MSG "Needs kernel RTC/threads timer" -#endif - -#else // CYGPKG_KERNEL -#define N_A_MSG "Needs Kernel" -#endif - -#ifdef N_A_MSG -void -cyg_start( void ) -{ - CYG_TEST_INIT(); - CYG_TEST_NA( N_A_MSG); -} -#endif // N_A_MSG - -// ------------------------------------------------------------------------- -// EOF watchdog_reset.cxx
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/mn10300/mn10300/current/ChangeLog @@ -0,0 +1,81 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * cdl/watchdog_mn10300.cdl: + * src/watchdog_mn10300.cxx: + Driver moved to devs/watchdog/mn10300/mn10300. Stripped out + unrelated ChangeLog entries. + +1999-08-24 Nick Garnett <nickg@cygnus.co.uk> + + * src/mn10300.cxx: Turn watchdog off in Cyg_Watchdog::trigger() to + prevent it repeating. + +1999-08-18 Nick Garnett <nickg@cygnus.co.uk> + + * src/mn10300.cxx: + Added support for AM33 variant. Since the AM33 can only provide a + maximum watchdog cycle time of 621ms, this has motiviated the + addition of the get_resolution() call described above. + +1999-07-14 Jesper Skov <jskov@cygnus.co.uk> + + * src/mn10300.cxx: + Include pkgconf/kernel.h. + +1999-02-20 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * src/mn10300.cxx: + Change CYG_VECTOR_WATCHDOG to CYGNUM_HAL_INTERRUPT_WATCHDOG in line + with HAL changes. + General QA improvements + +Tue Oct 20 15:52:46 1998 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * src/mn10300.cxx: + Include <pkgconf/watchdog.h> so that we get CYGIMP_WATCHDOG_EMULATE + defined appropriately + +1998-09-01 Nick Garnett <nickg@cygnus.co.uk> + + * src/mn10300.cxx: + Added include for <cyg/kernel/sched.inl>, for scheduler lock and + unlock functions. + +1998-07-31 Nick Garnett <nickg@cygnus.co.uk> + + * src/PKGconf.mak: + Added mn10300.cxx to COMPILE list. + + * src/mn10300.cxx: + Completed implementation using MN10300 watchdog timer. + + * include/watchdog.hxx: + Renamed 'register' functions to 'install'. Added install() and + uninstall() to Cyg_Watchdog_Action class. + + * include/pkgconf/watchdog.h: + Added this file to contain watchdog config options. + +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND####
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/mn10300/mn10300/current/cdl/watchdog_mn10300.cdl @@ -0,0 +1,92 @@ +# ==================================================================== +# +# watchdog_mn10300.cdl +# +# eCos watchdog for VR4300/Mn10300 driver configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Contributors: jskov +# Date: 2000-05-31 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300 { + parent CYGPKG_IO_WATCHDOG + active_if CYGPKG_IO_WATCHDOG + display "MN10300 watchdog driver" + requires CYGPKG_HAL_MN10300 + requires CYGPKG_KERNEL + hardware + compile watchdog_mn10300.cxx + implements CYGINT_WATCHDOG_HW_IMPLEMENTATIONS + active_if CYGIMP_WATCHDOG_HARDWARE + + cdl_option CYGIMP_WATCHDOG_HARDWARE { + parent CYGPKG_IO_WATCHDOG_IMPLEMENTATION + display "Hardware watchdog" + default_value 1 + implements CYGINT_WATCHDOG_IMPLEMENTATIONS + } + + cdl_component CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300_OPTIONS { + display "MN10300 watchdog build options" + flavor none + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are removed from + the set of global flags if present." + } + + } +}
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/mn10300/mn10300/current/src/watchdog_mn10300.cxx @@ -0,0 +1,190 @@ +//========================================================================== +// +// devs/watchdog/mn10300/mn10300/watchdog_mn10300.cxx +// +// Watchdog implementation for MN10300 +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1999-02-18 +// Purpose: Watchdog class implementation +// Description: Contains an implementation of the Watchdog class for use +// with the MN10300 hardware watchdog timer. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> // system configuration file +#include <pkgconf/watchdog.h> // configuration for this package +#include <pkgconf/kernel.h> // Kernel config + +#include <cyg/kernel/ktypes.h> // base kernel types +#include <cyg/infra/cyg_trac.h> // tracing macros +#include <cyg/kernel/instrmnt.h> // instrumentation + +#include <cyg/hal/hal_io.h> // IO register access + +#include <cyg/kernel/intr.hxx> // interrupts + +#include <cyg/io/watchdog.hxx> // watchdog API + +// ------------------------------------------------------------------------- +// MN10300 watchdog timer registers + +#if defined(CYGPKG_HAL_MN10300_AM31) + +#define WATCHDOG_BASE 0x34004000 +#define WATCHDOG_COUNTER (WATCHDOG_BASE) +#define WATCHDOG_CONTROL (WATCHDOG_BASE+2) +#define WATCHDOG_RESET (WATCHDOG_BASE+4) + +#define WATCHDOG_WDCK0 0x07 +#define WATCHDOG_WDCK0_DEFAULT 0x04 // 1016.801ms cycle +#define WATCHDOG_WDRST 0x40 +#define WATCHDOG_WDCNE 0x80 + +#define WATCHDOG_RESOLUTION 1016801000 // cycle time in nanoseconds + +#elif defined(CYGPKG_HAL_MN10300_AM33) + +#define WATCHDOG_BASE 0xC0001000 +#define WATCHDOG_COUNTER (WATCHDOG_BASE) +#define WATCHDOG_CONTROL (WATCHDOG_BASE+2) +#define WATCHDOG_RESET (WATCHDOG_BASE+4) + +#define WATCHDOG_WDCK0 0x07 +#define WATCHDOG_WDCK0_DEFAULT 0x04 // 621.387ms cycle +#define WATCHDOG_WDRST 0x40 +#define WATCHDOG_WDCNE 0x80 + +#define WATCHDOG_RESOLUTION 621387000 // cycle time in nanoseconds + +#else + +#error Unsupported MN10300 variant + +#endif + +// ------------------------------------------------------------------------- +// Forward definitions + +static cyg_ISR watchdog_isr; + +// ------------------------------------------------------------------------- +// Statics + +// Interrupt object +static Cyg_Interrupt interrupt( + CYGNUM_HAL_INTERRUPT_WATCHDOG, + 0, + 0, + watchdog_isr, + NULL // no DSR + ); + +// ------------------------------------------------------------------------- +// Constructor + +void +Cyg_Watchdog::init_hw(void) +{ + CYG_REPORT_FUNCTION(); + + // HW doesn't need init. + + resolution = WATCHDOG_RESOLUTION; + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Start the watchdog running. + +void +Cyg_Watchdog::start(void) +{ + CYG_REPORT_FUNCTION(); + + interrupt.attach(); + + HAL_WRITE_UINT8( WATCHDOG_COUNTER, 0 ); + + // Set overflow cycle + // Enable and reset counter + HAL_WRITE_UINT8( WATCHDOG_CONTROL, + WATCHDOG_WDCK0_DEFAULT|WATCHDOG_WDCNE|WATCHDOG_WDRST); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Reset watchdog timer. This needs to be called regularly to prevent +// the watchdog firing. + +void +Cyg_Watchdog::reset() +{ + CYG_REPORT_FUNCTION(); + + cyg_uint8 ctrl; + + HAL_READ_UINT8( WATCHDOG_CONTROL, ctrl ); + + ctrl |= WATCHDOG_WDRST; + + HAL_WRITE_UINT8( WATCHDOG_CONTROL, ctrl ); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// ISR + +cyg_uint32 +watchdog_isr( cyg_vector vector, CYG_ADDRWORD data) +{ + CYG_REPORT_FUNCTION(); + + // Disable interrupt just in case + interrupt.detach(); + + // Turn watchdog off to prevent it re-triggering. + HAL_WRITE_UINT8( WATCHDOG_CONTROL, 0 ); + + Cyg_Watchdog::watchdog.trigger(); + + CYG_REPORT_RETURN(); + + return Cyg_Interrupt::HANDLED; +} + +// ------------------------------------------------------------------------- +// EOF watchdog_mn10300.cxx
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/sh/sh3/current/ChangeLog @@ -0,0 +1,35 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * cdl/watchdog_sh3.cdl: + * src/watchdog_sh3.cxx: + Driver moved to devs/watchdog/sh/sh3. Stripped out + unrelated ChangeLog entries. + +1999-09-01 Jesper Skov <jskov@cygnus.co.uk> + + * src/sh.cxx: + Added watchdog driver for SH. + +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND####
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/sh/sh3/current/cdl/watchdog_sh3.cdl @@ -0,0 +1,93 @@ +# ==================================================================== +# +# watchdog_sh3.cdl +# +# eCos watchdog for the Hitachi SH3 driver configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Contributors: jskov +# Date: 2000-05-31 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVICES_WATCHDOG_SH_SH3 { + parent CYGPKG_IO_WATCHDOG + active_if CYGPKG_IO_WATCHDOG + display "SH3 watchdog driver" + requires CYGPKG_HAL_SH + requires CYGPKG_KERNEL + hardware + compile watchdog_sh3.cxx + implements CYGINT_WATCHDOG_HW_IMPLEMENTATIONS + implements CYGINT_WATCHDOG_RESETS_ON_TIMEOUT + active_if CYGIMP_WATCHDOG_HARDWARE + + cdl_option CYGIMP_WATCHDOG_HARDWARE { + parent CYGPKG_IO_WATCHDOG_IMPLEMENTATION + display "Hardware watchdog" + default_value 1 + implements CYGINT_WATCHDOG_IMPLEMENTATIONS + } + + cdl_component CYGPKG_DEVICES_WATCHDOG_SH_SH3_OPTIONS { + display "SH3 watchdog build options" + flavor none + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_DEVICES_WATCHDOG_SH_SH3_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_DEVICES_WATCHDOG_SH_SH3_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog device. These flags are removed from + the set of global flags if present." + } + + } +}
new file mode 100644 --- /dev/null +++ b/packages/devs/watchdog/sh/sh3/current/src/watchdog_sh3.cxx @@ -0,0 +1,132 @@ +//========================================================================== +// +// devs/watchdog/sh/sh3/watchdog_sh3.cxx +// +// Watchdog implementation for Hitachi SH CPUs +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors: jskov +// Date: 1999-09-01 +// Purpose: Watchdog class implementation +// Description: Contains an implementation of the Watchdog class for use +// with the Hitachi SH watchdog timer. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> // system configuration file +#include <pkgconf/watchdog.h> // configuration for this package +#include <pkgconf/kernel.h> // kernel config + +#include <cyg/infra/cyg_trac.h> // tracing macros +#include <cyg/kernel/instrmnt.h> // instrumentation + +#include <cyg/hal/hal_io.h> // IO register access +#include <cyg/hal/sh_regs.h> // watchdog register definitions + +#include <cyg/io/watchdog.hxx> // watchdog API + +// ------------------------------------------------------------------------- +// Constructor + +void +Cyg_Watchdog::init_hw(void) +{ + CYG_REPORT_FUNCTION(); + + // No hardware init needed. + + resolution = CYGARC_REG_WTCSR_PERIOD; + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Start the watchdog running. + +void +Cyg_Watchdog::start() +{ + CYG_REPORT_FUNCTION(); + + // Init the watchdog timer (note: 8 bit reads, 16 bit writes) + cyg_uint16 csr; + // First disable without changing other bits. + HAL_READ_UINT8(CYGARC_REG_WTCSR, csr); + csr |= CYGARC_REG_WTCSR_WRITE; + csr &= ~CYGARC_REG_WTCSR_TME; + HAL_WRITE_UINT16(CYGARC_REG_WTCSR, csr); + // Then set control bits and clear counter. + csr = (CYGARC_REG_WTCSR_WRITE + |CYGARC_REG_WTCSR_WT_IT + |CYGARC_REG_WTCSR_CKSx_SETTING); + HAL_WRITE_UINT16(CYGARC_REG_WTCSR, csr); + HAL_WRITE_UINT16(CYGARC_REG_WTCNT, CYGARC_REG_WTCNT_WRITE); + // Finally enable timer. + csr |= CYGARC_REG_WTCSR_TME; + HAL_WRITE_UINT16(CYGARC_REG_WTCSR, csr); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Reset watchdog timer. This needs to be called regularly to prevent +// the watchdog firing. + +void +Cyg_Watchdog::reset() +{ + CYG_REPORT_FUNCTION(); + + HAL_WRITE_UINT16(CYGARC_REG_WTCNT, CYGARC_REG_WTCNT_WRITE); + + CYG_REPORT_RETURN(); +} + +#if 0 +// ------------------------------------------------------------------------- +// Trigger the watchdog as if the timer had expired. + +void +Cyg_Watchdog::action_reset(void) +{ + CYG_REPORT_FUNCTION(); + + start(); + + HAL_WRITE_UINT16(CYGARC_REG_WTCNT, CYGARC_REG_WTCNT_WRITE|0xfe); + + CYG_REPORT_RETURN(); +} +#endif + +// ------------------------------------------------------------------------- +// EOF watchdog_sh3.cxx
--- a/packages/ecos.db +++ b/packages/ecos.db @@ -262,10 +262,61 @@ package CYGPKG_DEVICES_WALLCLOCK_SH3 { Hitachi SH3 CPU's RTC module." } +package CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS1742 { + alias { "Wallclock driver for Dallas 1742" devices_wallclock_ds1742 device_wallclock_ds1742 } + directory devs/wallclock/dallas/ds1742 + script wallclock_ds1742.cdl + hardware + description " + This package provides a driver implementation for + the Dallas 1742 wallclock." +} -package CYGPKG_DEVICES_WATCHDOG { - alias { "Watchdog device code" watchdog devices_watchdog device_watchdog } - directory devs/watchdog + + +package CYGPKG_DEVICES_WATCHDOG_ARM_AEB { + alias { "Watchdog driver for ARM/AEB board" devices_watchdog_aeb device_watchdog_aeb } + directory devs/watchdog/arm/aeb + script watchdog_aeb.cdl + hardware + description " + This package provides a watchdog driver implementation for the + ARM/AEB board." +} + +package CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285 { + alias { "Watchdog driver for ARM/EBSA285 board" devices_watchdog_ebsa285 device_watchdog_ebsa285 } + directory devs/watchdog/arm/ebsa285 + script watchdog_ebsa285.cdl + hardware + description " + This package provides a watchdog driver implementation for the + ARM/EBSA285 board." +} + +package CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300 { + alias { "Watchdog driver for MN10300 chip" devices_watchdog_mn10300 device_watchdog_mn10300 } + directory devs/watchdog/mn10300/mn10300 + script watchdog_mn10300.cdl + hardware + description " + This package provides a watchdog driver implementation for the + MN10300 chip." +} + +package CYGPKG_DEVICES_WATCHDOG_SH_SH3 { + alias { "Watchdog driver for the Hitachi SH3 chip" devices_watchdog_sh3 device_watchdog_sh3 } + directory devs/watchdog/sh/sh3 + script watchdog_sh3.cdl + hardware + description " + This package provides a watchdog driver implementation for the + Hitachi SH3 chip." +} + +package CYGPKG_IO_WATCHDOG { + alias { "Watchdog IO device" watchdog io_watchdog } + directory io/watchdog script watchdog.cdl description " This package provides a watchdog device." @@ -420,6 +471,17 @@ package CYGPKG_HAL_SH_EDK7708 { eCos on a Hitachi SH3 EDK7708 board." } +package CYGPKG_HAL_SH_SH7708_CQ7708 { + alias { "CqREEK Hitachi SH7708 board" hal_sh_cq sh_cq_hal } + directory hal/sh/cq7708 + script hal_sh_sh7708_cq7708.cdl + hardware + description " + The cq HAL package provides the support needed to run + eCos on a Hitachi SH3 CqREEK board." +} + + # -------------------------------------------------------------------------- # i386 packages package CYGPKG_HAL_I386 { @@ -747,6 +809,7 @@ target aeb { packages { CYGPKG_HAL_ARM CYGPKG_HAL_ARM_AEB CYGPKG_IO_SERIAL_ARM_AEB + CYGPKG_DEVICES_WATCHDOG_ARM_AEB } description " The aeb target provides the packages needed to run eCos on an ARM @@ -759,6 +822,7 @@ target ebsa285 { CYGPKG_IO_PCI CYGPKG_DEVS_ETH_ARM_EBSA285 CYGPKG_IO_SERIAL_ARM_EBSA285 + CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285 } description " The ebsa285 target provides the packages needed to run @@ -795,6 +859,7 @@ target sh7708 { CYGPKG_HAL_SH_EDK7708 CYGPKG_DEVICES_WALLCLOCK_SH3 CYGPKG_IO_SERIAL_SH_EDK7708 + CYGPKG_DEVICES_WATCHDOG_SH_SH3 } enable { CYGPKG_HAL_SH_7708 } description " @@ -802,6 +867,17 @@ target sh7708 { eCos on a Hitachi EDK/SH7708 board." } +target cq7708 { + alias { "CqREEK SH7708 Evaluation board" cq7708 } + packages { CYGPKG_HAL_SH + CYGPKG_HAL_SH_SH7708_CQ7708 + } + enable { CYGPKG_HAL_SH_7708 } + description " + The cq7708 target provides the packages needed to run + eCos on a CqREEK Hitachi SH7708 board." +} + # -------------------------------------------------------------------------- # i386 targets target linux { @@ -967,6 +1043,7 @@ target stdeval1 { CYGPKG_HAL_MN10300_AM31_STDEVAL1 CYGPKG_HAL_MN10300_AM31 CYGPKG_IO_SERIAL_MN10300 + CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300 } description " The stdeval1 target provides the packages needed to run @@ -980,6 +1057,7 @@ target stb { CYGPKG_HAL_MN10300_AM33_STB CYGPKG_HAL_MN10300_AM33 CYGPKG_IO_SERIAL_MN10300 + CYGPKG_DEVICES_WATCHDOG_MN10300_MN10300 } description " The stb target provides the packages needed to run
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/ChangeLog @@ -0,0 +1,33 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * Munging sources to matches post-1.3.1 changes. + +2000-03-30 Haruki Kashiwaya <kashiwaya@cygnus.co.jp> + + * Set up directory structure. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//===========================================================================
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/cdl/hal_sh_sh7708_cq7708.cdl @@ -0,0 +1,230 @@ +# ==================================================================== +# +# hal_sh_sh7708_cq7708.cdl +# +# CQ7708 board HAL package configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Original data: jskov +# Contributors: Haruki Kashiwaya +# Date: 1999-10-29 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_HAL_SH_SH7708_CQ7708 { + display "Hitachi SH3 CQ7708 evaluation board" + parent CYGPKG_HAL_SH + define_header hal_sh_sh7708_cq7708.h + include_dir cyg/hal + description " + The cq HAL package provides the support needed to run + eCos on a Hitachi SH3 CQ7708 board." + + compile hal_diag.c plf_stub.c plf_misc.c + + implements CYGINT_HAL_DEBUG_GDB_STUBS + implements CYGINT_HAL_DEBUG_GDB_STUBS_BREAK + + define_proc { + puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H <pkgconf/hal_sh.h>" + puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_sh_sh7708_cq7708.h>" + + puts $::cdl_header "#define CYGHWR_HAL_VSR_TABLE 0x0c000000" + } + + cdl_component CYG_HAL_STARTUP { + display "Startup type" + flavor data + legal_values {"RAM" "ROM"} + default_value {"RAM"} + no_define + define -file system.h CYG_HAL_STARTUP + description " + When targetting the CQ7708 board it is possible to build + the system for either RAM bootstrap or ROM bootstrap. + RAM bootstrap generally requires that the board + is equipped with ROMs containing a suitable ROM monitor or + equivalent software that allows GDB to download the eCos + application on to the board. The ROM bootstrap typically + requires that the eCos application be blown into EPROMs or + equivalent technology." + } + + # Real-time clock/counter specifics + cdl_component CYGNUM_HAL_RTC_CONSTANTS { + display "Real-time clock constants." + description " + Using TMU counter 0, clocked at p/4, with peripheral clock + sourced directly from the 15MHz crystal (which is the + default setup on the CQ). This means 150000/4 + oscillations in 1/100 second." + flavor none + + cdl_option CYGNUM_HAL_RTC_NUMERATOR { + display "Real-time clock numerator" + flavor data + calculated 1000000000 + } + cdl_option CYGNUM_HAL_RTC_DENOMINATOR { + display "Real-time clock denominator" + flavor data + calculated 100 + } + cdl_option CYGNUM_HAL_RTC_PERIOD { + display "Real-time clock period" + flavor data + calculated 37500 + } + } + + cdl_component CYGBLD_GLOBAL_OPTIONS { + display "Global build options" + flavor none + parent CYGPKG_NONE + description " + Global build options including control over + compiler flags, linker flags and choice of toolchain." + + + cdl_option CYGBLD_GLOBAL_COMMAND_PREFIX { + display "Global command prefix" + flavor data + no_define + default_value { "sh-elf" } + description " + This option specifies the command prefix used when + invoking the build tools." + } + + cdl_option CYGBLD_GLOBAL_CFLAGS { + display "Global compiler flags" + flavor data + no_define + default_value { CYGHWR_HAL_SH_BIGENDIAN ? "-mb -m3 -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -ggdb -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority" : "-ml -m3 -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -ggdb -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority" } + description " + This option controls the global compiler flags which + are used to compile all packages by + default. Individual packages may define + options which override these global flags." + } + + cdl_option CYGBLD_GLOBAL_LDFLAGS { + display "Global linker flags" + flavor data + no_define + default_value { CYGHWR_HAL_SH_BIGENDIAN ? "-mb -m3 -ggdb -nostdlib -Wl,--gc-sections -Wl,-static" : "-ml -m3 -ggdb -nostdlib -Wl,--gc-sections -Wl,-static" } + description " + This option controls the global linker flags. Individual + packages may define options which override these global flags." + } + + cdl_option CYGBLD_BUILD_GDB_STUBS { + display "Build GDB stub ROM image" + default_value 0 + requires { CYG_HAL_STARTUP == "ROM" } + requires CYGSEM_HAL_ROM_MONITOR + requires CYGBLD_BUILD_COMMON_GDB_STUBS + requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + requires ! CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT + requires ! CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT + requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT + requires ! CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM + no_define + description " + This option enables the building of the GDB stubs for the + board. The common HAL controls takes care of most of the + build process, but the final conversion from ELF image to + binary data is handled by the platform CDL, allowing + relocation of the data if necessary." + + make -priority 320 { + <PREFIX>/bin/gdb_module.bin : <PREFIX>/bin/gdb_module.img + $(OBJCOPY) -O binary $< $@ + } + } + } + + cdl_component CYGHWR_MEMORY_LAYOUT { + display "Memory layout" + flavor data + no_define + calculated { CYG_HAL_STARTUP == "RAM" ? "sh_sh7708_cq7708_ram" : \ + "sh_sh7708_cq7708_rom" } + + cdl_option CYGHWR_MEMORY_LAYOUT_LDI { + display "Memory layout linker script fragment" + flavor data + no_define + define -file system.h CYGHWR_MEMORY_LAYOUT_LDI + calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_sh_sh7708_cq7708_ram.ldi>" : \ + "<pkgconf/mlt_sh_sh7708_cq7708_rom.ldi>" } + } + + cdl_option CYGHWR_MEMORY_LAYOUT_H { + display "Memory layout header file" + flavor data + no_define + define -file system.h CYGHWR_MEMORY_LAYOUT_H + calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_sh_sh7708_cq7708_ram.h>" : \ + "<pkgconf/mlt_sh_sh7708_cq7708_rom.h>" } + } + } + + cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + display "Work with a ROM monitor" + flavor booldata + legal_values { "GDB_stubs" } + default_value { CYG_HAL_STARTUP == "RAM" ? "GDB_stubs" : 0 } + requires { CYG_HAL_STARTUP == "RAM" } + parent CYGPKG_HAL_ROM_MONITOR + requires !CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + description " + Support can be enabled for boot ROMs or ROM monitors which contain + GDB stubs. This support changes various eCos semantics such as + the encoding of diagnostic output, and the overriding of hardware + interrupt vectors." + } + + cdl_option CYGSEM_HAL_ROM_MONITOR { + display "Behave as a ROM monitor" + flavor bool + default_value 0 + parent CYGPKG_HAL_ROM_MONITOR + requires { CYG_HAL_STARTUP == "ROM" } + description " + Enable this option if this program is to be used as a ROM monitor, + i.e. applications will be loaded into RAM on the board, and this + ROM monitor may process exceptions or interrupts generated from the + application. This enables features such as utilizing a separate + interrupt stack when exceptions are generated." + } +}
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/hal_diag.h @@ -0,0 +1,76 @@ +#ifndef CYGONCE_HAL_HAL_DIAG_H +#define CYGONCE_HAL_HAL_DIAG_H + +//============================================================================= +// +// hal_diag.h +// +// HAL Support for Kernel Diagnostic Routines +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors:jskov +// Date: 1999-04-24 +// Purpose: HAL Support for Kernel Diagnostic Routines +// Description: Diagnostic routines for use during kernel development. +// Usage: #include <cyg/hal/hal_diag.h> +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include <pkgconf/hal.h> + +#include <cyg/infra/cyg_type.h> + +//----------------------------------------------------------------------------- +// functions implemented in hal_diag.c + +externC void hal_diag_init(void); + +externC void hal_diag_write_char(char c); + +externC void hal_diag_read_char(char *c); + +//----------------------------------------------------------------------------- + +#define HAL_DIAG_INIT() hal_diag_init() + +#define HAL_DIAG_WRITE_CHAR(_c_) hal_diag_write_char(_c_) + +#define HAL_DIAG_READ_CHAR(_c_) hal_diag_read_char(&_c_) + +//----------------------------------------------------------------------------- +// Simple LED control. +externC void hal_diag_led_on( void ); +externC void hal_diag_led_off( void ); + +//----------------------------------------------------------------------------- +// end of hal_diag.h +#endif // CYGONCE_HAL_HAL_DIAG_H
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/pkgconf/mlt_sh_sh7708_cq7708_ram.h @@ -0,0 +1,10 @@ +// eCos memory layout - Tue Apr 11 12:43:47 2000 + +// This is a generated file - do not edit + +#include <cyg/infra/cyg_type.h> +#include <stddef.h> + +#define CYGMEM_REGION_ram (0xc004000) +#define CYGMEM_REGION_ram_SIZE (0x3fc000) +#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/pkgconf/mlt_sh_sh7708_cq7708_ram.ldi @@ -0,0 +1,23 @@ +// eCos memory layout - Tue Apr 11 12:43:47 2000 + +// This is a generated file - do not edit + +MEMORY +{ + ram : ORIGIN = 0xc004000, LENGTH = 0x3fc000 +} + +SECTIONS +{ + SECTIONS_BEGIN + SECTION_vectors (ram, 0xc004000, LMA_EQ_VMA) + SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata1 (ram, ALIGN (0x8), LMA_EQ_VMA) + SECTION_rodata (ram, ALIGN (0x8), LMA_EQ_VMA) + SECTION_fixup (ram, ALIGN (0x4), LMA_EQ_VMA) + SECTION_gcc_except_table (ram, ALIGN (0x1), LMA_EQ_VMA) + SECTION_data (ram, ALIGN (0x8), LMA_EQ_VMA) + SECTION_bss (ram, ALIGN (0x10), LMA_EQ_VMA) + SECTIONS_END +}
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/pkgconf/mlt_sh_sh7708_cq7708_ram.mlt @@ -0,0 +1,11 @@ +version 0 +region ram c004000 3fc000 0 ! +section vectors 0 1 0 1 1 1 1 1 c004000 c004000 text text ! +section text 0 4 0 1 0 1 0 1 fini fini ! +section fini 0 4 0 1 0 1 0 1 rodata1 rodata1 ! +section rodata1 0 8 0 1 0 1 0 1 rodata rodata ! +section rodata 0 8 0 1 0 1 0 1 fixup fixup ! +section fixup 0 4 0 1 0 1 0 1 gcc_except_table gcc_except_table ! +section gcc_except_table 0 1 0 1 0 1 0 1 data data ! +section data 0 8 0 1 0 1 0 1 bss bss ! +section bss 0 10 0 1 0 0 0 0 !
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/pkgconf/mlt_sh_sh7708_cq7708_rom.h @@ -0,0 +1,13 @@ +// eCos memory layout - Tue Apr 11 12:40:10 2000 + +// This is a generated file - do not edit + +#include <cyg/infra/cyg_type.h> +#include <stddef.h> + +#define CYGMEM_REGION_ram (0xc000100) +#define CYGMEM_REGION_ram_SIZE (0x3fff00) +#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) +#define CYGMEM_REGION_rom (0xa0000000) +#define CYGMEM_REGION_rom_SIZE (0x8000) +#define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R)
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/pkgconf/mlt_sh_sh7708_cq7708_rom.ldi @@ -0,0 +1,24 @@ +// eCos memory layout - Tue Apr 11 12:40:10 2000 + +// This is a generated file - do not edit + +MEMORY +{ + ram : ORIGIN = 0xc000100, LENGTH = 0x3fff00 + rom : ORIGIN = 0xa0000000, LENGTH = 0x8000 +} + +SECTIONS +{ + SECTIONS_BEGIN + SECTION_vectors (rom, 0xa0000000, LMA_EQ_VMA) + SECTION_text (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_fini (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_rodata1 (rom, ALIGN (0x8), LMA_EQ_VMA) + SECTION_rodata (rom, ALIGN (0x8), LMA_EQ_VMA) + SECTION_fixup (rom, ALIGN (0x4), LMA_EQ_VMA) + SECTION_gcc_except_table (rom, ALIGN (0x1), LMA_EQ_VMA) + SECTION_data (ram, 0xc000100, FOLLOWING (.gcc_except_table)) + SECTION_bss (ram, ALIGN (0x10), LMA_EQ_VMA) + SECTIONS_END +}
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/pkgconf/mlt_sh_sh7708_cq7708_rom.mlt @@ -0,0 +1,12 @@ +version 0 +region ram c000100 3fff00 0 ! +region rom a0000000 8000 1 ! +section data 0 1 1 1 1 1 0 0 c000100 bss ! +section bss 0 10 0 1 0 0 0 0 ! +section vectors 0 1 0 1 1 1 1 1 a0000000 a0000000 text text ! +section text 0 4 0 1 0 1 0 1 fini fini ! +section fini 0 4 0 1 0 1 0 1 rodata1 rodata1 ! +section rodata1 0 8 0 1 0 1 0 1 rodata rodata ! +section rodata 0 8 0 1 0 1 0 1 fixup fixup ! +section fixup 0 4 0 1 0 1 0 1 gcc_except_table gcc_except_table ! +section gcc_except_table 0 1 0 1 0 0 0 1 data !
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/platform.inc @@ -0,0 +1,181 @@ +#ifndef CYGONCE_HAL_PLATFORM_INC +#define CYGONCE_HAL_PLATFORM_INC +##============================================================================= +## +## platform.inc +## +## SH/CQ7708 board assembler header file +## +##============================================================================= +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat 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 +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +##============================================================================= +#######DESCRIPTIONBEGIN#### +## +## Author(s): jskov +## Contributors:jskov +## Date: 2000-02-02 +## Purpose: SH/CQ7708 board definitions. +## Description: This file contains various definitions and macros that are +## useful for writing assembly code for the SH/CQ7708 board. +## Usage: +## #include <cyg/hal/platform.inc> +## ... +## +## +######DESCRIPTIONEND#### +## +##============================================================================= + +#include <pkgconf/hal.h> + +#include <cyg/hal/sh_offsets.inc> +#include <cyg/hal/sh_regs.h> + +#------------------------------------------------------------------------------ +# Hardware initialization. + + .macro hal_hardware_init + // Set up the Bus State Controller + mova BSC_settings_table,r0 + mov r0,r3 +1: mov.w @r3+,r0 // Address (or zero) + cmp/eq #0,r0 + bt 2f + mov.w @r3+,r1 // data + bra 1b + mov.w r1,@r0 // delay slot + + .align 2 + +BSC_settings_table: + # These are the settings set by the ROM Monitor. + + # BCR1: Areas 3 are SDRAM + .word CYGARC_REG_BCR1 + .word 0x0010 + # BCR2: Bus size of areas 2,4 are 8 bits + .word CYGARC_REG_BCR2 + .word 0x3ddc + # WCR1: 3 wait-state cycles inserted for all areas + .word CYGARC_REG_WCR1 + .word 0x3fff + # WCR2: cs0=8wait cs1=0wait cs2=0wait cs3=2wait cs4=4wait */ + .word CYGARC_REG_WCR2 + .word 0x0246 + # MCR: dram setting 10 bit + .word CYGARC_REG_MCR + .word 0x0074 + # RTCSR: refresh timer control + .word CYGARC_REG_RTCSR + .word (0xa500 | 0x0010) + # RTCOR: refresh time constant + .word CYGARC_REG_RTCOR + .word (0xa500 | 0x003a) + + # Table end + .word 0 + + .align 2 +2: + .endm + +#------------------------------------------------------------------------------ +# Monitor initialization. + +#ifndef CYGPKG_HAL_SH_MON_DEFINED + +#if defined(CYG_HAL_STARTUP_ROM) || \ + ( defined(CYG_HAL_STARTUP_RAM) && \ + !defined(CYGSEM_HAL_USE_ROM_MONITOR)) + + # If we are starting up from ROM, or we are starting in + # RAM and NOT using a ROM monitor, initialize the VSR table. + + .macro hal_mon_init + mov.l $_hal_vsr_table_p,r3 + # Write exception vectors + mov.l $_cyg_hal_default_exception_vsr_p,r4 + mov #CYGNUM_HAL_VSR_EXCEPTION_COUNT,r5 +1: mov.l r4,@r3 + add #4,r3 + dt r5 + bf 1b + # Write interrupt vector + mov.l $_cyg_hal_default_interrupt_vsr_p,r4 + mov.l r4,@r3 + bra 2f + nop + .align 2 + +$_cyg_hal_default_exception_vsr_p: + .long _cyg_hal_default_exception_vsr +$_cyg_hal_default_interrupt_vsr_p: + .long _cyg_hal_default_interrupt_vsr + + .extern _hal_vsr_table +$_hal_vsr_table_p: + .long _hal_vsr_table + +2: + .endm + +#elif defined(CYG_HAL_STARTUP_RAM) && defined(CYGSEM_HAL_USE_ROM_MONITOR) + + # Initialize the VSR table entries + # We only take control of the interrupt vector, + # the rest are left to the ROM for now... + + .macro hal_mon_init + # Write interrupt vector + mov.l $_hal_vsr_table_p,r3 + mov.l $_cyg_hal_default_interrupt_vsr_p,r4 + mov.l r4,@r3 + bra 2f + nop + .align 2 + +$_cyg_hal_default_interrupt_vsr_p: + .long _cyg_hal_default_interrupt_vsr + + .extern _hal_vsr_table +$_hal_vsr_table_p: + .long _hal_vsr_table+CYGNUM_HAL_VECTOR_INTERRUPT*4 + +2: + .endm + +#else + + .macro hal_mon_init + .endm + +#endif + + +#define CYGPKG_HAL_SH_MON_DEFINED + +#endif // CYGPKG_HAL_SH_MON_DEFINED + +#endif // CYGONCE_HAL_PLATFORM_INC
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/include/plf_stub.h @@ -0,0 +1,96 @@ +#ifndef CYGONCE_HAL_PLF_STUB_H +#define CYGONCE_HAL_PLF_STUB_H + +//============================================================================= +// +// plf_stub.h +// +// Platform header for GDB stub support. +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors:jskov +// Date: 1999-05-18 +// Purpose: Platform HAL stub support for Hitachi/CQ boards. +// Usage: #include <cyg/hal/plf_stub.h> +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include <pkgconf/system.h> +#include <pkgconf/hal.h> + +#ifdef CYGPKG_IO_SERIAL +#include <pkgconf/io_serial.h> +#endif + +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + +#include <cyg/infra/cyg_type.h> // CYG_UNUSED_PARAM, externC + +#include <cyg/hal/sh_stub.h> // architecture stub support + +#include <cyg/hal/hal_diag.h> // hal_diag_led_on + +//---------------------------------------------------------------------------- +// Define serial stuff. +externC void hal_sci_stub_init_serial( void ); +externC int hal_sci_stub_get_char( void ); +externC void hal_sci_stub_put_char( int c ); +externC int hal_sci_stub_interruptible( int state ); +externC void hal_sci_stub_init_break_irq( void ); + +#define HAL_STUB_PLATFORM_INIT_SERIAL() hal_sci_stub_init_serial() +#define HAL_STUB_PLATFORM_GET_CHAR() hal_sci_stub_get_char() +#define HAL_STUB_PLATFORM_PUT_CHAR(c) hal_sci_stub_put_char((c)) +#define HAL_STUB_PLATFORM_SET_BAUD_RATE(baud) CYG_UNUSED_PARAM(int, (baud)) +#define HAL_STUB_PLATFORM_INTERRUPTIBLE (&hal_sci_stub_interruptible) +#define HAL_STUB_PLATFORM_INIT_BREAK_IRQ() hal_sci_stub_init_break_irq() + +//---------------------------------------------------------------------------- +// Stub initializer. +#ifdef CYGSEM_HAL_ROM_MONITOR +# define HAL_STUB_PLATFORM_INIT() hal_diag_led_on() +#else +# define HAL_STUB_PLATFORM_INIT() CYG_EMPTY_STATEMENT +#endif + +//---------------------------------------------------------------------------- +// Reset. +// Block interrupts and cause an exception. This forces a reset. +#define HAL_STUB_PLATFORM_RESET() \ + asm volatile ("ldc %0,sr;trapa #0x00;" : : "r" (CYGARC_REG_SR_BL)) + + +#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + +//----------------------------------------------------------------------------- +#endif // CYGONCE_HAL_PLF_STUB_H +// End of plf_stub.h
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/misc/mkcqrom.c @@ -0,0 +1,70 @@ +/* Split ROM data Program for CqREEK SH-3 (Thanks Yamanaka-san) */ +/* Nihon Cygnus Solutions KASHIWAYA Haruki '00-4-13 */ + +/* This program separate ROM data for one ROM socket. + The cq board has two ROM sockets, and those bus size can + switch to 8bit or 16bit with JP6. + If your program is smaller than 32kByte, you can use + a 256k bit ROM with 8bit bus mode. + However, the board curcuit connection is peculiar. + A0 is connected to A14 in 8bit bus mode (See the curcuit diagram), + this mean's all odd data are assigned from 0x4000 offset. + You must use this program and separate ROM data when you use + a 256k bit ROM with 8bit bus mode. + + If your program is bigger than 32kByte, simply, you can use + two 256k bit(or bigger) ROM with 16bit bus mode. + You do *not* need to use this program. + (Details, separate ROM data to odd and even, and write each data to + each ROMs, and attach odd's ROM to IC4, even's ROM to IC8.) + +*/ + +#include <stdio.h> +#include <errno.h> + +#define ROMSIZE (32 * 1024) + +main(int argc, char **argv) +{ + FILE *fpr, *fpw; + int i, c; + char *s, *p; + + if(argc != 3) { + printf("Usage: mkcqrom <input-filename> <output-filename>\n Please see comments in mkcqrom.c.\n"); + exit(1); + } + + p = (char *)malloc(ROMSIZE); + if(p == NULL) { + printf("malloc error\n"); + exit(1); + } + fpr = fopen(*++argv, "rb"); + if(fpr == NULL) { + printf("open error %s %d\n", *argv, errno); + exit(1); + } + memset(p, 0xff, ROMSIZE); + + /* split even data to 0x4000 offset (A0 is assigned to A14) */ + i = 0; + while(1) { + c = getc(fpr); + if(c == EOF) break; + s = p + (i / 2) + (i % 2) * 0x4000; + *s = (char)c; + i++; + } + fclose(fpr); + + fpw = fopen(*++argv, "wb"); + if(fpw == NULL) { + printf("open error %s %d\n", *argv, errno); + exit(1); + } + fwrite(p, ROMSIZE, sizeof(char), fpw); + fclose(fpw); +} + \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/src/hal_diag.c @@ -0,0 +1,189 @@ +//============================================================================= +// +// hal_diag.c +// +// HAL diagnostic output code +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg, jskov +// Contributors: nickg, jskov +// Date: 1999-03-23 +// Purpose: HAL diagnostic output +// Description: Implementations of HAL diagnostic output support. +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include <pkgconf/hal.h> + +#include <cyg/hal/hal_diag.h> // our header. + +#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) +#include <cyg/hal/hal_stub.h> // hal_output_gdb_string +#endif + +#include <cyg/infra/cyg_type.h> // base types, externC +#include <cyg/hal/hal_io.h> // IO macros +#include <cyg/hal/hal_intr.h> // Interrupt macros + +#include <cyg/hal/sh_sci.inl> + +//----------------------------------------------------------------------------- + +#if defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs) + +#define CYG_HAL_DIAG_GDB + +#elif defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) + +#define CYG_HAL_DIAG_GDB + +#endif + +//----------------------------------------------------------------------------- + +void hal_diag_init(void) +{ + hal_sci_init_serial(); +} + +void +hal_diag_write_char_serial( char c ) +{ + hal_sci_put_char(c); +} + +void +hal_diag_read_char(char *c) +{ + *c = (char) hal_sci_get_char(); +} + +externC cyg_bool cyg_hal_is_break(char *buf, int size); +externC void cyg_hal_user_break(CYG_ADDRWORD *regs); + +// Packet function +void +hal_diag_write_char(char c) +{ +#ifdef CYG_HAL_DIAG_GDB + static char line[100]; + static int pos = 0; + + // No need to send CRs + if( c == '\r' ) return; + + line[pos++] = c; + + if( c == '\n' || pos == sizeof(line) ) + { + CYG_INTERRUPT_STATE old; + + // Disable interrupts. This prevents GDB trying to interrupt us + // while we are in the middle of sending a packet. The serial + // receive interrupt will be seen when we re-enable interrupts + // later. + +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old); +#else + HAL_DISABLE_INTERRUPTS(old); +#endif + + while(1) + { + char c1; + static char hex[] = "0123456789ABCDEF"; + cyg_uint8 csum = 0; + int i; + + hal_diag_write_char_serial('$'); + hal_diag_write_char_serial('O'); + csum += 'O'; + for( i = 0; i < pos; i++ ) + { + char ch = line[i]; + char h = hex[(ch>>4)&0xF]; + char l = hex[ch&0xF]; + hal_diag_write_char_serial(h); + hal_diag_write_char_serial(l); + csum += h; + csum += l; + } + hal_diag_write_char_serial('#'); + hal_diag_write_char_serial(hex[(csum>>4)&0xF]); + hal_diag_write_char_serial(hex[csum&0xF]); + + // Wait for the ACK character '+' from GDB here and handle + // receiving a ^C instead. + hal_diag_read_char(&c1); + + if( c1 == '+' ) + break; // a good acknowledge + + // Check for user break. + if( cyg_hal_is_break( &c1, 1 ) ) + cyg_hal_user_break( NULL ); + + // otherwise, loop round again + } + + pos = 0; + + // And re-enable interrupts +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old); +#else + HAL_RESTORE_INTERRUPTS(old); +#endif + } +#else // CYG_HAL_DIAG_GDB + hal_diag_write_char_serial(c); +#endif +} + +//----------------------------------------------------------------------------- +// Led control +#define LED 0xa8000000 + +void +hal_diag_led_on( void ) +{ + HAL_WRITE_UINT8(LED, 0x18); +} + +void +hal_diag_led_off( void ) +{ + HAL_WRITE_UINT8(LED, 0); +} + +//----------------------------------------------------------------------------- +// End of hal_diag.c
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/src/plf_misc.c @@ -0,0 +1,102 @@ +//========================================================================== +// +// plf_misc.c +// +// HAL platform miscellaneous functions +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors: jskov,nickg, jlarmour +// Date: 1999-10-13 +// Purpose: HAL miscellaneous functions +// Description: This file contains miscellaneous functions provided by the +// HAL. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/hal.h> + +#include <cyg/infra/cyg_type.h> // Base types + +#include <cyg/hal/hal_arch.h> // architectural definitions + +#include <cyg/hal/hal_intr.h> // Interrupt handling + +#include <cyg/hal/hal_cache.h> // Cache handling + +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS +#include <cyg/hal/hal_stub.h> // stub functionality +#endif + +//-------------------------------------------------------------------------- +// Functions to support the detection and execution of a user provoked +// program break. These are usually called from interrupt routines. + +cyg_bool +cyg_hal_is_break(char *buf, int size) +{ + while( size ) + if( buf[--size] == 0x03 ) return true; + + return false; +} + +void +cyg_hal_user_break( CYG_ADDRWORD *regs ) +{ +#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT + HAL_SavedRegisters *__sreg = (HAL_SavedRegisters *)regs; + target_register_t __pc; + + if (__sreg) + __pc = (target_register_t) __sreg->pc; + else + __pc = (target_register_t) &&safe_breakpoint; + + // Note: This would be better for the else case but doesn't work + // at the moment. CR: 101357 + // __pc = (target_register_t) __builtin_return_address(0); + + cyg_hal_gdb_interrupt (__pc); + + safe_breakpoint: +#elif defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs) + + // Note: Need to communicate to the ROM stub instead + HAL_BREAKPOINT(breakinst); + +#else + + HAL_BREAKPOINT(breakinst); + +#endif + +}
new file mode 100644 --- /dev/null +++ b/packages/hal/sh/cq7708/current/src/plf_stub.c @@ -0,0 +1,58 @@ +//============================================================================= +// +// plf_stub.c +// +// Platform specific code for GDB stub support. +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors:jskov +// Date: 1999-05-18 +// Purpose: Platform specific code for GDB stub support. +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include <pkgconf/hal.h> + +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + +#include <cyg/hal/hal_stub.h> + +//---------------------------------------------------------------------------- +// Include the serial driver. +#define CYG_SCI_STUB +#define CYG_SCI_PUBLIC +#define CYG_SCI_NAME_PREFIX hal_sci_stub_ +#include <cyg/hal/sh_sci.inl> + +#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS +//----------------------------------------------------------------------------- +// End of plf_stub.c
--- a/packages/io/wallclock/current/ChangeLog +++ b/packages/io/wallclock/current/ChangeLog @@ -1,3 +1,25 @@ +2000-05-30 Jesper Skov <jskov@redhat.com> + + * include/wallclock/wallclock.inl (_simple_mktime): Replaced + expression with algorithm. + + * tests/wallclock2.cxx: Test wallclock's conversion functions for + Y2K safety. + +2000-05-26 Jesper Skov <jskov@redhat.com> + + * include/wallclock/wallclock.inl: + (_simple_mkdate): Rewritten. + + * src/wallclock.cxx: + * include/wallclock.hxx: low-level driver may need init call also + in set-get mode. Split helper functions out in new .inl header. + + * cdl/wallclock.cdl: Added set-get/init-get option. + + * tests/wallclock2.cxx: Allow HW calls to take one second. + * tests/wallclock.cxx: Don't set clock. + 2000-04-19 Jesper Skov <jskov@cygnus.co.uk> * src/wallclock.cxx: Construct after kernel RTC since the
--- a/packages/io/wallclock/current/cdl/wallclock.cdl +++ b/packages/io/wallclock/current/cdl/wallclock.cdl @@ -43,6 +43,7 @@ cdl_package CYGPKG_IO_WALLCLOCK { display "Wallclock device" include_dir cyg/io + define_header wallclock.h description " The wallclock device provides real time stamps, as opposed @@ -65,6 +66,34 @@ cdl_package CYGPKG_IO_WALLCLOCK { requires 1 == CYGINT_WALLCLOCK_IMPLEMENTATIONS } + cdl_interface CYGINT_WALLCLOCK_SET_GET_MODE_SUPPORTED { + display "Wallclock driver supports set/get mode" + no_define + } + + cdl_option CYGSEM_WALLCLOCK_MODE { + display "Wallclock mode" + flavor data + legal_values { "init_get" "set_get" } + default_value { CYGINT_WALLCLOCK_SET_GET_MODE_SUPPORTED ? \ + "set_get" : "init_get" } + requires { CYGINT_WALLCLOCK_SET_GET_MODE_SUPPORTED || \ + CYGSEM_WALLCLOCK_MODE == "init_get" } + no_define + description " + The wallclock driver can be used in one of two + modes. Set/get mode allows time to be kept during power + off (assuming there's a battery backed clock). Init/get + mode is slightly smaller and can be used when there is no + battery backed clock - in this mode time 0 is the time of + the board power up." + } + + cdl_option CYGSEM_WALLCLOCK_SET_GET_MODE { + display "Wallclock set/get mode" + calculated { CYGSEM_WALLCLOCK_MODE == "set_get" ? 1 : 0 } + } + cdl_component CYGPKG_IO_WALLCLOCK_IMPLEMENTATION { display "Wallclock implementation" flavor none
--- a/packages/io/wallclock/current/include/wallclock.hxx +++ b/packages/io/wallclock/current/include/wallclock.hxx @@ -85,10 +85,9 @@ private: // epoch base is factored out, so the driver can use any base // desired (see the emulated device). -#ifndef CYGSEM_WALLCLOCK_SET_GET_MODE - // Called to initialize the hardware clock to a known sane state. + // Called to initialize the hardware clock to a known sane state, or + // simply to make sure it can be accessed in set-get mode. void init_hw_seconds( void ); -#endif // Returns the number of seconds elapsed since 1970-01-01 00:00:00. // (or any desired epoch when in init-get mode) @@ -100,47 +99,5 @@ private: #endif }; -#ifdef __CYGBLD_DRIVER_PRIVATE - -// ------------------------------------------------------------------------- -// Some helper functions - -// This function is from the Linux kernel. -// -// Converts Gregorian date to seconds since 1970-01-01 00:00:00. -// Assumes input in normal date format, i.e. 1980-12-31 23:59:59 -// => year=1980, mon=12, day=31, hour=23, min=59, sec=59. -// -// This algorithm was first published by Gauss (I think). -// -// WARNING: this function will overflow on 2106-02-07 06:28:16 on -// machines were long is 32-bit! (However, as time_t is signed, we -// will already get problems at other places on 2038-01-19 03:14:08) -static cyg_uint32 -_simple_mktime(cyg_uint32 year, cyg_uint32 mon, - cyg_uint32 day, cyg_uint32 hour, - cyg_uint32 min, cyg_uint32 sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (cyg_uint32)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - -//----------------------------------------------------------------------------- -// BCD helper macros -#define TO_BCD(x) (((x/10)<<4) | (x%10)) -#define TO_DEC(x) (((x>>4)*10) + (x&0xf)) - - -// ------------------------------------------------------------------------- -#endif // __CYGBLD_DRIVER_PRIVATE - #endif // ifndef CYGONCE_DEVS_WALLCLOCK_HXX // EOF wallclock.hxx
new file mode 100644 --- /dev/null +++ b/packages/io/wallclock/current/include/wallclock/wallclock.inl @@ -0,0 +1,130 @@ +#ifndef CYGONCE_IO_WALLCLOCK_INL +#define CYGONCE_IO_WALLCLOCK_INL + +//========================================================================== +// +// wallclock.inl +// +// Wallclock internal helper functions +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors: jskov +// Date: 2000-05-26 +// Purpose: Wall Clock internal helper functions +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <cyg/infra/cyg_type.h> + +// ------------------------------------------------------------------------- +// Some helper functions + +#define is_leap(_y_) (((0==(_y_)%4 && 0!=(_y_)%100) || 0==(_y_)%400) ? 1 : 0) +#define year_days(_y_) (is_leap(_y_) ? 366 : 365) + +static cyg_int32 days_per_month[2][12] = { + {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} +}; + +#ifndef time_t +#define time_t cyg_uint32 +#endif + +static time_t +_simple_mktime(cyg_uint32 year, cyg_uint32 mon, + cyg_uint32 day, cyg_uint32 hour, + cyg_uint32 min, cyg_uint32 sec) +{ + time_t secs; + cyg_uint32 y, m, days; + + // Number of days due to years + days = 0; + for (y = 1970; y < year; y++) + days += year_days(y); + + // Due to months + for (m = 0; m < mon-1; m++) + days += days_per_month[is_leap(year)][m]; + // Add days + days += day - 1; + + // Add hours, minutes, and seconds + secs = ((days * 24 + hour) * 60 + min) * 60 + sec; + + return secs; +} + +#ifdef CYGSEM_WALLCLOCK_SET_GET_MODE + + +static void +_simple_mkdate(time_t time, + cyg_uint32* year, cyg_uint32* mon, + cyg_uint32* day, cyg_uint32* hour, + cyg_uint32* min, cyg_uint32* sec) +{ + cyg_int32 days, hms, y, m, *dpm; + + days = (cyg_int32) (time / (24*60*60)); + hms = (cyg_int32) (time % (24*60*60)); + + // Nothing fancy about the time - no leap year magic involved + *sec = hms % 60; + *min = (hms % (60*60)) / 60; + *hour = hms / 60*60; + + // Find year + for (y = 1970; days >= year_days(y); y++) + days -= year_days(y); + *year = y; + dpm = &days_per_month[is_leap(y)][0]; + + // Find month + for (m = 0; days >= dpm[m]; m++) + days -= dpm[m]; + m++; + *mon = m; + + *day = days+1; +} + +#endif + +//----------------------------------------------------------------------------- +// BCD helper macros +#define TO_BCD(x) (((x/10)<<4) | (x%10)) +#define TO_DEC(x) (((x>>4)*10) + (x&0xf)) + +#endif // ifndef CYGONCE_DEVS_WALLCLOCK_INL +// EOF wallclock.inl
--- a/packages/io/wallclock/current/src/wallclock.cxx +++ b/packages/io/wallclock/current/src/wallclock.cxx @@ -89,11 +89,9 @@ Cyg_WallClock::Cyg_WallClock() // install instance pointer wallclock = &wallclock_instance; -#ifndef CYGSEM_WALLCLOCK_SET_GET_MODE - // Since set_hw_seconds is not going to write to the hardware - // clock, initialize it to a sane state now. + // Always allow low-level driver to initialize clock, even though it + // may not be necessary for set-get mode. init_hw_seconds(); -#endif } //-----------------------------------------------------------------------------
--- a/packages/io/wallclock/current/tests/wallclock.cxx +++ b/packages/io/wallclock/current/tests/wallclock.cxx @@ -51,7 +51,7 @@ #include <cyg/kernel/diag.h> -#include <cyg/io/wallclock.hxx> +#include <cyg/io/wallclock.hxx> // The WallClock API #include <cyg/infra/testcase.h> @@ -78,8 +78,6 @@ char thread[sizeof(Cyg_Thread)]; Cyg_Thread *th; -#define EPOCH 900000000U - // MN10300 sim takes 1min15secs to do one loop on 300MHz PII. #define LOOPS_SIM 2 #define LOOPS_HW 10 @@ -93,6 +91,7 @@ cyg_tick_count one_sec; void wallclock_thread( CYG_ADDRWORD id ) { + cyg_uint32 base; cyg_uint32 wtime; cyg_tick_count ticks; @@ -100,15 +99,25 @@ void wallclock_thread( CYG_ADDRWORD id ) // Check clock only every other second since the call itself may // take about a second. - Cyg_WallClock::wallclock->set_current_time( EPOCH ); + + // Start by synchronizing to next wallclock increment, then wait for + // a bit to get away from the exact time of the increment (or minor + // inaccuracies in the HW clock will cause failures). + wtime = Cyg_WallClock::wallclock->get_current_time(); + do { + base = Cyg_WallClock::wallclock->get_current_time(); + } while (base == wtime); + th->delay( one_sec/10 ); + for( int i = 0; i < loops; i += 2 ) { // Make a note of the time ticks = Cyg_Clock::real_time_clock->current_value(); wtime = Cyg_WallClock::wallclock->get_current_time(); - if(wtime != EPOCH+i) + if(wtime != base+i) { + diag_printf("offset %d, read %d, expected %d\n", i, wtime, base+i); CYG_TEST_FAIL_FINISH( "Clock out of sync" ); } @@ -118,21 +127,30 @@ void wallclock_thread( CYG_ADDRWORD id ) th->delay( 2*one_sec - ticks ); } - + if ( ! cyg_test_is_simulator ) { CYG_TEST_INFO("Tick output. Two seconds between each output."); - Cyg_WallClock::wallclock->set_current_time( EPOCH ); + // Start by synchronizing to next wallclock increment, then + // wait for a bit to get away from the exact time of the + // increment (or minor inaccuracies in the HW clock will cause + // failures). + wtime = Cyg_WallClock::wallclock->get_current_time(); + do { + base = Cyg_WallClock::wallclock->get_current_time(); + } while (base == wtime); + th->delay( one_sec/10 ); + for( int i = 0; i < loops; i += 2 ) { // Make a note of the time ticks = Cyg_Clock::real_time_clock->current_value(); wtime = Cyg_WallClock::wallclock->get_current_time(); - if(wtime != EPOCH+i) + if(wtime != base+i) { diag_printf("wallclock drift: saw %d expected %d\n", - wtime, EPOCH+i); + wtime, base+i); } CYG_TEST_STILL_ALIVE(i, "2xtick...");
--- a/packages/io/wallclock/current/tests/wallclock2.cxx +++ b/packages/io/wallclock/current/tests/wallclock2.cxx @@ -52,7 +52,7 @@ #if defined(CYGSEM_LIBC_TIME_CLOCK_WORKING) #include <time.h> -#include <cyg/io/wallclock.hxx> +#include <cyg/io/wallclock.hxx> // The WallClock API // ------------------------------------------------------------------------- @@ -60,7 +60,7 @@ externC int main (void ) { - time_t now, test; + time_t now, test, test2; CYG_TEST_INIT(); @@ -76,9 +76,18 @@ main (void ) // Check that set/get works Cyg_WallClock::wallclock->set_current_time( 0 ); test = (time_t) Cyg_WallClock::wallclock->get_current_time(); + // 2000.03.01 00:00:00 UTC + Cyg_WallClock::wallclock->set_current_time( 951868800 ); + test2 = (time_t) Cyg_WallClock::wallclock->get_current_time(); + // Should test 2100 and 2400 leap year calculations as well, but + // these would overflow with today's time_t. Cyg_WallClock::wallclock->set_current_time( now ); - CYG_TEST_PASS_FAIL(0 == test, "Can set WallClock to epoch"); - + CYG_TEST_PASS_FAIL(2 >= test, // each operation can take one second + "Can set WallClock to epoch"); + CYG_TEST_PASS_FAIL(951868800+2 > test2 && + 951868800 <= test2, + "WallClock date conversion Y2K safe"); + // Test that the wallclock and libc use same epoch. test = (time_t) 0; CYG_TEST_PASS_FAIL(!strcmp(ctime(&test), "Thu Jan 01 00:00:00 1970\n"),
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/ChangeLog @@ -0,0 +1,284 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * tests/watchdog.cxx: fix comment. + + * tests/watchdog2.cxx: + * cdl/watchdog.cdl: + watchdog2 tests timeout is not too fast (safe for both types of + watchdog semantics). + + * tests/watchdog_reset.cxx: + * src/emulate.cxx: + * include/watchdog.hxx: + Fixed compile errors. + + * cdl/watchdog.cdl: Only build test if the watchdog does not reset + the board. + Added build option for interactive reset test. + +2000-05-30 Jesper Skov <jskov@redhat.com> + + * tests/watchdog_reset.cxx: + * tests/watchdog.cxx: + * src/emulate.cxx: + * src/watchdog.cxx: + * include/watchdog.hxx: + * cdl/watchdog.cdl: + Moved to io/watchdog. + +2000-01-31 Simon FitzMaurice <sdf@cygnus.co.uk> + * cdl/watchdog.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice <sdf@cygnus.co.uk> + * cdl/watchdog.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson <hmt@cygnus.co.uk> + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-03 John Dallaway <jld@cygnus.co.uk> + + * cdl/watchdog.cdl: Define build options. + +1999-09-09 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * include/pkgconf/watchdog.h: Rename CYGPKG_HAL_MN10300_SIM to + CYGPKG_HAL_MN10300_AM31_SIM + +1999-09-07 Jesper Skov <jskov@cygnus.co.uk> + + * include/pkgconf/watchdog.h: + * src/aeb1.cxx: [added] + * src/PKGconf.mak: + * tests/PKGconf.mak: + Added watchdog driver for AEB-1 board. + +1999-09-07 Jesper Skov <jskov@cygnus.co.uk> + PRs 20427, 20428, 20432 + * tests/PKGconf.mak (TESTS): Clear on targets that reset the + board. + +1999-09-01 Jesper Skov <jskov@cygnus.co.uk> + * cdl/watchdog.cdl: + * include/pkgconf/watchdog.h: + * src/PKGconf.mak: + * src/sh.cxx: + Added watchdog driver for SH. + +1999-08-27 Jesper Skov <jskov@cygnus.co.uk> + * include/pkgconf/watchdog.h: + * src/PKGconf.mak: + * src/ebsa285.cxx: + Added watchdog device for 21285. + + * tests/watchdog_reset.cxx: + * tests/PKGconf.mak (TESTS): + Added test for watchdog devices that reset the board. + +1999-08-24 Nick Garnett <nickg@cygnus.co.uk> + + * src/mn10300.cxx: Turn watchdog off in Cyg_Watchdog::trigger() to + prevent it repeating. + +1999-08-18 Nick Garnett <nickg@cygnus.co.uk> + + * include/pkgconf/watchdog.h: Made test for use of a non-emulated + watchdog more generic for MN10300 targets. + + * src/emulate.cxx: + * include/watchdog.hxx (class Cyg_Watchdog): + Added get_resolution() to return maximum time, in nanoseconds, + between calls to reset(). + + * tests/watchdog.cxx: + Modified to use the value returned from get_resolution() to + control the timing of reset() calls. + + * src/mn10300.cxx: + Added support for AM33 variant. Since the AM33 can only provide a + maximum watchdog cycle time of 621ms, this has motiviated the + addition of the get_resolution() call described above. + +1999-07-14 Jesper Skov <jskov@cygnus.co.uk> + + * src/mn10300.cxx: + * src/emulate.cxx: + Include pkgconf/kernel.h. + +1999-04-21 Gary Thomas <gthomas@cygnus.co.uk> + + * tests/watchdog.cxx: The 'keep alive' message was interfering + with the watchdog measurement. Some rearrangement fixes this. + +1999-04-20 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * tests/watchdog.cxx: + Restrict number of loops, and number of seconds per loop when we + detect we are in a simulator. Do this instead of changing the + value of one_sec in the simulator, since this invalidates the test + somewhat. + Output occasional messages to reassure the user that the test is + still running. + Fix for PR 19865 + +1999-04-14 Jesper Skov <jskov@cygnus.co.uk> + + * tests/watchdog.cxx (cyg_start): Added workaround for PR 17974. + +1999-04-12 John Dallaway <jld@cygnus.co.uk> + + * include/pkgconf/watchdog.h: Add cdl_package doc attribute. + +1999-04-08 Gary Thomas <gthomas@cygnus.co.uk> + + * tests/watchdog.cxx: PR 19773 - Loop over first test for better + coverage. Print some additional messages, especially if failure + detected. Reset watchdog after installing handler. + (watchdog_thread): Capture fail time before printing message. + +1999-04-07 Jesper Skov <jskov@cygnus.co.uk> + PR 19667 + * tests/watchdog.cxx (cyg_start): + Changed to use the new Cyg_Thread constructor. + +1999-03-22 Hugo Tyson <hmt@cygnus.co.uk> + + * tests/watchdog.cxx: + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-12 Hugo Tyson <hmt@cygnus.co.uk> + + * tests/watchdog.cxx: + Deal with CYGNUM_HAL_MINIMUM_STACK_SIZE requirement. + +1999-03-04 Gary Thomas <gthomas@cygnus.co.uk> + + * include/pkgconf/watchdog.h: Make package stand-alone (no "DEVICES") + +1999-02-20 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * src/mn10300.cxx: + Change CYG_VECTOR_WATCHDOG to CYGNUM_HAL_INTERRUPT_WATCHDOG in line + with HAL changes. + General QA improvements + +1999-02-03 Jesper Skov <jskov@cygnus.co.uk> + PR 19034 + * tests/watchdog.cxx: Reduced run-time on SIM. + +1998-12-17 Jesper Skov <jskov@cygnus.co.uk> + + * tests/watchdog.cxx: Do NOP test if kernel RTC disabled. + +1998-10-23 Jesper Skov <jskov@cygnus.co.uk> + + * tests/watchdog.cxx (cyg_start): Reduce test time on TX39 SIM. + + * include/pkgconf/watchdog.h: Use emulatation code for MN10300 + SIM. + +Tue Oct 20 15:52:46 1998 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * src/mn10300.cxx: + Include <pkgconf/watchdog.h> so that we get CYGIMP_WATCHDOG_EMULATE + defined appropriately + + * src/PKGconf.mak: + Remove unnecessary override of PKGCONF_CXXFLAGS + +1998-09-26 Bart Veer <bartv@cygnus.co.uk> + + * include/pkgconf/watchdog.h: + PR17501: When using the emulation there is a requirement on the + kernel clock. This has been added to the configuration data. The + mn10300 hardware implementation does not have this requirement, + but there is no easy way to express this at present. + +1998-09-12 Bart Veer <bartv@cygnus.co.uk> + + * include/pkgconf/watchdog.h: + Added missing descriptions (PR 17184) + +1998-09-02 Bart Veer <bartv@cygnus.co.uk> + + * include/pkgconf/watchdog.h: + Added minimal configuration data. + +1998-09-01 Nick Garnett <nickg@cygnus.co.uk> + + * src/mn10300.cxx: + Added include for <cyg/kernel/sched.inl>, for scheduler lock and + unlock functions. + + * src/PKGconf.mak: + Added mn10300.cxx to COMPILE for mn10300. + + * include/pkgconf/watchdog.h: + Default to using real hardware on MN10300. + +Fri Aug 28 09:42:26 1998 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * tests/watchdog.cxx: + Rename int main(argc, argv) to void cyg_start( void ) under the + new entry point system. Therefore also remove return code. + +Tue Aug 18 16:51:24 1998 Jonathan Larmour <jlarmour@cygnus.co.uk> + + * tests/watchdog.cxx: + Move inclusion of thread.inl to before sched.hxx to prevent inline + warnings + +1998-08-14 Nick Garnett <nickg@cygnus.co.uk> + + * src/emulate.cxx: + Added include for cyg/kernel/sched.inl. + +1998-07-31 Nick Garnett <nickg@cygnus.co.uk> + + * src/PKGconf.mak: + Added mn10300.cxx to COMPILE list. + + * src/mn10300.cxx: + Completed implementation using MN10300 watchdog timer. + + * include/watchdog.hxx: + Renamed 'register' functions to 'install'. Added install() and + uninstall() to Cyg_Watchdog_Action class. + + * include/pkgconf/watchdog.h: + Added this file to contain watchdog config options. + +1998-07-29 Nick Garnett <nickg@cygnus.co.uk> + + * include/watchdog.hxx, src/emulate.cxx: + Created initial versions of watchdog device. + +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND####
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/cdl/watchdog.cdl @@ -0,0 +1,168 @@ +# ==================================================================== +# +# watchdog.cdl +# +# eCos watchdog configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# 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 Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Original data: nickg +# Contributors: +# Date: 1999-07-13 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_IO_WATCHDOG { + display "Watchdog IO device" + define_header watchdog.h + include_dir cyg/io + description " + The watchdog IO device allows applications to make use of a + timer facility. Depending on the underlying hardware device + driver, a watchdog timeout will either cause a board reset + or an action routine to be called. The application must call + the watchdog reset function at regular intervals, or else the + device will timeout. The assumption is that the watchdog timer + should never trigger unless there has been a serious fault in + either the hardware or the software." + + compile watchdog.cxx + + cdl_interface CYGINT_WATCHDOG_HW_IMPLEMENTATIONS { + display "Number of watchdog hardware implementations" + no_define + } + + cdl_interface CYGINT_WATCHDOG_IMPLEMENTATIONS { + display "Number of watchdog implementations" + no_define + requires 1 == CYGINT_WATCHDOG_IMPLEMENTATIONS + } + + cdl_component CYGPKG_IO_WATCHDOG_IMPLEMENTATION { + display "Watchdog implementation" + flavor none + no_define + description "Implementations of the watchdog device." + + cdl_option CYGPKG_WATCHDOG_EMULATE { + default_value { 0 == CYGINT_WATCHDOG_HW_IMPLEMENTATIONS } + display "Watchdog emulator" + implements CYGINT_WATCHDOG_IMPLEMENTATIONS + requires CYGVAR_KERNEL_COUNTERS_CLOCK + compile emulate.cxx + description " + When this option is enabled, a watchdog device will be + emulated using the kernel real-time clock." + } + + cdl_option CYGIMP_WATCHDOG_NONE { + display "No wallclock" + default_value 0 + implements CYGINT_WATCHDOG_IMPLEMENTATIONS + description "Disables the watchdog." + } + } + + cdl_interface CYGINT_WATCHDOG_RESETS_ON_TIMEOUT { + display "Set if device causes a reset on timeout" + no_define + } + + cdl_option CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT { + display "Set if device causes a reset on timeout" + calculated { CYGINT_WATCHDOG_RESETS_ON_TIMEOUT == 1 } + description " + Some watchdog devices reset the board on timeout - for these + implementations it does not make sense to register timeout + actions so the code gets disabled when this option is set. + When this option is not set, it is the application's + responsibility to register an action handler which can force + a board reset when it gets called." + } + + cdl_option CYGPKG_IO_WATCHDOG_BUILD_INTERACTIVE_TEST { + display "Build interactive watchdog test" + flavor bool + no_define + default_value 0 + description " + This option enables the building of a watchdog test + which can be used to test that the board resets on + watchdog timeout. This test is built separately since + it only makes sense to use interactively." + } + + cdl_component CYGPKG_IO_WATCHDOG_OPTIONS { + display "Watchdog build options" + flavor none + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_IO_WATCHDOG_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog IO device. These flags are used + in addition to the set of global flags." + } + + cdl_option CYGPKG_IO_WATCHDOG_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the watchdog IO device. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_IO_WATCHDOG_TESTS { + display "Watchdog tests" + flavor data + no_define + calculated { CYGPKG_IO_WATCHDOG_BUILD_INTERACTIVE_TEST ? + CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT ? "tests/watchdog2 tests/watchdog_reset" : "tests/watchdog tests/watchdog2 tests/watchdog_reset" : + CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT ? "tests/watchdog2" : "tests/watchdog tests/watchdog2" } + + description " + This option specifies the set of tests for the + watchdog IO device." + } + } +}
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/include/watchdog.hxx @@ -0,0 +1,159 @@ +#ifndef CYGONCE_DEVS_WATCHDOG_HXX +#define CYGONCE_DEVS_WATCHDOG_HXX + +//========================================================================== +// +// watchdog.hxx +// +// Watchdog interface declaration +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1998-07-14 +// Purpose: Watchdog declarations +// Description: This file defines the interface to the watchdog device +// that provides timer based recovery from software and +// hardware faults. +// Usage: #include <cyg/devs/watchdog.hxx> +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <cyg/kernel/ktypes.h> +#include <cyg/infra/cyg_ass.h> // assertion macros + +class Cyg_Watchdog_Action; + +// ------------------------------------------------------------------------- +// Watchdog class + +class Cyg_Watchdog +{ + + Cyg_Watchdog_Action *action_list; + + cyg_uint64 resolution; + +public: + + Cyg_Watchdog(); + + // Return time interval allowed between resets before watchdog + // triggers, in nanoseconds. + cyg_uint64 get_resolution( void ); + + // Start the watchdog running. + void start( void ); + + // Reset watchdog timer. This needs to be called regularly to prevent + // the watchdog firing. + void reset( void ); + +#ifndef CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT + // Trigger the watchdog as if the timer had expired. + void trigger( void ); + + // Register an action routine that will be called when the timer + // triggers. + void install_action( Cyg_Watchdog_Action *wdaction ); + + // Deregister a previously registered action routine. + void uninstall_action( Cyg_Watchdog_Action *wdaction ); +#endif + + // A static instance of the single system defined watchdog device. + static Cyg_Watchdog watchdog; + +private: + void init_hw( void ); +}; + +#ifndef CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT +// ------------------------------------------------------------------------- +// Watchdog action class + +class Cyg_Watchdog_Action +{ + friend class Cyg_Watchdog; + + Cyg_Watchdog_Action *next; // link in chain + + void (*action)( CYG_ADDRWORD data ); // action function + + CYG_ADDRWORD data; // data argument + +public: + + Cyg_Watchdog_Action( + void (*action)( CYG_ADDRWORD data ), + CYG_ADDRWORD data + ); + + ~Cyg_Watchdog_Action(); + + void install(); + + void uninstall(); +}; + +// ------------------------------------------------------------------------- +// Cyg_Watchdog_Action inlines + +inline Cyg_Watchdog_Action::Cyg_Watchdog_Action( + void (*action_arg)( CYG_ADDRWORD data ), + CYG_ADDRWORD data_arg + ) +{ + next = NULL; + action = action_arg; + data = data_arg; +} + +inline Cyg_Watchdog_Action::~Cyg_Watchdog_Action() +{ + Cyg_Watchdog::watchdog.uninstall_action( this ); +} + +inline void Cyg_Watchdog_Action::install() +{ + Cyg_Watchdog::watchdog.install_action( this ); +} + +inline void Cyg_Watchdog_Action::uninstall() +{ + Cyg_Watchdog::watchdog.uninstall_action( this ); +} + +#endif // CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT + +// ------------------------------------------------------------------------- +#endif // ifndef CYGONCE_DEVS_WATCHDOG_HXX +// EOF watchdog.hxx
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/src/emulate.cxx @@ -0,0 +1,140 @@ +//========================================================================== +// +// io/watchdog/emulate.cxx +// +// Watchdog implementation emulation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1998-07-29 +// Purpose: Watchdog class implementation +// Description: Contains an implementation of the Watchdog class for use +// when there is no hardware watchdog timer. Instead it is +// emulated using an Alarm object. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/watchdog.h> // watchdog configuration file +#include <pkgconf/kernel.h> // Kernel config + +#include <cyg/kernel/ktypes.h> // base kernel types +#include <cyg/infra/cyg_trac.h> // tracing macros +#include <cyg/infra/cyg_ass.h> // assertion macros +#include <cyg/kernel/instrmnt.h> // instrumentation + +#include <cyg/kernel/clock.hxx> // clock and alarm +#include <cyg/kernel/sched.hxx> // scheduler + +#include <cyg/io/watchdog.hxx> // watchdog API + +#include <cyg/kernel/sched.inl> // scheduler inlines + +// ------------------------------------------------------------------------- +// Forward definitions + +static cyg_alarm_fn watchdog_alarm; + +// ------------------------------------------------------------------------- +// Statics + +static Cyg_Alarm alarm( Cyg_Clock::real_time_clock, watchdog_alarm, 0 ); + +// One second's worth of ticks. +static cyg_tick_count one_sec; + +// ------------------------------------------------------------------------- +// HW init + +void +Cyg_Watchdog::init_hw(void) +{ + CYG_REPORT_FUNCTION(); + + Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); + + one_sec = ( res.divisor * 1000000000LL ) / res.dividend ; + + resolution = 1000000000LL; + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Start the watchdog running. + +void Cyg_Watchdog::start() +{ + CYG_REPORT_FUNCTION(); + + Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); + + // Set alarm to a one second single-shot trigger + alarm.initialize( Cyg_Clock::real_time_clock->current_value() + one_sec, 0 ); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Reset watchdog timer. This needs to be called regularly to prevent +// the watchdog firing. + +void Cyg_Watchdog::reset() +{ + CYG_REPORT_FUNCTION(); + + Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); + + Cyg_Scheduler::lock(); + + // Set alarm to a one second single-shot trigger + alarm.initialize( Cyg_Clock::real_time_clock->current_value() + one_sec, 0 ); + + Cyg_Scheduler::unlock(); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Alarm function + +void watchdog_alarm( Cyg_Alarm *a, CYG_ADDRWORD data) +{ + CYG_REPORT_FUNCTION(); + + // Disable alarm just in case + alarm.disable(); + + Cyg_Watchdog::watchdog.trigger(); +} + +// ------------------------------------------------------------------------- +// EOF watchdog/emulate.cxx
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/src/watchdog.cxx @@ -0,0 +1,163 @@ +//========================================================================== +// +// io/watchdog/watchdog.cxx +// +// Watchdog common code +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1999-02-18 +// Purpose: Watchdog class implementation +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> // system configuration file +#include <pkgconf/watchdog.h> // configuration for this package + +#include <cyg/infra/cyg_trac.h> // tracing macros +#include <cyg/infra/cyg_ass.h> // assertion macros + +#include <cyg/hal/drv_api.h> // for locking + +#include <cyg/io/watchdog.hxx> // watchdog API + +// ------------------------------------------------------------------------- +// Statics + +// A static pointer to the single system defined watchdog device. +Cyg_Watchdog Cyg_Watchdog::watchdog; + +// ------------------------------------------------------------------------- +// Constructor + + +Cyg_Watchdog::Cyg_Watchdog() +{ + CYG_REPORT_FUNCTION(); + +#ifndef CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT + action_list = 0; +#endif + + // HW driver initialization. This must set the watchdog resolution. + init_hw(); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Return reset resolution + +cyg_uint64 +Cyg_Watchdog::get_resolution() +{ + return resolution; +} + +#ifndef CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT +// ------------------------------------------------------------------------- +// Trigger the watchdog as if the timer had expired. This should be called +// from the driver's ISR. + +void +Cyg_Watchdog::trigger() +{ + CYG_REPORT_FUNCTION(); + + cyg_drv_dsr_lock(); + + Cyg_Watchdog_Action *act = action_list; + + while( 0 != act ) + { + act->action( act->data ); + + act = act->next; + } + + cyg_drv_dsr_unlock(); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Register an action routine that will be called when the timer +// triggers. + +void +Cyg_Watchdog::install_action( Cyg_Watchdog_Action *action ) +{ + CYG_REPORT_FUNCTION(); + + cyg_drv_dsr_lock(); + + action->next = action_list; + action_list = action; + + cyg_drv_dsr_unlock(); + + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- +// Deregister a previously registered action routine. + +void +Cyg_Watchdog::uninstall_action( Cyg_Watchdog_Action *action ) +{ + CYG_REPORT_FUNCTION(); + + cyg_drv_dsr_lock(); + + Cyg_Watchdog_Action **act_ptr = &action_list; + + while( 0 != *act_ptr ) + { + Cyg_Watchdog_Action *a = *act_ptr; + + if( a == action ) + { + *act_ptr = a->next; + break; + } + act_ptr = &a->next; + } + + cyg_drv_dsr_unlock(); + + CYG_REPORT_RETURN(); +} + +#endif // CYGSEM_WATCHDOG_RESETS_ON_TIMEOUT + +// ------------------------------------------------------------------------- +// EOF io/watchdog/watchdog.cxx
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/tests/watchdog.cxx @@ -0,0 +1,229 @@ +//========================================================================== +// +// watchdog.cxx +// +// Watchdog test +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1998-07-20 +// Description: This test exercises the Watchdog class and checks that it +// works as advertised. +//####DESCRIPTIONEND#### +// ------------------------------------------------------------------------- + +#include <pkgconf/kernel.h> + +#include <cyg/kernel/thread.hxx> +#include <cyg/kernel/thread.inl> +#include <cyg/kernel/sched.hxx> +#include <cyg/kernel/mutex.hxx> +#include <cyg/kernel/sema.hxx> +#include <cyg/kernel/clock.hxx> + +#include <cyg/kernel/diag.h> + +#include <cyg/io/watchdog.hxx> + +#include <cyg/infra/testcase.h> +#include <cyg/infra/diag.h> + +#if defined(CYGFUN_KERNEL_THREADS_TIMER) && \ + defined(CYGVAR_KERNEL_COUNTERS_CLOCK) + +#include <cyg/kernel/sched.inl> + +// ------------------------------------------------------------------------- +// Data for the test + +#ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL +#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL +#else +#define STACKSIZE (2*1024) // size of thread stack +#endif + +char thread_stack[STACKSIZE]; + +inline void *operator new(size_t size, void *ptr) { return ptr; }; + +// array of threads. +char thread[sizeof(Cyg_Thread)]; + +Cyg_Thread *th; + +//cyg_tick_count one_sec; +cyg_tick_count watchdog_delay; +volatile bool watchdog_fired; +volatile cyg_tick_count watchdog_time; + +#define WATCHDOG_LOOPS_HW 5 +#define WATCHDOG_LOOPS_SIM 1 +#define WATCHDOG_CYCLES_PER_LOOP_HW 10 +#define WATCHDOG_CYCLES_PER_LOOP_SIM 2 +#define WATCHDOG_TICKS_TILL_TIMEOUT 10 + +// ------------------------------------------------------------------------- +// Action functions: + +void watchdog_action1( CYG_ADDRWORD data ) +{ + watchdog_fired = true; + watchdog_time = Cyg_Clock::real_time_clock->current_value(); +} + +void watchdog_action2( CYG_ADDRWORD data ) +{ + CYG_TEST_PASS_FINISH("Watchdog OK"); +} + +// ------------------------------------------------------------------------- +// Thread body + + +void watchdog_thread( CYG_ADDRWORD id ) +{ + cyg_tick_count watchdog_start_time; + cyg_tick_count thread_start_time, thread_end_time; + cyg_ucount8 watchdog_loops, watchdog_cycles_per_loop; + + if (cyg_test_is_simulator) { + watchdog_loops = WATCHDOG_LOOPS_SIM; + watchdog_cycles_per_loop = WATCHDOG_CYCLES_PER_LOOP_SIM; + } else { + watchdog_loops = WATCHDOG_LOOPS_HW; + watchdog_cycles_per_loop = WATCHDOG_CYCLES_PER_LOOP_HW; + } + + watchdog_fired = false; + Cyg_Watchdog::watchdog.start(); + + CYG_TEST_INFO("Testing that watchdog does not fire early"); + + for (cyg_ucount8 tries = 0; tries < watchdog_loops; tries++) { + diag_printf("Iteration #%d (testing over %d cycles)\n", + tries, watchdog_cycles_per_loop); + + // First test that the watchdog does not trigger when being reset. + Cyg_Watchdog_Action wdaction( watchdog_action1, 0 ); + + wdaction.install(); + Cyg_Watchdog::watchdog.reset(); + + watchdog_start_time = Cyg_Clock::real_time_clock->current_value(); + watchdog_fired = false; + + for( cyg_ucount8 i = 0; i < watchdog_cycles_per_loop; i++ ) { + thread_start_time = Cyg_Clock::real_time_clock->current_value(); + th->delay( watchdog_delay-2 ); + Cyg_Watchdog::watchdog.reset(); + if (watchdog_fired) { + thread_end_time = Cyg_Clock::real_time_clock->current_value(); + diag_printf("Watchdog fired prematurely after %d ticks\n", + (int)(watchdog_time - watchdog_start_time)); + diag_printf(" Thread slept for %d ticks, loop #%d\n", + (int)(thread_end_time - thread_start_time), i); + CYG_TEST_FAIL_FINISH("Watchdog triggered unexpectedly"); + break; + } else { + CYG_TEST_STILL_ALIVE(i, "Resetting watchdog..."); + Cyg_Watchdog::watchdog.reset(); + watchdog_fired = false; + watchdog_start_time = Cyg_Clock::real_time_clock->current_value(); + } + } + } + + // Now check that it triggers when not reset + CYG_TEST_INFO("Testing that watchdog fires"); + { + Cyg_Watchdog_Action wdaction( watchdog_action2, 0 ); + + wdaction.install(); + + Cyg_Watchdog::watchdog.reset(); + + th->delay( watchdog_delay*WATCHDOG_TICKS_TILL_TIMEOUT ); + } + + CYG_TEST_FAIL_FINISH("Watchdog failed to trigger"); +} + +// ------------------------------------------------------------------------- + + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + +#if !defined(CYGIMP_WATCHDOG_EMULATE) && defined(CYGPKG_HAL_MN10300_STDEVAL1) + // Workaround for PR 17974 + if( cyg_test_is_simulator ) + CYG_TEST_NA("Watchdog device not implemented in MN10300 simulator."); +#endif + + + Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); + + cyg_uint64 wres = Cyg_Watchdog::watchdog.get_resolution(); + + // Calculate how many clock ticks there are in a watchdog cycle. + + watchdog_delay = ((cyg_tick_count)wres * (cyg_tick_count)res.divisor ); + watchdog_delay /= res.dividend; + + th = new((void *)&thread) Cyg_Thread(CYG_SCHED_DEFAULT_INFO, + watchdog_thread, + 0, + "watchdog_thread", + (CYG_ADDRESS)thread_stack, + STACKSIZE + ); + + th->resume(); + + // Get the world going + Cyg_Scheduler::scheduler.start(); + +} + +#else // if defined(CYGFUN_KERNEL_THREADS_TIMER) etc... + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + CYG_TEST_NA("Kernel real-time clock/threads timer disabled"); +} + +#endif // if defined(CYGFUN_KERNEL_THREADS_TIMER) etc... + +// ------------------------------------------------------------------------- +// EOF watchdog.cxx
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/tests/watchdog2.cxx @@ -0,0 +1,211 @@ +//========================================================================== +// +// watchdog2.cxx +// +// Watchdog test +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg, jskov +// Date: 1998-07-20 +// Description: Tests the watchdog driver. +// This test tries to make sure the watchdog does not trigger +// early. On boards where the watchdog performs a reset on +// timeout, there will be no FAIL message - but it should +// PASS even on those boards when the driver implementation +// is correct. +// +//####DESCRIPTIONEND#### +// ------------------------------------------------------------------------- + +#include <pkgconf/kernel.h> + +#include <cyg/kernel/thread.hxx> +#include <cyg/kernel/thread.inl> +#include <cyg/kernel/sched.hxx> +#include <cyg/kernel/mutex.hxx> +#include <cyg/kernel/sema.hxx> +#include <cyg/kernel/clock.hxx> + +#include <cyg/kernel/diag.h> + +#include <cyg/io/watchdog.hxx> + +#include <cyg/infra/testcase.h> +#include <cyg/infra/diag.h> + +#if defined(CYGFUN_KERNEL_THREADS_TIMER) && \ + defined(CYGVAR_KERNEL_COUNTERS_CLOCK) + +#include <cyg/kernel/sched.inl> + +// ------------------------------------------------------------------------- +// Data for the test + +#ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL +#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL +#else +#define STACKSIZE (2*1024) // size of thread stack +#endif + +char thread_stack[STACKSIZE]; + +inline void *operator new(size_t size, void *ptr) { return ptr; }; + +// array of threads. +char thread[sizeof(Cyg_Thread)]; + +Cyg_Thread *th; + +//cyg_tick_count one_sec; +cyg_tick_count watchdog_delay; +volatile bool watchdog_fired; +volatile cyg_tick_count watchdog_time; + +#define WATCHDOG_CYCLES_PER_LOOP_HW 7 +#define WATCHDOG_CYCLES_PER_LOOP_SIM 2 +#define WATCHDOG_TICKS_TILL_TIMEOUT 10 + +// ------------------------------------------------------------------------- +// Action functions: + +#ifdef CYGINT_WATCHDOG_RESETS_ON_TIMEOUT +void watchdog_action1( CYG_ADDRWORD data ) +{ + watchdog_fired = true; + watchdog_time = Cyg_Clock::real_time_clock->current_value(); +} +#endif + +// ------------------------------------------------------------------------- +// Thread body + +void watchdog_thread( CYG_ADDRWORD id ) +{ + cyg_tick_count watchdog_start_time; + cyg_tick_count thread_start_time, thread_end_time; + cyg_ucount8 watchdog_cycles_per_loop; + + if (cyg_test_is_simulator) { + watchdog_cycles_per_loop = WATCHDOG_CYCLES_PER_LOOP_SIM; + } else { + watchdog_cycles_per_loop = WATCHDOG_CYCLES_PER_LOOP_HW; + } + + CYG_TEST_INFO("Testing that watchdog does not fire early"); + + watchdog_fired = false; + Cyg_Watchdog::watchdog.start(); + +#ifdef CYGINT_WATCHDOG_RESETS_ON_TIMEOUT + // First test that the watchdog does not trigger when being reset. + Cyg_Watchdog_Action wdaction( watchdog_action1, 0 ); + wdaction.install(); +#endif + Cyg_Watchdog::watchdog.reset(); + + watchdog_start_time = Cyg_Clock::real_time_clock->current_value(); + watchdog_fired = false; + + for( cyg_ucount8 i = 0; i < watchdog_cycles_per_loop; i++ ) { + thread_start_time = Cyg_Clock::real_time_clock->current_value(); + th->delay( watchdog_delay-2 ); + Cyg_Watchdog::watchdog.reset(); + if (watchdog_fired) { + thread_end_time = Cyg_Clock::real_time_clock->current_value(); + diag_printf("Watchdog fired prematurely after %d ticks\n", + (int)(watchdog_time - watchdog_start_time)); + diag_printf(" Thread slept for %d ticks, loop #%d\n", + (int)(thread_end_time - thread_start_time), i); + CYG_TEST_FAIL_FINISH("Watchdog triggered unexpectedly"); + break; + } else { + // No printing - delays are fatal! + // CYG_TEST_STILL_ALIVE(i, "Resetting watchdog..."); + Cyg_Watchdog::watchdog.reset(); + watchdog_fired = false; + watchdog_start_time = Cyg_Clock::real_time_clock->current_value(); + } + } + + CYG_TEST_PASS_FINISH("Watchdog OK"); +} + +// ------------------------------------------------------------------------- + + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + +#if !defined(CYGIMP_WATCHDOG_EMULATE) && defined(CYGPKG_HAL_MN10300_STDEVAL1) + // Workaround for PR 17974 + if( cyg_test_is_simulator ) + CYG_TEST_NA("Watchdog device not implemented in MN10300 simulator."); +#endif + + + Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); + + cyg_uint64 wres = Cyg_Watchdog::watchdog.get_resolution(); + + // Calculate how many clock ticks there are in a watchdog cycle. + + watchdog_delay = ((cyg_tick_count)wres * (cyg_tick_count)res.divisor ); + watchdog_delay /= res.dividend; + + th = new((void *)&thread) Cyg_Thread(CYG_SCHED_DEFAULT_INFO, + watchdog_thread, + 0, + "watchdog_thread", + (CYG_ADDRESS)thread_stack, + STACKSIZE + ); + + th->resume(); + + // Get the world going + Cyg_Scheduler::scheduler.start(); + +} + +#else // if defined(CYGFUN_KERNEL_THREADS_TIMER) etc... + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + CYG_TEST_NA("Kernel real-time clock/threads timer disabled"); +} + +#endif // if defined(CYGFUN_KERNEL_THREADS_TIMER) etc... + +// ------------------------------------------------------------------------- +// EOF watchdog.cxx
new file mode 100644 --- /dev/null +++ b/packages/io/watchdog/current/tests/watchdog_reset.cxx @@ -0,0 +1,175 @@ +//========================================================================== +// +// watchdog_reset.cxx +// +// Watchdog reset test +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// 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 Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov (based on watchdog.cxx) +// Contributors: jskov, nickg +// Date: 1999-08-27 +// Description: Tests that the watchdog timer resets the board. +// This test needs to be run by an operator - automatic +// testing not possible. +//####DESCRIPTIONEND#### +// ------------------------------------------------------------------------- + +#include <pkgconf/system.h> + +#include <cyg/infra/testcase.h> +#include <cyg/infra/diag.h> + +// Package requirements +#if defined(CYGPKG_KERNEL) + +#include <pkgconf/kernel.h> + +// Package option requirements +#if defined(CYGFUN_KERNEL_THREADS_TIMER) && \ + defined(CYGVAR_KERNEL_COUNTERS_CLOCK) + + +#include <cyg/kernel/thread.inl> + +#include <cyg/hal/hal_cache.h> + +#include <cyg/io/watchdog.hxx> // watchdog API + + +// ------------------------------------------------------------------------- +// Data for the test + +#ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL +#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL +#else +#define STACKSIZE (2*1024) // size of thread stack +#endif + +char thread_stack[STACKSIZE]; + +inline void *operator new(size_t size, void *ptr) { return ptr; }; + +// array of threads. +char thread[sizeof(Cyg_Thread)]; + +Cyg_Thread *th; + +//cyg_tick_count one_sec; +cyg_tick_count watchdog_delay; + +// ------------------------------------------------------------------------- +// Thread body + +volatile int watchdog_accuracy = 50; + +void watchdog_thread( CYG_ADDRWORD id ) +{ + diag_printf("Test of watchdog timer accuracy. Expect the test to run\n" + "for at least 10 times the watchdog timeout time. After\n" + "that time you may have to reset the board manually and/or\n" + "restart GDB which tends to get a little confused.\n"); + diag_printf("When you get contact with the board again, read the value\n" + "in watchdog_accuracy - it should be close to 100 if the\n" + "watchdog timer is accurate.\n"); + + // Disable data cache so the variable in memory gets updated. + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + + Cyg_Watchdog::watchdog.start(); + Cyg_Watchdog::watchdog.reset(); + + while (watchdog_accuracy < 400) { + Cyg_Watchdog::watchdog.reset(); + th->delay( watchdog_delay*watchdog_accuracy/100 ); + watchdog_accuracy += 5; + } + + CYG_TEST_FAIL_FINISH("Watchdog failed to reset board. " + "Timer value is off by at least a factor of 4!"); +} + +// ------------------------------------------------------------------------- + + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + +#if !defined(CYGIMP_WATCHDOG_EMULATE) && defined(CYGPKG_HAL_MN10300_STDEVAL1) + // Workaround for PR 17974 + if( cyg_test_is_simulator ) + CYG_TEST_NA("Watchdog device not implemented in MN10300 simulator."); +#endif + + + Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution(); + + cyg_uint64 wres = Cyg_Watchdog::watchdog.get_resolution(); + + // Calculate how many clock ticks there are in a watchdog cycle. + + watchdog_delay = ((cyg_tick_count)wres * (cyg_tick_count)res.divisor ); + watchdog_delay /= res.dividend; + + th = new((void *)&thread) Cyg_Thread(CYG_SCHED_DEFAULT_INFO, + watchdog_thread, + 0, + "watchdog_thread", + (CYG_ADDRESS)thread_stack, + STACKSIZE + ); + + th->resume(); + + // Get the world going + Cyg_Scheduler::scheduler.start(); + +} + +#else // CYGFUN_KERNEL_THREADS_TIMER etc... +#define N_A_MSG "Needs kernel RTC/threads timer" +#endif + +#else // CYGPKG_KERNEL +#define N_A_MSG "Needs Kernel" +#endif + +#ifdef N_A_MSG +void +cyg_start( void ) +{ + CYG_TEST_INIT(); + CYG_TEST_NA( N_A_MSG); +} +#endif // N_A_MSG + +// ------------------------------------------------------------------------- +// EOF watchdog_reset.cxx
--- a/packages/language/c/libm/current/ChangeLog +++ b/packages/language/c/libm/current/ChangeLog @@ -1,6 +1,11 @@ +2000-05-30 Jesper Skov <jskov@redhat.com> + + * include/sys/ieeefp.h: Undo below change. + 2000-05-26 Jesper Skov <jskov@redhat.com> * include/sys/ieeefp.h: Support FPU double-LE layout in BE mode. + Fix paste bug. 2000-03-28 John Dallaway <jld@cygnus.co.uk>
--- a/packages/language/c/libm/current/include/sys/ieeefp.h +++ b/packages/language/c/libm/current/include/sys/ieeefp.h @@ -61,8 +61,6 @@ // Note: there do not seem to be any current machines which are Big Endian but // have a mixed up double layout. -#if (CYG_BYTEORDER == CYG_MSBFIRST) // Big endian - typedef union { cyg_int32 asi32[2]; @@ -73,26 +71,17 @@ typedef union struct { -#if (CYG_DOUBLE_BYTEORDER == CYG_MSBFIRST) unsigned int sign : 1; unsigned int exponent: 11; unsigned int fraction0:4; unsigned int fraction1:16; unsigned int fraction2:16; unsigned int fraction3:16; -#else - unsigned int fraction2:16; - unsigned int fraction3:16; - unsigned int sign : 1; - unsigned int exponent: 11; - unsigned int fraction0:4; - unsigned int fraction1:16; -#endif + } number; struct { -#if (CYG_DOUBLE_BYTEORDER == CYG_MSBFIRST) unsigned int sign : 1; unsigned int exponent: 11; unsigned int quiet:1; @@ -100,31 +89,18 @@ typedef union unsigned int function1:16; unsigned int function2:16; unsigned int function3:16; -#else - unsigned int function2:16; - unsigned int function3:16; - unsigned int sign : 1; - unsigned int exponent: 11; - unsigned int quiet:1; - unsigned int function0:3; - unsigned int function1:16; -#endif } nan; struct { -#if (CYG_DOUBLE_BYTEORDER == CYG_MSBFIRST) cyg_uint32 msw; cyg_uint32 lsw; -#else - cyg_uint32 lsw; - cyg_uint32 msw; -#endif } parts; } Cyg_libm_ieee_double_shape_type; + typedef union { cyg_int32 asi32;
--- a/packages/templates/all/ChangeLog +++ b/packages/templates/all/ChangeLog @@ -1,3 +1,7 @@ +2000-05-31 Jesper Skov <jskov@redhat.com> + + * current.ect: Renamed watchdog package. + 2000-04-07 Hugo Tyson <hmt@cygnus.co.uk> * ecos.db: Re-organize device packages. This is a massive change
--- a/packages/templates/all/current.ect +++ b/packages/templates/all/current.ect @@ -17,7 +17,7 @@ cdl_configuration template_all { package CYGPKG_LIBC current ; package CYGPKG_LIBM current ; package CYGPKG_UITRON current ; - package CYGPKG_DEVICES_WATCHDOG current ; + package CYGPKG_IO_WATCHDOG current ; package CYGPKG_IO_WALLCLOCK current ; package CYGPKG_ERROR current ; };
