From: Alan Cox Date: Sun, 7 Oct 2018 21:14:35 +0000 (+0100) Subject: amstradnc: clock support X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=5f697552f7709740e8d41d1c39a66c968b30bf76;p=FUZIX.git amstradnc: clock support Also adjust the config for the NC200 as it was spilling over the boundary --- diff --git a/Kernel/platform-amstradnc/config.h b/Kernel/platform-amstradnc/config.h index 9a2284d9..ba0009af 100644 --- a/Kernel/platform-amstradnc/config.h +++ b/Kernel/platform-amstradnc/config.h @@ -3,6 +3,7 @@ /* We have an RTC */ #define CONFIG_RTC +#define CONFIG_RTC_FULL /* Enable to make ^Z dump the inode table for debug */ #undef CONFIG_IDUMP /* Enable to make ^A drop back into the monitor */ @@ -55,7 +56,7 @@ /* Device parameters */ #define NUM_DEV_TTY 2 #define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */ -#define NBUFS 10 /* Number of block buffers */ +#define NBUFS 9 /* Number of block buffers */ #ifdef CONFIG_NC200 #define NMOUNTS 2 /* Floppy can also be mounted */ #define BOOTDEVICENAMES "hd#,fd#" diff --git a/Kernel/platform-amstradnc/m146818.c b/Kernel/platform-amstradnc/m146818.c new file mode 100644 index 00000000..95a2bfac --- /dev/null +++ b/Kernel/platform-amstradnc/m146818.c @@ -0,0 +1,69 @@ +/* + * This is intended for the NC200. It assumes 24 hour clock mode and + * decimal. The year is 1990 based. This is all fine for the NC200 + * as that is how the firmware/OS leave it. + */ + +#include +#include +#include +#include +#include + +__sfr __at 0xD0 rtc_second; +__sfr __at 0xD2 rtc_minute; +__sfr __at 0xD4 rtc_hour; +__sfr __at 0xD7 rtc_day; +__sfr __at 0xD8 rtc_month; +__sfr __at 0xD9 rtc_year; +__sfr __at 0xDA rtc_rega; + +uint8_t platform_rtc_secs(void) __naked +{ + static uint8_t last; + if (rtc_rega & 0x80) + return last; + return rtc_second; +} + +/* Full RTC support (for read - no write yet) */ +int platform_rtc_read(void) +{ + uint16_t len = sizeof(struct cmos_rtc); + uint16_t y; + irqflags_t flags; + struct cmos_rtc cmos; + uint8_t *p = cmos.data.bytes; + + if (udata.u_count < len) + len = udata.u_count; + +sync: + while(rtc_rega & 0x80); /* Wait for UIP to clear */ + + flags = di(); + if (rtc_rega & 0x80) + goto sync; + + /* We are now safe for 244uS */ + y = rtc_year + 1990; + *p++ = y; + *p++ = y >> 8; + *p++ = rtc_month; + *p++ = rtc_day; + *p++ = rtc_hour; + *p++ = rtc_minute; + *p++ = rtc_second; + irqrestore(flags); + + cmos.type = CMOS_RTC_DEC; + if (uput(&cmos, udata.u_base, len) == -1) + return -1; + return len; +} + +int platform_rtc_write(void) +{ + udata.u_error = -EOPNOTSUPP; + return -1; +} diff --git a/Kernel/platform-amstradnc/main.c b/Kernel/platform-amstradnc/main.c index 7f8a607a..20e3a33b 100644 --- a/Kernel/platform-amstradnc/main.c +++ b/Kernel/platform-amstradnc/main.c @@ -45,19 +45,3 @@ void map_init(void) { } -__sfr __at 0xD0 rtc_secl; -__sfr __at 0xD1 rtc_sech; -__sfr __at 0xDD rtc_page; - -uint8_t platform_rtc_secs(void) -{ - uint8_t sl, rv; - /* Make sure we are seeing the seconds not NVRAM */ - rtc_page = 0; - /* BCD encoded */ - do { - sl = rtc_secl; - rv = sl + rtc_sech * 10; - } while (sl != rtc_secl); - return rv; -} diff --git a/Kernel/platform-amstradnc/nc100/Makefile b/Kernel/platform-amstradnc/nc100/Makefile index 5f8fceb7..160dcfb6 100644 --- a/Kernel/platform-amstradnc/nc100/Makefile +++ b/Kernel/platform-amstradnc/nc100/Makefile @@ -1,6 +1,6 @@ CSRCS = ../devlpr.c ../devtty.c ../devrd.c ../devaudio.c ../devgfx.c -CSRCS += ../devices.c ../main.c +CSRCS += ../devices.c ../main.c ../tc8521.c ASRCS = ../nc100.s ../crt0.s ASRCS += ../tricks.s ../commonmem.s diff --git a/Kernel/platform-amstradnc/nc100/fuzix.lnk b/Kernel/platform-amstradnc/nc100/fuzix.lnk index c6f21f7c..683a9964 100644 --- a/Kernel/platform-amstradnc/nc100/fuzix.lnk +++ b/Kernel/platform-amstradnc/nc100/fuzix.lnk @@ -39,5 +39,6 @@ platform-amstradnc/devlpr.rel platform-amstradnc/devtty.rel platform-amstradnc/devaudio.rel platform-amstradnc/devgfx.rel +platform-amstradnc/tc8521.rel font4x6.rel -e diff --git a/Kernel/platform-amstradnc/nc200/Makefile b/Kernel/platform-amstradnc/nc200/Makefile index 2d6b79e1..80405e03 100644 --- a/Kernel/platform-amstradnc/nc200/Makefile +++ b/Kernel/platform-amstradnc/nc200/Makefile @@ -7,6 +7,7 @@ CSRCS = \ ../devgfx.c \ ../devices.c \ ../main.c \ + ../m146818.c ASRCS = \ ../nc100.s \ diff --git a/Kernel/platform-amstradnc/nc200/fuzix.lnk b/Kernel/platform-amstradnc/nc200/fuzix.lnk index d664db73..46af87f0 100644 --- a/Kernel/platform-amstradnc/nc200/fuzix.lnk +++ b/Kernel/platform-amstradnc/nc200/fuzix.lnk @@ -41,5 +41,6 @@ platform-amstradnc/devlpr.rel platform-amstradnc/devtty.rel platform-amstradnc/devaudio.rel platform-amstradnc/devgfx.rel +platform-amstradnc/m146818.rel font4x6.rel -e