diff options
author | luoqi <luoqi@FreeBSD.org> | 1999-04-29 04:37:57 +0000 |
---|---|---|
committer | luoqi <luoqi@FreeBSD.org> | 1999-04-29 04:37:57 +0000 |
commit | a71077fa5c7b9f5688d8aed793f912fc32e377e9 (patch) | |
tree | 8d9868add9d324f0c4f4cf6846209fb2cfa81e1a /sys/i386/linux | |
parent | ef1528cdb769f3426dc5e9218ad2a8fcef45aa41 (diff) | |
download | FreeBSD-src-a71077fa5c7b9f5688d8aed793f912fc32e377e9.zip FreeBSD-src-a71077fa5c7b9f5688d8aed793f912fc32e377e9.tar.gz |
- Handle mixer read ioctls correctly. They have the same group, number and
argument size as their write counterparts and were handled as write ioctls.
- Emulate some cdrom ioctls.
Diffstat (limited to 'sys/i386/linux')
-rw-r--r-- | sys/i386/linux/linux.h | 31 | ||||
-rw-r--r-- | sys/i386/linux/linux_ioctl.c | 167 |
2 files changed, 178 insertions, 20 deletions
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index eaffa61..0774dd3 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux.h,v 1.25 1998/12/19 02:55:32 julian Exp $ + * $Id: linux.h,v 1.26 1998/12/30 21:19:59 sos Exp $ */ #ifndef _I386_LINUX_LINUX_H_ @@ -570,7 +570,6 @@ struct trapframe; #define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10 #define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe - /* Socket system defines */ #define LINUX_FIOSETOWN 0x8901 #define LINUX_SIOCSPGRP 0x8902 @@ -660,4 +659,32 @@ struct linux_ifreq #define LINUX_ASYNC_CALLOUT_NOHUP 0x0400 #define LINUX_ASYNC_FLAGS 0x0FFF +/* cdrom */ +#define LINUX_CDROMPAUSE 0x5301 +#define LINUX_CDROMRESUME 0x5302 +#define LINUX_CDROMPLAYMSF 0x5303 +#define LINUX_CDROMPLAYTRKIND 0x5304 +#define LINUX_CDROMREADTOCHDR 0x5305 +#define LINUX_CDROMREADTOCENTRY 0x5306 +#define LINUX_CDROMSTOP 0x5307 +#define LINUX_CDROMSTART 0x5308 +#define LINUX_CDROMEJECT 0x5309 +#define LINUX_CDROMVOLCTRL 0x530a +#define LINUX_CDROMSUBCHNL 0x530b +#define LINUX_CDROMREADMODE2 0x530c +#define LINUX_CDROMREADMODE1 0x530d +#define LINUX_CDROMREADAUDIO 0x530e +#define LINUX_CDROMEJECT_SW 0x530f +#define LINUX_CDROMMULTISESSION 0x5310 +#define LINUX_CDROM_GET_UPC 0x5311 +#define LINUX_CDROMRESET 0x5312 +#define LINUX_CDROMVOLREAD 0x5313 +#define LINUX_CDROMREADRAW 0x5314 +#define LINUX_CDROMREADCOOKED 0x5315 +#define LINUX_CDROMSEEK 0x5316 +#define LINUX_CDROMPLAYBLK 0x5317 +#define LINUX_CDROMREADALL 0x5318 +#define LINUX_CDROMCLOSETRAY 0x5319 +#define LINUX_CDROMLOADFROMSLOT 0x531a + #endif /* !_I386_LINUX_LINUX_H_ */ diff --git a/sys/i386/linux/linux_ioctl.c b/sys/i386/linux/linux_ioctl.c index 3010f74..9af33a9 100644 --- a/sys/i386/linux/linux_ioctl.c +++ b/sys/i386/linux/linux_ioctl.c @@ -25,13 +25,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_ioctl.c,v 1.29 1998/09/30 01:42:53 jfieber Exp $ + * $Id: linux_ioctl.c,v 1.30 1998/11/12 00:42:08 jkh Exp $ */ #include <sys/param.h> #include <sys/systm.h> #include <sys/sysproto.h> #include <sys/proc.h> +#include <sys/cdio.h> #include <sys/fcntl.h> #include <sys/file.h> #include <sys/filedesc.h> @@ -447,6 +448,72 @@ linux_tiocsserial(struct file *fp, struct linux_serial_struct *lss) return; } +struct linux_cdrom_msf +{ + u_char cdmsf_min0; + u_char cdmsf_sec0; + u_char cdmsf_frame0; + u_char cdmsf_min1; + u_char cdmsf_sec1; + u_char cdmsf_frame1; +}; + +struct linux_cdrom_tochdr +{ + u_char cdth_trk0; + u_char cdth_trk1; +}; + +union linux_cdrom_addr +{ + struct { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; +}; + +struct linux_cdrom_tocentry +{ + u_char cdte_track; + u_char cdte_adr:4; + u_char cdte_ctrl:4; + u_char cdte_format; + union linux_cdrom_addr cdte_addr; + u_char cdte_datamode; +}; + +static void +linux_to_bsd_msf_lba(u_char address_format, + union linux_cdrom_addr *lp, union msf_lba *bp) +{ + if (address_format == CD_LBA_FORMAT) + bp->lba = lp->lba; + else { + bp->msf.minute = lp->msf.minute; + bp->msf.second = lp->msf.second; + bp->msf.frame = lp->msf.frame; + } +} + +static void +bsd_to_linux_msf_lba(u_char address_format, + union msf_lba *bp, union linux_cdrom_addr *lp) +{ + if (address_format == CD_LBA_FORMAT) + lp->lba = bp->lba; + else { + lp->msf.minute = bp->msf.minute; + lp->msf.second = bp->msf.second; + lp->msf.frame = bp->msf.frame; + } +} + +static unsigned dirbits[4] = { IOC_VOID, IOC_OUT, IOC_IN, IOC_INOUT }; + +#define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30]) + int linux_ioctl(struct proc *p, struct linux_ioctl_args *args) { @@ -821,71 +888,71 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args) return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_VOLUME: - args->cmd = SOUND_MIXER_WRITE_VOLUME; + args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_BASS: - args->cmd = SOUND_MIXER_WRITE_BASS; + args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_TREBLE: - args->cmd = SOUND_MIXER_WRITE_TREBLE; + args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_SYNTH: - args->cmd = SOUND_MIXER_WRITE_SYNTH; + args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_PCM: - args->cmd = SOUND_MIXER_WRITE_PCM; + args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_SPEAKER: - args->cmd = SOUND_MIXER_WRITE_SPEAKER; + args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_LINE: - args->cmd = SOUND_MIXER_WRITE_LINE; + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_MIC: - args->cmd = SOUND_MIXER_WRITE_MIC; + args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_CD: - args->cmd = SOUND_MIXER_WRITE_CD; + args->cmd = SETDIR(SOUND_MIXER_WRITE_CD); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_IMIX: - args->cmd = SOUND_MIXER_WRITE_IMIX; + args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_ALTPCM: - args->cmd = SOUND_MIXER_WRITE_ALTPCM; + args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_RECLEV: - args->cmd = SOUND_MIXER_WRITE_RECLEV; + args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_IGAIN: - args->cmd = SOUND_MIXER_WRITE_IGAIN; + args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_OGAIN: - args->cmd = SOUND_MIXER_WRITE_OGAIN; + args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_LINE1: - args->cmd = SOUND_MIXER_WRITE_LINE1; + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_LINE2: - args->cmd = SOUND_MIXER_WRITE_LINE2; + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_WRITE_LINE3: - args->cmd = SOUND_MIXER_WRITE_LINE3; + args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3); return ioctl(p, (struct ioctl_args *)args); case LINUX_SOUND_MIXER_READ_DEVMASK: @@ -998,6 +1065,70 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args) case LINUX_KDMKTONE: args->cmd = KDMKTONE; return ioctl(p, (struct ioctl_args *)args); + + + case LINUX_CDROMPAUSE: + args->cmd = CDIOCPAUSE; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMRESUME: + args->cmd = CDIOCRESUME; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMPLAYMSF: + args->cmd = CDIOCPLAYMSF; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMPLAYTRKIND: + args->cmd = CDIOCPLAYTRACKS; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMSTART: + args->cmd = CDIOCSTART; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMSTOP: + args->cmd = CDIOCSTOP; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMEJECT: + args->cmd = CDIOCEJECT; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMRESET: + args->cmd = CDIOCRESET; + return ioctl(p, (struct ioctl_args *)args); + + case LINUX_CDROMREADTOCHDR: { + struct ioc_toc_header th; + struct linux_cdrom_tochdr lth; + error = (*func)(fp, CDIOREADTOCHEADER, (caddr_t)&th, p); + if (!error) { + lth.cdth_trk0 = th.starting_track; + lth.cdth_trk1 = th.ending_track; + copyout((caddr_t)<h, (caddr_t)args->arg, sizeof(lth)); + } + return error; + } + + case LINUX_CDROMREADTOCENTRY: { + struct linux_cdrom_tocentry lte, *ltep = + (struct linux_cdrom_tocentry *)args->arg; + struct ioc_read_toc_single_entry irtse; + irtse.address_format = ltep->cdte_format; + irtse.track = ltep->cdte_track; + error = (*func)(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p); + if (!error) { + lte = *ltep; + lte.cdte_ctrl = irtse.entry.control; + lte.cdte_adr = irtse.entry.addr_type; + bsd_to_linux_msf_lba(irtse.address_format, + &irtse.entry.addr, <e.cdte_addr); + copyout((caddr_t)<e, (caddr_t)args->arg, sizeof(lte)); + } + return error; + } + } uprintf("LINUX: 'ioctl' fd=%d, typ=0x%x(%c), num=0x%x not implemented\n", |