From c14ede24f7d461d73489a7e7aad15307d38a8159 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 22 Dec 2014 13:03:54 +0000 Subject: [PATCH] trs80: turn on the RTC support --- Kernel/platform-trs80/config.h | 5 +++++ Kernel/platform-trs80/devices.c | 6 +++++- Kernel/platform-trs80/main.c | 13 +++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Kernel/platform-trs80/config.h b/Kernel/platform-trs80/config.h index 9bfa1f86..bce93777 100644 --- a/Kernel/platform-trs80/config.h +++ b/Kernel/platform-trs80/config.h @@ -1,3 +1,8 @@ +/* Set if you want RTC support and have an RTC on ports 0xB0-0xBC */ +#define CONFIG_RTC + + + /* Enable to make ^Z dump the inode table for debug */ #undef CONFIG_IDUMP /* Enable to make ^A drop back into the monitor */ diff --git a/Kernel/platform-trs80/devices.c b/Kernel/platform-trs80/devices.c index 9fadf00f..bd466cb3 100644 --- a/Kernel/platform-trs80/devices.c +++ b/Kernel/platform-trs80/devices.c @@ -36,7 +36,11 @@ bool validdev(uint16_t dev) void device_init(void) { int i; +#ifdef CONFIG_RTC + /* Time of day clock */ + inittod(); +#endif /* Add 64 swaps (2MB) */ - for (i = 0; i < MAX_SWAPS; i++) + for (i = MAX_SWAPS - 1 ; i >= 0; i--) swapmap_add(i); } diff --git a/Kernel/platform-trs80/main.c b/Kernel/platform-trs80/main.c index 74a5fa5f..b03c22ed 100644 --- a/Kernel/platform-trs80/main.c +++ b/Kernel/platform-trs80/main.c @@ -41,3 +41,16 @@ void pagemap_init(void) pagemap_add(0x63); /* Mode 3, U64K low 32K mapped as low 32K */ pagemap_add(0x73); /* Mode 3, U64K high 32K mapped as low 32K */ } + +#ifdef CONFIG_RTC + +__sfr __at 0xB0 rtc_secl; +__sfr __at 0xB1 rtc_sech; + +uint8_t rtc_secs(void) +{ + /* BCD encoded */ + return rtc_secl + 10 * rtc_sech; +} + +#endif -- 2.34.1