Compare commits
No commits in common. "ef75ad874dcf7061df3f47c8ed1ac4e287d3200f" and "ddf3cfff681ec4af542a1d4ee32736259f7e2a19" have entirely different histories.
ef75ad874d
...
ddf3cfff68
@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define SECOND_REGISTER 0x00
|
|
||||||
#define MINUTE_REGISTER 0x02
|
|
||||||
#define HOUR_REGISTER 0x04
|
|
||||||
#define DAY_OF_THE_MONTH_REGISTER 0x07
|
|
||||||
#define MONTH_REGISTER 0x08
|
|
||||||
#define YEAR_REGISTER 0x09
|
|
||||||
#define CENTURY_REGISTER 0x32
|
|
||||||
|
|
||||||
#define REGISTER_A 0x0A
|
|
||||||
#define REGISTER_B 0x0B
|
|
||||||
|
|
||||||
enum {
|
|
||||||
CMOS_ADDRESS = 0x70,
|
|
||||||
CMOS_DATA = 0x71
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rtc_date {
|
|
||||||
uint8_t second;
|
|
||||||
uint8_t minute;
|
|
||||||
uint8_t hour;
|
|
||||||
|
|
||||||
uint8_t index_of_the_day;
|
|
||||||
uint8_t day;
|
|
||||||
uint8_t month;
|
|
||||||
uint32_t year;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rtc_date get_date(void);
|
|
@ -53,7 +53,6 @@ typedef enum {
|
|||||||
ECHO,
|
ECHO,
|
||||||
COLOR,
|
COLOR,
|
||||||
MERDELLA,
|
MERDELLA,
|
||||||
DATE,
|
|
||||||
ERROR
|
ERROR
|
||||||
} CMD_TOK;
|
} CMD_TOK;
|
||||||
|
|
||||||
@ -61,4 +60,3 @@ void shell_init(void);
|
|||||||
void reboot(void);
|
void reboot(void);
|
||||||
void halt(void);
|
void halt(void);
|
||||||
void print_stack(void);
|
void print_stack(void);
|
||||||
void date(void);
|
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
#include "sys/io.h"
|
|
||||||
|
|
||||||
#include "rtc.h"
|
|
||||||
|
|
||||||
#include "kprintf.h"
|
|
||||||
|
|
||||||
static uint16_t raw_read_register(uint16_t cmos_register)
|
|
||||||
{
|
|
||||||
//selecting the register
|
|
||||||
outb(CMOS_ADDRESS, cmos_register);
|
|
||||||
//read value of the selectect register
|
|
||||||
return inb(CMOS_DATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t update_is_in_progress(void)
|
|
||||||
{
|
|
||||||
return raw_read_register(REGISTER_A) & 0x80;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t read_register(uint16_t cmos_register)
|
|
||||||
{
|
|
||||||
while (update_is_in_progress())
|
|
||||||
kprintf(0, "%d\n", update_is_in_progress());
|
|
||||||
return raw_read_register(cmos_register);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t bcd_mode_to_bin(uint8_t value)
|
|
||||||
{
|
|
||||||
return (value & 0x0F) + ((value/ 16) * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct rtc_date get_date(void)
|
|
||||||
{
|
|
||||||
struct rtc_date rv;
|
|
||||||
uint8_t century;
|
|
||||||
|
|
||||||
rv.second = read_register(SECOND_REGISTER);
|
|
||||||
rv.minute = read_register(MINUTE_REGISTER);
|
|
||||||
rv.hour = read_register(HOUR_REGISTER);
|
|
||||||
rv.day = read_register(DAY_OF_THE_MONTH_REGISTER);
|
|
||||||
rv.month = read_register(MONTH_REGISTER);
|
|
||||||
rv.year += read_register(YEAR_REGISTER);
|
|
||||||
century = read_register(CENTURY_REGISTER);
|
|
||||||
|
|
||||||
if (!(read_register(REGISTER_B) & 0x04)) {
|
|
||||||
rv.second = bcd_mode_to_bin(rv.second);
|
|
||||||
rv.minute = bcd_mode_to_bin(rv.minute);
|
|
||||||
rv.hour = bcd_mode_to_bin(rv.hour);
|
|
||||||
rv.day = bcd_mode_to_bin(rv.day);
|
|
||||||
rv.month = bcd_mode_to_bin(rv.month);
|
|
||||||
rv.year = bcd_mode_to_bin(rv.year);
|
|
||||||
century = bcd_mode_to_bin(century);
|
|
||||||
}
|
|
||||||
rv.year += century * 100 - 108; // -108 = bozo offset
|
|
||||||
return rv;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
#include "kprintf.h"
|
|
||||||
#include "rtc.h"
|
|
||||||
|
|
||||||
void date()
|
|
||||||
{
|
|
||||||
static const char *months[12] = {
|
|
||||||
"January",
|
|
||||||
"February",
|
|
||||||
"March",
|
|
||||||
"April",
|
|
||||||
"May",
|
|
||||||
"June",
|
|
||||||
"July",
|
|
||||||
"August",
|
|
||||||
"September",
|
|
||||||
"October",
|
|
||||||
"November",
|
|
||||||
"December" };
|
|
||||||
struct rtc_date date = get_date();
|
|
||||||
|
|
||||||
kprintf(0, "%s. %d %s. %d %d:%d:%d\n", "mer", date.day, months[date.month], date.year, date.hour, date.minute, date.second);
|
|
||||||
}
|
|
@ -39,8 +39,6 @@ static CMD_TOK find_command(char *line)
|
|||||||
command = COLOR;
|
command = COLOR;
|
||||||
else if (!strcmp(line, "merdella"))
|
else if (!strcmp(line, "merdella"))
|
||||||
command = MERDELLA;
|
command = MERDELLA;
|
||||||
else if (!strcmp(line, "date"))
|
|
||||||
command = DATE;
|
|
||||||
else
|
else
|
||||||
kprintf(0, "invalid command: %s\n", line);
|
kprintf(0, "invalid command: %s\n", line);
|
||||||
if (uwu)
|
if (uwu)
|
||||||
@ -122,9 +120,6 @@ void shell_init(void)
|
|||||||
"by Targon (/)\n");
|
"by Targon (/)\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DATE:
|
|
||||||
date();
|
|
||||||
break;
|
|
||||||
case ERROR:
|
case ERROR:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user