| 786 | } |
| 787 | |
| 788 | int |
| 789 | vrtc_nvram_write(struct vm *vm, int offset, uint8_t value) |
| 790 | { |
| 791 | struct vrtc *vrtc; |
| 792 | uint8_t *ptr; |
| 793 | |
| 794 | vrtc = vm_rtc(vm); |
| 795 | |
| 796 | /* |
| 797 | * Don't allow writes to RTC control registers or the date/time fields. |
| 798 | */ |
| 799 | if (offset < offsetof(struct rtcdev, nvram[0]) || |
| 800 | offset == RTC_CENTURY || offset >= sizeof(struct rtcdev)) { |
| 801 | VM_CTR1(vrtc->vm, "RTC nvram write to invalid offset %d", |
| 802 | offset); |
| 803 | return (EINVAL); |
| 804 | } |
| 805 | |
| 806 | VRTC_LOCK(vrtc); |
| 807 | ptr = (uint8_t *)(&vrtc->rtcdev); |
| 808 | ptr[offset] = value; |
| 809 | VM_CTR2(vrtc->vm, "RTC nvram write %#x to offset %#x", value, offset); |
| 810 | VRTC_UNLOCK(vrtc); |
| 811 | |
| 812 | return (0); |
| 813 | } |
| 814 | |
| 815 | int |
| 816 | vrtc_nvram_read(struct vm *vm, int offset, uint8_t *retval) |
no test coverage detected