From 8f6a5b8ecf1955a61f7e21f5034ac027412cec08 Mon Sep 17 00:00:00 2001 From: takawata Date: Wed, 8 May 2013 12:53:21 +0000 Subject: [PATCH] A driver for Intel Rapid Start Technology ACPI device. Note that it is just for 'Advanced' configuration for Rapid start technology. --- sys/dev/acpi_support/acpi_rapidstart.c | 133 ++++++++++++++++++++++ sys/modules/acpi/acpi_rapidstart/Makefile | 8 ++ 2 files changed, 141 insertions(+) create mode 100644 sys/dev/acpi_support/acpi_rapidstart.c create mode 100644 sys/modules/acpi/acpi_rapidstart/Makefile diff --git a/sys/dev/acpi_support/acpi_rapidstart.c b/sys/dev/acpi_support/acpi_rapidstart.c new file mode 100644 index 000000000000..2da93ec17127 --- /dev/null +++ b/sys/dev/acpi_support/acpi_rapidstart.c @@ -0,0 +1,133 @@ +/*- + * Copyright (c) 2013 Takanori Watanabe + * 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 +__FBSDID("$FreeBSD$"); + +#include "opt_acpi.h" +#include +#include +#include + +#include + +#include "acpi_if.h" +#include +#include +#include +static int sysctl_acpi_rapidstart_gen_handler(SYSCTL_HANDLER_ARGS); + + +static struct acpi_rapidstart_name_list +{ + char *nodename; + char *getmethod; + char *setmethod; + char *comment; +} acpi_rapidstart_oids[] ={ + {"ffs","GFFS","SFFS","Flash Fast Store Flag"}, + {"ftv","GFTV","SFTV","Time value"}, + {NULL, NULL, NULL, NULL} +}; + +struct acpi_rapidstart_softc { + struct sysctl_ctx_list *sysctl_ctx; + struct sysctl_oid *sysctl_tree; + +}; +static char *rapidstart_ids[] = {"INT3392", NULL}; +static int +acpi_rapidstart_probe(device_t dev) +{ + if (acpi_disabled("rapidstart") || + ACPI_ID_PROBE(device_get_parent(dev), dev, rapidstart_ids) == NULL || + device_get_unit(dev) != 0) + return (ENXIO); + + device_set_desc(dev, "Intel Rapid Start ACPI device"); + + return (0); + +} + +static int +acpi_rapidstart_attach(device_t dev) +{ + struct acpi_rapidstart_softc *sc; + int i; + + sc = device_get_softc(dev); + + sc->sysctl_ctx = device_get_sysctl_ctx(dev); + sc->sysctl_tree = device_get_sysctl_tree(dev); + for (i = 0 ; acpi_rapidstart_oids[i].nodename != NULL; i++){ + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + i, acpi_rapidstart_oids[i].nodename , CTLTYPE_INT | + ((acpi_rapidstart_oids[i].setmethod)? CTLFLAG_RW: CTLFLAG_RD), + dev, i, sysctl_acpi_rapidstart_gen_handler, "I", + acpi_rapidstart_oids[i].comment); + } + return (0); +} + +static int +sysctl_acpi_rapidstart_gen_handler(SYSCTL_HANDLER_ARGS) +{ + device_t dev = arg1; + int function = oidp->oid_arg2; + int error = 0, val; + + acpi_GetInteger(acpi_get_handle(dev), + acpi_rapidstart_oids[function].getmethod, &val); + error = sysctl_handle_int(oidp, &val, 0, req); + if (error || !req->newptr || !acpi_rapidstart_oids[function].setmethod) + return (error); + acpi_SetInteger(acpi_get_handle(dev), + acpi_rapidstart_oids[function].setmethod, val); + return (0); +} + +static device_method_t acpi_rapidstart_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, acpi_rapidstart_probe), + DEVMETHOD(device_attach, acpi_rapidstart_attach), + + DEVMETHOD_END +}; + +static driver_t acpi_rapidstart_driver = { + "acpi_rapidstart", + acpi_rapidstart_methods, + sizeof(struct acpi_rapidstart_softc), +}; + +static devclass_t acpi_rapidstart_devclass; + +DRIVER_MODULE(acpi_rapidstart, acpi, acpi_rapidstart_driver, acpi_rapidstart_devclass, + 0, 0); +MODULE_DEPEND(acpi_rapidstart, acpi, 1, 1, 1); + diff --git a/sys/modules/acpi/acpi_rapidstart/Makefile b/sys/modules/acpi/acpi_rapidstart/Makefile new file mode 100644 index 000000000000..161962573bfe --- /dev/null +++ b/sys/modules/acpi/acpi_rapidstart/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../../dev/acpi_support + +KMOD= acpi_rapidstart +SRCS= acpi_rapidstart.c opt_acpi.h device_if.h bus_if.h acpi_if.h + +.include