Add support to talk to the LSI ioctl path on with FreeBSD 32 bit app's

on amd64.  Note the only difference is the iovec32 part so I use the
native structure for everything else.

Also I plan to MFC all the changes in -current to 7-stable and 6-stable
shortly since I've been running them.  This does not include the cam
changes.

MFC after:	3 days
This commit is contained in:
Doug Ambrisko 2008-05-28 23:19:27 +00:00
parent 6076cbacea
commit 46fb79ea72
2 changed files with 62 additions and 0 deletions

View file

@ -2108,6 +2108,9 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, d_thread_t *td)
struct mfi_softc *sc;
union mfi_statrequest *ms;
struct mfi_ioc_packet *ioc;
#ifdef __amd64__
struct mfi_ioc_packet32 *ioc32;
#endif
struct mfi_ioc_aen *aen;
struct mfi_command *cm = NULL;
uint32_t context;
@ -2165,6 +2168,9 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, d_thread_t *td)
break;
}
case MFI_CMD:
#ifdef __amd64__
case MFI_CMD32:
#endif
{
devclass_t devclass;
ioc = (struct mfi_ioc_packet *)arg;
@ -2222,9 +2228,27 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, d_thread_t *td)
temp = data;
if (cm->cm_flags & MFI_CMD_DATAOUT) {
for (i = 0; i < ioc->mfi_sge_count; i++) {
#ifdef __amd64__
if (cmd == MFI_CMD) {
/* Native */
error = copyin(ioc->mfi_sgl[i].iov_base,
temp,
ioc->mfi_sgl[i].iov_len);
} else {
void *temp_convert;
/* 32bit */
ioc32 = (struct mfi_ioc_packet32 *)ioc;
temp_convert =
PTRIN(ioc32->mfi_sgl[i].iov_base);
error = copyin(temp_convert,
temp,
ioc32->mfi_sgl[i].iov_len);
}
#else
error = copyin(ioc->mfi_sgl[i].iov_base,
temp,
ioc->mfi_sgl[i].iov_len);
#endif
if (error != 0) {
device_printf(sc->mfi_dev,
"Copy in failed\n");
@ -2257,9 +2281,27 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, d_thread_t *td)
temp = data;
if (cm->cm_flags & MFI_CMD_DATAIN) {
for (i = 0; i < ioc->mfi_sge_count; i++) {
#ifdef __amd64__
if (cmd == MFI_CMD) {
/* Native */
error = copyout(temp,
ioc->mfi_sgl[i].iov_base,
ioc->mfi_sgl[i].iov_len);
} else {
void *temp_convert;
/* 32bit */
ioc32 = (struct mfi_ioc_packet32 *)ioc;
temp_convert =
PTRIN(ioc32->mfi_sgl[i].iov_base);
error = copyout(temp,
temp_convert,
ioc32->mfi_sgl[i].iov_len);
}
#else
error = copyout(temp,
ioc->mfi_sgl[i].iov_base,
ioc->mfi_sgl[i].iov_len);
#endif
if (error != 0) {
device_printf(sc->mfi_dev,
"Copy out failed\n");

View file

@ -67,6 +67,23 @@ struct mfi_ioc_packet {
struct iovec mfi_sgl[MAX_IOCTL_SGE];
} __packed;
#ifdef __amd64__
struct mfi_ioc_packet32 {
uint16_t mfi_adapter_no;
uint16_t mfi_pad1;
uint32_t mfi_sgl_off;
uint32_t mfi_sge_count;
uint32_t mfi_sense_off;
uint32_t mfi_sense_len;
union {
uint8_t raw[128];
struct mfi_frame_header hdr;
} mfi_frame;
struct iovec32 mfi_sgl[MAX_IOCTL_SGE];
} __packed;
#endif
struct mfi_ioc_aen {
uint16_t aen_adapter_no;
uint16_t aen_pad1;
@ -75,6 +92,9 @@ struct mfi_ioc_aen {
} __packed;
#define MFI_CMD _IOWR('M', 1, struct mfi_ioc_packet)
#ifdef __amd64__
#define MFI_CMD32 _IOWR('M', 1, struct mfi_ioc_packet32)
#endif
#define MFI_SET_AEN _IOW('M', 3, struct mfi_ioc_aen)
#define MAX_LINUX_IOCTL_SGE 16