Index: i82489var.h
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/include/i82489var.h,v
retrieving revision 1.1
diff -u -p -r1.1 i82489var.h
--- i82489var.h	28 Sep 2006 18:53:15 -0000	1.1
+++ i82489var.h	17 Apr 2008 09:51:12 -0000
@@ -1,5 +1,54 @@
-/*	$NetBSD: i82489var.h,v 1.1 2006/09/28 18:53:15 bouyer Exp $	*/
+/*	 $NetBSD: i82489var.h,v 1.1 2006/09/28 18:53:15 bouyer Exp $ */
 
+#include "opt_xen.h"
+#define _LAPIC_CUSTOM_RW
 #include <x86/i82489var.h>
+#include <hypervisor.h>
+
 #undef lapic_cpu_number
-#define lapic_cpu_number() (0)
+
+#ifdef XEN3
+
+static inline uint32_t
+lapic_cpu_number(void)
+{
+#ifdef VCPUOP_get_physid
+	struct vcpu_get_physid cpu_id;
+	int ret;
+
+	ret = HYPERVISOR_vcpu_op(VCPUOP_get_physid, 0, &cpu_id);
+	if (ret != 0) {
+		return 0;
+	}
+
+	return xen_vcpu_physid_to_x86_apicid(cpu_id.phys_id);
+#else
+	printf("%s: WARNING: Xen 3.2.x or newer required to determine APIC ID\n", __func__);
+	return 0;
+#endif
+}
+
+static inline uint32_t
+acpi_cpu_number(void)
+{
+#ifdef VCPUOP_get_physid
+	struct vcpu_get_physid cpu_id;
+	int ret;
+
+	ret = HYPERVISOR_vcpu_op(VCPUOP_get_physid, 0, &cpu_id);
+	if (ret != 0) {
+		return 0;
+	}
+
+	return xen_vcpu_physid_to_x86_acpiid(cpu_id.phys_id);
+#else
+	printf("%s: WARNING: Xen 3.2.x or newer required to determine ACPI ID\n", __func__);
+	return 0;
+#endif
+}
+
+#else
+
+#define lapic_cpu_number()	(0)
+
+#endif