.\" rtc.4 .\" Copyright 2002 Urs Thuermann (urs@isnogud.escape.de) .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" $Id: rtc.4,v 1.4 2005/12/05 17:19:49 urs Exp $ .\" .\" 2006-02-08 Various additions by mtk .\" 2006-11-26 cleanup, cover the generic rtc framework; David Brownell .\" .\" Japanese Version Copyright (c) 2006-2007 Yuichi SATO .\" all rights reserved. .\" Translated 2006-07-12 by Yuichi SATO . LDP v2.29 .\" Updated & Modified 2007-01-08 by Yuichi SATO. LDP v2.43 .\" .TH RTC 4 2010-02-25 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O rtc \- real-time clock rtc \- リアルタイムクロック .\"O .SH SYNOPSIS .SH 書式 #include .sp .BI "int ioctl(" fd ", RTC_" request ", " param ");" .\"O .SH DESCRIPTION .SH 説明 .\"O This is the interface to drivers for real-time clocks (RTCs). これはリアルタイムクロック (RTC) のドライバのインタフェースである。 .\"O Most computers have one or more hardware clocks which record the .\"O current "wall clock" time. .\"O These are called "Real Time Clocks" (RTCs). .\"O One of these usually has battery backup power so that it tracks the time .\"O even while the computer is turned off. .\"O RTCs often provide alarms and other interrupts. 多くのコンピュータは、現在の「壁時計」時刻 ("wall clock" time) を記録する、 ハードウェアクロックを 1 個以上持っている。 これらは「リアルタイムクロック」(RTC) と呼ばれる。 これらの時計のうち 1 つは、通常は電池でバックアップして駆動されるので、 コンピュータのスイッチを切っても、時刻を保持できる。 多くの場合、RTC はアラームやその他の割り込みの機能を提供する。 .\"O All i386 PCs, and ACPI-based systems, have an RTC that is compatible with .\"O the Motorola MC146818 chip on the original PC/AT. .\"O Today such an RTC is usually integrated into the mainboard's chipset .\"O (south bridge), and uses a replaceable coin-sized backup battery. 全ての i386 PC と ACPI ベースのシステムには RTC がある。 この RTC は、元々の PC/AT に存在した Motorola MC146818 チップと互換性がある。 このような RTC は、今日ではマザーボードの チップセット (サウスブリッジ) 内で実装されていることが多く、 交換可能な硬貨くらいの大きさのバックアップ電池を使っている。 .\"O Non-PC systems, such as embedded systems built around system-on-chip .\"O processors, use other implementations. .\"O They usually won't offer the same functionality as the RTC from a PC/AT. システムオンチップ (system-on-chip) プロセッサを使って作られた 組み込みシステムといった、PC 以外のシステムでは、別な実装を用いている。 このようなシステムでは、PC/AT の RTC と同じ機能を提供していない場合が多い。 .\"O .SS RTC vs System Clock .SS RTC とシステムクロックの違い .\"O RTCs should not be confused with the system clock, which is .\"O a software clock maintained by the kernel and used to implement .\"O .BR gettimeofday (2) .\"O and .\"O .BR time (2), .\"O as well as setting timestamps on files, etc. RTC をシステムクロックと混同すべきではない。 システムクロックは、カーネルに管理されるソフトウェアクロックであり、 ファイルによるタイムスタンプ設定などとともに、 .BR gettimeofday (2) や .BR time (2) を実装するのに使用されている。 .\"O The system clock reports seconds and microseconds since a start point, .\"O defined to be the POSIX Epoch: 1970-01-01 00:00:00 +0000 (UTC). システムクロックは、POSIX における紀元 (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) からの秒とミリ秒を表す。 .\"O (One common implementation counts timer interrupts, once .\"O per "jiffy", at a frequency of 100, 250, or 1000 Hz.) .\"O That is, it is supposed to report wall clock time, which RTCs also do. 1 つの一般的な実装ではタイマー割り込みを、"jiffy" 毎に 1 回、 100, 250, 1000 Hz という周波数でカウントする。 .\"O A key difference between an RTC and the system clock is that RTCs .\"O run even when the system is in a low power state (including "off"), .\"O and the system clock can't. RTC とシステムクロックの重要な違いは、 RTC はシステムが低電力状態 (「オフ」の場合も含む) でも動作するのに対し、 システムクロックは動作しない点である。 .\"O Until it is initialized, the system clock can only report time since .\"O system boot ... not since the POSIX Epoch. システムクロックは、初期化が行われるまでは、 POSIX 紀元からではなくシステムのブート時からの時刻しか返せない。 .\"O So at boot time, and after resuming from a system low power state, the .\"O system clock will often be set to the current wall clock time using an RTC. そのため、ブート時やシステムの低電力状態からの復帰 (resume) 後には、 システムクロックは RTC を使って現在の壁時計時刻に設定される場合が多い。 .\"O Systems without an RTC need to set the system clock using another clock, .\"O maybe across the network or by entering that data manually. RTC を持たないシステムでは、 他の時計を使ってシステムクロックを設定する必要があり、 ネットワークにアクセスしたり、(時刻) データを手動で入力したりするだろう。 .\"O .SS RTC functionality .SS RTC の機能 .\"O RTCs can be read and written with .\"O .BR hwclock (8), .\"O or directly with the ioctl requests listed below. RTC は .BR hwclock (8) または下記の ioctl リクエストで読み書きができる。 .\"O Besides tracking the date and time, many RTCs can also generate .\"O interrupts 日付と時間をカウントするのに加えて、 多くの RTC は以下のように割り込みを発生できる。 .IP * 3 .\"O on every clock update (i.e., once per second); クロックの更新毎 (つまり 1 秒毎)。 .IP * .\"O at periodic intervals with a frequency that can be set to .\"O any power-of-2 multiple in the range 2 Hz to 8192 Hz; 2 Hz から 8192 Hz までの 2 の乗数の周波数で、定期的な間隔。 .IP * .\"O on reaching a previously specified alarm time. 前もって指定したアラーム時刻に達した時。 .PP .\"O Each of those interrupt sources can be enabled or disabled separately. これらの割り込み元は、個別に有効にしたり無効にしたりできる。 .\"O On many systems, the alarm interrupt can be configured as a system wakeup .\"O event, which can resume the system from a low power state such as .\"O Suspend-to-RAM (STR, called S3 in ACPI systems), .\"O Hibernation (called S4 in ACPI systems), .\"O or even "off" (called S5 in ACPI systems). 多くのシステムでは、アラーム割り込みをシステムの ウェイクアップイベントとして設定できる。 このイベントは、RAM へのサスペンド (STR, ACPI システムで S3 と呼ばれる) や ハイバーネーション (ACPI システムで S4 と呼ばれる) といった低電力状態や、 「オフ」(ACPI システムで S5 と呼ばれる) からでも、システムを復帰できる。 .\"O On some systems, the battery backed RTC can't issue .\"O interrupts, but another one can. 電池でバックアップされた RTC が割り込みを発生できるシステムと、 できないシステムがある。 .\"O The .\"O .I /dev/rtc .\"O (or .\"O .IR /dev/rtc0 , .\"O .IR /dev/rtc1 , .\"O etc.) .\"O device can be opened only once (until it is closed) and it is read-only. .I /dev/rtc (または .IR /dev/rtc0 , .I /dev/rtc1 などの) デバイスは (クローズされるまで) 1 回しかオープンすることができず、 読み込み専用である。 .\"O On .\"O .BR read (2) .\"O and .\"O .BR select (2) .\"O the calling process is blocked until the next interrupt from that RTC .\"O is received. .BR read (2) と .BR select (2) を呼び出したプロセスは、 RTC からの割り込みを受け取るまで停止 (block) される。 .\"O Following the interrupt, the process can read a long integer, of which .\"O the least significant byte contains a bit mask encoding .\"O the types of interrupt that occurred, .\"O while the remaining 3 bytes contain the number of interrupts since the .\"O last .\"O .BR read (2). 割り込みの後、プロセスは long 型整数を読み出すことができる。 この整数の最下位バイトは発生した割り込みの種別を コード化したビットマスクであり、 残りの 3 バイトは最後の .BR read (2) 以降に発生した割り込みの回数である。 .\"O .SS ioctl(2) interface .SS ioctl(2) インタフェース .\"O The following .\"O .BR ioctl (2) .\"O requests are defined on file descriptors connected to RTC devices: 以下の .BR ioctl (2) リクエストが RTC デバイスの接続された ファイルディスクリプタに対して定義されている: .TP .B RTC_RD_TIME .\"O Returns this RTC's time in the following structure: RTC の時刻を以下の構造体で返す: .IP .in +4n .nf struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; .\"O int tm_wday; /* unused */ int tm_wday; /* 未使用 */ .\"O int tm_yday; /* unused */ int tm_yday; /* 未使用 */ .\"O int tm_isdst; /* unused */ int tm_isdst; /* 未使用 */ }; .fi .in .IP .\"O The fields in this structure have the same meaning and ranges as for the .\"O .I tm .\"O structure described in .\"O .BR gmtime (3). この構造体のフィールドは .BR gmtime (3) で説明されている .I tm 構造体のフィールドと同じ意味で同じ範囲である。 .\"O A pointer to this structure should be passed as the third .\"O .BR ioctl (2) .\"O argument. この構造体へのポインタを .BR ioctl (2) の第 3 引き数として渡す。 .TP .B RTC_SET_TIME .\"O Sets this RTC's time to the time specified by the .\"O .I rtc_time .\"O structure pointed to by the third .\"O .BR ioctl (2) .\"O argument. .BR ioctl (2) の第 3 引き数が指す .I rtc_time 構造体の値を RTC 時刻に設定する。 .\"O To set the .\"O RTC's time the process must be privileged (i.e., have the .\"O .B CAP_SYS_TIME .\"O capability). RTC 時刻の設定する場合、プロセスは特権 (つまり .B CAP_SYS_TIME ケーパビリティ) を持たなければならない。 .TP .BR RTC_ALM_READ ", " RTC_ALM_SET .\"O Read and set the alarm time, for RTCs that support alarms. アラームがサポートされている RTC に対して、 アラーム時刻の読み込みと設定を行う。 .\"O The alarm interrupt must be separately enabled or disabled using the .\"O .BR RTC_AIE_ON ", " RTC_AIE_OFF .\"O requests. アラーム割り込みは、 .BR RTC_AIE_ON ", " RTC_AIE_OFF を使って、これとは別に有効または無効にしなければならない。 .\"O The third .\"O .BR ioctl (2) .\"O argument is a pointer to an .\"O .I rtc_time .\"O structure. \fBioctl\fP(2) の第 3 引き数は、 .I rtc_time 構造体へのポインタでなければならない。 .\"O Only the .\"O .IR tm_sec , .\"O .IR tm_min , .\"O and .\"O .I tm_hour .\"O fields of this structure are used. この構造体の .IR tm_sec , .IR tm_min , .I tm_hour フィールドのみが使用される。 .TP .BR RTC_IRQP_READ ", " RTC_IRQP_SET .\"O Read and set the frequency for periodic interrupts, .\"O for RTCs that support periodic interrupts. 周期的な割り込みがサポートされている RTC に対して、 周期的な割り込みの周波数の読み込みと設定を行う。 .\"O The periodic interrupt must be separately enabled or disabled using the .\"O .BR RTC_PIE_ON ", " RTC_PIE_OFF .\"O requests. 周期的な割り込みは、 .BR RTC_PIE_ON ", " RTC_PIE_OFF を使って、これとは別に有効または無効にしなければならない。 .\"O The third .\"O .BR ioctl (2) .\"O argument is an .\"O .I "unsigned long\ *" .\"O or an .\"O .IR "unsigned long" , .\"O respectively. \fBioctl\fP(2) の第 3 引き数は、それぞれ .I "unsigned long\ *" と .I "unsigned long" である。 .\"O The value is the frequency in interrupts per second. .\"O The set of allowable frequencies is the multiples of two .\"O in the range 2 to 8192. この値は 1 秒当たりの割り込みの回数である。 指定可能な周波数は、2 の乗数で 2 から 8192 の範囲である。 .\"O Only a privileged process (i.e., one having the .\"O .B CAP_SYS_RESOURCE .\"O capability) can set frequencies above the value specified in .\"O .IR /proc/sys/dev/rtc/max-user-freq . 特権プロセス (つまり .B CAP_SYS_RESOURCE ケーパビリティを持つプロセス) のみが、 .I /proc/sys/dev/rtc/max-user-freq に書かれた上記の周波数を設定できる。 .\"O (This file contains the value 64 by default.) (このファイルにはデフォルトで 64 という値が書かれている)。 .TP .BR RTC_AIE_ON ", " RTC_AIE_OFF .\"O Enable or disable the alarm interrupt, for RTCs that support alarms. .\"O The third .\"O .BR ioctl (2) .\"O argument is ignored. アラームがサポートされている RTC に対して、 アラーム割り込みを有効または無効にする。 \fBioctl\fP(2) の第 3 引き数は無視される。 .TP .BR RTC_UIE_ON ", " RTC_UIE_OFF .\"O Enable or disable the interrupt on every clock update, .\"O for RTCs that support this once-per-second interrupt. .\"O The third .\"O .BR ioctl (2) .\"O argument is ignored. 1 秒毎の割り込みがサポートされている RTC に対して、 クロック更新毎の割り込みを有効または無効にする。 \fBioctl\fP(2) の第 3 引き数は無視される。 .TP .BR RTC_PIE_ON ", " RTC_PIE_OFF .\"O Enable or disable the periodic interrupt, .\"O for RTCs that support these periodic interrupts. .\"O The third .\"O .BR ioctl (2) .\"O argument is ignored. 周期的な割り込みがサポートされている RTC に対して、 周期的な割り込みを有効または無効にする。 \fBioctl\fP(2) の第 3 引き数は無視される。 .\"O Only a privileged process (i.e., one having the .\"O .B CAP_SYS_RESOURCE .\"O capability) can enable the periodic interrupt if the frequency is .\"O currently set above the value specified in .\"O .IR /proc/sys/dev/rtc/max-user-freq . 特権プロセス (つまり .B CAP_SYS_RESOURCE ケーパビリティを持つプロセス) のみが、 その時点で .I /proc/sys/dev/rtc/max-user-freq に周期が上記の値に指定されている場合に、 周期的な割り込みを有効にできる。 .TP .BR RTC_EPOCH_READ ", " RTC_EPOCH_SET .\"O Many RTCs encode the year in an 8-bit register which is either .\"O interpreted as an 8-bit binary number or as a BCD number. .\"O In both cases, .\"O the number is interpreted relative to this RTC's Epoch. 多くの RTC は年を 8 ビットのレジスタにコード化する。 年は 8 ビットのバイナリ数または BCD 数に変換される。 どちらの場合でも、その数値は RTC の紀元から相対値に変換される。 .\"O The RTC's Epoch is .\"O initialized to 1900 on most systems but on Alpha and MIPS it might .\"O also be initialized to 1952, 1980, or 2000, depending on the value of .\"O an RTC register for the year. 多くのシステムでは RTC の紀元は 1900 に初期化されるが、 Alpha と MIPS では、RTC レジスタの年の値に応じて、 1952, 1980, 2000 の何れかに初期化される。 .\"O With some RTCs, .\"O these operations can be used to read or to set the RTC's Epoch, .\"O respectively. これらの操作でそれぞれ RTC の紀元の読み込みと設定が可能な RTC もある。 .\"O The third .\"O .BR ioctl (2) .\"O argument is a .\"O .I "unsigned long\ *" .\"O or a .\"O .IR "unsigned long" , .\"O respectively, and the value returned (or assigned) is the Epoch. \fBioctl\fP(2) の第 3 引き数は、それぞれ .I "unsigned long\ *" と .I "unsigned long" である。 返される値 (または指定される値) は紀元である。 .\"O To set the RTC's Epoch the process must be privileged (i.e., have the .\"O .B CAP_SYS_TIME .\"O capability). RTC の紀元を設定する場合、プロセスは特権 (つまり .B CAP_SYS_TIME ケーパビリティ) を持たなければならない。 .TP .BR RTC_WKALM_RD ", " RTC_WKALM_SET .\"O Some RTCs support a more powerful alarm interface, using these ioctls .\"O to read or write the RTC's alarm time (respectively) with this structure: RTC の中にはより強力なアラームインタフェースをサポートするものもあり、 これらの ioctl を使うことで、以下のような構造体で RTC のアラーム時刻を (それぞれ) 読み書きできる: .PP .RS .in +4n .nf struct rtc_wkalrm { unsigned char enabled; unsigned char pending; struct rtc_time time; }; .fi .in .RE .IP .\"O The .\"O .I enabled .\"O flag is used to enable or disable the alarm interrupt, .\"O or to read its current status; when using these calls, .\"O .BR RTC_AIE_ON " and " RTC_AIE_OFF .\"O are not used. .\"O The .\"O .I pending .\"O flag is used by .\"O .B RTC_WKALM_RD .\"O to report a pending interrupt .\"O (so it's mostly useless on Linux, except when talking .\"O to the RTC managed by EFI firmware). .I enabled フラグはアラーム割り込みを有効または無効したり、 現在の状態を読み込むのに使用される。 これらのフラグを使う場合、 .BR RTC_AIE_ON " と " RTC_AIE_OFF は使用されない。 .I pending フラグは .B RTC_WKALM_RD で使用され、処理待ちの割り込みを表示する (EFI ファームウェアで管理される RTC と通信するとき以外、 Linux ではほとんど役に立たない)。 .\"O The .\"O .I time .\"O field is as used with .\"O .B RTC_ALM_READ .\"O and .\"O .B RTC_ALM_SET .\"O except that the .\"O .IR tm_mday , .\"O .IR tm_mon , .\"O and .\"O .I tm_year .\"O fields are also valid. .I time フィールドは .B RTC_ALM_READ や .B RTC_ALM_SET の場合と同じように使用されるが、 .IR tm_mday , .IR tm_mon , .I tm_year フィールドも有効であるという点が異なる。 .\"O A pointer to this structure should be passed as the third .\"O .BR ioctl (2) .\"O argument. この構造体へのポインタを .BR ioctl (2) の第 3 引き数として渡さなければならない。 .\"O .SH FILES .SH ファイル .IR /dev/rtc ", " .IR /dev/rtc0 ", " .\"O .IR /dev/rtc1 ", " .I /dev/rtc1 .\"O etc: RTC special character device files. など: RTC 特殊キャラクターデバイスファイル .IR /proc/driver/rtc : .\"O status of the (first) RTC. (1 つ目の) RTC の状態 .\"O .SH NOTES .SH 注意 .\"O When the kernel's system time is synchronized with an external .\"O reference using .\"O .BR adjtimex (2) .\"O it will update a designated RTC periodically every 11 minutes. .\"O To do so, the kernel has to briefly turn off periodic interrupts; .\"O this might affect programs using that RTC. カーネルのシステムクロックを .BR adjtimex (2) を使って外部参照で同期させる場合、 .BR adjtimex (2) は指定された RTC を 11 分毎に定期的に更新する。 これを行うためカーネルは周期的な割り込みを短期間無効にする必要がある。 これは RTC を使うプログラムに影響を与える。 .\"O An RTC's Epoch has nothing to do with the POSIX Epoch which is only .\"O used for the system clock. RTC の紀元は、システムクロックでのみ使用される POSIX の紀元とは何の関係もない。 .\"O If the year according to the RTC's Epoch and the year register is .\"O less than 1970 it is assumed to be 100 years later, that is, between 2000 .\"O and 2069. RTC の紀元と年のレジスタに基づく年が 1970 未満である場合、 100 年後、つまり 2000 から 2069 であると仮定される。 .\"O Some RTCs support "wildcard" values in alarm fields, to support .\"O scenarios like periodic alarms at fifteen minutes after every hour, .\"O or on the first day of each month. .\"O Such usage is nonportable; .\"O portable user space code only expects a single alarm interrupt, and .\"O will either disable or reinitialize the alarm after receiving it. RTC の中にはアラームフィールドに 「ワイルドカード」の値をサポートするものもあり、 毎時 15 分や各月の初日など、定期的なアラームを行うシナリオをサポートする。 このような使い方は移植性がない。 移植性の高いユーザ空間コードでは、単独のアラーム割り込みだけを想定し、 割り込みの受信後にアラームを無効または再初期化すべきである。 .\"O Some RTCs support periodic interrupts with periods that are multiples .\"O of a second rather than fractions of a second; .\"O multiple alarms; .\"O programmable output clock signals; .\"O nonvolatile memory; .\"O and other hardware .\"O capabilities that are not currently exposed by this API. 以下の機能をサポートする RTC もある。 1 秒の分数ではなく、1 秒の倍数を周期とする周期的な割り込み。 複数のアラーム。 プログラム可能な出力クロックシグナル。 不揮発性 (nonvolatile) メモリ。 この API で現在提供していない、その他のハードウェア機能。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR date (1), .BR adjtimex (2), .BR gettimeofday (2), .BR settimeofday (2), .BR stime (2), .BR time (2), .BR gmtime (3), .BR time (7), .BR hwclock (8), /usr/src/linux/Documentation/rtc.txt