#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <sys/kassert.h>
#include <sys/kdebug.h>
#include <sys/ktime.h>
#include "ioport.h"
Go to the source code of this file.
◆ BCD_TO_BIN
#define BCD_TO_BIN |
( |
|
_B | ) |
((_B & 0x0F) + ((_B >> 4) * 10)) |
◆ RTC_DAY
Definition at line 16 of file rtc.c.
◆ RTC_HOURS
Definition at line 14 of file rtc.c.
◆ RTC_MINUTES
Definition at line 13 of file rtc.c.
◆ RTC_MONTH
Definition at line 17 of file rtc.c.
◆ RTC_SECONDS
Definition at line 12 of file rtc.c.
◆ RTC_WEEKDAY
Definition at line 15 of file rtc.c.
◆ RTC_YEAR
Definition at line 18 of file rtc.c.
◆ RTC_Init()
Definition at line 23 of file rtc.c.
24{
27
28 kprintf(
"RTC: Measuring CPU clock...\n");
29
31 while (1) {
33 if (first != second)
34 break;
35 first = second;
36 }
38
40 while (1) {
42 if (first != second)
43 break;
44 first = second;
45 }
47
48 kprintf(
"RTC: %lld Ticks Per Second: %lld\n", second, stopTSC - startTSC);
49
51}
int kprintf(const char *fmt,...)
void KTime_SetTime(UnixEpoch epoch, uint64_t tsc, uint64_t tps)
◆ RTC_ReadReg()
Definition at line 54 of file rtc.c.
55{
58}
static INLINE uint8_t inb(uint16_t port)
static INLINE void outb(uint16_t port, uint8_t data)
◆ RTC_ReadTime()
Definition at line 61 of file rtc.c.
62{
64 bool isPM = false;
66
67
75
76
78 isPM = true;
79 }
80 if ((flags & 0x04) == 0) {
81#define BCD_TO_BIN(_B) ((_B & 0x0F) + ((_B >> 4) * 10))
89 }
90 if (((flags & 0x02) == 0) && isPM) {
91 tm.hour = (
tm.hour + 12) % 24;
92 }
93
96
99
100
102}
UnixEpoch KTime_ToEpoch(const KTime *tm)
static uint8_t RTC_ReadReg(uint8_t reg)