rtc.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*-
  2. * SPDX-License-Identifier: BSD-3-Clause
  3. *
  4. * Copyright (c) 1990 The Regents of the University of California.
  5. * All rights reserved.
  6. *
  7. * This code is derived from software contributed to Berkeley by
  8. * William Jolitz.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the University nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. */
  34. #ifndef _I386_ISA_RTC_H_
  35. #define _I386_ISA_RTC_H_ 1
  36. /*
  37. * MC146818 RTC Register locations
  38. */
  39. #define RTC_SEC 0x00 /* seconds */
  40. #define RTC_SECALRM 0x01 /* seconds alarm */
  41. #define RTC_MIN 0x02 /* minutes */
  42. #define RTC_MINALRM 0x03 /* minutes alarm */
  43. #define RTC_HRS 0x04 /* hours */
  44. #define RTC_HRSALRM 0x05 /* hours alarm */
  45. #define RTC_WDAY 0x06 /* week day */
  46. #define RTC_DAY 0x07 /* day of month */
  47. #define RTC_MONTH 0x08 /* month of year */
  48. #define RTC_YEAR 0x09 /* month of year */
  49. #define RTC_STATUSA 0x0a /* status register A */
  50. #define RTCSA_TUP 0x80 /* time update, don't look now */
  51. #define RTCSA_RESET 0x70 /* reset divider */
  52. #define RTCSA_DIVIDER 0x20 /* divider correct for 32768 Hz */
  53. #define RTCSA_8192 0x03 /* 8192 Hz interrupt */
  54. #define RTCSA_4096 0x04
  55. #define RTCSA_2048 0x05
  56. #define RTCSA_1024 0x06 /* default for profiling */
  57. #define RTCSA_PROF RTCSA_1024
  58. #define RTC_PROFRATE 1024
  59. #define RTCSA_512 0x07
  60. #define RTCSA_256 0x08
  61. #define RTCSA_128 0x09
  62. #define RTCSA_NOPROF RTCSA_128
  63. #define RTC_NOPROFRATE 128
  64. #define RTCSA_64 0x0a
  65. #define RTCSA_32 0x0b /* 32 Hz interrupt */
  66. #define RTC_STATUSB 0x0b /* status register B */
  67. #define RTCSB_DST 0x01 /* USA Daylight Savings Time enable */
  68. #define RTCSB_24HR 0x02 /* 0 = 12 hours, 1 = 24 hours */
  69. #define RTCSB_BCD 0x04 /* 0 = BCD, 1 = Binary coded time */
  70. #define RTCSB_SQWE 0x08 /* 1 = output sqare wave at SQW pin */
  71. #define RTCSB_UINTR 0x10 /* 1 = enable update-ended interrupt */
  72. #define RTCSB_AINTR 0x20 /* 1 = enable alarm interrupt */
  73. #define RTCSB_PINTR 0x40 /* 1 = enable periodic clock interrupt */
  74. #define RTCSB_HALT 0x80 /* stop clock updates */
  75. #define RTC_INTR 0x0c /* status register C (R) interrupt source */
  76. #define RTCIR_UPDATE 0x10 /* update intr */
  77. #define RTCIR_ALARM 0x20 /* alarm intr */
  78. #define RTCIR_PERIOD 0x40 /* periodic intr */
  79. #define RTCIR_INT 0x80 /* interrupt output signal */
  80. #define RTC_STATUSD 0x0d /* status register D (R) Lost Power */
  81. #define RTCSD_PWR 0x80 /* clock power OK */
  82. #define RTC_DIAG 0x0e /* status register E - bios diagnostic */
  83. #define RTCDG_BITS "\020\010clock_battery\007ROM_cksum\006config_unit\005memory_size\004fixed_disk\003invalid_time"
  84. #define RTC_RESET 0x0f /* status register F - reset code byte */
  85. #define RTCRS_RST 0x00 /* normal reset */
  86. #define RTCRS_LOAD 0x04 /* load system */
  87. #define RTC_FDISKETTE 0x10 /* diskette drive type in upper/lower nibble */
  88. #define RTCFDT_NONE 0 /* none present */
  89. #define RTCFDT_360K 0x10 /* 360K */
  90. #define RTCFDT_12M 0x20 /* 1.2M */
  91. #define RTCFDT_720K 0x30 /* 720K */
  92. #define RTCFDT_144M 0x40 /* 1.44M */
  93. #define RTCFDT_288M_1 0x50 /* 2.88M, some BIOSes */
  94. #define RTCFDT_288M 0x60 /* 2.88M */
  95. #define RTC_BASELO 0x15 /* low byte of basemem size */
  96. #define RTC_BASEHI 0x16 /* high byte of basemem size */
  97. #define RTC_EXTLO 0x17 /* low byte of extended mem size */
  98. #define RTC_EXTHI 0x18 /* low byte of extended mem size */
  99. #define RTC_CENTURY 0x32 /* current century */
  100. #ifdef _KERNEL
  101. extern struct mtx atrtc_time_lock;
  102. extern int atrtcclock_disable;
  103. int rtcin(int reg);
  104. void atrtc_restore(void);
  105. void writertc(int reg, u_char val);
  106. #endif
  107. #endif /* _I386_ISA_RTC_H_ */