Display BIOS date correctly

This commit is contained in:
2024-03-30 12:36:23 -05:00
parent 5b53383d80
commit b35a391887
4 changed files with 35 additions and 4 deletions

View File

@@ -1,7 +1,18 @@
#pragma once
#include "types.hpp"
#include <stddef.h>
namespace JabyEngine {
template<typename T>
static constexpr T pow(T base, T power) {
T result = base;
while(power > 1) {
result = result*base;
power--;
}
return result;
}
template<typename T>
static constexpr pair<T, T> div_and_mod(T value, T div) {
const auto result = value/div;
@@ -12,4 +23,15 @@ namespace JabyEngine {
const auto [tenth, rest] = div_and_mod(value, static_cast<uint8_t>(10));
return (tenth << 4 | rest);
}
template<typename T>
static constexpr T from_bcd(T value) {
T result = 0;
for(size_t n = 1; n < pow(10u, sizeof(T)*2); n *= 10) {
result += (value & 0b1111)*n;
value = value >> 4;
}
return result;
}
}

View File

@@ -56,7 +56,11 @@ namespace JabyEngine {
#pragma pack(pop)
struct BIOSVersion {
uint32_t date_bcd;
struct {
uint8_t day;
uint8_t month;
uint16_t year;
} date;
const char* kernel_maker;
const char* gui_version;
};