view Documentation/cdrom/aztcd @ 524:7f8b544237bf

netfront: Allow netfront in domain 0.

This is useful if your physical network device is in a utility domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 15 15:18:58 2008 +0100 (2008-04-15)
parents 831230e53067
line source
1 $Id: README.aztcd,v 2.60 1997/11/29 09:51:25 root Exp root $
2 Readme-File Documentation/cdrom/aztcd
3 for
6 CD-ROM Drives
7 Version 2.6 and newer
8 (for other drives see 6.-8.)
11 A PROPRIETARY INTERFACE (implemented on a sound card or on an
12 ISA-AT-bus card).
14 such as the Aztech CDA269-031SE !!! (The only known exceptions are
15 'faked' IDE drives like the CyCDROM CR520ie which work with aztcd
16 under certain conditions, see 7.). IF YOU'RE USING A CD-ROM DRIVE
21 ----------------------------------------------------------------------------
23 Contents of this file:
24 1. NOTE
40 APPENDIX: Source code of cdplay.c
41 ----------------------------------------------------------------------------
43 1. NOTE
44 This software has been successfully in alpha and beta test and is part of
45 the standard kernel since kernel 1.1.8x since December 1994. It works with
47 (Nr.99 31 23 -series 04) and has proven to be stable with kernel
48 versions 1.0.9 and newer. But with any software there still may be bugs in it.
49 So if you encounter problems, you are invited to help us improve this software.
50 Please send me a detailed bug report (see chapter BUG REPORTS). You are also
51 invited in helping us to increase the number of drives, which are supported.
53 Please read the README-files carefully and always keep a backup copy of your
54 old kernel, in order to reboot if something goes wrong!
57 The driver consists of a header file 'aztcd.h', which normally should reside
58 in /usr/src/linux/drivers/cdrom and the source code 'aztcd.c', which normally
59 resides in the same place. It uses /dev/aztcd (/dev/aztcd0 in some distri-
60 butions), which must be a valid block device with major number 29 and reside
61 in directory /dev. To mount a CD-ROM, your kernel needs to have the ISO9660-
62 filesystem support included.
64 PLEASE NOTE: aztcd.c has been developed in parallel to the linux kernel,
65 which had and is having many major and minor changes which are not backward
66 compatible. Quite definitely aztcd.c version 1.80 and newer will NOT work
67 in kernels older than 1.3.33. So please always use the most recent version
68 of aztcd.c with the appropriate linux-kernel.
71 If your kernel is already configured for using the AZTECH driver you will
72 see the following message while Linux boots:
73 Aztech CD-ROM Init: DriverVersion=<version number> BaseAddress=<baseaddress>
74 Aztech CD-ROM Init: FirmwareVersion=<firmware version id of your I/O-card>>>
75 Aztech CD-ROM Init: <drive type> detected
76 Aztech CD-ROM Init: End
77 If the message looks different and you are sure to have a supported drive,
78 it may have a different base address. The Aztech driver does look for the
79 CD-ROM drive at the base address specified in aztcd.h at compile time. This
80 address can be overwritten by boot parameter aztcd=....You should reboot and
81 start Linux with boot parameter aztcd=<base address>, e.g. aztcd=0x320. If
82 you do not know the base address, start your PC with DOS and look at the boot
83 message of your CD-ROM's DOS driver. If that still does not help, use boot
84 parameter aztcd=<base address>,0x79 , this tells aztcd to try a little harder.
85 aztcd may be configured to use autoprobing the base address by recompiling
86 it (see chapter 4.).
88 If the message looks correct, as user 'root' you should be able to mount the
89 drive by
90 mount -t iso9660 -r /dev/aztcd0 /mnt
91 and use it as any other filesystem. (If this does not work, check if
92 /dev/aztcd0 and /mnt do exist and create them, if necessary by doing
93 mknod /dev/aztcd0 b 29 0
94 mkdir /mnt
96 If you still get a different message while Linux boots or when you get the
97 message, that the ISO9660-filesystem is not supported by your kernel, when
98 you try to mount the CD-ROM drive, you have to recompile your kernel.
100 If you do *not* have an Aztech/Orchid/Okano/Wearnes/TXC drive and want to
101 bypass drive detection during Linux boot up, start with boot parameter aztcd=0.
103 Most distributions nowadays do contain a boot disk image containing aztcd.
104 Please note, that this driver will not work with IDE/ATAPI drives! With these
105 you must use ide-cd.c instead.
108 If your kernel is not yet configured for the AZTECH driver and the ISO9660-
109 filesystem, you have to recompile your kernel:
111 - Edit aztcd.h to set the I/O-address to your I/O-Base address (AZT_BASE_ADDR),
112 the driver does not use interrupts or DMA, so if you are using an AZTECH
113 CD268, an ORCHID CD-3110 or ORCHID/WEARNES CDD110 that's the only item you
114 have to set up. If you have a soundcard, read chapter 4.2.
115 Users of other drives should read chapter OTHER DRIVES of this file.
116 You also can configure that address by kernel boot parameter aztcd=...
117 - aztcd may be configured to use autoprobing the base address by setting
118 AZT_BASE_ADDR to '-1'. In that case aztcd probes the addresses listed
119 under AZT_BASE_AUTO. But please remember, that autoprobing always may
120 incorrectly influence other hardware components too!
121 - There are some other points, which may be configured, e.g. auto-eject the
122 CD when unmounting a drive, tray locking etc., see aztcd.h for details.
123 - If you're using a linux kernel version prior to 2.1.0, in aztcd.h
124 uncomment the line '#define AZT_KERNEL_PRIOR_2_1'
125 - Build a new kernel, configure it for 'Aztech/Orchid/Okano/Wearnes support'
126 (if you want aztcd to be part of the kernel). Do not configure it for
127 'Aztech... support', if you want to use aztcd as a run time loadable module.
128 But in any case you must have the ISO9660-filesystem included in your
129 kernel.
130 - Activate the new kernel, normally this is done by running LILO (don't for-
131 get to configure it before and to keep a copy of your old kernel in case
132 something goes wrong!).
133 - Reboot
134 - If you've included aztcd in your kernel, you now should see during boot
135 some messages like
136 Aztech CD-ROM Init: DriverVersion=<version number> BaseAddress=<baseaddress>
137 Aztech CD-ROM Init: FirmwareVersion=<firmware version id of your I/O-card>
138 Aztech CD-ROM Init: <drive type> detected
139 Aztech CD-ROM Init: End
140 - If you have not included aztcd in your kernel, but want to load aztcd as a
141 run time loadable module see 4.1.
142 - If the message looks correct, as user 'root' you should be able to mount
143 the drive by
144 mount -t iso9660 -r /dev/aztcd0 /mnt
145 and use it as any other filesystem. (If this does not work, check if
146 /dev/aztcd0 and /mnt do exist and create them, if necessary by doing
147 mknod /dev/aztcd0 b 29 0
148 mkdir /mnt
149 - If this still does not help, see chapters OTHER DRIVES and DEBUGGING.
152 If you do not need aztcd permanently, you can also load and remove the driver
153 during runtime via insmod and rmmod. To build aztcd as a loadable module you
154 must configure your kernel for AZTECH module support (answer 'm' when con-
155 figuring the kernel). Anyhow, you may run into problems, if the version of
156 your boot kernel is not the same than the source kernel version, from which
157 you create the modules. So rebuild your kernel, if necessary.
159 Now edit the base address of your AZTECH interface card in
160 /usr/src/linux/drivers/cdrom/aztcd.h to the appropriate value.
161 aztcd may be configured to use autoprobing the base address by setting
162 AZT_BASE_ADDR to '-1'. In that case aztcd probes the addresses listed
163 under AZT_BASE_AUTO. But please remember, that autoprobing always may
164 incorrectly influence other hardware components too!
165 There are also some special features which may be configured, e.g.
166 auto-eject a CD when unmounting the drive etc; see aztcd.h for details.
167 Then change to /usr/src/linux and do a
168 make modules
169 make modules_install
170 After that you can run-time load the driver via
171 insmod /lib/modules/X.X.X/misc/aztcd.o
172 and remove it via rmmod aztcd.
173 If you did not set the correct base address in aztcd.h, you can also supply the
174 base address when loading the driver via
175 insmod /lib/modules/X.X.X/misc/aztcd.o aztcd=<base address>
176 Again specifying aztcd=-1 will cause autoprobing.
177 If you do not have the iso9660-filesystem in your boot kernel, you also have
178 to load it before you can mount the CDROM:
179 insmod /lib/modules/X.X.X/fs/isofs.o
180 The mount procedure works as described in 4. above.
181 (In all commands 'X.X.X' is the current linux kernel version number)
184 Most soundcards do have a bus interface to the CDROM-drive. In many cases
185 this soundcard needs to be configured, before the CDROM can be used. This
186 configuration procedure consists of writing some kind of initialization
187 data to the soundcard registers. The AZTECH-CDROM driver in the moment does
188 only support one type of soundcard (SoundWave32). Users of other soundcards
189 should try to boot DOS first and let their DOS drivers initialize the
190 soundcard and CDROM, then warm boot (or use loadlin) their PC to start
191 Linux.
192 Support for the CDROM-interface of SoundWave32-soundcards is directly
193 implemented in the AZTECH driver. Please edit linux/drivers/cdrom/aztdc.h,
194 uncomment line '#define AZT_SW32' and set the appropriate value for
195 AZT_BASE_ADDR and AZT_SW32_BASE_ADDR. This support was tested with an Orchid
196 CDS-3110 connected to a SoundWave32.
197 If you want your soundcard to be supported, find out, how it needs to be
198 configured and mail me (see 6.) the appropriate information.
202 Multisession support for CD's still is a myth. I implemented and tested a basic
203 support for multisession and XA CDs, but I still have not enough CDs and appli-
204 cations to test it rigorously. So if you'd like to help me, please contact me
205 (Email address see below). As of version 1.4 and newer you can enable the
206 multisession support in aztcd.h by setting AZT_MULTISESSION to 1. Doing so
207 will cause the ISO9660-filesystem to deal with multisession CDs, ie. redirect
208 requests to the Table of Contents (TOC) information from the last session,
209 which contains the info of all previous sessions etc.. If you do set
210 AZT_MULTISESSION to 0, you can use multisession CDs anyway. In that case the
211 drive's firmware will do automatic redirection. For the ISO9660-filesystem any
212 multisession CD will then look like a 'normal' single session CD. But never-
213 theless the data of all sessions are viewable and accessible. So with practical-
214 ly all real world applications you won't notice the difference. But as future
215 applications may make use of advanced multisession features, I've started to
216 implement the interface for the ISO9660 multisession interface via ioctl
220 The drive status recognition does not work correctly in all cases. Changing
221 a disk or having the door open, when a drive is already mounted, is detected
222 by the Aztech driver itself, but nevertheless causes multiple read attempts
223 by the different layers of the ISO9660-filesystem driver, which finally timeout,
224 so you have to wait quite a little... But isn't it bad style to change a disk
225 in a mounted drive, anyhow ?!
227 The driver uses busy wait in most cases for the drive handshake (macros
228 STEN_LOW and DTEN_LOW). I tested with a 486/DX2 at 66MHz and a Pentium at
229 60MHz and 90MHz. Whenever you use a much faster machine you are likely to get
230 timeout messages. In that case edit aztcd.h and increase the timeout value
233 For some 'slow' drive commands I implemented waiting with a timer waitqueue
234 (macro STEN_LOW_WAIT). If you get this timeout message, you may also edit
235 aztcd.h and increase the timeout value AZT_STATUS_DELAY. The waitqueue has
236 shown to be a little critical. If you get kernel panic messages, edit aztcd.c
237 and substitute STEN_LOW_WAIT by STEN_LOW. Busy waiting with STEN_LOW is more
238 stable, but also causes CPU overhead.
241 With release 1.20 aztcd was modified to allow access to CD-ROMS when running
242 under dosemu-0.60.0 aztcd-versions before 1.20 are most likely to crash
243 Linux, when a CD-ROM is accessed under dosemu. This problem has partly been
244 fixed, but still when accessing a directory for the first time the system
245 might hang for some 30sec. So be patient, when using dosemu's CD-ROM support
246 in combination with aztcd :-) !
247 This problem has now (July 1995) been fixed by a modification to dosemu's
248 CD-ROM driver. The new version came with dosemu-0.60.2, see dosemu's
252 Please send detailed bug reports and bug fixes via EMail to
254 Werner.Zimmermann@fht-esslingen.de
256 Please include a description of your CD-ROM drive type and interface card,
257 the exact firmware message during Linux bootup, the version number of the
258 AZTECH-CDROM-driver and the Linux kernel version. Also a description of your
259 system's other hardware could be of interest, especially microprocessor type,
260 clock frequency, other interface cards such as soundcards, ethernet adapter,
261 game cards etc..
263 I will try to collect the reports and make the necessary modifications from
264 time to time. I may also come back to you directly with some bug fixes and
265 ask you to do further testing and debugging.
267 Editors of CD-ROMs are invited to send a 'cooperation' copy of their
268 CD-ROMs to the volunteers, who provided the CD-ROM support for Linux. My
269 snail mail address for such 'stuff' is
270 Prof. Dr. W. Zimmermann
271 Fachhochschule fuer Technik Esslingen
272 Fachbereich IT
273 Flandernstrasse 101
274 D-73732 Esslingen
275 Germany
279 The following drives ORCHID CDS3110, OKANO CDD110, WEARNES CDD110 and Conrad
280 TXC Nr. 993123-series 04 nearly look the same as AZTECH CDA268-01A, especially
281 they seem to use the same command codes. So it was quite simple to make the
282 AZTECH driver work with these drives.
284 Unfortunately I do not have any of these drives available, so I couldn't test
285 it myself. In some installations, it seems necessary to initialize the drive
286 with the DOS driver before (especially if combined with a sound card) and then
287 do a warm boot (CTRL-ALT-RESET) or start Linux from DOS, e.g. with 'loadlin'.
289 If you do not succeed, read chapter DEBUGGING. Thanks in advance!
291 Sorry for the inconvenience, but it is difficult to develop for hardware,
292 which you don't have available for testing. So if you like, please help us.
294 If you do have a CyCDROM CR520ie thanks to Hilmar Berger's help your chances
295 are good, that it will work with aztcd. The CR520ie is sold as an IDE-drive
296 and really is connected to the IDE interface (primary at 0x1F0 or secondary
297 at 0x170, configured as slave, not as master). Nevertheless it is not ATAPI
298 compatible but still uses Aztech's command codes.
302 -reread the complete README file
303 -make sure, that your drive is hardware configured for
304 transfer mode: polled
305 IRQ: not used
306 DMA: not used
307 Base Address: something like 300, 320 ...
308 You can check this, when you start the DOS driver, which came with your
309 drive. By appropriately configuring the drive and the DOS driver you can
310 check, whether your drive does operate in this mode correctly under DOS. If
311 it does not operate under DOS, it won't under Linux.
312 If your drive's base address is something like 0x170 or 0x1F0 (and it is
313 not a CyCDROM CR520ie or CR 940ie) you most likely are having an IDE/ATAPI-
314 compatible drive, which is not supported by aztcd.c, use ide-cd.c instead.
315 Make sure the Base Address is configured correctly in aztcd.h, also make
316 sure, that /dev/aztcd0 exists with the correct major number (compare it with
317 the entry in file /usr/include/linux/major.h for the Aztech drive).
318 -insert a CD-ROM and close the tray
319 -cold boot your PC (i.e. via the power on switch or the reset button)
320 -if you start Linux via DOS, e.g. using loadlin, make sure, that the DOS
321 driver for the CD-ROM drive is not loaded (comment out the calling lines
322 in DOS' config.sys!)
323 -look for the aztcd: init message during Linux init and note them exactly
324 -log in as root and do a mount -t iso9660 /dev/aztcd0 /mnt
325 -if you don't succeed in the first time, try several times. Try also to open
326 and close the tray, then mount again. Please note carefully all commands
327 you typed in and the aztcd-messages, which you get.
328 -if you get an 'Aztech CD-ROM init: aborted' message, read the remarks about
329 the version string below.
331 If this does not help, do the same with the following differences
332 -start DOS before; make now sure, that the DOS driver for the CD-ROM is
333 loaded under DOS (i.e. uncomment it again in config.sys)
334 -warm boot your PC (i.e. via CTRL-ALT-DEL)
335 if you have it, you can also start via loadlin (try both).
336 ...
337 Again note all commands and the aztcd-messages.
339 If you see STEN_LOW or STEN_LOW_WAIT error messages, increase the timeout
340 values.
342 If this still does not help,
343 -look in aztcd.c for the lines #if 0
344 #define AZT_TEST1
345 ...
346 #endif
347 and substitute '#if 0' by '#if 1'.
348 -recompile your kernel and repeat the above two procedures. You will now get
349 a bundle of debugging messages from the driver. Again note your commands
350 and the appropriate messages. If you have syslogd running, these messages
351 may also be found in syslogd's kernel log file. Nevertheless in some
352 installations syslogd does not yet run, when init() is called, thus look for
353 the aztcd-messages during init, before the login-prompt appears.
354 Then look in aztcd.c, to find out, what happened. The normal calling sequence
355 is: aztcd_init() during Linux bootup procedure init()
356 after doing a 'mount -t iso9660 /dev/aztcd0 /mnt' the normal calling sequence is
357 aztcd_open() -> Status 2c after cold reboot with CDROM or audio CD inserted
358 -> Status 8 after warm reboot with CDROM inserted
359 -> Status 2e after cold reboot with no disk, closed tray
360 -> Status 6e after cold reboot, mount with door open
361 aztUpdateToc()
362 aztGetDiskInfo()
363 aztGetQChannelInfo() repeated several times
364 aztGetToc()
365 aztGetQChannelInfo() repeated several times
366 a list of track information
367 do_aztcd_request() }
368 azt_transfer() } repeated several times
369 azt_poll }
370 Check, if there is a difference in the calling sequence or the status flags!
372 There are a lot of other messages, eg. the ACMD-command code (defined in
373 aztcd.h), status info from the getAztStatus-command and the state sequence of
374 the finite state machine in azt_poll(). The most important are the status
375 messages, look how they are defined and try to understand, if they make
376 sense in the context where they appear. With a CD-ROM inserted the status
377 should always be 8, except in aztcd_open(). Try to open the tray, insert an
378 audio disk, insert no disk or reinsert the CD-ROM and check, if the status
379 bits change accordingly. The status bits are the most likely point, where
380 the drive manufacturers may implement changes.
382 If you still don't succeed, a good point to start is to look in aztcd.c in
383 function aztcd_init, where the drive should be detected during init. Do the
384 following:
385 -reboot the system with boot parameter 'aztcd=<your base address>,0x79'. With
386 parameter 0x79 most of the drive version detection is bypassed. After that
387 you should see the complete version string including leading and trailing
388 blanks during init.
389 Now adapt the statement
390 if ((result[1]=='A')&&(result[2]=='Z' ...)
391 in aztcd_init() to exactly match the first 3 or 4 letters you have seen.
392 -Another point is the 'smart' card detection feature in aztcd_init(). Normally
393 the CD-ROM drive is ready, when aztcd_init is trying to read the version
394 string and a time consuming ACMD_SOFT_RESET command can be avoided. This is
395 detected by looking, if AFL_OP_OK can be read correctly. If the CD-ROM drive
396 hangs in some unknown state, e.g. because of an error before a warm start or
397 because you first operated under DOS, even the version string may be correct,
398 but the following commands will not. Then change the code in such a way,
399 that the ACMD_SOFT_RESET is issued in any case, by substituting the
400 if-statement 'if ( ...=AFL_OP_OK)' by 'if (1)'.
402 If you succeed, please mail me the exact version string of your drive and
403 the code modifications, you have made together with a short explanation.
404 If you don't succeed, you may mail me the output of the debugging messages.
405 But remember, they are only useful, if they are exact and complete and you
406 describe in detail your hardware setup and what you did (cold/warm reboot,
407 with/without DOS, DOS-driver started/not started, which Linux-commands etc.)
411 The AZTECH-Driver is a rework of the Mitsumi-Driver. Four major items had to
412 be reworked:
414 a) The Mitsumi drive does issue complete status information acknowledging
415 each command, the Aztech drive does only signal that the command was
416 processed. So whenever the complete status information is needed, an extra
417 ACMD_GET_STATUS command is issued. The handshake procedure for the drive
418 can be found in the functions aztSendCmd(), sendAztCmd() and getAztStatus().
420 b) The Aztech Drive does not have a ACMD_GET_DISK_INFO command, so the
421 necessary info about the number of tracks (firstTrack, lastTrack), disk
422 length etc. has to be read from the TOC in the lead in track (see function
423 aztGetDiskInfo()).
425 c) Whenever data is read from the drive, the Mitsumi drive is started with a
426 command to read an indefinite (0xffffff) number of sectors. When the appropriate
427 number of sectors is read, the drive is stopped by a ACDM_STOP command. This
428 does not work with the Aztech drive. I did not find a way to stop it. The
429 stop and pause commands do only work in AUDIO mode but not in DATA mode.
430 Therefore I had to modify the 'finite state machine' in function azt_poll to
431 only read a certain number of sectors and then start a new read on demand. As I
432 have not completely understood, how the buffer/caching scheme of the Mitsumi
433 driver was implemented, I am not sure, if I have covered all cases correctly,
434 whenever you get timeout messages, the bug is most likely to be in that
435 function azt_poll() around switch(cmd) .... case ACD_S_DATA.
437 d) I did not get information about changing drive mode. So I doubt, that the
438 code around function azt_poll() case AZT_S_MODE does work. In my test I have
439 not been able to switch to reading in raw mode. For reading raw mode, Aztech
440 uses a different command than for cooked mode, which I only have implemen-
441 ted in the ioctl-section but not in the section which is used by the ISO9660.
443 The driver was developed on an AST PC with Intel 486/DX2, 8MB RAM, 340MB IDE
444 hard disk and on an AST PC with Intel Pentium 60MHz, 16MB RAM, 520MB IDE
445 running Linux kernel version 1.0.9 from the LST 1.8 Distribution. The kernel
446 was compiled with gcc.2.5.8. My CD-ROM drive is an Aztech CDA268-01A. My
447 drive says, that it has Firmware Version AZT26801A1.3. It came with an ISA-bus
448 interface card and works with polled I/O without DMA and without interrupts.
449 The code for all other drives was 'remote' tested and debugged by a number of
450 volunteers on the Internet.
452 Points, where I feel that possible problems might be and all points where I
453 did not completely understand the drive's behaviour or trust my own code are
454 marked with /*???*/ in the source code. There are also some parts in the
455 Mitsumi driver, where I did not completely understand their code.
459 Without the help of P.Bush, Aztech, who delivered technical information
460 about the Aztech Drive and without the help of E.Moenkeberg, GWDG, who did a
461 great job in analyzing the command structure of various CD-ROM drives, this
462 work would not have been possible. E.Moenkeberg was also a great help in
463 making the software 'kernel ready' and in answering many of the CDROM-related
464 questions in the newsgroups. He really is *the* Linux CD-ROM guru. Thanks
465 also to all the guys on the Internet, who collected valuable technical
466 information about CDROMs.
468 Joe Nardone (joe@access.digex.net) was a patient tester even for my first
469 trial, which was more than slow, and made suggestions for code improvement.
470 Especially the 'finite state machine' azt_poll() was rewritten by Joe to get
471 clean C code and avoid the ugly 'gotos', which I copied from mcd.c.
473 Robby Schirmer (schirmer@fmi.uni-passau.de) tested the audio stuff (ioctls)
474 and suggested a lot of patches for them.
476 Joseph Piskor and Peter Nugent were the first users with the ORCHID CD3110
477 and also were very patient with the problems which occurred.
479 Reinhard Max delivered the information for the CDROM-interface of the
480 SoundWave32 soundcards.
482 Jochen Kunz and Olaf Kaluza delivered the information for supporting Conrad's
483 TXC drive.
485 Hilmar Berger delivered the patches for supporting CyCDROM CR520ie.
487 Anybody, who is interested in these items should have a look at 'ftp.gwdg.de',
488 directory 'pub/linux/cdrom' and at 'ftp.cdrom.com', directory 'pub/cdrom'.
490 11. PROGRAMMING ADD ONs: cdplay.c
491 You can use the ioctl-functions included in aztcd.c in your own programs. As
492 an example on how to do this, you will find a tiny CD Player for audio CDs
493 named 'cdplay.c'. It allows you to play audio CDs. You can play a specified
494 track, pause and resume or skip tracks forward and backwards. If you quit the
495 program without stopping the drive, playing is continued. You can also
496 (mis)use cdplay to read and hexdump data disks. You can find the code in the
497 APPENDIX of this file, which you should cut out with an editor and store in a
498 separate file 'cdplay.c'. To compile it and make it executable, do
499 gcc -s -Wall -O2 -L/usr/lib cdplay.c -o /usr/local/bin/cdplay # compiles it
500 chmod +755 /usr/local/bin/cdplay # makes it executable
501 ln -s /dev/aztcd0 /dev/cdrom # creates a link
502 (for /usr/lib substitute the top level directory, where your include files
503 reside, and for /usr/local/bin the directory, where you want the executable
504 binary to reside )
506 You have to set the correct permissions for cdplay *and* for /dev/mcd0 or
507 /dev/aztcd0 in order to use it. Remember, that you should not have /dev/cdrom
508 mounted, when you're playing audio CDs.
510 This program is just a hack for testing the ioctl-functions in aztcd.c. I will
511 not maintain it, so if you run into problems, discard it or have a look into
512 the source code 'cdplay.c'. The program does only contain a minimum of user
513 protection and input error detection. If you use the commands in the wrong
514 order or if you try to read a CD at wrong addresses, you may get error messages
515 or even hang your machine. If you get STEN_LOW, STEN_LOW_WAIT or segment violation
516 error messages when using cdplay, after that, the system might not be stable
517 any more, so you'd better reboot. As the ioctl-functions run in kernel mode,
518 most normal Linux-multitasking protection features do not work. By using
519 uninitialized 'wild' pointers etc., it is easy to write to other users' data
520 and program areas, destroy kernel tables etc.. So if you experiment with ioctls
521 as always when you are doing systems programming and kernel hacking, you
522 should have a backup copy of your system in a safe place (and you also
523 should try restoring from a backup copy first)!
525 A reworked and improved version called 'cdtester.c', which has yet more
526 features for testing CDROM-drives can be found in
527 Documentation/cdrom/sbpcd, written by E.Moenkeberg.
529 Werner Zimmermann
530 Fachhochschule fuer Technik Esslingen
531 (EMail: Werner.Zimmermann@fht-esslingen.de)
532 October, 1997
534 ---------------------------------------------------------------------------
535 APPENDIX: Source code of cdplay.c
537 /* Tiny Audio CD Player
539 Copyright 1994, 1995, 1996 Werner Zimmermann (Werner.Zimmermann@fht-esslingen.de)
541 This program originally was written to test the audio functions of the
542 AZTECH.CDROM-driver, but it should work with every CD-ROM drive. Before
543 using it, you should set a symlink from /dev/cdrom to your real CDROM
544 device.
546 The GNU General Public License applies to this program.
548 History: V0.1 W.Zimmermann: First release. Nov. 8, 1994
549 V0.2 W.Zimmermann: Enhanced functionality. Nov. 9, 1994
550 V0.3 W.Zimmermann: Additional functions. Nov. 28, 1994
551 V0.4 W.Zimmermann: fixed some bugs. Dec. 17, 1994
552 V0.5 W.Zimmermann: clean 'scanf' commands without compiler warnings
553 Jan. 6, 1995
554 V0.6 W.Zimmermann: volume control (still experimental). Jan. 24, 1995
555 V0.7 W.Zimmermann: read raw modified. July 26, 95
556 */
558 #include <stdio.h>
559 #include <ctype.h>
560 #include <sys/ioctl.h>
561 #include <sys/types.h>
562 #include <fcntl.h>
563 #include <unistd.h>
564 #include <linux/cdrom.h>
565 #include <linux/../../drivers/cdrom/aztcd.h>
567 void help(void)
568 { printf("Available Commands: STOP s EJECT/CLOSE e QUIT q\n");
569 printf(" PLAY TRACK t PAUSE p RESUME r\n");
570 printf(" NEXT TRACK n REPEAT LAST l HELP h\n");
571 printf(" SUB CHANNEL c TRACK INFO i PLAY AT a\n");
572 printf(" READ d READ RAW w VOLUME v\n");
573 }
575 int main(void)
576 { int handle;
577 unsigned char command=' ', ini=0, first=1, last=1;
578 unsigned int cmd, i,j,k, arg1,arg2,arg3;
579 struct cdrom_ti ti;
580 struct cdrom_tochdr tocHdr;
581 struct cdrom_subchnl subchnl;
582 struct cdrom_tocentry entry;
583 struct cdrom_msf msf;
584 union { struct cdrom_msf msf;
585 unsigned char buf[CD_FRAMESIZE_RAW];
586 } azt;
587 struct cdrom_volctrl volctrl;
589 printf("\nMini-Audio CD-Player V0.72 (C) 1994,1995,1996 W.Zimmermann\n");
590 handle=open("/dev/cdrom",O_RDWR);
591 ioctl(handle,CDROMRESUME);
593 if (handle<=0)
594 { printf("Drive Error: already playing, no audio disk, door open\n");
595 printf(" or no permission (you must be ROOT in order to use this program)\n");
596 }
597 else
598 { help();
599 while (1)
600 { printf("Type command (h = help): ");
601 scanf("%s",&command);
602 switch (command)
603 { case 'e': cmd=CDROMEJECT;
604 ioctl(handle,cmd);
605 break;
606 case 'p': if (!ini)
607 { printf("Command not allowed - play track first\n");
608 }
609 else
610 { cmd=CDROMPAUSE;
611 if (ioctl(handle,cmd)) printf("Drive Error\n");
612 }
613 break;
614 case 'r': if (!ini)
615 { printf("Command not allowed - play track first\n");
616 }
617 else
618 { cmd=CDROMRESUME;
619 if (ioctl(handle,cmd)) printf("Drive Error\n");
620 }
621 break;
622 case 's': cmd=CDROMPAUSE;
623 if (ioctl(handle,cmd)) printf("Drive error or already stopped\n");
624 cmd=CDROMSTOP;
625 if (ioctl(handle,cmd)) printf("Drive error\n");
626 break;
627 case 't': cmd=CDROMREADTOCHDR;
628 if (ioctl(handle,cmd,&tocHdr)) printf("Drive Error\n");
629 first=tocHdr.cdth_trk0;
630 last= tocHdr.cdth_trk1;
631 if ((first==0)||(first>last))
632 { printf ("--could not read TOC\n");
633 }
634 else
635 { printf("--first track: %d --last track: %d --enter track number: ",first,last);
637 scanf("%i",&arg1);
638 ti.cdti_trk0=arg1;
639 if (ti.cdti_trk0<first) ti.cdti_trk0=first;
640 if (ti.cdti_trk0>last) ti.cdti_trk0=last;
641 ti.cdti_ind0=0;
642 ti.cdti_trk1=last;
643 ti.cdti_ind1=0;
644 if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");
645 ini=1;
646 }
647 break;
648 case 'n': if (!ini++)
649 { if (ioctl(handle,CDROMREADTOCHDR,&tocHdr)) printf("Drive Error\n");
650 first=tocHdr.cdth_trk0;
651 last= tocHdr.cdth_trk1;
652 ti.cdti_trk0=first-1;
653 }
654 if ((first==0)||(first>last))
655 { printf ("--could not read TOC\n");
656 }
657 else
659 if (++ti.cdti_trk0 > last) ti.cdti_trk0=last;
660 ti.cdti_ind0=0;
661 ti.cdti_trk1=last;
662 ti.cdti_ind1=0;
663 if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");
664 ini=1;
665 }
666 break;
667 case 'l': if (!ini++)
668 { if (ioctl(handle,CDROMREADTOCHDR,&tocHdr)) printf("Drive Error\n");
669 first=tocHdr.cdth_trk0;
670 last= tocHdr.cdth_trk1;
671 ti.cdti_trk0=first+1;
672 }
673 if ((first==0)||(first>last))
674 { printf ("--could not read TOC\n");
675 }
676 else
678 if (--ti.cdti_trk0 < first) ti.cdti_trk0=first;
679 ti.cdti_ind0=0;
680 ti.cdti_trk1=last;
681 ti.cdti_ind1=0;
682 if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");
683 ini=1;
684 }
685 break;
686 case 'c': subchnl.cdsc_format=CDROM_MSF;
687 if (ioctl(handle,CDROMSUBCHNL,&subchnl))
688 printf("Drive Error\n");
689 else
690 { printf("AudioStatus:%s Track:%d Mode:%d MSF=%d:%d:%d\n", \
691 subchnl.cdsc_audiostatus==CDROM_AUDIO_PLAY ? "PLAYING":"NOT PLAYING",\
692 subchnl.cdsc_trk,subchnl.cdsc_adr, \
693 subchnl.cdsc_absaddr.msf.minute, subchnl.cdsc_absaddr.msf.second, \
694 subchnl.cdsc_absaddr.msf.frame);
695 }
696 break;
697 case 'i': if (!ini)
698 { printf("Command not allowed - play track first\n");
699 }
700 else
702 printf("Track No.: ");
703 scanf("%d",&arg1);
704 entry.cdte_track=arg1;
705 if (entry.cdte_track<first) entry.cdte_track=first;
706 if (entry.cdte_track>last) entry.cdte_track=last;
707 entry.cdte_format=CDROM_MSF;
708 if (ioctl(handle,cmd,&entry))
709 { printf("Drive error or invalid track no.\n");
710 }
711 else
712 { printf("Mode %d Track, starts at %d:%d:%d\n", \
713 entry.cdte_adr,entry.cdte_addr.msf.minute, \
714 entry.cdte_addr.msf.second,entry.cdte_addr.msf.frame);
715 }
716 }
717 break;
718 case 'a': cmd=CDROMPLAYMSF;
719 printf("Address (min:sec:frame) ");
720 scanf("%d:%d:%d",&arg1,&arg2,&arg3);
721 msf.cdmsf_min0 =arg1;
722 msf.cdmsf_sec0 =arg2;
723 msf.cdmsf_frame0=arg3;
724 if (msf.cdmsf_sec0 > 59) msf.cdmsf_sec0 =59;
725 if (msf.cdmsf_frame0> 74) msf.cdmsf_frame0=74;
726 msf.cdmsf_min1=60;
727 msf.cdmsf_sec1=00;
728 msf.cdmsf_frame1=00;
729 if (ioctl(handle,cmd,&msf))
730 { printf("Drive error or invalid address\n");
731 }
732 break;
733 #ifdef AZT_PRIVATE_IOCTLS /*not supported by every CDROM driver*/
734 case 'd': cmd=CDROMREADCOOKED;
735 printf("Address (min:sec:frame) ");
736 scanf("%d:%d:%d",&arg1,&arg2,&arg3);
737 azt.msf.cdmsf_min0 =arg1;
738 azt.msf.cdmsf_sec0 =arg2;
739 azt.msf.cdmsf_frame0=arg3;
740 if (azt.msf.cdmsf_sec0 > 59) azt.msf.cdmsf_sec0 =59;
741 if (azt.msf.cdmsf_frame0> 74) azt.msf.cdmsf_frame0=74;
742 if (ioctl(handle,cmd,&azt.msf))
743 { printf("Drive error, invalid address or unsupported command\n");
744 }
745 k=0;
746 getchar();
747 for (i=0;i<128;i++)
748 { printf("%4d:",i*16);
749 for (j=0;j<16;j++)
750 { printf("%2x ",azt.buf[i*16+j]);
751 }
752 for (j=0;j<16;j++)
753 { if (isalnum(azt.buf[i*16+j]))
754 printf("%c",azt.buf[i*16+j]);
755 else
756 printf(".");
757 }
758 printf("\n");
759 k++;
760 if (k>=20)
761 { printf("press ENTER to continue\n");
762 getchar();
763 k=0;
764 }
765 }
766 break;
767 case 'w': cmd=CDROMREADRAW;
768 printf("Address (min:sec:frame) ");
769 scanf("%d:%d:%d",&arg1,&arg2,&arg3);
770 azt.msf.cdmsf_min0 =arg1;
771 azt.msf.cdmsf_sec0 =arg2;
772 azt.msf.cdmsf_frame0=arg3;
773 if (azt.msf.cdmsf_sec0 > 59) azt.msf.cdmsf_sec0 =59;
774 if (azt.msf.cdmsf_frame0> 74) azt.msf.cdmsf_frame0=74;
775 if (ioctl(handle,cmd,&azt))
776 { printf("Drive error, invalid address or unsupported command\n");
777 }
778 k=0;
779 for (i=0;i<147;i++)
780 { printf("%4d:",i*16);
781 for (j=0;j<16;j++)
782 { printf("%2x ",azt.buf[i*16+j]);
783 }
784 for (j=0;j<16;j++)
785 { if (isalnum(azt.buf[i*16+j]))
786 printf("%c",azt.buf[i*16+j]);
787 else
788 printf(".");
789 }
790 printf("\n");
791 k++;
792 if (k>=20)
793 { getchar();
794 k=0;
795 }
796 }
797 break;
798 #endif
799 case 'v': cmd=CDROMVOLCTRL;
800 printf("--Channel 0 Left (0-255): ");
801 scanf("%d",&arg1);
802 printf("--Channel 1 Right (0-255): ");
803 scanf("%d",&arg2);
804 volctrl.channel0=arg1;
805 volctrl.channel1=arg2;
806 volctrl.channel2=0;
807 volctrl.channel3=0;
808 if (ioctl(handle,cmd,&volctrl))
809 { printf("Drive error or unsupported command\n");
810 }
811 break;
812 case 'q': if (close(handle)) printf("Drive Error: CLOSE\n");
813 exit(0);
814 case 'h': help();
815 break;
816 default: printf("unknown command\n");
817 break;
818 }
819 }
820 }
821 return 0;
822 }