diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/cmos.c | 18 | ||||
-rw-r--r-- | src/kernel/cmos.h | 1 | ||||
-rw-r--r-- | src/kernel/main.c | 1 |
3 files changed, 15 insertions, 5 deletions
diff --git a/src/kernel/cmos.c b/src/kernel/cmos.c index 39f7c4f..1a95805 100644 --- a/src/kernel/cmos.c +++ b/src/kernel/cmos.c @@ -3,9 +3,22 @@ static inline uint8_t read_cmos(uint8_t reg) { outb(0x0070, reg); + for (uint32_t i = 0; i < 1000000; ++i) + ;//spin return inb(0x0071); } +static inline void write_cmos(uint8_t reg, uint8_t value) { + outb(0x0070, reg); + for (uint32_t i = 0; i < 1000000; ++i) + ;//spin + outb(0x0071, value); +} + +void cmos_init() { + write_cmos(0x0b, read_cmos(0x0b) | 0x06); +} + //The idea of reading until you get the same value twice, and checking the status register // is from the OSDev Wiki page at <https://wiki.osdev.org/CMOS#The_Real-Time_Clock>. struct rtc_time get_rtc_time() { @@ -21,11 +34,6 @@ get_sec: } ret.minutes = read_cmos(0x02); ret.hours = read_cmos(0x04); - if (ret.hours & 0x80) { - ret.hours -= 0x80 - 12; - if (ret.hours == 24) - ret.hours = 0; - } ret.day_of_week = read_cmos(0x06); ret.day_of_month = read_cmos(0x07); ret.month = read_cmos(0x08); diff --git a/src/kernel/cmos.h b/src/kernel/cmos.h index 53ec398..515de1d 100644 --- a/src/kernel/cmos.h +++ b/src/kernel/cmos.h @@ -14,5 +14,6 @@ struct rtc_time { }; struct rtc_time get_rtc_time(); +void cmos_init(); #endif
\ No newline at end of file diff --git a/src/kernel/main.c b/src/kernel/main.c index 7e49049..36b5fc1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -23,6 +23,7 @@ void _start_user_mode() __attribute__ ((noreturn)); __attribute__ ((noreturn)) void main() { + cmos_init(); init_pagemap(); init_paging(); init_tasks(); |