mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-12 05:58:15 -04:00
Cleanup
This commit is contained in:
parent
90277e3355
commit
a417a07ab1
@ -129,7 +129,6 @@ void uptime_command(const char*){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CURRENT_YEAR 2013
|
#define CURRENT_YEAR 2013
|
||||||
#define century_register 0x00
|
|
||||||
#define cmos_address 0x70
|
#define cmos_address 0x70
|
||||||
#define cmos_data 0x71
|
#define cmos_data 0x71
|
||||||
|
|
||||||
@ -151,16 +150,18 @@ void date_command(const char*){
|
|||||||
uint8_t month;
|
uint8_t month;
|
||||||
unsigned int year;
|
unsigned int year;
|
||||||
|
|
||||||
uint8_t century;
|
|
||||||
uint8_t last_second;
|
uint8_t last_second;
|
||||||
uint8_t last_minute;
|
uint8_t last_minute;
|
||||||
uint8_t last_hour;
|
uint8_t last_hour;
|
||||||
uint8_t last_day;
|
uint8_t last_day;
|
||||||
uint8_t last_month;
|
uint8_t last_month;
|
||||||
uint8_t last_year;
|
uint8_t last_year;
|
||||||
uint8_t last_century;
|
|
||||||
uint8_t registerB;
|
uint8_t registerB;
|
||||||
|
|
||||||
|
//TODO When ACPI gets supported, get the address
|
||||||
|
//of the century register and use it to make
|
||||||
|
//better year calculation
|
||||||
|
|
||||||
while (get_update_in_progress_flag()){}; // Make sure an update isn't in progress
|
while (get_update_in_progress_flag()){}; // Make sure an update isn't in progress
|
||||||
|
|
||||||
second = get_RTC_register(0x00);
|
second = get_RTC_register(0x00);
|
||||||
@ -170,10 +171,6 @@ void date_command(const char*){
|
|||||||
month = get_RTC_register(0x08);
|
month = get_RTC_register(0x08);
|
||||||
year = get_RTC_register(0x09);
|
year = get_RTC_register(0x09);
|
||||||
|
|
||||||
if(century_register != 0) {
|
|
||||||
century = get_RTC_register(century_register);
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
last_second = second;
|
last_second = second;
|
||||||
last_minute = minute;
|
last_minute = minute;
|
||||||
@ -181,7 +178,6 @@ void date_command(const char*){
|
|||||||
last_day = day;
|
last_day = day;
|
||||||
last_month = month;
|
last_month = month;
|
||||||
last_year = year;
|
last_year = year;
|
||||||
last_century = century;
|
|
||||||
|
|
||||||
while (get_update_in_progress_flag()){}; // Make sure an update isn't in progress
|
while (get_update_in_progress_flag()){}; // Make sure an update isn't in progress
|
||||||
|
|
||||||
@ -191,13 +187,8 @@ void date_command(const char*){
|
|||||||
day = get_RTC_register(0x07);
|
day = get_RTC_register(0x07);
|
||||||
month = get_RTC_register(0x08);
|
month = get_RTC_register(0x08);
|
||||||
year = get_RTC_register(0x09);
|
year = get_RTC_register(0x09);
|
||||||
|
|
||||||
if(century_register != 0) {
|
|
||||||
century = get_RTC_register(century_register);
|
|
||||||
}
|
|
||||||
} while( (last_second != second) || (last_minute != minute) || (last_hour != hour) ||
|
} while( (last_second != second) || (last_minute != minute) || (last_hour != hour) ||
|
||||||
(last_day != day) || (last_month != month) || (last_year != year) ||
|
(last_day != day) || (last_month != month) || (last_year != year) );
|
||||||
(last_century != century) );
|
|
||||||
|
|
||||||
registerB = get_RTC_register(0x0B);
|
registerB = get_RTC_register(0x0B);
|
||||||
|
|
||||||
@ -211,9 +202,6 @@ void date_command(const char*){
|
|||||||
month = (month & 0x0F) + ((month / 16) * 10);
|
month = (month & 0x0F) + ((month / 16) * 10);
|
||||||
year = (year & 0x0F) + ((year / 16) * 10);
|
year = (year & 0x0F) + ((year / 16) * 10);
|
||||||
|
|
||||||
if(century_register != 0) {
|
|
||||||
century = (century & 0x0F) + ((century / 16) * 10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert 12 hour clock to 24 hour clock if necessary
|
// Convert 12 hour clock to 24 hour clock if necessary
|
||||||
@ -224,11 +212,9 @@ void date_command(const char*){
|
|||||||
|
|
||||||
// Calculate the full (4-digit) year
|
// Calculate the full (4-digit) year
|
||||||
|
|
||||||
if(century_register != 0) {
|
year += (CURRENT_YEAR / 100) * 100;
|
||||||
year += century * 100;
|
if(year < CURRENT_YEAR){
|
||||||
} else {
|
year += 100;
|
||||||
year += (CURRENT_YEAR / 100) * 100;
|
|
||||||
if(year < CURRENT_YEAR) year += 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
k_print((std::size_t) day);
|
k_print((std::size_t) day);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user