Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #ifndef __KVM_IODEV_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #define __KVM_IODEV_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/kvm_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) struct kvm_io_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct kvm_vcpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * kvm_io_device_ops are called under kvm slots_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * read and write handlers return 0 if the transaction has been handled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * or non-zero to have it passed to the next device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct kvm_io_device_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	int (*read)(struct kvm_vcpu *vcpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 		    struct kvm_io_device *this,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		    gpa_t addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		    int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		    void *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	int (*write)(struct kvm_vcpu *vcpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		     struct kvm_io_device *this,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		     gpa_t addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		     int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		     const void *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	void (*destructor)(struct kvm_io_device *this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct kvm_io_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	const struct kvm_io_device_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static inline void kvm_iodevice_init(struct kvm_io_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 				     const struct kvm_io_device_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	dev->ops = ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static inline int kvm_iodevice_read(struct kvm_vcpu *vcpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 				    struct kvm_io_device *dev, gpa_t addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 				    int l, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	return dev->ops->read ? dev->ops->read(vcpu, dev, addr, l, v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 				: -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static inline int kvm_iodevice_write(struct kvm_vcpu *vcpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 				     struct kvm_io_device *dev, gpa_t addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 				     int l, const void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	return dev->ops->write ? dev->ops->write(vcpu, dev, addr, l, v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 				 : -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	if (dev->ops->destructor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		dev->ops->destructor(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #endif /* __KVM_IODEV_H__ */