X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/b26d3165c52589d1f8de37bf0df27ad96f460f47..1fe5f5eb5378a47bf0f3451762743c162e40faad:/lunaix-os/hal/rtc.c diff --git a/lunaix-os/hal/rtc.c b/lunaix-os/hal/rtc.c deleted file mode 100644 index bc2c2ef..0000000 --- a/lunaix-os/hal/rtc.c +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @file rtc.c - * @author Lunaixsky - * @brief RTC & CMOS abstraction. Reference: MC146818A & Intel Series 500 PCH datasheet - * @version 0.1 - * @date 2022-03-07 - * - * @copyright Copyright (c) 2022 - * - */ -#include -#include - -void -rtc_init() { - u8_t regA = rtc_read_reg(RTC_REG_A | WITH_NMI_DISABLED); - regA = (regA & ~0x7f) | RTC_FREQUENCY_1024HZ | RTC_DIVIDER_33KHZ; - rtc_write_reg(RTC_REG_A | WITH_NMI_DISABLED, regA); - - // Make sure the rtc timer is disabled by default - rtc_disable_timer(); -} - -u8_t -rtc_read_reg(u8_t reg_selector) -{ - io_outb(RTC_INDEX_PORT, reg_selector); - return io_inb(RTC_TARGET_PORT); -} - -void -rtc_write_reg(u8_t reg_selector, u8_t val) -{ - io_outb(RTC_INDEX_PORT, reg_selector); - io_outb(RTC_TARGET_PORT, val); -} - -u8_t -bcd2dec(u8_t bcd) -{ - return ((bcd & 0xF0) >> 1) + ((bcd & 0xF0) >> 3) + (bcd & 0xf); -} - - -void -rtc_enable_timer() { - u8_t regB = rtc_read_reg(RTC_REG_B | WITH_NMI_DISABLED); - rtc_write_reg(RTC_REG_B | WITH_NMI_DISABLED, regB | RTC_TIMER_ON); -} - -void -rtc_disable_timer() { - u8_t regB = rtc_read_reg(RTC_REG_B | WITH_NMI_DISABLED); - rtc_write_reg(RTC_REG_B | WITH_NMI_DISABLED, regB & ~RTC_TIMER_ON); -} \ No newline at end of file