From 8986eb3674f73ce5343160273e23faed563a786e Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Tue, 1 Mar 2011 17:40:16 +0000 Subject: Remove (Abandoned). --- c/src/lib/libbsp/i386/ts_386ex/clock/ckinit.c | 153 ------------------ c/src/lib/libbsp/i386/ts_386ex/clock/rtc.c | 218 -------------------------- 2 files changed, 371 deletions(-) delete mode 100644 c/src/lib/libbsp/i386/ts_386ex/clock/ckinit.c delete mode 100644 c/src/lib/libbsp/i386/ts_386ex/clock/rtc.c (limited to 'c/src/lib/libbsp/i386/ts_386ex/clock') diff --git a/c/src/lib/libbsp/i386/ts_386ex/clock/ckinit.c b/c/src/lib/libbsp/i386/ts_386ex/clock/ckinit.c deleted file mode 100644 index 7527f90354..0000000000 --- a/c/src/lib/libbsp/i386/ts_386ex/clock/ckinit.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Clock_initialize - * - * This routine initializes the Timer/Counter on the Intel - * 386ex evaluation board. - * - * The tick frequency is 1 millisecond. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - * $Id$ - */ - -#include -#include - -#include - -uint32_t Clock_isrs; /* ISRs until next tick */ -static uint32_t Clock_initial_isr_value; - -volatile uint32_t Clock_driver_ticks; - -extern void Clock_exit( void ); - -/* External Prototypes */ -extern void init_rtc(void); /* defined in 'rtc.c' */ -extern long rtc_read(rtems_time_of_day *); /* defined in 'rtc.c' */ - -/* - * These are set by clock driver during its init - */ - -rtems_device_major_number rtems_clock_major = ~0; -rtems_device_major_number rtems_clock_minor = 0; - -/* - * This is the ISR handler. - */ - -void Clock_isr(rtems_irq_hdl_param unused) -{ - /* enable_tracing(); */ - Clock_driver_ticks += 1; - if ( Clock_isrs == 1 ) { - rtems_clock_tick(); - Clock_isrs = Clock_initial_isr_value; /* rtems_configuration_get_microseconds_per_tick() / 1000;*/ - } - else - Clock_isrs -= 1; -} - -void ClockOff(const rtems_irq_connect_data* unused) -{ - outport_byte (TIMER_CONFIG, 0x80 ); /* disable the counter timer */ -} - -void ClockOn(const rtems_irq_connect_data* unused) -{ - outport_byte (TIMER_CONFIG, 0x00 ); /* enable the counter timer */ -} - -int ClockIsOn(const rtems_irq_connect_data* unused) -{ - return ((i8259s_cache & 0x1) == 0); -} - -static rtems_irq_connect_data clockIrqData = {BSP_PERIODIC_TIMER, - Clock_isr, - 0, - ClockOn, - ClockOff, - ClockIsOn}; - -rtems_device_driver Clock_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *pargp -) -{ - unsigned timer_counter_init_value; - unsigned char clock_lsb, clock_msb; - -#ifdef BSP_DEBUG - printk("Initializing clock driver in Clock_initialize().\n"); -#endif - -#ifdef LOAD_RTC_AT_START - /* Initialize clock from on-board real time clock. This breaks the */ - /* test code which assumes which assumes the application will do it. */ - { - rtems_time_of_day now; - - -#ifdef BSP_DEBUG - printk("Loading clock from on-board real-time clock.\n"); -#endif - - init_rtc(); - if (rtc_read(&now) >= 0) - rtems_clock_set(&now); - } -#endif - - Clock_driver_ticks = 0; - - Clock_isrs = - Clock_initial_isr_value = - rtems_configuration_get_microseconds_per_tick() / 1000; /* ticks per clock_isr */ - - /* - * configure the counter timer ( should be based on microsecs/tick ) - * NB. The divisor(Clock_isrs) resolves the is the same number that appears in confdefs.h - * when setting the microseconds_per_tick value. - */ - ClockOff ( &clockIrqData ); - - timer_counter_init_value = rtems_configuration_get_microseconds_per_tick() / Clock_isrs; - clock_lsb = (unsigned char)timer_counter_init_value; - clock_msb = timer_counter_init_value >> 8; - - outport_byte (TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN); - outport_byte (TIMER_CNTR0, clock_lsb ); /* load LSB first */ - outport_byte (TIMER_CNTR0, clock_msb ); /* then MSB */ - - if (!BSP_install_rtems_irq_handler (&clockIrqData)) { - printk("Unable to initialize system clock\n"); - rtems_fatal_error_occurred(1); - } - - /* - * make major/minor avail to others such as shared memory driver - */ - - rtems_clock_major = major; - rtems_clock_minor = minor; - - return RTEMS_SUCCESSFUL; -} - -void Clock_exit(void) -{ - ClockOff(&clockIrqData); - BSP_remove_rtems_irq_handler (&clockIrqData); -} diff --git a/c/src/lib/libbsp/i386/ts_386ex/clock/rtc.c b/c/src/lib/libbsp/i386/ts_386ex/clock/rtc.c deleted file mode 100644 index a82ac835db..0000000000 --- a/c/src/lib/libbsp/i386/ts_386ex/clock/rtc.c +++ /dev/null @@ -1,218 +0,0 @@ -/*-------------------------------------------------------------------------+ -| rtc.c v1.1 - PC386 BSP - 1997/08/07 -+--------------------------------------------------------------------------+ -| This file contains the real time clock manipulation package for the -| PC386 board. -+--------------------------------------------------------------------------+ -| (C) Copyright 1997 - -| - NavIST Group - Real-Time Distributed Systems and Industrial Automation -| -| http://pandora.ist.utl.pt -| -| Instituto Superior Tecnico * Lisboa * PORTUGAL -+--------------------------------------------------------------------------+ -| Disclaimer: -| -| This file is provided "AS IS" without warranty of any kind, either -| expressed or implied. -+--------------------------------------------------------------------------+ -| This code is based on: -| rtc.c,v 1.4 1995/12/19 20:07:15 joel Exp - go32 BSP -| With the following copyright notice: -| ************************************************************************** -| * COPYRIGHT (c) 1989-1999. -| * On-Line Applications Research Corporation (OAR). -| * -| * The license and distribution terms for this file may be -| * found in the file LICENSE in this distribution or at -| * http://www.rtems.com/license/LICENSE. -| ************************************************************************** -| -| $Id$ -+--------------------------------------------------------------------------*/ - -#include - -#include - -/*-------------------------------------------------------------------------+ -| Constants -+--------------------------------------------------------------------------*/ -#define IO_RTC 0x70 /* RTC */ - -#define RTC_SEC 0x00 /* seconds */ -#define RTC_SECALRM 0x01 /* seconds alarm */ -#define RTC_MIN 0x02 /* minutes */ -#define RTC_MINALRM 0x03 /* minutes alarm */ -#define RTC_HRS 0x04 /* hours */ -#define RTC_HRSALRM 0x05 /* hours alarm */ -#define RTC_WDAY 0x06 /* week day */ -#define RTC_DAY 0x07 /* day of month */ -#define RTC_MONTH 0x08 /* month of year */ -#define RTC_YEAR 0x09 /* month of year */ -#define RTC_STATUSA 0x0a /* status register A */ -#define RTCSA_TUP 0x80 /* time update, don't look now */ - -#define RTC_STATUSB 0x0b /* status register B */ - -#define RTC_INTR 0x0c /* status register C (R) interrupt source */ -#define RTCIR_UPDATE 0x10 /* update intr */ -#define RTCIR_ALARM 0x20 /* alarm intr */ -#define RTCIR_PERIOD 0x40 /* periodic intr */ -#define RTCIR_INT 0x80 /* interrupt output signal */ - -#define RTC_STATUSD 0x0d /* status register D (R) Lost Power */ -#define RTCSD_PWR 0x80 /* clock lost power */ - -#define RTC_DIAG 0x0e /* status register E - bios diagnostic */ -#define RTCDG_BITS "\020\010clock_battery\007ROM_cksum\006config_unit\005memory_size\004fixed_disk\003invalid_time" - -#define RTC_CENTURY 0x32 /* current century - increment in Dec99 */ - -/*-------------------------------------------------------------------------+ -| Auxiliary Functions -+--------------------------------------------------------------------------*/ -/*-------------------------------------------------------------------------+ -| Function: bcd -| Description: Convert 2 digit number to its BCD representation. -| Global Variables: None. -| Arguments: i - Number to convert. -| Returns: BCD representation of number. -+--------------------------------------------------------------------------*/ -static inline uint8_t -bcd(uint8_t i) -{ - return ((i / 16) * 10 + (i % 16)); -} /* bcd */ - -#define QUICK_READ /* Quick read of the RTC: don't return number of seconds. */ - -#ifndef QUICK_READ - -#define SECS_PER_DAY (24 * 60 * 60) -#define SECS_PER_REG_YEAR (365 * SECS_PER_DAY) - -/*-------------------------------------------------------------------------+ -| Function: ytos -| Description: Convert years to seconds (since 1970). -| Global Variables: None. -| Arguments: y - year to convert (1970 <= y <= 2100). -| Returns: number of seconds since 1970. -+--------------------------------------------------------------------------*/ -static inline uint32_t -ytos(uint16_t y) -{ /* v NUM LEAP YEARS v */ - return ((y - 1970) * SECS_PER_REG_YEAR + (y - 1970 + 1) / 4 * SECS_PER_DAY); -} /* ytos */ - -/*-------------------------------------------------------------------------+ -| Function: mtos -| Description: Convert months to seconds since January. -| Global Variables: None. -| Arguments: m - month to convert, leap - is this a month of a leap year. -| Returns: number of seconds since January. -+--------------------------------------------------------------------------*/ -static inline uint32_t -mtos(uint8_t m, bool leap) -{ - static uint16_t daysMonth[] = { 0, 0, 31, 59, 90, 120, 151, 181, - 212, 243, 273, 304, 334, 365 }; - /* Days since beginning of year until beginning of month. */ - - return ((daysMonth[m] + (leap ? 1 : 0)) * SECS_PER_DAY); -} /* mtos */ - -#endif /* QUICK_READ */ - -/*-------------------------------------------------------------------------+ -| Function: rtcin -| Description: Perform action on RTC and return its result. -| Global Variables: None. -| Arguments: what - what to write to RTC port (what to do). -| Returns: result received from RTC port after action performed. -+--------------------------------------------------------------------------*/ -static inline uint8_t -rtcin(uint8_t what) -{ - uint8_t r; - - outport_byte(IO_RTC, what); - inport_byte (IO_RTC+1, r); - return r; -} /* rtcin */ - -/*-------------------------------------------------------------------------+ -| Functions -+--------------------------------------------------------------------------*/ -/*-------------------------------------------------------------------------+ -| Function: init_rtc -| Description: Initialize real-time clock (RTC). -| Global Variables: None. -| Arguments: None. -| Returns: Nothing. -+--------------------------------------------------------------------------*/ -void -init_rtc(void) -{ - uint8_t s; - - /* initialize brain-dead battery powered clock */ - outport_byte(IO_RTC, RTC_STATUSA); - outport_byte(IO_RTC+1, 0x26); - outport_byte(IO_RTC, RTC_STATUSB); - outport_byte(IO_RTC+1, 2); - - outport_byte(IO_RTC, RTC_DIAG); - inport_byte (IO_RTC+1, s); - if (s) - printk("RTC BIOS diagnostic error %b\n", s); - - /* FIXME: This was last line's original version. How was it supposed to work? - printf("RTC BIOS diagnostic error %b\n", s, RTCDG_BITS); */ -} /* init_rtc */ - -/*-------------------------------------------------------------------------+ -| Function: rtc_read -| Description: Read present time from RTC and return it. -| Global Variables: None. -| Arguments: tod - to return present time in 'rtems_time_of_day' format. -| Returns: number of seconds from 1970/01/01 corresponding to 'tod'. -+--------------------------------------------------------------------------*/ -long int -rtc_read(rtems_time_of_day *tod) -{ - uint8_t sa; - uint32_t sec = 0; - - memset(tod, 0, sizeof *tod); /* zero tod structure */ - - /* do we have a realtime clock present? (otherwise we loop below) */ - sa = rtcin(RTC_STATUSA); - if (sa == 0xff || sa == 0) - return -1; - - /* ready for a read? */ - while ((sa&RTCSA_TUP) == RTCSA_TUP) - sa = rtcin(RTC_STATUSA); - - tod->year = bcd(rtcin(RTC_YEAR)) + 1900; /* year */ - if (tod->year < 1970) tod->year += 100; - tod->month = bcd(rtcin(RTC_MONTH)); /* month */ - tod->day = bcd(rtcin(RTC_DAY)); /* day */ - (void) bcd(rtcin(RTC_WDAY)); /* weekday */ - tod->hour = bcd(rtcin(RTC_HRS)); /* hour */ - tod->minute = bcd(rtcin(RTC_MIN)); /* minutes */ - tod->second = bcd(rtcin(RTC_SEC)); /* seconds */ - tod->ticks = 0; - -#ifndef QUICK_READ /* Quick read of the RTC: don't return number of seconds. */ - sec = ytos(tod->year); - sec += mtos(tod->month, (tod->year % 4) == 0); - sec += tod->day * SECS_PER_DAY; - sec += tod->hour * 60 * 60; /* hour */ - sec += tod->minute * 60; /* minutes */ - sec += tod->second; /* seconds */ -#endif /* QUICK_READ */ - - return (long int)sec; -} /* rtc_read */ -- cgit v1.2.3