PERFORCE change 50721 for review
Warner Losh
imp at FreeBSD.org
Fri Apr 9 09:41:50 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=50721
Change 50721 by imp at imp_pacopaco on 2004/04/09 09:41:42
IFC @50716
Affected files ...
.. //depot/projects/power/sys/conf/files#9 integrate
.. //depot/projects/power/sys/dev/acpica/acpi.c#17 integrate
.. //depot/projects/power/sys/dev/acpica/acpi_package.c#3 integrate
.. //depot/projects/power/sys/dev/acpica/acpi_pci.c#11 integrate
.. //depot/projects/power/sys/dev/acpica/acpi_pcib_acpi.c#3 integrate
.. //depot/projects/power/sys/dev/acpica/acpi_powerres.c#3 integrate
.. //depot/projects/power/sys/dev/acpica/acpi_thermal.c#6 integrate
.. //depot/projects/power/sys/dev/acpica/acpivar.h#10 integrate
.. //depot/projects/power/sys/dev/md/md.c#9 integrate
.. //depot/projects/power/sys/dev/pci/pci.c#10 integrate
.. //depot/projects/power/sys/dev/pci/pci_pci.c#8 integrate
.. //depot/projects/power/sys/dev/pci/pci_private.h#6 integrate
.. //depot/projects/power/sys/dev/random/harvest.c#4 integrate
.. //depot/projects/power/sys/dev/random/hash.c#3 integrate
.. //depot/projects/power/sys/dev/random/hash.h#2 integrate
.. //depot/projects/power/sys/dev/random/nehemiah.c#1 branch
.. //depot/projects/power/sys/dev/random/nehemiah.h#1 branch
.. //depot/projects/power/sys/dev/random/probe.c#1 branch
.. //depot/projects/power/sys/dev/random/randomdev.c#4 integrate
.. //depot/projects/power/sys/dev/random/randomdev.h#3 integrate
.. //depot/projects/power/sys/dev/random/randomdev_soft.c#1 branch
.. //depot/projects/power/sys/dev/random/randomdev_soft.h#1 branch
.. //depot/projects/power/sys/dev/random/yarrow.c#3 integrate
.. //depot/projects/power/sys/dev/random/yarrow.h#2 integrate
.. //depot/projects/power/sys/i386/i386/identcpu.c#5 integrate
.. //depot/projects/power/sys/kern/kern_linker.c#4 integrate
.. //depot/projects/power/sys/kern/sched_ule.c#8 integrate
.. //depot/projects/power/sys/kern/uipc_socket.c#9 integrate
.. //depot/projects/power/sys/modules/random/Makefile#2 integrate
.. //depot/projects/power/sys/sys/wait.h#4 integrate
Differences ...
==== //depot/projects/power/sys/conf/files#9 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.882 2004/04/08 18:17:13 mlaier Exp $
+# $FreeBSD: src/sys/conf/files,v 1.883 2004/04/09 15:47:10 markm Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -608,6 +608,9 @@
dev/puc/pucdata.c optional puc pci
dev/random/harvest.c standard
dev/random/randomdev.c optional random
+dev/random/randomdev_soft.c optional random
+dev/random/nehemiah.c optional random
+dev/random/probe.c optional random
dev/random/yarrow.c optional random
dev/random/hash.c optional random
crypto/rijndael/rijndael-alg-fst.c optional random
==== //depot/projects/power/sys/dev/acpica/acpi.c#17 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.135 2004/04/08 16:45:12 njl Exp $
+ * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.136 2004/04/09 06:40:03 njl Exp $
*/
#include "opt_acpi.h"
@@ -1993,9 +1993,11 @@
acpi_device_enable_wake_event(ACPI_HANDLE h)
{
struct acpi_softc *sc;
+ uint32_t gpe_bit, lowest_wake;
+ ACPI_HANDLE handle;
ACPI_STATUS status;
ACPI_BUFFER prw_buffer;
- ACPI_OBJECT *res;
+ ACPI_OBJECT *res, *res2;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -2004,67 +2006,72 @@
return;
/*
- * _PRW object is only required for devices that have the ability
- * to wake the system from a system sleeping state.
+ * The _PRW object (7.2.9) is only required for devices that have the
+ * ability to wake the system from a sleeping state.
*/
+ prw_buffer.Pointer = NULL;
prw_buffer.Length = ACPI_ALLOCATE_BUFFER;
status = AcpiEvaluateObject(h, "_PRW", NULL, &prw_buffer);
if (ACPI_FAILURE(status))
return;
-
res = (ACPI_OBJECT *)prw_buffer.Pointer;
if (res == NULL)
return;
-
- if ((res->Type != ACPI_TYPE_PACKAGE) || (res->Package.Count < 2)) {
+ if (!ACPI_PKG_VALID(res, 2))
goto out;
- }
/*
- * The element 1 of the _PRW object:
- * The lowest power system sleeping state that can be entered
- * while still providing wake functionality.
- * The sleeping state being entered must be greater or equal to
- * the power state declared in element 1 of the _PRW object.
+ * Element 1 of the _PRW object:
+ * The lowest power system sleeping state that can be entered while still
+ * providing wake functionality. The sleeping state being entered must
+ * be less than (i.e., higher power) or equal to this value.
*/
- if (res->Package.Elements[1].Type != ACPI_TYPE_INTEGER)
+ if (acpi_PkgInt32(res, 1, &lowest_wake) != 0)
goto out;
-
- if (sc->acpi_sstate > res->Package.Elements[1].Integer.Value)
+ if (sc->acpi_sstate > lowest_wake)
goto out;
/*
- * The element 0 of the _PRW object:
+ * Element 0 of the _PRW object:
*/
- switch(res->Package.Elements[0].Type) {
+ switch (res->Package.Elements[0].Type) {
case ACPI_TYPE_INTEGER:
- /*
+ /*
* If the data type of this package element is numeric, then this
* _PRW package element is the bit index in the GPEx_EN, in the
* GPE blocks described in the FADT, of the enable bit that is
* enabled for the wake event.
*/
-
- status = AcpiEnableGpe(NULL, res->Package.Elements[0].Integer.Value,
- ACPI_EVENT_WAKE_ENABLE);
+ gpe_bit = res->Package.Elements[0].Integer.Value;
+ status = AcpiEnableGpe(NULL, gpe_bit, ACPI_EVENT_WAKE_ENABLE);
if (ACPI_FAILURE(status))
- printf("%s: EnableEvent Failed\n", __func__);
+ printf("wake enable: AcpiEnableGpe failed for %u\n",
+ gpe_bit);
break;
case ACPI_TYPE_PACKAGE:
/*
- * XXX TBD
- *
* If the data type of this package element is a package, then this
* _PRW package element is itself a package containing two
- * elements. The first is an object reference to the GPE Block
+ * elements. The first is an object reference to the GPE Block
* device that contains the GPE that will be triggered by the wake
- * event. The second element is numeric and it contains the bit
+ * event. The second element is numeric and it contains the bit
* index in the GPEx_EN, in the GPE Block referenced by the
* first element in the package, of the enable bit that is enabled for
* the wake event.
+ *
* For example, if this field is a package then it is of the form:
* Package() {\_SB.PCI0.ISA.GPE, 2}
*/
+ res2 = &res->Package.Elements[0];
+ if (!ACPI_PKG_VALID(res2, 2))
+ goto out;
+ handle = acpi_GetReference(NULL, &res2->Package.Elements[0]);
+ if (handle == NULL || acpi_PkgInt32(res2, 1, &gpe_bit) != 0)
+ goto out;
+ status = AcpiEnableGpe(handle, gpe_bit, ACPI_EVENT_WAKE_ENABLE);
+ if (ACPI_FAILURE(status))
+ printf("wake enable: AcpiEnableGpe (package) failed for %u\n",
+ gpe_bit);
break;
default:
break;
==== //depot/projects/power/sys/dev/acpica/acpi_package.c#3 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/acpica/acpi_package.c,v 1.2 2003/12/23 18:26:53 njl Exp $
+ * $FreeBSD: src/sys/dev/acpica/acpi_package.c,v 1.3 2004/04/09 06:40:03 njl Exp $
*/
#include <sys/param.h>
@@ -123,3 +123,34 @@
return (0);
}
+
+ACPI_HANDLE
+acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj)
+{
+ ACPI_HANDLE h;
+
+ if (obj == NULL)
+ return (NULL);
+
+ switch (obj->Type) {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ case ACPI_TYPE_ANY:
+ h = obj->Reference.Handle;
+ break;
+ case ACPI_TYPE_STRING:
+ /*
+ * The String object usually contains a fully-qualified path, so
+ * scope can be NULL.
+ *
+ * XXX This may not always be the case.
+ */
+ if (ACPI_FAILURE(AcpiGetHandle(scope, obj->String.Pointer, &h)))
+ h = NULL;
+ break;
+ default:
+ h = NULL;
+ break;
+ }
+
+ return (h);
+}
==== //depot/projects/power/sys/dev/acpica/acpi_pci.c#11 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.10 2004/04/07 19:42:21 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.11 2004/04/09 15:44:34 imp Exp $");
#include "opt_bus.h"
@@ -87,7 +87,7 @@
DEVMETHOD(bus_probe_nomatch, pci_probe_nomatch),
DEVMETHOD(bus_read_ivar, acpi_pci_read_ivar),
DEVMETHOD(bus_write_ivar, pci_write_ivar),
- DEVMETHOD(bus_driver_added, bus_generic_driver_added),
+ DEVMETHOD(bus_driver_added, pci_driver_added),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
==== //depot/projects/power/sys/dev/acpica/acpi_pcib_acpi.c#3 (text+ko) ====
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/acpica/acpi_pcib_acpi.c,v 1.30 2004/03/03 18:34:42 njl Exp $
+ * $FreeBSD: src/sys/dev/acpica/acpi_pcib_acpi.c,v 1.31 2004/04/09 15:44:34 imp Exp $
*/
#include "opt_acpi.h"
#include <sys/param.h>
@@ -70,6 +70,10 @@
u_int32_t data, int bytes);
static int acpi_pcib_acpi_route_interrupt(device_t pcib,
device_t dev, int pin);
+static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev,
+ device_t child, int type, int *rid,
+ u_long start, u_long end, u_long count,
+ u_int flags);
static device_method_t acpi_pcib_acpi_methods[] = {
/* Device interface */
@@ -83,7 +87,7 @@
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar),
DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
@@ -289,3 +293,20 @@
sc = device_get_softc(pcib);
return (acpi_pcib_route_interrupt(pcib, dev, pin, &sc->ap_prt));
}
+
+struct resource *
+acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid,
+ u_long start, u_long end, u_long count, u_int flags)
+{
+ /*
+ * If no memory preference is given, use upper 256MB slot most
+ * bioses use for their memory window. Typically other bridges
+ * before us get in the way to assert their preferences on memory.
+ * Hardcoding like this sucks, so a more MD/MI way needs to be
+ * found to do it.
+ */
+ if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL)
+ start = 0xf0000000;
+ return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
+ count, flags));
+}
==== //depot/projects/power/sys/dev/acpica/acpi_powerres.c#3 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_powerres.c,v 1.19 2004/03/03 18:34:42 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_powerres.c,v 1.20 2004/04/09 06:55:50 njl Exp $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -488,30 +488,10 @@
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
- /* check the object type */
- switch (obj->Type) {
- case ACPI_TYPE_ANY:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "building reference from %s to %s\n",
- acpi_name(pc->ac_consumer),
- acpi_name(obj->Reference.Handle)));
- res = obj->Reference.Handle;
- break;
- case ACPI_TYPE_STRING:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "building reference from %s to %s\n",
- acpi_name(pc->ac_consumer), obj->String.Pointer));
-
- /* Get the handle of the resource */
- status = AcpiGetHandle(NULL, obj->String.Pointer, &res);
- if (ACPI_FAILURE(status)) {
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
- "couldn't find power resource %s\n",
- obj->String.Pointer));
- return_VOID;
- }
- break;
- default:
+ res = acpi_GetReference(NULL, obj);
+ if (res == NULL) {
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
- "can't create a power reference for object type %d\n",
+ "can't create a power reference for object type %d\n",
obj->Type));
return_VOID;
}
==== //depot/projects/power/sys/dev/acpica/acpi_thermal.c#6 (text+ko) ====
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_thermal.c,v 1.40 2004/03/05 18:06:31 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_thermal.c,v 1.41 2004/04/09 06:55:50 njl Exp $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -550,38 +550,27 @@
static void
acpi_tz_switch_cooler_off(ACPI_OBJECT *obj, void *arg)
{
- ACPI_HANDLE cooler;
+ struct acpi_tz_softc *sc = (struct acpi_tz_softc *)arg;
+ ACPI_HANDLE cooler;
+ ACPI_STATUS status;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
ACPI_ASSERTLOCK;
- switch(obj->Type) {
- case ACPI_TYPE_ANY:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s off\n",
- acpi_name(obj->Reference.Handle)));
+ cooler = acpi_GetReference(NULL, obj);
+ if (cooler == NULL) {
+ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get handle\n"));
+ return_VOID;
+ }
- acpi_pwr_switch_consumer(obj->Reference.Handle, ACPI_STATE_D3);
- break;
- case ACPI_TYPE_STRING:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s off\n",
- obj->String.Pointer));
-
- /*
- * Find the handle for the device and turn it off.
- * The String object here seems to contain a fully-qualified path, so we
- * don't have to search for it in our parents.
- *
- * XXX This may not always be the case.
- */
- if (ACPI_SUCCESS(AcpiGetHandle(NULL, obj->String.Pointer, &cooler)))
- acpi_pwr_switch_consumer(cooler, ACPI_STATE_D3);
- break;
- default:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
- "called to handle unsupported object type %d\n",
- obj->Type));
- break;
+ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s off\n",
+ acpi_name(cooler)));
+ status = acpi_pwr_switch_consumer(cooler, ACPI_STATE_D3);
+ if (ACPI_FAILURE(status)) {
+ ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
+ "failed to deactivate %s - %s\n", acpi_name(cooler),
+ AcpiFormatException(status));
}
return_VOID;
@@ -591,7 +580,7 @@
* Given an object, verify that it's a reference to a device of some sort,
* and try to switch it on.
*
- * XXX replication of off/on function code is bad, mmmkay?
+ * XXX replication of off/on function code is bad.
*/
static void
acpi_tz_switch_cooler_on(ACPI_OBJECT *obj, void *arg)
@@ -604,47 +593,19 @@
ACPI_ASSERTLOCK;
- switch(obj->Type) {
- case ACPI_TYPE_ANY:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s on\n",
- acpi_name(obj->Reference.Handle)));
+ cooler = acpi_GetReference(NULL, obj);
+ if (cooler == NULL) {
+ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get handle\n"));
+ return_VOID;
+ }
- status = acpi_pwr_switch_consumer(obj->Reference.Handle, ACPI_STATE_D0);
- if (ACPI_FAILURE(status)) {
- ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
- "failed to activate %s - %s\n",
- acpi_name(obj->Reference.Handle),
- AcpiFormatException(status));
- }
- break;
- case ACPI_TYPE_STRING:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s on\n",
- obj->String.Pointer));
-
- /*
- * Find the handle for the device and turn it off.
- * The String object here seems to contain a fully-qualified path, so we
- * don't have to search for it in our parents.
- *
- * XXX This may not always be the case.
- */
- if (ACPI_SUCCESS(AcpiGetHandle(NULL, obj->String.Pointer, &cooler))) {
- status = acpi_pwr_switch_consumer(cooler, ACPI_STATE_D0);
- if (ACPI_FAILURE(status)) {
- ACPI_VPRINT(sc->tz_dev,
- acpi_device_get_parent_softc(sc->tz_dev),
- "failed to activate %s - %s\n",
- obj->String.Pointer, AcpiFormatException(status));
- }
- } else {
- ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
- "couldn't find %s\n", obj->String.Pointer);
- }
- break;
- default:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "unsupported object type %d\n",
- obj->Type));
- break;
+ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s on\n",
+ acpi_name(cooler)));
+ status = acpi_pwr_switch_consumer(cooler, ACPI_STATE_D0);
+ if (ACPI_FAILURE(status)) {
+ ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
+ "failed to activate %s - %s\n", acpi_name(cooler),
+ AcpiFormatException(status));
}
return_VOID;
==== //depot/projects/power/sys/dev/acpica/acpivar.h#10 (text+ko) ====
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.59 2004/04/01 04:21:33 njl Exp $
+ * $FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.60 2004/04/09 06:53:50 njl Exp $
*/
#include "bus_if.h"
@@ -361,6 +361,7 @@
int acpi_PkgStr(ACPI_OBJECT *res, int idx, void *dst, size_t size);
int acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *rid,
struct resource **dst);
+ACPI_HANDLE acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj);
#if __FreeBSD_version >= 500000
#ifndef ACPI_MAX_THREADS
==== //depot/projects/power/sys/dev/md/md.c#9 (text+ko) ====
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $FreeBSD: src/sys/dev/md/md.c,v 1.121 2004/04/07 20:45:57 imp Exp $
+ * $FreeBSD: src/sys/dev/md/md.c,v 1.122 2004/04/09 05:12:47 imp Exp $
*
*/
@@ -19,6 +19,10 @@
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
==== //depot/projects/power/sys/dev/pci/pci.c#10 (text+ko) ====
@@ -25,7 +25,7 @@
* (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: src/sys/dev/pci/pci.c,v 1.237 2003/12/24 02:01:22 imp Exp $
+ * $FreeBSD: src/sys/dev/pci/pci.c,v 1.238 2004/04/09 15:44:33 imp Exp $
*
*/
==== //depot/projects/power/sys/dev/pci/pci_pci.c#8 (text+ko) ====
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.30 2004/01/17 21:54:04 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.31 2004/04/09 15:44:34 imp Exp $");
/*
* PCI:PCI bridge support.
@@ -321,7 +321,7 @@
}
} else {
ok = 1;
-#if 0
+#if 1
if (start < sc->iobase && end > sc->iolimit) {
start = sc->iobase;
end = sc->iolimit;
@@ -377,7 +377,7 @@
}
} else if (!ok) {
ok = 1; /* subtractive bridge: always ok */
-#if 0
+#if 1
if (pcib_is_nonprefetch_open(sc)) {
if (start < sc->membase && end > sc->memlimit) {
start = sc->membase;
==== //depot/projects/power/sys/dev/pci/pci_private.h#6 (text+ko) ====
@@ -25,7 +25,7 @@
* (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: src/sys/dev/pci/pci_private.h,v 1.11 2003/09/17 08:32:44 iwasaki Exp $
+ * $FreeBSD: src/sys/dev/pci/pci_private.h,v 1.12 2004/04/09 15:44:34 imp Exp $
*
*/
==== //depot/projects/power/sys/dev/random/harvest.c#4 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000, 2001, 2002, 2003 Mark R V Murray
+ * Copyright (c) 2000-2004 Mark R V Murray
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/random/harvest.c,v 1.22 2004/03/05 22:42:17 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/random/harvest.c,v 1.23 2004/04/09 15:47:09 markm Exp $");
#include <sys/param.h>
#include <sys/kthread.h>
@@ -37,29 +37,29 @@
#include <sys/queue.h>
#include <sys/random.h>
#include <sys/selinfo.h>
+#include <sys/systm.h>
#include <sys/sysctl.h>
-#include <sys/systm.h>
#include <machine/cpu.h>
-#include <dev/random/randomdev.h>
+#include <dev/random/randomdev_soft.h>
static int read_random_phony(void *, int);
/* Structure holding the desired entropy sources */
-struct harvest_select harvest = { 0, 0, 0 };
+struct harvest_select harvest = { 0, 0, 0, 0 };
/* hold the address of the routine which is actually called if
* the randomdev is loaded
*/
-static void (*reap_func)(u_int64_t, void *, u_int, u_int, u_int, enum esource)
- = NULL;
+static void (*reap_func)(u_int64_t, const void *, u_int, u_int, u_int,
+ enum esource) = NULL;
static int (*read_func)(void *, int) = read_random_phony;
/* Initialise the harvester at load time */
void
-random_init_harvester(void (*reaper)(u_int64_t, void *, u_int, u_int, u_int,
- enum esource), int (*reader)(void *, int))
+random_yarrow_init_harvester(void (*reaper)(u_int64_t, const void *, u_int,
+ u_int, u_int, enum esource), int (*reader)(void *, int))
{
reap_func = reaper;
read_func = reader;
@@ -67,7 +67,7 @@
/* Deinitialise the harvester at unload time */
void
-random_deinit_harvester(void)
+random_yarrow_deinit_harvester(void)
{
reap_func = NULL;
read_func = read_random_phony;
@@ -91,7 +91,7 @@
int
read_random(void *buf, int count)
{
- return (*read_func)(buf, count);
+ return ((*read_func)(buf, count));
}
/* If the entropy device is not loaded, make a token effort to
@@ -109,13 +109,11 @@
/* Fill buf[] with random(9) output */
for (i = 0; i < count; i+= (int)sizeof(u_long)) {
randval = random();
- size = (count - i) < (int)sizeof(u_long)
- ? (count - i)
- : sizeof(u_long);
+ size = MIN(count - i, sizeof(u_long));
memcpy(&((char *)buf)[i], &randval, (size_t)size);
}
- return count;
+ return (count);
}
/* Helper routine to enable kthread_exit() to work while the module is
==== //depot/projects/power/sys/dev/random/hash.c#3 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000, 2001, 2002, 2003 Mark R V Murray
+ * Copyright (c) 2000-2004 Mark R V Murray
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/random/hash.c,v 1.11 2003/11/17 23:02:21 markm Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/random/hash.c,v 1.12 2004/04/09 15:47:09 markm Exp $");
#include <sys/param.h>
#include <sys/systm.h>
==== //depot/projects/power/sys/dev/random/hash.h#2 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000 Mark R V Murray
+ * Copyright (c) 2000-2004 Mark R V Murray
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* (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: src/sys/dev/random/hash.h,v 1.4 2002/07/15 13:58:35 markm Exp $
+ * $FreeBSD: src/sys/dev/random/hash.h,v 1.5 2004/04/09 15:47:09 markm Exp $
*/
#define KEYSIZE 32 /* (in bytes) 32 bytes == 256 bits */
==== //depot/projects/power/sys/dev/random/randomdev.c#4 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000, 2001, 2002, 2003 Mark R V Murray
+ * Copyright (c) 2000-2004 Mark R V Murray
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/random/randomdev.c,v 1.48 2004/02/21 21:10:45 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/random/randomdev.c,v 1.49 2004/04/09 15:47:09 markm Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -41,9 +41,7 @@
#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/proc.h>
-#include <sys/random.h>
#include <sys/selinfo.h>
-#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
@@ -53,150 +51,96 @@
#include <dev/random/randomdev.h>
-static d_close_t random_close;
-static d_read_t random_read;
-static d_write_t random_write;
-static d_ioctl_t random_ioctl;
-static d_poll_t random_poll;
-
#define RANDOM_MINOR 0
-#define RANDOM_FIFO_MAX 256 /* How many events to queue up */
+static d_close_t random_close;
+static d_read_t random_read;
+static d_write_t random_write;
+static d_ioctl_t random_ioctl;
+static d_poll_t random_poll;
static struct cdevsw random_cdevsw = {
- .d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
- .d_close = random_close,
- .d_read = random_read,
- .d_write = random_write,
- .d_ioctl = random_ioctl,
- .d_poll = random_poll,
- .d_name = "random",
+ .d_version = D_VERSION,
+ .d_close = random_close,
+ .d_read = random_read,
+ .d_write = random_write,
+ .d_ioctl = random_ioctl,
+ .d_poll = random_poll,
+ .d_name = "random",
};
-static void random_kthread(void *);
-static void random_harvest_internal(u_int64_t, void *, u_int, u_int, u_int, enum esource);
-static void random_write_internal(void *, int);
+static void *random_buf;
-MALLOC_DEFINE(M_ENTROPY, "entropy", "Entropy harvesting buffers");
-
-/* Lockable FIFO queue holding entropy buffers */
-struct entropyfifo {
- struct mtx lock;
- int count;
- STAILQ_HEAD(harvestlist, harvest) head;
-};
-
-/* Empty entropy buffers */
-static struct entropyfifo emptyfifo;
-#define EMPTYBUFFERS 1024
-
-/* Harvested entropy */
-static struct entropyfifo harvestfifo[ENTROPYSOURCE];
-
-static struct random_systat {
- u_int seeded; /* 0 causes blocking 1 allows normal output */
- struct selinfo rsel; /* For poll(2) */
-} random_systat;
+struct random_systat random_systat;
-/* <0 to end the kthread, 0 to let it run */
-static int random_kthread_control = 0;
-
-static struct proc *random_kthread_proc;
-
/* For use with make_dev(9)/destroy_dev(9). */
-static dev_t random_dev;
+static dev_t random_dev;
-/* ARGSUSED */
-static int
-random_check_boolean(SYSCTL_HANDLER_ARGS)
+/* Used to fake out unused random calls in random_systat */
+void
+random_null_func(void)
{
- if (oidp->oid_arg1 != NULL && *(u_int *)(oidp->oid_arg1) != 0)
- *(u_int *)(oidp->oid_arg1) = 1;
- return sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
}
-SYSCTL_NODE(_kern, OID_AUTO, random, CTLFLAG_RW,
- 0, "Random Number Generator");
-SYSCTL_NODE(_kern_random, OID_AUTO, sys, CTLFLAG_RW,
- 0, "Entropy Device Parameters");
-SYSCTL_PROC(_kern_random_sys, OID_AUTO, seeded,
- CTLTYPE_INT|CTLFLAG_RW, &random_systat.seeded, 1,
- random_check_boolean, "I", "Seeded State");
-SYSCTL_NODE(_kern_random_sys, OID_AUTO, harvest, CTLFLAG_RW,
- 0, "Entropy Sources");
-SYSCTL_PROC(_kern_random_sys_harvest, OID_AUTO, ethernet,
- CTLTYPE_INT|CTLFLAG_RW, &harvest.ethernet, 0,
- random_check_boolean, "I", "Harvest NIC entropy");
-SYSCTL_PROC(_kern_random_sys_harvest, OID_AUTO, point_to_point,
- CTLTYPE_INT|CTLFLAG_RW, &harvest.point_to_point, 0,
- random_check_boolean, "I", "Harvest serial net entropy");
-SYSCTL_PROC(_kern_random_sys_harvest, OID_AUTO, interrupt,
- CTLTYPE_INT|CTLFLAG_RW, &harvest.interrupt, 0,
- random_check_boolean, "I", "Harvest IRQ entropy");
-SYSCTL_PROC(_kern_random_sys_harvest, OID_AUTO, swi,
- CTLTYPE_INT|CTLFLAG_RW, &harvest.swi, 0,
- random_check_boolean, "I", "Harvest SWI entropy");
-
/* ARGSUSED */
static int
-random_close(dev_t dev __unused, int flags, int fmt __unused, struct thread *td)
+random_close(dev_t dev __unused, int flags, int fmt __unused,
+ struct thread *td)
{
- if (flags & FWRITE) {
- if (suser(td) == 0 && securelevel_gt(td->td_ucred, 0) == 0)
- random_reseed();
+ if ((flags & FWRITE) && (suser(td) == 0)
+ && (securelevel_gt(td->td_ucred, 0) == 0)) {
+ mtx_lock(&random_systat.lock);
+ (*random_systat.reseed)();
+ random_systat.seeded = 1;
+ mtx_unlock(&random_systat.lock);
}
- return 0;
+ return (0);
}
/* ARGSUSED */
static int
random_read(dev_t dev __unused, struct uio *uio, int flag)
{
- int c, ret;
- int error = 0;
- void *random_buf;
+ int c, error = 0;
- while (!random_systat.seeded) {
+ /* Blocking logic */
+ while (!random_systat.seeded && !error) {
if (flag & IO_NDELAY)
- error = EWOULDBLOCK;
+ error = EWOULDBLOCK;
else
- error = tsleep(&random_systat, PUSER|PCATCH,
- "block", 0);
- if (error != 0)
- return error;
+ error = tsleep(&random_systat,
+ PUSER | PCATCH, "block", 0);
}
- c = uio->uio_resid < PAGE_SIZE ? uio->uio_resid : PAGE_SIZE;
- random_buf = (void *)malloc((u_long)c, M_TEMP, M_WAITOK);
- while (uio->uio_resid > 0 && error == 0) {
- ret = read_random_real(random_buf, c);
- error = uiomove(random_buf, ret, uio);
+
+ /* The actual read */
+ if (!error) {
+ mtx_lock(&random_systat.lock);
+ while (uio->uio_resid > 0 && !error) {
+ c = MIN(uio->uio_resid, PAGE_SIZE);
+ c = (*random_systat.read)(random_buf, c);
+ error = uiomove(random_buf, c, uio);
+ }
+ mtx_unlock(&random_systat.lock);
}
- free(random_buf, M_TEMP);
- return error;
+ return (error);
}
/* ARGSUSED */
static int
random_write(dev_t dev __unused, struct uio *uio, int flag __unused)
{
- int c;
- int error;
- void *random_buf;
+ int c, error = 0;
- error = 0;
- random_buf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
+ mtx_lock(&random_systat.lock);
while (uio->uio_resid > 0) {
- c = (int)(uio->uio_resid < PAGE_SIZE
- ? uio->uio_resid
- : PAGE_SIZE);
+ c = MIN((int)uio->uio_resid, PAGE_SIZE);
error = uiomove(random_buf, c, uio);
if (error)
break;
- random_write_internal(random_buf, c);
+ (*random_systat.write)(random_buf, c);
}
- free(random_buf, M_TEMP);
- return error;
+ mtx_unlock(&random_systat.lock);
+ return (error);
}
/* ARGSUSED */
@@ -204,264 +148,70 @@
random_ioctl(dev_t dev __unused, u_long cmd, caddr_t addr __unused,
int flags __unused, struct thread *td __unused)
{
+ int error = 0;
+
switch (cmd) {
- /* Really handled in upper layer */
+ /* Really handled in upper layer */
case FIOASYNC:
case FIONBIO:
- return 0;
+ break;
default:
- return ENOTTY;
+ error = ENOTTY;
}
+ return (error);
}
/* ARGSUSED */
static int
random_poll(dev_t dev __unused, int events, struct thread *td)
{
- int revents;
+ int revents = 0;
- revents = 0;
if (events & (POLLIN | POLLRDNORM)) {
if (random_systat.seeded)
revents = events & (POLLIN | POLLRDNORM);
else
selrecord(td, &random_systat.rsel);
}
- return revents;
+ return (revents);
}
/* ARGSUSED */
static int
random_modevent(module_t mod __unused, int type, void *data __unused)
{
- int error, i;
- struct harvest *np;
+ int error = 0;
- switch(type) {
+ switch (type) {
case MOD_LOAD:
- random_init();
+ random_buf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
+ random_ident_hardware(&random_systat);
+ mtx_init(&random_systat.lock, "entropy device lock",
+ NULL, MTX_DEF);
+ (*random_systat.init)();
- /* This can be turned off by the very paranoid
- * a reseed will turn it back on.
- */
- random_systat.seeded = 1;
+ printf("random: <entropy source, %s>\n", random_systat.ident);
- /* Initialise the harvest fifos */
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list