@samitouri / QOSamiQemu / commits / 5341284a7c

standard-headers: Add virtio_rtc.h from Linux 7.0-rc1

Add virtio_rtc.h from the upstream Linux kernel using scripts/update-linux-headers.sh. Source: - Linux commit 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f (v7.0-rc1) - Author: Linus Torvalds <torvalds@linux-foundation.org> - Date: Sun Feb 22 13:18:59 2026 -0800 Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260228182246.700714-2-visitorckw@gmail.com>

Kuan-Wei Chiu committed Feb 28, 2026 at 18:22 UTC 5341284a7cbadb19fa61dadb643475d3aef2f5a3
1 file changed +237
include/standard-headers/linux/virtio_rtc.h new
+237
@@ -0,0 +1,237 @@
1 +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */
2 +/*
3 + * Copyright (C) 2022-2024 OpenSynergy GmbH
4 + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
5 + */
6 +
7 +#ifndef _LINUX_VIRTIO_RTC_H
8 +#define _LINUX_VIRTIO_RTC_H
9 +
10 +#include "standard-headers/linux/types.h"
11 +
12 +/* alarm feature */
13 +#define VIRTIO_RTC_F_ALARM 0
14 +
15 +/* read request message types */
16 +
17 +#define VIRTIO_RTC_REQ_READ 0x0001
18 +#define VIRTIO_RTC_REQ_READ_CROSS 0x0002
19 +
20 +/* control request message types */
21 +
22 +#define VIRTIO_RTC_REQ_CFG 0x1000
23 +#define VIRTIO_RTC_REQ_CLOCK_CAP 0x1001
24 +#define VIRTIO_RTC_REQ_CROSS_CAP 0x1002
25 +#define VIRTIO_RTC_REQ_READ_ALARM 0x1003
26 +#define VIRTIO_RTC_REQ_SET_ALARM 0x1004
27 +#define VIRTIO_RTC_REQ_SET_ALARM_ENABLED 0x1005
28 +
29 +/* alarmq message types */
30 +
31 +#define VIRTIO_RTC_NOTIF_ALARM 0x2000
32 +
33 +/* Message headers */
34 +
35 +/** common request header */
36 +struct virtio_rtc_req_head {
37 + uint16_t msg_type;
38 + uint8_t reserved[6];
39 +};
40 +
41 +/** common response header */
42 +struct virtio_rtc_resp_head {
43 +#define VIRTIO_RTC_S_OK 0
44 +#define VIRTIO_RTC_S_EOPNOTSUPP 2
45 +#define VIRTIO_RTC_S_ENODEV 3
46 +#define VIRTIO_RTC_S_EINVAL 4
47 +#define VIRTIO_RTC_S_EIO 5
48 + uint8_t status;
49 + uint8_t reserved[7];
50 +};
51 +
52 +/** common notification header */
53 +struct virtio_rtc_notif_head {
54 + uint16_t msg_type;
55 + uint8_t reserved[6];
56 +};
57 +
58 +/* read requests */
59 +
60 +/* VIRTIO_RTC_REQ_READ message */
61 +
62 +struct virtio_rtc_req_read {
63 + struct virtio_rtc_req_head head;
64 + uint16_t clock_id;
65 + uint8_t reserved[6];
66 +};
67 +
68 +struct virtio_rtc_resp_read {
69 + struct virtio_rtc_resp_head head;
70 + uint64_t clock_reading;
71 +};
72 +
73 +/* VIRTIO_RTC_REQ_READ_CROSS message */
74 +
75 +struct virtio_rtc_req_read_cross {
76 + struct virtio_rtc_req_head head;
77 + uint16_t clock_id;
78 +/* Arm Generic Timer Counter-timer Virtual Count Register (CNTVCT_EL0) */
79 +#define VIRTIO_RTC_COUNTER_ARM_VCT 0
80 +/* x86 Time-Stamp Counter */
81 +#define VIRTIO_RTC_COUNTER_X86_TSC 1
82 +/* Invalid */
83 +#define VIRTIO_RTC_COUNTER_INVALID 0xFF
84 + uint8_t hw_counter;
85 + uint8_t reserved[5];
86 +};
87 +
88 +struct virtio_rtc_resp_read_cross {
89 + struct virtio_rtc_resp_head head;
90 + uint64_t clock_reading;
91 + uint64_t counter_cycles;
92 +};
93 +
94 +/* control requests */
95 +
96 +/* VIRTIO_RTC_REQ_CFG message */
97 +
98 +struct virtio_rtc_req_cfg {
99 + struct virtio_rtc_req_head head;
100 + /* no request params */
101 +};
102 +
103 +struct virtio_rtc_resp_cfg {
104 + struct virtio_rtc_resp_head head;
105 + /** # of clocks -> clock ids < num_clocks are valid */
106 + uint16_t num_clocks;
107 + uint8_t reserved[6];
108 +};
109 +
110 +/* VIRTIO_RTC_REQ_CLOCK_CAP message */
111 +
112 +struct virtio_rtc_req_clock_cap {
113 + struct virtio_rtc_req_head head;
114 + uint16_t clock_id;
115 + uint8_t reserved[6];
116 +};
117 +
118 +struct virtio_rtc_resp_clock_cap {
119 + struct virtio_rtc_resp_head head;
120 +#define VIRTIO_RTC_CLOCK_UTC 0
121 +#define VIRTIO_RTC_CLOCK_TAI 1
122 +#define VIRTIO_RTC_CLOCK_MONOTONIC 2
123 +#define VIRTIO_RTC_CLOCK_UTC_SMEARED 3
124 +#define VIRTIO_RTC_CLOCK_UTC_MAYBE_SMEARED 4
125 + uint8_t type;
126 +#define VIRTIO_RTC_SMEAR_UNSPECIFIED 0
127 +#define VIRTIO_RTC_SMEAR_NOON_LINEAR 1
128 +#define VIRTIO_RTC_SMEAR_UTC_SLS 2
129 + uint8_t leap_second_smearing;
130 +#define VIRTIO_RTC_FLAG_ALARM_CAP (1 << 0)
131 + uint8_t flags;
132 + uint8_t reserved[5];
133 +};
134 +
135 +/* VIRTIO_RTC_REQ_CROSS_CAP message */
136 +
137 +struct virtio_rtc_req_cross_cap {
138 + struct virtio_rtc_req_head head;
139 + uint16_t clock_id;
140 + uint8_t hw_counter;
141 + uint8_t reserved[5];
142 +};
143 +
144 +struct virtio_rtc_resp_cross_cap {
145 + struct virtio_rtc_resp_head head;
146 +#define VIRTIO_RTC_FLAG_CROSS_CAP (1 << 0)
147 + uint8_t flags;
148 + uint8_t reserved[7];
149 +};
150 +
151 +/* VIRTIO_RTC_REQ_READ_ALARM message */
152 +
153 +struct virtio_rtc_req_read_alarm {
154 + struct virtio_rtc_req_head head;
155 + uint16_t clock_id;
156 + uint8_t reserved[6];
157 +};
158 +
159 +struct virtio_rtc_resp_read_alarm {
160 + struct virtio_rtc_resp_head head;
161 + uint64_t alarm_time;
162 +#define VIRTIO_RTC_FLAG_ALARM_ENABLED (1 << 0)
163 + uint8_t flags;
164 + uint8_t reserved[7];
165 +};
166 +
167 +/* VIRTIO_RTC_REQ_SET_ALARM message */
168 +
169 +struct virtio_rtc_req_set_alarm {
170 + struct virtio_rtc_req_head head;
171 + uint64_t alarm_time;
172 + uint16_t clock_id;
173 + /* flag VIRTIO_RTC_FLAG_ALARM_ENABLED */
174 + uint8_t flags;
175 + uint8_t reserved[5];
176 +};
177 +
178 +struct virtio_rtc_resp_set_alarm {
179 + struct virtio_rtc_resp_head head;
180 + /* no response params */
181 +};
182 +
183 +/* VIRTIO_RTC_REQ_SET_ALARM_ENABLED message */
184 +
185 +struct virtio_rtc_req_set_alarm_enabled {
186 + struct virtio_rtc_req_head head;
187 + uint16_t clock_id;
188 + /* flag VIRTIO_RTC_ALARM_ENABLED */
189 + uint8_t flags;
190 + uint8_t reserved[5];
191 +};
192 +
193 +struct virtio_rtc_resp_set_alarm_enabled {
194 + struct virtio_rtc_resp_head head;
195 + /* no response params */
196 +};
197 +
198 +/** Union of request types for requestq */
199 +union virtio_rtc_req_requestq {
200 + struct virtio_rtc_req_read read;
201 + struct virtio_rtc_req_read_cross read_cross;
202 + struct virtio_rtc_req_cfg cfg;
203 + struct virtio_rtc_req_clock_cap clock_cap;
204 + struct virtio_rtc_req_cross_cap cross_cap;
205 + struct virtio_rtc_req_read_alarm read_alarm;
206 + struct virtio_rtc_req_set_alarm set_alarm;
207 + struct virtio_rtc_req_set_alarm_enabled set_alarm_enabled;
208 +};
209 +
210 +/** Union of response types for requestq */
211 +union virtio_rtc_resp_requestq {
212 + struct virtio_rtc_resp_read read;
213 + struct virtio_rtc_resp_read_cross read_cross;
214 + struct virtio_rtc_resp_cfg cfg;
215 + struct virtio_rtc_resp_clock_cap clock_cap;
216 + struct virtio_rtc_resp_cross_cap cross_cap;
217 + struct virtio_rtc_resp_read_alarm read_alarm;
218 + struct virtio_rtc_resp_set_alarm set_alarm;
219 + struct virtio_rtc_resp_set_alarm_enabled set_alarm_enabled;
220 +};
221 +
222 +/* alarmq notifications */
223 +
224 +/* VIRTIO_RTC_NOTIF_ALARM notification */
225 +
226 +struct virtio_rtc_notif_alarm {
227 + struct virtio_rtc_notif_head head;
228 + uint16_t clock_id;
229 + uint8_t reserved[6];
230 +};
231 +
232 +/** Union of notification types for alarmq */
233 +union virtio_rtc_notif_alarmq {
234 + struct virtio_rtc_notif_alarm alarm;
235 +};
236 +
237 +#endif /* _LINUX_VIRTIO_RTC_H */