Module Name: src
Committed By: mbalmer
Date: Mon May 20 15:48:25 UTC 2013
Modified Files:
src/sys/dev/gpio: gpiosim.c
Log Message:
Make the gpiosim(4) device a 64 bit wide GPIO.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/gpio/gpiosim.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/gpio/gpiosim.c
diff -u src/sys/dev/gpio/gpiosim.c:1.14 src/sys/dev/gpio/gpiosim.c:1.15
--- src/sys/dev/gpio/gpiosim.c:1.14 Sat Jun 2 21:36:44 2012
+++ src/sys/dev/gpio/gpiosim.c Mon May 20 15:48:25 2013
@@ -1,8 +1,8 @@
-/* $NetBSD: gpiosim.c,v 1.14 2012/06/02 21:36:44 dsl Exp $ */
+/* $NetBSD: gpiosim.c,v 1.15 2013/05/20 15:48:25 mbalmer Exp $ */
/* $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $ */
/*
- * Copyright (c) 2007, 2008, 2009, 2010, 2011 Marc Balmer <[email protected]>
+ * Copyright (c) 2007 - 2011, 2013 Marc Balmer <[email protected]>
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -18,7 +18,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* 32 bit wide GPIO simulator */
+/* 64 bit wide GPIO simulator */
#include <sys/param.h>
#include <sys/systm.h>
@@ -30,12 +30,12 @@
#include <sys/ioccom.h>
#include <dev/gpio/gpiovar.h>
-#define GPIOSIM_NPINS 32
+#define GPIOSIM_NPINS 64
struct gpiosim_softc {
device_t sc_dev;
device_t sc_gdev; /* gpio that attaches here */
- uint32_t sc_state;
+ uint64_t sc_state;
struct gpio_chipset_tag sc_gpio_gc;
gpio_pin_t sc_gpio_pins[GPIOSIM_NPINS];
@@ -105,19 +105,19 @@ gpiosim_attach(device_t parent, device_t
/* read initial state */
sc->sc_gpio_pins[i].pin_flags = GPIO_PIN_INPUT;
- sc->sc_state = 0;
-
- /* create controller tag */
- sc->sc_gpio_gc.gp_cookie = sc;
- sc->sc_gpio_gc.gp_pin_read = gpiosim_pin_read;
- sc->sc_gpio_gc.gp_pin_write = gpiosim_pin_write;
- sc->sc_gpio_gc.gp_pin_ctl = gpiosim_pin_ctl;
-
- /* gba.gba_name = "gpio"; */
- gba.gba_gc = &sc->sc_gpio_gc;
- gba.gba_pins = sc->sc_gpio_pins;
- gba.gba_npins = GPIOSIM_NPINS;
}
+ sc->sc_state = 0;
+
+ /* create controller tag */
+ sc->sc_gpio_gc.gp_cookie = sc;
+ sc->sc_gpio_gc.gp_pin_read = gpiosim_pin_read;
+ sc->sc_gpio_gc.gp_pin_write = gpiosim_pin_write;
+ sc->sc_gpio_gc.gp_pin_ctl = gpiosim_pin_ctl;
+
+ /* gba.gba_name = "gpio"; */
+ gba.gba_gc = &sc->sc_gpio_gc;
+ gba.gba_pins = sc->sc_gpio_pins;
+ gba.gba_npins = GPIOSIM_NPINS;
pmf_device_register(self, NULL, NULL);
@@ -140,7 +140,7 @@ gpiosim_attach(device_t parent, device_t
sysctl_createv(&sc->sc_log, 0, &node, NULL,
CTLFLAG_READWRITE,
- CTLTYPE_INT, "value",
+ CTLTYPE_QUAD, "value",
SYSCTL_DESCR("Current GPIO simulator value"),
gpiosim_sysctl, 0, (void *)sc, 0,
CTL_CREATE, CTL_EOL);
@@ -171,7 +171,7 @@ gpiosim_sysctl(SYSCTLFN_ARGS)
{
struct sysctlnode node;
struct gpiosim_softc *sc;
- int val, error;
+ uint64_t val, error;
node = *rnode;
sc = node.sysctl_data;
@@ -192,7 +192,7 @@ gpiosim_pin_read(void *arg, int pin)
{
struct gpiosim_softc *sc = arg;
- if (sc->sc_state & (1 << pin))
+ if (sc->sc_state & (1LL << pin))
return GPIO_PIN_HIGH;
else
return GPIO_PIN_LOW;
@@ -204,9 +204,9 @@ gpiosim_pin_write(void *arg, int pin, in
struct gpiosim_softc *sc = arg;
if (value == 0)
- sc->sc_state &= ~(1 << pin);
+ sc->sc_state &= ~(1LL << pin);
else
- sc->sc_state |= (1 << pin);
+ sc->sc_state |= (1LL << pin);
}
static void