From d6ef0bf1198dd3bb0f634ba306cf8659519b0c0d Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 17 Dec 2004 17:45:29 +0000 Subject: [PATCH] Recognize the 32-bit form of the twe binary passthrough ioctl()s so that there is some hope for the 32-bit management utilities to run. I've used the cli successfully, but 3dm2 doesn't work for other reasons. Of course, a native binary of the 3dm2 and cli would be much better, but that doesn't exist. --- sys/dev/twe/twe.c | 36 ++++++++++++++++++++++++++++++++++++ sys/dev/twe/tweio.h | 23 +++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/sys/dev/twe/twe.c b/sys/dev/twe/twe.c index 340dab931e64..6ee9db538416 100644 --- a/sys/dev/twe/twe.c +++ b/sys/dev/twe/twe.c @@ -500,9 +500,25 @@ twe_ioctl(struct twe_softc *sc, int ioctlcmd, void *addr) struct twe_request *tr; u_int8_t srid; int s, error; +#ifdef __amd64__ + struct twe_paramcommand32 *tp32 = (struct twe_paramcommand32 *)addr; + struct twe_usercommand32 *tu32 = (struct twe_usercommand32 *)addr; + struct twe_paramcommand tp_swab; + struct twe_usercommand tu_swab; +#endif error = 0; switch(ioctlcmd) { + +#ifdef __amd64__ + case TWEIO_COMMAND32: + tu_swab.tu_command = tu32->tu_command; + tu_swab.tu_data = (void *)(uintptr_t)tu32->tu_data; + tu_swab.tu_size = tu32->tu_size; + tu = &tu_swab; + /* FALLTHROUGH */ +#endif + /* handle a command from userspace */ case TWEIO_COMMAND: /* get a request */ @@ -588,6 +604,16 @@ twe_ioctl(struct twe_softc *sc, int ioctlcmd, void *addr) splx(s); break; +#ifdef __amd64__ + case TWEIO_GET_PARAM32: + tp_swab.tp_table_id = tp32->tp_table_id; + tp_swab.tp_param_id = tp32->tp_param_id; + tp_swab.tp_data = (void *)(uintptr_t)tp32->tp_data; + tp_swab.tp_size = tp32->tp_size; + tp = &tp_swab; + /* FALLTHROUGH */ +#endif + case TWEIO_GET_PARAM: if ((param = twe_get_param(sc, tp->tp_table_id, tp->tp_param_id, tp->tp_size, NULL)) == NULL) { twe_printf(sc, "TWEIO_GET_PARAM failed for 0x%x/0x%x/%d\n", @@ -605,6 +631,16 @@ twe_ioctl(struct twe_softc *sc, int ioctlcmd, void *addr) } break; +#ifdef __amd64__ + case TWEIO_SET_PARAM32: + tp_swab.tp_table_id = tp32->tp_table_id; + tp_swab.tp_param_id = tp32->tp_param_id; + tp_swab.tp_data = (void *)(uintptr_t)tp32->tp_data; + tp_swab.tp_size = tp32->tp_size; + tp = &tp_swab; + /* FALLTHROUGH */ +#endif + case TWEIO_SET_PARAM: if ((data = malloc(tp->tp_size, M_DEVBUF, M_WAITOK)) == NULL) { error = ENOMEM; diff --git a/sys/dev/twe/tweio.h b/sys/dev/twe/tweio.h index 1b78472495ab..43f707b52213 100644 --- a/sys/dev/twe/tweio.h +++ b/sys/dev/twe/tweio.h @@ -44,6 +44,17 @@ struct twe_usercommand { #define TWEIO_COMMAND _IOWR('T', 100, struct twe_usercommand) +#ifdef __amd64__ +struct twe_usercommand32 { + TWE_Command tu_command; /* command ready for the controller */ + uint32_t tu_data; /* pointer to data in userspace */ + uint32_t tu_size; /* userspace data length */ +}; + +#define TWEIO_COMMAND32 _IOWR('T', 100, struct twe_usercommand32) +#endif + + /* * Command queue statistics */ @@ -89,6 +100,18 @@ struct twe_paramcommand { #define TWEIO_SET_PARAM _IOW ('T', 104, struct twe_paramcommand) #define TWEIO_GET_PARAM _IOW ('T', 105, struct twe_paramcommand) +#ifdef __amd64__ +struct twe_paramcommand32 { + u_int16_t tp_table_id; + u_int8_t tp_param_id; + u_int32_t tp_data; + u_int8_t tp_size; +}; + +#define TWEIO_SET_PARAM32 _IOW ('T', 104, struct twe_paramcommand32) +#define TWEIO_GET_PARAM32 _IOW ('T', 105, struct twe_paramcommand32) +#endif + /* * Request a controller soft-reset */