[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Jul 25 14:36:10 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/99650cb861f2
changeset: 495:99650cb861f2
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Wed Jul 25 16:42:35 2012 +0300
description:
Lazy update

diffstat:

 head/sys/x86/acpica/acpi_wakeup.c |  391 ++++++++++++++++++++++++++++++++++++++
 head/sys/x86/include/_limits.h    |    6 +-
 head/sys/x86/include/_stdint.h    |   16 +-
 head/sys/x86/include/_types.h     |   14 +-
 head/sys/x86/include/float.h      |    4 +-
 head/sys/x86/include/ptrace.h     |    8 +-
 head/sys/x86/include/specialreg.h |    7 +-
 head/sys/x86/include/vdso.h       |   42 ++++
 head/sys/x86/x86/dump_machdep.c   |    8 +-
 head/sys/x86/x86/intr_machdep.c   |    9 +-
 head/sys/x86/x86/tsc.c            |   26 ++-
 11 files changed, 499 insertions(+), 32 deletions(-)

diffs (781 lines):

diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/acpica/acpi_wakeup.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/x86/acpica/acpi_wakeup.c	Wed Jul 25 16:42:35 2012 +0300
@@ -0,0 +1,391 @@
+/*-
+ * Copyright (c) 2001 Takanori Watanabe <takawata at jp.freebsd.org>
+ * Copyright (c) 2001-2012 Mitsuru IWASAKI <iwasaki at jp.freebsd.org>
+ * Copyright (c) 2003 Peter Wemm
+ * Copyright (c) 2008-2012 Jung-uk Kim <jkim at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: head/sys/x86/acpica/acpi_wakeup.c 237037 2012-06-13 22:53:56Z jkim $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/eventhandler.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/memrange.h>
+#include <sys/smp.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/clock.h>
+#include <machine/intr_machdep.h>
+#include <x86/mca.h>
+#include <machine/pcb.h>
+#include <machine/pmap.h>
+#include <machine/specialreg.h>
+#include <machine/md_var.h>
+
+#ifdef SMP
+#include <x86/apicreg.h>
+#include <machine/smp.h>
+#include <machine/vmparam.h>
+#endif
+
+#include <contrib/dev/acpica/include/acpi.h>
+
+#include <dev/acpica/acpivar.h>
+
+#include "acpi_wakecode.h"
+#include "acpi_wakedata.h"
+
+/* Make sure the code is less than a page and leave room for the stack. */
+CTASSERT(sizeof(wakecode) < PAGE_SIZE - 1024);
+
+extern int		acpi_resume_beep;
+extern int		acpi_reset_video;
+
+#ifdef SMP
+extern struct pcb	**susppcbs;
+static cpuset_t		suspcpus;
+#else
+static struct pcb	**susppcbs;
+#endif
+
+static void		*acpi_alloc_wakeup_handler(void);
+static void		acpi_stop_beep(void *);
+
+#ifdef SMP
+static int		acpi_wakeup_ap(struct acpi_softc *, int);
+static void		acpi_wakeup_cpus(struct acpi_softc *);
+#endif
+
+#ifdef __amd64__
+#define ACPI_PAGETABLES	3
+#else
+#define ACPI_PAGETABLES	0
+#endif
+
+#define	WAKECODE_VADDR(sc)				\
+    ((sc)->acpi_wakeaddr + (ACPI_PAGETABLES * PAGE_SIZE))
+#define	WAKECODE_PADDR(sc)				\
+    ((sc)->acpi_wakephys + (ACPI_PAGETABLES * PAGE_SIZE))
+#define	WAKECODE_FIXUP(offset, type, val)	do {	\
+	type	*addr;					\
+	addr = (type *)(WAKECODE_VADDR(sc) + offset);	\
+	*addr = val;					\
+} while (0)
+
+static void
+acpi_stop_beep(void *arg)
+{
+
+	if (acpi_resume_beep != 0)
+		timer_spkr_release();
+}
+
+#ifdef SMP
+static int
+acpi_wakeup_ap(struct acpi_softc *sc, int cpu)
+{
+	int		vector = (WAKECODE_PADDR(sc) >> 12) & 0xff;
+	int		apic_id = cpu_apic_ids[cpu];
+	int		ms;
+
+	WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[cpu]);
+	WAKECODE_FIXUP(wakeup_gdt, uint16_t, susppcbs[cpu]->pcb_gdt.rd_limit);
+	WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t,
+	    susppcbs[cpu]->pcb_gdt.rd_base);
+
+	ipi_startup(apic_id, vector);
+
+	/* Wait up to 5 seconds for it to resume. */
+	for (ms = 0; ms < 5000; ms++) {
+		if (!CPU_ISSET(cpu, &suspended_cpus))
+			return (1);	/* return SUCCESS */
+		DELAY(1000);
+	}
+	return (0);		/* return FAILURE */
+}
+
+#define	WARMBOOT_TARGET		0
+#define	WARMBOOT_OFF		(KERNBASE + 0x0467)
+#define	WARMBOOT_SEG		(KERNBASE + 0x0469)
+
+#define	CMOS_REG		(0x70)
+#define	CMOS_DATA		(0x71)
+#define	BIOS_RESET		(0x0f)
+#define	BIOS_WARM		(0x0a)
+
+static void
+acpi_wakeup_cpus(struct acpi_softc *sc)
+{
+	uint32_t	mpbioswarmvec;
+	int		cpu;
+	u_char		mpbiosreason;
+
+	/* save the current value of the warm-start vector */
+	mpbioswarmvec = *((uint32_t *)WARMBOOT_OFF);
+	outb(CMOS_REG, BIOS_RESET);
+	mpbiosreason = inb(CMOS_DATA);
+
+	/* setup a vector to our boot code */
+	*((volatile u_short *)WARMBOOT_OFF) = WARMBOOT_TARGET;
+	*((volatile u_short *)WARMBOOT_SEG) = WAKECODE_PADDR(sc) >> 4;
+	outb(CMOS_REG, BIOS_RESET);
+	outb(CMOS_DATA, BIOS_WARM);	/* 'warm-start' */
+
+	/* Wake up each AP. */
+	for (cpu = 1; cpu < mp_ncpus; cpu++) {
+		if (!CPU_ISSET(cpu, &suspcpus))
+			continue;
+		if (acpi_wakeup_ap(sc, cpu) == 0) {
+			/* restore the warmstart vector */
+			*(uint32_t *)WARMBOOT_OFF = mpbioswarmvec;
+			panic("acpi_wakeup: failed to resume AP #%d (PHY #%d)",
+			    cpu, cpu_apic_ids[cpu]);
+		}
+	}
+
+	/* restore the warmstart vector */
+	*(uint32_t *)WARMBOOT_OFF = mpbioswarmvec;
+
+	outb(CMOS_REG, BIOS_RESET);
+	outb(CMOS_DATA, mpbiosreason);
+}
+#endif
+
+int
+acpi_sleep_machdep(struct acpi_softc *sc, int state)
+{
+	ACPI_STATUS	status;
+
+	if (sc->acpi_wakeaddr == 0ul)
+		return (-1);	/* couldn't alloc wake memory */
+
+#ifdef SMP
+	suspcpus = all_cpus;
+	CPU_CLR(PCPU_GET(cpuid), &suspcpus);
+#endif
+
+	if (acpi_resume_beep != 0)
+		timer_spkr_acquire();
+
+	AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc));
+
+	intr_suspend();
+
+	if (savectx(susppcbs[0])) {
+#ifdef __amd64__
+		ctx_fpusave(susppcbs[0]->pcb_fpususpend);
+#endif
+#ifdef SMP
+		if (!CPU_EMPTY(&suspcpus) && suspend_cpus(suspcpus) == 0) {
+			device_printf(sc->acpi_dev, "Failed to suspend APs\n");
+			return (0);	/* couldn't sleep */
+		}
+#endif
+
+		WAKECODE_FIXUP(resume_beep, uint8_t, (acpi_resume_beep != 0));
+		WAKECODE_FIXUP(reset_video, uint8_t, (acpi_reset_video != 0));
+
+#ifndef __amd64__
+		WAKECODE_FIXUP(wakeup_cr4, register_t, susppcbs[0]->pcb_cr4);
+#endif
+		WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[0]);
+		WAKECODE_FIXUP(wakeup_gdt, uint16_t,
+		    susppcbs[0]->pcb_gdt.rd_limit);
+		WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t,
+		    susppcbs[0]->pcb_gdt.rd_base);
+
+		/* Call ACPICA to enter the desired sleep state */
+		if (state == ACPI_STATE_S4 && sc->acpi_s4bios)
+			status = AcpiEnterSleepStateS4bios();
+		else
+			status = AcpiEnterSleepState(state, acpi_sleep_flags);
+		if (ACPI_FAILURE(status)) {
+			device_printf(sc->acpi_dev,
+			    "AcpiEnterSleepState failed - %s\n",
+			    AcpiFormatException(status));
+			return (0);	/* couldn't sleep */
+		}
+
+		for (;;)
+			ia32_pause();
+	}
+
+	return (1);	/* wakeup successfully */
+}
+
+int
+acpi_wakeup_machdep(struct acpi_softc *sc, int state, int sleep_result,
+    int intr_enabled)
+{
+
+	if (sleep_result == -1)
+		return (sleep_result);
+
+	if (!intr_enabled) {
+		/* Wakeup MD procedures in interrupt disabled context */
+		if (sleep_result == 1) {
+			pmap_init_pat();
+			initializecpu();
+			PCPU_SET(switchtime, 0);
+			PCPU_SET(switchticks, ticks);
+#ifdef SMP
+			if (!CPU_EMPTY(&suspcpus))
+				acpi_wakeup_cpus(sc);
+#endif
+		}
+
+#ifdef SMP
+		if (!CPU_EMPTY(&suspcpus))
+			restart_cpus(suspcpus);
+#endif
+		mca_resume();
+		intr_resume();
+
+		AcpiSetFirmwareWakingVector(0);
+	} else {
+		/* Wakeup MD procedures in interrupt enabled context */
+		if (sleep_result == 1 && mem_range_softc.mr_op != NULL &&
+		    mem_range_softc.mr_op->reinit != NULL)
+			mem_range_softc.mr_op->reinit(&mem_range_softc);
+	}
+
+	return (sleep_result);
+}
+
+static void *
+acpi_alloc_wakeup_handler(void)
+{
+	void		*wakeaddr;
+	int		i;
+
+	/*
+	 * Specify the region for our wakeup code.  We want it in the low 1 MB
+	 * region, excluding real mode IVT (0-0x3ff), BDA (0x400-0x4ff), EBDA
+	 * (less than 128KB, below 0xa0000, must be excluded by SMAP and DSDT),
+	 * and ROM area (0xa0000 and above).  The temporary page tables must be
+	 * page-aligned.
+	 */
+	wakeaddr = contigmalloc((ACPI_PAGETABLES + 1) * PAGE_SIZE, M_DEVBUF,
+	    M_WAITOK, 0x500, 0xa0000, PAGE_SIZE, 0ul);
+	if (wakeaddr == NULL) {
+		printf("%s: can't alloc wake memory\n", __func__);
+		return (NULL);
+	}
+	if (EVENTHANDLER_REGISTER(power_resume, acpi_stop_beep, NULL,
+	    EVENTHANDLER_PRI_LAST) == NULL) {
+		printf("%s: can't register event handler\n", __func__);
+		contigfree(wakeaddr, (ACPI_PAGETABLES + 1) * PAGE_SIZE,
+		    M_DEVBUF);
+		return (NULL);
+	}
+	susppcbs = malloc(mp_ncpus * sizeof(*susppcbs), M_DEVBUF, M_WAITOK);
+	for (i = 0; i < mp_ncpus; i++) {
+		susppcbs[i] = malloc(sizeof(**susppcbs), M_DEVBUF, M_WAITOK);
+#ifdef __amd64__
+		susppcbs[i]->pcb_fpususpend = alloc_fpusave(M_WAITOK);
+#endif
+	}
+
+	return (wakeaddr);
+}
+
+void
+acpi_install_wakeup_handler(struct acpi_softc *sc)
+{
+	static void	*wakeaddr = NULL;
+#ifdef __amd64__
+	uint64_t	*pt4, *pt3, *pt2;
+	int		i;
+#endif
+
+	if (wakeaddr != NULL)
+		return;
+
+	wakeaddr = acpi_alloc_wakeup_handler();
+	if (wakeaddr == NULL)
+		return;
+
+	sc->acpi_wakeaddr = (vm_offset_t)wakeaddr;
+	sc->acpi_wakephys = vtophys(wakeaddr);
+
+	bcopy(wakecode, (void *)WAKECODE_VADDR(sc), sizeof(wakecode));
+
+	/* Patch GDT base address, ljmp targets. */
+	WAKECODE_FIXUP((bootgdtdesc + 2), uint32_t,
+	    WAKECODE_PADDR(sc) + bootgdt);
+	WAKECODE_FIXUP((wakeup_sw32 + 2), uint32_t,
+	    WAKECODE_PADDR(sc) + wakeup_32);
+#ifdef __amd64__
+	WAKECODE_FIXUP((wakeup_sw64 + 1), uint32_t,
+	    WAKECODE_PADDR(sc) + wakeup_64);
+	WAKECODE_FIXUP(wakeup_pagetables, uint32_t, sc->acpi_wakephys);
+#endif
+
+	/* Save pointers to some global data. */
+	WAKECODE_FIXUP(wakeup_ret, void *, resumectx);
+#ifndef __amd64__
+#ifdef PAE
+	WAKECODE_FIXUP(wakeup_cr3, register_t, vtophys(kernel_pmap->pm_pdpt));
+#else
+	WAKECODE_FIXUP(wakeup_cr3, register_t, vtophys(kernel_pmap->pm_pdir));
+#endif
+
+#else
+	/* Build temporary page tables below realmode code. */
+	pt4 = wakeaddr;
+	pt3 = pt4 + (PAGE_SIZE) / sizeof(uint64_t);
+	pt2 = pt3 + (PAGE_SIZE) / sizeof(uint64_t);
+
+	/* Create the initial 1GB replicated page tables */
+	for (i = 0; i < 512; i++) {
+		/*
+		 * Each slot of the level 4 pages points
+		 * to the same level 3 page
+		 */
+		pt4[i] = (uint64_t)(sc->acpi_wakephys + PAGE_SIZE);
+		pt4[i] |= PG_V | PG_RW | PG_U;
+
+		/*
+		 * Each slot of the level 3 pages points
+		 * to the same level 2 page
+		 */
+		pt3[i] = (uint64_t)(sc->acpi_wakephys + (2 * PAGE_SIZE));
+		pt3[i] |= PG_V | PG_RW | PG_U;
+
+		/* The level 2 page slots are mapped with 2MB pages for 1GB. */
+		pt2[i] = i * (2 * 1024 * 1024);
+		pt2[i] |= PG_V | PG_RW | PG_PS | PG_U;
+	}
+#endif
+
+	if (bootverbose)
+		device_printf(sc->acpi_dev, "wakeup code va %#jx pa %#jx\n",
+		    (uintmax_t)sc->acpi_wakeaddr, (uintmax_t)sc->acpi_wakephys);
+}
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/include/_limits.h
--- a/head/sys/x86/include/_limits.h	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/include/_limits.h	Wed Jul 25 16:42:35 2012 +0300
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)limits.h	8.3 (Berkeley) 1/4/94
- * $FreeBSD: head/sys/x86/include/_limits.h 232262 2012-02-28 18:24:28Z tijl $
+ * $FreeBSD: head/sys/x86/include/_limits.h 235939 2012-05-24 21:44:46Z obrien $
  */
 
 #ifndef	_MACHINE__LIMITS_H_
@@ -57,7 +57,7 @@
 #define	__INT_MAX	0x7fffffff	/* max value for an int */
 #define	__INT_MIN	(-0x7fffffff - 1)	/* min value for an int */
 
-#ifdef	_LP64
+#ifdef	__LP64__
 #define	__ULONG_MAX	0xffffffffffffffff	/* max for an unsigned long */
 #define	__LONG_MAX	0x7fffffffffffffff	/* max for a long */
 #define	__LONG_MIN	(-0x7fffffffffffffff - 1) /* min for a long */
@@ -72,7 +72,7 @@
 #define	__LLONG_MAX	0x7fffffffffffffffLL	/* max value for a long long */
 #define	__LLONG_MIN	(-0x7fffffffffffffffLL - 1)  /* min for a long long */
 
-#ifdef	_LP64
+#ifdef	__LP64__
 #define	__SSIZE_MAX	__LONG_MAX	/* max value for a ssize_t */
 #define	__SIZE_T_MAX	__ULONG_MAX	/* max value for a size_t */
 #define	__OFF_MAX	__LONG_MAX	/* max value for an off_t */
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/include/_stdint.h
--- a/head/sys/x86/include/_stdint.h	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/include/_stdint.h	Wed Jul 25 16:42:35 2012 +0300
@@ -34,7 +34,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/sys/x86/include/_stdint.h 232519 2012-03-04 20:02:20Z tijl $
+ * $FreeBSD: head/sys/x86/include/_stdint.h 237517 2012-06-24 04:15:58Z andrew $
  */
 
 #ifndef _MACHINE__STDINT_H_
@@ -50,7 +50,7 @@
 #define	UINT16_C(c)		(c)
 #define	UINT32_C(c)		(c ## U)
 
-#ifdef	_LP64
+#ifdef	__LP64__
 #define	INT64_C(c)		(c ## L)
 #define	UINT64_C(c)		(c ## UL)
 #else
@@ -81,7 +81,7 @@
 #define	UINT16_MAX	0xffff
 #define	UINT32_MAX	0xffffffffU
 
-#ifdef _LP64
+#ifdef __LP64__
 #define	INT64_MIN	(-0x7fffffffffffffff-1)
 #define	INT64_MAX	0x7fffffffffffffff
 #define	UINT64_MAX	0xffffffffffffffff
@@ -139,7 +139,7 @@
  * ISO/IEC 9899:1999
  * 7.18.2.4  Limits of integer types capable of holding object pointers
  */
-#ifdef	_LP64
+#ifdef	__LP64__
 #define	INTPTR_MIN	INT64_MIN
 #define	INTPTR_MAX	INT64_MAX
 #define	UINTPTR_MAX	UINT64_MAX
@@ -161,7 +161,7 @@
  * ISO/IEC 9899:1999
  * 7.18.3  Limits of other integer types
  */
-#ifdef	_LP64
+#ifdef	__LP64__
 /* Limits of ptrdiff_t. */
 #define	PTRDIFF_MIN	INT64_MIN	
 #define	PTRDIFF_MAX	INT64_MAX
@@ -180,12 +180,6 @@
 #define	SIZE_MAX	UINT32_MAX
 #endif
 
-#ifndef WCHAR_MIN /* Also possibly defined in <wchar.h> */
-/* Limits of wchar_t. */
-#define	WCHAR_MIN	INT32_MIN
-#define	WCHAR_MAX	INT32_MAX
-#endif
-
 /* Limits of wint_t. */
 #define	WINT_MIN	INT32_MIN
 #define	WINT_MAX	INT32_MAX
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/include/_types.h
--- a/head/sys/x86/include/_types.h	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/include/_types.h	Wed Jul 25 16:42:35 2012 +0300
@@ -33,7 +33,7 @@
  *
  *	From: @(#)ansi.h	8.2 (Berkeley) 1/4/94
  *	From: @(#)types.h	8.3 (Berkeley) 1/5/94
- * $FreeBSD: head/sys/x86/include/_types.h 232261 2012-02-28 18:15:28Z tijl $
+ * $FreeBSD: head/sys/x86/include/_types.h 237517 2012-06-24 04:15:58Z andrew $
  */
 
 #ifndef _MACHINE__TYPES_H_
@@ -54,7 +54,7 @@
 typedef	unsigned short		__uint16_t;
 typedef	int			__int32_t;
 typedef	unsigned int		__uint32_t;
-#ifdef	_LP64
+#ifdef	__LP64__
 typedef	long			__int64_t;
 typedef	unsigned long		__uint64_t;
 #else
@@ -73,7 +73,7 @@
 /*
  * Standard type definitions.
  */
-#ifdef	_LP64
+#ifdef	__LP64__
 typedef	__int32_t	__clock_t;		/* clock()... */
 typedef	__int64_t	__critical_t;
 typedef	double		__double_t;
@@ -97,7 +97,7 @@
 typedef	__int16_t	__int_least16_t;
 typedef	__int32_t	__int_least32_t;
 typedef	__int64_t	__int_least64_t;
-#ifdef	_LP64
+#ifdef	__LP64__
 typedef	__int64_t	__ptrdiff_t;		/* ptr1 - ptr2 */
 typedef	__int64_t	__register_t;
 typedef	__int64_t	__segsz_t;		/* segment size (in pages) */
@@ -125,7 +125,7 @@
 typedef	__uint16_t	__uint_least16_t;
 typedef	__uint32_t	__uint_least32_t;
 typedef	__uint64_t	__uint_least64_t;
-#ifdef	_LP64
+#ifdef	__LP64__
 typedef	__uint64_t	__u_register_t;
 typedef	__uint64_t	__vm_offset_t;
 typedef	__uint64_t	__vm_paddr_t;
@@ -142,6 +142,10 @@
 #endif
 typedef	__int64_t	__vm_ooffset_t;
 typedef	__uint64_t	__vm_pindex_t;
+typedef	int		__wchar_t;
+
+#define	__WCHAR_MIN	__INT_MIN	/* min value for a wchar_t */
+#define	__WCHAR_MAX	__INT_MAX	/* max value for a wchar_t */
 
 /*
  * Unusual type definitions.
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/include/float.h
--- a/head/sys/x86/include/float.h	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/include/float.h	Wed Jul 25 16:42:35 2012 +0300
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)float.h	7.1 (Berkeley) 5/8/90
- * $FreeBSD: head/sys/x86/include/float.h 232491 2012-03-04 14:00:32Z tijl $
+ * $FreeBSD: head/sys/x86/include/float.h 235939 2012-05-24 21:44:46Z obrien $
  */
 
 #ifndef _MACHINE_FLOAT_H_
@@ -42,7 +42,7 @@
 #define FLT_RADIX	2		/* b */
 #define FLT_ROUNDS	__flt_rounds()
 #if __ISO_C_VISIBLE >= 1999
-#ifdef _LP64
+#ifdef __LP64__
 #define	FLT_EVAL_METHOD	0		/* no promotions */
 #else
 #define	FLT_EVAL_METHOD	(-1)		/* i387 semantics are...interesting */
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/include/ptrace.h
--- a/head/sys/x86/include/ptrace.h	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/include/ptrace.h	Wed Jul 25 16:42:35 2012 +0300
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ptrace.h	8.1 (Berkeley) 6/11/93
- * $FreeBSD: head/sys/x86/include/ptrace.h 232520 2012-03-04 20:24:28Z tijl $
+ * $FreeBSD: head/sys/x86/include/ptrace.h 235563 2012-05-17 20:21:55Z jhb $
  */
 
 #ifndef _MACHINE_PTRACE_H_
@@ -40,8 +40,10 @@
  * PT_GETXSTATE and PT_SETXSTATE.  They should not be (re)used.
  */
 
-#define	PT_GETXMMREGS	(PT_FIRSTMACH + 0)	/* i386 only */
-#define	PT_SETXMMREGS	(PT_FIRSTMACH + 1)	/* i386 only */
+#ifdef __i386__
+#define	PT_GETXMMREGS	(PT_FIRSTMACH + 0)
+#define	PT_SETXMMREGS	(PT_FIRSTMACH + 1)
+#endif
 #define	PT_GETXSTATE	(PT_FIRSTMACH + 2)
 #define	PT_SETXSTATE	(PT_FIRSTMACH + 3)
 
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/include/specialreg.h
--- a/head/sys/x86/include/specialreg.h	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/include/specialreg.h	Wed Jul 25 16:42:35 2012 +0300
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)specialreg.h	7.1 (Berkeley) 5/9/91
- * $FreeBSD: head/sys/x86/include/specialreg.h 234364 2012-04-17 00:54:38Z grehan $
+ * $FreeBSD: head/sys/x86/include/specialreg.h 238450 2012-07-14 15:48:30Z kib $
  */
 
 #ifndef _MACHINE_SPECIALREG_H_
@@ -247,6 +247,11 @@
 #define	CPUID_TYPE_CORE		2
 
 /*
+ * CPUID instruction 0xd Processor Extended State Enumeration Sub-leaf 1
+ */
+#define	CPUID_EXTSTATE_XSAVEOPT	0x00000001
+
+/*
  * AMD extended function 8000_0007h edx info
  */
 #define	AMDPM_TS		0x00000001
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/include/vdso.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/x86/include/vdso.h	Wed Jul 25 16:42:35 2012 +0300
@@ -0,0 +1,42 @@
+/*-
+ * Copyright 2012 Konstantin Belousov <kib at FreeBSD.ORG>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: head/sys/x86/include/vdso.h 237433 2012-06-22 07:06:40Z kib $
+ */
+
+#ifndef _X86_VDSO_H
+#define	_X86_VDSO_H
+
+#define	VDSO_TIMEHANDS_MD			\
+	uint32_t	th_x86_shift;		\
+	uint32_t	th_res[7];
+
+#ifdef _KERNEL
+#ifdef COMPAT_FREEBSD32
+
+#define	VDSO_TIMEHANDS_MD32	VDSO_TIMEHANDS_MD
+
+#endif
+#endif
+#endif
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/x86/dump_machdep.c
--- a/head/sys/x86/x86/dump_machdep.c	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/x86/dump_machdep.c	Wed Jul 25 16:42:35 2012 +0300
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/x86/x86/dump_machdep.c 221173 2011-04-28 16:02:05Z attilio $");
+__FBSDID("$FreeBSD: head/sys/x86/x86/dump_machdep.c 236503 2012-06-03 08:01:12Z avg $");
 
 #include "opt_watchdog.h"
 
@@ -36,9 +36,7 @@
 #include <sys/sysctl.h>
 #include <sys/kernel.h>
 #include <sys/kerneldump.h>
-#ifdef SW_WATCHDOG
 #include <sys/watchdog.h>
-#endif
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <machine/elf.h>
@@ -198,9 +196,9 @@
 			a = pa + i * PAGE_SIZE;
 			va = pmap_kenter_temporary(trunc_page(a), i);
 		}
-#ifdef SW_WATCHDOG
+
 		wdog_kern_pat(WD_LASTVAL);
-#endif
+
 		error = dump_write(di, va, 0, dumplo, sz);
 		if (error)
 			break;
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/x86/intr_machdep.c
--- a/head/sys/x86/x86/intr_machdep.c	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/x86/intr_machdep.c	Wed Jul 25 16:42:35 2012 +0300
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sys/x86/x86/intr_machdep.c 233961 2012-04-06 21:19:28Z gibbs $
+ * $FreeBSD: head/sys/x86/x86/intr_machdep.c 234989 2012-05-03 21:44:01Z attilio $
  */
 
 /*
@@ -565,4 +565,11 @@
 
 	return (PCPU_GET(apic_id));
 }
+
+/* Use an empty stub for compatibility. */
+void
+intr_add_cpu(u_int cpu __unused)
+{
+
+}
 #endif
diff -r d36a04c5f34a -r 99650cb861f2 head/sys/x86/x86/tsc.c
--- a/head/sys/x86/x86/tsc.c	Wed Jul 25 16:42:12 2012 +0300
+++ b/head/sys/x86/x86/tsc.c	Wed Jul 25 16:42:35 2012 +0300
@@ -25,8 +25,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/x86/x86/tsc.c 225069 2011-08-22 03:10:29Z silby $");
+__FBSDID("$FreeBSD: head/sys/x86/x86/tsc.c 238755 2012-07-24 22:10:11Z jimharris $");
 
+#include "opt_compat.h"
 #include "opt_clock.h"
 
 #include <sys/param.h>
@@ -41,6 +42,7 @@
 #include <sys/kernel.h>
 #include <sys/power.h>
 #include <sys/smp.h>
+#include <sys/vdso.h>
 #include <machine/clock.h>
 #include <machine/cputypes.h>
 #include <machine/md_var.h>
@@ -326,6 +328,7 @@
 
 #ifdef SMP
 
+/* rmb is required here because rdtsc is not a serializing instruction. */
 #define	TSC_READ(x)			\
 static void				\
 tsc_read_##x(void *arg)			\
@@ -333,6 +336,7 @@
 	uint32_t *tsc = arg;		\
 	u_int cpu = PCPU_GET(cpuid);	\
 					\
+	rmb();				\
 	tsc[cpu * 3 + x] = rdtsc32();	\
 }
 TSC_READ(0)
@@ -604,3 +608,23 @@
 	: "=a" (rv) : "c" ((int)(intptr_t)tc->tc_priv) : "edx");
 	return (rv);
 }
+
+uint32_t
+cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th)
+{
+
+	vdso_th->th_x86_shift = (int)(intptr_t)timecounter->tc_priv;
+	bzero(vdso_th->th_res, sizeof(vdso_th->th_res));
+	return (timecounter == &tsc_timecounter);
+}
+
+#ifdef COMPAT_FREEBSD32
+uint32_t
+cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32)
+{
+
+	vdso_th32->th_x86_shift = (int)(intptr_t)timecounter->tc_priv;
+	bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res));
+	return (timecounter == &tsc_timecounter);
+}
+#endif


More information about the Zrouter-src-freebsd mailing list