summaryrefslogtreecommitdiffstats
path: root/sys/i386/bios/smapi.c
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-01-17 08:10:18 +0000
committermdodd <mdodd@FreeBSD.org>2003-01-17 08:10:18 +0000
commitdef7e1bda051583fcc3525070ac5429f314f7fcf (patch)
tree9569a08b4ce3cebe0d49d0bb941a139c6b6d5f61 /sys/i386/bios/smapi.c
parent67dc3cf7fb55dd4317169204e4235cc4b359827c (diff)
downloadFreeBSD-src-def7e1bda051583fcc3525070ac5429f314f7fcf.zip
FreeBSD-src-def7e1bda051583fcc3525070ac5429f314f7fcf.tar.gz
A driver for the System Management Application Program
Interface (SMAPI) BIOS, which is present on some IBM Thinkpad models (560, 600, 770 to name a few.) The SMAPI BIOS provides access to System Information, System Configuration, and Power Management.
Diffstat (limited to 'sys/i386/bios/smapi.c')
-rw-r--r--sys/i386/bios/smapi.c167
1 files changed, 167 insertions, 0 deletions
diff --git a/sys/i386/bios/smapi.c b/sys/i386/bios/smapi.c
new file mode 100644
index 0000000..e2e96ad
--- /dev/null
+++ b/sys/i386/bios/smapi.c
@@ -0,0 +1,167 @@
+/*-
+ * Copyright (c) 2003 Matthew N. Dodd <winter@jurai.net>
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+
+#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
+
+#include <machine/smapi.h>
+#include <i386/smapi/smapi_var.h>
+
+u_long smapi32_offset;
+u_short smapi32_segment;
+#define SMAPI32_SEGMENT 0x18
+
+devclass_t smapi_devclass;
+
+static d_open_t smapi_open;
+static d_close_t smapi_close;
+static d_ioctl_t smapi_ioctl;
+
+#define CDEV_MAJOR 183
+
+static struct cdevsw smapi_cdevsw = {
+ /* open */ smapi_open,
+ /* close */ smapi_close,
+ /* read */ noread,
+ /* write */ nowrite,
+ /* ioctl */ smapi_ioctl,
+ /* poll */ nopoll,
+ /* mmap */ nommap,
+ /* strategy */ nostrategy,
+ /* name */ "smapi",
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ D_MEM,
+ /* kqfilter */ NULL,
+};
+
+static int
+smapi_open (dev, oflags, devtype, td)
+ dev_t dev;
+ int oflags;
+ int devtype;
+ d_thread_t * td;
+{
+
+ return (0);
+}
+
+static int
+smapi_close (dev, fflag, devtype, td)
+ dev_t dev;
+ int fflag;
+ int devtype;
+ d_thread_t * td;
+{
+
+ return (0);
+}
+
+static int
+smapi_ioctl (dev, cmd, data, fflag, td)
+ dev_t dev;
+ u_long cmd;
+ caddr_t data;
+ int fflag;
+ d_thread_t * td;
+{
+ struct smapi_softc *sc;
+ int error;
+
+ error = 0;
+ sc = devclass_get_softc(smapi_devclass, minor(dev));
+ if (sc == NULL) {
+ error = ENXIO;
+ goto fail;
+ }
+
+ switch (cmd) {
+ case SMAPIOGHEADER:
+ bcopy((caddr_t)sc->header, data,
+ sizeof(struct smapi_bios_header));
+ error = 0;
+ break;
+ case SMAPIOCGFUNCTION:
+ smapi32_segment = SMAPI32_SEGMENT;
+ smapi32_offset = sc->smapi32_entry;
+ error = smapi32((struct smapi_bios_parameter *)data,
+ (struct smapi_bios_parameter *)data);
+ break;
+ default:
+ error = ENOTTY;
+ }
+
+fail:
+ return (error);
+}
+
+int
+smapi_attach (struct smapi_softc *sc)
+{
+ struct smapi_bios_parameter input_param;
+ struct smapi_bios_parameter output_param;
+ int retval;
+
+ sc->cdev = make_dev(&smapi_cdevsw,
+ device_get_unit(sc->dev),
+ UID_ROOT, GID_WHEEL, 0600,
+ "%s%d",
+ smapi_cdevsw.d_name,
+ device_get_unit(sc->dev));
+
+ bzero(&input_param, sizeof(struct smapi_bios_parameter));
+ bzero(&output_param, sizeof(struct smapi_bios_parameter));
+ smapi32_segment = SMAPI32_SEGMENT;
+ smapi32_offset = sc->smapi32_entry;
+ retval = smapi32(&output_param, &output_param);
+
+#if 0
+ retval = smapi32_new(sc->smapi32_entry, SMAPI32_SEGMENT,
+ &output_param, &output_param);
+#endif
+
+ return (0);
+}
+
+int
+smapi_detach (struct smapi_softc *sc)
+{
+
+ destroy_dev(sc->cdev);
+ return (0);
+}
OpenPOWER on IntegriCloud