xref: /netbsd-src/sys/arch/xen/include/i82093var.h (revision c24c993fe4cf289234b8ce9b47d92eb1278cfbda)
1 /*	 $NetBSD: i82093var.h,v 1.7 2020/04/25 15:26:17 bouyer Exp $ */
2 
3 #ifndef _XEN_I82093VAR_H_
4 #define _XEN_I82093VAR_H_
5 
6 #include "opt_xen.h"
7 #define _IOAPIC_CUSTOM_RW
8 #include <x86/i82093var.h>
9 #include <hypervisor.h>
10 
11 static inline  uint32_t
ioapic_read_ul(struct ioapic_softc * sc,int regid)12 ioapic_read_ul(struct ioapic_softc *sc, int regid)
13 {
14 	struct physdev_apic apic_op;
15 	int ret;
16 
17 	apic_op.apic_physbase = sc->sc_pa;
18 	apic_op.reg = regid;
19 	ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
20 	if (ret) {
21 		printf("PHYSDEVOP_APIC_READ ret %d\n", ret);
22 		panic("PHYSDEVOP_APIC_READ");
23 	}
24 	return apic_op.value;
25 }
26 
27 static inline void
ioapic_write_ul(struct ioapic_softc * sc,int regid,uint32_t val)28 ioapic_write_ul(struct ioapic_softc *sc, int regid, uint32_t val)
29 {
30 	struct physdev_apic apic_op;
31 	int ret;
32 
33 	apic_op.apic_physbase = sc->sc_pa;
34 	apic_op.reg = regid;
35 	apic_op.value = val;
36 	ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op);
37 	if (ret)
38 		printf("PHYSDEVOP_APIC_WRITE ret %d\n", ret);
39 }
40 
41 #endif /* !_XEN_I82093VAR_H_ */
42