/*
 * clock.h
 *
 * Copyright 2013 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _CLOCK_H_
#define _CLOCK_H_

#include <sdk/clock.h>

#define CLOCK_IRQ 8
#define CLOCK_PM_BIT (1 << 7)

#define CLOCK_DAYLIGHT_SAVINGS (1 << 0)
#define CLOCK_24HOUR_MODE (1 << 1)
#define CLOCK_BINARY_MODE (1 << 2)
#define CLOCK_SQUARE_WAVE (1 << 3)
#define CLOCK_UPDATE_INT (1 << 4)
#define CLOCK_ALARM_INT (1 << 5)
#define CLOCK_PERIODIC_INT (1 << 6)
#define CLOCK_DISABLE (1 << 7)

#define CMOS_CMD_PORT 0x70
#define CMOS_DATA_PORT 0x71

#define CMOS_RTC_SECONDS_REG 0x00
#define CMOS_RTC_MINUTES_REG 0x02
#define CMOS_RTC_HOURS_REG 0x04
#define CMOS_RTC_DAY_REG 0x07
#define CMOS_RTC_MONTH_REG 0x08
#define CMOS_RTC_YEAR_REG 0x09
#define CMOS_RTC_STA_REG 0x0A
#define CMOS_RTC_STB_REG 0x0B
#define CMOS_RTC_STC_REG 0x0C

void clock_init();
bool_t clock_check_time(clock_time_t *time);

#endif
