Add some ioctls for harddisk, floppy disk and console handling.

Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
This commit is contained in:
fvdl 2000-12-10 14:12:16 +00:00
parent e772d7a6d5
commit a499e56944
9 changed files with 926 additions and 116 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_cdrom.c,v 1.5 1999/10/29 15:02:56 mycroft Exp $ */ /* $NetBSD: linux_cdrom.c,v 1.6 2000/12/10 14:12:16 fvdl Exp $ */
/* /*
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -53,12 +53,39 @@
#include <compat/linux/linux_syscallargs.h> #include <compat/linux/linux_syscallargs.h>
static int bsd_to_linux_msf_lba(unsigned address_format, union msf_lba *bml,
union linux_cdrom_addr *llml);
#if 0 #if 0
#define DPRINTF(x) printf x #define DPRINTF(x) printf x
#else #else
#define DPRINTF(x) #define DPRINTF(x)
#endif #endif
/*
* XXX from dev/scsipi/cd.c
*/
#define MAXTRACK 99
static int
bsd_to_linux_msf_lba(unsigned address_format, union msf_lba *bml,
union linux_cdrom_addr *llml)
{
switch (address_format) {
case CD_LBA_FORMAT:
llml->lba = bml->lba;
break;
case CD_MSF_FORMAT:
llml->msf.minute = bml->msf.minute;
llml->msf.second = bml->msf.second;
llml->msf.frame = bml->msf.frame;
break;
default:
return -1;
}
return 0;
}
int int
linux_ioctl_cdrom(p, uap, retval) linux_ioctl_cdrom(p, uap, retval)
struct proc *p; struct proc *p;
@ -83,6 +110,7 @@ linux_ioctl_cdrom(p, uap, retval)
struct linux_cdrom_tocentry l_tocentry; struct linux_cdrom_tocentry l_tocentry;
struct linux_cdrom_subchnl l_subchnl; struct linux_cdrom_subchnl l_subchnl;
struct linux_cdrom_volctrl l_volctrl; struct linux_cdrom_volctrl l_volctrl;
struct linux_cdrom_multisession l_session;
struct ioc_play_blocks t_blocks; struct ioc_play_blocks t_blocks;
struct ioc_play_msf t_msf; struct ioc_play_msf t_msf;
@ -99,18 +127,21 @@ linux_ioctl_cdrom(p, uap, retval)
fdp = p->p_fd; fdp = p->p_fd;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL ||
(fp->f_iflags & FIF_WANTCLOSE) != 0)
return (EBADF); return (EBADF);
FILE_USE(fp);
com = SCARG(uap, com); com = SCARG(uap, com);
ioctlf = fp->f_ops->fo_ioctl; ioctlf = fp->f_ops->fo_ioctl;
retval[0] = 0; retval[0] = error = 0;
switch(com) { switch(com) {
case LINUX_CDROMPLAYMSF: case LINUX_CDROMPLAYMSF:
error = copyin(SCARG(uap, data), &l_msf, sizeof l_msf); error = copyin(SCARG(uap, data), &l_msf, sizeof l_msf);
if (error) if (error)
return error; break;
t_msf.start_m = l_msf.cdmsf_min0; t_msf.start_m = l_msf.cdmsf_min0;
t_msf.start_s = l_msf.cdmsf_sec0; t_msf.start_s = l_msf.cdmsf_sec0;
@ -119,35 +150,38 @@ linux_ioctl_cdrom(p, uap, retval)
t_msf.end_s = l_msf.cdmsf_sec1; t_msf.end_s = l_msf.cdmsf_sec1;
t_msf.end_f = l_msf.cdmsf_frame1; t_msf.end_f = l_msf.cdmsf_frame1;
return ioctlf(fp, CDIOCPLAYMSF, (caddr_t)&t_msf, p); error = ioctlf(fp, CDIOCPLAYMSF, (caddr_t)&t_msf, p);
break;
case LINUX_CDROMPLAYTRKIND: case LINUX_CDROMPLAYTRKIND:
error = copyin(SCARG(uap, data), &l_ti, sizeof l_ti); error = copyin(SCARG(uap, data), &l_ti, sizeof l_ti);
if (error) if (error)
return error; break;
t_track.start_track = l_ti.cdti_trk0; t_track.start_track = l_ti.cdti_trk0;
t_track.start_index = l_ti.cdti_ind0; t_track.start_index = l_ti.cdti_ind0;
t_track.end_track = l_ti.cdti_trk1; t_track.end_track = l_ti.cdti_trk1;
t_track.end_index = l_ti.cdti_ind1; t_track.end_index = l_ti.cdti_ind1;
return ioctlf(fp, CDIOCPLAYTRACKS, (caddr_t)&t_track, p); error = ioctlf(fp, CDIOCPLAYTRACKS, (caddr_t)&t_track, p);
break;
case LINUX_CDROMREADTOCHDR: case LINUX_CDROMREADTOCHDR:
error = ioctlf(fp, CDIOREADTOCHEADER, (caddr_t)&t_header, p); error = ioctlf(fp, CDIOREADTOCHEADER, (caddr_t)&t_header, p);
if (error) if (error)
return error; break;
l_tochdr.cdth_trk0 = t_header.starting_track; l_tochdr.cdth_trk0 = t_header.starting_track;
l_tochdr.cdth_trk1 = t_header.ending_track; l_tochdr.cdth_trk1 = t_header.ending_track;
return copyout(&l_tochdr, SCARG(uap, data), sizeof l_tochdr); error = copyout(&l_tochdr, SCARG(uap, data), sizeof l_tochdr);
break;
case LINUX_CDROMREADTOCENTRY: case LINUX_CDROMREADTOCENTRY:
error = copyin(SCARG(uap, data), &l_tocentry, error = copyin(SCARG(uap, data), &l_tocentry,
sizeof l_tocentry); sizeof l_tocentry);
if (error) if (error)
return error; break;
sg = stackgap_init(p->p_emul); sg = stackgap_init(p->p_emul);
entry = stackgap_alloc(&sg, sizeof *entry); entry = stackgap_alloc(&sg, sizeof *entry);
@ -156,65 +190,58 @@ linux_ioctl_cdrom(p, uap, retval)
t_toc_entry.data_len = sizeof *entry; t_toc_entry.data_len = sizeof *entry;
t_toc_entry.data = entry; t_toc_entry.data = entry;
error = ioctlf(fp, CDIOREADTOCENTRYS, (caddr_t)&t_toc_entry, error = ioctlf(fp, CDIOREADTOCENTRIES, (caddr_t)&t_toc_entry,
p); p);
if (error) if (error)
return error; break;
error = copyin(entry, &t_entry, sizeof t_entry); error = copyin(entry, &t_entry, sizeof t_entry);
if (error) if (error)
return error; break;
l_tocentry.cdte_adr = t_entry.addr_type; l_tocentry.cdte_adr = t_entry.addr_type;
l_tocentry.cdte_ctrl = t_entry.control; l_tocentry.cdte_ctrl = t_entry.control;
switch (t_toc_entry.address_format) { if (bsd_to_linux_msf_lba(t_entry.addr_type, &t_entry.addr,
case CD_LBA_FORMAT: &l_tocentry.cdte_addr) < 0) {
l_tocentry.cdte_addr.lba = t_entry.addr.lba;
break;
case CD_MSF_FORMAT:
l_tocentry.cdte_addr.msf.minute =
t_entry.addr.msf.minute;
l_tocentry.cdte_addr.msf.second =
t_entry.addr.msf.second;
l_tocentry.cdte_addr.msf.frame =
t_entry.addr.msf.frame;
break;
default:
printf("linux_ioctl: unknown format msf/lba\n"); printf("linux_ioctl: unknown format msf/lba\n");
return EINVAL; error = EINVAL;
break;
} }
return copyout(&l_tocentry, SCARG(uap, data), error = copyout(&l_tocentry, SCARG(uap, data),
sizeof l_tocentry); sizeof l_tocentry);
break;
case LINUX_CDROMVOLCTRL: case LINUX_CDROMVOLCTRL:
error = copyin(SCARG(uap, data), &l_volctrl, sizeof l_volctrl); error = copyin(SCARG(uap, data), &l_volctrl, sizeof l_volctrl);
if (error) if (error)
return error; break;
t_vol.vol[0] = l_volctrl.channel0; t_vol.vol[0] = l_volctrl.channel0;
t_vol.vol[1] = l_volctrl.channel1; t_vol.vol[1] = l_volctrl.channel1;
t_vol.vol[2] = l_volctrl.channel2; t_vol.vol[2] = l_volctrl.channel2;
t_vol.vol[3] = l_volctrl.channel3; t_vol.vol[3] = l_volctrl.channel3;
return ioctlf(fp, CDIOCSETVOL, (caddr_t)&t_vol, p); error = ioctlf(fp, CDIOCSETVOL, (caddr_t)&t_vol, p);
break;
case LINUX_CDROMVOLREAD: case LINUX_CDROMVOLREAD:
error = ioctlf(fp, CDIOCGETVOL, (caddr_t)&t_vol, p); error = ioctlf(fp, CDIOCGETVOL, (caddr_t)&t_vol, p);
if (error) if (error)
return error; break;
l_volctrl.channel0 = t_vol.vol[0]; l_volctrl.channel0 = t_vol.vol[0];
l_volctrl.channel1 = t_vol.vol[1]; l_volctrl.channel1 = t_vol.vol[1];
l_volctrl.channel2 = t_vol.vol[2]; l_volctrl.channel2 = t_vol.vol[2];
l_volctrl.channel3 = t_vol.vol[3]; l_volctrl.channel3 = t_vol.vol[3];
return copyout(&l_volctrl, SCARG(uap, data), sizeof l_volctrl); error = copyout(&l_volctrl, SCARG(uap, data), sizeof l_volctrl);
break;
case LINUX_CDROMSUBCHNL: case LINUX_CDROMSUBCHNL:
error = copyin(SCARG(uap, data), &l_subchnl, sizeof l_subchnl); error = copyin(SCARG(uap, data), &l_subchnl, sizeof l_subchnl);
if (error) if (error)
return error; break;
sg = stackgap_init(p->p_emul); sg = stackgap_init(p->p_emul);
info = stackgap_alloc(&sg, sizeof *info); info = stackgap_alloc(&sg, sizeof *info);
@ -229,153 +256,191 @@ linux_ioctl_cdrom(p, uap, retval)
error = ioctlf(fp, CDIOCREADSUBCHANNEL, (caddr_t)&t_subchannel, error = ioctlf(fp, CDIOCREADSUBCHANNEL, (caddr_t)&t_subchannel,
p); p);
if (error) if (error)
return error; break;
error = copyin(info, &t_info, sizeof t_info); error = copyin(info, &t_info, sizeof t_info);
if (error) if (error)
return error; break;
l_subchnl.cdsc_audiostatus = t_info.header.audio_status; l_subchnl.cdsc_audiostatus = t_info.header.audio_status;
l_subchnl.cdsc_adr = t_info.what.position.addr_type; l_subchnl.cdsc_adr = t_info.what.position.addr_type;
l_subchnl.cdsc_ctrl = t_info.what.position.control; l_subchnl.cdsc_ctrl = t_info.what.position.control;
l_subchnl.cdsc_ind = t_info.what.position.index_number; l_subchnl.cdsc_ind = t_info.what.position.index_number;
DPRINTF(("linux_ioctl: CDIOCREADSUBCHANNEL %d %d %d\n", DPRINTF(("linux_ioctl: CDIOCREADSUBCHANNEL %d %d %d\n",
t_info.header.audio_status, t_info.header.audio_status,
t_info.header.data_len[0], t_info.header.data_len[0],
t_info.header.data_len[1])); t_info.header.data_len[1]));
DPRINTF(("(more) %d %d %d %d %d\n", DPRINTF(("(more) %d %d %d %d %d\n",
t_info.what.position.data_format, t_info.what.position.data_format,
t_info.what.position.control, t_info.what.position.control,
t_info.what.position.addr_type, t_info.what.position.addr_type,
t_info.what.position.track_number, t_info.what.position.track_number,
t_info.what.position.index_number)); t_info.what.position.index_number));
switch (t_subchannel.address_format) { if (bsd_to_linux_msf_lba(t_subchannel.address_format,
case CD_LBA_FORMAT: &t_info.what.position.absaddr,
l_subchnl.cdsc_absaddr.lba = &l_subchnl.cdsc_absaddr) < 0 ||
t_info.what.position.absaddr.lba; bsd_to_linux_msf_lba(t_subchannel.address_format,
l_subchnl.cdsc_reladdr.lba = &t_info.what.position.reladdr,
t_info.what.position.reladdr.lba; &l_subchnl.cdsc_reladdr) < 0) {
DPRINTF(("LBA: %d %d\n", DPRINTF(("linux_ioctl: unknown format msf/lba\n"));
t_info.what.position.absaddr.lba, error = EINVAL;
t_info.what.position.reladdr.lba)); break;
break; }
case CD_MSF_FORMAT: error = copyout(&l_subchnl, SCARG(uap, data), sizeof l_subchnl);
l_subchnl.cdsc_absaddr.msf.minute = break;
t_info.what.position.absaddr.msf.minute;
l_subchnl.cdsc_absaddr.msf.second =
t_info.what.position.absaddr.msf.second;
l_subchnl.cdsc_absaddr.msf.frame =
t_info.what.position.absaddr.msf.frame;
l_subchnl.cdsc_reladdr.msf.minute =
t_info.what.position.reladdr.msf.minute;
l_subchnl.cdsc_reladdr.msf.second =
t_info.what.position.reladdr.msf.second;
l_subchnl.cdsc_reladdr.msf.frame =
t_info.what.position.reladdr.msf.frame;
DPRINTF(("MSF: %d %d %d %d\n",
t_info.what.position.absaddr.msf.minute,
t_info.what.position.absaddr.msf.second,
t_info.what.position.reladdr.msf.minute,
t_info.what.position.reladdr.msf.second));
break;
default:
DPRINTF(("linux_ioctl: unknown format msf/lba\n"));
return EINVAL;
}
return copyout(&l_subchnl, SCARG(uap, data), sizeof l_subchnl);
case LINUX_CDROMPLAYBLK: case LINUX_CDROMPLAYBLK:
error = copyin(SCARG(uap, data), &l_blk, sizeof l_blk); error = copyin(SCARG(uap, data), &l_blk, sizeof l_blk);
if (error) if (error)
return error; break;
t_blocks.blk = l_blk.from; t_blocks.blk = l_blk.from;
t_blocks.len = l_blk.len; t_blocks.len = l_blk.len;
return ioctlf(fp, CDIOCPLAYBLOCKS, (caddr_t)&t_blocks, p); error = ioctlf(fp, CDIOCPLAYBLOCKS, (caddr_t)&t_blocks, p);
break;
case LINUX_CDROMEJECT_SW: case LINUX_CDROMEJECT_SW:
error = copyin(SCARG(uap, data), &idata, sizeof idata); error = copyin(SCARG(uap, data), &idata, sizeof idata);
if (error) if (error)
return error; break;
if (idata == 1) if (idata == 1)
ncom = CDIOCALLOW; ncom = CDIOCALLOW;
else else
ncom = CDIOCPREVENT; ncom = CDIOCPREVENT;
error = ioctlf(fp, ncom, NULL, p);
break; break;
case LINUX_CDROMPAUSE: case LINUX_CDROMPAUSE:
ncom = CDIOCPAUSE; error = ioctlf(fp, CDIOCPAUSE, NULL, p);
break; break;
case LINUX_CDROMRESUME: case LINUX_CDROMRESUME:
ncom = CDIOCRESUME; error = ioctlf(fp, CDIOCRESUME, NULL, p);
break; break;
case LINUX_CDROMSTOP: case LINUX_CDROMSTOP:
ncom = CDIOCSTOP; error = ioctlf(fp, CDIOCSTOP, NULL, p);
break; break;
case LINUX_CDROMSTART: case LINUX_CDROMSTART:
ncom = CDIOCSTART; error = ioctlf(fp, CDIOCSTART, NULL, p);
break; break;
case LINUX_CDROMEJECT: case LINUX_CDROMEJECT:
ncom = CDIOCEJECT; error = ioctlf(fp, CDIOCEJECT, NULL, p);
break; break;
case LINUX_CDROMRESET: case LINUX_CDROMRESET:
ncom = CDIOCRESET; error = ioctlf(fp, CDIOCRESET, NULL, p);
break;
case LINUX_CDROMMULTISESSION:
error = copyin(SCARG(uap, data), &l_session, sizeof l_session);
if (error)
break;
error = ioctlf(fp, CDIOREADTOCHEADER, (caddr_t)&t_header, p);
if (error)
break;
sg = stackgap_init(p->p_emul);
entry = stackgap_alloc(&sg, sizeof *entry);
t_toc_entry.address_format = l_session.addr_format;
t_toc_entry.starting_track = 0;
t_toc_entry.data_len = sizeof *entry;
t_toc_entry.data = entry;
error = ioctlf(fp, CDIOREADTOCENTRIES,
(caddr_t)&t_toc_entry, p);
if (error)
break;
error = copyin(entry, &t_entry, sizeof t_entry);
if (error)
break;
if (bsd_to_linux_msf_lba(l_session.addr_format,
&t_entry.addr, &l_session.addr) < 0) {
error = EINVAL;
break;
}
l_session.xa_flag =
t_header.starting_track != t_header.ending_track;
error = copyout(&l_session, SCARG(uap, data), sizeof l_session);
break;
case LINUX_CDROMCLOSETRAY:
error = ioctlf(fp, CDIOCCLOSE, NULL, p);
break;
case LINUX_CDROM_LOCKDOOR:
ncom = SCARG(uap, data) != 0 ? CDIOCPREVENT : CDIOCALLOW;
error = ioctlf(fp, ncom, NULL, p);
break;
case LINUX_CDROM_SET_OPTIONS:
case LINUX_CDROM_CLEAR_OPTIONS:
/* whatever you say */
break;
case LINUX_CDROM_DEBUG:
ncom = SCARG(uap, data) != 0 ? CDIOCSETDEBUG : CDIOCCLRDEBUG;
error = ioctlf(fp, ncom, NULL, p);
break;
case LINUX_CDROM_SELECT_SPEED:
case LINUX_CDROM_SELECT_DISC:
case LINUX_CDROM_MEDIA_CHANGED:
case LINUX_CDROM_DRIVE_STATUS:
case LINUX_CDROM_DISC_STATUS:
case LINUX_CDROM_CHANGER_NSLOTS:
case LINUX_CDROM_GET_CAPABILITY:
error = EINVAL;
break; break;
case LINUX_DVD_READ_STRUCT: case LINUX_DVD_READ_STRUCT:
error = copyin(SCARG(uap, data), &ds, sizeof ds); error = copyin(SCARG(uap, data), &ds, sizeof ds);
if (error) if (error)
return (error); break;
error = ioctlf(fp, DVD_READ_STRUCT, (caddr_t)&ds, p); error = ioctlf(fp, DVD_READ_STRUCT, (caddr_t)&ds, p);
if (error) if (error)
return (error); break;
error = copyout(&ds, SCARG(uap, data), sizeof ds); error = copyout(&ds, SCARG(uap, data), sizeof ds);
if (error) break;
return (error);
return (0);
case LINUX_DVD_WRITE_STRUCT: case LINUX_DVD_WRITE_STRUCT:
error = copyin(SCARG(uap, data), &ds, sizeof ds); error = copyin(SCARG(uap, data), &ds, sizeof ds);
if (error) if (error)
return (error); break;
error = ioctlf(fp, DVD_WRITE_STRUCT, (caddr_t)&ds, p); error = ioctlf(fp, DVD_WRITE_STRUCT, (caddr_t)&ds, p);
if (error) if (error)
return (error); break;
error = copyout(&ds, SCARG(uap, data), sizeof ds); error = copyout(&ds, SCARG(uap, data), sizeof ds);
if (error) break;
return (error);
return (0);
case LINUX_DVD_AUTH: case LINUX_DVD_AUTH:
error = copyin(SCARG(uap, data), &dai, sizeof dai); error = copyin(SCARG(uap, data), &dai, sizeof dai);
if (error) if (error)
return (error); break;
error = ioctlf(fp, DVD_AUTH, (caddr_t)&dai, p); error = ioctlf(fp, DVD_AUTH, (caddr_t)&dai, p);
if (error) if (error)
return (error); break;
error = copyout(&dai, SCARG(uap, data), sizeof dai); error = copyout(&dai, SCARG(uap, data), sizeof dai);
if (error) break;
return (error);
return (0);
default: default:
DPRINTF(("linux_ioctl: unimplemented ioctl %08lx\n", com)); DPRINTF(("linux_ioctl: unimplemented ioctl %08lx\n", com));
return EINVAL; error = EINVAL;
} }
return ioctlf(fp, ncom, NULL, p); FILE_UNUSE(fp, p);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_cdrom.h,v 1.4 1999/10/29 15:02:56 mycroft Exp $ */ /* $NetBSD: linux_cdrom.h,v 1.5 2000/12/10 14:12:16 fvdl Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -39,6 +39,8 @@
#ifndef _LINUX_CDROM_H #ifndef _LINUX_CDROM_H
#define _LINUX_CDROM_H #define _LINUX_CDROM_H
#include <machine/endian.h>
#define LINUX_CDROMPAUSE 0x5301 #define LINUX_CDROMPAUSE 0x5301
#define LINUX_CDROMRESUME 0x5302 #define LINUX_CDROMRESUME 0x5302
#define LINUX_CDROMPLAYMSF 0x5303 /* (struct linux_cdrom_msf) */ #define LINUX_CDROMPLAYMSF 0x5303 /* (struct linux_cdrom_msf) */
@ -51,9 +53,22 @@
#define LINUX_CDROMVOLCTRL 0x530a /* (struct linux_cdrom_volctrl) */ #define LINUX_CDROMVOLCTRL 0x530a /* (struct linux_cdrom_volctrl) */
#define LINUX_CDROMSUBCHNL 0x530b /* (struct linux_cdrom_subchnl) */ #define LINUX_CDROMSUBCHNL 0x530b /* (struct linux_cdrom_subchnl) */
#define LINUX_CDROMEJECT_SW 0x530f /* arg: 0 or 1 */ #define LINUX_CDROMEJECT_SW 0x530f /* arg: 0 or 1 */
#define LINUX_CDROMMULTISESSION 0x5310 /* (struct linux_cdrom_multisession) */
#define LINUX_CDROMRESET 0x5312 #define LINUX_CDROMRESET 0x5312
#define LINUX_CDROMVOLREAD 0x5313 /* (struct linux_cdrom_volctrl) */ #define LINUX_CDROMVOLREAD 0x5313 /* (struct linux_cdrom_volctrl) */
#define LINUX_CDROMPLAYBLK 0x5317 /* (struct linux_cdrom_blk) */ #define LINUX_CDROMPLAYBLK 0x5317 /* (struct linux_cdrom_blk) */
#define LINUX_CDROMCLOSETRAY 0x5319 /* */
#define LINUX_CDROM_SET_OPTIONS 0x5320 /* int */
#define LINUX_CDROM_CLEAR_OPTIONS 0x5321 /* int */
#define LINUX_CDROM_SELECT_SPEED 0x5322
#define LINUX_CDROM_SELECT_DISC 0x5323
#define LINUX_CDROM_MEDIA_CHANGED 0x5325
#define LINUX_CDROM_DRIVE_STATUS 0x5326
#define LINUX_CDROM_DISC_STATUS 0x5327
#define LINUX_CDROM_CHANGER_NSLOTS 0x5328
#define LINUX_CDROM_LOCKDOOR 0x5329
#define LINUX_CDROM_DEBUG 0x5330
#define LINUX_CDROM_GET_CAPABILITY 0x5331
/* DVD-ROM Specific ioctls */ /* DVD-ROM Specific ioctls */
#define LINUX_DVD_READ_STRUCT 0x5390 /* Read structure */ #define LINUX_DVD_READ_STRUCT 0x5390 /* Read structure */
@ -124,4 +139,51 @@ struct linux_cdrom_volctrl {
u_char channel3; u_char channel3;
}; };
struct linux_cdrom_multisession {
union linux_cdrom_addr addr;
u_char xa_flag;
u_char addr_format;
};
struct linux_cdrom_mechstat_header {
#if BYTE_ORDER == BIG_ENDIAN
u_int8_t fault : 1;
u_int8_t changer_state : 2;
u_int8_t curslot : 5;
u_int8_t mech_state : 3;
u_int8_t door_open : 1;
u_int8_t reserved1 : 4;
#elif BYTE_ORDER == LITTLE_ENDIAN
u_int8_t curslot : 5;
u_int8_t changer_state : 2;
u_int8_t fault : 1;
u_int8_t reserved1 : 4;
u_int8_t door_open : 1;
u_int8_t mech_state : 3;
#endif
u_int8_t curlba[3];
u_int8_t nslots;
u_int16_t slot_tablelen;
};
struct linux_cdrom_slot {
#if BYTE_ORDER == BIG_ENDIAN
u_int8_t disc_present : 1;
u_int8_t reserved1 : 6;
u_int8_t change : 1;
#elif BYTE_ORDER == LITTLE_ENDIAN
u_int8_t change : 1;
u_int8_t reserved1 : 6;
u_int8_t disc_present : 1;
#endif
u_int8_t reserved2[3];
};
#define LINUX_CDROM_MAX_SLOTS 256
struct linux_cdrom_changer_info {
struct linux_cdrom_mechstat_header hdr;
struct linux_cdrom_slot slots[LINUX_CDROM_MAX_SLOTS];
};
#endif /* !_LINUX_CDROM_H */ #endif /* !_LINUX_CDROM_H */

View File

@ -0,0 +1,172 @@
/* $NetBSD: linux_fdio.c,v 1.1 2000/12/10 14:12:16 fvdl Exp $ */
/*
* Copyright (c) 2000 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden for Wasabi Systems, Inc.
*
* 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 for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/disklabel.h>
#include <sys/fdio.h>
#include <sys/syscallargs.h>
#include <dev/isa/fdreg.h>
#include <compat/linux/common/linux_types.h>
#include <compat/linux/common/linux_ioctl.h>
#include <compat/linux/common/linux_signal.h>
#include <compat/linux/common/linux_util.h>
#include <compat/linux/common/linux_fdio.h>
#include <compat/linux/linux_syscallargs.h>
int
linux_ioctl_fdio(struct proc *p, struct linux_sys_ioctl_args *uap,
register_t *retval)
{
struct filedesc *fdp;
struct file *fp;
int error;
int (*ioctlf) __P((struct file *, u_long, caddr_t, struct proc *));
u_long com;
struct fdformat_parms fparams;
struct linux_floppy_struct lflop;
struct linux_floppy_drive_struct ldrive;
com = (u_long)SCARG(uap, data);
fdp = p->p_fd;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL ||
(fp->f_iflags & FIF_WANTCLOSE) != 0)
return (EBADF);
FILE_USE(fp);
com = SCARG(uap, com);
ioctlf = fp->f_ops->fo_ioctl;
retval[0] = error = 0;
switch (com) {
case LINUX_FDMSGON:
case LINUX_FDMSGOFF:
case LINUX_FDTWADDLE:
case LINUX_FDCLRPRM:
/* whatever you say */
break;
case LINUX_FDPOLLDRVSTAT:
/*
* Just fill in some innocent defaults.
*/
memset(&ldrive, 0, sizeof ldrive);
ldrive.fd_ref = 1;
ldrive.maxblock = 2;
ldrive.maxtrack = ldrive.track = 1;
ldrive.flags = LINUX_FD_DISK_WRITABLE;
error = copyout(&ldrive, SCARG(uap, data), sizeof ldrive);
break;
case LINUX_FDGETPRM:
error = ioctlf(fp, FDIOCGETFORMAT, (caddr_t)&fparams, p);
if (error != 0)
break;
lflop.size = fparams.ncyl * fparams.nspt * fparams.ntrk;
lflop.sect = fparams.nspt;
lflop.head = fparams.ntrk;
lflop.track = fparams.ncyl;
lflop.stretch = fparams.stepspercyl == 2 ? 1 : 0;
lflop.fmt_gap = fparams.gaplen;
/*
* XXXX Use knowledge of floppy for these fields.
* FDIOCGETFORMAT does not provide enough information.
* It would be better to have FDIOCGETFORMAT return more
* information.
*/
switch (fparams.xfer_rate) {
case 500 * 1024:
lflop.spec1 = 0xcf;
lflop.gap = 0x1b;
lflop.rate = FDC_500KBPS;
break;
case 300 * 1024:
lflop.spec1 = 0xdf;
lflop.gap = 0x23;
lflop.rate = FDC_300KBPS;
break;
case 250 * 1024:
lflop.spec1 = 0xdf;
lflop.gap = 0x2a;
lflop.rate = FDC_250KBPS;
break;
}
error = copyout(&lflop, SCARG(uap, data), sizeof lflop);
break;
case LINUX_FDSETPRM:
/*
* Should use FDIOCSETFORMAT here, iff its interface
* is extended.
*/
case LINUX_FDDEFPRM:
case LINUX_FDFMTBEG:
case LINUX_FDFMTTRK:
case LINUX_FDFMTEND:
case LINUX_FDSETEMSGTRESH:
case LINUX_FDFLUSH:
case LINUX_FDSETMAXERRS:
case LINUX_FDGETMAXERRS:
case LINUX_FDGETDRVTYP:
case LINUX_FDSETDRVPRM:
case LINUX_FDGETDRVPRM:
case LINUX_FDGETDRVSTAT:
case LINUX_FDRESET:
case LINUX_FDGETFDCSTAT:
case LINUX_FDWERRORCLR:
case LINUX_FDWERRORGET:
case LINUX_FDRAWCMD:
case LINUX_FDEJECT:
default:
error = EINVAL;
}
FILE_UNUSE(fp, p);
return 0;
}

View File

@ -0,0 +1,200 @@
/* $NetBSD: linux_fdio.h,v 1.1 2000/12/10 14:12:16 fvdl Exp $ */
/*
* Copyright (c) 2000 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden for Wasabi Systems, Inc.
*
* 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 for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
#ifndef _LINUX_FDIO_H
#define _LINUX_FDIO_H
/*
* Linux floppy ioctl call structures and defines.
*/
struct linux_floppy_struct {
u_int size;
u_int sect;
u_int head;
u_int track;
u_int stretch;
u_char gap;
u_char rate;
u_char spec1;
u_char fmt_gap;
const char *name;
};
struct linux_floppy_max_errors {
u_int abort;
u_int read_track;
u_int reset;
u_int recal;
u_int reporting;
};
struct linux_floppy_drive_params {
char cmos;
u_long max_dtr;
u_long hlt;
u_long hut;
u_long srt;
u_long spinup;
u_long spindown;
u_char spindown_offset;
u_char select_delay;
u_char rps;
u_char tracks;
u_long timeout;
u_char interleave_sect;
struct linux_floppy_max_errors max_errors;
char flags;
char read_track;
short autodetect[8];
int checkfreq;
int native_format;
};
struct linux_floppy_drive_struct {
u_long flags;
u_long spinup_date;
u_long select_date;
u_long first_read_date;
short probed_format;
short track;
short maxblock;
short maxtrack;
int generation;
int keep_data;
int fd_ref;
int fd_device;
u_long last_checked;
char *dmabuf;
int bufblocks;
};
#define LINUX_FD_NEED_TWADDLE 0x01
#define LINUX_FD_VERIFY 0x02
#define LINUX_FD_DISK_NEWCHANGE 0x04
#define LINUX_FD_DISK_CHANGED 0x10
#define LINUX_FD_DISK_WRITABLE 0x20
struct linux_floppy_fdc_state {
int spec1;
int spec2;
int dtr;
u_char version;
u_char dor;
u_long address;
u_int rawcmd:2;
u_int reset:1;
u_int need_configure:1;
u_int perp_mode:2;
u_int has_fifo:1;
u_int driver_version;
u_char track[4];
};
struct linux_floppy_write_errors {
u_int write_errors;
u_long first_error_sector;
u_int first_error_generation;
u_long last_error_sector;
u_int last_error_generation;
u_int badness;
};
struct linux_floppy_raw_cmd {
u_int flags;
void *data;
caddr_t kernel_data;
struct floppy_raw_cmd *next;
long length;
long phys_length;
int buffer_length;
u_char rate;
u_char cmd_count;
u_char cmd[16];
u_char reply_count;
u_char reply[16];
int track;
int resultcode;
int reserved1;
int reserved2;
};
struct linux_format_descr {
u_int device;
u_int head;
u_int track;
};
typedef char linux_floppy_drive_name[16];
#define LINUX_FDCLRPRM _LINUX_IO(2, 0x41)
#define LINUX_FDSETPRM _LINUX_IOW(2, 0x42, struct linux_floppy_struct)
#define LINUX_FDDEFPRM _LINUX_IOW(2, 0x43, struct linux_floppy_struct)
#define LINUX_FDGETPRM _LINUX_IOR(2, 0x04, struct linux_floppy_struct)
#define LINUX_FDMSGON _LINUX_IO(2, 0x45)
#define LINUX_FDMSGOFF _LINUX_IO(2, 0x46)
#define LINUX_FDFMTBEG _LINUX_IO(2, 0x47)
#define LINUX_FDFMTTRK _LINUX_IOW(2, 0x48, struct linux_format_descr)
#define LINUX_FDFMTEND _LINUX_IO(2, 0x49)
#define LINUX_FDSETEMSGTRESH _LINUX_IO(2, 0x4a)
#define LINUX_FDFLUSH _LINUX_IO(2, 0x4b)
#define LINUX_FDSETMAXERRS \
_LINUX_IOW(2, 0x4c, struct linux_floppy_max_errors)
#define LINUX_FDGETMAXERRS \
_LINUX_IOR(2, 0x0e, struct linux_floppy_max_errors)
#define LINUX_FDGETDRVTYP _LINUX_IOR(2, 0x0f, linux_floppy_drive_name)
/* 0x90 is not a typo, that's how it's listed in the Linux include file */
#define LINUX_FDSETDRVPRM \
_LINUX_IOW(2, 0x90, struct linux_floppy_drive_params)
#define LINUX_FDGETDRVPRM \
_LINUX_IOR(2, 0x11, struct linux_floppy_drive_params)
#define LINUX_FDGETDRVSTAT \
_LINUX_IOR(2, 0x12, struct linux_floppy_drive_struct)
#define LINUX_FDPOLLDRVSTAT \
_LINUX_IOR(2, 0x13, struct linux_floppy_drive_struct)
#define LINUX_FDRESET _LINUX_IO(2, 0x54)
#define LINUX_FDGETFDCSTAT \
_LINUX_IOR(2, 0x15, struct linux_floppy_fdc_state)
#define LINUX_FDWERRORCLR _LINUX_IO(2, 0x56)
#define LINUX_FDWERRORGET \
_LINUX_IOR(2, 0x17, struct linux_floppy_write_errors)
#define LINUX_FDRAWCMD _LINUX_IO(2, 0x58)
#define LINUX_FDTWADDLE _LINUX_IO(2, 0x59)
#define LINUX_FDEJECT _LINUX_IO(2, 0x5a)
#endif /* _LINUX_FDIO_H */

View File

@ -0,0 +1,184 @@
/* $NetBSD: linux_hdio.c,v 1.1 2000/12/10 14:12:17 fvdl Exp $ */
/*
* Copyright (c) 2000 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden for Wasabi Systems, Inc.
*
* 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 for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/disklabel.h>
#include <dev/ata/atareg.h>
#include <dev/ic/wdcreg.h>
#include <sys/ataio.h>
#include <sys/syscallargs.h>
#include <compat/linux/common/linux_types.h>
#include <compat/linux/common/linux_ioctl.h>
#include <compat/linux/common/linux_signal.h>
#include <compat/linux/common/linux_util.h>
#include <compat/linux/common/linux_hdio.h>
#include <compat/linux/linux_syscallargs.h>
int
linux_ioctl_hdio(struct proc *p, struct linux_sys_ioctl_args *uap,
register_t *retval)
{
u_long com;
int error, error1;
caddr_t sg;
struct filedesc *fdp;
struct file *fp;
int (*ioctlf) __P((struct file *, u_long, caddr_t, struct proc *));
struct ataparams *atap, ata;
struct atareq req;
struct disklabel label, *labp;
struct partinfo partp;
struct linux_hd_geometry hdg;
struct linux_hd_big_geometry hdg_big;
fdp = p->p_fd;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL ||
(fp->f_iflags & FIF_WANTCLOSE) != 0)
return (EBADF);
FILE_USE(fp);
com = SCARG(uap, com);
ioctlf = fp->f_ops->fo_ioctl;
retval[0] = error = 0;
com = SCARG(uap, com);
switch (com) {
case LINUX_HDIO_OBSOLETE_IDENTITY:
case LINUX_HDIO_GET_IDENTITY:
sg = stackgap_init(p->p_emul);
atap = stackgap_alloc(&sg, DEV_BSIZE);
if (atap == NULL) {
error = ENOMEM;
break;
}
req.flags = ATACMD_READ;
req.command = WDCC_IDENTIFY;
req.databuf = (caddr_t)atap;
req.datalen = DEV_BSIZE;
req.timeout = 1000;
error = ioctlf(fp, ATAIOCCOMMAND, (caddr_t)&req, p);
if (error != 0)
break;
if (req.retsts != ATACMD_OK)
return EIO;
error = copyin(atap, &ata, sizeof ata);
if (error != 0)
break;
/*
* 142 is the size of the old structure used by Linux,
* which doesn't seem to be defined anywhere anymore.
*/
error = copyout(&ata, SCARG(uap, data),
com == LINUX_HDIO_GET_IDENTITY ? sizeof ata : 142);
break;
case LINUX_HDIO_GETGEO:
error = linux_machdepioctl(p, uap, retval);
if (error == 0)
break;
error = ioctlf(fp, DIOCGDEFLABEL, (caddr_t)&label, p);
error1 = ioctlf(fp, DIOCGPART, (caddr_t)&partp, p);
if (error != 0 && error1 != 0) {
error = error1;
break;
}
labp = error != 0 ? &label : partp.disklab;
hdg.start = error1 != 0 ? partp.part->p_offset : 0;
hdg.heads = labp->d_ntracks;
hdg.cylinders = labp->d_ncylinders;
hdg.sectors = labp->d_nsectors;
error = copyout(&hdg, SCARG(uap, data), sizeof hdg);
break;
case LINUX_HDIO_GETGEO_BIG:
error = linux_machdepioctl(p, uap, retval);
if (error == 0)
break;
case LINUX_HDIO_GETGEO_BIG_RAW:
error = ioctlf(fp, DIOCGDEFLABEL, (caddr_t)&label, p);
error1 = ioctlf(fp, DIOCGPART, (caddr_t)&partp, p);
if (error != 0 && error1 != 0) {
error = error1;
break;
}
labp = error != 0 ? &label : partp.disklab;
hdg_big.start = error1 != 0 ? partp.part->p_offset : 0;
hdg_big.heads = labp->d_ntracks;
hdg_big.cylinders = labp->d_ncylinders;
hdg_big.sectors = labp->d_nsectors;
error = copyout(&hdg_big, SCARG(uap, data), sizeof hdg_big);
break;
case LINUX_HDIO_GET_UNMASKINTR:
case LINUX_HDIO_GET_MULTCOUNT:
case LINUX_HDIO_GET_KEEPSETTINGS:
case LINUX_HDIO_GET_32BIT:
case LINUX_HDIO_GET_NOWERR:
case LINUX_HDIO_GET_DMA:
case LINUX_HDIO_GET_NICE:
case LINUX_HDIO_DRIVE_RESET:
case LINUX_HDIO_TRISTATE_HWIF:
case LINUX_HDIO_DRIVE_TASK:
case LINUX_HDIO_DRIVE_CMD:
case LINUX_HDIO_SET_MULTCOUNT:
case LINUX_HDIO_SET_UNMASKINTR:
case LINUX_HDIO_SET_KEEPSETTINGS:
case LINUX_HDIO_SET_32BIT:
case LINUX_HDIO_SET_NOWERR:
case LINUX_HDIO_SET_DMA:
case LINUX_HDIO_SET_PIO_MODE:
case LINUX_HDIO_SCAN_HWIF:
case LINUX_HDIO_SET_NICE:
case LINUX_HDIO_UNREGISTER_HWIF:
error = EINVAL;
}
FILE_UNUSE(fp, p);
return error;
}

View File

@ -0,0 +1,88 @@
/* $NetBSD: linux_hdio.h,v 1.1 2000/12/10 14:12:17 fvdl Exp $ */
/*
* Copyright (c) 2000 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden for Wasabi Systems, Inc.
*
* 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 for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
#ifndef _LINUX_HDIO_H
#define _LINUX_HDIO_H
/*
* Linux 'hd' (mostly really IDE disk) ioctl calls.
*/
#define LINUX_HDIO_GETGEO 0x0301
#define LINUX_HDIO_GETGEO_BIG 0x0330
#define LINUX_HDIO_GETGEO_BIG_RAW 0x0331
#define LINUX_HDIO_GET_UNMASKINTR 0x0302
#define LINUX_HDIO_GET_MULTCOUNT 0x0304
#define LINUX_HDIO_OBSOLETE_IDENTITY 0x0307
#define LINUX_HDIO_GET_KEEPSETTINGS 0x0308
#define LINUX_HDIO_GET_32BIT 0x0309
#define LINUX_HDIO_GET_NOWERR 0x030a
#define LINUX_HDIO_GET_DMA 0x030b
#define LINUX_HDIO_GET_NICE 0x030c
#define LINUX_HDIO_GET_IDENTITY 0x030d
#define LINUX_HDIO_DRIVE_RESET 0x031c
#define LINUX_HDIO_TRISTATE_HWIF 0x031d
#define LINUX_HDIO_DRIVE_TASK 0x031e
#define LINUX_HDIO_DRIVE_CMD 0x031f
#define LINUX_HDIO_SET_MULTCOUNT 0x0321
#define LINUX_HDIO_SET_UNMASKINTR 0x0322
#define LINUX_HDIO_SET_KEEPSETTINGS 0x0323
#define LINUX_HDIO_SET_32BIT 0x0324
#define LINUX_HDIO_SET_NOWERR 0x0325
#define LINUX_HDIO_SET_DMA 0x0326
#define LINUX_HDIO_SET_PIO_MODE 0x0327
#define LINUX_HDIO_SCAN_HWIF 0x0328
#define LINUX_HDIO_SET_NICE 0x0329
#define LINUX_HDIO_UNREGISTER_HWIF 0x032a
struct linux_hd_geometry {
u_char heads;
u_char sectors;
u_short cylinders;
u_long start;
};
struct linux_hd_big_geometry {
u_char heads;
u_char sectors;
u_int cylinders;
u_long start;
};
#endif /* _LINUX_HDIO_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_ioctl.c,v 1.23 2000/11/29 22:05:37 jdolecek Exp $ */ /* $NetBSD: linux_ioctl.c,v 1.24 2000/12/10 14:12:17 fvdl Exp $ */
/*- /*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -131,6 +131,10 @@ linux_sys_ioctl(p, v, retval)
} }
case 0x89: case 0x89:
return linux_ioctl_socket(p, uap, retval); return linux_ioctl_socket(p, uap, retval);
case 0x03:
return linux_ioctl_hdio(p, uap, retval);
case 0x02:
return linux_ioctl_fdio(p, uap, retval);
default: default:
return linux_machdepioctl(p, uap, retval); return linux_machdepioctl(p, uap, retval);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_termios.c,v 1.7 2000/03/30 11:27:18 augustss Exp $ */ /* $NetBSD: linux_termios.c,v 1.8 2000/12/10 14:12:17 fvdl Exp $ */
/*- /*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -462,6 +462,7 @@ linux_ioctl_termios(p, uap, retval)
int idat; int idat;
struct sys_ioctl_args ia; struct sys_ioctl_args ia;
int error; int error;
char tioclinux;
fdp = p->p_fd; fdp = p->p_fd;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
@ -611,6 +612,29 @@ linux_ioctl_termios(p, uap, retval)
if (error) if (error)
return error; return error;
return 0; return 0;
case LINUX_TIOCLINUX:
error = copyin(SCARG(uap, data), &tioclinux, sizeof tioclinux);
if (error != 0)
return error;
switch (tioclinux) {
case LINUX_TIOCLINUX_KERNMSG:
/*
* XXX needed to not fail for some things. Could
* try to use TIOCCONS, but the char argument
* specifies the VT #, not an fd.
*/
return 0;
case LINUX_TIOCLINUX_COPY:
case LINUX_TIOCLINUX_PASTE:
case LINUX_TIOCLINUX_UNBLANK:
case LINUX_TIOCLINUX_LOADLUT:
case LINUX_TIOCLINUX_READSHIFT:
case LINUX_TIOCLINUX_READMOUSE:
case LINUX_TIOCLINUX_VESABLANK:
case LINUX_TIOCLINUX_CURCONS: /* could use VT_GETACTIVE */
return EINVAL;
}
break;
case LINUX_TIOCGWINSZ: case LINUX_TIOCGWINSZ:
SCARG(&ia, com) = TIOCGWINSZ; SCARG(&ia, com) = TIOCGWINSZ;
break; break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_termios.h,v 1.5 1998/12/15 19:31:40 itohy Exp $ */ /* $NetBSD: linux_termios.h,v 1.6 2000/12/10 14:12:17 fvdl Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -109,6 +109,17 @@ struct linux_termios {
#define LINUX_N_X25 6 #define LINUX_N_X25 6
#define LINUX_N_6PACK 7 #define LINUX_N_6PACK 7
/* values passed to TIOCLINUX ioctl */
#define LINUX_TIOCLINUX_COPY 2
#define LINUX_TIOCLINUX_PASTE 3
#define LINUX_TIOCLINUX_UNBLANK 4
#define LINUX_TIOCLINUX_LOADLUT 5
#define LINUX_TIOCLINUX_READSHIFT 6
#define LINUX_TIOCLINUX_READMOUSE 7
#define LINUX_TIOCLINUX_VESABLANK 10
#define LINUX_TIOCLINUX_KERNMSG 11
#define LINUX_TIOCLINUX_CURCONS 12
#if defined(__i386__) #if defined(__i386__)
#include <compat/linux/arch/i386/linux_termios.h> #include <compat/linux/arch/i386/linux_termios.h>
#elif defined(__m68k__) #elif defined(__m68k__)