2
0

rtc.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * RTC configuration and clock read
  3. *
  4. * Copyright (c) 2003-2021 QEMU contributors
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #ifndef SYSTEM_RTC_H
  25. #define SYSTEM_RTC_H
  26. /**
  27. * qemu_get_timedate: Get the current RTC time
  28. * @tm: struct tm to fill in with RTC time
  29. * @offset: offset in seconds to adjust the RTC time by before
  30. * converting to struct tm format.
  31. *
  32. * This function fills in @tm with the current RTC time, as adjusted
  33. * by @offset (for example, if @offset is 3600 then the returned time/date
  34. * will be one hour further ahead than the current RTC time).
  35. *
  36. * The usual use is by RTC device models, which should call this function
  37. * to find the time/date value that they should return to the guest
  38. * when it reads the RTC registers.
  39. *
  40. * The behaviour of the clock whose value this function returns will
  41. * depend on the -rtc command line option passed by the user.
  42. */
  43. void qemu_get_timedate(struct tm *tm, time_t offset);
  44. /**
  45. * qemu_timedate_diff: Return difference between a struct tm and the RTC
  46. * @tm: struct tm containing the date/time to compare against
  47. *
  48. * Returns the difference in seconds between the RTC clock time
  49. * and the date/time specified in @tm. For example, if @tm specifies
  50. * a timestamp one hour further ahead than the current RTC time
  51. * then this function will return 3600.
  52. */
  53. time_t qemu_timedate_diff(struct tm *tm);
  54. #endif