| 813 | } |
| 814 | |
| 815 | int |
| 816 | vrtc_nvram_read(struct vm *vm, int offset, uint8_t *retval) |
| 817 | { |
| 818 | struct vrtc *vrtc; |
| 819 | sbintime_t basetime; |
| 820 | time_t curtime; |
| 821 | uint8_t *ptr; |
| 822 | |
| 823 | /* |
| 824 | * Allow all offsets in the RTC to be read. |
| 825 | */ |
| 826 | if (offset < 0 || offset >= sizeof(struct rtcdev)) |
| 827 | return (EINVAL); |
| 828 | |
| 829 | vrtc = vm_rtc(vm); |
| 830 | VRTC_LOCK(vrtc); |
| 831 | |
| 832 | /* |
| 833 | * Update RTC date/time fields if necessary. |
| 834 | */ |
| 835 | if (offset < 10 || offset == RTC_CENTURY) { |
| 836 | curtime = vrtc_curtime(vrtc, &basetime); |
| 837 | secs_to_rtc(curtime, vrtc, 0); |
| 838 | } |
| 839 | |
| 840 | ptr = (uint8_t *)(&vrtc->rtcdev); |
| 841 | *retval = ptr[offset]; |
| 842 | |
| 843 | VRTC_UNLOCK(vrtc); |
| 844 | return (0); |
| 845 | } |
| 846 | |
| 847 | int |
| 848 | vrtc_addr_handler(struct vm *vm, int vcpuid, bool in, int port, int bytes, |
no test coverage detected