File Index
Files and directories
Sign in
FILE

i8254.h

File preview with syntax highlighting.

linux-6.19.14/arch/x86/kvm/i8254.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __I8254_H
 3#define __I8254_H
 4
 5#include <linux/kthread.h>
 6
 7#include <kvm/iodev.h>
 8
 9#include <uapi/asm/kvm.h>
10
11#include "ioapic.h"
12
13#ifdef CONFIG_KVM_IOAPIC
14struct kvm_kpit_channel_state {
15	u32 count; /* can be 65536 */
16	u16 latched_count;
17	u8 count_latched;
18	u8 status_latched;
19	u8 status;
20	u8 read_state;
21	u8 write_state;
22	u8 write_latch;
23	u8 rw_mode;
24	u8 mode;
25	u8 bcd; /* not supported */
26	u8 gate; /* timer start */
27	ktime_t count_load_time;
28};
29
30struct kvm_kpit_state {
31	/* All members before "struct mutex lock" are protected by the lock. */
32	struct kvm_kpit_channel_state channels[3];
33	u32 flags;
34	bool is_periodic;
35	s64 period; 				/* unit: ns */
36	struct hrtimer timer;
37
38	struct mutex lock;
39	atomic_t reinject;
40	atomic_t pending; /* accumulated triggered timers */
41	atomic_t irq_ack;
42	struct kvm_irq_ack_notifier irq_ack_notifier;
43};
44
45struct kvm_pit {
46	struct kvm_io_device dev;
47	struct kvm_io_device speaker_dev;
48	struct kvm *kvm;
49	struct kvm_kpit_state pit_state;
50	struct kvm_irq_mask_notifier mask_notifier;
51	struct kthread_worker *worker;
52	struct kthread_work expired;
53};
54
55#define KVM_PIT_BASE_ADDRESS	    0x40
56#define KVM_SPEAKER_BASE_ADDRESS    0x61
57#define KVM_PIT_MEM_LENGTH	    4
58#define KVM_PIT_FREQ		    1193181
59#define KVM_MAX_PIT_INTR_INTERVAL   HZ / 100
60#define KVM_PIT_CHANNEL_MASK	    0x3
61
62int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps);
63int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps);
64int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps);
65int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps);
66int kvm_vm_ioctl_reinject(struct kvm *kvm, struct kvm_reinject_control *control);
67
68struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags);
69void kvm_free_pit(struct kvm *kvm);
70#endif /* CONFIG_KVM_IOAPIC */
71
72#endif
~/ Read-only file preview.