2 .\" Copyright 2002 Urs Thuermann (urs@isnogud.escape.de)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 .\" GNU General Public License for more details.
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, write to the Free
21 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
24 .\" $Id: rtc.4,v 1.4 2005/12/05 17:19:49 urs Exp $
26 .\" 2006-02-08 Various additions by mtk
27 .\" 2006-11-26 cleanup, cover the generic rtc framework; David Brownell
29 .\" Japanese Version Copyright (c) 2006-2007 Yuichi SATO
30 .\" all rights reserved.
31 .\" Translated 2006-07-12 by Yuichi SATO <ysato444@yahoo.co.jp>. LDP v2.29
32 .\" Updated & Modified 2007-01-08 by Yuichi SATO. LDP v2.43
34 .TH RTC 4 2010-02-25 "Linux" "Linux Programmer's Manual"
37 .\"O rtc \- real-time clock
41 #include <linux/rtc.h>
43 .BI "int ioctl(" fd ", RTC_" request ", " param ");"
46 .\"O This is the interface to drivers for real-time clocks (RTCs).
47 これはリアルタイムクロック (RTC) のドライバのインタフェースである。
49 .\"O Most computers have one or more hardware clocks which record the
50 .\"O current "wall clock" time.
51 .\"O These are called "Real Time Clocks" (RTCs).
52 .\"O One of these usually has battery backup power so that it tracks the time
53 .\"O even while the computer is turned off.
54 .\"O RTCs often provide alarms and other interrupts.
55 多くのコンピュータは、現在の「壁時計」時刻 ("wall clock" time) を記録する、
56 ハードウェアクロックを 1 個以上持っている。
57 これらは「リアルタイムクロック」(RTC) と呼ばれる。
58 これらの時計のうち 1 つは、通常は電池でバックアップして駆動されるので、
59 コンピュータのスイッチを切っても、時刻を保持できる。
60 多くの場合、RTC はアラームやその他の割り込みの機能を提供する。
62 .\"O All i386 PCs, and ACPI-based systems, have an RTC that is compatible with
63 .\"O the Motorola MC146818 chip on the original PC/AT.
64 .\"O Today such an RTC is usually integrated into the mainboard's chipset
65 .\"O (south bridge), and uses a replaceable coin-sized backup battery.
66 全ての i386 PC と ACPI ベースのシステムには RTC がある。
67 この RTC は、元々の PC/AT に存在した
68 Motorola MC146818 チップと互換性がある。
69 このような RTC は、今日ではマザーボードの
70 チップセット (サウスブリッジ) 内で実装されていることが多く、
71 交換可能な硬貨くらいの大きさのバックアップ電池を使っている。
73 .\"O Non-PC systems, such as embedded systems built around system-on-chip
74 .\"O processors, use other implementations.
75 .\"O They usually won't offer the same functionality as the RTC from a PC/AT.
76 システムオンチップ (system-on-chip) プロセッサを使って作られた
77 組み込みシステムといった、PC 以外のシステムでは、別な実装を用いている。
78 このようなシステムでは、PC/AT の RTC と同じ機能を提供していない場合が多い。
80 .\"O .SS RTC vs System Clock
82 .\"O RTCs should not be confused with the system clock, which is
83 .\"O a software clock maintained by the kernel and used to implement
84 .\"O .BR gettimeofday (2)
87 .\"O as well as setting timestamps on files, etc.
88 RTC をシステムクロックと混同すべきではない。
89 システムクロックは、カーネルに管理されるソフトウェアクロックであり、
90 ファイルによるタイムスタンプ設定などとともに、
95 .\"O The system clock reports seconds and microseconds since a start point,
96 .\"O defined to be the POSIX Epoch: 1970-01-01 00:00:00 +0000 (UTC).
97 システムクロックは、POSIX における紀元
98 (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) からの秒とミリ秒を表す。
99 .\"O (One common implementation counts timer interrupts, once
100 .\"O per "jiffy", at a frequency of 100, 250, or 1000 Hz.)
101 .\"O That is, it is supposed to report wall clock time, which RTCs also do.
102 1 つの一般的な実装ではタイマー割り込みを、"jiffy" 毎に 1 回、
103 100, 250, 1000 Hz という周波数でカウントする。
105 .\"O A key difference between an RTC and the system clock is that RTCs
106 .\"O run even when the system is in a low power state (including "off"),
107 .\"O and the system clock can't.
108 RTC とシステムクロックの重要な違いは、
109 RTC はシステムが低電力状態 (「オフ」の場合も含む) でも動作するのに対し、
111 .\"O Until it is initialized, the system clock can only report time since
112 .\"O system boot ... not since the POSIX Epoch.
113 システムクロックは、初期化が行われるまでは、
114 POSIX 紀元からではなくシステムのブート時からの時刻しか返せない。
115 .\"O So at boot time, and after resuming from a system low power state, the
116 .\"O system clock will often be set to the current wall clock time using an RTC.
117 そのため、ブート時やシステムの低電力状態からの復帰 (resume) 後には、
118 システムクロックは RTC を使って現在の壁時計時刻に設定される場合が多い。
119 .\"O Systems without an RTC need to set the system clock using another clock,
120 .\"O maybe across the network or by entering that data manually.
122 他の時計を使ってシステムクロックを設定する必要があり、
123 ネットワークにアクセスしたり、(時刻) データを手動で入力したりするだろう。
124 .\"O .SS RTC functionality
126 .\"O RTCs can be read and written with
127 .\"O .BR hwclock (8),
128 .\"O or directly with the ioctl requests listed below.
131 または下記の ioctl リクエストで読み書きができる。
133 .\"O Besides tracking the date and time, many RTCs can also generate
136 多くの RTC は以下のように割り込みを発生できる。
138 .\"O on every clock update (i.e., once per second);
141 .\"O at periodic intervals with a frequency that can be set to
142 .\"O any power-of-2 multiple in the range 2 Hz to 8192 Hz;
143 2 Hz から 8192 Hz までの 2 の乗数の周波数で、定期的な間隔。
145 .\"O on reaching a previously specified alarm time.
148 .\"O Each of those interrupt sources can be enabled or disabled separately.
149 これらの割り込み元は、個別に有効にしたり無効にしたりできる。
150 .\"O On many systems, the alarm interrupt can be configured as a system wakeup
151 .\"O event, which can resume the system from a low power state such as
152 .\"O Suspend-to-RAM (STR, called S3 in ACPI systems),
153 .\"O Hibernation (called S4 in ACPI systems),
154 .\"O or even "off" (called S5 in ACPI systems).
155 多くのシステムでは、アラーム割り込みをシステムの
157 このイベントは、RAM へのサスペンド (STR, ACPI システムで S3 と呼ばれる) や
158 ハイバーネーション (ACPI システムで S4 と呼ばれる) といった低電力状態や、
159 「オフ」(ACPI システムで S5 と呼ばれる) からでも、システムを復帰できる。
160 .\"O On some systems, the battery backed RTC can't issue
161 .\"O interrupts, but another one can.
162 電池でバックアップされた RTC が割り込みを発生できるシステムと、
171 .\"O device can be opened only once (until it is closed) and it is read-only.
177 デバイスは (クローズされるまで) 1 回しかオープンすることができず、
183 .\"O the calling process is blocked until the next interrupt from that RTC
189 RTC からの割り込みを受け取るまで停止 (block) される。
190 .\"O Following the interrupt, the process can read a long integer, of which
191 .\"O the least significant byte contains a bit mask encoding
192 .\"O the types of interrupt that occurred,
193 .\"O while the remaining 3 bytes contain the number of interrupts since the
196 割り込みの後、プロセスは long 型整数を読み出すことができる。
197 この整数の最下位バイトは発生した割り込みの種別を
202 .\"O .SS ioctl(2) interface
206 .\"O requests are defined on file descriptors connected to RTC devices:
209 リクエストが RTC デバイスの接続された
210 ファイルディスクリプタに対して定義されている:
213 .\"O Returns this RTC's time in the following structure:
225 .\"O int tm_wday; /* unused */
226 int tm_wday; /* 未使用 */
227 .\"O int tm_yday; /* unused */
228 int tm_yday; /* 未使用 */
229 .\"O int tm_isdst; /* unused */
230 int tm_isdst; /* 未使用 */
235 .\"O The fields in this structure have the same meaning and ranges as for the
237 .\"O structure described in
243 構造体のフィールドと同じ意味で同じ範囲である。
244 .\"O A pointer to this structure should be passed as the third
252 .\"O Sets this RTC's time to the time specified by the
254 .\"O structure pointed to by the third
262 .\"O RTC's time the process must be privileged (i.e., have the
265 RTC 時刻の設定する場合、プロセスは特権
268 ケーパビリティ) を持たなければならない。
270 .BR RTC_ALM_READ ", " RTC_ALM_SET
271 .\"O Read and set the alarm time, for RTCs that support alarms.
272 アラームがサポートされている RTC に対して、
274 .\"O The alarm interrupt must be separately enabled or disabled using the
275 .\"O .BR RTC_AIE_ON ", " RTC_AIE_OFF
278 .BR RTC_AIE_ON ", " RTC_AIE_OFF
279 を使って、これとは別に有効または無効にしなければならない。
282 .\"O argument is a pointer to an
285 \fBioctl\fP(2) の第 3 引き数は、
293 .\"O fields of this structure are used.
300 .BR RTC_IRQP_READ ", " RTC_IRQP_SET
301 .\"O Read and set the frequency for periodic interrupts,
302 .\"O for RTCs that support periodic interrupts.
303 周期的な割り込みがサポートされている RTC に対して、
304 周期的な割り込みの周波数の読み込みと設定を行う。
305 .\"O The periodic interrupt must be separately enabled or disabled using the
306 .\"O .BR RTC_PIE_ON ", " RTC_PIE_OFF
309 .BR RTC_PIE_ON ", " RTC_PIE_OFF
310 を使って、これとは別に有効または無効にしなければならない。
314 .\"O .I "unsigned long\ *"
316 .\"O .IR "unsigned long" ,
318 \fBioctl\fP(2) の第 3 引き数は、それぞれ
319 .I "unsigned long\ *"
323 .\"O The value is the frequency in interrupts per second.
324 .\"O The set of allowable frequencies is the multiples of two
325 .\"O in the range 2 to 8192.
326 この値は 1 秒当たりの割り込みの回数である。
327 指定可能な周波数は、2 の乗数で 2 から 8192 の範囲である。
328 .\"O Only a privileged process (i.e., one having the
329 .\"O .B CAP_SYS_RESOURCE
330 .\"O capability) can set frequencies above the value specified in
331 .\"O .IR /proc/sys/dev/rtc/max-user-freq .
335 .I /proc/sys/dev/rtc/max-user-freq
337 .\"O (This file contains the value 64 by default.)
338 (このファイルにはデフォルトで 64 という値が書かれている)。
340 .BR RTC_AIE_ON ", " RTC_AIE_OFF
341 .\"O Enable or disable the alarm interrupt, for RTCs that support alarms.
344 .\"O argument is ignored.
345 アラームがサポートされている RTC に対して、
347 \fBioctl\fP(2) の第 3 引き数は無視される。
349 .BR RTC_UIE_ON ", " RTC_UIE_OFF
350 .\"O Enable or disable the interrupt on every clock update,
351 .\"O for RTCs that support this once-per-second interrupt.
354 .\"O argument is ignored.
355 1 秒毎の割り込みがサポートされている RTC に対して、
356 クロック更新毎の割り込みを有効または無効にする。
357 \fBioctl\fP(2) の第 3 引き数は無視される。
359 .BR RTC_PIE_ON ", " RTC_PIE_OFF
360 .\"O Enable or disable the periodic interrupt,
361 .\"O for RTCs that support these periodic interrupts.
364 .\"O argument is ignored.
365 周期的な割り込みがサポートされている RTC に対して、
367 \fBioctl\fP(2) の第 3 引き数は無視される。
368 .\"O Only a privileged process (i.e., one having the
369 .\"O .B CAP_SYS_RESOURCE
370 .\"O capability) can enable the periodic interrupt if the frequency is
371 .\"O currently set above the value specified in
372 .\"O .IR /proc/sys/dev/rtc/max-user-freq .
377 .I /proc/sys/dev/rtc/max-user-freq
381 .BR RTC_EPOCH_READ ", " RTC_EPOCH_SET
382 .\"O Many RTCs encode the year in an 8-bit register which is either
383 .\"O interpreted as an 8-bit binary number or as a BCD number.
385 .\"O the number is interpreted relative to this RTC's Epoch.
386 多くの RTC は年を 8 ビットのレジスタにコード化する。
387 年は 8 ビットのバイナリ数または BCD 数に変換される。
388 どちらの場合でも、その数値は RTC の紀元から相対値に変換される。
389 .\"O The RTC's Epoch is
390 .\"O initialized to 1900 on most systems but on Alpha and MIPS it might
391 .\"O also be initialized to 1952, 1980, or 2000, depending on the value of
392 .\"O an RTC register for the year.
393 多くのシステムでは RTC の紀元は 1900 に初期化されるが、
394 Alpha と MIPS では、RTC レジスタの年の値に応じて、
395 1952, 1980, 2000 の何れかに初期化される。
397 .\"O these operations can be used to read or to set the RTC's Epoch,
399 これらの操作でそれぞれ RTC の紀元の読み込みと設定が可能な RTC もある。
403 .\"O .I "unsigned long\ *"
405 .\"O .IR "unsigned long" ,
406 .\"O respectively, and the value returned (or assigned) is the Epoch.
407 \fBioctl\fP(2) の第 3 引き数は、それぞれ
408 .I "unsigned long\ *"
412 返される値 (または指定される値) は紀元である。
413 .\"O To set the RTC's Epoch the process must be privileged (i.e., have the
416 RTC の紀元を設定する場合、プロセスは特権 (つまり
418 ケーパビリティ) を持たなければならない。
420 .BR RTC_WKALM_RD ", " RTC_WKALM_SET
421 .\"O Some RTCs support a more powerful alarm interface, using these ioctls
422 .\"O to read or write the RTC's alarm time (respectively) with this structure:
423 RTC の中にはより強力なアラームインタフェースをサポートするものもあり、
424 これらの ioctl を使うことで、以下のような構造体で
425 RTC のアラーム時刻を (それぞれ) 読み書きできる:
431 unsigned char enabled;
432 unsigned char pending;
433 struct rtc_time time;
441 .\"O flag is used to enable or disable the alarm interrupt,
442 .\"O or to read its current status; when using these calls,
443 .\"O .BR RTC_AIE_ON " and " RTC_AIE_OFF
449 .\"O to report a pending interrupt
450 .\"O (so it's mostly useless on Linux, except when talking
451 .\"O to the RTC managed by EFI firmware).
453 フラグはアラーム割り込みを有効または無効したり、
456 .BR RTC_AIE_ON " と " RTC_AIE_OFF
462 (EFI ファームウェアで管理される RTC と通信するとき以外、
466 .\"O field is as used with
475 .\"O fields are also valid.
486 .\"O A pointer to this structure should be passed as the third
491 の第 3 引き数として渡さなければならない。
496 .\"O .IR /dev/rtc1 ", "
498 .\"O etc: RTC special character device files.
502 .IR /proc/driver/rtc :
503 .\"O status of the (first) RTC.
507 .\"O When the kernel's system time is synchronized with an external
509 .\"O .BR adjtimex (2)
510 .\"O it will update a designated RTC periodically every 11 minutes.
511 .\"O To do so, the kernel has to briefly turn off periodic interrupts;
512 .\"O this might affect programs using that RTC.
517 は指定された RTC を 11 分毎に定期的に更新する。
518 これを行うためカーネルは周期的な割り込みを短期間無効にする必要がある。
519 これは RTC を使うプログラムに影響を与える。
521 .\"O An RTC's Epoch has nothing to do with the POSIX Epoch which is only
522 .\"O used for the system clock.
523 RTC の紀元は、システムクロックでのみ使用される
526 .\"O If the year according to the RTC's Epoch and the year register is
527 .\"O less than 1970 it is assumed to be 100 years later, that is, between 2000
529 RTC の紀元と年のレジスタに基づく年が 1970 未満である場合、
530 100 年後、つまり 2000 から 2069 であると仮定される。
532 .\"O Some RTCs support "wildcard" values in alarm fields, to support
533 .\"O scenarios like periodic alarms at fifteen minutes after every hour,
534 .\"O or on the first day of each month.
535 .\"O Such usage is nonportable;
536 .\"O portable user space code only expects a single alarm interrupt, and
537 .\"O will either disable or reinitialize the alarm after receiving it.
539 「ワイルドカード」の値をサポートするものもあり、
540 毎時 15 分や各月の初日など、定期的なアラームを行うシナリオをサポートする。
542 移植性の高いユーザ空間コードでは、単独のアラーム割り込みだけを想定し、
543 割り込みの受信後にアラームを無効または再初期化すべきである。
545 .\"O Some RTCs support periodic interrupts with periods that are multiples
546 .\"O of a second rather than fractions of a second;
547 .\"O multiple alarms;
548 .\"O programmable output clock signals;
549 .\"O nonvolatile memory;
550 .\"O and other hardware
551 .\"O capabilities that are not currently exposed by this API.
552 以下の機能をサポートする RTC もある。
553 1 秒の分数ではなく、1 秒の倍数を周期とする周期的な割り込み。
556 不揮発性 (nonvolatile) メモリ。
557 この API で現在提供していない、その他のハードウェア機能。
562 .BR gettimeofday (2),
563 .BR settimeofday (2),
569 /usr/src/linux/Documentation/rtc.txt