efirtc.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. EFI Real Time Clock driver
  2. -------------------------------
  3. S. Eranian <eranian@hpl.hp.com>
  4. March 2000
  5. I/ Introduction
  6. This document describes the efirtc.c driver has provided for
  7. the IA-64 platform.
  8. The purpose of this driver is to supply an API for kernel and user applications
  9. to get access to the Time Service offered by EFI version 0.92.
  10. EFI provides 4 calls one can make once the OS is booted: GetTime(),
  11. SetTime(), GetWakeupTime(), SetWakeupTime() which are all supported by this
  12. driver. We describe those calls as well the design of the driver in the
  13. following sections.
  14. II/ Design Decisions
  15. The original ideas was to provide a very simple driver to get access to,
  16. at first, the time of day service. This is required in order to access, in a
  17. portable way, the CMOS clock. A program like /sbin/hwclock uses such a clock
  18. to initialize the system view of the time during boot.
  19. Because we wanted to minimize the impact on existing user-level apps using
  20. the CMOS clock, we decided to expose an API that was very similar to the one
  21. used today with the legacy RTC driver (driver/char/rtc.c). However, because
  22. EFI provides a simpler services, not all ioctl() are available. Also
  23. new ioctl()s have been introduced for things that EFI provides but not the
  24. legacy.
  25. EFI uses a slightly different way of representing the time, noticeably
  26. the reference date is different. Year is the using the full 4-digit format.
  27. The Epoch is January 1st 1998. For backward compatibility reasons we don't
  28. expose this new way of representing time. Instead we use something very
  29. similar to the struct tm, i.e. struct rtc_time, as used by hwclock.
  30. One of the reasons for doing it this way is to allow for EFI to still evolve
  31. without necessarily impacting any of the user applications. The decoupling
  32. enables flexibility and permits writing wrapper code is ncase things change.
  33. The driver exposes two interfaces, one via the device file and a set of
  34. ioctl()s. The other is read-only via the /proc filesystem.
  35. As of today we don't offer a /proc/sys interface.
  36. To allow for a uniform interface between the legacy RTC and EFI time service,
  37. we have created the include/linux/rtc.h header file to contain only the
  38. "public" API of the two drivers. The specifics of the legacy RTC are still
  39. in include/linux/mc146818rtc.h.
  40. III/ Time of day service
  41. The part of the driver gives access to the time of day service of EFI.
  42. Two ioctl()s, compatible with the legacy RTC calls:
  43. Read the CMOS clock: ioctl(d, RTC_RD_TIME, &rtc);
  44. Write the CMOS clock: ioctl(d, RTC_SET_TIME, &rtc);
  45. The rtc is a pointer to a data structure defined in rtc.h which is close
  46. to a struct tm:
  47. struct rtc_time {
  48. int tm_sec;
  49. int tm_min;
  50. int tm_hour;
  51. int tm_mday;
  52. int tm_mon;
  53. int tm_year;
  54. int tm_wday;
  55. int tm_yday;
  56. int tm_isdst;
  57. };
  58. The driver takes care of converting back an forth between the EFI time and
  59. this format.
  60. Those two ioctl()s can be exercised with the hwclock command:
  61. For reading:
  62. # /sbin/hwclock --show
  63. Mon Mar 6 15:32:32 2000 -0.910248 seconds
  64. For setting:
  65. # /sbin/hwclock --systohc
  66. Root privileges are required to be able to set the time of day.
  67. IV/ Wakeup Alarm service
  68. EFI provides an API by which one can program when a machine should wakeup,
  69. i.e. reboot. This is very different from the alarm provided by the legacy
  70. RTC which is some kind of interval timer alarm. For this reason we don't use
  71. the same ioctl()s to get access to the service. Instead we have
  72. introduced 2 news ioctl()s to the interface of an RTC.
  73. We have added 2 new ioctl()s that are specific to the EFI driver:
  74. Read the current state of the alarm
  75. ioctl(d, RTC_WKLAM_RD, &wkt)
  76. Set the alarm or change its status
  77. ioctl(d, RTC_WKALM_SET, &wkt)
  78. The wkt structure encapsulates a struct rtc_time + 2 extra fields to get
  79. status information:
  80. struct rtc_wkalrm {
  81. unsigned char enabled; /* =1 if alarm is enabled */
  82. unsigned char pending; /* =1 if alarm is pending */
  83. struct rtc_time time;
  84. }
  85. As of today, none of the existing user-level apps supports this feature.
  86. However writing such a program should be hard by simply using those two
  87. ioctl().
  88. Root privileges are required to be able to set the alarm.
  89. V/ References.
  90. Checkout the following Web site for more information on EFI:
  91. http://developer.intel.com/technology/efi/