trs80: turn on the RTC support
authorAlan Cox <alan@linux.intel.com>
Mon, 22 Dec 2014 13:03:54 +0000 (13:03 +0000)
committerAlan Cox <alan@linux.intel.com>
Mon, 22 Dec 2014 13:03:54 +0000 (13:03 +0000)
Kernel/platform-trs80/config.h
Kernel/platform-trs80/devices.c
Kernel/platform-trs80/main.c

index 9bfa1f8..bce9377 100644 (file)
@@ -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 */
index 9fadf00..bd466cb 100644 (file)
@@ -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);
 }
index 74a5fa5..b03c22e 100644 (file)
@@ -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