diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-18 16:48:14 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-18 16:48:14 +0000 |
commit | 0c04c377bc8ac177d28bd0e0096d7c6940d33cd4 (patch) | |
tree | ba3062eb819e89de2eee14397ffe61b202ad10de /c/src/lib/libbsp/powerpc/ppcn_60x/tod | |
parent | ./clock/Makefile.in,v (diff) | |
download | rtems-0c04c377bc8ac177d28bd0e0096d7c6940d33cd4.tar.bz2 |
./clock/Makefile.in,v
./clock/clock.c,v
./console/Makefile.in,v
./console/config.c,v
./console/console.c,v
./console/console.h,v
./console/debugio.c,v
./console/i8042.c,v
./console/i8042_p.h,v
./console/i8042vga.c,v
./console/i8042vga.h,v
./console/ns16550.c,v
./console/ns16550.h,v
./console/ns16550_p.h,v
./console/ns16550cfg.c,v
./console/ns16550cfg.h,v
./console/vga.c,v
./console/vga_p.h,v
./console/z85c30.c,v
./console/z85c30.h,v
./console/z85c30_p.h,v
./console/z85c30cfg.c,v
./console/z85c30cfg.h,v
./include/Makefile.in,v
./include/bsp.h,v
./include/chain.h,v
./include/coverhd.h,v
./include/extisrdrv.h,v
./include/nvram.h,v
./include/pci.h,v
./include/tod.h,v
./network/Makefile.in,v
./network/amd79c970.c,v
./network/amd79c970.h,v
./nvram/Makefile.in,v
./nvram/ds1385.h,v
./nvram/mk48t18.h,v
./nvram/nvram.c,v
./nvram/prepnvr.h,v
./nvram/stk11c68.h,v
./pci/Makefile.in,v
./pci/pci.c,v
./start/Makefile.in,v
./start/start.s,v
./startup/Makefile.in,v
./startup/bspclean.c,v
./startup/bspstart.c,v
./startup/bsptrap.s,v
./startup/device-tree,v
./startup/genpvec.c,v
./startup/linkcmds,v
./startup/rtems-ctor.cc,v
./startup/sbrk.c,v
./startup/setvec.c,v
./startup/spurious.c,v
./startup/swap.c,v
./timer/Makefile.in,v
./timer/timer.c,v
./tod/Makefile.in,v
./tod/cmos.h,v
./tod/tod.c,v
./universe/Makefile.in,v
./universe/universe.c,v
./vectors/Makefile.in,v
./vectors/README,v
./vectors/align_h.s,v
./vectors/vectors.s,v
./wrapup/Makefile.in,v
./Makefile.in,v
./README,v
./STATUS,v
./bsp_specs,v
Diffstat (limited to 'c/src/lib/libbsp/powerpc/ppcn_60x/tod')
-rw-r--r-- | c/src/lib/libbsp/powerpc/ppcn_60x/tod/Makefile.in | 56 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/ppcn_60x/tod/cmos.h | 95 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/ppcn_60x/tod/tod.c | 617 |
3 files changed, 768 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/powerpc/ppcn_60x/tod/Makefile.in b/c/src/lib/libbsp/powerpc/ppcn_60x/tod/Makefile.in new file mode 100644 index 0000000000..240373136e --- /dev/null +++ b/c/src/lib/libbsp/powerpc/ppcn_60x/tod/Makefile.in @@ -0,0 +1,56 @@ +# +# $Id$ +# + +@SET_MAKE@ +srcdir = @srcdir@ +VPATH = @srcdir@ +RTEMS_ROOT = @top_srcdir@ +PROJECT_ROOT = @PROJECT_ROOT@ + +PGM=${ARCH}/tod.rel + +# C source names, if any, go here -- minus the .c +C_PIECES=$(TOD_PIECES) +C_FILES=$(C_PIECES:%=%.c) +C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) + +H_FILES= + +SRCS=$(C_FILES) $(H_FILES) +OBJS=$(C_O_FILES) + +include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg +include $(RTEMS_ROOT)/make/leaf.cfg + +TOD_PIECES=tod + +# +# (OPTIONAL) Add local stuff here using += +# + +DEFINES += +CPPFLAGS += +CFLAGS += + +LD_PATHS += +LD_LIBS += +LDFLAGS += + +# +# Add your list of files to delete here. The config files +# already know how to delete some stuff, so you may want +# to just run 'make clean' first to see what gets missed. +# 'make clobber' already includes 'make clean' +# + +CLEAN_ADDITIONS += +CLOBBER_ADDITIONS += + +${PGM}: ${SRCS} ${OBJS} + $(make-rel) + +all: ${ARCH} $(SRCS) $(PGM) + +# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile +install: all diff --git a/c/src/lib/libbsp/powerpc/ppcn_60x/tod/cmos.h b/c/src/lib/libbsp/powerpc/ppcn_60x/tod/cmos.h new file mode 100644 index 0000000000..92cd7813a8 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/ppcn_60x/tod/cmos.h @@ -0,0 +1,95 @@ +/* Structure map for CMOS on PowerPC Reference Platform */ +/* + * COPYRIGHT (c) 1998 by Radstone Technology + * + * + * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK + * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU. + * + * You are hereby granted permission to use, copy, modify, and distribute + * this file, provided that this notice, plus the above copyright notice + * and disclaimer, appears in all copies. Radstone Technology will provide + * no support for this code. + * + */ +/* CMOS is the 64 bytes of RAM in the DS1385 chip */ +/* The CRC's are computed with x**16+x**12+x**5 + 1 polynomial */ +/* The clock is kept in 24 hour BCD mode and should be set to UT(GMT) */ + +#ifndef _CMOS_ +#define _CMOS_ + +/* + * Address port is at 0x70, data at 0x71 + */ +#define RTC_PORT 0x70 + +/* Define Realtime Clock register numbers. */ + +#define RTC_SECOND 0 /* second of minute [0..59] */ +#define RTC_SECOND_ALARM 1 /* seconds to alarm */ +#define RTC_MINUTE 2 /* minute of hour [0..59] */ +#define RTC_MINUTE_ALARM 3 /* minutes to alarm */ +#define RTC_HOUR 4 /* hour of day [0..23] */ +#define RTC_HOUR_ALARM 5 /* hours to alarm */ +#define RTC_DAY_OF_WEEK 6 /* day of week [1..7] */ +#define RTC_DAY_OF_MONTH 7 /* day of month [1..31] */ +#define RTC_MONTH 8 /* month of year [1..12] */ +#define RTC_YEAR 9 /* year [00..99] */ +#define RTC_CONTROL_REGISTERA 10 /* control register A */ +#define RTC_CONTROL_REGISTERB 11 /* control register B */ +#define RTC_CONTROL_REGISTERC 12 /* control register C */ +#define RTC_CONTROL_REGISTERD 13 /* control register D */ +#define RTC_BATTERY_BACKED_UP_RAM 14 /* battery backed up RAM [0..49] */ + +/* Define Control Register A structure. */ +#define DS1385_REGA_UIP 0x80 + +/* Define Control Register B structure. */ +#define DS1385_REGB_SET_TIME 0x80 +#define DS1385_REGB_TIM_IRQ_EN 0x40 +#define DS1385_REGB_ALM_IRQ_EN 0x20 +#define DS1385_REGB_UPD_IRQ_EN 0x10 +#define DS1385_REGB_SQR_EN 0x08 +#define DS1385_REGB_DATA_M 0x04 +#define DS1385_REGB_HOURS_FMT 0x02 +#define DS1385_REGB_DLS_EN 0x01 + +/* Define Control Register C structure. */ +#define DS1385_REGC_IRQ_REQ 0x08 +#define DS1385_REGC_IRQ_TIME 0x04 +#define DS1385_REGC_IRQ_ALM 0x02 +#define DS1385_REGC_IRQ_UPD 0x01 + +/* Define Control Register D structure. */ +#define DS1385_REGD_VALID 0x80 + +typedef struct _CMOS_MAP { + volatile rtems_unsigned8 DateAndTime[14]; + + rtems_unsigned8 SystemDependentArea1[2]; + rtems_unsigned8 SystemDependentArea2[8]; + rtems_unsigned8 FeatureByte0[1]; + rtems_unsigned8 FeatureByte1[1]; /* 19 = PW Flag; + attribute = write protect */ + rtems_unsigned8 Century[1]; /* century byte in BCD, e.g. 0x19 currently */ + rtems_unsigned8 FeatureByte3[1]; + rtems_unsigned8 FeatureByte4[1]; + rtems_unsigned8 FeatureByte5[1]; + rtems_unsigned8 FeatureByte6[1]; + rtems_unsigned8 FeatureByte7[1]; /* 1F = Alternate PW Flag; + attribute = write protect */ + rtems_unsigned8 BootPW[14]; /* Power-on password needed to boot system; + reset value = 0x00000000000000005a5a5a5a5a5a); + attribute = lock */ + rtems_unsigned8 BootCrc[2]; /* CRC on BootPW */ + rtems_unsigned8 ConfigPW[14]; /* Configuration Password needed to + change configuration of system; + reset value = 0x00000000000000005a5a5a5a5a5a); + attribute = lock */ + rtems_unsigned8 ConfigCrc[2]; /* CRC on ConfigPW */ +} CMOS_MAP, *PCMOS_MAP; + +#endif /* _CMOS_ */ diff --git a/c/src/lib/libbsp/powerpc/ppcn_60x/tod/tod.c b/c/src/lib/libbsp/powerpc/ppcn_60x/tod/tod.c new file mode 100644 index 0000000000..80e0ff3116 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/ppcn_60x/tod/tod.c @@ -0,0 +1,617 @@ +/* + * COPYRIGHT (c) 1998 by Radstone Technology + * + * + * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK + * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU. + * + * You are hereby granted permission to use, copy, modify, and distribute + * this file, provided that this notice, plus the above copyright notice + * and disclaimer, appears in all copies. Radstone Technology will provide + * no support for this code. + * + */ + +#define MIN_YEAR 1996 + +#include <stdlib.h> +#include "bsp.h" +#include "cmos.h" +#include "../nvram/mk48t18.h" + +#define Bin2BCD(Value) (((Value / 10) << 4) | (Value % 10)) +#define BCD2Bin(BcdValue) ((BcdValue >> 4) * 10 + (BcdValue & 0x0f)) + +/* + * Private types + */ +typedef +void +(*PTIMESET) +( + rtems_time_of_day *pTOD +); + +typedef +boolean +(*PTIMEGET) +( + rtems_time_of_day *pTOD +); + +typedef struct _TIME_ENTRY_TABLE +{ + PTIMESET SetTime; + PTIMEGET GetTime; +} TIME_ENTRY_TABLE, *PTIME_ENTRY_TABLE; + +/* + * Private routines + */ + +/* + * DS1385 specific routines + */ +static void timeDsSet(rtems_time_of_day *pTOD); +static boolean timeDsGet(rtems_time_of_day *pTOD); + +/* + * MK48T18 specific routines + */ +static void timeMkSet(rtems_time_of_day *pTOD); +static boolean timeMkGet(rtems_time_of_day *pTOD); + +TIME_ENTRY_TABLE timeDsTable = +{ + timeDsSet, + timeDsGet +}; + +TIME_ENTRY_TABLE timeMkTable = +{ + timeMkSet, + timeMkGet +}; + +/* + * Private variables + */ +static PTIME_ENTRY_TABLE pTimeFunc; + +/* + * Mutual-exclusion semaphore + */ +static rtems_id semRTC; + +/* + * This only works for the Gregorian calendar - i.e. after 1752 (in the UK) + */ +rtems_unsigned8 +GregorianDay(rtems_time_of_day *pTOD) +{ + boolean isLeap; + unsigned long leapsToDate; + unsigned long lastYear; + unsigned long day; + unsigned long MonthOffset[] = { 0, 31, 59, 90, 120, 151, + 181, 212, 243, 273, 304, 334 }; + + lastYear=pTOD->year-1; + + /* + * Number of leap corrections to apply up to end of last year + */ + leapsToDate = lastYear/4 - lastYear/100 + lastYear/400; + + /* + * This year is a leap year if it is divisible by 4 except when it is + * divisible by 100 unless it is divisible by 400 + * + * e.g. 1904 was a leap year, 1900 was not, 1996 is, and 2000 will be + */ + isLeap = (pTOD->year%4==0) && + ((pTOD->year%100!=0) || (pTOD->year%400==0)); + + if(isLeap && (pTOD->month>2)) + { + day=1; + } + else + { + day=0; + } + + day += lastYear*365 + leapsToDate + MonthOffset[pTOD->month-1] + + pTOD->day; + + return((rtems_unsigned8)(day%7)); +} + +void +DsWriteRawClockRegister ( + rtems_unsigned8 Register, + rtems_unsigned8 Value +) + +/*++ + +Routine Description: + + This routine reads the specified realtime clock register. + + This function was added to bridge the BCD format of the IBM roms + and the binary formate of NT + + +Arguments: + + Register - Supplies the number of the register whose value is read. + +Return Value: + + The value of the register is returned as the function value. + +--*/ + +{ + outport_byte((rtems_unsigned8 *)RTC_PORT, Register & 0x7f); + + /* Read the realtime clock register value. */ + + outport_byte((rtems_unsigned8 *)(RTC_PORT + 1), Value); + return; +} + +rtems_unsigned8 +DsReadRawClockRegister ( + rtems_unsigned8 Register +) + +/*++ + +Routine Description: + + This routine reads the specified realtime clock register. + + This function was added to bridge the BCD format of the IBM roms + and the binary formate of NT + + +Arguments: + + Register - Supplies the number of the register whose value is read. + +Return Value: + + The value of the register is returned as the function value. + +--*/ + +{ + rtems_unsigned8 ucDataByte; + + outport_byte((rtems_unsigned8 *)RTC_PORT, Register & 0x7f); + + /* Read the realtime clock register value. */ + + inport_byte((rtems_unsigned8 *)(RTC_PORT + 1), ucDataByte); + return ucDataByte; +} + +void +DsWriteClockRegister ( + rtems_unsigned8 Register, + rtems_unsigned8 Value +) + +/*++ + +Routine Description: + + This routine writes the specified value to the specified realtime + clock register. + +Arguments: + + Register - Supplies the number of the register whose value is written. + + Value - Supplies the value that is written to the specified register. + +Return Value: + + The value of the register is returned as the function value. + +--*/ + +{ + rtems_unsigned8 BcdValue; + + BcdValue = Bin2BCD(Value); + DsWriteRawClockRegister(Register, BcdValue); + return; +} + +rtems_unsigned8 +DsReadClockRegister ( + rtems_unsigned8 Register +) + +/*++ + +Routine Description: + + This routine reads the specified realtime clock register. + +Arguments: + + Register - Supplies the number of the register whose value is read. + +Return Value: + + The value of the register is returned as the function value. + +--*/ + +{ + rtems_unsigned8 BcdValue; + + BcdValue = DsReadRawClockRegister(Register); + return BCD2Bin(BcdValue); +} + +void +timeDsSet ( + rtems_time_of_day *pTOD + ) + +/*++ + +Routine Description: + + This routine sets the realtime clock. + + N.B. This routine assumes that the caller has provided any required + synchronization to set the realtime clock information. + +Arguments: + + pTOD - Supplies a pointer to a time structure that specifies the + realtime clock information. + +Return Value: + + If the power to the realtime clock has not failed, then the time + values are written to the realtime clock and a value of TRUE is + returned. Otherwise, a value of FALSE is returned. + +--*/ + +{ + rtems_unsigned8 ucDataByte; + PCMOS_MAP pCMOS = (PCMOS_MAP)0; + + /* If the realtime clock battery is still functioning, then write */ + /* the realtime clock values, and return a function value of TRUE. */ + /* Otherwise, return a function value of FALSE. */ + + ucDataByte = DsReadRawClockRegister(RTC_CONTROL_REGISTERD); + if (ucDataByte&DS1385_REGD_VALID) + { + /* Set the realtime clock control to set the time. */ + + ucDataByte = DS1385_REGB_HOURS_FMT | DS1385_REGB_SET_TIME; + DsWriteRawClockRegister(RTC_CONTROL_REGISTERB, ucDataByte); + + /* Write the realtime clock values. */ + + DsWriteClockRegister(RTC_YEAR, + (rtems_unsigned8)(pTOD->year%100)); + if(pTOD->year>=100) + { + DsWriteClockRegister((rtems_unsigned8) + ((unsigned long)&pCMOS->Century), + pTOD->year/100); + } + DsWriteClockRegister(RTC_MONTH, + (rtems_unsigned8)pTOD->month); + DsWriteClockRegister(RTC_DAY_OF_MONTH, + (rtems_unsigned8)pTOD->day); + DsWriteClockRegister(RTC_DAY_OF_WEEK, + (rtems_unsigned8) + (GregorianDay(pTOD) + 1)); + DsWriteClockRegister(RTC_HOUR, + (rtems_unsigned8)pTOD->hour); + DsWriteClockRegister(RTC_MINUTE, + (rtems_unsigned8)pTOD->minute); + DsWriteClockRegister(RTC_SECOND, + (rtems_unsigned8)pTOD->second); + + /* Set the realtime clock control to update the time. */ + + ucDataByte &= ~DS1385_REGB_SET_TIME; + DsWriteRawClockRegister(RTC_CONTROL_REGISTERB, ucDataByte); + return; + + } + else + { + return; + } +} + +boolean +timeDsGet ( + rtems_time_of_day *pTOD + ) + +/*++ + +Routine Description: + + This routine queries the realtime clock. + +Arguments: + + pTOD - Supplies a pointer to a time structure that receives + the realtime clock information. + +Return Value: + + If the power to the realtime clock has not failed, then the time + values are read from the realtime clock and a value of TRUE is + returned. Otherwise, a value of FALSE is returned. + +--*/ + +{ + rtems_unsigned8 ucDataByte; + PCMOS_MAP pCMOS = (PCMOS_MAP)0; + + /* If the realtime clock battery is still functioning, then read */ + /* the realtime clock values, and return a function value of TRUE. */ + /* Otherwise, return a function value of FALSE. */ + + ucDataByte = DsReadRawClockRegister(RTC_CONTROL_REGISTERD); + if(ucDataByte&DS1385_REGD_VALID) + { + /* Wait until the realtime clock is not being updated. */ + + do + { + ucDataByte=DsReadRawClockRegister(RTC_CONTROL_REGISTERA); + } while (ucDataByte&DS1385_REGA_UIP); + + /* Read the realtime clock values. */ + + pTOD->year=(rtems_unsigned16) + (DsReadClockRegister( + (rtems_unsigned8) + (unsigned long)&pCMOS->Century) + *100 + DsReadClockRegister(RTC_YEAR)); + pTOD->month=DsReadClockRegister(RTC_MONTH); + pTOD->day=DsReadClockRegister(RTC_DAY_OF_MONTH); + pTOD->hour=DsReadClockRegister(RTC_HOUR); + pTOD->minute=DsReadClockRegister(RTC_MINUTE); + pTOD->second=DsReadClockRegister(RTC_SECOND); + return TRUE; + } + else + { + return FALSE; + } +} + +void +timeMkSet ( + rtems_time_of_day *pTOD + ) + +/*++ + +Routine Description: + + This routine sets the realtime clock. + + N.B. This routine assumes that the caller has provided any required + synchronization to set the realtime clock information. + +Arguments: + + pTOD - Supplies a pointer to a time structure that specifies the + realtime clock information. + +Return Value: + + If the power to the realtime clock has not failed, then the time + values are written to the realtime clock and a value of TRUE is + returned. Otherwise, a value of FALSE is returned. + +--*/ + +{ + PMK48T18_NVRAM_MAP pNvRAM = MK48T18_BASE; + + /* + * Set the RTC into write mode + */ + pNvRAM->CMOS.Control|=MK48T18_CTRL_WRITE; + EIEIO; + + /* + * Write the realtime clock values. + */ + + pNvRAM->CMOS.Year = (rtems_unsigned8)Bin2BCD(pTOD->year%100); + if(pTOD->year>=100) + { + pNvRAM->CMOS.Century=(rtems_unsigned8) + Bin2BCD(pTOD->year/100); + } + pNvRAM->CMOS.Month = (rtems_unsigned8)Bin2BCD(pTOD->month); + pNvRAM->CMOS.Date = (rtems_unsigned8)Bin2BCD(pTOD->day); + pNvRAM->CMOS.Day = (rtems_unsigned8)(GregorianDay(pTOD) + 1); + pNvRAM->CMOS.Hour = (rtems_unsigned8)Bin2BCD(pTOD->hour); + pNvRAM->CMOS.Minute = (rtems_unsigned8)Bin2BCD(pTOD->minute); + pNvRAM->CMOS.Second = (rtems_unsigned8)Bin2BCD(pTOD->second); + + /* + * Set the realtime clock control to update the time. + */ + + EIEIO; + pNvRAM->CMOS.Control&=~MK48T18_CTRL_WRITE; +} + +boolean +timeMkGet ( + rtems_time_of_day *pTOD + ) + +/*++ + +Routine Description: + + This routine queries the realtime clock. + + N.B. This routine is required to provide any synchronization necessary + to query the realtime clock information. + +Arguments: + + pTOD - Supplies a pointer to a time structure that receives + the realtime clock information. + +Return Value: + + If the power to the realtime clock has not failed, then the time + values are read from the realtime clock and a value of TRUE is + returned. Otherwise, a value of FALSE is returned. + +--*/ + +{ + PMK48T18_NVRAM_MAP pNvRAM = MK48T18_BASE; + + /* + * Set the RTC into read mode + */ + pNvRAM->CMOS.Control|=MK48T18_CTRL_READ; + EIEIO; + + /* + * Read the realtime clock values. + */ + + pTOD->year = (rtems_unsigned16)(100*BCD2Bin(pNvRAM->CMOS.Century)+ + BCD2Bin(pNvRAM->CMOS.Year)); + pTOD->month = (rtems_unsigned8)BCD2Bin(pNvRAM->CMOS.Month); + pTOD->day = (rtems_unsigned8)BCD2Bin(pNvRAM->CMOS.Date); + pTOD->hour = (rtems_unsigned8)BCD2Bin(pNvRAM->CMOS.Hour); + pTOD->minute = (rtems_unsigned8)BCD2Bin(pNvRAM->CMOS.Minute); + pTOD->second = (rtems_unsigned8)BCD2Bin(pNvRAM->CMOS.Second); + + /* + * Set the realtime clock control to normal mode. + */ + EIEIO; + pNvRAM->CMOS.Control&=~MK48T18_CTRL_READ; + + return TRUE; +} + +/* + * Set up entry table + */ +void +InitializeRTC(void) +{ + rtems_status_code sc; + + switch(ucSystemType) + { + case SYS_TYPE_PPC1: + { + if(ucBoardRevMaj<5) + { + pTimeFunc=&timeDsTable; + break; + } + /* + * For the 005 and later drop through to the PPC1a support + */ + } + + case SYS_TYPE_PPC1a: + { + pTimeFunc=&timeMkTable; + break; + } + + default: + { + pTimeFunc=&timeDsTable; + break; + } + } + + /* + * Set up mutex semaphore + */ + sc = rtems_semaphore_create ( + rtems_build_name ('R', 'T', 'C', 's'), + 1, + RTEMS_BINARY_SEMAPHORE | + RTEMS_INHERIT_PRIORITY | + RTEMS_PRIORITY, + RTEMS_NO_PRIORITY, + &semRTC); + if (sc != RTEMS_SUCCESSFUL) + { + rtems_fatal_error_occurred (sc); + } +} + +void setRealTimeToRTEMS() +{ + rtems_time_of_day rtc_tod; + + rtems_semaphore_obtain(semRTC, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + (pTimeFunc->GetTime)(&rtc_tod); + rtems_semaphore_release(semRTC); + + /* + * Millenium fix... + * + * If year is earlier than MIN_YEAR then assume the clock has wrapped from + * 1999 to 1900 so advance by a century + */ + if(rtc_tod.year<MIN_YEAR) + { + rtc_tod.year+=100; + rtems_semaphore_obtain(semRTC, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + (pTimeFunc->SetTime)(&rtc_tod); + rtems_semaphore_release(semRTC); + } + + rtc_tod.ticks=0; + + rtems_clock_set( &rtc_tod ); +} + +void setRealTimeFromRTEMS() +{ + rtems_time_of_day rtems_tod; + + rtems_clock_get( RTEMS_CLOCK_GET_TOD, &rtems_tod ); + rtems_semaphore_obtain(semRTC, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + (pTimeFunc->SetTime)(&rtems_tod); + rtems_semaphore_release(semRTC); +} + + +int checkRealTime() +{ + return 0; +} |