12f93d8b0SPeter Maydell /* 22f93d8b0SPeter Maydell * RTC configuration and clock read 32f93d8b0SPeter Maydell * 42f93d8b0SPeter Maydell * Copyright (c) 2003-2021 QEMU contributors 52f93d8b0SPeter Maydell * 62f93d8b0SPeter Maydell * Permission is hereby granted, free of charge, to any person obtaining a copy 72f93d8b0SPeter Maydell * of this software and associated documentation files (the "Software"), to deal 82f93d8b0SPeter Maydell * in the Software without restriction, including without limitation the rights 92f93d8b0SPeter Maydell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 102f93d8b0SPeter Maydell * copies of the Software, and to permit persons to whom the Software is 112f93d8b0SPeter Maydell * furnished to do so, subject to the following conditions: 122f93d8b0SPeter Maydell * 132f93d8b0SPeter Maydell * The above copyright notice and this permission notice shall be included in 142f93d8b0SPeter Maydell * all copies or substantial portions of the Software. 152f93d8b0SPeter Maydell * 162f93d8b0SPeter Maydell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 172f93d8b0SPeter Maydell * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 182f93d8b0SPeter Maydell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 192f93d8b0SPeter Maydell * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 202f93d8b0SPeter Maydell * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 212f93d8b0SPeter Maydell * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 222f93d8b0SPeter Maydell * THE SOFTWARE. 232f93d8b0SPeter Maydell */ 242f93d8b0SPeter Maydell 252f93d8b0SPeter Maydell #ifndef SYSEMU_RTC_H 262f93d8b0SPeter Maydell #define SYSEMU_RTC_H 272f93d8b0SPeter Maydell 282f93d8b0SPeter Maydell /** 292f93d8b0SPeter Maydell * qemu_get_timedate: Get the current RTC time 302f93d8b0SPeter Maydell * @tm: struct tm to fill in with RTC time 312f93d8b0SPeter Maydell * @offset: offset in seconds to adjust the RTC time by before 322f93d8b0SPeter Maydell * converting to struct tm format. 332f93d8b0SPeter Maydell * 342f93d8b0SPeter Maydell * This function fills in @tm with the current RTC time, as adjusted 352f93d8b0SPeter Maydell * by @offset (for example, if @offset is 3600 then the returned time/date 362f93d8b0SPeter Maydell * will be one hour further ahead than the current RTC time). 372f93d8b0SPeter Maydell * 382f93d8b0SPeter Maydell * The usual use is by RTC device models, which should call this function 392f93d8b0SPeter Maydell * to find the time/date value that they should return to the guest 402f93d8b0SPeter Maydell * when it reads the RTC registers. 412f93d8b0SPeter Maydell * 422f93d8b0SPeter Maydell * The behaviour of the clock whose value this function returns will 432f93d8b0SPeter Maydell * depend on the -rtc command line option passed by the user. 442f93d8b0SPeter Maydell */ 45*5ec008a2SPeter Maydell void qemu_get_timedate(struct tm *tm, time_t offset); 462f93d8b0SPeter Maydell 472f93d8b0SPeter Maydell /** 482f93d8b0SPeter Maydell * qemu_timedate_diff: Return difference between a struct tm and the RTC 492f93d8b0SPeter Maydell * @tm: struct tm containing the date/time to compare against 502f93d8b0SPeter Maydell * 512f93d8b0SPeter Maydell * Returns the difference in seconds between the RTC clock time 522f93d8b0SPeter Maydell * and the date/time specified in @tm. For example, if @tm specifies 532f93d8b0SPeter Maydell * a timestamp one hour further ahead than the current RTC time 542f93d8b0SPeter Maydell * then this function will return 3600. 552f93d8b0SPeter Maydell */ 56*5ec008a2SPeter Maydell time_t qemu_timedate_diff(struct tm *tm); 572f93d8b0SPeter Maydell 582f93d8b0SPeter Maydell #endif 59