/*
    TMClock.h, Copyright (c) by Silvio Dragone & David Reist,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public Licence.
 
    A full copy of the GNU GPL is provided in the file COPYING found in the 
    development root of Topsy.
*/

#ifndef __TMCLOCK_H
#define __TMCLOCK_H

#include "tm-include.h"
#include "cpu.h"
#include "Configuration.h"

/* The 4 system timers of the SA */
typedef enum { CLOCK0, CLOCK1, CLOCK2, CLOCK3 } ClockId;

/* Emulates modes for the 82C54, because all other systems had a 82C54.
 * Only RATEGENERATOR is supported.
 */
typedef enum { RATEGENERATOR } ClockMode;

/* Configuration of the OS timer (each counter separately) */
Error setClockValue( ClockId cId, int period, ClockMode cMode );
void setClockValue_asm( unsigned long int TimerNo, int period, unsigned long int TimerEnable );
void resetClock_asm( unsigned long int TimerNo, unsigned long int TimerDisable );

void tmResetClockInterrupt( ClockId cId);

/* Configuration of the PCI interrupt handler */
InterruptHandler tmPCIIntHandler(void);

/* RTC routines
 * Seconds difference from January 1st 1998, 00:00, UTC
 */
unsigned long tmRTClockGetSeconds(void);
void tmRTClockSetSeconds(unsigned long seconds, unsigned long microSeconds);

#endif
