New Maple Bus driver
- interrupt driven - support hot swapping - sub-drivers can send commands
This commit is contained in:
parent
7710d527c5
commit
154b121f4b
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,40 @@
|
|||
/* $NetBSD: maple.h,v 1.4 2002/03/25 18:59:40 uch Exp $ */
|
||||
/* $NetBSD: maple.h,v 1.5 2002/11/15 13:30:21 itohy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by ITOH Yasufumi.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Marcus Comstedt
|
||||
|
@ -35,45 +71,45 @@
|
|||
#ifndef _DREAMCAST_DEV_MAPLE_MAPLE_H_
|
||||
#define _DREAMCAST_DEV_MAPLE_MAPLE_H_
|
||||
|
||||
#include <sys/device.h>
|
||||
|
||||
#define MAPLE_PORTS 4
|
||||
#define MAPLE_SUBUNITS 6
|
||||
/* signed is more effective than unsigned on SH */
|
||||
typedef int8_t maple_response_t;
|
||||
|
||||
/* Maple Bus command and response codes */
|
||||
|
||||
#define MAPLE_RESPONSE_FILEERR -5
|
||||
#define MAPLE_RESPONSE_AGAIN -4 /* request should be retransmitted */
|
||||
#define MAPLE_RESPONSE_BADCMD -3
|
||||
#define MAPLE_RESPONSE_BADFUNC -2
|
||||
#define MAPLE_RESPONSE_NONE -1 /* unit didn't respond at all */
|
||||
#define MAPLE_COMMAND_DEVINFO 1
|
||||
#define MAPLE_COMMAND_ALLINFO 2
|
||||
#define MAPLE_COMMAND_RESET 3
|
||||
#define MAPLE_COMMAND_KILL 4
|
||||
#define MAPLE_RESPONSE_DEVINFO 5
|
||||
#define MAPLE_RESPONSE_ALLINFO 6
|
||||
#define MAPLE_RESPONSE_OK 7
|
||||
#define MAPLE_RESPONSE_DATATRF 8
|
||||
#define MAPLE_COMMAND_GETCOND 9
|
||||
#define MAPLE_COMMAND_GETMINFO 10
|
||||
#define MAPLE_COMMAND_BREAD 11
|
||||
#define MAPLE_COMMAND_BWRITE 12
|
||||
#define MAPLE_COMMAND_SETCOND 14
|
||||
|
||||
#define MAPLE_RESPONSE_LCDERR (-6)
|
||||
#define MAPLE_RESPONSE_FILEERR (-5)
|
||||
#define MAPLE_RESPONSE_AGAIN (-4) /* request should be retransmitted */
|
||||
#define MAPLE_RESPONSE_BADCMD (-3)
|
||||
#define MAPLE_RESPONSE_BADFUNC (-2)
|
||||
#define MAPLE_RESPONSE_NONE (-1) /* unit didn't respond at all */
|
||||
#define MAPLE_COMMAND_DEVINFO 1
|
||||
#define MAPLE_COMMAND_ALLINFO 2
|
||||
#define MAPLE_COMMAND_RESET 3
|
||||
#define MAPLE_COMMAND_KILL 4
|
||||
#define MAPLE_RESPONSE_DEVINFO 5
|
||||
#define MAPLE_RESPONSE_ALLINFO 6
|
||||
#define MAPLE_RESPONSE_OK 7
|
||||
#define MAPLE_RESPONSE_DATATRF 8
|
||||
#define MAPLE_COMMAND_GETCOND 9
|
||||
#define MAPLE_COMMAND_GETMINFO 10
|
||||
#define MAPLE_COMMAND_BREAD 11
|
||||
#define MAPLE_COMMAND_BWRITE 12
|
||||
#define MAPLE_COMMAND_GETLASTERR 13
|
||||
#define MAPLE_COMMAND_SETCOND 14
|
||||
|
||||
/* Function codes */
|
||||
#define MAPLE_FN_CONTROLLER 0
|
||||
#define MAPLE_FN_MEMCARD 1
|
||||
#define MAPLE_FN_LCD 2
|
||||
#define MAPLE_FN_CLOCK 3
|
||||
#define MAPLE_FN_MICROPHONE 4
|
||||
#define MAPLE_FN_ARGUN 5
|
||||
#define MAPLE_FN_KEYBOARD 6
|
||||
#define MAPLE_FN_LIGHTGUN 7
|
||||
#define MAPLE_FN_PURUPURU 8
|
||||
#define MAPLE_FN_MOUSE 9
|
||||
|
||||
#define MAPLE_FUNC_CONTROLLER 0x001
|
||||
#define MAPLE_FUNC_MEMCARD 0x002
|
||||
#define MAPLE_FUNC_LCD 0x004
|
||||
#define MAPLE_FUNC_CLOCK 0x008
|
||||
#define MAPLE_FUNC_MICROPHONE 0x010
|
||||
#define MAPLE_FUNC_ARGUN 0x020
|
||||
#define MAPLE_FUNC_KEYBOARD 0x040
|
||||
#define MAPLE_FUNC_LIGHTGUN 0x080
|
||||
#define MAPLE_FUNC_PURUPURU 0x100
|
||||
#define MAPLE_FUNC_MOUSE 0x200
|
||||
#define MAPLE_FUNC(fn) (1 << (fn))
|
||||
|
||||
struct maple_devinfo {
|
||||
u_int32_t di_func; /* function code */
|
||||
|
@ -86,19 +122,29 @@ struct maple_devinfo {
|
|||
u_int16_t di_max_power; /* maximum power consumption */
|
||||
};
|
||||
|
||||
struct maple_unit {
|
||||
int port, subunit;
|
||||
int status;
|
||||
u_int32_t getcond_func;
|
||||
void (*getcond_callback)(void *, void *, int);
|
||||
void *getcond_data;
|
||||
struct maple_devinfo devinfo;
|
||||
struct maple_response {
|
||||
u_int32_t response_code;
|
||||
u_int32_t data[1]; /* variable length */
|
||||
};
|
||||
|
||||
extern void maple_set_condition_callback(struct device *, int, int,
|
||||
u_int32_t, void (*)(void *, void *, int), void *);
|
||||
extern u_int32_t maple_get_function_data(struct maple_devinfo *, u_int32_t);
|
||||
#define MAPLE_FLAG_PERIODIC 1
|
||||
#define MAPLE_FLAG_CMD_PERIODIC_TIMING 2
|
||||
|
||||
struct maple_unit;
|
||||
|
||||
extern void maple_set_callback(struct device *, struct maple_unit *, int,
|
||||
void (*)(void *, struct maple_response *, int, int),
|
||||
void *);
|
||||
extern void maple_enable_unit_ping(struct device *, struct maple_unit *,
|
||||
int /*func*/, int /*enable*/);
|
||||
extern void maple_enable_periodic(struct device *, struct maple_unit *,
|
||||
int /*func*/, int /*on*/);
|
||||
extern void maple_command(struct device *, struct maple_unit *,
|
||||
int /*func*/, int /*command*/, int /*datalen*/, void *,
|
||||
int /*flags*/);
|
||||
extern u_int32_t maple_get_function_data(struct maple_devinfo *, int);
|
||||
extern void maple_run_polling(struct device *);
|
||||
extern int maple_unit_ioctl(struct device *, struct maple_unit *,
|
||||
u_long, caddr_t, int, struct proc *);
|
||||
|
||||
#endif /* _DREAMCAST_DEV_MAPLE_MAPLE_H_ */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mapleconf.h,v 1.4 2002/03/25 18:59:40 uch Exp $ */
|
||||
/* $NetBSD: mapleconf.h,v 1.5 2002/11/15 13:30:21 itohy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Marcus Comstedt
|
||||
|
@ -33,7 +33,10 @@
|
|||
*/
|
||||
|
||||
struct maple_attach_args {
|
||||
int ma_port, ma_subunit;
|
||||
struct maple_unit *ma_unit;
|
||||
u_int32_t ma_function;
|
||||
struct maple_devinfo *ma_devinfo;
|
||||
};
|
||||
|
||||
#define MAPLE_MATCH_FUNC 2
|
||||
#define MAPLE_MATCH_FALLBACK 1
|
||||
|
|
|
@ -1,4 +1,41 @@
|
|||
/* $NetBSD: maplevar.h,v 1.4 2001/05/26 19:04:40 marcus Exp $ */
|
||||
/* $NetBSD: maplevar.h,v 1.5 2002/11/15 13:30:21 itohy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by ITOH Yasufumi.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Marcus Comstedt
|
||||
* All rights reserved.
|
||||
|
@ -31,16 +68,109 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#define MAPLE_PORTS 4
|
||||
#define MAPLE_SUBUNITS 6
|
||||
|
||||
#define MAPLE_NFUNC 32
|
||||
|
||||
struct maple_func {
|
||||
int f_funcno;
|
||||
struct maple_unit *f_unit;
|
||||
struct device *f_dev;
|
||||
|
||||
/* callback */
|
||||
void (*f_callback)(void *, struct maple_response *,
|
||||
int /*len*/, int /*flags*/);
|
||||
void *f_arg;
|
||||
|
||||
u_int32_t f_work; /* for periodic GETCOND and ping */
|
||||
|
||||
/* periodic command request */
|
||||
enum maple_periodic_stat {
|
||||
MAPLE_PERIODIC_NONE,
|
||||
MAPLE_PERIODIC_INQ,
|
||||
MAPLE_PERIODIC_DEFERED
|
||||
} f_periodic_stat;
|
||||
TAILQ_ENTRY(maple_func) f_periodicq;
|
||||
|
||||
/* command request */
|
||||
int f_command;
|
||||
int f_datalen;
|
||||
void *f_dataaddr;
|
||||
enum maple_command_stat {
|
||||
MAPLE_CMDSTAT_NONE, /* not in queue */
|
||||
MAPLE_CMDSTAT_ASYNC, /* process immediately */
|
||||
MAPLE_CMDSTAT_PERIODIC_DEFERED, /* periodic but process imdtly*/
|
||||
MAPLE_CMDSTAT_ASYNC_PERIODICQ, /* async but on periodic queue*/
|
||||
MAPLE_CMDSTAT_PERIODIC /* process on periodic timing */
|
||||
} f_cmdstat;
|
||||
TAILQ_ENTRY(maple_func) f_cmdq;
|
||||
};
|
||||
|
||||
struct maple_unit {
|
||||
int port, subunit;
|
||||
struct maple_func u_func[MAPLE_NFUNC];
|
||||
u_int32_t getcond_func_set;
|
||||
int u_ping_func; /* function used for ping */
|
||||
u_int32_t u_noping; /* stop ping (bitmap of function) */
|
||||
struct maple_devinfo devinfo;
|
||||
|
||||
/* DMA status / function */
|
||||
enum maple_dma_stat {
|
||||
MAPLE_DMA_IDLE, /* not in queue */
|
||||
MAPLE_DMA_RETRY, /* retrying last command (sc_retryq) */
|
||||
MAPLE_DMA_PERIODIC, /* periodic GETCOND */
|
||||
MAPLE_DMA_ACMD, /* asynchronous command */
|
||||
MAPLE_DMA_PCMD, /* command on periodic timing */
|
||||
MAPLE_DMA_PROBE, /* checking for insertion */
|
||||
MAPLE_DMA_PING /* checking for removal */
|
||||
} u_dma_stat;
|
||||
int u_dma_func;
|
||||
|
||||
SIMPLEQ_ENTRY(maple_unit) u_dmaq;
|
||||
|
||||
/* start of each receive buffer */
|
||||
u_int32_t *u_rxbuf;
|
||||
u_int32_t u_rxbuf_phys;
|
||||
|
||||
/* for restarting command */
|
||||
int u_command;
|
||||
int u_datalen;
|
||||
void *u_dataaddr;
|
||||
enum maple_dma_stat u_saved_dma_stat;
|
||||
int u_retrycnt;
|
||||
#define MAPLE_RETRY_MAX 100 /* ~2s */
|
||||
/*
|
||||
* The 2s retry is rather too long, but required to avoid
|
||||
* unwanted detach/attach.
|
||||
* If a Visual Memory (without cells) is inserted to a controller,
|
||||
* the controller (including the base device and the other unit
|
||||
* in the slot) stops responding for near 1 second. If two VM are
|
||||
* inserted in succession, the period becomes near 2s.
|
||||
*/
|
||||
|
||||
/* queue for probe/ping */
|
||||
enum maple_queue_stat {
|
||||
MAPLE_QUEUE_NONE, /* not in queue */
|
||||
MAPLE_QUEUE_PROBE, /* checking for insertion */
|
||||
MAPLE_QUEUE_PING /* checking for removal */
|
||||
} u_queuestat;
|
||||
TAILQ_ENTRY(maple_unit) u_q;
|
||||
int u_proberetry; /* retry count (subunit != 0) */
|
||||
#define MAPLE_PROBERETRY_MAX 5
|
||||
};
|
||||
|
||||
struct maple_softc {
|
||||
struct device sc_dev;
|
||||
struct device sc_dev;
|
||||
|
||||
struct callout maple_callout_ch;
|
||||
int maple_commands_pending;
|
||||
struct callout maple_callout_ch;
|
||||
struct proc *event_thread;
|
||||
|
||||
int sc_port_units[MAPLE_PORTS];
|
||||
int sc_port_units_open[MAPLE_PORTS];
|
||||
int8_t sc_port_unit_map[MAPLE_PORTS];
|
||||
int sc_port_units[MAPLE_PORTS];
|
||||
int sc_port_units_open[MAPLE_PORTS];
|
||||
|
||||
struct maple_unit sc_unit[MAPLE_PORTS][MAPLE_SUBUNITS];
|
||||
|
||||
|
@ -48,10 +178,15 @@ struct maple_softc {
|
|||
u_int32_t *sc_txpos; /* current write position in tx buffer */
|
||||
u_int32_t *sc_txlink; /* start of last written frame */
|
||||
|
||||
/* start of each receive buffer */
|
||||
u_int32_t *sc_rxbuf[MAPLE_PORTS][MAPLE_SUBUNITS];
|
||||
|
||||
u_int32_t sc_txbuf_phys; /* 29-bit physical address */
|
||||
u_int32_t sc_rxbuf_phys[MAPLE_PORTS][MAPLE_SUBUNITS];
|
||||
};
|
||||
|
||||
void *sc_intrhand;
|
||||
int sc_dmadone; /* wchan */
|
||||
|
||||
int sc_event; /* periodic event is active / wchan */
|
||||
|
||||
SIMPLEQ_HEAD(maple_dmaq_head, maple_unit) sc_dmaq, sc_retryq;
|
||||
TAILQ_HEAD(maple_unitq_head, maple_unit) sc_probeq, sc_pingq;
|
||||
TAILQ_HEAD(maple_fnq_head, maple_func) sc_periodicq, sc_periodicdeferq;
|
||||
TAILQ_HEAD(maple_cmdq_head, maple_func) sc_acmdq, sc_pcmdq;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkbd.c,v 1.16 2002/10/02 15:45:16 thorpej Exp $ */
|
||||
/* $NetBSD: mkbd.c,v 1.17 2002/11/15 13:30:21 itohy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Marcus Comstedt
|
||||
|
@ -61,6 +61,7 @@
|
|||
*/
|
||||
static int mkbdmatch(struct device *, struct cfdata *, void *);
|
||||
static void mkbdattach(struct device *, struct device *, void *);
|
||||
static int mkbddetach(struct device *, int);
|
||||
|
||||
int mkbd_enable(void *, int);
|
||||
void mkbd_set_leds(void *, int);
|
||||
|
@ -72,7 +73,7 @@ struct wskbd_accessops mkbd_accessops = {
|
|||
mkbd_ioctl,
|
||||
};
|
||||
|
||||
static void mkbd_intr(struct mkbd_softc *, struct mkbd_condition *, int);
|
||||
static void mkbd_intr(void *, struct maple_response *, int, int);
|
||||
|
||||
void mkbd_cngetc(void *, u_int *, int *);
|
||||
void mkbd_cnpollc(void *, int);
|
||||
|
@ -88,19 +89,20 @@ struct wskbd_mapdata mkbd_keymapdata = {
|
|||
KB_JP,
|
||||
};
|
||||
|
||||
static struct mkbd_softc *mkbd_console_softc = NULL;
|
||||
static struct mkbd_softc *mkbd_console_softc;
|
||||
|
||||
static int mkbd_console_initted = 0;
|
||||
static int mkbd_is_console;
|
||||
static int mkbd_console_initted;
|
||||
|
||||
CFATTACH_DECL(mkbd, sizeof(struct mkbd_softc),
|
||||
mkbdmatch, mkbdattach, NULL, NULL);
|
||||
mkbdmatch, mkbdattach, mkbddetach, NULL);
|
||||
|
||||
static int
|
||||
mkbdmatch(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct maple_attach_args *ma = aux;
|
||||
|
||||
return ((ma->ma_function & MAPLE_FUNC_KEYBOARD) != 0);
|
||||
return (ma->ma_function == MAPLE_FN_KEYBOARD ? MAPLE_MATCH_FUNC : 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -114,11 +116,10 @@ mkbdattach(struct device *parent, struct device *self, void *aux)
|
|||
u_int32_t kbdtype;
|
||||
|
||||
sc->sc_parent = parent;
|
||||
sc->sc_port = ma->ma_port;
|
||||
sc->sc_subunit = ma->ma_subunit;
|
||||
sc->sc_unit = ma->ma_unit;
|
||||
|
||||
kbdtype = maple_get_function_data(ma->ma_devinfo,
|
||||
MAPLE_FUNC_KEYBOARD) >> 24;
|
||||
MAPLE_FN_KEYBOARD) >> 24;
|
||||
switch (kbdtype) {
|
||||
case 1:
|
||||
printf(": Japanese keyboard");
|
||||
|
@ -138,21 +139,45 @@ mkbdattach(struct device *parent, struct device *self, void *aux)
|
|||
printf("\n");
|
||||
|
||||
#if NWSKBD > 0
|
||||
a.console = ((sc->sc_dev.dv_unit == 0) && (mkbd_console_initted == 1))
|
||||
? 1 : 0;
|
||||
if ((a.console = mkbd_is_console) != 0) {
|
||||
mkbd_is_console = 0;
|
||||
if (!mkbd_console_initted)
|
||||
wskbd_cnattach(&mkbd_consops, NULL, &mkbd_keymapdata);
|
||||
mkbd_console_softc = sc;
|
||||
}
|
||||
a.keymap = &mkbd_keymapdata;
|
||||
a.accessops = &mkbd_accessops;
|
||||
a.accesscookie = sc;
|
||||
if (a.console)
|
||||
mkbd_console_softc = sc;
|
||||
sc->sc_wskbddev = config_found(self, &a, wskbddevprint);
|
||||
#endif
|
||||
|
||||
maple_set_condition_callback(parent, sc->sc_port, sc->sc_subunit,
|
||||
MAPLE_FUNC_KEYBOARD,(void (*) (void *, void *, int)) mkbd_intr, sc);
|
||||
maple_set_callback(parent, sc->sc_unit, MAPLE_FN_KEYBOARD,
|
||||
mkbd_intr, sc);
|
||||
maple_enable_periodic(parent, sc->sc_unit, MAPLE_FN_KEYBOARD, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
mkbddetach(struct device *self, int flags)
|
||||
{
|
||||
struct mkbd_softc *sc = (struct mkbd_softc *) self;
|
||||
int rv = 0;
|
||||
|
||||
if (sc == mkbd_console_softc) {
|
||||
/*
|
||||
* Hack to allow another Maple keyboard to be new console.
|
||||
* XXX Should some other type device can be console.
|
||||
*/
|
||||
printf("%s: was console keyboard\n", sc->sc_dev.dv_xname);
|
||||
wskbd_cndetach();
|
||||
mkbd_console_softc = NULL;
|
||||
mkbd_console_initted = 0;
|
||||
mkbd_is_console = 1;
|
||||
}
|
||||
if (sc->sc_wskbddev)
|
||||
rv = config_detach(sc->sc_wskbddev, flags);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
mkbd_enable(void *v, int on)
|
||||
|
@ -193,6 +218,7 @@ mkbd_cnattach()
|
|||
|
||||
wskbd_cnattach(&mkbd_consops, NULL, &mkbd_keymapdata);
|
||||
mkbd_console_initted = 1;
|
||||
mkbd_is_console = 1;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -221,10 +247,13 @@ extern int maple_polling;
|
|||
#define SHIFT_DOWN(n) KEY_DOWN((n) | SHIFT_KEYCODE_BASE)
|
||||
|
||||
static void
|
||||
mkbd_intr(struct mkbd_softc *sc, struct mkbd_condition *kbddata, int sz)
|
||||
mkbd_intr(void *arg, struct maple_response *response, int sz, int flags)
|
||||
{
|
||||
struct mkbd_softc *sc = arg;
|
||||
struct mkbd_condition *kbddata = (void *) response->data;
|
||||
|
||||
if (sz >= sizeof(struct mkbd_condition)) {
|
||||
if ((flags & MAPLE_FLAG_PERIODIC) &&
|
||||
sz >= sizeof(struct mkbd_condition)) {
|
||||
int i, j, v;
|
||||
|
||||
v = sc->sc_condition.shift & ~kbddata->shift;
|
||||
|
@ -259,7 +288,7 @@ mkbd_intr(struct mkbd_softc *sc, struct mkbd_condition *kbddata, int sz)
|
|||
}
|
||||
|
||||
void
|
||||
mkbd_cngetc(void *v, u_int *type,int *data)
|
||||
mkbd_cngetc(void *v, u_int *type, int *data)
|
||||
{
|
||||
int key;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mkbdvar.h,v 1.3 2002/03/25 18:59:40 uch Exp $ */
|
||||
/* $NetBSD: mkbdvar.h,v 1.4 2002/11/15 13:30:21 itohy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Marcus Comstedt
|
||||
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
struct mkbd_condition {
|
||||
u_int32_t func_code; /* function code (big endian) */
|
||||
u_int8_t shift;
|
||||
u_int8_t led;
|
||||
u_int8_t key[6];
|
||||
|
@ -46,7 +47,7 @@ struct mkbd_softc {
|
|||
struct device *sc_wskbddev;
|
||||
struct device *sc_parent;
|
||||
|
||||
int sc_port, sc_subunit;
|
||||
struct maple_unit *sc_unit;
|
||||
struct mkbd_condition sc_condition;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mms.c,v 1.5 2002/10/02 15:45:17 thorpej Exp $ */
|
||||
/* $NetBSD: mms.c,v 1.6 2002/11/15 13:30:22 itohy Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -50,6 +50,7 @@
|
|||
#include <dreamcast/dev/maple/mapleconf.h>
|
||||
|
||||
struct mms_condition {
|
||||
uint32_t func_code; /* function code (big endian) */
|
||||
uint32_t buttons;
|
||||
uint16_t axis1; /* X */
|
||||
uint16_t axis2; /* Y */
|
||||
|
@ -86,8 +87,7 @@ struct mms_condition {
|
|||
struct mms_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
int sc_port;
|
||||
int sc_subunit;
|
||||
struct maple_unit *sc_unit;
|
||||
|
||||
uint32_t sc_oldbuttons;
|
||||
|
||||
|
@ -96,9 +96,10 @@ struct mms_softc {
|
|||
|
||||
int mms_match(struct device *, struct cfdata *, void *);
|
||||
void mms_attach(struct device *, struct device *, void *);
|
||||
int mms_detach(struct device *, int);
|
||||
|
||||
CFATTACH_DECL(mms, sizeof(struct mms_softc),
|
||||
mms_match, mms_attach, NULL, NULL);
|
||||
mms_match, mms_attach, mms_detach, NULL);
|
||||
|
||||
int mms_enable(void *);
|
||||
int mms_ioctl(void *, u_long, caddr_t, int, struct proc *);
|
||||
|
@ -110,14 +111,14 @@ const struct wsmouse_accessops mms_accessops = {
|
|||
mms_disable,
|
||||
};
|
||||
|
||||
void mms_intr(void *, void *, int);
|
||||
void mms_intr(void *, struct maple_response *, int, int);
|
||||
|
||||
int
|
||||
mms_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct maple_attach_args *ma = aux;
|
||||
|
||||
return ((ma->ma_function & MAPLE_FUNC_MOUSE) != 0);
|
||||
return (ma->ma_function == MAPLE_FN_MOUSE ? MAPLE_MATCH_FUNC : 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -130,11 +131,10 @@ mms_attach(struct device *parent, struct device *self, void *aux)
|
|||
|
||||
printf(": SEGA Dreamcast Mouse\n");
|
||||
|
||||
sc->sc_port = ma->ma_port;
|
||||
sc->sc_subunit = ma->ma_subunit;
|
||||
sc->sc_unit = ma->ma_unit;
|
||||
|
||||
data = maple_get_function_data(ma->ma_devinfo,
|
||||
MAPLE_FUNC_MOUSE);
|
||||
MAPLE_FN_MOUSE);
|
||||
|
||||
printf("%s: buttons:", sc->sc_dev.dv_xname);
|
||||
if (data & MMS_FUNCDATA_A)
|
||||
|
@ -161,8 +161,20 @@ mms_attach(struct device *parent, struct device *self, void *aux)
|
|||
return;
|
||||
}
|
||||
|
||||
maple_set_condition_callback(parent, sc->sc_port, sc->sc_subunit,
|
||||
MAPLE_FUNC_MOUSE, mms_intr, sc);
|
||||
maple_set_callback(parent, sc->sc_unit, MAPLE_FN_MOUSE, mms_intr, sc);
|
||||
maple_enable_periodic(parent, sc->sc_unit, MAPLE_FN_MOUSE, 1);
|
||||
}
|
||||
|
||||
int
|
||||
mms_detach(struct device *self, int flags)
|
||||
{
|
||||
struct mms_softc *sc = (void *) self;
|
||||
int rv = 0;
|
||||
|
||||
if (sc->sc_wsmousedev != NULL)
|
||||
rv = config_detach(sc->sc_wsmousedev, flags);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -200,14 +212,15 @@ mms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
|
|||
}
|
||||
|
||||
void
|
||||
mms_intr(void *arg, void *buf, int size)
|
||||
mms_intr(void *arg, struct maple_response *response, int size, int flags)
|
||||
{
|
||||
struct mms_softc *sc = arg;
|
||||
struct mms_condition *data = buf;
|
||||
struct mms_condition *data = (void *) response->data;
|
||||
int dx = 0, dy = 0, dz = 0, buttons = 0;
|
||||
uint32_t buttonchg;
|
||||
|
||||
if (size < sizeof(*data))
|
||||
if ((flags & MAPLE_FLAG_PERIODIC) == 0 ||
|
||||
size < sizeof(*data))
|
||||
return;
|
||||
|
||||
data->buttons &= MMS_BUTTON_MASK;
|
||||
|
|
Loading…
Reference in New Issue