35 .year = rtcDateTime.date.year + century,
36 .month = rtcDateTime.date.month,
37 .day = rtcDateTime.date.day,
38 .weekday = rtcDateTime.weekday,
39 .hour = rtcDateTime.time.hour,
40 .minute = rtcDateTime.time.minute,
41 .second = rtcDateTime.time.second,
121 return static_cast<igros_byte_t>((value & 0x0F_u32) + (((value >> 4) & 0x0F_u32) * 10_u32));
147 const auto readStable = []()
noexcept {
153 auto rtcDateTime {readStable()};
154 auto lastDateTime {readStable()};
156 while (lastDateTime != rtcDateTime) {
157 lastDateTime = rtcDateTime;
158 rtcDateTime = readStable();
165 if (!flags.isSet(RTC_B::BINARY)) {
167 const auto hourModeBit {
static_cast<igros_byte_t>(rtcDateTime.time.hour & 0x80_u8)};
169 rtcDateTime.time.hour &= 0x7F_u8;
173 rtcDateTime.time.hour |= hourModeBit;
178 if (!flags.isSet(RTC_B::TIME_24)) {
179 const auto isPM {0x00_u8 != (0x80_u8 & rtcDateTime.time.hour)};
181 rtcDateTime.time.hour =
static_cast<igros_byte_t>(((rtcDateTime.time.hour & 0x7F_u8) % 12_u8) + (isPM ? 12_u8 : 0_u8));
184 return clockFromRTC(rtcDateTime, ((0x00_u8 != century) ? (century * 100_u32) : 2000_u32));
195 "RTC date/time:\t%02d.%02d.%04d %02d:%02d:%02d",
static auto readPort8(const port_t addr) noexcept -> igros_byte_t
Read byte from port.
static void writePort8(const port_t addr, const igros_byte_t value) noexcept
Write byte to port.
static constexpr auto from(const U value) noexcept -> kFlags
From raw value (hardware register, table entry).
std::uint8_t igros_byte_t
8-bit unsigned integer
std::uint32_t igros_dword_t
32-bit unsigned integer
Bit flags template datatype.
Kernel text print functions.
@ UPDATING
Date/time update in progress (values unstable).
@ TIME_24
24-hour format (12-hour otherwise, bit 7 of hour - PM)
@ BINARY
Binary values (BCD otherwise).
Architecture-independent interface: drivers and aliases of current architecture types.
auto rtcReadDateTime() noexcept -> rtcDateTime_t
Read CMOS date/time.
constexpr auto RTC_REGISTER_B
Status register B.
auto clockFromRTC(const rtcDateTime_t &rtcDateTime, const igros_dword_t century) noexcept -> clockDateTime_t
Clock from RTC conversion.
constexpr auto RTC_WEEKDAY
Day of week register.
constexpr auto CMOS_DATA
Data port.
void rtcTimeFromBCD(rtcTime_t &time) noexcept
Convert BCD time to binary.
constexpr auto RTC_YEAR
Year register.
auto rtcReadTime() noexcept -> rtcTime_t
Read CMOS time.
constexpr auto RTC_MONTH
Month register.
constexpr auto RTC_DAY
Day of month register.
auto rtcRead(const igros_byte_t cmd) noexcept -> igros_byte_t
Read CMOS register.
auto rtcFromBCD(const igros_byte_t bcd) noexcept -> igros_byte_t
Convert BCD to binary.
constexpr auto RTC_HOUR
Hour register.
constexpr auto RTC_SECOND
Second register.
void rtcDateTimeFromBCD(rtcDateTime_t &dateTime) noexcept
Convert BCD date/time to binary.
constexpr auto RTC_MINUTE
Minute register.
auto clockGetCurrentDateTime() noexcept -> clockDateTime_t
Get current date/time.
constexpr auto RTC_REGISTER_A
Status register A.
constexpr auto CMOS_COMMAND
Register select port.
auto rtcSetup() noexcept -> bool
Setup RTC function.
auto rtcReadDate() noexcept -> rtcDate_t
Read CMOS date.
constexpr auto RTC_CENTURY
Century register (ACPI FADT default).
void rtcDateFromBCD(rtcDate_t &date) noexcept
Convert BCD date to binary.
void kprintf(const char *const format,...) noexcept
Kernel printf function (arguments are checked against format at compile time).
igros_word_t port_t
Define port data type which is 16bit word.