Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Aug 1999 18:31:56 +0200
From:      Marcel Moolenaar <marcel@scc.nl>
To:        emulation@FreeBSD.ORG
Subject:   REVIEW: Linuxulator: CDROMSUBCHNL ioctl
Message-ID:  <37B2F6FC.D8287D62@scc.nl>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------7309109606E3DF9E4CD742B6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

The following implementation of the CDROMSUBCHNL ioctl is about to be
committed. Please review the attached patch.

-- 
Marcel Moolenaar                                  mailto:marcel@scc.nl
SCC Internetworking & Databases                     http://www.scc.nl/
Amsterdam, The Netherlands                         tel: +31 20 4200655
--------------7309109606E3DF9E4CD742B6
Content-Type: text/plain; charset=us-ascii;
 name=".cdrom.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename=".cdrom.diff"

Index: linux.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux.h,v
retrieving revision 1.31
diff -u -r1.31 linux.h
--- linux.h	1999/08/11 13:34:29	1.31
+++ linux.h	1999/08/12 13:29:14
@@ -706,4 +706,7 @@
 #define LINUX_CDROMCLOSETRAY		0x5319
 #define LINUX_CDROMLOADFROMSLOT		0x531a
 
+#define LINUX_CDROM_LBA                 0x01
+#define LINUX_CDROM_MSF                 0x02
+
 #endif /* !_I386_LINUX_LINUX_H_ */
Index: linux_ioctl.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_ioctl.c,v
retrieving revision 1.36
diff -u -r1.36 linux_ioctl.c
--- linux_ioctl.c	1999/07/17 08:24:57	1.36
+++ linux_ioctl.c	1999/08/12 15:27:54
@@ -484,6 +484,18 @@
     u_char	cdte_datamode;  
 };
 
+struct linux_cdrom_subchnl
+{
+    u_char      cdsc_format;
+    u_char      cdsc_audiostatus;
+    u_char      cdsc_adr:4;
+    u_char      cdsc_ctrl:4;
+    u_char      cdsc_trk;
+    u_char      cdsc_ind;
+    union linux_cdrom_addr cdsc_absaddr;
+    union linux_cdrom_addr cdsc_reladdr;
+};
+
 #if 0
 static void
 linux_to_bsd_msf_lba(u_char address_format,
@@ -512,6 +524,20 @@
     }
 }
 
+static void
+set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba)
+{
+    if (format == LINUX_CDROM_MSF) {
+        addr->msf.frame = lba % 75;
+        lba /= 75;
+        lba += 2;
+        addr->msf.second = lba % 60;
+        addr->msf.minute = lba / 60;
+    }
+    else
+        addr->lba = lba;
+}
+
 static unsigned dirbits[4] = { IOC_VOID, IOC_OUT, IOC_IN, IOC_INOUT };
 
 #define SETDIR(c)	(((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30])
@@ -1182,6 +1208,40 @@
 	    copyout((caddr_t)&lte, (caddr_t)args->arg, sizeof(lte));
 	}
 	return error;
+    }
+
+    case LINUX_CDROMSUBCHNL: {
+        struct linux_cdrom_subchnl sc;
+        struct ioc_read_subchannel bsdsc;
+        struct cd_sub_channel_info bsdinfo;
+
+        bsdsc.address_format = CD_LBA_FORMAT;
+        bsdsc.data_format = CD_CURRENT_POSITION;
+        bsdsc.data_len = sizeof(bsdinfo);
+        bsdsc.data = &bsdinfo;
+        error = (*func)(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p);
+        /*
+         * Ignore error because the ll-driver uses a copyout to
+         * pass the data to the user. In this case that fails
+         */
+
+        error = copyin((caddr_t)args->arg, (caddr_t)&sc,
+                       sizeof(struct linux_cdrom_subchnl));
+        if (error)
+            return error;
+
+        sc.cdsc_audiostatus = bsdinfo.header.audio_status;
+        sc.cdsc_adr = bsdinfo.what.position.addr_type;
+        sc.cdsc_ctrl = bsdinfo.what.position.control;
+        sc.cdsc_trk = bsdinfo.what.position.track_number;
+        sc.cdsc_ind = bsdinfo.what.position.index_number;
+        set_linux_cdrom_addr(&sc.cdsc_absaddr, sc.cdsc_format,
+                             bsdinfo.what.position.absaddr.lba);
+        set_linux_cdrom_addr(&sc.cdsc_reladdr, sc.cdsc_format,
+                             bsdinfo.what.position.reladdr.lba);
+        error = copyout((caddr_t)&sc, (caddr_t)args->arg,
+                        sizeof(struct linux_cdrom_subchnl));
+        return error;
     }
 
     }

--------------7309109606E3DF9E4CD742B6--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-emulation" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37B2F6FC.D8287D62>