OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /or1k/trunk/ecos-2.0/packages/devs/wallclock
    from Rev 1254 to Rev 1765
    Reverse comparison

Rev 1254 → Rev 1765

/powerpc/mpc5xx/v2_0/cdl/wallclock_mpc5xx.cdl
0,0 → 1,101
# ====================================================================
#
# wallclock_mpc5xx.cdl
#
# eCos wallclock motorola MPC555-module driver configuration data
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): Bob Koninckx
# Original data: nickg
# Contributors:
# Date: 2002-01-18
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_DEVICES_WALLCLOCK_MPC5xx {
parent CYGPKG_IO_WALLCLOCK
active_if CYGPKG_IO_WALLCLOCK
display "mpc5xx RTC-module wallclock driver"
requires CYGPKG_HAL_POWERPC_MPC5xx
hardware
compile wallclock_mpc5xx.cxx
implements CYGINT_WALLCLOCK_HW_IMPLEMENTATIONS
active_if CYGIMP_WALLCLOCK_HARDWARE
 
cdl_option CYGIMP_WALLCLOCK_HARDWARE {
parent CYGPKG_IO_WALLCLOCK_IMPLEMENTATION
display "Hardware wallclock"
default_value 1
implements CYGINT_WALLCLOCK_IMPLEMENTATIONS
}
 
cdl_component CYGPKG_DEVICES_WALLCLOCK_MPC5xx_OPTIONS {
display "mpc5xx RTC-module wallclock 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_WALLCLOCK_MPC5xx_CFLAGS_ADD {
display "Additional compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the wallclock device. These flags are used in addition
to the set of global flags."
}
 
cdl_option CYGPKG_DEVICES_WALLCLOCK_MPC5xx_CFLAGS_REMOVE {
display "Suppressed compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the wallclock device. These flags are removed from
the set of global flags if present."
}
 
}
}
/powerpc/mpc5xx/v2_0/ChangeLog
0,0 → 1,38
2002-04-24 Bob Koninckx <bob.koninckx@mech.kuleuven.ac.be>
 
* New package.
 
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
/powerpc/mpc5xx/v2_0/src/wallclock_mpc5xx.cxx
0,0 → 1,100
//==========================================================================
//
// wallclock_mpc5xx.cxx
//
// mpc5xx RTC module driver.
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): Bob Koninckx
// Contributors: Bob Koninckx
// Date: 2002-01-18
// Purpose: Wallclock driver for mpc5xx
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#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
 
#include <cyg/io/wallclock.hxx> // The WallClock API
#include <cyg/io/wallclock/wallclock.inl> // Helpers
 
#include <cyg/hal/hal_arch.h> // RTC register definitions
 
#include <cyg/infra/diag.h> // For debugging
 
//-----------------------------------------------------------------------------
// Functions required for the hardware-driver API.
 
// Returns the number of seconds elapsed since 1970-01-01 00:00:00.
cyg_uint32
Cyg_WallClock::get_hw_seconds(void)
{
cyg_uint32 now;
HAL_READ_UINT32(CYGARC_REG_IMM_RTC, now);
 
return now;
}
 
#ifndef CYGSEM_WALLCLOCK_SET_GET_MODE
 
void
Cyg_WallClock::init_hw_seconds(void)
{
cyg_uint32 key = 0x55ccaa33;
cyg_uint16 rtcsc;
 
// Write zero to the time register
// and start up the RTC
HAL_WRITE_UINT32(CYGARC_REG_IMM_RTCK, key);
HAL_WRITE_UINT32(CYGARC_REG_IMM_RTCSCK, key);
key = 0;
HAL_WRITE_UINT32(CYGARC_REG_IMM_RTC, key);
HAL_READ_UINT16(CYGARC_REG_IMM_RTCSC, rtcsc);
rtcsc |= 0x0001;
HAL_WRITE_UINT16(CYGARC_REG_IMM_RTCSC, rtcsc);
}
 
#endif // CYGSEM_WALLCLOCK_SET_GET_MODE
 
//-----------------------------------------------------------------------------
// End of wallclock_mpc5xx.cxx
/dallas/ds12887/v2_0/cdl/wallclock_ds12887.cdl
0,0 → 1,105
# ====================================================================
#
# wallclock_ds12887.cdl
#
# eCos configuration data for Dallas 12887
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): jskov
# Contributors: jskov
# Date: 2001-07-06
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS12887 {
parent CYGPKG_IO_WALLCLOCK
active_if CYGPKG_IO_WALLCLOCK
display "Wallclock device driver for Dallas 12887"
description "
This package provides a file with init, get and set functions
for the Dallas 12887 clock part."
 
compile ds12887.cxx
 
implements CYGINT_WALLCLOCK_HW_IMPLEMENTATIONS
active_if CYGIMP_WALLCLOCK_HARDWARE
implements CYGINT_WALLCLOCK_SET_GET_MODE_SUPPORTED
 
cdl_option CYGIMP_WALLCLOCK_HARDWARE {
parent CYGPKG_IO_WALLCLOCK_IMPLEMENTATION
display "Hardware wallclock"
default_value 1
implements CYGINT_WALLCLOCK_IMPLEMENTATIONS
}
 
 
cdl_component CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS12887_OPTIONS {
display "DS12887 wallclock 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_WALLCLOCK_DALLAS_DS12887_CFLAGS_ADD {
display "Additional compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the wallclock device. These flags are used in addition
to the set of global flags."
}
 
cdl_option CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS12887_CFLAGS_REMOVE {
display "Suppressed compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the wallclock device. These flags are removed from
the set of global flags if present."
}
 
}
}
/dallas/ds12887/v2_0/ChangeLog
0,0 → 1,47
2001-07-27 Jesper Skov <jskov@redhat.com>
 
* src/ds12887.cxx (init_ds_hwclock): Use BCD mode since Century is
NA in binary mode. Force sane settings in registers if they are
undefined.
 
2001-07-06 Jesper Skov <jskov@redhat.com>
 
* src/ds12887.cxx (get_ds_hwclock): Instead of locking while
reading (which prevents updates if polled), disable interrupts.
 
* New package, based on 1742 driver.
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
 
 
/dallas/ds12887/v2_0/src/ds12887.cxx
0,0 → 1,297
//==========================================================================
//
// devs/wallclock/ds12887.inl
//
// Wallclock implementation for Dallas 12887
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jskov
// Contributors: jskov
// Date: 2001-07-06
// Purpose: Wallclock driver for Dallas 12887
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#include <pkgconf/wallclock.h> // Wallclock device config
 
#include <cyg/hal/hal_io.h> // IO macros
#include <cyg/hal/hal_intr.h> // interrupt enable/disable
#include <cyg/infra/cyg_type.h> // Common type definitions and support
 
#include <cyg/io/wallclock.hxx> // The WallClock API
#include <cyg/io/wallclock/wallclock.inl> // Helpers
 
#include <cyg/infra/diag.h>
 
#define nDEBUG
 
// Platform details
#include CYGDAT_DEVS_WALLCLOCK_DALLAS_12887_INL
 
#ifndef DS_READ_UINT8
# define DS_READ_UINT8(x,y) HAL_READ_UINT8(x,y)
# define DS_WRITE_UINT8(x,y) HAL_WRITE_UINT8(x,y)
#endif
 
#ifdef DS_LINEAR
# ifndef DS_STEP
# define DS_STEP 0
# endif
# ifndef DS_BASE
# error "Need to know base of DS12887 part"
# endif
# define DS_READ(offset, data) DS_READ_UINT8(DS_BASE + ((offset) << DS_STEP), (data))
# define DS_WRITE(offset, data) DS_WRITE_UINT8(DS_BASE + ((offset) << DS_STEP), (data))
#else
# if !defined(DS_ADDR) || !defined(DS_DATA)
# error "Need to know addr/data locations of DS12887 part"
# endif
# define DS_READ(offset, data) \
CYG_MACRO_START \
DS_WRITE_UINT8(DS_ADDR, (offset)); \
DS_READ_UINT8(DS_DATA, (data)); \
CYG_MACRO_END
# define DS_WRITE(offset, data) \
CYG_MACRO_START \
DS_WRITE_UINT8(DS_ADDR, (offset)); \
DS_WRITE_UINT8(DS_DATA, (data)); \
CYG_MACRO_END
#endif
 
// Registers
#define DS_SECONDS 0x00
#define DS_SECONDS_ALARM 0x01
#define DS_MINUTES 0x02
#define DS_MINUTES_ALARM 0x03
#define DS_HOURS 0x04
#define DS_HOURS_ALARM 0x05
#define DS_DOW 0x06
#define DS_DOM 0x07
#define DS_MONTH 0x08
#define DS_YEAR 0x09
#define DS_CENTURY 0x32
 
#define DS_REG_A 0x0a
#define DS_REG_B 0x0b
#define DS_REG_C 0x0c
#define DS_REG_D 0x0d
 
// Control bits
#define DS_REG_A_UIP 0x80
#define DS_REG_A_ENABLE 0x20
 
#define DS_REG_B_SET 0x80
#define DS_REG_B_DM 0x04
#define DS_REG_B_24H 0x02
 
 
//----------------------------------------------------------------------------
// Accessor functions
static inline void
init_ds_hwclock(void)
{
cyg_uint8 _regb, _tmp;
 
// Set 24H mode
DS_WRITE(DS_REG_B, DS_REG_B_24H);
// Enable clock
DS_WRITE(DS_REG_A, DS_REG_A_ENABLE);
// Verify that there are reasonable default settings - otherwise
// set them.
 
// Stop counting
DS_READ(DS_REG_B, _regb);
_regb |= DS_REG_B_SET;
DS_WRITE(DS_REG_B, _regb);
 
DS_READ(DS_CENTURY, _tmp);
if (0xff == _tmp)
DS_WRITE(DS_CENTURY, TO_BCD(20));
 
DS_READ(DS_MONTH, _tmp);
if (0x00 == _tmp)
DS_WRITE(DS_MONTH, TO_BCD(1));
 
DS_READ(DS_DOM, _tmp);
if (0x00 == _tmp)
DS_WRITE(DS_DOM, TO_BCD(1));
 
DS_READ(DS_DOM, _tmp);
if (0x00 == _tmp)
DS_WRITE(DS_DOM, TO_BCD(1));
 
// Restart counting
_regb &= ~DS_REG_B_SET;
DS_WRITE(DS_REG_B, _regb);
}
 
 
static inline void
set_ds_hwclock(cyg_uint32 year, cyg_uint32 month, cyg_uint32 mday,
cyg_uint32 hour, cyg_uint32 minute, cyg_uint32 second)
{
cyg_uint8 _regb;
// Stop counting
DS_READ(DS_REG_B, _regb);
_regb |= DS_REG_B_SET;
DS_WRITE(DS_REG_B, _regb);
 
DS_WRITE(DS_CENTURY, TO_BCD((cyg_uint8)(year / 100)));
DS_WRITE(DS_YEAR, TO_BCD((cyg_uint8)(year % 100)));
DS_WRITE(DS_MONTH, TO_BCD((cyg_uint8)month));
DS_WRITE(DS_DOM, TO_BCD((cyg_uint8)mday));
DS_WRITE(DS_HOURS, TO_BCD((cyg_uint8)hour));
DS_WRITE(DS_MINUTES, TO_BCD((cyg_uint8)minute));
DS_WRITE(DS_SECONDS, TO_BCD((cyg_uint8)second));
 
// Restart counting
_regb &= ~DS_REG_B_SET;
DS_WRITE(DS_REG_B, _regb);
 
#ifdef DEBUG
// This will cause the test to eventually fail due to these printouts
// causing timer interrupts to be lost...
diag_printf("Set -------------\n");
diag_printf("year %02d\n", year);
diag_printf("month %02d\n", month);
diag_printf("mday %02d\n", mday);
diag_printf("hour %02d\n", hour);
diag_printf("minute %02d\n", minute);
diag_printf("second %02d\n", second);
#endif
}
 
static inline void
get_ds_hwclock(cyg_uint32* year, cyg_uint32* month, cyg_uint32* mday,
cyg_uint32* hour, cyg_uint32* minute, cyg_uint32* second)
{
cyg_uint8 _reg, _t1, _t2;
cyg_uint32 _old;
 
// Wait for update flag clears
do {
DS_READ(DS_REG_A, _reg);
} while (_reg & DS_REG_A_UIP);
 
// Disable interrupts while reading to ensure it doesn't take more
// than 244us.
HAL_DISABLE_INTERRUPTS(_old);
 
DS_READ(DS_CENTURY, _t1);
DS_READ(DS_YEAR, _t2);
*year = (cyg_uint32)TO_DEC(_t1)*100 + (cyg_uint32)TO_DEC(_t2);
 
DS_READ(DS_MONTH, _t1);
*month = (cyg_uint32)TO_DEC(_t1);
 
DS_READ(DS_DOM, _t1);
*mday = (cyg_uint32)TO_DEC(_t1);
 
DS_READ(DS_HOURS, _t1);
*hour = (cyg_uint32)TO_DEC(_t1);
 
DS_READ(DS_MINUTES, _t1);
*minute = (cyg_uint32)TO_DEC(_t1);
 
DS_READ(DS_SECONDS, _t1);
*second = (cyg_uint32)TO_DEC(_t1);
 
// Reenable interrupts
HAL_RESTORE_INTERRUPTS(_old);
 
#ifdef DEBUG
// This will cause the test to eventually fail due to these printouts
// causing timer interrupts to be lost...
diag_printf("year %02d\n", *year);
diag_printf("month %02d\n", *month);
diag_printf("mday %02d\n", *mday);
diag_printf("hour %02d\n", *hour);
diag_printf("minute %02d\n", *minute);
diag_printf("second %02d\n", *second);
#endif
}
 
//-----------------------------------------------------------------------------
// Functions required for the hardware-driver API.
 
// Returns the number of seconds elapsed since 1970-01-01 00:00:00.
cyg_uint32
Cyg_WallClock::get_hw_seconds(void)
{
cyg_uint32 year, month, mday, hour, minute, second;
 
get_ds_hwclock(&year, &month, &mday, &hour, &minute, &second);
 
cyg_uint32 now = _simple_mktime(year, month, mday, hour, minute, second);
return now;
}
 
#ifdef CYGSEM_WALLCLOCK_SET_GET_MODE
 
// Sets the clock. Argument is seconds elapsed since 1970-01-01 00:00:00.
void
Cyg_WallClock::set_hw_seconds( cyg_uint32 secs )
{
cyg_uint32 year, month, mday, hour, minute, second;
 
_simple_mkdate(secs, &year, &month, &mday, &hour, &minute, &second);
 
set_ds_hwclock(year, month, mday, hour, minute, second);
}
 
#endif
 
void
Cyg_WallClock::init_hw_seconds(void)
{
#ifdef CYGSEM_WALLCLOCK_SET_GET_MODE
init_ds_hwclock();
#else
// This is our base: 1970-01-01 00:00:00
// Set the HW clock - if for nothing else, just to be sure it's in a
// legal range. Any arbitrary base could be used.
// After this the hardware clock is only read.
set_ds_hwclock(1970,1,1,0,0,0);
#endif
}
 
//-----------------------------------------------------------------------------
// End of devs/wallclock/ds12887.inl
/dallas/ds1742/v2_0/wallclock_ds1742.cdl
0,0 → 1,60
# ====================================================================
#
# wallclock_ds1742.cdl
#
# eCos configuration data for Dallas 1742
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######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."
}
/dallas/ds1742/v2_0/ds1742.inl
0,0 → 1,183
//==========================================================================
//
// devs/wallclock/ds1742.inl
//
// Wallclock implementation for Dallas 1742
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####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
/dallas/ds1742/v2_0/ChangeLog
0,0 → 1,38
2000-05-26 Jesper Skov <jskov@redhat.com>
* wallclock_ds1742.cdl:
Parent under IO/Wallclock.
 
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
 
 
/mips/ref4955/v2_0/cdl/wallclock_ref4955.cdl
0,0 → 1,102
# ====================================================================
#
# wallclock_ref4955.cdl
#
# eCos wallclock for REF4955 driver configuration data
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): jskov
# Contributors: jskov
# Date: 2000-05-25
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_DEVICES_WALLCLOCK_MIPS_REF4955 {
parent CYGPKG_IO_WALLCLOCK
active_if CYGPKG_IO_WALLCLOCK
display "REF4955 wallclock driver"
requires CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS1742
requires CYGPKG_HAL_MIPS_TX49_REF4955
hardware
compile wallclock_ref4955.cxx
implements CYGINT_WALLCLOCK_HW_IMPLEMENTATIONS
implements CYGINT_WALLCLOCK_SET_GET_MODE_SUPPORTED
active_if CYGIMP_WALLCLOCK_HARDWARE
 
cdl_option CYGIMP_WALLCLOCK_HARDWARE {
parent CYGPKG_IO_WALLCLOCK_IMPLEMENTATION
display "Hardware wallclock"
default_value 1
implements CYGINT_WALLCLOCK_IMPLEMENTATIONS
}
 
cdl_component CYGPKG_DEVICES_WALLCLOCK_MIPS_REF4955_OPTIONS {
display "REF4955 wallclock 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_WALLCLOCK_MIPS_REF4955_CFLAGS_ADD {
display "Additional compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the wallclock device. These flags are used in addition
to the set of global flags."
}
 
cdl_option CYGPKG_DEVICES_WALLCLOCK_MIPS_REF4955_CFLAGS_REMOVE {
display "Suppressed compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the wallclock device. These flags are removed from
the set of global flags if present."
}
 
}
}
/mips/ref4955/v2_0/ChangeLog
0,0 → 1,53
2001-07-03 Jesper Skov <jskov@redhat.com>
 
* src/wallclock_ref4955.cxx: Don't include kernel config.
 
2000-05-26 Jesper Skov <jskov@redhat.com>
 
* cdl/wallclock_ref4955.cdl:
* src/wallclock_ref4955.cxx:
* src/ds1742.inl: [deleted]
Added set-get mode. Moved Dallas driver to its own package.
 
2000-05-25 Jesper Skov <jskov@redhat.com>
 
* cdl/wallclock_ref4955.cdl:
* src/wallclock_ref4955.cxx:
* src/ds1742.inl:
Added wallclock driver REF4955 (Dallas 1742)
(set_ds_hwclock): Clear frequency test bit.
 
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
 
 
/mips/ref4955/v2_0/src/wallclock_ref4955.cxx
0,0 → 1,122
//==========================================================================
//
// devs/wallclock/mips/ref4955/ref4955.cxx
//
// Wallclock implementation
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jskov
// Contributors: jskov
// Date: 2000-05-25
// Purpose: Wallclock driver for REF4955
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#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
 
#include <cyg/io/wallclock.hxx> // The WallClock API
#include <cyg/io/wallclock/wallclock.inl> // Helpers
 
#include <cyg/infra/diag.h> // For debugging
 
// REF4955 has a Dallas 1742W part.
#define DS_BASE 0xb5000000
#include <cyg/io/wallclock/ds1742.inl>
 
//-----------------------------------------------------------------------------
// Functions required for the hardware-driver API.
 
// Returns the number of seconds elapsed since 1970-01-01 00:00:00.
cyg_uint32
Cyg_WallClock::get_hw_seconds(void)
{
cyg_uint32 year, month, mday, hour, minute, second;
 
get_ds_hwclock(&year, &month, &mday, &hour, &minute, &second);
 
#if 0
// This will cause the test to eventually fail due to these printouts
// causing timer interrupts to be lost...
diag_printf("year %02d\n", year);
diag_printf("month %02d\n", month);
diag_printf("mday %02d\n", mday);
diag_printf("hour %02d\n", hour);
diag_printf("minute %02d\n", minute);
diag_printf("second %02d\n", second);
#endif
 
cyg_uint32 now = _simple_mktime(year, month, mday, hour, minute, second);
return now;
}
 
#ifdef CYGSEM_WALLCLOCK_SET_GET_MODE
 
// Sets the clock. Argument is seconds elapsed since 1970-01-01 00:00:00.
void
Cyg_WallClock::set_hw_seconds( cyg_uint32 secs )
{
cyg_uint32 year, month, mday, hour, minute, second;
 
_simple_mkdate(secs, &year, &month, &mday, &hour, &minute, &second);
 
set_ds_hwclock(year, month, mday, hour, minute, second);
}
 
#endif
 
void
Cyg_WallClock::init_hw_seconds(void)
{
#ifdef CYGSEM_WALLCLOCK_SET_GET_MODE
init_ds_hwclock();
#else
// This is our base: 1970-01-01 00:00:00
// Set the HW clock - if for nothing else, just to be sure it's in a
// legal range. Any arbitrary base could be used.
// After this the hardware clock is only read.
set_ds_hwclock(1970,1,1,0,0,0);
#endif
}
 
//-----------------------------------------------------------------------------
// End of devs/wallclock/mips/ref4955/wallclock_ref4955.cxx
/i386/pc/v2_0/cdl/i386_pc_wallclock_drivers.cdl
0,0 → 1,86
# ====================================================================
#
# i386_pc_wallclock_drivers.cdl
#
# Wallclock drivers - support for DS12887 RTC on the PC
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): rajt
# Contributors: rajt
# Date: 2001-07-19
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_DEVICES_WALLCLOCK_I386_PC {
display "PC board RTC Driver"
description "RTC driver for PC."
 
parent CYGPKG_IO_WALLCLOCK
active_if CYGPKG_IO_WALLCLOCK
active_if CYGPKG_HAL_I386_PC
requires CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS12887
 
include_dir cyg/io
 
define_proc {
puts $::cdl_system_header "/***** PC RTC driver proc output start *****/"
puts $::cdl_system_header "#define CYGDAT_DEVS_WALLCLOCK_DALLAS_12887_INL <cyg/io/devices_wallclock_i386_pc.inl>"
puts $::cdl_system_header "#define CYGDAT_DEVS_WALLCLOCK_i386_PC_CFG <pkgconf/devices_wallclock_i386_pc.h>"
puts $::cdl_system_header "/***** PC RTC driver proc output end *****/"
}
 
cdl_option CYGDAT_DEVS_WALLCLOCK_I386_PC_RTC_ADDRESS_PORT {
display "IO port address of the ADDRESS register"
flavor data
default_value 0x70
description "
This option sets the io address of the address port for
accessing the PC RTC"
}
 
cdl_option CYGDAT_DEVS_WALLCLOCK_I386_PC_RTC_DATA_PORT {
display "IO port address of the DATA register"
flavor data
default_value 0x71
description "
This option sets the io address of the data port for
accessing the PC RTC"
}
}
/i386/pc/v2_0/include/devices_wallclock_i386_pc.inl
0,0 → 1,55
//==========================================================================
//
// devs/wallclock/i386/pc/include/devs_wallclock_i386_pc.inl
//
// PC RTC IO definitions
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): rajt
// Contributors:rajt
// Date: 2001-07-19
// Purpose: PC RTC definitions for using DS12887
//####DESCRIPTIONEND####
//==========================================================================
 
#include CYGDAT_DEVS_WALLCLOCK_i386_PC_CFG
 
#define DS_ADDR CYGDAT_DEVS_WALLCLOCK_I386_PC_RTC_ADDRESS_PORT
#define DS_DATA CYGDAT_DEVS_WALLCLOCK_I386_PC_RTC_DATA_PORT
 
// EOF devs_wallclock_i386_pc.inl
/i386/pc/v2_0/ChangeLog
0,0 → 1,40
2001-09-18 Rajagopalan Thiruvenkatachary <rajt@us.ibm.com>
 
* include/devices_wallclock_i386_pc.inl:
* cdl/i386_pc_wallclock_drivers.cdl:
New package.
 
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
 
 
/sh/hs7729pci/v2_0/cdl/wallclock_hs7729pci.cdl
0,0 → 1,65
# ====================================================================
#
# wallclock_hs7729pci.cdl
#
# eCos wallclock for HS7729PCI driver configuration data
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): jskov
# Contributors: jskov
# Date: 2001-07-06
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_DEVICES_WALLCLOCK_SH_HS7729PCI {
parent CYGPKG_IO_WALLCLOCK
active_if CYGPKG_IO_WALLCLOCK
display "HS7729PCI wallclock driver"
requires CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS12887
requires CYGPKG_HAL_SH_SH7729_HS7729PCI
hardware
include_dir cyg/io
 
define_proc {
puts $::cdl_system_header "/***** wallclock driver proc output start *****/"
puts $::cdl_system_header "#define CYGDAT_DEVS_WALLCLOCK_DALLAS_12887_INL <cyg/io/devs_wallclock_sh_hs7729pci.inl>"
puts $::cdl_system_header "/***** wallclock driver proc output end *****/"
}
}
/sh/hs7729pci/v2_0/include/devs_wallclock_sh_hs7729pci.inl
0,0 → 1,70
//==========================================================================
//
// wallclock_hs7729pci.inl
//
// HS7729PCI wallclock details
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jskov
// Contributors: jskov
// Date: 2001-07-06
// Purpose: Wallclock driver details for HS7729PCI
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#define nDS_LINEAR
#define DS_ADDR 0xa80000e0
#define DS_DATA 0xa80000e2
 
#define DS_READ_UINT8(_a_, _d_) \
CYG_MACRO_START \
cyg_uint16 t; \
HAL_READ_UINT16((_a_), t); \
(_d_) = (t >> 8) & 0xff; \
CYG_MACRO_END
 
#define DS_WRITE_UINT8(_a_, _d_) \
CYG_MACRO_START \
HAL_WRITE_UINT16((_a_), (_d_)<<8); \
CYG_MACRO_END
 
 
//-----------------------------------------------------------------------------
// End of wallclock_hs7729pci.inl
/sh/hs7729pci/v2_0/ChangeLog
0,0 → 1,38
2001-07-06 Jesper Skov <jskov@redhat.com>
 
New package.
 
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
 
 
/sh/sh3/v2_0/cdl/wallclock_sh3.cdl
0,0 → 1,101
# ====================================================================
#
# wallclock_sh3.cdl
#
# eCos wallclock SH3 RTC-module driver configuration data
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): jskov
# Original data: nickg
# Contributors:
# Date: 2000-04-05
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_DEVICES_WALLCLOCK_SH3 {
parent CYGPKG_IO_WALLCLOCK
active_if CYGPKG_IO_WALLCLOCK
display "SH3 RTC-module wallclock driver"
requires CYGPKG_HAL_SH
hardware
compile wallclock_sh3.cxx
implements CYGINT_WALLCLOCK_HW_IMPLEMENTATIONS
active_if CYGIMP_WALLCLOCK_HARDWARE
 
cdl_option CYGIMP_WALLCLOCK_HARDWARE {
parent CYGPKG_IO_WALLCLOCK_IMPLEMENTATION
display "Hardware wallclock"
default_value 1
implements CYGINT_WALLCLOCK_IMPLEMENTATIONS
}
 
cdl_component CYGPKG_DEVICES_WALLCLOCK_SH3_OPTIONS {
display "SH3 RTC-module wallclock 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_WALLCLOCK_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 wallclock device. These flags are used in addition
to the set of global flags."
}
 
cdl_option CYGPKG_DEVICES_WALLCLOCK_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 wallclock device. These flags are removed from
the set of global flags if present."
}
 
}
}
/sh/sh3/v2_0/ChangeLog
0,0 → 1,83
2001-07-09 Jesper Skov <jskov@redhat.com>
 
* src/wallclock_sh3.cxx: fix description.
 
2001-03-20 Jesper Skov <jskov@redhat.com>
 
* src/wallclock_sh3.cxx: Don't include kernel config.
 
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.
 
2000-04-05 John Dallaway <jld@cygnus.co.uk>
 
* cdl/wallclock_sh3.cdl:
 
Provide hardware wallclock implementation as a radio button.
 
2000-04-05 Jesper Skov <jskov@redhat.com>
 
* src/wallclock_sh3.cxx:
Moved from devs/wallclock/current to here.
Get API from io/wallclock.
Deleted all non-SH3 changelog entries
 
2000-03-29 Jesper Skov <jskov@redhat.com>
 
* tests/wallclock2.cxx:
* include/wallclock.hxx:
* src/sh3.cxx:
* src/wallclock.cxx:
* cdl/wallclock.cdl:
Reworked WallClock API. It should now be simpler to add new
wallclock drivers. Added a simple test to print out the current
wallclock value so a human can verify battery backup works.
 
2000-03-17 Jesper Skov <jskov@redhat.com>
 
* cdl/wallclock.cdl:
* src/sh3.cxx:
Added wallclock driver for SH3 RTC module.
 
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
 
 
/sh/sh3/v2_0/src/wallclock_sh3.cxx
0,0 → 1,175
//==========================================================================
//
// devs/wallclock/sh3.cxx
//
// SH3 RTC module driver.
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jskov
// Contributors: jskov
// Date: 2000-03-17
// Purpose: Wallclock driver for SH3 CPU RTC module
//
//####DESCRIPTIONEND####
//
//==========================================================================
 
#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
 
#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/infra/diag.h> // For debugging
 
 
 
//-----------------------------------------------------------------------------
// Functions for setting and getting the hardware clock counters
 
// Year must be last two digits of "western calendar year". Leap year when
// divisible by four.
static void
set_sh3_hwclock(cyg_uint32 year, cyg_uint32 month, cyg_uint32 mday,
cyg_uint32 hour, cyg_uint32 minute, cyg_uint32 second)
{
// Stop RTC
HAL_WRITE_UINT8(CYGARC_REG_RCR2, CYGARC_REG_RCR2_RESET);
 
// Program it
HAL_WRITE_UINT8(CYGARC_REG_RYRCNT, TO_BCD(year));
HAL_WRITE_UINT8(CYGARC_REG_RMONCNT, TO_BCD(month));
HAL_WRITE_UINT8(CYGARC_REG_RDAYCNT, TO_BCD(mday));
HAL_WRITE_UINT8(CYGARC_REG_RHRCNT, TO_BCD(hour));
HAL_WRITE_UINT8(CYGARC_REG_RMINCNT, TO_BCD(minute));
HAL_WRITE_UINT8(CYGARC_REG_RSECCNT, TO_BCD(second));
 
// Start RTC
HAL_WRITE_UINT8(CYGARC_REG_RCR1, CYGARC_REG_RCR1_CIE);
HAL_WRITE_UINT8(CYGARC_REG_RCR2,
CYGARC_REG_RCR2_RTCEN | CYGARC_REG_RCR2_START);
 
}
 
static void
get_sh3_hwclock(cyg_uint32* year, cyg_uint32* month, cyg_uint32* mday,
cyg_uint32* hour, cyg_uint32* minute, cyg_uint32* second)
{
cyg_uint8 tmp;
 
do {
// Clear carry flag
HAL_WRITE_UINT8(CYGARC_REG_RCR1, 0);
// Read time
HAL_READ_UINT8(CYGARC_REG_RYRCNT, tmp);
*year = TO_DEC(tmp);
HAL_READ_UINT8(CYGARC_REG_RMONCNT, tmp);
*month = TO_DEC(tmp);
HAL_READ_UINT8(CYGARC_REG_RDAYCNT, tmp);
*mday = TO_DEC(tmp);
HAL_READ_UINT8(CYGARC_REG_RHRCNT, tmp);
*hour = TO_DEC(tmp);
HAL_READ_UINT8(CYGARC_REG_RMINCNT, tmp);
*minute = TO_DEC(tmp);
HAL_READ_UINT8(CYGARC_REG_RSECCNT, tmp);
*second = TO_DEC(tmp);
 
// Read carry flag
HAL_READ_UINT8(CYGARC_REG_RCR1, tmp);
} while (CYGARC_REG_RCR1_CF & tmp); // loop if carry set
}
 
//-----------------------------------------------------------------------------
// Functions required for the hardware-driver API.
 
// Returns the number of seconds elapsed since 1970-01-01 00:00:00.
cyg_uint32
Cyg_WallClock::get_hw_seconds(void)
{
cyg_uint32 year, month, mday, hour, minute, second;
 
get_sh3_hwclock(&year, &month, &mday, &hour, &minute, &second);
 
#if 0
// This will cause the test to eventually fail due to these printouts
// causing timer interrupts to be lost...
diag_printf("year %02d\n", year);
diag_printf("month %02d\n", month);
diag_printf("mday %02d\n", mday);
diag_printf("hour %02d\n", hour);
diag_printf("minute %02d\n", minute);
diag_printf("second %02d\n", second);
#endif
 
#ifndef CYGSEM_WALLCLOCK_SET_GET_MODE
// We know what we initialized the hardware for : 1970, so by doing this
// the returned time should be OK for 30 years uptime.
year += 1900;
#else
// Need to use sliding window or similar to figure out what the
// century should be... Patent issue is unclear, and since there's
// no battery backup of the clock, there's little point in
// investigating.
# error "Need some magic here to figure out century counter"
#endif
 
cyg_uint32 now = _simple_mktime(year, month, mday, hour, minute, second);
return now;
}
 
#ifndef CYGSEM_WALLCLOCK_SET_GET_MODE
 
void
Cyg_WallClock::init_hw_seconds(void)
{
// This is our base: 1970-01-01 00:00:00
// Set the HW clock - if for nothing else, just to be sure it's in a
// legal range. Any arbitrary base could be used.
// After this the hardware clock is only read.
set_sh3_hwclock(70,1,1,0,0,0);
}
 
#endif // CYGSEM_WALLCLOCK_SET_GET_MODE
 
//-----------------------------------------------------------------------------
// End of devs/wallclock/sh3.cxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.