summaryrefslogtreecommitdiff
path: root/sys/arch/xen/include/i82093var.h
blob: 49cca0bbc1f3ad01272f9bade7a1fe43b4948c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*	 $NetBSD: i82093var.h,v 1.7 2020/04/25 15:26:17 bouyer Exp $ */

#ifndef _XEN_I82093VAR_H_
#define _XEN_I82093VAR_H_

#include "opt_xen.h"
#define _IOAPIC_CUSTOM_RW
#include <x86/i82093var.h>
#include <hypervisor.h>

static inline  uint32_t
ioapic_read_ul(struct ioapic_softc *sc, int regid)
{
	struct physdev_apic apic_op;
	int ret;

	apic_op.apic_physbase = sc->sc_pa;
	apic_op.reg = regid;
	ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
	if (ret) {
		printf("PHYSDEVOP_APIC_READ ret %d\n", ret);
		panic("PHYSDEVOP_APIC_READ");
	}
	return apic_op.value;      
}

static inline void
ioapic_write_ul(struct ioapic_softc *sc, int regid, uint32_t val)
{
	struct physdev_apic apic_op;
	int ret;

	apic_op.apic_physbase = sc->sc_pa;
	apic_op.reg = regid;
	apic_op.value = val;
	ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op);
	if (ret)
		printf("PHYSDEVOP_APIC_WRITE ret %d\n", ret);
}

#endif /* !_XEN_I82093VAR_H_ */