diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 674f3cc146bc..e3e867ab84d6 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1,1668 +1,1672 @@ # # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.457 1998/09/03 20:58:34 nsouch Exp $ +# $Id: LINT,v 1.458 1998/09/08 18:09:49 brian Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from # this file as required. # # # This directive is mandatory; it defines the architecture to be # configured for; in this case, the 386 family based IBM-PC and # compatibles. # machine "i386" # # This is the ``identification'' of the kernel. Usually this should # be the same as the name of your kernel. # ident LINT # # The `maxusers' parameter controls the static sizing of a number of # internal system tables by a complicated formula defined in param.c. # maxusers 10 # # Certain applications can grow to be larger than the 128M limit # that FreeBSD initially imposes. Below are some options to # allow that limit to grow to 256MB, and can be increased further # with changing the parameters. MAXDSIZ is the maximum that the # limit can be set to, and the DFLDSIZ is the default value for # the limit. You might want to set the default lower than the # max, and explicitly set the maximum with a shell command for processes # that regularly exceed the limit like INND. # options "MAXDSIZ=(256*1024*1024)" options "DFLDSIZ=(256*1024*1024)" # When this is set, be extra conservative in various parts of the kernel # and choose functionality over speed (on the widest variety of systems). options FAILSAFE # Options for the VM subsystem #options PQ_NOOPT # No coloring options PQ_LARGECACHE # color for 512k/16k cache #options PQ_HUGECACHE # color for 1024k/16k cache # This allows you to actually store this configuration file into # the kernel binary itself, where it may be later read by saying: # strings /kernel | grep ^___ | sed -e 's/^___//' > MYKERNEL # options INCLUDE_CONFIG_FILE # Include this file in kernel # # This directive defines a number of things: # - The compiled kernel is to be called `kernel' # - The root filesystem might be on partition wd0a # - Crash dumps will be written to wd0b, if possible. Specifying the # dump device here is not recommended. Use dumpon(8). # config kernel root on wd0 dumps on wd0 ##################################################################### # SMP OPTIONS: # # SMP enables building of a Symmetric MultiProcessor Kernel. # APIC_IO enables the use of the IO APIC for Symmetric I/O. # NCPU sets the number of CPUs, defaults to 2. # NBUS sets the number of busses, defaults to 4. # NAPIC sets the number of IO APICs on the motherboard, defaults to 1. # NINTR sets the total number of INTs provided by the motherboard. # # Notes: # # An SMP kernel will ONLY run on an Intel MP spec. qualified motherboard. # # Be sure to disable 'cpu "I386_CPU"' && 'cpu "I486_CPU"' for SMP kernels. # # Check the 'Rogue SMP hardware' section to see if additional options # are required by your hardware. # # Mandatory: options SMP # Symmetric MultiProcessor Kernel options APIC_IO # Symmetric (APIC) I/O # Optional, these are the defaults plus 1: options NCPU=5 # number of CPUs options NBUS=5 # number of busses options NAPIC=2 # number of IO APICs options NINTR=25 # number of INTs # # Rogue SMP hardware: # # Bridged PCI cards: # # The MP tables of most of the current generation MP motherboards # do NOT properly support bridged PCI cards. To use one of these # cards you should refer to ??? ##################################################################### # CPU OPTIONS # # You must specify at least one CPU (the one you intend to run on); # deleting the specification for CPUs you don't need to use may make # parts of the system run faster. This is especially true removing # I386_CPU. # cpu "I386_CPU" cpu "I486_CPU" cpu "I586_CPU" # aka Pentium(tm) cpu "I686_CPU" # aka Pentium Pro(tm) # # Options for CPU features. # # CPU_BLUELIGHTNING_FPU_OP_CACHE enables FPU operand cache on IBM # BlueLightning CPU. It works only with Cyrix FPU, and this option # should not be used with Intel FPU. # # CPU_BLUELIGHTNING_3X enables triple-clock mode on IBM Blue Lightning # CPU if CPU supports it. The default is double-clock mode on # BlueLightning CPU box. # # CPU_BTB_EN enables branch target buffer on Cyrix 5x86 (NOTE 1). # # CPU_DIRECT_MAPPED_CACHE sets L1 cache of Cyrix 486DLC CPU in direct # mapped mode. Default is 2-way set associative mode. # # CPU_CYRIX_NO_LOCK enables weak locking for the entire address space # of Cyrix 6x86 and 6x86MX CPUs. If this option is not set and # FAILESAFE is defined, NO_LOCK bit of CCR1 is cleared. (NOTE 3) # # CPU_DISABLE_5X86_LSSER disables load store serialize (i.e. enables # reorder). This option should not be used if you use memory mapped # I/O device(s). # # CPU_FASTER_5X86_FPU enables faster FPU exception handler. # # CPU_I486_ON_386 enables CPU cache on i486 based CPU upgrade products # for i386 machines. # # CPU_IORT defines I/O clock delay time (NOTE 1). Default vaules of # I/O clock delay time on Cyrix 5x86 and 6x86 are 0 and 7,respectively # (no clock delay). # # CPU_LOOP_EN prevents flushing the prefetch buffer if the destination # of a jump is already present in the prefetch buffer on Cyrix 5x86(NOTE # 1). # # CPU_RSTK_EN enables return stack on Cyrix 5x86 (NOTE 1). # # CPU_SUSP_HLT enables suspend on HALT. If this option is set, CPU # enters suspend mode following execution of HALT instruction. # # CPU_WT_ALLOC enables write-through allocation. # # CYRIX_CACHE_WORKS enables CPU cache on Cyrix 486 CPUs with cache # flush at hold state. # # CYRIX_CACHE_REALLY_WORKS enables (1) CPU cache on Cyrix 486 CPUs # without cache flush at hold state, and (2) write-back CPU cache on # Cyrix 6x86 whose revision < 2.7 (NOTE 2). # # NO_F00F_HACK disables the hack that prevents Pentiums (and ONLY # Pentiums) from locking up when a LOCK CMPXCHG8B instruction is # executed. This should be included for ALL kernels that won't run # on a Pentium. # # NOTE 1: The options, CPU_BTB_EN, CPU_LOOP_EN, CPU_IORT, # CPU_LOOP_ENand CPU_RSTK_EN should no be used becasue of CPU bugs. # These options may crash your system. # # NOTE 2: If CYRIX_CACHE_REALLY_WORKS is not set, CPU cache is enabled # in write-through mode when revision < 2.7. If revision of Cyrix # 6x86 >= 2.7, CPU cache is always enabled in write-back mode. # # NOTE 3: This option may cause failures for software that requires # locked cycles in order to operate correctly. # options "CPU_BLUELIGHTNING_FPU_OP_CACHE" options "CPU_BLUELIGHTNING_3X" options "CPU_BTB_EN" options "CPU_DIRECT_MAPPED_CACHE" options "CPU_DISABLE_5X86_LSSER" options "CPU_FASTER_5X86_FPU" options "CPU_I486_ON_386" options "CPU_IORT" options "CPU_LOOP_EN" options "CPU_RSTK_EN" options "CPU_SUSP_HLT" options "CYRIX_CACHE_WORKS" options "CYRIX_CACHE_REALLY_WORKS" #options "NO_F00F_HACK" # # A math emulator is mandatory if you wish to run on hardware which # does not have a floating-point processor. Pick either the original, # bogus (but freely-distributable) math emulator, or a much more # fully-featured but GPL-licensed emulator taken from Linux. # options MATH_EMULATE #Support for x87 emulation # Don't enable both of these in a real config. options GPL_MATH_EMULATE #Support for x87 emulation via #new math emulator ##################################################################### # COMPATIBILITY OPTIONS # # Implement system calls compatible with 4.3BSD and older versions of # FreeBSD. You probably do NOT want to remove this as much current code # still relies on the 4.3 emulation. # options "COMPAT_43" # # Allow user-mode programs to manipulate their local descriptor tables. # This option is required for the WINE Windows(tm) emulator, and is # not used by anything else (that we know of). # options USER_LDT #allow user-level control of i386 ldt # # These three options provide support for System V Interface # Definition-style interprocess communication, in the form of shared # memory, semaphores, and message queues, respectively. # options SYSVSHM options SYSVSEM options SYSVMSG # # This option includes a MD5 routine in the kernel, this is used for # various authentication and privacy uses. # options "MD5" # # Allow processes to switch to vm86 mode, as well as enabling direct # user-mode access to the I/O port space. This option is necessary for # the doscmd emulator to run. # options "VM86" ##################################################################### # DEBUGGING OPTIONS # # Enable the kernel debugger. # options DDB # # Don't drop into DDB for a panic. Intended for unattended operation # where you may want to drop to DDB from the console, but still want # the machine to recover from a panic # options DDB_UNATTENDED # # If using GDB remote mode to debug the kernel, there's a non-standard # extension to the remote protocol that can be used to use the serial # port as both the debugging port and the system console. It's non- # standard and you're on your own if you enable it. See also the # "remotechat" variables in the FreeBSD specific version of gdb. # options GDB_REMOTE_CHAT # # KTRACE enables the system-call tracing facility ktrace(2). # options KTRACE #kernel tracing # # The DIAGNOSTIC option is used in a number of source files to enable # extra sanity checking of internal structures. This support is not # enabled by default because of the extra time it would take to check # for these conditions, which can only occur as a result of # programming errors. # options DIAGNOSTIC # # PERFMON causes the driver for Pentium/Pentium Pro performance counters # to be compiled. See perfmon(4) for more information. # options PERFMON # # This option let some drivers co-exist that can't co-exist in a running # system. This is used to be able to compile all kernel code in one go for # quality assurance purposes (like this file, which the option takes it name # from.) # options COMPILING_LINT # XXX - this doesn't belong here. # Allow ordinary users to take the console - this is useful for X. options UCONSOLE # XXX - this doesn't belong here either options USERCONFIG #boot -c editor options USERCONFIG_BOOT #imply -c and parse info area options VISUAL_USERCONFIG #visual boot -c editor ##################################################################### # NETWORKING OPTIONS # # Protocol families: # Only the INET (Internet) family is officially supported in FreeBSD. # Source code for the NS (Xerox Network Service) is provided for amusement # value. # options INET #Internet communications protocols options IPX #IPX/SPX communications protocols options IPXIP #IPX in IP encapsulation (not available) options IPTUNNEL #IP in IPX encapsulation (not available) options NETATALK #Appletalk communications protocols # These are currently broken but are shipped due to interest. #options NS #Xerox NS protocols # These are currently broken and are no longer shipped due to lack # of interest. #options CCITT #X.25 network layer #options ISO #options TPIP #ISO TP class 4 over IP #options TPCONS #ISO TP class 0 over X.25 #options LLC #X.25 link layer for Ethernets #options HDLC #X.25 link layer for serial lines #options EON #ISO CLNP over IP #options NSIP #XNS over IP # # Network interfaces: # The `loop' pseudo-device is MANDATORY when networking is enabled. # The `ether' pseudo-device provides generic code to handle # Ethernets; it is MANDATORY when a Ethernet device driver is # configured. # The 'fddi' pseudo-device provides generic code to support FDDI. # The `sppp' pseudo-device serves a similar role for certain types # of synchronous PPP links (like `cx', `ar'). # The `sl' pseudo-device implements the Serial Line IP (SLIP) service. # The `ppp' pseudo-device implements the Point-to-Point Protocol. # The `bpfilter' pseudo-device enables the Berkeley Packet Filter. Be # aware of the legal and administrative consequences of enabling this # option. The number of devices determines the maximum number of # simultaneous BPF clients programs runnable. # The `disc' pseudo-device implements a minimal network interface, # which throws away all packets sent and never receives any. It is # included for testing purposes. # The `tun' pseudo-device implements the User Process PPP (iijppp) # # The PPP_BSDCOMP option enables support for compress(1) style entire # packet compression, the PPP_DEFLATE is for zlib/gzip style compression. # PPP_FILTER enables code for filtering the ppp data stream and selecting # events for resetting the demand dial activity timer - requires bpfilter. # See pppd(8) for more details. # pseudo-device ether #Generic Ethernet pseudo-device fddi #Generic FDDI pseudo-device sppp #Generic Synchronous PPP pseudo-device loop #Network loopback device pseudo-device bpfilter 4 #Berkeley packet filter pseudo-device disc #Discard device pseudo-device tun 1 #Tunnel driver (user process ppp(8)) pseudo-device sl 2 #Serial Line IP pseudo-device ppp 2 #Point-to-point protocol options PPP_BSDCOMP #PPP BSD-compress support options PPP_DEFLATE #PPP zlib/deflate/gzip support options PPP_FILTER #enable bpf filtering (needs bpfilter) # # Internet family options: # # TCP_COMPAT_42 causes the TCP code to emulate certain bugs present in # 4.2BSD. This option should not be used unless you have a 4.2BSD # machine and TCP connections fail. # # MROUTING enables the kernel multicast packet forwarder, which works # with mrouted(8). # # IPFIREWALL enables support for IP firewall construction, in # conjunction with the `ipfw' program. IPFIREWALL_VERBOSE sends # logged packets to the system logger. IPFIREWALL_VERBOSE_LIMIT # limits the number of times a matching entry can be logged. # # WARNING: IPFIREWALL defaults to a policy of "deny ip from any to any" # and if you do not add other rules during startup to allow access, # YOU WILL LOCK YOURSELF OUT. It is suggested that you set firewall=open # in /etc/rc.conf when first enabling this feature, then refining the # firewall rules in /etc/rc.firewall after you've tested that the new kernel # feature works properly. # # IPFIREWALL_DEFAULT_TO_ACCEPT causes the default rule (at boot) to # allow everything. Use with care, if a cracker can crash your # firewall machine, they can get to your protected machines. However, # if you are using it as an as-needed filter for specific problems as # they arise, then this may be for you. Changing the default to 'allow' # means that you won't get stuck if the kernel and /sbin/ipfw binary get # out of sync. # # IPDIVERT enables the divert IP sockets, used by ``ipfw divert'' # # IPFILTER enables Darren Reed's ipfilter package. # IPFILTER_LOG enables ipfilter's logging. # IPFILTER_LKM enables LKM support for an ipfilter module (untested). # # TCPDEBUG is undocumented. # options "TCP_COMPAT_42" #emulate 4.2BSD TCP bugs options MROUTING # Multicast routing options IPFIREWALL #firewall options IPFIREWALL_VERBOSE #print information about # dropped packets options IPFIREWALL_FORWARD #enable xparent proxy support options "IPFIREWALL_VERBOSE_LIMIT=100" #limit verbosity options IPFIREWALL_DEFAULT_TO_ACCEPT #allow everything by default options IPDIVERT #divert sockets options IPFILTER #kernel ipfilter support options IPFILTER_LOG #ipfilter logging #options IPFILTER_LKM #kernel support for ip_fil.o LKM options TCPDEBUG ##################################################################### # FILESYSTEM OPTIONS # # Only the root, /usr, and /tmp filesystems need be statically # compiled; everything else will be automatically loaded at mount # time. (Exception: the UFS family---FFS, and MFS --- cannot # currently be demand-loaded.) Some people still prefer to statically # compile other filesystems as well. # # NB: The NULL, PORTAL, UMAP and UNION filesystems are known to be # buggy, and WILL panic your system if you attempt to do anything with # them. They are included here as an incentive for some enterprising # soul to sit down and fix them. # # One of these is mandatory: options FFS #Fast filesystem options NFS #Network File System # The rest are optional: # options NFS_NOSERVER #Disable the NFS-server code. options "CD9660" #ISO 9660 filesystem options FDESC #File descriptor filesystem options KERNFS #Kernel filesystem options MFS #Memory File System options MSDOSFS #MS DOS File System options NULLFS #NULL filesystem options PORTAL #Portal filesystem options PROCFS #Process filesystem options UMAPFS #UID map filesystem options UNION #Union filesystem options "CD9660_ROOT" #CD-ROM usable as root device options FFS_ROOT #FFS usable as root device options NFS_ROOT #NFS usable as root device # DEVFS and SLICE are experimental but work. # SLICE disables too much old code so enabling it in LINT would be bad options DEVFS #devices filesystem #options SLICE #devfs based disk handling # Allow the FFS to use Softupdates technology. # To do this you need to copy the two files # /sys/ufs/ffs/softdep.h and /sys/ufs/ffs/ffs_softdep.c # from /usr/src/contrib/sys/softupdates # and understand the licensing restrictions. # You should also check on the FreeBSD website for newer versions. #options SOFTUPDATES # (we can't actually enable it because the files may not be present) # Make space in the kernel for a MFS root filesystem. Define to the number # of kilobytes to reserve for the filesystem. options MFS_ROOT=10 # Allow the MFS_ROOT code to load the MFS image from floppy if it is missing. options MFS_AUTOLOAD # Allows MFS filesystems to be exported via nfs options EXPORTMFS # Allow this many swap-devices. options NSWAPDEV=20 # Disk quotas are supported when this option is enabled. If you # change the value of this option, you must do a `make clean' in your # kernel compile directory in order to get a working kernel. # options QUOTA #enable disk quotas # Add more checking code to various filesystems #options NULLFS_DIAGNOSTIC #options KERNFS_DIAGNOSTIC #options UMAPFS_DIAGNOSTIC #options UNION_DIAGNOSTIC # In particular multi-session CD-Rs might require a huge amount of # time in order to "settle". If we are about mounting them as the # root f/s, we gotta wait a little. # # The number is supposed to be in seconds. options "CD9660_ROOTDELAY=20" # If you are running a machine just as a fileserver for PC and MAC # users, using SAMBA or Netatalk, you may consider setting this option # and keeping all those users' directories on a filesystem that is # mounted with the suiddir option. This gives new files the same # ownership as the directory (similiar to group). It's a security hole # if you let these users run programs, so confine it to file-servers # (but it'll save you lots of headaches in those cases). Root owned # directories are exempt and X bits are cleared. The suid bit must be # set on the directory as well; see chmod(1) PC owners can't see/set # ownerships so they keep getting their toes trodden on. This saves # you all the support calls as the filesystem it's used on will act as # they expect: "It's my dir so it must be my file". # options SUIDDIR # Add some error checking code to the null_bypass routine # in the NULL filesystem #options SAFETY # NFS options: options "NFS_MINATTRTIMO=3" # VREG attrib cache timeout in sec options "NFS_MAXATTRTIMO=60" options "NFS_MINDIRATTRTIMO=30" # VDIR attrib cache timeout in sec options "NFS_MAXDIRATTRTIMO=60" options "NFS_GATHERDELAY=10" # Default write gather delay (msec) options "NFS_UIDHASHSIZ=29" # Tune the size of nfssvc_sock with this options "NFS_WDELAYHASHSIZ=16" # and with this options "NFS_MUIDHASHSIZ=63" # Tune the size of nfsmount with this options NFS_DEBUG # Enable NFS Debugging # CFS stuff: #options CFS #CODA filesystem. #pseudo-device vcfs 4 #coda minicache <-> venus comm. ##################################################################### # POSIX P1003.1B # Real time extensions added int the 1993 Posix # P1003_1B: Infrastructure # _KPOSIX_PRIORITY_SCHEDULING: Build in _POSIX_PRIORITY_SCHEDULING # _KPOSIX_VERSION: Version kernel is built for options "P1003_1B" options "_KPOSIX_PRIORITY_SCHEDULING" options "_KPOSIX_VERSION=199309L" ##################################################################### # SCSI DEVICES # SCSI DEVICE CONFIGURATION # The SCSI subsystem consists of the `base' SCSI code, a number of # high-level SCSI device `type' drivers, and the low-level host-adapter # device drivers. The host adapters are listed in the ISA and PCI # device configuration sections below. # # Beginning with FreeBSD 2.0.5 you can wire down your SCSI devices so # that a given bus, target, and LUN always come on line as the same # device unit. In earlier versions the unit numbers were assigned # in the order that the devices were probed on the SCSI bus. This # means that if you removed a disk drive, you may have had to rewrite # your /etc/fstab file, and also that you had to be careful when adding # a new disk as it may have been probed earlier and moved your device # configuration around. # This old behavior is maintained as the default behavior. The unit # assignment begins with the first non-wired down unit for a device # type. For example, if you wire a disk as "sd3" then the first # non-wired disk will be assigned sd4. # The syntax for wiring down devices is: # controller scbus0 at ahc0 # Single bus device # controller scbus1 at ahc1 bus 0 # Single bus device # controller scbus3 at ahc2 bus 0 # Twin bus device # controller scbus2 at ahc2 bus 1 # Twin bus device # disk sd0 at scbus0 target 0 unit 0 # disk sd1 at scbus3 target 1 # disk sd2 at scbus2 target 3 # tape st1 at scbus1 target 6 # device cd0 at scbus? # "units" (SCSI logical unit number) that are not specified are # treated as if specified as LUN 0. # All SCSI devices allocate as many units as are required. # The "unknown" device (uk? in pre-2.0.5) is now part of the base SCSI # configuration and doesn't have to be explicitly configured. controller scbus0 #base SCSI code device ch0 #SCSI media changers device sd0 #SCSI disks device st0 #SCSI tapes device cd0 #SCSI CD-ROMs device od0 #SCSI optical disk # The previous devices (ch, sd, st, cd) are recognized by config. # config doesn't (and shouldn't) know about these newer ones, # so we have to specify that they are on a SCSI bus with the "at scbus?" # clause. device worm0 at scbus? # SCSI worm device pt0 at scbus? # SCSI processor type device sctarg0 at scbus? # SCSI target # SCSI OPTIONS: # SCSIDEBUG: When defined enables debugging macros # NO_SCSI_SENSE: When defined disables sense descriptions (about 4k) # SCSI_REPORT_GEOMETRY: Always report disk geometry at boot up instead # of only when booting verbosely. options SCSIDEBUG #options NO_SCSI_SENSE options SCSI_REPORT_GEOMETRY # Options for the `od' optical disk driver: # # If drive returns sense key as 0x02 with vendor specific additional # sense code (ASC) and additional sense code qualifier (ASCQ), or # illegal ASC and ASCQ. This cause an error (NOT READY) and retrying. # To suppress this, use the following option. # options OD_BOGUS_NOT_READY # # For an automatic spindown, try this. Again, preferably as an # option in your config file. # WARNING! Use at your own risk. Joerg's ancient SONY SMO drive # groks it fine, while Shunsuke's Fujitsu chokes on it and times # out. # options OD_AUTO_TURNOFF ##################################################################### # MISCELLANEOUS DEVICES AND OPTIONS # The `pty' device usually turns out to be ``effectively mandatory'', # as it is required for `telnetd', `rlogind', `screen', `emacs', and # `xterm', among others. pseudo-device pty 16 #Pseudo ttys - can go as high as 256 pseudo-device speaker #Play IBM BASIC-style noises out your speaker pseudo-device gzip #Exec gzipped a.out's pseudo-device vn #Vnode driver (turns a file into a device) pseudo-device snp 3 #Snoop device - to look at pty/vty/etc.. pseudo-device ccd 4 #Concatenated disk driver # These are only for watching for bitrot in old tty code. # broken #pseudo-device tb # These are only for watching for bitrot in old SCSI code. pseudo-device su #scsi user pseudo-device ssc #super scsi # Size of the kernel message buffer. Should be N * pagesize. options "MSGBUF_SIZE=40960" ##################################################################### # HARDWARE DEVICE CONFIGURATION # ISA and EISA devices: # EISA support is available for some device, so they can be auto-probed. # Micro Channel is not supported at all. # # Mandatory ISA devices: isa, npx # controller isa0 # # Options for `isa': # # AUTO_EOI_1 enables the `automatic EOI' feature for the master 8259A # interrupt controller. This saves about 0.7-1.25 usec for each interrupt. # This option breaks suspend/resume on some portables. # # AUTO_EOI_2 enables the `automatic EOI' feature for the slave 8259A # interrupt controller. This saves about 0.7-1.25 usec for each interrupt. # Automatic EOI is documented not to work for for the slave with the # original i8259A, but it works for some clones and some integrated # versions. # # BOUNCE_BUFFERS provides support for ISA DMA on machines with more # than 16 megabytes of memory. It doesn't hurt on other machines. # Some broken EISA and VLB hardware may need this, too. # # MAXMEM specifies the amount of RAM on the machine; if this is not # specified, FreeBSD will first read the amount of memory from the CMOS # RAM, so the amount of memory will initially be limited to 64MB or 16MB # depending on the BIOS. If the BIOS reports 64MB, a memory probe will # then attempt to detect the installed amount of RAM. If this probe # fails to detect >64MB RAM you will have to use the MAXMEM option. # The amount is in kilobytes, so for a machine with 128MB of RAM, it would # be 131072 (128 * 1024). # # TUNE_1542 enables the automatic ISA bus speed selection for the # Adaptec 1542 boards. Does not work for all boards, use it with caution. # # BROKEN_KEYBOARD_RESET disables the use of the keyboard controller to # reset the CPU for reboot. This is needed on some systems with broken # keyboard controllers. # # PAS_JOYSTICK_ENABLE enables the gameport on the ProAudio Spectrum options "AUTO_EOI_1" #options "AUTO_EOI_2" options BOUNCE_BUFFERS options "MAXMEM=(128*1024)" options "TUNE_1542" #options BROKEN_KEYBOARD_RESET #options PAS_JOYSTICK_ENABLE # Enable support for the kernel PLL to use an external PPS signal, # under supervision of [x]ntpd(8) # More info in ftp://ftp.udel.edu/pub/ntp/kernel.tar.Z options PPS_SYNC # Enable PnP support in the kernel. This allows you to automaticly # attach to PnP cards for drivers that support it and allows you to # configure cards from USERCONFIG. See pnp(4) for more info. controller pnp0 # The pcvt console driver (vt220 compatible). device vt0 at isa? port "IO_KBD" tty irq 1 vector pcrint options XSERVER # support for running an X server. options FAT_CURSOR # start with block cursor # This PCVT option is for keyboards such as those used on IBM ThinkPad laptops options PCVT_SCANSET=2 # IBM keyboards are non-std # The syscons console driver (sco color console compatible). device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr options MAXCONS=16 # number of virtual consoles options SLOW_VGA # do byte-wide i/o's to TS and GDC regs options "STD8X16FONT" # Compile font in makeoptions "STD8X16FONT"="cp850" options SC_HISTORY_SIZE=200 # number of history buffer lines options SC_DISABLE_REBOOT # disable reboot key sequence # If the screen flickers badly when the mouse pointer is moved, try this. options SC_BAD_FLICKER # # `flags' for sc0: # 0x01 Use a 'visual' bell # 0x02 Use a 'blink' cursor # 0x04 Use a 'underline' cursor # 0x06 Use a 'blinking underline' (destructive) cursor # 0x08 Force detection of keyboard, else we always assume a keyboard # 0x10 Old-style (XT) keyboard support, useful for older ThinkPads # 0x20 Don't reset keyboard, useful for some newer ThinkPads # 0x40 Make the bell quiet if it is rung in the backgroud vty. # # The Numeric Processing eXtension driver. This should be configured if # your machine has a math co-processor, unless the coprocessor is very # buggy. If it is not configured then you *must* configure math emulation # (see above). If both npx0 and emulation are configured, then only npx0 # is used (provided it works). device npx0 at isa? port "IO_NPX" iosiz 0x0 flags 0x0 irq 13 vector npxintr # # `flags' for npx0: # 0x01 don't use the npx registers to optimize bcopy # 0x02 don't use the npx registers to optimize bzero # 0x04 don't use the npx registers to optimize copyin or copyout. # The npx registers are normally used to optimize copying and zeroing when # all of the following conditions are satisfied: # "I586_CPU" is an option # the cpu is an i586 (perhaps not a Pentium) # the probe for npx0 succeeds # INT 16 exception handling works. # Then copying and zeroing using the npx registers is normally 30-100% faster. # The flags can be used to control cases where it doesn't work or is slower. # Setting them at boot time using userconfig works right (the optimizations # are not used until later in the bootstrap when npx0 is attached). # # # `iosiz' for npx0: # This can be used instead of the MAXMEM option to set the memory size. If # it is nonzero, then it overrides both the MAXMEM option and the memory # size reported by the BIOS. Setting it at boot time using userconfig takes # effect on the next reboot after the change has been recorded in the kernel # binary (the size is used early in the boot before userconfig has a chance # to change it). # # # Optional ISA and EISA devices: # # # SCSI host adapters: `aha', `aic', `bt', `nca' # # aha: Adaptec 154x # ahc: Adaptec 274x/284x/294x # aic: Adaptec 152x and sound cards using the Adaptec AIC-6360 (slow!) # bt: Most Buslogic controllers # nca: ProAudioSpectrum cards using the NCR 5380 or Trantor T130 # uha: UltraStor ULTRA 14F/24F/34F # sea: Seagate ST01/02 8 bit controller (slow!) # wds: Western Digital WD7000 controller (no scatter/gather!). # # Note that the order is important in order for Buslogic cards to be # probed correctly. # controller bt0 at isa? port "IO_BT0" bio irq ? vector bt_isa_intr controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr controller aic0 at isa? port 0x340 bio irq 11 vector aicintr controller nca0 at isa? port 0x1f88 bio irq 10 vector ncaintr controller nca1 at isa? port 0x1f84 controller nca2 at isa? port 0x1f8c controller nca3 at isa? port 0x1e88 controller nca4 at isa? port 0x350 bio irq 5 vector ncaintr controller sea0 at isa? bio irq 5 iomem 0xdc000 iosiz 0x2000 vector seaintr controller wds0 at isa? port 0x350 bio irq 15 drq 6 vector wdsintr # # ST-506, ESDI, and IDE hard disks: `wdc' and `wd' # # The flags fields are used to enable the multi-sector I/O and # the 32BIT I/O modes. The flags may be used in either the controller # definition or in the individual disk definitions. The controller # definition is supported for the boot configuration stuff. # # Each drive has a 16 bit flags value defined: # The low 8 bits are the maximum value for the multi-sector I/O, # where 0xff defaults to the maximum that the drive can handle. # The high bit of the 16 bit flags (0x8000) allows probing for # 32 bit transfers. Bit 14 (0x4000) enables a hack to wake # up powered-down laptop drives. Bit 13 (0x2000) allows # probing for PCI IDE DMA controllers, such as Intel's PIIX # south bridges. Bit 12 (0x1000) sets LBA mode instead of the # default CHS mode for accessing the drive. See the wd.4 man page. # # The flags field for the drives can be specified in the controller # specification with the low 16 bits for drive 0, and the high 16 bits # for drive 1. # e.g.: #controller wdc0 at isa? port "IO_WD1" bio irq 14 flags 0x00ff8004 vector wdintr # # specifies that drive 0 will be allowed to probe for 32 bit transfers and # a maximum multi-sector transfer of 4 sectors, and drive 1 will not be # allowed to probe for 32 bit transfers, but will allow multi-sector # transfers up to the maximum that the drive supports. # # If you are using a PCI controller that is not running in compatibility # mode (for example, it is a 2nd IDE PCI interface), then use config line(s) # such as: # #controller wdc2 at isa? port "0" bio irq ? flags 0xa0ffa0ff vector wdintr #disk wd4 at wdc2 drive 0 #disk wd5 at wdc2 drive 1 # #controller wdc3 at isa? port "0" bio irq ? flags 0xa0ffa0ff vector wdintr #disk wd6 at wdc3 drive 0 #disk wd7 at wdc3 drive 1 # # Note that the above config would be useful for a Promise card, when used # on a MB that already has a PIIX controller. Note the bogus irq and port # entries. These are automatically filled in by the IDE/PCI support. # controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr disk wd0 at wdc0 drive 0 disk wd1 at wdc0 drive 1 controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr disk wd2 at wdc1 drive 0 disk wd3 at wdc1 drive 1 # # Options for `wdc': # # CMD640 enables serializing access to primary and secondary channel # of the CMD640B IDE Chip. The serializing will only take place # if this option is set *and* the chip is probed by the pci-system. # options "CMD640" #Enable work around for CMD640 h/w bug # # ATAPI enables the support for ATAPI-compatible IDE devices # options ATAPI #Enable ATAPI support for IDE bus options ATAPI_STATIC #Don't do it as an LKM +# Use either the acd or the wcd device, not both! +# IDE CD-ROM & CD-R/RW driver - requires wdc controller and ATAPI option +device acd0 + # IDE CD-ROM driver - requires wdc controller and ATAPI option device wcd0 # IDE floppy driver - requires wdc controller and ATAPI option device wfd0 # IDE tape driver - requires wdc controller and ATAPI option device wst0 # # Standard floppy disk controllers and floppy tapes: `fdc', `fd', and `ft' # controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr # # FDC_DEBUG enables floppy debugging. Since the debug output is huge, you # gotta turn it actually on by setting the variable fd_debug with DDB, # however. options FDC_DEBUG # This option is undocumented on purpose. options FDC_PRINT_BOGUS_CHIPTYPE # # Activate this line instead of the fdc0 line above if you happen to # have an Insight floppy tape. Probing them proved to be dangerous # for people with floppy disks only, so it's "hidden" behind a flag: #controller fdc0 at isa? port "IO_FD1" bio flags 1 irq 6 drq 2 vector fdintr disk fd0 at fdc0 drive 0 disk fd1 at fdc0 drive 1 tape ft0 at fdc0 drive 2 # # Other standard PC hardware: `lpt', `mse', `psm', `sio', etc. # # lpt: printer port # lpt specials: # port can be specified as ?, this will cause the driver to scan # the BIOS port list; # the irq and vector clauses may be omitted, this # will force the port into polling mode. # mse: Logitech and ATI InPort bus mouse ports # psm: PS/2 mouse port [note: conflicts with sc0/vt0, thus "conflicts" keywd] # sio: serial ports (see sio(4)) device lpt0 at isa? port? tty irq 7 vector lptintr device lpt1 at isa? port "IO_LPT3" tty irq 5 vector lptintr device mse0 at isa? port 0x23c tty irq 5 vector mseintr device psm0 at isa? port "IO_KBD" conflicts tty irq 12 vector psmintr # Options for psm: options PSM_HOOKAPM #hook the APM resume event, useful #for some laptops options PSM_RESETAFTERSUSPEND #reset the device at the resume event device sio0 at isa? port "IO_COM1" tty flags 0x10 irq 4 vector siointr # # `flags' for serial drivers that support consoles (only for sio now): # 0x10 enable console support for this unit. The other console flags # are ignored unless this is set. Enabling console support does # not make the unit the preferred console - boot with -h or set # the 0x20 flag for that. Currently, at most one unit can have # console support; the first one (in config file order) with # this flag set is preferred. Setting this flag for sio0 gives # the old behaviour. # 0x20 force this unit to be the console (unless there is another # higher priority console). This replaces the COMCONSOLE option. # 0x40 reserve this unit for low level console operations. Do not # # PnP `flags' (set via userconfig using pnp x flags y) # 0x1 disable probing of this device. Used to prevent your modem # from being attached as a PnP modem. # # Options for serial drivers that support consoles (only for sio now): options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to #DDB, if available. options CONSPEED=9600 #default speed for serial console (default 9600) # Options for sio: options COM_ESP #code for Hayes ESP options COM_MULTIPORT #code for some cards with shared IRQs options DSI_SOFT_MODEM #code for DSI Softmodems options "EXTRA_SIO=2" #number of extra sio ports to allocate # Other flags for sio that aren't documented in the man page. # 0x20000 enable hardware RTS/CTS and larger FIFOs. Only works for # ST16650A-compatible UARTs. # # Network interfaces: `cx', `ed', `el', `ep', `ie', `is', `le', `lnc' # # ar: Arnet SYNC/570i hdlc sync 2/4 port V.35/X.21 serial driver (requires sppp) # cs: IBM Etherjet and other Crystal Semi CS89x0-based adapters # cx: Cronyx/Sigma multiport sync/async (with Cisco or PPP framing) # ed: Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503 # el: 3Com 3C501 (slow!) # ep: 3Com 3C509 (buggy) # fe: Fujitsu MB86960A/MB86965A Ethernet # ie: AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210; Intel EtherExpress # le: Digital Equipment EtherWorks 2 and EtherWorks 3 (DEPCA, DE100, # DE101, DE200, DE201, DE202, DE203, DE204, DE205, DE422) # lnc: Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL) # sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp) # wl: Lucent Wavelan (ISA card only). # ze: IBM/National Semiconductor PCMCIA ethernet controller. # zp: 3Com PCMCIA Etherlink III (It does not require shared memory for # send/receive operation, but it needs 'iomem' to read/write the # attribute memory) # device ar0 at isa? port 0x300 net irq 10 iomem 0xd0000 vector arintr device cs0 at isa? port 0x300 net irq ? vector csintr device cx0 at isa? port 0x240 net irq 15 drq 7 vector cxintr device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr device eg0 at isa? port 0x310 net irq 5 vector egintr device el0 at isa? port 0x300 net irq 9 vector elintr device ep0 at isa? port 0x300 net irq 10 vector epintr device ex0 at isa? port? net irq? vector exintr device fe0 at isa? port 0x300 net irq ? vector feintr device ie0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector ieintr device ie1 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr device le0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector le_intr device lnc0 at isa? port 0x300 net irq 10 drq 0 vector lncintr device sr0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector srintr options WLCACHE # enables the signal-strength cache options WLDEBUG # enables verbose debugging output device wl0 at isa? port 0x300 net irq ? vector wlintr # We can (bogusly) include both the dedicated PCCARD drivers and the generic # support when COMPILING_LINT. device ze0 at isa? port 0x300 net irq 5 iomem 0xd8000 vector zeintr device zp0 at isa? port 0x300 net irq 10 iomem 0xd8000 vector zpintr # # ATM related options # # The `en' device provides support for Efficient Networks (ENI) # ENI-155 PCI midway cards, and the Adaptec 155Mbps PCI ATM cards (ANA-59x0). # # atm pseudo-device provides generic atm functions and is required for # atm devices. # NATM enables the netnatm protocol family that can be used to # bypass TCP/IP. # # the current driver supports only PVC operations (no atm-arp, no multicast). # for more details, please read the original documents at # http://www.ccrc.wustl.edu/pub/chuck/bsdatm/wucs.html # pseudo-device atm device en0 device en1 options NATM #native ATM # # Audio drivers: `snd', `sb', `pas', `gus', `pca' # # snd: Voxware sound support code # sb: SoundBlaster PCM - SoundBlaster, SB Pro, SB16, ProAudioSpectrum # sbxvi: SoundBlaster 16 # sbmidi: SoundBlaster 16 MIDI interface # pas: ProAudioSpectrum PCM and MIDI # gus: Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX # gusxvi: Gravis Ultrasound 16-bit PCM (do not use) # mss: Microsoft Sound System # css: Crystal Sound System (CSS 423x PnP) # sscape: Ensoniq Soundscape MIDI interface # sscape_mss: Ensoniq Soundscape PCM (requires sscape) # opl: Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum # uart: stand-alone 6850 UART for MIDI # mpu: Roland MPU-401 stand-alone card # # Beware! The addresses specified below are also hard-coded in # i386/isa/sound/sound_config.h. If you change the values here, you # must also change the values in the include file. # # pcm: PCM audio through various sound cards. # # This is the work in progress from Luigi Rizzo. This has support for # CS423x based cards, OPTi931, SB16 PnP, GusPnP. For more information # about this driver, take a look at sys/i386/isa/snd/README. # # The flags of the device tells the device a bit more info about the # device that normally is obtained through the PnP interface. # bit 2..0 secondary DMA channel; # bit 4 set if the board uses two dma channels; # bit 15..8 board type, overrides autodetection; leave it # zero if don't know what to put in (and you don't, # since this is unsupported at the moment...). # # This driver will use the new PnP code if it's available. # # pca: PCM audio through your PC speaker # # If you have a GUS-MAX card and want to use the CS4231 codec on the # card the drqs for the gus max must be 8 bit (1, 2, or 3). # # If you would like to use the full duplex option on the gus, then define # flags to be the ``read dma channel''. # # options BROKEN_BUS_CLOCK #PAS-16 isn't working and OPTI chipset # options SYMPHONY_PAS #PAS-16 isn't working and SYMPHONY chipset # options EXCLUDE_SBPRO #PAS-16 # options SBC_IRQ=5 #PAS-16. Must match irq on sb0 line. # PAS16: The order of the pas0/sb0/opl0 is important since the # sb emulation is enabled in the pas-16 attach. # # To overide the GUS defaults use: # options GUS_DMA2 # options GUS_DMA # options GUS_IRQ # # The i386/isa/sound/sound.doc has more information. # Controls all "VOXWARE" driver sound devices. See Luigi's driver # below for an alternate which may work better for some cards. # controller snd0 device pas0 at isa? port 0x388 irq 10 drq 6 vector pasintr device sb0 at isa? port 0x220 irq 5 drq 1 vector sbintr device sbxvi0 at isa? drq 5 device sbmidi0 at isa? port 0x330 device awe0 at isa? port 0x620 device gus0 at isa? port 0x220 irq 12 drq 1 vector gusintr #device gus0 at isa? port 0x220 irq 12 drq 1 flags 0x3 vector gusintr device mss0 at isa? port 0x530 irq 10 drq 1 vector adintr device css0 at isa? port 0x534 irq 5 drq 1 flags 0x08 vector adintr device sscape0 at isa? port 0x330 irq 9 drq 0 vector sscapeintr device trix0 at isa? port 0x330 irq 6 drq 0 vector sscapeintr device sscape_mss0 at isa? port 0x534 irq 5 drq 1 vector sndintr device opl0 at isa? port 0x388 device mpu0 at isa? port 0x330 irq 6 drq 0 device uart0 at isa? port 0x330 irq 5 vector "m6850intr" # Luigi's snd code (use INSTEAD of snd0 and all VOXWARE drivers!). # You may also wish to enable the pnp controller with this, for pnp # sound cards. # #device pcm0 at isa? port ? tty irq 10 drq 1 flags 0x0 vector pcmintr # Not controlled by `snd' device pca0 at isa? port IO_TIMER1 tty # # Miscellaneous hardware: # # mcd: Mitsumi CD-ROM # scd: Sony CD-ROM # matcd: Matsushita/Panasonic CD-ROM # wt: Wangtek and Archive QIC-02/QIC-36 tape drives # ctx: Cortex-I frame grabber # apm: Laptop Advanced Power Management (experimental) # spigot: The Creative Labs Video Spigot video-acquisition board # meteor: Matrox Meteor video capture board # alog: Industrial Computer Source AIO8-P driver # bktr: Bt848 capture boards (http://www.freebsd.org/~fsmp/HomeAuto/Bt848.html) # cy: Cyclades serial driver # dgb: Digiboard PC/Xi and PC/Xe series driver (ALPHA QUALITY!) # dgm: Digiboard PC/Xem driver # gp: National Instruments AT-GPIB and AT-GPIB/TNT board # asc: GI1904-based hand scanners, e.g. the Trust Amiscan Grey # gsc: Genius GS-4500 hand scanner. # joy: joystick # labpc: National Instrument's Lab-PC and Lab-PC+ # rc: RISCom/8 multiport card # rp: Comtrol Rocketport(ISA) - single card # tw: TW-523 power line interface for use with X-10 home control products # si: Specialix SI/XIO 4-32 port terminal multiplexor # stl: Stallion EasyIO and EasyConnection 8/32 (cd1400 based) # stli: Stallion EasyConnection 8/64, ONboard, Brumby (intelligent) # # Notes on APM # The flags takes the following meaning for apm0: # 0x0020 Statclock is broken. # 0x0011 Limit APM protocol to 1.1 or 1.0 # 0x0010 Limit APM protocol to 1.0 # # # Notes on the spigot: # The video spigot is at 0xad6. This port address can not be changed. # The irq values may only be 10, 11, or 15 # I/O memory is an 8kb region. Possible values are: # 0a0000, 0a2000, ..., 0fffff, f00000, f02000, ..., ffffff # The start address must be on an even boundary. # Add the following option if you want to allow non-root users to be able # to access the spigot. This option is not secure because it allows users # direct access to the I/O page. # options SPIGOT_UNSECURE # # Notes on the Comtrol Rocketport driver: # # The exact values used for rp0 depend on how many boards you have # in the system. The manufacturer's sample configs are listed as: # # Comtrol Rocketport ISA single card # device rp0 at isa? port 0x280 tty # # If instead you have two ISA cards, one installed at 0x100 and the # second installed at 0x180, then you should add the following to # your kernel configuration file: # # device rp0 at isa? port 0x100 tty # device rp1 at isa? port 0x180 tty # # For 4 ISA cards, it might be something like this: # # device rp0 at isa? port 0x180 tty # device rp1 at isa? port 0x100 tty # device rp2 at isa? port 0x340 tty # device rp3 at isa? port 0x240 tty # # And for PCI cards, you only need say: # # device rp0 # device rp1 # ... # Note: Make sure that any Rocketport PCI devices are specified BEFORE the # ISA Rocketport devices. # Notes on the Digiboard driver: # # The following flag values have special meanings: # 0x01 - alternate layout of pins (dgb & dgm) # 0x02 - use the windowed PC/Xe in 64K mode (dgb only) # Notes on the Specialix SI/XIO driver: # **This is NOT a Specialix supported Driver!** # The host card is memory, not IO mapped. # The Rev 1 host cards use a 64K chunk, on a 32K boundary. # The Rev 2 host cards use a 32K chunk, on a 32K boundary. # The cards can use an IRQ of 11, 12 or 15. # Notes on the Stallion stl and stli drivers: # See src/i386/isa/README.stl for complete instructions. # This is version 0.0.5alpha, unsupported by Stallion. # The stl driver has a secondary IO port hard coded at 0x280. You need # to change src/i386/isa/stallion.c if you reconfigure this on the boards. # The "flags" and "iosiz" settings on the stli driver depend on the board: # EasyConnection 8/64 ISA: flags 23 iosiz 0x1000 # EasyConnection 8/64 EISA: flags 24 iosiz 0x10000 # EasyConnection 8/64 MCA: flags 25 iosiz 0x1000 # ONboard ISA: flags 4 iosiz 0x10000 # ONboard EISA: flags 7 iosiz 0x10000 # ONboard MCA: flags 3 iosiz 0x10000 # Brumby: flags 2 iosiz 0x4000 # Stallion: flags 1 iosiz 0x10000 device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr # for the Sony CDU31/33A CDROM device scd0 at isa? port 0x230 bio # for the SoundBlaster 16 multicd - up to 4 devices controller matcd0 at isa? port 0x230 bio device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr device ctx0 at isa? port 0x230 iomem 0xd0000 device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr device apm0 at isa? device gp0 at isa? port 0x2c0 tty device gsc0 at isa? port "IO_GSC1" tty drq 3 device joy0 at isa? port "IO_GAME" device alog0 at isa? port 0x260 tty irq 5 vector alogintr device cy0 at isa? tty irq 10 iomem 0xd4000 iosiz 0x2000 vector cyintr device dgb0 at isa? port 0x220 iomem 0xfc0000 iosiz ? tty device dgm0 at isa? port 0x104 iomem 0xd00000 iosiz ? tty device labpc0 at isa? port 0x260 tty irq 5 vector labpcintr device rc0 at isa? port 0x220 tty irq 12 vector rcintr device rp0 at isa? port 0x280 tty # the port and irq for tw0 are fictitious device tw0 at isa? port 0x380 tty irq 11 vector twintr device si0 at isa? iomem 0xd0000 tty irq 12 device asc0 at isa? port IO_ASC1 tty drq 3 irq 10 vector ascintr device bqu0 at isa? port 0x150 device stl0 at isa? port 0x2a0 tty irq 10 vector stlintr device stli0 at isa? port 0x2a0 tty iomem 0xcc000 flags 23 iosiz 0x1000 # You are unlikely to have the hardware for loran0 device loran0 at isa? port ? tty irq 5 vector loranintr # HOT1 Xilinx 6200 card (www.vcc.com) device xrpu0 # # EISA devices: # # The EISA bus device is eisa0. It provides auto-detection and # configuration support for all devices on the EISA bus. # # The `ahb' device provides support for the Adaptec 174X adapter. # # The `ahc' device provides support for the Adaptec 274X and 284X # adapters. The 284X, although a VLB card responds to EISA probes. # # fea: DEC DEFEA EISA FDDI adapter # controller eisa0 controller ahb0 controller ahc0 device fea0 # enable tagged command queuing, which is a major performance win on # devices that support it (and controllers with enough SCB's) options AHC_TAGENABLE # enable SCB paging - See the ahc.4 man page options AHC_SCBPAGING_ENABLE # The aic7xxx driver will attempt to use memory mapped I/O for all PCI # controllers that have it configured only if this option is set. Unfortunately, # this doesn't work on some motherboards, which prevents it from being the # default. options AHC_ALLOW_MEMIO # By default, only 10 EISA slots are probed, since the slot numbers # above clash with the configuration address space of the PCI subsystem, # and the EISA probe is not very smart about this. This is sufficient # for most machines, but in particular the HP NetServer LC series comes # with an onboard AIC7770 dual-channel SCSI controller on EISA slot #11, # thus you need to bump this figure to 12 for them. options "EISA_SLOTS=12" # # PCI devices & PCI options: # # The main PCI bus device is `pci'. It provides auto-detection and # configuration support for all devices on the PCI bus, using either # configuration mode defined in the PCI specification. # # The `ahc' device provides support for the Adaptec 29/3940(U)(W) # and motherboard based AIC7870/AIC7880 adapters. # # The `ncr' device provides support for the NCR 53C810 and 53C825 # self-contained SCSI host adapters. # # The `isp' device provides support for the Qlogic ISP 1020, 1040 # nd 1040B PCI SCSI host adapters, as well as the Qlogic ISP 2100 # FC/AL Host Adapter. # # The `amd' device provides support for the Tekram DC-390 and 390T # SCSI host adapters, but is expected to work with any AMD 53c974 # PCI SCSI chip and the AMD Ethernet+SCSI Combo chip, after some # local patches were applied to the sources (that had originally # been written by Tekram and limited to work with their SCSI cards). # # The `de' device provides support for the Digital Equipment DC21040 # self-contained Ethernet adapter. # # The `fxp' device provides support for the Intel EtherExpress Pro/100B # PCI Fast Ethernet adapters. # # The 'tl' device provides support for the Texas Instruments TNETE100 # series 'ThunderLAN' cards and integrated ethernet controllers. This # includes several Compaq Netelligent 10/100 cards and the built-in # ethernet controllers in several Compaq Prosignia, Proliant and # Deskpro systems. It also supports several Olicom 10Mbps and 10/100 # boards. # # The `tx' device provides support for the SMC 9432TX cards. # # The `vx' device provides support for the 3Com 3C590 and 3C595 # early support # # The `xl' driver provides support for the 3Com 3c900, 3c905 and # 3c905B (Fast) Etherlink XL cards and integrated controllers. This # includes the integrated 3c905B-TX chips in certain Dell Optiplex and # Dell Precision desktop machines and the integrated 3c905-TX chips # in Dell Latitude laptop docking stations. # # The `fpa' device provides support for the Digital DEFPA PCI FDDI # adapter. pseudo-device fddi is also needed. # # The `meteor' device is a PCI video capture board. It can also have the # following options: # options METEOR_ALLOC_PAGES=xxx preallocate kernel pages for data entry # figure (ROWS*COLUMN*BYTES_PER_PIXEL*FRAME+PAGE_SIZE-1)/PAGE_SIZE # options METEOR_DEALLOC_PAGES remove all allocated pages on close(2) # options METEOR_DEALLOC_ABOVE=xxx remove all allocated pages above the # specified amount. If this value is below the allocated amount no action # taken # option METEOR_SYSTEM_DEFAULT={METEOR_PAL|METEOR_NTSC|METEOR_SECAM}, used # for initialization of fps routine when a signal is not present. # # The 'bktr' device is a PCI video capture board. It also has a TV tuner # on board. To override the tuner detection use # options OVERRIDE_TUNER=x # The current values are found in /usr/src/sys/pci/brooktree848.c # # controller pci0 controller ahc1 controller ncr0 controller isp0 controller amd0 device de0 device fxp0 device tl0 device tx0 device vx0 device xl0 device fpa0 device meteor0 device bktr0 options OVERRIDE_TUNER=NO_TUNER # # PCI options # #options PCI_QUIET #quiets PCI code on chipset settings # # PCCARD/PCMCIA # # card: slot controller # pcic: slots controller card0 device pcic0 at card? device pcic1 at card? # You may need to reset all pccards after resuming options PCIC_RESUME_RESET # reset after resume # # Laptop/Notebook options: # # See also: # apm under `Miscellaneous hardware' # above. # For older notebooks that signal a powerfail condition (external # power supply dropped, or battery state low) by issuing an NMI: options POWERFAIL_NMI # make it beep instead of panicing # # SMB bus # # System Management Bus support provided by the 'smbus' device. # # Supported devices: # smb standard io # # Supported interfaces: # iicsmb I2C to SMB bridge # controller smbus0 device smb0 at smbus? # # I2C Bus # # Philips i2c bus support is provided by the `iicbus' device. # # Supported devices: # ic i2c network interface # iic i2c standard io # # Supported interfaces: # pcf Philips PCF8584 ISA-bus controller # controller iicbus0 device ic0 at iicbus? device iic0 at iicbus? device iicsmb0 at iicbus? controller pcf0 at isa? port 0x320 net irq 5 vector pcfintr # # Parallel-Port Bus # # Parallel port bus support is provided by the `ppbus' device. # Multiple devices may be attached to the parallel port, devices # are automatically probed and attached when found. # # Supported devices: # vpo Iomega Zip Drive # Requires SCSI disk support ('scbus' and 'sd'), best # performance is achieved with ports in EPP 1.9 mode. # nlpt Parallel Printer # plip Parallel network interface # ppi General-purpose I/O ("Geek Port") # # Supported interfaces: # ppc ISA-bus parallel port interfaces. # controller ppbus0 controller vpo0 at ppbus? device nlpt0 at ppbus? device plip0 at ppbus? device ppi0 at ppbus? device pps0 at ppbus? controller ppc0 at isa? disable port ? tty irq 7 vector ppcintr # Kernel BOOTP support options BOOTP # Use BOOTP to obtain IP address/hostname options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info options "BOOTP_NFSV3" # Use NFS v3 to NFS mount root options BOOTP_COMPAT # Workaround for broken bootp daemons. options "BOOTP_WIRED_TO=fxp0" # Use interface fxp0 for BOOTP # If you want to disable loadable kernel modules (LKM), you # might want to use this option. #options NO_LKM # # Add tie-ins for a hardware watchdog. This only enable the hooks; # the user must still supply the actual driver. # options HW_WDOG # # Set the number of PV entries per process. Increasing this can # stop panics related to heavy use of shared memory. However, that can # (combined with large amounts of physical memory) cause panics at # boot time due the kernel running out of VM space. # # If you're tweaking this, you might also want to increase the sysctls # "vm.v_free_min", "vm.v_free_reserved", and "vm.v_free_target". # # The value below is the one more than the default. # options "PMAP_SHPGPERPROC=201" # More undocumented options for linting. options CLK_CALIBRATION_LOOP options "CLK_USE_I8254_CALIBRATION" options CLK_USE_TSC_CALIBRATION options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG options "DEBUG_1284" #options DISABLE_PSE options "EXT2FS" options "I586_PMC_GUPROF=0x70000" options "IBCS2" options KEY options KEY_DEBUG options LOCKF_DEBUG options LOUTB options KBD_MAXRETRY=4 options KBD_MAXWAIT=6 options KBD_RESETDELAY=201 options KBDIO_DEBUG=2 options MSGMNB=2049 options MSGMNI=41 options MSGSEG=2049 options MSGSSZ=16 options MSGTQL=41 options NBUF=512 options NETATALKDEBUG options NMBCLUSTERS=1024 options NPX_DEBUG options PANIC_REBOOT_WAIT_TIME=16 options "PCVT_24LINESDEF" options PCVT_CTRL_ALT_DEL options PCVT_EMU_MOUSE options PCVT_FREEBSD=211 options PCVT_META_ESC options PCVT_NSCREENS=9 options PCVT_PRETTYSCRNS options PCVT_SCREENSAVER options PCVT_USEKBDSEC options "PCVT_VT220KEYB" options PSM_DEBUG=1 options "SCSI_2_DEF" options SCSI_DELAY=8 # Be pessimistic about Joe SCSI device options SCSI_NCR_DEBUG options SCSI_NCR_DFLT_TAGS=4 options SCSI_NCR_MAX_SYNC=10000 options SCSI_NCR_MAX_WIDE=1 options SCSI_NCR_MYADDR=7 options SEMMAP=31 options SEMMNI=11 options SEMMNS=61 options SEMMNU=31 options SEMMSL=61 options SEMOPM=101 options SEMUME=11 options SHOW_BUSYBUFS # List buffers that prevent root unmount options SHMALL=1025 options "SHMMAX=(SHMMAXPGS*PAGE_SIZE+1)" options SHMMAXPGS=1025 options SHMMIN=2 options SHMMNI=33 options SHMSEG=9 options SI_DEBUG options SIMPLELOCK_DEBUG options SPX_HACK # The 'dpt' driver provides support for DPT controllers (http://www.dpt.com/). # These have hardware RAID-{0,1,5} support, and do multi-initiator I/O. # The DPT controllers are commonly re-licensed under other brand-names - # some controllers by Olivetti, Dec, HP, AT&T, SNI, AST, Alphatronic, NEC and # Compaq are actually DPT controllers. # # See sys/dev/dpt for debugging and other subtle options. # DPT_VERIFY_HINTR Performs some strict hardware interrupts testing. # Only use if you suspect PCI bus corruption problems # DPT_RESTRICTED_FREELIST Normally, the freelisat used by the DPT for queue # will grow to accomodate increased use. This growth # will NOT shrink. To restrict the number of queue # slots to exactly what the DPT can hold at one time, # enable this option. # DPT_MEASURE_PERFORMANCE Enables a set of (semi)invasive metrics. Various # instruments are enabled. The tools in # /usr/sbin/dpt_* assume these to be enabled. # DPT_FREELIST_IS_STACK For optimal L{1,2} CPU cache utilization, enable # this option. Otherwise, the transaction queue is # a LIFO. I cannot measure the performance gain. # DPT_HANDLE_TIMEOUTS Normally device timeouts are handled by the DPT. # If you ant the driver to handle timeouts, enable # this option. If your system is very busy, this # option will create more trouble than solve. # DPT_TIMEOUT_FACTOR Used to compute the excessive amount of time to # wait when timing out with the above option. # DPT_DEBUG_xxxx These are controllable from sys/dev/dpt/dpt.h # DPT_LOST_IRQ When enabled, will try, once per second, to catch # any interrupt that got lost. Seems to help in some # DPT-firmware/Motherboard combinations. Minimal # cost, great benefit. # DPT_RESET_HBA Make "reset" actually reset the controller # instead of fudging it. Only enable this if you # are 100% certain you need it. # DPT_SHUTDOWN_SLEEP Reset controller if a request take more than # this number of seconds. Do NOT enable this # unless you are really, really, really certain # you need it. You are advised to call Simon (the # driver author) before setting it, and NEVER, # EVER set it to less than 300s (5 minutes). controller dpt0 # DPT options options DPT_VERIFY_HINTR options DPT_RESTRICTED_FREELIST options DPT_MEASURE_PERFORMANCE options DPT_FREELIST_IS_STACK options DPT_HANDLE_TIMEOUTS options DPT_TIMEOUT_FACTOR=4 options DPT_INTR_DELAY=200 # Some motherboards need that options DPT_LOST_IRQ options DPT_RESET_HBA # Don't EVER set this without having talked to Simon Shapiro on the phone # first. options DPT_SHUTDOWN_SLEEP=500 diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index bccdc5bc5ce3..e2a865eaad47 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -1,320 +1,321 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $Id: files.i386,v 1.200 1998/08/04 21:44:09 brian Exp $ +# $Id: files.i386,v 1.201 1998/09/04 06:06:55 nsouch Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # linux_genassym optional compat_linux \ dependency "$S/i386/linux/linux_genassym.c $S/i386/linux/linux.h" \ compile-with "${CC} ${CFLAGS} ${PARAM} -UKERNEL -o $@ $<" \ no-obj no-implicit-rule \ clean "linux_genassym" # linux_assym.h optional compat_linux \ dependency "linux_genassym" \ compile-with "./linux_genassym > $@" \ no-obj no-implicit-rule before-depend \ clean "linux_assym.h" # font8x16.o optional std8x16font \ compile-with "uudecode < /usr/share/syscons/fonts/${STD8X16FONT}-8x16.fnt && file2c 'unsigned char font_16[16*256] = {' '};' < ${STD8X16FONT}-8x16 > font8x16.c && ${CC} -c ${CFLAGS} font8x16.c" \ no-implicit-rule before-depend \ clean "${STD8X16FONT}-8x16 font8x16.c" # i386/apm/apm.c optional apm device-driver i386/apm/apm_setup.s optional apm i386/eisa/dpt_eisa.c optional eisa dpt device-driver i386/eisa/3c5x9.c optional ep device-driver i386/eisa/aic7770.c optional ahc device-driver \ dependency "aic7xxx_reg.h $S/i386/eisa/aic7770.c" i386/eisa/aha1742.c optional ahb device-driver i386/eisa/bt74x.c optional bt device-driver i386/eisa/eisaconf.c optional eisa i386/eisa/if_vx_eisa.c optional vx device-driver i386/eisa/if_fea.c optional fea device-driver i386/i386/autoconf.c standard device-driver i386/i386/mountroot.c optional slice i386/i386/bios.c standard i386/i386/bioscall.s standard i386/i386/busdma_machdep.c standard i386/i386/cons.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb i386/i386/exception.s standard i386/i386/globals.s standard i386/i386/i386-gdbstub.c optional ddb i386/i386/identcpu.c standard i386/i386/in_cksum.c optional inet i386/i386/initcpu.c standard # locore.s needs to be handled in Makefile to put it first. Otherwise it's # now normal. # i386/i386/locore.s standard i386/i386/machdep.c standard i386/i386/math_emulate.c optional math_emulate i386/i386/mem.c standard i386/i386/mp_machdep.c optional smp i386/i386/mpapic.c optional smp i386/i386/mpboot.s optional smp i386/i386/mplock.s optional smp i386/i386/perfmon.c optional perfmon profiling-routine i386/i386/perfmon.c optional perfmon i386/i386/pmap.c standard i386/i386/procfs_machdep.c standard i386/i386/simplelock.s optional smp i386/i386/support.s standard i386/i386/swtch.s standard i386/i386/sys_machdep.c standard i386/i386/trap.c standard i386/i386/userconfig.c optional userconfig i386/i386/vm_machdep.c standard i386/i386/vm86.c optional vm86 i386/ibcs2/ibcs2_fcntl.c optional ibcs2 i386/ibcs2/ibcs2_stat.c optional ibcs2 i386/ibcs2/ibcs2_ipc.c optional ibcs2 i386/ibcs2/ibcs2_msg.c optional ibcs2 i386/ibcs2/ibcs2_misc.c optional ibcs2 i386/ibcs2/ibcs2_other.c optional ibcs2 i386/ibcs2/ibcs2_signal.c optional ibcs2 i386/ibcs2/ibcs2_ioctl.c optional ibcs2 i386/ibcs2/ibcs2_socksys.c optional ibcs2 i386/ibcs2/ibcs2_sysi86.c optional ibcs2 i386/ibcs2/ibcs2_util.c optional ibcs2 i386/ibcs2/ibcs2_isc.c optional ibcs2 i386/ibcs2/ibcs2_isc_sysent.c optional ibcs2 i386/ibcs2/ibcs2_xenix.c optional ibcs2 i386/ibcs2/ibcs2_xenix_sysent.c optional ibcs2 i386/ibcs2/ibcs2_errno.c optional ibcs2 i386/ibcs2/ibcs2_sysent.c optional ibcs2 i386/ibcs2/ibcs2_sysvec.c optional ibcs2 i386/ibcs2/imgact_coff.c optional ibcs2 i386/isa/aha1542.c optional aha device-driver i386/isa/aic6360.c optional aic device-driver i386/isa/alog.c optional alog device-driver i386/isa/b004.c optional bqu device-driver i386/isa/bt5xx-445.c optional bt device-driver i386/isa/clock.c standard i386/isa/cronyx.c optional cx device-driver i386/isa/ctx.c optional ctx device-driver i386/isa/cx.c optional cx device-driver i386/isa/cy.c optional cy device-driver i386/isa/diskslice_machdep.c standard i386/isa/elink.c optional ep device-driver i386/isa/elink.c optional ie device-driver i386/isa/fd.c optional fd device-driver i386/isa/ft.c optional ft device-driver i386/isa/gpib.c optional gp device-driver i386/isa/asc.c optional asc device-driver i386/isa/gsc.c optional gsc device-driver i386/isa/if_ar.c optional ar device-driver i386/isa/if_cs.c optional cs device-driver i386/isa/if_cx.c optional cx device-driver i386/isa/if_ed.c optional ed device-driver i386/isa/if_eg.c optional eg device-driver i386/isa/if_el.c optional el device-driver i386/isa/if_ep.c optional ep device-driver i386/isa/if_ex.c optional ex device-driver i386/isa/if_fe.c optional fe device-driver i386/isa/if_ie.c optional ie device-driver i386/isa/if_le.c optional le device-driver i386/isa/if_lnc.c optional lnc device-driver i386/isa/if_sr.c optional sr device-driver i386/isa/if_wl.c optional wl device-driver i386/isa/if_ze.c optional ze device-driver i386/isa/if_zp.c optional zp device-driver i386/isa/ipl_funcs.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} $<" i386/isa/intr_machdep.c standard i386/isa/isa.c optional isa device-driver i386/isa/istallion.c optional stli device-driver i386/isa/joy.c optional joy device-driver i386/isa/kbdio.c optional psm device-driver i386/isa/kbdio.c optional sc device-driver i386/isa/kbdio.c optional vt device-driver i386/isa/loran.c optional loran device-driver i386/isa/lpt.c optional lpt device-driver i386/isa/labpc.c optional labpc device-driver i386/isa/mcd.c optional mcd device-driver i386/isa/mse.c optional mse device-driver i386/isa/ncr5380.c optional nca device-driver i386/isa/npx.c mandatory npx device-driver i386/isa/pcaudio.c optional pca device-driver i386/isa/matcd/matcd.c optional matcd device-driver i386/isa/pcibus.c optional pci device-driver i386/isa/pcicx.c optional ze device-driver i386/isa/pcicx.c optional zp device-driver i386/isa/pcvt/pcvt_drv.c optional vt device-driver i386/isa/pcvt/pcvt_ext.c optional vt device-driver i386/isa/pcvt/pcvt_kbd.c optional vt device-driver i386/isa/pcvt/pcvt_out.c optional vt device-driver i386/isa/pcvt/pcvt_sup.c optional vt device-driver i386/isa/pcvt/pcvt_vtf.c optional vt device-driver i386/isa/pnp.c optional pnp device-driver i386/isa/prof_machdep.c optional profiling-routine i386/isa/ppc.c optional ppc device-driver i386/isa/pcf.c optional pcf device-driver i386/isa/psm.c optional psm device-driver i386/isa/random_machdep.c standard i386/isa/rc.c optional rc device-driver i386/isa/rp.c optional rp device-driver i386/isa/scd.c optional scd device-driver i386/isa/seagate.c optional sea device-driver i386/isa/si.c optional si device-driver i386/isa/si2_z280.c optional si device-driver i386/isa/si3_t225.c optional si device-driver i386/isa/sio.c optional sio device-driver i386/isa/snd/sound.c optional pcm device-driver i386/isa/snd/dmabuf.c optional pcm device-driver i386/isa/snd/ad1848.c optional pcm device-driver i386/isa/snd/sb_dsp.c optional pcm device-driver i386/isa/snd/clones.c optional pcm device-driver i386/isa/sound/dev_table.c optional snd device-driver i386/isa/sound/soundcard.c optional snd device-driver i386/isa/sound/sound_switch.c optional snd device-driver i386/isa/sound/audio.c optional snd device-driver i386/isa/sound/dmabuf.c optional snd device-driver i386/isa/sound/sys_timer.c optional snd device-driver i386/isa/sound/sequencer.c optional snd device-driver i386/isa/sound/patmgr.c optional snd device-driver i386/isa/sound/adlib_card.c optional opl device-driver i386/isa/sound/opl3.c optional opl device-driver i386/isa/sound/gus_card.c optional gus device-driver i386/isa/sound/gus_midi.c optional gus device-driver i386/isa/sound/gus_vol.c optional gus device-driver i386/isa/sound/gus_wave.c optional gus device-driver i386/isa/sound/ics2101.c optional gus device-driver i386/isa/sound/sound_timer.c optional gus device-driver i386/isa/sound/sound_timer.c optional css device-driver i386/isa/sound/sound_timer.c optional mss device-driver i386/isa/sound/midi_synth.c optional gus device-driver i386/isa/sound/midibuf.c optional gus device-driver i386/isa/sound/ad1848.c optional gusxvi device-driver i386/isa/sound/ad1848.c optional gus device-driver i386/isa/sound/ad1848.c optional mss device-driver i386/isa/sound/ad1848.c optional css device-driver i386/isa/sound/sound_timer.c optional mss device-driver i386/isa/sound/midi_synth.c optional mss device-driver i386/isa/sound/midibuf.c optional mss device-driver i386/isa/sound/mpu401.c optional mpu device-driver i386/isa/sound/midi_synth.c optional mpu device-driver i386/isa/sound/midibuf.c optional mpu device-driver i386/isa/sound/pas2_card.c optional pas device-driver i386/isa/sound/pas2_midi.c optional pas device-driver i386/isa/sound/pas2_mixer.c optional pas device-driver i386/isa/sound/pas2_pcm.c optional pas device-driver i386/isa/sound/midi_synth.c optional pas device-driver i386/isa/sound/midibuf.c optional pas device-driver i386/isa/sound/sb_card.c optional sb device-driver i386/isa/sound/sb_dsp.c optional sb device-driver i386/isa/sound/sb_midi.c optional sb device-driver i386/isa/sound/sb_mixer.c optional sb device-driver i386/isa/sound/midi_synth.c optional sb device-driver i386/isa/sound/midibuf.c optional sb device-driver i386/isa/sound/sb16_dsp.c optional sbxvi device-driver i386/isa/sound/sb16_midi.c optional sbmidi device-driver i386/isa/sound/uart6850.c optional uart device-driver i386/isa/sound/midi_synth.c optional uart device-driver i386/isa/sound/midi_synth.c optional css device-driver i386/isa/sound/midibuf.c optional uart device-driver i386/isa/sound/midibuf.c optional css device-driver i386/isa/sound/trix.c optional trix device-driver i386/isa/sound/adlib_card.c optional trix device-driver i386/isa/sound/opl3.c optional trix device-driver i386/isa/sound/ad1848.c optional trix device-driver i386/isa/sound/sound_timer.c optional trix device-driver i386/isa/sound/sscape.c optional sscape device-driver i386/isa/sound/ad1848.c optional sscape device-driver i386/isa/sound/sound_timer.c optional sscape device-driver i386/isa/sound/mpu401.c optional sscape device-driver i386/isa/sound/midi_synth.c optional sscape device-driver i386/isa/sound/midibuf.c optional sscape device-driver i386/isa/sound/cs4232.c optional css device-driver i386/isa/spigot.c optional spigot device-driver i386/isa/spkr.c optional speaker device-driver i386/isa/stallion.c optional stl device-driver i386/isa/syscons.c optional sc device-driver i386/isa/tw.c optional tw device-driver i386/isa/ultra14f.c optional uha device-driver i386/isa/wd.c optional wdc device-driver i386/isa/wd.c optional wd device-driver i386/isa/atapi.c optional atapi device-driver +i386/isa/atapi-cd.c optional acd device-driver i386/isa/wcd.c optional wcd device-driver i386/isa/wfd.c optional wfd device-driver i386/isa/wst.c optional wst device-driver i386/isa/wd7000.c optional wds device-driver i386/isa/wt.c optional wt device-driver i386/linux/imgact_linux.c optional compat_linux i386/linux/linux_dummy.c optional compat_linux i386/linux/linux_file.c optional compat_linux i386/linux/linux_ioctl.c optional compat_linux i386/linux/linux_ipc.c optional compat_linux i386/linux/linux_locore.s optional compat_linux \ dependency "linux_assym.h" i386/linux/linux_misc.c optional compat_linux i386/linux/linux_signal.c optional compat_linux i386/linux/linux_socket.c optional compat_linux i386/linux/linux_stats.c optional compat_linux i386/linux/linux_sysent.c optional compat_linux i386/linux/linux_sysvec.c optional compat_linux i386/linux/linux_util.c optional compat_linux i386/scsi/93cx6.c optional ahc device-driver i386/scsi/aic7xxx.c optional ahc device-driver \ dependency "aic7xxx_{reg,seq}.h" i386/scsi/bt.c optional bt device-driver libkern/bcd.c standard libkern/divdi3.c standard libkern/inet_ntoa.c standard libkern/index.c standard libkern/mcount.c optional profiling-routine libkern/moddi3.c standard libkern/qdivrem.c standard libkern/qsort.c standard libkern/random.c standard libkern/scanc.c standard libkern/skpc.c standard libkern/strcat.c standard libkern/strcmp.c standard libkern/strcpy.c standard libkern/strlen.c standard libkern/strncmp.c standard libkern/strncpy.c standard libkern/udivdi3.c standard libkern/umoddi3.c standard gnu/i386/fpemul/div_small.s optional gpl_math_emulate gnu/i386/fpemul/errors.c optional gpl_math_emulate gnu/i386/fpemul/fpu_arith.c optional gpl_math_emulate gnu/i386/fpemul/fpu_aux.c optional gpl_math_emulate gnu/i386/fpemul/fpu_entry.c optional gpl_math_emulate gnu/i386/fpemul/fpu_etc.c optional gpl_math_emulate gnu/i386/fpemul/fpu_trig.c optional gpl_math_emulate gnu/i386/fpemul/get_address.c optional gpl_math_emulate gnu/i386/fpemul/load_store.c optional gpl_math_emulate gnu/i386/fpemul/poly_2xm1.c optional gpl_math_emulate gnu/i386/fpemul/poly_atan.c optional gpl_math_emulate gnu/i386/fpemul/poly_div.s optional gpl_math_emulate gnu/i386/fpemul/poly_l2.c optional gpl_math_emulate gnu/i386/fpemul/poly_mul64.s optional gpl_math_emulate gnu/i386/fpemul/poly_sin.c optional gpl_math_emulate gnu/i386/fpemul/poly_tan.c optional gpl_math_emulate gnu/i386/fpemul/polynomial.s optional gpl_math_emulate gnu/i386/fpemul/reg_add_sub.c optional gpl_math_emulate gnu/i386/fpemul/reg_compare.c optional gpl_math_emulate gnu/i386/fpemul/reg_constant.c optional gpl_math_emulate gnu/i386/fpemul/reg_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_ld_str.c optional gpl_math_emulate gnu/i386/fpemul/reg_mul.c optional gpl_math_emulate gnu/i386/fpemul/reg_norm.s optional gpl_math_emulate gnu/i386/fpemul/reg_round.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_add.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_mul.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_sub.s optional gpl_math_emulate gnu/i386/fpemul/wm_shrx.s optional gpl_math_emulate gnu/i386/fpemul/wm_sqrt.s optional gpl_math_emulate gnu/i386/isa/dgb.c optional dgb device-driver gnu/i386/isa/dgm.c optional dgm device-driver gnu/i386/isa/sound/awe_wave.c optional awe device-driver pci/ide_pci.c optional wd device-driver diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index 674f3cc146bc..e3e867ab84d6 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -1,1668 +1,1672 @@ # # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.457 1998/09/03 20:58:34 nsouch Exp $ +# $Id: LINT,v 1.458 1998/09/08 18:09:49 brian Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from # this file as required. # # # This directive is mandatory; it defines the architecture to be # configured for; in this case, the 386 family based IBM-PC and # compatibles. # machine "i386" # # This is the ``identification'' of the kernel. Usually this should # be the same as the name of your kernel. # ident LINT # # The `maxusers' parameter controls the static sizing of a number of # internal system tables by a complicated formula defined in param.c. # maxusers 10 # # Certain applications can grow to be larger than the 128M limit # that FreeBSD initially imposes. Below are some options to # allow that limit to grow to 256MB, and can be increased further # with changing the parameters. MAXDSIZ is the maximum that the # limit can be set to, and the DFLDSIZ is the default value for # the limit. You might want to set the default lower than the # max, and explicitly set the maximum with a shell command for processes # that regularly exceed the limit like INND. # options "MAXDSIZ=(256*1024*1024)" options "DFLDSIZ=(256*1024*1024)" # When this is set, be extra conservative in various parts of the kernel # and choose functionality over speed (on the widest variety of systems). options FAILSAFE # Options for the VM subsystem #options PQ_NOOPT # No coloring options PQ_LARGECACHE # color for 512k/16k cache #options PQ_HUGECACHE # color for 1024k/16k cache # This allows you to actually store this configuration file into # the kernel binary itself, where it may be later read by saying: # strings /kernel | grep ^___ | sed -e 's/^___//' > MYKERNEL # options INCLUDE_CONFIG_FILE # Include this file in kernel # # This directive defines a number of things: # - The compiled kernel is to be called `kernel' # - The root filesystem might be on partition wd0a # - Crash dumps will be written to wd0b, if possible. Specifying the # dump device here is not recommended. Use dumpon(8). # config kernel root on wd0 dumps on wd0 ##################################################################### # SMP OPTIONS: # # SMP enables building of a Symmetric MultiProcessor Kernel. # APIC_IO enables the use of the IO APIC for Symmetric I/O. # NCPU sets the number of CPUs, defaults to 2. # NBUS sets the number of busses, defaults to 4. # NAPIC sets the number of IO APICs on the motherboard, defaults to 1. # NINTR sets the total number of INTs provided by the motherboard. # # Notes: # # An SMP kernel will ONLY run on an Intel MP spec. qualified motherboard. # # Be sure to disable 'cpu "I386_CPU"' && 'cpu "I486_CPU"' for SMP kernels. # # Check the 'Rogue SMP hardware' section to see if additional options # are required by your hardware. # # Mandatory: options SMP # Symmetric MultiProcessor Kernel options APIC_IO # Symmetric (APIC) I/O # Optional, these are the defaults plus 1: options NCPU=5 # number of CPUs options NBUS=5 # number of busses options NAPIC=2 # number of IO APICs options NINTR=25 # number of INTs # # Rogue SMP hardware: # # Bridged PCI cards: # # The MP tables of most of the current generation MP motherboards # do NOT properly support bridged PCI cards. To use one of these # cards you should refer to ??? ##################################################################### # CPU OPTIONS # # You must specify at least one CPU (the one you intend to run on); # deleting the specification for CPUs you don't need to use may make # parts of the system run faster. This is especially true removing # I386_CPU. # cpu "I386_CPU" cpu "I486_CPU" cpu "I586_CPU" # aka Pentium(tm) cpu "I686_CPU" # aka Pentium Pro(tm) # # Options for CPU features. # # CPU_BLUELIGHTNING_FPU_OP_CACHE enables FPU operand cache on IBM # BlueLightning CPU. It works only with Cyrix FPU, and this option # should not be used with Intel FPU. # # CPU_BLUELIGHTNING_3X enables triple-clock mode on IBM Blue Lightning # CPU if CPU supports it. The default is double-clock mode on # BlueLightning CPU box. # # CPU_BTB_EN enables branch target buffer on Cyrix 5x86 (NOTE 1). # # CPU_DIRECT_MAPPED_CACHE sets L1 cache of Cyrix 486DLC CPU in direct # mapped mode. Default is 2-way set associative mode. # # CPU_CYRIX_NO_LOCK enables weak locking for the entire address space # of Cyrix 6x86 and 6x86MX CPUs. If this option is not set and # FAILESAFE is defined, NO_LOCK bit of CCR1 is cleared. (NOTE 3) # # CPU_DISABLE_5X86_LSSER disables load store serialize (i.e. enables # reorder). This option should not be used if you use memory mapped # I/O device(s). # # CPU_FASTER_5X86_FPU enables faster FPU exception handler. # # CPU_I486_ON_386 enables CPU cache on i486 based CPU upgrade products # for i386 machines. # # CPU_IORT defines I/O clock delay time (NOTE 1). Default vaules of # I/O clock delay time on Cyrix 5x86 and 6x86 are 0 and 7,respectively # (no clock delay). # # CPU_LOOP_EN prevents flushing the prefetch buffer if the destination # of a jump is already present in the prefetch buffer on Cyrix 5x86(NOTE # 1). # # CPU_RSTK_EN enables return stack on Cyrix 5x86 (NOTE 1). # # CPU_SUSP_HLT enables suspend on HALT. If this option is set, CPU # enters suspend mode following execution of HALT instruction. # # CPU_WT_ALLOC enables write-through allocation. # # CYRIX_CACHE_WORKS enables CPU cache on Cyrix 486 CPUs with cache # flush at hold state. # # CYRIX_CACHE_REALLY_WORKS enables (1) CPU cache on Cyrix 486 CPUs # without cache flush at hold state, and (2) write-back CPU cache on # Cyrix 6x86 whose revision < 2.7 (NOTE 2). # # NO_F00F_HACK disables the hack that prevents Pentiums (and ONLY # Pentiums) from locking up when a LOCK CMPXCHG8B instruction is # executed. This should be included for ALL kernels that won't run # on a Pentium. # # NOTE 1: The options, CPU_BTB_EN, CPU_LOOP_EN, CPU_IORT, # CPU_LOOP_ENand CPU_RSTK_EN should no be used becasue of CPU bugs. # These options may crash your system. # # NOTE 2: If CYRIX_CACHE_REALLY_WORKS is not set, CPU cache is enabled # in write-through mode when revision < 2.7. If revision of Cyrix # 6x86 >= 2.7, CPU cache is always enabled in write-back mode. # # NOTE 3: This option may cause failures for software that requires # locked cycles in order to operate correctly. # options "CPU_BLUELIGHTNING_FPU_OP_CACHE" options "CPU_BLUELIGHTNING_3X" options "CPU_BTB_EN" options "CPU_DIRECT_MAPPED_CACHE" options "CPU_DISABLE_5X86_LSSER" options "CPU_FASTER_5X86_FPU" options "CPU_I486_ON_386" options "CPU_IORT" options "CPU_LOOP_EN" options "CPU_RSTK_EN" options "CPU_SUSP_HLT" options "CYRIX_CACHE_WORKS" options "CYRIX_CACHE_REALLY_WORKS" #options "NO_F00F_HACK" # # A math emulator is mandatory if you wish to run on hardware which # does not have a floating-point processor. Pick either the original, # bogus (but freely-distributable) math emulator, or a much more # fully-featured but GPL-licensed emulator taken from Linux. # options MATH_EMULATE #Support for x87 emulation # Don't enable both of these in a real config. options GPL_MATH_EMULATE #Support for x87 emulation via #new math emulator ##################################################################### # COMPATIBILITY OPTIONS # # Implement system calls compatible with 4.3BSD and older versions of # FreeBSD. You probably do NOT want to remove this as much current code # still relies on the 4.3 emulation. # options "COMPAT_43" # # Allow user-mode programs to manipulate their local descriptor tables. # This option is required for the WINE Windows(tm) emulator, and is # not used by anything else (that we know of). # options USER_LDT #allow user-level control of i386 ldt # # These three options provide support for System V Interface # Definition-style interprocess communication, in the form of shared # memory, semaphores, and message queues, respectively. # options SYSVSHM options SYSVSEM options SYSVMSG # # This option includes a MD5 routine in the kernel, this is used for # various authentication and privacy uses. # options "MD5" # # Allow processes to switch to vm86 mode, as well as enabling direct # user-mode access to the I/O port space. This option is necessary for # the doscmd emulator to run. # options "VM86" ##################################################################### # DEBUGGING OPTIONS # # Enable the kernel debugger. # options DDB # # Don't drop into DDB for a panic. Intended for unattended operation # where you may want to drop to DDB from the console, but still want # the machine to recover from a panic # options DDB_UNATTENDED # # If using GDB remote mode to debug the kernel, there's a non-standard # extension to the remote protocol that can be used to use the serial # port as both the debugging port and the system console. It's non- # standard and you're on your own if you enable it. See also the # "remotechat" variables in the FreeBSD specific version of gdb. # options GDB_REMOTE_CHAT # # KTRACE enables the system-call tracing facility ktrace(2). # options KTRACE #kernel tracing # # The DIAGNOSTIC option is used in a number of source files to enable # extra sanity checking of internal structures. This support is not # enabled by default because of the extra time it would take to check # for these conditions, which can only occur as a result of # programming errors. # options DIAGNOSTIC # # PERFMON causes the driver for Pentium/Pentium Pro performance counters # to be compiled. See perfmon(4) for more information. # options PERFMON # # This option let some drivers co-exist that can't co-exist in a running # system. This is used to be able to compile all kernel code in one go for # quality assurance purposes (like this file, which the option takes it name # from.) # options COMPILING_LINT # XXX - this doesn't belong here. # Allow ordinary users to take the console - this is useful for X. options UCONSOLE # XXX - this doesn't belong here either options USERCONFIG #boot -c editor options USERCONFIG_BOOT #imply -c and parse info area options VISUAL_USERCONFIG #visual boot -c editor ##################################################################### # NETWORKING OPTIONS # # Protocol families: # Only the INET (Internet) family is officially supported in FreeBSD. # Source code for the NS (Xerox Network Service) is provided for amusement # value. # options INET #Internet communications protocols options IPX #IPX/SPX communications protocols options IPXIP #IPX in IP encapsulation (not available) options IPTUNNEL #IP in IPX encapsulation (not available) options NETATALK #Appletalk communications protocols # These are currently broken but are shipped due to interest. #options NS #Xerox NS protocols # These are currently broken and are no longer shipped due to lack # of interest. #options CCITT #X.25 network layer #options ISO #options TPIP #ISO TP class 4 over IP #options TPCONS #ISO TP class 0 over X.25 #options LLC #X.25 link layer for Ethernets #options HDLC #X.25 link layer for serial lines #options EON #ISO CLNP over IP #options NSIP #XNS over IP # # Network interfaces: # The `loop' pseudo-device is MANDATORY when networking is enabled. # The `ether' pseudo-device provides generic code to handle # Ethernets; it is MANDATORY when a Ethernet device driver is # configured. # The 'fddi' pseudo-device provides generic code to support FDDI. # The `sppp' pseudo-device serves a similar role for certain types # of synchronous PPP links (like `cx', `ar'). # The `sl' pseudo-device implements the Serial Line IP (SLIP) service. # The `ppp' pseudo-device implements the Point-to-Point Protocol. # The `bpfilter' pseudo-device enables the Berkeley Packet Filter. Be # aware of the legal and administrative consequences of enabling this # option. The number of devices determines the maximum number of # simultaneous BPF clients programs runnable. # The `disc' pseudo-device implements a minimal network interface, # which throws away all packets sent and never receives any. It is # included for testing purposes. # The `tun' pseudo-device implements the User Process PPP (iijppp) # # The PPP_BSDCOMP option enables support for compress(1) style entire # packet compression, the PPP_DEFLATE is for zlib/gzip style compression. # PPP_FILTER enables code for filtering the ppp data stream and selecting # events for resetting the demand dial activity timer - requires bpfilter. # See pppd(8) for more details. # pseudo-device ether #Generic Ethernet pseudo-device fddi #Generic FDDI pseudo-device sppp #Generic Synchronous PPP pseudo-device loop #Network loopback device pseudo-device bpfilter 4 #Berkeley packet filter pseudo-device disc #Discard device pseudo-device tun 1 #Tunnel driver (user process ppp(8)) pseudo-device sl 2 #Serial Line IP pseudo-device ppp 2 #Point-to-point protocol options PPP_BSDCOMP #PPP BSD-compress support options PPP_DEFLATE #PPP zlib/deflate/gzip support options PPP_FILTER #enable bpf filtering (needs bpfilter) # # Internet family options: # # TCP_COMPAT_42 causes the TCP code to emulate certain bugs present in # 4.2BSD. This option should not be used unless you have a 4.2BSD # machine and TCP connections fail. # # MROUTING enables the kernel multicast packet forwarder, which works # with mrouted(8). # # IPFIREWALL enables support for IP firewall construction, in # conjunction with the `ipfw' program. IPFIREWALL_VERBOSE sends # logged packets to the system logger. IPFIREWALL_VERBOSE_LIMIT # limits the number of times a matching entry can be logged. # # WARNING: IPFIREWALL defaults to a policy of "deny ip from any to any" # and if you do not add other rules during startup to allow access, # YOU WILL LOCK YOURSELF OUT. It is suggested that you set firewall=open # in /etc/rc.conf when first enabling this feature, then refining the # firewall rules in /etc/rc.firewall after you've tested that the new kernel # feature works properly. # # IPFIREWALL_DEFAULT_TO_ACCEPT causes the default rule (at boot) to # allow everything. Use with care, if a cracker can crash your # firewall machine, they can get to your protected machines. However, # if you are using it as an as-needed filter for specific problems as # they arise, then this may be for you. Changing the default to 'allow' # means that you won't get stuck if the kernel and /sbin/ipfw binary get # out of sync. # # IPDIVERT enables the divert IP sockets, used by ``ipfw divert'' # # IPFILTER enables Darren Reed's ipfilter package. # IPFILTER_LOG enables ipfilter's logging. # IPFILTER_LKM enables LKM support for an ipfilter module (untested). # # TCPDEBUG is undocumented. # options "TCP_COMPAT_42" #emulate 4.2BSD TCP bugs options MROUTING # Multicast routing options IPFIREWALL #firewall options IPFIREWALL_VERBOSE #print information about # dropped packets options IPFIREWALL_FORWARD #enable xparent proxy support options "IPFIREWALL_VERBOSE_LIMIT=100" #limit verbosity options IPFIREWALL_DEFAULT_TO_ACCEPT #allow everything by default options IPDIVERT #divert sockets options IPFILTER #kernel ipfilter support options IPFILTER_LOG #ipfilter logging #options IPFILTER_LKM #kernel support for ip_fil.o LKM options TCPDEBUG ##################################################################### # FILESYSTEM OPTIONS # # Only the root, /usr, and /tmp filesystems need be statically # compiled; everything else will be automatically loaded at mount # time. (Exception: the UFS family---FFS, and MFS --- cannot # currently be demand-loaded.) Some people still prefer to statically # compile other filesystems as well. # # NB: The NULL, PORTAL, UMAP and UNION filesystems are known to be # buggy, and WILL panic your system if you attempt to do anything with # them. They are included here as an incentive for some enterprising # soul to sit down and fix them. # # One of these is mandatory: options FFS #Fast filesystem options NFS #Network File System # The rest are optional: # options NFS_NOSERVER #Disable the NFS-server code. options "CD9660" #ISO 9660 filesystem options FDESC #File descriptor filesystem options KERNFS #Kernel filesystem options MFS #Memory File System options MSDOSFS #MS DOS File System options NULLFS #NULL filesystem options PORTAL #Portal filesystem options PROCFS #Process filesystem options UMAPFS #UID map filesystem options UNION #Union filesystem options "CD9660_ROOT" #CD-ROM usable as root device options FFS_ROOT #FFS usable as root device options NFS_ROOT #NFS usable as root device # DEVFS and SLICE are experimental but work. # SLICE disables too much old code so enabling it in LINT would be bad options DEVFS #devices filesystem #options SLICE #devfs based disk handling # Allow the FFS to use Softupdates technology. # To do this you need to copy the two files # /sys/ufs/ffs/softdep.h and /sys/ufs/ffs/ffs_softdep.c # from /usr/src/contrib/sys/softupdates # and understand the licensing restrictions. # You should also check on the FreeBSD website for newer versions. #options SOFTUPDATES # (we can't actually enable it because the files may not be present) # Make space in the kernel for a MFS root filesystem. Define to the number # of kilobytes to reserve for the filesystem. options MFS_ROOT=10 # Allow the MFS_ROOT code to load the MFS image from floppy if it is missing. options MFS_AUTOLOAD # Allows MFS filesystems to be exported via nfs options EXPORTMFS # Allow this many swap-devices. options NSWAPDEV=20 # Disk quotas are supported when this option is enabled. If you # change the value of this option, you must do a `make clean' in your # kernel compile directory in order to get a working kernel. # options QUOTA #enable disk quotas # Add more checking code to various filesystems #options NULLFS_DIAGNOSTIC #options KERNFS_DIAGNOSTIC #options UMAPFS_DIAGNOSTIC #options UNION_DIAGNOSTIC # In particular multi-session CD-Rs might require a huge amount of # time in order to "settle". If we are about mounting them as the # root f/s, we gotta wait a little. # # The number is supposed to be in seconds. options "CD9660_ROOTDELAY=20" # If you are running a machine just as a fileserver for PC and MAC # users, using SAMBA or Netatalk, you may consider setting this option # and keeping all those users' directories on a filesystem that is # mounted with the suiddir option. This gives new files the same # ownership as the directory (similiar to group). It's a security hole # if you let these users run programs, so confine it to file-servers # (but it'll save you lots of headaches in those cases). Root owned # directories are exempt and X bits are cleared. The suid bit must be # set on the directory as well; see chmod(1) PC owners can't see/set # ownerships so they keep getting their toes trodden on. This saves # you all the support calls as the filesystem it's used on will act as # they expect: "It's my dir so it must be my file". # options SUIDDIR # Add some error checking code to the null_bypass routine # in the NULL filesystem #options SAFETY # NFS options: options "NFS_MINATTRTIMO=3" # VREG attrib cache timeout in sec options "NFS_MAXATTRTIMO=60" options "NFS_MINDIRATTRTIMO=30" # VDIR attrib cache timeout in sec options "NFS_MAXDIRATTRTIMO=60" options "NFS_GATHERDELAY=10" # Default write gather delay (msec) options "NFS_UIDHASHSIZ=29" # Tune the size of nfssvc_sock with this options "NFS_WDELAYHASHSIZ=16" # and with this options "NFS_MUIDHASHSIZ=63" # Tune the size of nfsmount with this options NFS_DEBUG # Enable NFS Debugging # CFS stuff: #options CFS #CODA filesystem. #pseudo-device vcfs 4 #coda minicache <-> venus comm. ##################################################################### # POSIX P1003.1B # Real time extensions added int the 1993 Posix # P1003_1B: Infrastructure # _KPOSIX_PRIORITY_SCHEDULING: Build in _POSIX_PRIORITY_SCHEDULING # _KPOSIX_VERSION: Version kernel is built for options "P1003_1B" options "_KPOSIX_PRIORITY_SCHEDULING" options "_KPOSIX_VERSION=199309L" ##################################################################### # SCSI DEVICES # SCSI DEVICE CONFIGURATION # The SCSI subsystem consists of the `base' SCSI code, a number of # high-level SCSI device `type' drivers, and the low-level host-adapter # device drivers. The host adapters are listed in the ISA and PCI # device configuration sections below. # # Beginning with FreeBSD 2.0.5 you can wire down your SCSI devices so # that a given bus, target, and LUN always come on line as the same # device unit. In earlier versions the unit numbers were assigned # in the order that the devices were probed on the SCSI bus. This # means that if you removed a disk drive, you may have had to rewrite # your /etc/fstab file, and also that you had to be careful when adding # a new disk as it may have been probed earlier and moved your device # configuration around. # This old behavior is maintained as the default behavior. The unit # assignment begins with the first non-wired down unit for a device # type. For example, if you wire a disk as "sd3" then the first # non-wired disk will be assigned sd4. # The syntax for wiring down devices is: # controller scbus0 at ahc0 # Single bus device # controller scbus1 at ahc1 bus 0 # Single bus device # controller scbus3 at ahc2 bus 0 # Twin bus device # controller scbus2 at ahc2 bus 1 # Twin bus device # disk sd0 at scbus0 target 0 unit 0 # disk sd1 at scbus3 target 1 # disk sd2 at scbus2 target 3 # tape st1 at scbus1 target 6 # device cd0 at scbus? # "units" (SCSI logical unit number) that are not specified are # treated as if specified as LUN 0. # All SCSI devices allocate as many units as are required. # The "unknown" device (uk? in pre-2.0.5) is now part of the base SCSI # configuration and doesn't have to be explicitly configured. controller scbus0 #base SCSI code device ch0 #SCSI media changers device sd0 #SCSI disks device st0 #SCSI tapes device cd0 #SCSI CD-ROMs device od0 #SCSI optical disk # The previous devices (ch, sd, st, cd) are recognized by config. # config doesn't (and shouldn't) know about these newer ones, # so we have to specify that they are on a SCSI bus with the "at scbus?" # clause. device worm0 at scbus? # SCSI worm device pt0 at scbus? # SCSI processor type device sctarg0 at scbus? # SCSI target # SCSI OPTIONS: # SCSIDEBUG: When defined enables debugging macros # NO_SCSI_SENSE: When defined disables sense descriptions (about 4k) # SCSI_REPORT_GEOMETRY: Always report disk geometry at boot up instead # of only when booting verbosely. options SCSIDEBUG #options NO_SCSI_SENSE options SCSI_REPORT_GEOMETRY # Options for the `od' optical disk driver: # # If drive returns sense key as 0x02 with vendor specific additional # sense code (ASC) and additional sense code qualifier (ASCQ), or # illegal ASC and ASCQ. This cause an error (NOT READY) and retrying. # To suppress this, use the following option. # options OD_BOGUS_NOT_READY # # For an automatic spindown, try this. Again, preferably as an # option in your config file. # WARNING! Use at your own risk. Joerg's ancient SONY SMO drive # groks it fine, while Shunsuke's Fujitsu chokes on it and times # out. # options OD_AUTO_TURNOFF ##################################################################### # MISCELLANEOUS DEVICES AND OPTIONS # The `pty' device usually turns out to be ``effectively mandatory'', # as it is required for `telnetd', `rlogind', `screen', `emacs', and # `xterm', among others. pseudo-device pty 16 #Pseudo ttys - can go as high as 256 pseudo-device speaker #Play IBM BASIC-style noises out your speaker pseudo-device gzip #Exec gzipped a.out's pseudo-device vn #Vnode driver (turns a file into a device) pseudo-device snp 3 #Snoop device - to look at pty/vty/etc.. pseudo-device ccd 4 #Concatenated disk driver # These are only for watching for bitrot in old tty code. # broken #pseudo-device tb # These are only for watching for bitrot in old SCSI code. pseudo-device su #scsi user pseudo-device ssc #super scsi # Size of the kernel message buffer. Should be N * pagesize. options "MSGBUF_SIZE=40960" ##################################################################### # HARDWARE DEVICE CONFIGURATION # ISA and EISA devices: # EISA support is available for some device, so they can be auto-probed. # Micro Channel is not supported at all. # # Mandatory ISA devices: isa, npx # controller isa0 # # Options for `isa': # # AUTO_EOI_1 enables the `automatic EOI' feature for the master 8259A # interrupt controller. This saves about 0.7-1.25 usec for each interrupt. # This option breaks suspend/resume on some portables. # # AUTO_EOI_2 enables the `automatic EOI' feature for the slave 8259A # interrupt controller. This saves about 0.7-1.25 usec for each interrupt. # Automatic EOI is documented not to work for for the slave with the # original i8259A, but it works for some clones and some integrated # versions. # # BOUNCE_BUFFERS provides support for ISA DMA on machines with more # than 16 megabytes of memory. It doesn't hurt on other machines. # Some broken EISA and VLB hardware may need this, too. # # MAXMEM specifies the amount of RAM on the machine; if this is not # specified, FreeBSD will first read the amount of memory from the CMOS # RAM, so the amount of memory will initially be limited to 64MB or 16MB # depending on the BIOS. If the BIOS reports 64MB, a memory probe will # then attempt to detect the installed amount of RAM. If this probe # fails to detect >64MB RAM you will have to use the MAXMEM option. # The amount is in kilobytes, so for a machine with 128MB of RAM, it would # be 131072 (128 * 1024). # # TUNE_1542 enables the automatic ISA bus speed selection for the # Adaptec 1542 boards. Does not work for all boards, use it with caution. # # BROKEN_KEYBOARD_RESET disables the use of the keyboard controller to # reset the CPU for reboot. This is needed on some systems with broken # keyboard controllers. # # PAS_JOYSTICK_ENABLE enables the gameport on the ProAudio Spectrum options "AUTO_EOI_1" #options "AUTO_EOI_2" options BOUNCE_BUFFERS options "MAXMEM=(128*1024)" options "TUNE_1542" #options BROKEN_KEYBOARD_RESET #options PAS_JOYSTICK_ENABLE # Enable support for the kernel PLL to use an external PPS signal, # under supervision of [x]ntpd(8) # More info in ftp://ftp.udel.edu/pub/ntp/kernel.tar.Z options PPS_SYNC # Enable PnP support in the kernel. This allows you to automaticly # attach to PnP cards for drivers that support it and allows you to # configure cards from USERCONFIG. See pnp(4) for more info. controller pnp0 # The pcvt console driver (vt220 compatible). device vt0 at isa? port "IO_KBD" tty irq 1 vector pcrint options XSERVER # support for running an X server. options FAT_CURSOR # start with block cursor # This PCVT option is for keyboards such as those used on IBM ThinkPad laptops options PCVT_SCANSET=2 # IBM keyboards are non-std # The syscons console driver (sco color console compatible). device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr options MAXCONS=16 # number of virtual consoles options SLOW_VGA # do byte-wide i/o's to TS and GDC regs options "STD8X16FONT" # Compile font in makeoptions "STD8X16FONT"="cp850" options SC_HISTORY_SIZE=200 # number of history buffer lines options SC_DISABLE_REBOOT # disable reboot key sequence # If the screen flickers badly when the mouse pointer is moved, try this. options SC_BAD_FLICKER # # `flags' for sc0: # 0x01 Use a 'visual' bell # 0x02 Use a 'blink' cursor # 0x04 Use a 'underline' cursor # 0x06 Use a 'blinking underline' (destructive) cursor # 0x08 Force detection of keyboard, else we always assume a keyboard # 0x10 Old-style (XT) keyboard support, useful for older ThinkPads # 0x20 Don't reset keyboard, useful for some newer ThinkPads # 0x40 Make the bell quiet if it is rung in the backgroud vty. # # The Numeric Processing eXtension driver. This should be configured if # your machine has a math co-processor, unless the coprocessor is very # buggy. If it is not configured then you *must* configure math emulation # (see above). If both npx0 and emulation are configured, then only npx0 # is used (provided it works). device npx0 at isa? port "IO_NPX" iosiz 0x0 flags 0x0 irq 13 vector npxintr # # `flags' for npx0: # 0x01 don't use the npx registers to optimize bcopy # 0x02 don't use the npx registers to optimize bzero # 0x04 don't use the npx registers to optimize copyin or copyout. # The npx registers are normally used to optimize copying and zeroing when # all of the following conditions are satisfied: # "I586_CPU" is an option # the cpu is an i586 (perhaps not a Pentium) # the probe for npx0 succeeds # INT 16 exception handling works. # Then copying and zeroing using the npx registers is normally 30-100% faster. # The flags can be used to control cases where it doesn't work or is slower. # Setting them at boot time using userconfig works right (the optimizations # are not used until later in the bootstrap when npx0 is attached). # # # `iosiz' for npx0: # This can be used instead of the MAXMEM option to set the memory size. If # it is nonzero, then it overrides both the MAXMEM option and the memory # size reported by the BIOS. Setting it at boot time using userconfig takes # effect on the next reboot after the change has been recorded in the kernel # binary (the size is used early in the boot before userconfig has a chance # to change it). # # # Optional ISA and EISA devices: # # # SCSI host adapters: `aha', `aic', `bt', `nca' # # aha: Adaptec 154x # ahc: Adaptec 274x/284x/294x # aic: Adaptec 152x and sound cards using the Adaptec AIC-6360 (slow!) # bt: Most Buslogic controllers # nca: ProAudioSpectrum cards using the NCR 5380 or Trantor T130 # uha: UltraStor ULTRA 14F/24F/34F # sea: Seagate ST01/02 8 bit controller (slow!) # wds: Western Digital WD7000 controller (no scatter/gather!). # # Note that the order is important in order for Buslogic cards to be # probed correctly. # controller bt0 at isa? port "IO_BT0" bio irq ? vector bt_isa_intr controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr controller aic0 at isa? port 0x340 bio irq 11 vector aicintr controller nca0 at isa? port 0x1f88 bio irq 10 vector ncaintr controller nca1 at isa? port 0x1f84 controller nca2 at isa? port 0x1f8c controller nca3 at isa? port 0x1e88 controller nca4 at isa? port 0x350 bio irq 5 vector ncaintr controller sea0 at isa? bio irq 5 iomem 0xdc000 iosiz 0x2000 vector seaintr controller wds0 at isa? port 0x350 bio irq 15 drq 6 vector wdsintr # # ST-506, ESDI, and IDE hard disks: `wdc' and `wd' # # The flags fields are used to enable the multi-sector I/O and # the 32BIT I/O modes. The flags may be used in either the controller # definition or in the individual disk definitions. The controller # definition is supported for the boot configuration stuff. # # Each drive has a 16 bit flags value defined: # The low 8 bits are the maximum value for the multi-sector I/O, # where 0xff defaults to the maximum that the drive can handle. # The high bit of the 16 bit flags (0x8000) allows probing for # 32 bit transfers. Bit 14 (0x4000) enables a hack to wake # up powered-down laptop drives. Bit 13 (0x2000) allows # probing for PCI IDE DMA controllers, such as Intel's PIIX # south bridges. Bit 12 (0x1000) sets LBA mode instead of the # default CHS mode for accessing the drive. See the wd.4 man page. # # The flags field for the drives can be specified in the controller # specification with the low 16 bits for drive 0, and the high 16 bits # for drive 1. # e.g.: #controller wdc0 at isa? port "IO_WD1" bio irq 14 flags 0x00ff8004 vector wdintr # # specifies that drive 0 will be allowed to probe for 32 bit transfers and # a maximum multi-sector transfer of 4 sectors, and drive 1 will not be # allowed to probe for 32 bit transfers, but will allow multi-sector # transfers up to the maximum that the drive supports. # # If you are using a PCI controller that is not running in compatibility # mode (for example, it is a 2nd IDE PCI interface), then use config line(s) # such as: # #controller wdc2 at isa? port "0" bio irq ? flags 0xa0ffa0ff vector wdintr #disk wd4 at wdc2 drive 0 #disk wd5 at wdc2 drive 1 # #controller wdc3 at isa? port "0" bio irq ? flags 0xa0ffa0ff vector wdintr #disk wd6 at wdc3 drive 0 #disk wd7 at wdc3 drive 1 # # Note that the above config would be useful for a Promise card, when used # on a MB that already has a PIIX controller. Note the bogus irq and port # entries. These are automatically filled in by the IDE/PCI support. # controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr disk wd0 at wdc0 drive 0 disk wd1 at wdc0 drive 1 controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr disk wd2 at wdc1 drive 0 disk wd3 at wdc1 drive 1 # # Options for `wdc': # # CMD640 enables serializing access to primary and secondary channel # of the CMD640B IDE Chip. The serializing will only take place # if this option is set *and* the chip is probed by the pci-system. # options "CMD640" #Enable work around for CMD640 h/w bug # # ATAPI enables the support for ATAPI-compatible IDE devices # options ATAPI #Enable ATAPI support for IDE bus options ATAPI_STATIC #Don't do it as an LKM +# Use either the acd or the wcd device, not both! +# IDE CD-ROM & CD-R/RW driver - requires wdc controller and ATAPI option +device acd0 + # IDE CD-ROM driver - requires wdc controller and ATAPI option device wcd0 # IDE floppy driver - requires wdc controller and ATAPI option device wfd0 # IDE tape driver - requires wdc controller and ATAPI option device wst0 # # Standard floppy disk controllers and floppy tapes: `fdc', `fd', and `ft' # controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr # # FDC_DEBUG enables floppy debugging. Since the debug output is huge, you # gotta turn it actually on by setting the variable fd_debug with DDB, # however. options FDC_DEBUG # This option is undocumented on purpose. options FDC_PRINT_BOGUS_CHIPTYPE # # Activate this line instead of the fdc0 line above if you happen to # have an Insight floppy tape. Probing them proved to be dangerous # for people with floppy disks only, so it's "hidden" behind a flag: #controller fdc0 at isa? port "IO_FD1" bio flags 1 irq 6 drq 2 vector fdintr disk fd0 at fdc0 drive 0 disk fd1 at fdc0 drive 1 tape ft0 at fdc0 drive 2 # # Other standard PC hardware: `lpt', `mse', `psm', `sio', etc. # # lpt: printer port # lpt specials: # port can be specified as ?, this will cause the driver to scan # the BIOS port list; # the irq and vector clauses may be omitted, this # will force the port into polling mode. # mse: Logitech and ATI InPort bus mouse ports # psm: PS/2 mouse port [note: conflicts with sc0/vt0, thus "conflicts" keywd] # sio: serial ports (see sio(4)) device lpt0 at isa? port? tty irq 7 vector lptintr device lpt1 at isa? port "IO_LPT3" tty irq 5 vector lptintr device mse0 at isa? port 0x23c tty irq 5 vector mseintr device psm0 at isa? port "IO_KBD" conflicts tty irq 12 vector psmintr # Options for psm: options PSM_HOOKAPM #hook the APM resume event, useful #for some laptops options PSM_RESETAFTERSUSPEND #reset the device at the resume event device sio0 at isa? port "IO_COM1" tty flags 0x10 irq 4 vector siointr # # `flags' for serial drivers that support consoles (only for sio now): # 0x10 enable console support for this unit. The other console flags # are ignored unless this is set. Enabling console support does # not make the unit the preferred console - boot with -h or set # the 0x20 flag for that. Currently, at most one unit can have # console support; the first one (in config file order) with # this flag set is preferred. Setting this flag for sio0 gives # the old behaviour. # 0x20 force this unit to be the console (unless there is another # higher priority console). This replaces the COMCONSOLE option. # 0x40 reserve this unit for low level console operations. Do not # # PnP `flags' (set via userconfig using pnp x flags y) # 0x1 disable probing of this device. Used to prevent your modem # from being attached as a PnP modem. # # Options for serial drivers that support consoles (only for sio now): options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to #DDB, if available. options CONSPEED=9600 #default speed for serial console (default 9600) # Options for sio: options COM_ESP #code for Hayes ESP options COM_MULTIPORT #code for some cards with shared IRQs options DSI_SOFT_MODEM #code for DSI Softmodems options "EXTRA_SIO=2" #number of extra sio ports to allocate # Other flags for sio that aren't documented in the man page. # 0x20000 enable hardware RTS/CTS and larger FIFOs. Only works for # ST16650A-compatible UARTs. # # Network interfaces: `cx', `ed', `el', `ep', `ie', `is', `le', `lnc' # # ar: Arnet SYNC/570i hdlc sync 2/4 port V.35/X.21 serial driver (requires sppp) # cs: IBM Etherjet and other Crystal Semi CS89x0-based adapters # cx: Cronyx/Sigma multiport sync/async (with Cisco or PPP framing) # ed: Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503 # el: 3Com 3C501 (slow!) # ep: 3Com 3C509 (buggy) # fe: Fujitsu MB86960A/MB86965A Ethernet # ie: AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210; Intel EtherExpress # le: Digital Equipment EtherWorks 2 and EtherWorks 3 (DEPCA, DE100, # DE101, DE200, DE201, DE202, DE203, DE204, DE205, DE422) # lnc: Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL) # sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp) # wl: Lucent Wavelan (ISA card only). # ze: IBM/National Semiconductor PCMCIA ethernet controller. # zp: 3Com PCMCIA Etherlink III (It does not require shared memory for # send/receive operation, but it needs 'iomem' to read/write the # attribute memory) # device ar0 at isa? port 0x300 net irq 10 iomem 0xd0000 vector arintr device cs0 at isa? port 0x300 net irq ? vector csintr device cx0 at isa? port 0x240 net irq 15 drq 7 vector cxintr device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr device eg0 at isa? port 0x310 net irq 5 vector egintr device el0 at isa? port 0x300 net irq 9 vector elintr device ep0 at isa? port 0x300 net irq 10 vector epintr device ex0 at isa? port? net irq? vector exintr device fe0 at isa? port 0x300 net irq ? vector feintr device ie0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector ieintr device ie1 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr device le0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector le_intr device lnc0 at isa? port 0x300 net irq 10 drq 0 vector lncintr device sr0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector srintr options WLCACHE # enables the signal-strength cache options WLDEBUG # enables verbose debugging output device wl0 at isa? port 0x300 net irq ? vector wlintr # We can (bogusly) include both the dedicated PCCARD drivers and the generic # support when COMPILING_LINT. device ze0 at isa? port 0x300 net irq 5 iomem 0xd8000 vector zeintr device zp0 at isa? port 0x300 net irq 10 iomem 0xd8000 vector zpintr # # ATM related options # # The `en' device provides support for Efficient Networks (ENI) # ENI-155 PCI midway cards, and the Adaptec 155Mbps PCI ATM cards (ANA-59x0). # # atm pseudo-device provides generic atm functions and is required for # atm devices. # NATM enables the netnatm protocol family that can be used to # bypass TCP/IP. # # the current driver supports only PVC operations (no atm-arp, no multicast). # for more details, please read the original documents at # http://www.ccrc.wustl.edu/pub/chuck/bsdatm/wucs.html # pseudo-device atm device en0 device en1 options NATM #native ATM # # Audio drivers: `snd', `sb', `pas', `gus', `pca' # # snd: Voxware sound support code # sb: SoundBlaster PCM - SoundBlaster, SB Pro, SB16, ProAudioSpectrum # sbxvi: SoundBlaster 16 # sbmidi: SoundBlaster 16 MIDI interface # pas: ProAudioSpectrum PCM and MIDI # gus: Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX # gusxvi: Gravis Ultrasound 16-bit PCM (do not use) # mss: Microsoft Sound System # css: Crystal Sound System (CSS 423x PnP) # sscape: Ensoniq Soundscape MIDI interface # sscape_mss: Ensoniq Soundscape PCM (requires sscape) # opl: Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum # uart: stand-alone 6850 UART for MIDI # mpu: Roland MPU-401 stand-alone card # # Beware! The addresses specified below are also hard-coded in # i386/isa/sound/sound_config.h. If you change the values here, you # must also change the values in the include file. # # pcm: PCM audio through various sound cards. # # This is the work in progress from Luigi Rizzo. This has support for # CS423x based cards, OPTi931, SB16 PnP, GusPnP. For more information # about this driver, take a look at sys/i386/isa/snd/README. # # The flags of the device tells the device a bit more info about the # device that normally is obtained through the PnP interface. # bit 2..0 secondary DMA channel; # bit 4 set if the board uses two dma channels; # bit 15..8 board type, overrides autodetection; leave it # zero if don't know what to put in (and you don't, # since this is unsupported at the moment...). # # This driver will use the new PnP code if it's available. # # pca: PCM audio through your PC speaker # # If you have a GUS-MAX card and want to use the CS4231 codec on the # card the drqs for the gus max must be 8 bit (1, 2, or 3). # # If you would like to use the full duplex option on the gus, then define # flags to be the ``read dma channel''. # # options BROKEN_BUS_CLOCK #PAS-16 isn't working and OPTI chipset # options SYMPHONY_PAS #PAS-16 isn't working and SYMPHONY chipset # options EXCLUDE_SBPRO #PAS-16 # options SBC_IRQ=5 #PAS-16. Must match irq on sb0 line. # PAS16: The order of the pas0/sb0/opl0 is important since the # sb emulation is enabled in the pas-16 attach. # # To overide the GUS defaults use: # options GUS_DMA2 # options GUS_DMA # options GUS_IRQ # # The i386/isa/sound/sound.doc has more information. # Controls all "VOXWARE" driver sound devices. See Luigi's driver # below for an alternate which may work better for some cards. # controller snd0 device pas0 at isa? port 0x388 irq 10 drq 6 vector pasintr device sb0 at isa? port 0x220 irq 5 drq 1 vector sbintr device sbxvi0 at isa? drq 5 device sbmidi0 at isa? port 0x330 device awe0 at isa? port 0x620 device gus0 at isa? port 0x220 irq 12 drq 1 vector gusintr #device gus0 at isa? port 0x220 irq 12 drq 1 flags 0x3 vector gusintr device mss0 at isa? port 0x530 irq 10 drq 1 vector adintr device css0 at isa? port 0x534 irq 5 drq 1 flags 0x08 vector adintr device sscape0 at isa? port 0x330 irq 9 drq 0 vector sscapeintr device trix0 at isa? port 0x330 irq 6 drq 0 vector sscapeintr device sscape_mss0 at isa? port 0x534 irq 5 drq 1 vector sndintr device opl0 at isa? port 0x388 device mpu0 at isa? port 0x330 irq 6 drq 0 device uart0 at isa? port 0x330 irq 5 vector "m6850intr" # Luigi's snd code (use INSTEAD of snd0 and all VOXWARE drivers!). # You may also wish to enable the pnp controller with this, for pnp # sound cards. # #device pcm0 at isa? port ? tty irq 10 drq 1 flags 0x0 vector pcmintr # Not controlled by `snd' device pca0 at isa? port IO_TIMER1 tty # # Miscellaneous hardware: # # mcd: Mitsumi CD-ROM # scd: Sony CD-ROM # matcd: Matsushita/Panasonic CD-ROM # wt: Wangtek and Archive QIC-02/QIC-36 tape drives # ctx: Cortex-I frame grabber # apm: Laptop Advanced Power Management (experimental) # spigot: The Creative Labs Video Spigot video-acquisition board # meteor: Matrox Meteor video capture board # alog: Industrial Computer Source AIO8-P driver # bktr: Bt848 capture boards (http://www.freebsd.org/~fsmp/HomeAuto/Bt848.html) # cy: Cyclades serial driver # dgb: Digiboard PC/Xi and PC/Xe series driver (ALPHA QUALITY!) # dgm: Digiboard PC/Xem driver # gp: National Instruments AT-GPIB and AT-GPIB/TNT board # asc: GI1904-based hand scanners, e.g. the Trust Amiscan Grey # gsc: Genius GS-4500 hand scanner. # joy: joystick # labpc: National Instrument's Lab-PC and Lab-PC+ # rc: RISCom/8 multiport card # rp: Comtrol Rocketport(ISA) - single card # tw: TW-523 power line interface for use with X-10 home control products # si: Specialix SI/XIO 4-32 port terminal multiplexor # stl: Stallion EasyIO and EasyConnection 8/32 (cd1400 based) # stli: Stallion EasyConnection 8/64, ONboard, Brumby (intelligent) # # Notes on APM # The flags takes the following meaning for apm0: # 0x0020 Statclock is broken. # 0x0011 Limit APM protocol to 1.1 or 1.0 # 0x0010 Limit APM protocol to 1.0 # # # Notes on the spigot: # The video spigot is at 0xad6. This port address can not be changed. # The irq values may only be 10, 11, or 15 # I/O memory is an 8kb region. Possible values are: # 0a0000, 0a2000, ..., 0fffff, f00000, f02000, ..., ffffff # The start address must be on an even boundary. # Add the following option if you want to allow non-root users to be able # to access the spigot. This option is not secure because it allows users # direct access to the I/O page. # options SPIGOT_UNSECURE # # Notes on the Comtrol Rocketport driver: # # The exact values used for rp0 depend on how many boards you have # in the system. The manufacturer's sample configs are listed as: # # Comtrol Rocketport ISA single card # device rp0 at isa? port 0x280 tty # # If instead you have two ISA cards, one installed at 0x100 and the # second installed at 0x180, then you should add the following to # your kernel configuration file: # # device rp0 at isa? port 0x100 tty # device rp1 at isa? port 0x180 tty # # For 4 ISA cards, it might be something like this: # # device rp0 at isa? port 0x180 tty # device rp1 at isa? port 0x100 tty # device rp2 at isa? port 0x340 tty # device rp3 at isa? port 0x240 tty # # And for PCI cards, you only need say: # # device rp0 # device rp1 # ... # Note: Make sure that any Rocketport PCI devices are specified BEFORE the # ISA Rocketport devices. # Notes on the Digiboard driver: # # The following flag values have special meanings: # 0x01 - alternate layout of pins (dgb & dgm) # 0x02 - use the windowed PC/Xe in 64K mode (dgb only) # Notes on the Specialix SI/XIO driver: # **This is NOT a Specialix supported Driver!** # The host card is memory, not IO mapped. # The Rev 1 host cards use a 64K chunk, on a 32K boundary. # The Rev 2 host cards use a 32K chunk, on a 32K boundary. # The cards can use an IRQ of 11, 12 or 15. # Notes on the Stallion stl and stli drivers: # See src/i386/isa/README.stl for complete instructions. # This is version 0.0.5alpha, unsupported by Stallion. # The stl driver has a secondary IO port hard coded at 0x280. You need # to change src/i386/isa/stallion.c if you reconfigure this on the boards. # The "flags" and "iosiz" settings on the stli driver depend on the board: # EasyConnection 8/64 ISA: flags 23 iosiz 0x1000 # EasyConnection 8/64 EISA: flags 24 iosiz 0x10000 # EasyConnection 8/64 MCA: flags 25 iosiz 0x1000 # ONboard ISA: flags 4 iosiz 0x10000 # ONboard EISA: flags 7 iosiz 0x10000 # ONboard MCA: flags 3 iosiz 0x10000 # Brumby: flags 2 iosiz 0x4000 # Stallion: flags 1 iosiz 0x10000 device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr # for the Sony CDU31/33A CDROM device scd0 at isa? port 0x230 bio # for the SoundBlaster 16 multicd - up to 4 devices controller matcd0 at isa? port 0x230 bio device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr device ctx0 at isa? port 0x230 iomem 0xd0000 device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr device apm0 at isa? device gp0 at isa? port 0x2c0 tty device gsc0 at isa? port "IO_GSC1" tty drq 3 device joy0 at isa? port "IO_GAME" device alog0 at isa? port 0x260 tty irq 5 vector alogintr device cy0 at isa? tty irq 10 iomem 0xd4000 iosiz 0x2000 vector cyintr device dgb0 at isa? port 0x220 iomem 0xfc0000 iosiz ? tty device dgm0 at isa? port 0x104 iomem 0xd00000 iosiz ? tty device labpc0 at isa? port 0x260 tty irq 5 vector labpcintr device rc0 at isa? port 0x220 tty irq 12 vector rcintr device rp0 at isa? port 0x280 tty # the port and irq for tw0 are fictitious device tw0 at isa? port 0x380 tty irq 11 vector twintr device si0 at isa? iomem 0xd0000 tty irq 12 device asc0 at isa? port IO_ASC1 tty drq 3 irq 10 vector ascintr device bqu0 at isa? port 0x150 device stl0 at isa? port 0x2a0 tty irq 10 vector stlintr device stli0 at isa? port 0x2a0 tty iomem 0xcc000 flags 23 iosiz 0x1000 # You are unlikely to have the hardware for loran0 device loran0 at isa? port ? tty irq 5 vector loranintr # HOT1 Xilinx 6200 card (www.vcc.com) device xrpu0 # # EISA devices: # # The EISA bus device is eisa0. It provides auto-detection and # configuration support for all devices on the EISA bus. # # The `ahb' device provides support for the Adaptec 174X adapter. # # The `ahc' device provides support for the Adaptec 274X and 284X # adapters. The 284X, although a VLB card responds to EISA probes. # # fea: DEC DEFEA EISA FDDI adapter # controller eisa0 controller ahb0 controller ahc0 device fea0 # enable tagged command queuing, which is a major performance win on # devices that support it (and controllers with enough SCB's) options AHC_TAGENABLE # enable SCB paging - See the ahc.4 man page options AHC_SCBPAGING_ENABLE # The aic7xxx driver will attempt to use memory mapped I/O for all PCI # controllers that have it configured only if this option is set. Unfortunately, # this doesn't work on some motherboards, which prevents it from being the # default. options AHC_ALLOW_MEMIO # By default, only 10 EISA slots are probed, since the slot numbers # above clash with the configuration address space of the PCI subsystem, # and the EISA probe is not very smart about this. This is sufficient # for most machines, but in particular the HP NetServer LC series comes # with an onboard AIC7770 dual-channel SCSI controller on EISA slot #11, # thus you need to bump this figure to 12 for them. options "EISA_SLOTS=12" # # PCI devices & PCI options: # # The main PCI bus device is `pci'. It provides auto-detection and # configuration support for all devices on the PCI bus, using either # configuration mode defined in the PCI specification. # # The `ahc' device provides support for the Adaptec 29/3940(U)(W) # and motherboard based AIC7870/AIC7880 adapters. # # The `ncr' device provides support for the NCR 53C810 and 53C825 # self-contained SCSI host adapters. # # The `isp' device provides support for the Qlogic ISP 1020, 1040 # nd 1040B PCI SCSI host adapters, as well as the Qlogic ISP 2100 # FC/AL Host Adapter. # # The `amd' device provides support for the Tekram DC-390 and 390T # SCSI host adapters, but is expected to work with any AMD 53c974 # PCI SCSI chip and the AMD Ethernet+SCSI Combo chip, after some # local patches were applied to the sources (that had originally # been written by Tekram and limited to work with their SCSI cards). # # The `de' device provides support for the Digital Equipment DC21040 # self-contained Ethernet adapter. # # The `fxp' device provides support for the Intel EtherExpress Pro/100B # PCI Fast Ethernet adapters. # # The 'tl' device provides support for the Texas Instruments TNETE100 # series 'ThunderLAN' cards and integrated ethernet controllers. This # includes several Compaq Netelligent 10/100 cards and the built-in # ethernet controllers in several Compaq Prosignia, Proliant and # Deskpro systems. It also supports several Olicom 10Mbps and 10/100 # boards. # # The `tx' device provides support for the SMC 9432TX cards. # # The `vx' device provides support for the 3Com 3C590 and 3C595 # early support # # The `xl' driver provides support for the 3Com 3c900, 3c905 and # 3c905B (Fast) Etherlink XL cards and integrated controllers. This # includes the integrated 3c905B-TX chips in certain Dell Optiplex and # Dell Precision desktop machines and the integrated 3c905-TX chips # in Dell Latitude laptop docking stations. # # The `fpa' device provides support for the Digital DEFPA PCI FDDI # adapter. pseudo-device fddi is also needed. # # The `meteor' device is a PCI video capture board. It can also have the # following options: # options METEOR_ALLOC_PAGES=xxx preallocate kernel pages for data entry # figure (ROWS*COLUMN*BYTES_PER_PIXEL*FRAME+PAGE_SIZE-1)/PAGE_SIZE # options METEOR_DEALLOC_PAGES remove all allocated pages on close(2) # options METEOR_DEALLOC_ABOVE=xxx remove all allocated pages above the # specified amount. If this value is below the allocated amount no action # taken # option METEOR_SYSTEM_DEFAULT={METEOR_PAL|METEOR_NTSC|METEOR_SECAM}, used # for initialization of fps routine when a signal is not present. # # The 'bktr' device is a PCI video capture board. It also has a TV tuner # on board. To override the tuner detection use # options OVERRIDE_TUNER=x # The current values are found in /usr/src/sys/pci/brooktree848.c # # controller pci0 controller ahc1 controller ncr0 controller isp0 controller amd0 device de0 device fxp0 device tl0 device tx0 device vx0 device xl0 device fpa0 device meteor0 device bktr0 options OVERRIDE_TUNER=NO_TUNER # # PCI options # #options PCI_QUIET #quiets PCI code on chipset settings # # PCCARD/PCMCIA # # card: slot controller # pcic: slots controller card0 device pcic0 at card? device pcic1 at card? # You may need to reset all pccards after resuming options PCIC_RESUME_RESET # reset after resume # # Laptop/Notebook options: # # See also: # apm under `Miscellaneous hardware' # above. # For older notebooks that signal a powerfail condition (external # power supply dropped, or battery state low) by issuing an NMI: options POWERFAIL_NMI # make it beep instead of panicing # # SMB bus # # System Management Bus support provided by the 'smbus' device. # # Supported devices: # smb standard io # # Supported interfaces: # iicsmb I2C to SMB bridge # controller smbus0 device smb0 at smbus? # # I2C Bus # # Philips i2c bus support is provided by the `iicbus' device. # # Supported devices: # ic i2c network interface # iic i2c standard io # # Supported interfaces: # pcf Philips PCF8584 ISA-bus controller # controller iicbus0 device ic0 at iicbus? device iic0 at iicbus? device iicsmb0 at iicbus? controller pcf0 at isa? port 0x320 net irq 5 vector pcfintr # # Parallel-Port Bus # # Parallel port bus support is provided by the `ppbus' device. # Multiple devices may be attached to the parallel port, devices # are automatically probed and attached when found. # # Supported devices: # vpo Iomega Zip Drive # Requires SCSI disk support ('scbus' and 'sd'), best # performance is achieved with ports in EPP 1.9 mode. # nlpt Parallel Printer # plip Parallel network interface # ppi General-purpose I/O ("Geek Port") # # Supported interfaces: # ppc ISA-bus parallel port interfaces. # controller ppbus0 controller vpo0 at ppbus? device nlpt0 at ppbus? device plip0 at ppbus? device ppi0 at ppbus? device pps0 at ppbus? controller ppc0 at isa? disable port ? tty irq 7 vector ppcintr # Kernel BOOTP support options BOOTP # Use BOOTP to obtain IP address/hostname options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info options "BOOTP_NFSV3" # Use NFS v3 to NFS mount root options BOOTP_COMPAT # Workaround for broken bootp daemons. options "BOOTP_WIRED_TO=fxp0" # Use interface fxp0 for BOOTP # If you want to disable loadable kernel modules (LKM), you # might want to use this option. #options NO_LKM # # Add tie-ins for a hardware watchdog. This only enable the hooks; # the user must still supply the actual driver. # options HW_WDOG # # Set the number of PV entries per process. Increasing this can # stop panics related to heavy use of shared memory. However, that can # (combined with large amounts of physical memory) cause panics at # boot time due the kernel running out of VM space. # # If you're tweaking this, you might also want to increase the sysctls # "vm.v_free_min", "vm.v_free_reserved", and "vm.v_free_target". # # The value below is the one more than the default. # options "PMAP_SHPGPERPROC=201" # More undocumented options for linting. options CLK_CALIBRATION_LOOP options "CLK_USE_I8254_CALIBRATION" options CLK_USE_TSC_CALIBRATION options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG options "DEBUG_1284" #options DISABLE_PSE options "EXT2FS" options "I586_PMC_GUPROF=0x70000" options "IBCS2" options KEY options KEY_DEBUG options LOCKF_DEBUG options LOUTB options KBD_MAXRETRY=4 options KBD_MAXWAIT=6 options KBD_RESETDELAY=201 options KBDIO_DEBUG=2 options MSGMNB=2049 options MSGMNI=41 options MSGSEG=2049 options MSGSSZ=16 options MSGTQL=41 options NBUF=512 options NETATALKDEBUG options NMBCLUSTERS=1024 options NPX_DEBUG options PANIC_REBOOT_WAIT_TIME=16 options "PCVT_24LINESDEF" options PCVT_CTRL_ALT_DEL options PCVT_EMU_MOUSE options PCVT_FREEBSD=211 options PCVT_META_ESC options PCVT_NSCREENS=9 options PCVT_PRETTYSCRNS options PCVT_SCREENSAVER options PCVT_USEKBDSEC options "PCVT_VT220KEYB" options PSM_DEBUG=1 options "SCSI_2_DEF" options SCSI_DELAY=8 # Be pessimistic about Joe SCSI device options SCSI_NCR_DEBUG options SCSI_NCR_DFLT_TAGS=4 options SCSI_NCR_MAX_SYNC=10000 options SCSI_NCR_MAX_WIDE=1 options SCSI_NCR_MYADDR=7 options SEMMAP=31 options SEMMNI=11 options SEMMNS=61 options SEMMNU=31 options SEMMSL=61 options SEMOPM=101 options SEMUME=11 options SHOW_BUSYBUFS # List buffers that prevent root unmount options SHMALL=1025 options "SHMMAX=(SHMMAXPGS*PAGE_SIZE+1)" options SHMMAXPGS=1025 options SHMMIN=2 options SHMMNI=33 options SHMSEG=9 options SI_DEBUG options SIMPLELOCK_DEBUG options SPX_HACK # The 'dpt' driver provides support for DPT controllers (http://www.dpt.com/). # These have hardware RAID-{0,1,5} support, and do multi-initiator I/O. # The DPT controllers are commonly re-licensed under other brand-names - # some controllers by Olivetti, Dec, HP, AT&T, SNI, AST, Alphatronic, NEC and # Compaq are actually DPT controllers. # # See sys/dev/dpt for debugging and other subtle options. # DPT_VERIFY_HINTR Performs some strict hardware interrupts testing. # Only use if you suspect PCI bus corruption problems # DPT_RESTRICTED_FREELIST Normally, the freelisat used by the DPT for queue # will grow to accomodate increased use. This growth # will NOT shrink. To restrict the number of queue # slots to exactly what the DPT can hold at one time, # enable this option. # DPT_MEASURE_PERFORMANCE Enables a set of (semi)invasive metrics. Various # instruments are enabled. The tools in # /usr/sbin/dpt_* assume these to be enabled. # DPT_FREELIST_IS_STACK For optimal L{1,2} CPU cache utilization, enable # this option. Otherwise, the transaction queue is # a LIFO. I cannot measure the performance gain. # DPT_HANDLE_TIMEOUTS Normally device timeouts are handled by the DPT. # If you ant the driver to handle timeouts, enable # this option. If your system is very busy, this # option will create more trouble than solve. # DPT_TIMEOUT_FACTOR Used to compute the excessive amount of time to # wait when timing out with the above option. # DPT_DEBUG_xxxx These are controllable from sys/dev/dpt/dpt.h # DPT_LOST_IRQ When enabled, will try, once per second, to catch # any interrupt that got lost. Seems to help in some # DPT-firmware/Motherboard combinations. Minimal # cost, great benefit. # DPT_RESET_HBA Make "reset" actually reset the controller # instead of fudging it. Only enable this if you # are 100% certain you need it. # DPT_SHUTDOWN_SLEEP Reset controller if a request take more than # this number of seconds. Do NOT enable this # unless you are really, really, really certain # you need it. You are advised to call Simon (the # driver author) before setting it, and NEVER, # EVER set it to less than 300s (5 minutes). controller dpt0 # DPT options options DPT_VERIFY_HINTR options DPT_RESTRICTED_FREELIST options DPT_MEASURE_PERFORMANCE options DPT_FREELIST_IS_STACK options DPT_HANDLE_TIMEOUTS options DPT_TIMEOUT_FACTOR=4 options DPT_INTR_DELAY=200 # Some motherboards need that options DPT_LOST_IRQ options DPT_RESET_HBA # Don't EVER set this without having talked to Simon Shapiro on the phone # first. options DPT_SHUTDOWN_SLEEP=500 diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 674f3cc146bc..e3e867ab84d6 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -1,1668 +1,1672 @@ # # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.457 1998/09/03 20:58:34 nsouch Exp $ +# $Id: LINT,v 1.458 1998/09/08 18:09:49 brian Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from # this file as required. # # # This directive is mandatory; it defines the architecture to be # configured for; in this case, the 386 family based IBM-PC and # compatibles. # machine "i386" # # This is the ``identification'' of the kernel. Usually this should # be the same as the name of your kernel. # ident LINT # # The `maxusers' parameter controls the static sizing of a number of # internal system tables by a complicated formula defined in param.c. # maxusers 10 # # Certain applications can grow to be larger than the 128M limit # that FreeBSD initially imposes. Below are some options to # allow that limit to grow to 256MB, and can be increased further # with changing the parameters. MAXDSIZ is the maximum that the # limit can be set to, and the DFLDSIZ is the default value for # the limit. You might want to set the default lower than the # max, and explicitly set the maximum with a shell command for processes # that regularly exceed the limit like INND. # options "MAXDSIZ=(256*1024*1024)" options "DFLDSIZ=(256*1024*1024)" # When this is set, be extra conservative in various parts of the kernel # and choose functionality over speed (on the widest variety of systems). options FAILSAFE # Options for the VM subsystem #options PQ_NOOPT # No coloring options PQ_LARGECACHE # color for 512k/16k cache #options PQ_HUGECACHE # color for 1024k/16k cache # This allows you to actually store this configuration file into # the kernel binary itself, where it may be later read by saying: # strings /kernel | grep ^___ | sed -e 's/^___//' > MYKERNEL # options INCLUDE_CONFIG_FILE # Include this file in kernel # # This directive defines a number of things: # - The compiled kernel is to be called `kernel' # - The root filesystem might be on partition wd0a # - Crash dumps will be written to wd0b, if possible. Specifying the # dump device here is not recommended. Use dumpon(8). # config kernel root on wd0 dumps on wd0 ##################################################################### # SMP OPTIONS: # # SMP enables building of a Symmetric MultiProcessor Kernel. # APIC_IO enables the use of the IO APIC for Symmetric I/O. # NCPU sets the number of CPUs, defaults to 2. # NBUS sets the number of busses, defaults to 4. # NAPIC sets the number of IO APICs on the motherboard, defaults to 1. # NINTR sets the total number of INTs provided by the motherboard. # # Notes: # # An SMP kernel will ONLY run on an Intel MP spec. qualified motherboard. # # Be sure to disable 'cpu "I386_CPU"' && 'cpu "I486_CPU"' for SMP kernels. # # Check the 'Rogue SMP hardware' section to see if additional options # are required by your hardware. # # Mandatory: options SMP # Symmetric MultiProcessor Kernel options APIC_IO # Symmetric (APIC) I/O # Optional, these are the defaults plus 1: options NCPU=5 # number of CPUs options NBUS=5 # number of busses options NAPIC=2 # number of IO APICs options NINTR=25 # number of INTs # # Rogue SMP hardware: # # Bridged PCI cards: # # The MP tables of most of the current generation MP motherboards # do NOT properly support bridged PCI cards. To use one of these # cards you should refer to ??? ##################################################################### # CPU OPTIONS # # You must specify at least one CPU (the one you intend to run on); # deleting the specification for CPUs you don't need to use may make # parts of the system run faster. This is especially true removing # I386_CPU. # cpu "I386_CPU" cpu "I486_CPU" cpu "I586_CPU" # aka Pentium(tm) cpu "I686_CPU" # aka Pentium Pro(tm) # # Options for CPU features. # # CPU_BLUELIGHTNING_FPU_OP_CACHE enables FPU operand cache on IBM # BlueLightning CPU. It works only with Cyrix FPU, and this option # should not be used with Intel FPU. # # CPU_BLUELIGHTNING_3X enables triple-clock mode on IBM Blue Lightning # CPU if CPU supports it. The default is double-clock mode on # BlueLightning CPU box. # # CPU_BTB_EN enables branch target buffer on Cyrix 5x86 (NOTE 1). # # CPU_DIRECT_MAPPED_CACHE sets L1 cache of Cyrix 486DLC CPU in direct # mapped mode. Default is 2-way set associative mode. # # CPU_CYRIX_NO_LOCK enables weak locking for the entire address space # of Cyrix 6x86 and 6x86MX CPUs. If this option is not set and # FAILESAFE is defined, NO_LOCK bit of CCR1 is cleared. (NOTE 3) # # CPU_DISABLE_5X86_LSSER disables load store serialize (i.e. enables # reorder). This option should not be used if you use memory mapped # I/O device(s). # # CPU_FASTER_5X86_FPU enables faster FPU exception handler. # # CPU_I486_ON_386 enables CPU cache on i486 based CPU upgrade products # for i386 machines. # # CPU_IORT defines I/O clock delay time (NOTE 1). Default vaules of # I/O clock delay time on Cyrix 5x86 and 6x86 are 0 and 7,respectively # (no clock delay). # # CPU_LOOP_EN prevents flushing the prefetch buffer if the destination # of a jump is already present in the prefetch buffer on Cyrix 5x86(NOTE # 1). # # CPU_RSTK_EN enables return stack on Cyrix 5x86 (NOTE 1). # # CPU_SUSP_HLT enables suspend on HALT. If this option is set, CPU # enters suspend mode following execution of HALT instruction. # # CPU_WT_ALLOC enables write-through allocation. # # CYRIX_CACHE_WORKS enables CPU cache on Cyrix 486 CPUs with cache # flush at hold state. # # CYRIX_CACHE_REALLY_WORKS enables (1) CPU cache on Cyrix 486 CPUs # without cache flush at hold state, and (2) write-back CPU cache on # Cyrix 6x86 whose revision < 2.7 (NOTE 2). # # NO_F00F_HACK disables the hack that prevents Pentiums (and ONLY # Pentiums) from locking up when a LOCK CMPXCHG8B instruction is # executed. This should be included for ALL kernels that won't run # on a Pentium. # # NOTE 1: The options, CPU_BTB_EN, CPU_LOOP_EN, CPU_IORT, # CPU_LOOP_ENand CPU_RSTK_EN should no be used becasue of CPU bugs. # These options may crash your system. # # NOTE 2: If CYRIX_CACHE_REALLY_WORKS is not set, CPU cache is enabled # in write-through mode when revision < 2.7. If revision of Cyrix # 6x86 >= 2.7, CPU cache is always enabled in write-back mode. # # NOTE 3: This option may cause failures for software that requires # locked cycles in order to operate correctly. # options "CPU_BLUELIGHTNING_FPU_OP_CACHE" options "CPU_BLUELIGHTNING_3X" options "CPU_BTB_EN" options "CPU_DIRECT_MAPPED_CACHE" options "CPU_DISABLE_5X86_LSSER" options "CPU_FASTER_5X86_FPU" options "CPU_I486_ON_386" options "CPU_IORT" options "CPU_LOOP_EN" options "CPU_RSTK_EN" options "CPU_SUSP_HLT" options "CYRIX_CACHE_WORKS" options "CYRIX_CACHE_REALLY_WORKS" #options "NO_F00F_HACK" # # A math emulator is mandatory if you wish to run on hardware which # does not have a floating-point processor. Pick either the original, # bogus (but freely-distributable) math emulator, or a much more # fully-featured but GPL-licensed emulator taken from Linux. # options MATH_EMULATE #Support for x87 emulation # Don't enable both of these in a real config. options GPL_MATH_EMULATE #Support for x87 emulation via #new math emulator ##################################################################### # COMPATIBILITY OPTIONS # # Implement system calls compatible with 4.3BSD and older versions of # FreeBSD. You probably do NOT want to remove this as much current code # still relies on the 4.3 emulation. # options "COMPAT_43" # # Allow user-mode programs to manipulate their local descriptor tables. # This option is required for the WINE Windows(tm) emulator, and is # not used by anything else (that we know of). # options USER_LDT #allow user-level control of i386 ldt # # These three options provide support for System V Interface # Definition-style interprocess communication, in the form of shared # memory, semaphores, and message queues, respectively. # options SYSVSHM options SYSVSEM options SYSVMSG # # This option includes a MD5 routine in the kernel, this is used for # various authentication and privacy uses. # options "MD5" # # Allow processes to switch to vm86 mode, as well as enabling direct # user-mode access to the I/O port space. This option is necessary for # the doscmd emulator to run. # options "VM86" ##################################################################### # DEBUGGING OPTIONS # # Enable the kernel debugger. # options DDB # # Don't drop into DDB for a panic. Intended for unattended operation # where you may want to drop to DDB from the console, but still want # the machine to recover from a panic # options DDB_UNATTENDED # # If using GDB remote mode to debug the kernel, there's a non-standard # extension to the remote protocol that can be used to use the serial # port as both the debugging port and the system console. It's non- # standard and you're on your own if you enable it. See also the # "remotechat" variables in the FreeBSD specific version of gdb. # options GDB_REMOTE_CHAT # # KTRACE enables the system-call tracing facility ktrace(2). # options KTRACE #kernel tracing # # The DIAGNOSTIC option is used in a number of source files to enable # extra sanity checking of internal structures. This support is not # enabled by default because of the extra time it would take to check # for these conditions, which can only occur as a result of # programming errors. # options DIAGNOSTIC # # PERFMON causes the driver for Pentium/Pentium Pro performance counters # to be compiled. See perfmon(4) for more information. # options PERFMON # # This option let some drivers co-exist that can't co-exist in a running # system. This is used to be able to compile all kernel code in one go for # quality assurance purposes (like this file, which the option takes it name # from.) # options COMPILING_LINT # XXX - this doesn't belong here. # Allow ordinary users to take the console - this is useful for X. options UCONSOLE # XXX - this doesn't belong here either options USERCONFIG #boot -c editor options USERCONFIG_BOOT #imply -c and parse info area options VISUAL_USERCONFIG #visual boot -c editor ##################################################################### # NETWORKING OPTIONS # # Protocol families: # Only the INET (Internet) family is officially supported in FreeBSD. # Source code for the NS (Xerox Network Service) is provided for amusement # value. # options INET #Internet communications protocols options IPX #IPX/SPX communications protocols options IPXIP #IPX in IP encapsulation (not available) options IPTUNNEL #IP in IPX encapsulation (not available) options NETATALK #Appletalk communications protocols # These are currently broken but are shipped due to interest. #options NS #Xerox NS protocols # These are currently broken and are no longer shipped due to lack # of interest. #options CCITT #X.25 network layer #options ISO #options TPIP #ISO TP class 4 over IP #options TPCONS #ISO TP class 0 over X.25 #options LLC #X.25 link layer for Ethernets #options HDLC #X.25 link layer for serial lines #options EON #ISO CLNP over IP #options NSIP #XNS over IP # # Network interfaces: # The `loop' pseudo-device is MANDATORY when networking is enabled. # The `ether' pseudo-device provides generic code to handle # Ethernets; it is MANDATORY when a Ethernet device driver is # configured. # The 'fddi' pseudo-device provides generic code to support FDDI. # The `sppp' pseudo-device serves a similar role for certain types # of synchronous PPP links (like `cx', `ar'). # The `sl' pseudo-device implements the Serial Line IP (SLIP) service. # The `ppp' pseudo-device implements the Point-to-Point Protocol. # The `bpfilter' pseudo-device enables the Berkeley Packet Filter. Be # aware of the legal and administrative consequences of enabling this # option. The number of devices determines the maximum number of # simultaneous BPF clients programs runnable. # The `disc' pseudo-device implements a minimal network interface, # which throws away all packets sent and never receives any. It is # included for testing purposes. # The `tun' pseudo-device implements the User Process PPP (iijppp) # # The PPP_BSDCOMP option enables support for compress(1) style entire # packet compression, the PPP_DEFLATE is for zlib/gzip style compression. # PPP_FILTER enables code for filtering the ppp data stream and selecting # events for resetting the demand dial activity timer - requires bpfilter. # See pppd(8) for more details. # pseudo-device ether #Generic Ethernet pseudo-device fddi #Generic FDDI pseudo-device sppp #Generic Synchronous PPP pseudo-device loop #Network loopback device pseudo-device bpfilter 4 #Berkeley packet filter pseudo-device disc #Discard device pseudo-device tun 1 #Tunnel driver (user process ppp(8)) pseudo-device sl 2 #Serial Line IP pseudo-device ppp 2 #Point-to-point protocol options PPP_BSDCOMP #PPP BSD-compress support options PPP_DEFLATE #PPP zlib/deflate/gzip support options PPP_FILTER #enable bpf filtering (needs bpfilter) # # Internet family options: # # TCP_COMPAT_42 causes the TCP code to emulate certain bugs present in # 4.2BSD. This option should not be used unless you have a 4.2BSD # machine and TCP connections fail. # # MROUTING enables the kernel multicast packet forwarder, which works # with mrouted(8). # # IPFIREWALL enables support for IP firewall construction, in # conjunction with the `ipfw' program. IPFIREWALL_VERBOSE sends # logged packets to the system logger. IPFIREWALL_VERBOSE_LIMIT # limits the number of times a matching entry can be logged. # # WARNING: IPFIREWALL defaults to a policy of "deny ip from any to any" # and if you do not add other rules during startup to allow access, # YOU WILL LOCK YOURSELF OUT. It is suggested that you set firewall=open # in /etc/rc.conf when first enabling this feature, then refining the # firewall rules in /etc/rc.firewall after you've tested that the new kernel # feature works properly. # # IPFIREWALL_DEFAULT_TO_ACCEPT causes the default rule (at boot) to # allow everything. Use with care, if a cracker can crash your # firewall machine, they can get to your protected machines. However, # if you are using it as an as-needed filter for specific problems as # they arise, then this may be for you. Changing the default to 'allow' # means that you won't get stuck if the kernel and /sbin/ipfw binary get # out of sync. # # IPDIVERT enables the divert IP sockets, used by ``ipfw divert'' # # IPFILTER enables Darren Reed's ipfilter package. # IPFILTER_LOG enables ipfilter's logging. # IPFILTER_LKM enables LKM support for an ipfilter module (untested). # # TCPDEBUG is undocumented. # options "TCP_COMPAT_42" #emulate 4.2BSD TCP bugs options MROUTING # Multicast routing options IPFIREWALL #firewall options IPFIREWALL_VERBOSE #print information about # dropped packets options IPFIREWALL_FORWARD #enable xparent proxy support options "IPFIREWALL_VERBOSE_LIMIT=100" #limit verbosity options IPFIREWALL_DEFAULT_TO_ACCEPT #allow everything by default options IPDIVERT #divert sockets options IPFILTER #kernel ipfilter support options IPFILTER_LOG #ipfilter logging #options IPFILTER_LKM #kernel support for ip_fil.o LKM options TCPDEBUG ##################################################################### # FILESYSTEM OPTIONS # # Only the root, /usr, and /tmp filesystems need be statically # compiled; everything else will be automatically loaded at mount # time. (Exception: the UFS family---FFS, and MFS --- cannot # currently be demand-loaded.) Some people still prefer to statically # compile other filesystems as well. # # NB: The NULL, PORTAL, UMAP and UNION filesystems are known to be # buggy, and WILL panic your system if you attempt to do anything with # them. They are included here as an incentive for some enterprising # soul to sit down and fix them. # # One of these is mandatory: options FFS #Fast filesystem options NFS #Network File System # The rest are optional: # options NFS_NOSERVER #Disable the NFS-server code. options "CD9660" #ISO 9660 filesystem options FDESC #File descriptor filesystem options KERNFS #Kernel filesystem options MFS #Memory File System options MSDOSFS #MS DOS File System options NULLFS #NULL filesystem options PORTAL #Portal filesystem options PROCFS #Process filesystem options UMAPFS #UID map filesystem options UNION #Union filesystem options "CD9660_ROOT" #CD-ROM usable as root device options FFS_ROOT #FFS usable as root device options NFS_ROOT #NFS usable as root device # DEVFS and SLICE are experimental but work. # SLICE disables too much old code so enabling it in LINT would be bad options DEVFS #devices filesystem #options SLICE #devfs based disk handling # Allow the FFS to use Softupdates technology. # To do this you need to copy the two files # /sys/ufs/ffs/softdep.h and /sys/ufs/ffs/ffs_softdep.c # from /usr/src/contrib/sys/softupdates # and understand the licensing restrictions. # You should also check on the FreeBSD website for newer versions. #options SOFTUPDATES # (we can't actually enable it because the files may not be present) # Make space in the kernel for a MFS root filesystem. Define to the number # of kilobytes to reserve for the filesystem. options MFS_ROOT=10 # Allow the MFS_ROOT code to load the MFS image from floppy if it is missing. options MFS_AUTOLOAD # Allows MFS filesystems to be exported via nfs options EXPORTMFS # Allow this many swap-devices. options NSWAPDEV=20 # Disk quotas are supported when this option is enabled. If you # change the value of this option, you must do a `make clean' in your # kernel compile directory in order to get a working kernel. # options QUOTA #enable disk quotas # Add more checking code to various filesystems #options NULLFS_DIAGNOSTIC #options KERNFS_DIAGNOSTIC #options UMAPFS_DIAGNOSTIC #options UNION_DIAGNOSTIC # In particular multi-session CD-Rs might require a huge amount of # time in order to "settle". If we are about mounting them as the # root f/s, we gotta wait a little. # # The number is supposed to be in seconds. options "CD9660_ROOTDELAY=20" # If you are running a machine just as a fileserver for PC and MAC # users, using SAMBA or Netatalk, you may consider setting this option # and keeping all those users' directories on a filesystem that is # mounted with the suiddir option. This gives new files the same # ownership as the directory (similiar to group). It's a security hole # if you let these users run programs, so confine it to file-servers # (but it'll save you lots of headaches in those cases). Root owned # directories are exempt and X bits are cleared. The suid bit must be # set on the directory as well; see chmod(1) PC owners can't see/set # ownerships so they keep getting their toes trodden on. This saves # you all the support calls as the filesystem it's used on will act as # they expect: "It's my dir so it must be my file". # options SUIDDIR # Add some error checking code to the null_bypass routine # in the NULL filesystem #options SAFETY # NFS options: options "NFS_MINATTRTIMO=3" # VREG attrib cache timeout in sec options "NFS_MAXATTRTIMO=60" options "NFS_MINDIRATTRTIMO=30" # VDIR attrib cache timeout in sec options "NFS_MAXDIRATTRTIMO=60" options "NFS_GATHERDELAY=10" # Default write gather delay (msec) options "NFS_UIDHASHSIZ=29" # Tune the size of nfssvc_sock with this options "NFS_WDELAYHASHSIZ=16" # and with this options "NFS_MUIDHASHSIZ=63" # Tune the size of nfsmount with this options NFS_DEBUG # Enable NFS Debugging # CFS stuff: #options CFS #CODA filesystem. #pseudo-device vcfs 4 #coda minicache <-> venus comm. ##################################################################### # POSIX P1003.1B # Real time extensions added int the 1993 Posix # P1003_1B: Infrastructure # _KPOSIX_PRIORITY_SCHEDULING: Build in _POSIX_PRIORITY_SCHEDULING # _KPOSIX_VERSION: Version kernel is built for options "P1003_1B" options "_KPOSIX_PRIORITY_SCHEDULING" options "_KPOSIX_VERSION=199309L" ##################################################################### # SCSI DEVICES # SCSI DEVICE CONFIGURATION # The SCSI subsystem consists of the `base' SCSI code, a number of # high-level SCSI device `type' drivers, and the low-level host-adapter # device drivers. The host adapters are listed in the ISA and PCI # device configuration sections below. # # Beginning with FreeBSD 2.0.5 you can wire down your SCSI devices so # that a given bus, target, and LUN always come on line as the same # device unit. In earlier versions the unit numbers were assigned # in the order that the devices were probed on the SCSI bus. This # means that if you removed a disk drive, you may have had to rewrite # your /etc/fstab file, and also that you had to be careful when adding # a new disk as it may have been probed earlier and moved your device # configuration around. # This old behavior is maintained as the default behavior. The unit # assignment begins with the first non-wired down unit for a device # type. For example, if you wire a disk as "sd3" then the first # non-wired disk will be assigned sd4. # The syntax for wiring down devices is: # controller scbus0 at ahc0 # Single bus device # controller scbus1 at ahc1 bus 0 # Single bus device # controller scbus3 at ahc2 bus 0 # Twin bus device # controller scbus2 at ahc2 bus 1 # Twin bus device # disk sd0 at scbus0 target 0 unit 0 # disk sd1 at scbus3 target 1 # disk sd2 at scbus2 target 3 # tape st1 at scbus1 target 6 # device cd0 at scbus? # "units" (SCSI logical unit number) that are not specified are # treated as if specified as LUN 0. # All SCSI devices allocate as many units as are required. # The "unknown" device (uk? in pre-2.0.5) is now part of the base SCSI # configuration and doesn't have to be explicitly configured. controller scbus0 #base SCSI code device ch0 #SCSI media changers device sd0 #SCSI disks device st0 #SCSI tapes device cd0 #SCSI CD-ROMs device od0 #SCSI optical disk # The previous devices (ch, sd, st, cd) are recognized by config. # config doesn't (and shouldn't) know about these newer ones, # so we have to specify that they are on a SCSI bus with the "at scbus?" # clause. device worm0 at scbus? # SCSI worm device pt0 at scbus? # SCSI processor type device sctarg0 at scbus? # SCSI target # SCSI OPTIONS: # SCSIDEBUG: When defined enables debugging macros # NO_SCSI_SENSE: When defined disables sense descriptions (about 4k) # SCSI_REPORT_GEOMETRY: Always report disk geometry at boot up instead # of only when booting verbosely. options SCSIDEBUG #options NO_SCSI_SENSE options SCSI_REPORT_GEOMETRY # Options for the `od' optical disk driver: # # If drive returns sense key as 0x02 with vendor specific additional # sense code (ASC) and additional sense code qualifier (ASCQ), or # illegal ASC and ASCQ. This cause an error (NOT READY) and retrying. # To suppress this, use the following option. # options OD_BOGUS_NOT_READY # # For an automatic spindown, try this. Again, preferably as an # option in your config file. # WARNING! Use at your own risk. Joerg's ancient SONY SMO drive # groks it fine, while Shunsuke's Fujitsu chokes on it and times # out. # options OD_AUTO_TURNOFF ##################################################################### # MISCELLANEOUS DEVICES AND OPTIONS # The `pty' device usually turns out to be ``effectively mandatory'', # as it is required for `telnetd', `rlogind', `screen', `emacs', and # `xterm', among others. pseudo-device pty 16 #Pseudo ttys - can go as high as 256 pseudo-device speaker #Play IBM BASIC-style noises out your speaker pseudo-device gzip #Exec gzipped a.out's pseudo-device vn #Vnode driver (turns a file into a device) pseudo-device snp 3 #Snoop device - to look at pty/vty/etc.. pseudo-device ccd 4 #Concatenated disk driver # These are only for watching for bitrot in old tty code. # broken #pseudo-device tb # These are only for watching for bitrot in old SCSI code. pseudo-device su #scsi user pseudo-device ssc #super scsi # Size of the kernel message buffer. Should be N * pagesize. options "MSGBUF_SIZE=40960" ##################################################################### # HARDWARE DEVICE CONFIGURATION # ISA and EISA devices: # EISA support is available for some device, so they can be auto-probed. # Micro Channel is not supported at all. # # Mandatory ISA devices: isa, npx # controller isa0 # # Options for `isa': # # AUTO_EOI_1 enables the `automatic EOI' feature for the master 8259A # interrupt controller. This saves about 0.7-1.25 usec for each interrupt. # This option breaks suspend/resume on some portables. # # AUTO_EOI_2 enables the `automatic EOI' feature for the slave 8259A # interrupt controller. This saves about 0.7-1.25 usec for each interrupt. # Automatic EOI is documented not to work for for the slave with the # original i8259A, but it works for some clones and some integrated # versions. # # BOUNCE_BUFFERS provides support for ISA DMA on machines with more # than 16 megabytes of memory. It doesn't hurt on other machines. # Some broken EISA and VLB hardware may need this, too. # # MAXMEM specifies the amount of RAM on the machine; if this is not # specified, FreeBSD will first read the amount of memory from the CMOS # RAM, so the amount of memory will initially be limited to 64MB or 16MB # depending on the BIOS. If the BIOS reports 64MB, a memory probe will # then attempt to detect the installed amount of RAM. If this probe # fails to detect >64MB RAM you will have to use the MAXMEM option. # The amount is in kilobytes, so for a machine with 128MB of RAM, it would # be 131072 (128 * 1024). # # TUNE_1542 enables the automatic ISA bus speed selection for the # Adaptec 1542 boards. Does not work for all boards, use it with caution. # # BROKEN_KEYBOARD_RESET disables the use of the keyboard controller to # reset the CPU for reboot. This is needed on some systems with broken # keyboard controllers. # # PAS_JOYSTICK_ENABLE enables the gameport on the ProAudio Spectrum options "AUTO_EOI_1" #options "AUTO_EOI_2" options BOUNCE_BUFFERS options "MAXMEM=(128*1024)" options "TUNE_1542" #options BROKEN_KEYBOARD_RESET #options PAS_JOYSTICK_ENABLE # Enable support for the kernel PLL to use an external PPS signal, # under supervision of [x]ntpd(8) # More info in ftp://ftp.udel.edu/pub/ntp/kernel.tar.Z options PPS_SYNC # Enable PnP support in the kernel. This allows you to automaticly # attach to PnP cards for drivers that support it and allows you to # configure cards from USERCONFIG. See pnp(4) for more info. controller pnp0 # The pcvt console driver (vt220 compatible). device vt0 at isa? port "IO_KBD" tty irq 1 vector pcrint options XSERVER # support for running an X server. options FAT_CURSOR # start with block cursor # This PCVT option is for keyboards such as those used on IBM ThinkPad laptops options PCVT_SCANSET=2 # IBM keyboards are non-std # The syscons console driver (sco color console compatible). device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr options MAXCONS=16 # number of virtual consoles options SLOW_VGA # do byte-wide i/o's to TS and GDC regs options "STD8X16FONT" # Compile font in makeoptions "STD8X16FONT"="cp850" options SC_HISTORY_SIZE=200 # number of history buffer lines options SC_DISABLE_REBOOT # disable reboot key sequence # If the screen flickers badly when the mouse pointer is moved, try this. options SC_BAD_FLICKER # # `flags' for sc0: # 0x01 Use a 'visual' bell # 0x02 Use a 'blink' cursor # 0x04 Use a 'underline' cursor # 0x06 Use a 'blinking underline' (destructive) cursor # 0x08 Force detection of keyboard, else we always assume a keyboard # 0x10 Old-style (XT) keyboard support, useful for older ThinkPads # 0x20 Don't reset keyboard, useful for some newer ThinkPads # 0x40 Make the bell quiet if it is rung in the backgroud vty. # # The Numeric Processing eXtension driver. This should be configured if # your machine has a math co-processor, unless the coprocessor is very # buggy. If it is not configured then you *must* configure math emulation # (see above). If both npx0 and emulation are configured, then only npx0 # is used (provided it works). device npx0 at isa? port "IO_NPX" iosiz 0x0 flags 0x0 irq 13 vector npxintr # # `flags' for npx0: # 0x01 don't use the npx registers to optimize bcopy # 0x02 don't use the npx registers to optimize bzero # 0x04 don't use the npx registers to optimize copyin or copyout. # The npx registers are normally used to optimize copying and zeroing when # all of the following conditions are satisfied: # "I586_CPU" is an option # the cpu is an i586 (perhaps not a Pentium) # the probe for npx0 succeeds # INT 16 exception handling works. # Then copying and zeroing using the npx registers is normally 30-100% faster. # The flags can be used to control cases where it doesn't work or is slower. # Setting them at boot time using userconfig works right (the optimizations # are not used until later in the bootstrap when npx0 is attached). # # # `iosiz' for npx0: # This can be used instead of the MAXMEM option to set the memory size. If # it is nonzero, then it overrides both the MAXMEM option and the memory # size reported by the BIOS. Setting it at boot time using userconfig takes # effect on the next reboot after the change has been recorded in the kernel # binary (the size is used early in the boot before userconfig has a chance # to change it). # # # Optional ISA and EISA devices: # # # SCSI host adapters: `aha', `aic', `bt', `nca' # # aha: Adaptec 154x # ahc: Adaptec 274x/284x/294x # aic: Adaptec 152x and sound cards using the Adaptec AIC-6360 (slow!) # bt: Most Buslogic controllers # nca: ProAudioSpectrum cards using the NCR 5380 or Trantor T130 # uha: UltraStor ULTRA 14F/24F/34F # sea: Seagate ST01/02 8 bit controller (slow!) # wds: Western Digital WD7000 controller (no scatter/gather!). # # Note that the order is important in order for Buslogic cards to be # probed correctly. # controller bt0 at isa? port "IO_BT0" bio irq ? vector bt_isa_intr controller aha0 at isa? port "IO_AHA0" bio irq ? drq 5 vector ahaintr controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr controller aic0 at isa? port 0x340 bio irq 11 vector aicintr controller nca0 at isa? port 0x1f88 bio irq 10 vector ncaintr controller nca1 at isa? port 0x1f84 controller nca2 at isa? port 0x1f8c controller nca3 at isa? port 0x1e88 controller nca4 at isa? port 0x350 bio irq 5 vector ncaintr controller sea0 at isa? bio irq 5 iomem 0xdc000 iosiz 0x2000 vector seaintr controller wds0 at isa? port 0x350 bio irq 15 drq 6 vector wdsintr # # ST-506, ESDI, and IDE hard disks: `wdc' and `wd' # # The flags fields are used to enable the multi-sector I/O and # the 32BIT I/O modes. The flags may be used in either the controller # definition or in the individual disk definitions. The controller # definition is supported for the boot configuration stuff. # # Each drive has a 16 bit flags value defined: # The low 8 bits are the maximum value for the multi-sector I/O, # where 0xff defaults to the maximum that the drive can handle. # The high bit of the 16 bit flags (0x8000) allows probing for # 32 bit transfers. Bit 14 (0x4000) enables a hack to wake # up powered-down laptop drives. Bit 13 (0x2000) allows # probing for PCI IDE DMA controllers, such as Intel's PIIX # south bridges. Bit 12 (0x1000) sets LBA mode instead of the # default CHS mode for accessing the drive. See the wd.4 man page. # # The flags field for the drives can be specified in the controller # specification with the low 16 bits for drive 0, and the high 16 bits # for drive 1. # e.g.: #controller wdc0 at isa? port "IO_WD1" bio irq 14 flags 0x00ff8004 vector wdintr # # specifies that drive 0 will be allowed to probe for 32 bit transfers and # a maximum multi-sector transfer of 4 sectors, and drive 1 will not be # allowed to probe for 32 bit transfers, but will allow multi-sector # transfers up to the maximum that the drive supports. # # If you are using a PCI controller that is not running in compatibility # mode (for example, it is a 2nd IDE PCI interface), then use config line(s) # such as: # #controller wdc2 at isa? port "0" bio irq ? flags 0xa0ffa0ff vector wdintr #disk wd4 at wdc2 drive 0 #disk wd5 at wdc2 drive 1 # #controller wdc3 at isa? port "0" bio irq ? flags 0xa0ffa0ff vector wdintr #disk wd6 at wdc3 drive 0 #disk wd7 at wdc3 drive 1 # # Note that the above config would be useful for a Promise card, when used # on a MB that already has a PIIX controller. Note the bogus irq and port # entries. These are automatically filled in by the IDE/PCI support. # controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr disk wd0 at wdc0 drive 0 disk wd1 at wdc0 drive 1 controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr disk wd2 at wdc1 drive 0 disk wd3 at wdc1 drive 1 # # Options for `wdc': # # CMD640 enables serializing access to primary and secondary channel # of the CMD640B IDE Chip. The serializing will only take place # if this option is set *and* the chip is probed by the pci-system. # options "CMD640" #Enable work around for CMD640 h/w bug # # ATAPI enables the support for ATAPI-compatible IDE devices # options ATAPI #Enable ATAPI support for IDE bus options ATAPI_STATIC #Don't do it as an LKM +# Use either the acd or the wcd device, not both! +# IDE CD-ROM & CD-R/RW driver - requires wdc controller and ATAPI option +device acd0 + # IDE CD-ROM driver - requires wdc controller and ATAPI option device wcd0 # IDE floppy driver - requires wdc controller and ATAPI option device wfd0 # IDE tape driver - requires wdc controller and ATAPI option device wst0 # # Standard floppy disk controllers and floppy tapes: `fdc', `fd', and `ft' # controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr # # FDC_DEBUG enables floppy debugging. Since the debug output is huge, you # gotta turn it actually on by setting the variable fd_debug with DDB, # however. options FDC_DEBUG # This option is undocumented on purpose. options FDC_PRINT_BOGUS_CHIPTYPE # # Activate this line instead of the fdc0 line above if you happen to # have an Insight floppy tape. Probing them proved to be dangerous # for people with floppy disks only, so it's "hidden" behind a flag: #controller fdc0 at isa? port "IO_FD1" bio flags 1 irq 6 drq 2 vector fdintr disk fd0 at fdc0 drive 0 disk fd1 at fdc0 drive 1 tape ft0 at fdc0 drive 2 # # Other standard PC hardware: `lpt', `mse', `psm', `sio', etc. # # lpt: printer port # lpt specials: # port can be specified as ?, this will cause the driver to scan # the BIOS port list; # the irq and vector clauses may be omitted, this # will force the port into polling mode. # mse: Logitech and ATI InPort bus mouse ports # psm: PS/2 mouse port [note: conflicts with sc0/vt0, thus "conflicts" keywd] # sio: serial ports (see sio(4)) device lpt0 at isa? port? tty irq 7 vector lptintr device lpt1 at isa? port "IO_LPT3" tty irq 5 vector lptintr device mse0 at isa? port 0x23c tty irq 5 vector mseintr device psm0 at isa? port "IO_KBD" conflicts tty irq 12 vector psmintr # Options for psm: options PSM_HOOKAPM #hook the APM resume event, useful #for some laptops options PSM_RESETAFTERSUSPEND #reset the device at the resume event device sio0 at isa? port "IO_COM1" tty flags 0x10 irq 4 vector siointr # # `flags' for serial drivers that support consoles (only for sio now): # 0x10 enable console support for this unit. The other console flags # are ignored unless this is set. Enabling console support does # not make the unit the preferred console - boot with -h or set # the 0x20 flag for that. Currently, at most one unit can have # console support; the first one (in config file order) with # this flag set is preferred. Setting this flag for sio0 gives # the old behaviour. # 0x20 force this unit to be the console (unless there is another # higher priority console). This replaces the COMCONSOLE option. # 0x40 reserve this unit for low level console operations. Do not # # PnP `flags' (set via userconfig using pnp x flags y) # 0x1 disable probing of this device. Used to prevent your modem # from being attached as a PnP modem. # # Options for serial drivers that support consoles (only for sio now): options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to #DDB, if available. options CONSPEED=9600 #default speed for serial console (default 9600) # Options for sio: options COM_ESP #code for Hayes ESP options COM_MULTIPORT #code for some cards with shared IRQs options DSI_SOFT_MODEM #code for DSI Softmodems options "EXTRA_SIO=2" #number of extra sio ports to allocate # Other flags for sio that aren't documented in the man page. # 0x20000 enable hardware RTS/CTS and larger FIFOs. Only works for # ST16650A-compatible UARTs. # # Network interfaces: `cx', `ed', `el', `ep', `ie', `is', `le', `lnc' # # ar: Arnet SYNC/570i hdlc sync 2/4 port V.35/X.21 serial driver (requires sppp) # cs: IBM Etherjet and other Crystal Semi CS89x0-based adapters # cx: Cronyx/Sigma multiport sync/async (with Cisco or PPP framing) # ed: Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503 # el: 3Com 3C501 (slow!) # ep: 3Com 3C509 (buggy) # fe: Fujitsu MB86960A/MB86965A Ethernet # ie: AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210; Intel EtherExpress # le: Digital Equipment EtherWorks 2 and EtherWorks 3 (DEPCA, DE100, # DE101, DE200, DE201, DE202, DE203, DE204, DE205, DE422) # lnc: Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL) # sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp) # wl: Lucent Wavelan (ISA card only). # ze: IBM/National Semiconductor PCMCIA ethernet controller. # zp: 3Com PCMCIA Etherlink III (It does not require shared memory for # send/receive operation, but it needs 'iomem' to read/write the # attribute memory) # device ar0 at isa? port 0x300 net irq 10 iomem 0xd0000 vector arintr device cs0 at isa? port 0x300 net irq ? vector csintr device cx0 at isa? port 0x240 net irq 15 drq 7 vector cxintr device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr device eg0 at isa? port 0x310 net irq 5 vector egintr device el0 at isa? port 0x300 net irq 9 vector elintr device ep0 at isa? port 0x300 net irq 10 vector epintr device ex0 at isa? port? net irq? vector exintr device fe0 at isa? port 0x300 net irq ? vector feintr device ie0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector ieintr device ie1 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr device le0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector le_intr device lnc0 at isa? port 0x300 net irq 10 drq 0 vector lncintr device sr0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector srintr options WLCACHE # enables the signal-strength cache options WLDEBUG # enables verbose debugging output device wl0 at isa? port 0x300 net irq ? vector wlintr # We can (bogusly) include both the dedicated PCCARD drivers and the generic # support when COMPILING_LINT. device ze0 at isa? port 0x300 net irq 5 iomem 0xd8000 vector zeintr device zp0 at isa? port 0x300 net irq 10 iomem 0xd8000 vector zpintr # # ATM related options # # The `en' device provides support for Efficient Networks (ENI) # ENI-155 PCI midway cards, and the Adaptec 155Mbps PCI ATM cards (ANA-59x0). # # atm pseudo-device provides generic atm functions and is required for # atm devices. # NATM enables the netnatm protocol family that can be used to # bypass TCP/IP. # # the current driver supports only PVC operations (no atm-arp, no multicast). # for more details, please read the original documents at # http://www.ccrc.wustl.edu/pub/chuck/bsdatm/wucs.html # pseudo-device atm device en0 device en1 options NATM #native ATM # # Audio drivers: `snd', `sb', `pas', `gus', `pca' # # snd: Voxware sound support code # sb: SoundBlaster PCM - SoundBlaster, SB Pro, SB16, ProAudioSpectrum # sbxvi: SoundBlaster 16 # sbmidi: SoundBlaster 16 MIDI interface # pas: ProAudioSpectrum PCM and MIDI # gus: Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX # gusxvi: Gravis Ultrasound 16-bit PCM (do not use) # mss: Microsoft Sound System # css: Crystal Sound System (CSS 423x PnP) # sscape: Ensoniq Soundscape MIDI interface # sscape_mss: Ensoniq Soundscape PCM (requires sscape) # opl: Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum # uart: stand-alone 6850 UART for MIDI # mpu: Roland MPU-401 stand-alone card # # Beware! The addresses specified below are also hard-coded in # i386/isa/sound/sound_config.h. If you change the values here, you # must also change the values in the include file. # # pcm: PCM audio through various sound cards. # # This is the work in progress from Luigi Rizzo. This has support for # CS423x based cards, OPTi931, SB16 PnP, GusPnP. For more information # about this driver, take a look at sys/i386/isa/snd/README. # # The flags of the device tells the device a bit more info about the # device that normally is obtained through the PnP interface. # bit 2..0 secondary DMA channel; # bit 4 set if the board uses two dma channels; # bit 15..8 board type, overrides autodetection; leave it # zero if don't know what to put in (and you don't, # since this is unsupported at the moment...). # # This driver will use the new PnP code if it's available. # # pca: PCM audio through your PC speaker # # If you have a GUS-MAX card and want to use the CS4231 codec on the # card the drqs for the gus max must be 8 bit (1, 2, or 3). # # If you would like to use the full duplex option on the gus, then define # flags to be the ``read dma channel''. # # options BROKEN_BUS_CLOCK #PAS-16 isn't working and OPTI chipset # options SYMPHONY_PAS #PAS-16 isn't working and SYMPHONY chipset # options EXCLUDE_SBPRO #PAS-16 # options SBC_IRQ=5 #PAS-16. Must match irq on sb0 line. # PAS16: The order of the pas0/sb0/opl0 is important since the # sb emulation is enabled in the pas-16 attach. # # To overide the GUS defaults use: # options GUS_DMA2 # options GUS_DMA # options GUS_IRQ # # The i386/isa/sound/sound.doc has more information. # Controls all "VOXWARE" driver sound devices. See Luigi's driver # below for an alternate which may work better for some cards. # controller snd0 device pas0 at isa? port 0x388 irq 10 drq 6 vector pasintr device sb0 at isa? port 0x220 irq 5 drq 1 vector sbintr device sbxvi0 at isa? drq 5 device sbmidi0 at isa? port 0x330 device awe0 at isa? port 0x620 device gus0 at isa? port 0x220 irq 12 drq 1 vector gusintr #device gus0 at isa? port 0x220 irq 12 drq 1 flags 0x3 vector gusintr device mss0 at isa? port 0x530 irq 10 drq 1 vector adintr device css0 at isa? port 0x534 irq 5 drq 1 flags 0x08 vector adintr device sscape0 at isa? port 0x330 irq 9 drq 0 vector sscapeintr device trix0 at isa? port 0x330 irq 6 drq 0 vector sscapeintr device sscape_mss0 at isa? port 0x534 irq 5 drq 1 vector sndintr device opl0 at isa? port 0x388 device mpu0 at isa? port 0x330 irq 6 drq 0 device uart0 at isa? port 0x330 irq 5 vector "m6850intr" # Luigi's snd code (use INSTEAD of snd0 and all VOXWARE drivers!). # You may also wish to enable the pnp controller with this, for pnp # sound cards. # #device pcm0 at isa? port ? tty irq 10 drq 1 flags 0x0 vector pcmintr # Not controlled by `snd' device pca0 at isa? port IO_TIMER1 tty # # Miscellaneous hardware: # # mcd: Mitsumi CD-ROM # scd: Sony CD-ROM # matcd: Matsushita/Panasonic CD-ROM # wt: Wangtek and Archive QIC-02/QIC-36 tape drives # ctx: Cortex-I frame grabber # apm: Laptop Advanced Power Management (experimental) # spigot: The Creative Labs Video Spigot video-acquisition board # meteor: Matrox Meteor video capture board # alog: Industrial Computer Source AIO8-P driver # bktr: Bt848 capture boards (http://www.freebsd.org/~fsmp/HomeAuto/Bt848.html) # cy: Cyclades serial driver # dgb: Digiboard PC/Xi and PC/Xe series driver (ALPHA QUALITY!) # dgm: Digiboard PC/Xem driver # gp: National Instruments AT-GPIB and AT-GPIB/TNT board # asc: GI1904-based hand scanners, e.g. the Trust Amiscan Grey # gsc: Genius GS-4500 hand scanner. # joy: joystick # labpc: National Instrument's Lab-PC and Lab-PC+ # rc: RISCom/8 multiport card # rp: Comtrol Rocketport(ISA) - single card # tw: TW-523 power line interface for use with X-10 home control products # si: Specialix SI/XIO 4-32 port terminal multiplexor # stl: Stallion EasyIO and EasyConnection 8/32 (cd1400 based) # stli: Stallion EasyConnection 8/64, ONboard, Brumby (intelligent) # # Notes on APM # The flags takes the following meaning for apm0: # 0x0020 Statclock is broken. # 0x0011 Limit APM protocol to 1.1 or 1.0 # 0x0010 Limit APM protocol to 1.0 # # # Notes on the spigot: # The video spigot is at 0xad6. This port address can not be changed. # The irq values may only be 10, 11, or 15 # I/O memory is an 8kb region. Possible values are: # 0a0000, 0a2000, ..., 0fffff, f00000, f02000, ..., ffffff # The start address must be on an even boundary. # Add the following option if you want to allow non-root users to be able # to access the spigot. This option is not secure because it allows users # direct access to the I/O page. # options SPIGOT_UNSECURE # # Notes on the Comtrol Rocketport driver: # # The exact values used for rp0 depend on how many boards you have # in the system. The manufacturer's sample configs are listed as: # # Comtrol Rocketport ISA single card # device rp0 at isa? port 0x280 tty # # If instead you have two ISA cards, one installed at 0x100 and the # second installed at 0x180, then you should add the following to # your kernel configuration file: # # device rp0 at isa? port 0x100 tty # device rp1 at isa? port 0x180 tty # # For 4 ISA cards, it might be something like this: # # device rp0 at isa? port 0x180 tty # device rp1 at isa? port 0x100 tty # device rp2 at isa? port 0x340 tty # device rp3 at isa? port 0x240 tty # # And for PCI cards, you only need say: # # device rp0 # device rp1 # ... # Note: Make sure that any Rocketport PCI devices are specified BEFORE the # ISA Rocketport devices. # Notes on the Digiboard driver: # # The following flag values have special meanings: # 0x01 - alternate layout of pins (dgb & dgm) # 0x02 - use the windowed PC/Xe in 64K mode (dgb only) # Notes on the Specialix SI/XIO driver: # **This is NOT a Specialix supported Driver!** # The host card is memory, not IO mapped. # The Rev 1 host cards use a 64K chunk, on a 32K boundary. # The Rev 2 host cards use a 32K chunk, on a 32K boundary. # The cards can use an IRQ of 11, 12 or 15. # Notes on the Stallion stl and stli drivers: # See src/i386/isa/README.stl for complete instructions. # This is version 0.0.5alpha, unsupported by Stallion. # The stl driver has a secondary IO port hard coded at 0x280. You need # to change src/i386/isa/stallion.c if you reconfigure this on the boards. # The "flags" and "iosiz" settings on the stli driver depend on the board: # EasyConnection 8/64 ISA: flags 23 iosiz 0x1000 # EasyConnection 8/64 EISA: flags 24 iosiz 0x10000 # EasyConnection 8/64 MCA: flags 25 iosiz 0x1000 # ONboard ISA: flags 4 iosiz 0x10000 # ONboard EISA: flags 7 iosiz 0x10000 # ONboard MCA: flags 3 iosiz 0x10000 # Brumby: flags 2 iosiz 0x4000 # Stallion: flags 1 iosiz 0x10000 device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr # for the Sony CDU31/33A CDROM device scd0 at isa? port 0x230 bio # for the SoundBlaster 16 multicd - up to 4 devices controller matcd0 at isa? port 0x230 bio device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr device ctx0 at isa? port 0x230 iomem 0xd0000 device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr device apm0 at isa? device gp0 at isa? port 0x2c0 tty device gsc0 at isa? port "IO_GSC1" tty drq 3 device joy0 at isa? port "IO_GAME" device alog0 at isa? port 0x260 tty irq 5 vector alogintr device cy0 at isa? tty irq 10 iomem 0xd4000 iosiz 0x2000 vector cyintr device dgb0 at isa? port 0x220 iomem 0xfc0000 iosiz ? tty device dgm0 at isa? port 0x104 iomem 0xd00000 iosiz ? tty device labpc0 at isa? port 0x260 tty irq 5 vector labpcintr device rc0 at isa? port 0x220 tty irq 12 vector rcintr device rp0 at isa? port 0x280 tty # the port and irq for tw0 are fictitious device tw0 at isa? port 0x380 tty irq 11 vector twintr device si0 at isa? iomem 0xd0000 tty irq 12 device asc0 at isa? port IO_ASC1 tty drq 3 irq 10 vector ascintr device bqu0 at isa? port 0x150 device stl0 at isa? port 0x2a0 tty irq 10 vector stlintr device stli0 at isa? port 0x2a0 tty iomem 0xcc000 flags 23 iosiz 0x1000 # You are unlikely to have the hardware for loran0 device loran0 at isa? port ? tty irq 5 vector loranintr # HOT1 Xilinx 6200 card (www.vcc.com) device xrpu0 # # EISA devices: # # The EISA bus device is eisa0. It provides auto-detection and # configuration support for all devices on the EISA bus. # # The `ahb' device provides support for the Adaptec 174X adapter. # # The `ahc' device provides support for the Adaptec 274X and 284X # adapters. The 284X, although a VLB card responds to EISA probes. # # fea: DEC DEFEA EISA FDDI adapter # controller eisa0 controller ahb0 controller ahc0 device fea0 # enable tagged command queuing, which is a major performance win on # devices that support it (and controllers with enough SCB's) options AHC_TAGENABLE # enable SCB paging - See the ahc.4 man page options AHC_SCBPAGING_ENABLE # The aic7xxx driver will attempt to use memory mapped I/O for all PCI # controllers that have it configured only if this option is set. Unfortunately, # this doesn't work on some motherboards, which prevents it from being the # default. options AHC_ALLOW_MEMIO # By default, only 10 EISA slots are probed, since the slot numbers # above clash with the configuration address space of the PCI subsystem, # and the EISA probe is not very smart about this. This is sufficient # for most machines, but in particular the HP NetServer LC series comes # with an onboard AIC7770 dual-channel SCSI controller on EISA slot #11, # thus you need to bump this figure to 12 for them. options "EISA_SLOTS=12" # # PCI devices & PCI options: # # The main PCI bus device is `pci'. It provides auto-detection and # configuration support for all devices on the PCI bus, using either # configuration mode defined in the PCI specification. # # The `ahc' device provides support for the Adaptec 29/3940(U)(W) # and motherboard based AIC7870/AIC7880 adapters. # # The `ncr' device provides support for the NCR 53C810 and 53C825 # self-contained SCSI host adapters. # # The `isp' device provides support for the Qlogic ISP 1020, 1040 # nd 1040B PCI SCSI host adapters, as well as the Qlogic ISP 2100 # FC/AL Host Adapter. # # The `amd' device provides support for the Tekram DC-390 and 390T # SCSI host adapters, but is expected to work with any AMD 53c974 # PCI SCSI chip and the AMD Ethernet+SCSI Combo chip, after some # local patches were applied to the sources (that had originally # been written by Tekram and limited to work with their SCSI cards). # # The `de' device provides support for the Digital Equipment DC21040 # self-contained Ethernet adapter. # # The `fxp' device provides support for the Intel EtherExpress Pro/100B # PCI Fast Ethernet adapters. # # The 'tl' device provides support for the Texas Instruments TNETE100 # series 'ThunderLAN' cards and integrated ethernet controllers. This # includes several Compaq Netelligent 10/100 cards and the built-in # ethernet controllers in several Compaq Prosignia, Proliant and # Deskpro systems. It also supports several Olicom 10Mbps and 10/100 # boards. # # The `tx' device provides support for the SMC 9432TX cards. # # The `vx' device provides support for the 3Com 3C590 and 3C595 # early support # # The `xl' driver provides support for the 3Com 3c900, 3c905 and # 3c905B (Fast) Etherlink XL cards and integrated controllers. This # includes the integrated 3c905B-TX chips in certain Dell Optiplex and # Dell Precision desktop machines and the integrated 3c905-TX chips # in Dell Latitude laptop docking stations. # # The `fpa' device provides support for the Digital DEFPA PCI FDDI # adapter. pseudo-device fddi is also needed. # # The `meteor' device is a PCI video capture board. It can also have the # following options: # options METEOR_ALLOC_PAGES=xxx preallocate kernel pages for data entry # figure (ROWS*COLUMN*BYTES_PER_PIXEL*FRAME+PAGE_SIZE-1)/PAGE_SIZE # options METEOR_DEALLOC_PAGES remove all allocated pages on close(2) # options METEOR_DEALLOC_ABOVE=xxx remove all allocated pages above the # specified amount. If this value is below the allocated amount no action # taken # option METEOR_SYSTEM_DEFAULT={METEOR_PAL|METEOR_NTSC|METEOR_SECAM}, used # for initialization of fps routine when a signal is not present. # # The 'bktr' device is a PCI video capture board. It also has a TV tuner # on board. To override the tuner detection use # options OVERRIDE_TUNER=x # The current values are found in /usr/src/sys/pci/brooktree848.c # # controller pci0 controller ahc1 controller ncr0 controller isp0 controller amd0 device de0 device fxp0 device tl0 device tx0 device vx0 device xl0 device fpa0 device meteor0 device bktr0 options OVERRIDE_TUNER=NO_TUNER # # PCI options # #options PCI_QUIET #quiets PCI code on chipset settings # # PCCARD/PCMCIA # # card: slot controller # pcic: slots controller card0 device pcic0 at card? device pcic1 at card? # You may need to reset all pccards after resuming options PCIC_RESUME_RESET # reset after resume # # Laptop/Notebook options: # # See also: # apm under `Miscellaneous hardware' # above. # For older notebooks that signal a powerfail condition (external # power supply dropped, or battery state low) by issuing an NMI: options POWERFAIL_NMI # make it beep instead of panicing # # SMB bus # # System Management Bus support provided by the 'smbus' device. # # Supported devices: # smb standard io # # Supported interfaces: # iicsmb I2C to SMB bridge # controller smbus0 device smb0 at smbus? # # I2C Bus # # Philips i2c bus support is provided by the `iicbus' device. # # Supported devices: # ic i2c network interface # iic i2c standard io # # Supported interfaces: # pcf Philips PCF8584 ISA-bus controller # controller iicbus0 device ic0 at iicbus? device iic0 at iicbus? device iicsmb0 at iicbus? controller pcf0 at isa? port 0x320 net irq 5 vector pcfintr # # Parallel-Port Bus # # Parallel port bus support is provided by the `ppbus' device. # Multiple devices may be attached to the parallel port, devices # are automatically probed and attached when found. # # Supported devices: # vpo Iomega Zip Drive # Requires SCSI disk support ('scbus' and 'sd'), best # performance is achieved with ports in EPP 1.9 mode. # nlpt Parallel Printer # plip Parallel network interface # ppi General-purpose I/O ("Geek Port") # # Supported interfaces: # ppc ISA-bus parallel port interfaces. # controller ppbus0 controller vpo0 at ppbus? device nlpt0 at ppbus? device plip0 at ppbus? device ppi0 at ppbus? device pps0 at ppbus? controller ppc0 at isa? disable port ? tty irq 7 vector ppcintr # Kernel BOOTP support options BOOTP # Use BOOTP to obtain IP address/hostname options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info options "BOOTP_NFSV3" # Use NFS v3 to NFS mount root options BOOTP_COMPAT # Workaround for broken bootp daemons. options "BOOTP_WIRED_TO=fxp0" # Use interface fxp0 for BOOTP # If you want to disable loadable kernel modules (LKM), you # might want to use this option. #options NO_LKM # # Add tie-ins for a hardware watchdog. This only enable the hooks; # the user must still supply the actual driver. # options HW_WDOG # # Set the number of PV entries per process. Increasing this can # stop panics related to heavy use of shared memory. However, that can # (combined with large amounts of physical memory) cause panics at # boot time due the kernel running out of VM space. # # If you're tweaking this, you might also want to increase the sysctls # "vm.v_free_min", "vm.v_free_reserved", and "vm.v_free_target". # # The value below is the one more than the default. # options "PMAP_SHPGPERPROC=201" # More undocumented options for linting. options CLK_CALIBRATION_LOOP options "CLK_USE_I8254_CALIBRATION" options CLK_USE_TSC_CALIBRATION options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG options "DEBUG_1284" #options DISABLE_PSE options "EXT2FS" options "I586_PMC_GUPROF=0x70000" options "IBCS2" options KEY options KEY_DEBUG options LOCKF_DEBUG options LOUTB options KBD_MAXRETRY=4 options KBD_MAXWAIT=6 options KBD_RESETDELAY=201 options KBDIO_DEBUG=2 options MSGMNB=2049 options MSGMNI=41 options MSGSEG=2049 options MSGSSZ=16 options MSGTQL=41 options NBUF=512 options NETATALKDEBUG options NMBCLUSTERS=1024 options NPX_DEBUG options PANIC_REBOOT_WAIT_TIME=16 options "PCVT_24LINESDEF" options PCVT_CTRL_ALT_DEL options PCVT_EMU_MOUSE options PCVT_FREEBSD=211 options PCVT_META_ESC options PCVT_NSCREENS=9 options PCVT_PRETTYSCRNS options PCVT_SCREENSAVER options PCVT_USEKBDSEC options "PCVT_VT220KEYB" options PSM_DEBUG=1 options "SCSI_2_DEF" options SCSI_DELAY=8 # Be pessimistic about Joe SCSI device options SCSI_NCR_DEBUG options SCSI_NCR_DFLT_TAGS=4 options SCSI_NCR_MAX_SYNC=10000 options SCSI_NCR_MAX_WIDE=1 options SCSI_NCR_MYADDR=7 options SEMMAP=31 options SEMMNI=11 options SEMMNS=61 options SEMMNU=31 options SEMMSL=61 options SEMOPM=101 options SEMUME=11 options SHOW_BUSYBUFS # List buffers that prevent root unmount options SHMALL=1025 options "SHMMAX=(SHMMAXPGS*PAGE_SIZE+1)" options SHMMAXPGS=1025 options SHMMIN=2 options SHMMNI=33 options SHMSEG=9 options SI_DEBUG options SIMPLELOCK_DEBUG options SPX_HACK # The 'dpt' driver provides support for DPT controllers (http://www.dpt.com/). # These have hardware RAID-{0,1,5} support, and do multi-initiator I/O. # The DPT controllers are commonly re-licensed under other brand-names - # some controllers by Olivetti, Dec, HP, AT&T, SNI, AST, Alphatronic, NEC and # Compaq are actually DPT controllers. # # See sys/dev/dpt for debugging and other subtle options. # DPT_VERIFY_HINTR Performs some strict hardware interrupts testing. # Only use if you suspect PCI bus corruption problems # DPT_RESTRICTED_FREELIST Normally, the freelisat used by the DPT for queue # will grow to accomodate increased use. This growth # will NOT shrink. To restrict the number of queue # slots to exactly what the DPT can hold at one time, # enable this option. # DPT_MEASURE_PERFORMANCE Enables a set of (semi)invasive metrics. Various # instruments are enabled. The tools in # /usr/sbin/dpt_* assume these to be enabled. # DPT_FREELIST_IS_STACK For optimal L{1,2} CPU cache utilization, enable # this option. Otherwise, the transaction queue is # a LIFO. I cannot measure the performance gain. # DPT_HANDLE_TIMEOUTS Normally device timeouts are handled by the DPT. # If you ant the driver to handle timeouts, enable # this option. If your system is very busy, this # option will create more trouble than solve. # DPT_TIMEOUT_FACTOR Used to compute the excessive amount of time to # wait when timing out with the above option. # DPT_DEBUG_xxxx These are controllable from sys/dev/dpt/dpt.h # DPT_LOST_IRQ When enabled, will try, once per second, to catch # any interrupt that got lost. Seems to help in some # DPT-firmware/Motherboard combinations. Minimal # cost, great benefit. # DPT_RESET_HBA Make "reset" actually reset the controller # instead of fudging it. Only enable this if you # are 100% certain you need it. # DPT_SHUTDOWN_SLEEP Reset controller if a request take more than # this number of seconds. Do NOT enable this # unless you are really, really, really certain # you need it. You are advised to call Simon (the # driver author) before setting it, and NEVER, # EVER set it to less than 300s (5 minutes). controller dpt0 # DPT options options DPT_VERIFY_HINTR options DPT_RESTRICTED_FREELIST options DPT_MEASURE_PERFORMANCE options DPT_FREELIST_IS_STACK options DPT_HANDLE_TIMEOUTS options DPT_TIMEOUT_FACTOR=4 options DPT_INTR_DELAY=200 # Some motherboards need that options DPT_LOST_IRQ options DPT_RESET_HBA # Don't EVER set this without having talked to Simon Shapiro on the phone # first. options DPT_SHUTDOWN_SLEEP=500 diff --git a/sys/i386/conf/files.i386 b/sys/i386/conf/files.i386 index bccdc5bc5ce3..e2a865eaad47 100644 --- a/sys/i386/conf/files.i386 +++ b/sys/i386/conf/files.i386 @@ -1,320 +1,321 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $Id: files.i386,v 1.200 1998/08/04 21:44:09 brian Exp $ +# $Id: files.i386,v 1.201 1998/09/04 06:06:55 nsouch Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # linux_genassym optional compat_linux \ dependency "$S/i386/linux/linux_genassym.c $S/i386/linux/linux.h" \ compile-with "${CC} ${CFLAGS} ${PARAM} -UKERNEL -o $@ $<" \ no-obj no-implicit-rule \ clean "linux_genassym" # linux_assym.h optional compat_linux \ dependency "linux_genassym" \ compile-with "./linux_genassym > $@" \ no-obj no-implicit-rule before-depend \ clean "linux_assym.h" # font8x16.o optional std8x16font \ compile-with "uudecode < /usr/share/syscons/fonts/${STD8X16FONT}-8x16.fnt && file2c 'unsigned char font_16[16*256] = {' '};' < ${STD8X16FONT}-8x16 > font8x16.c && ${CC} -c ${CFLAGS} font8x16.c" \ no-implicit-rule before-depend \ clean "${STD8X16FONT}-8x16 font8x16.c" # i386/apm/apm.c optional apm device-driver i386/apm/apm_setup.s optional apm i386/eisa/dpt_eisa.c optional eisa dpt device-driver i386/eisa/3c5x9.c optional ep device-driver i386/eisa/aic7770.c optional ahc device-driver \ dependency "aic7xxx_reg.h $S/i386/eisa/aic7770.c" i386/eisa/aha1742.c optional ahb device-driver i386/eisa/bt74x.c optional bt device-driver i386/eisa/eisaconf.c optional eisa i386/eisa/if_vx_eisa.c optional vx device-driver i386/eisa/if_fea.c optional fea device-driver i386/i386/autoconf.c standard device-driver i386/i386/mountroot.c optional slice i386/i386/bios.c standard i386/i386/bioscall.s standard i386/i386/busdma_machdep.c standard i386/i386/cons.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb i386/i386/exception.s standard i386/i386/globals.s standard i386/i386/i386-gdbstub.c optional ddb i386/i386/identcpu.c standard i386/i386/in_cksum.c optional inet i386/i386/initcpu.c standard # locore.s needs to be handled in Makefile to put it first. Otherwise it's # now normal. # i386/i386/locore.s standard i386/i386/machdep.c standard i386/i386/math_emulate.c optional math_emulate i386/i386/mem.c standard i386/i386/mp_machdep.c optional smp i386/i386/mpapic.c optional smp i386/i386/mpboot.s optional smp i386/i386/mplock.s optional smp i386/i386/perfmon.c optional perfmon profiling-routine i386/i386/perfmon.c optional perfmon i386/i386/pmap.c standard i386/i386/procfs_machdep.c standard i386/i386/simplelock.s optional smp i386/i386/support.s standard i386/i386/swtch.s standard i386/i386/sys_machdep.c standard i386/i386/trap.c standard i386/i386/userconfig.c optional userconfig i386/i386/vm_machdep.c standard i386/i386/vm86.c optional vm86 i386/ibcs2/ibcs2_fcntl.c optional ibcs2 i386/ibcs2/ibcs2_stat.c optional ibcs2 i386/ibcs2/ibcs2_ipc.c optional ibcs2 i386/ibcs2/ibcs2_msg.c optional ibcs2 i386/ibcs2/ibcs2_misc.c optional ibcs2 i386/ibcs2/ibcs2_other.c optional ibcs2 i386/ibcs2/ibcs2_signal.c optional ibcs2 i386/ibcs2/ibcs2_ioctl.c optional ibcs2 i386/ibcs2/ibcs2_socksys.c optional ibcs2 i386/ibcs2/ibcs2_sysi86.c optional ibcs2 i386/ibcs2/ibcs2_util.c optional ibcs2 i386/ibcs2/ibcs2_isc.c optional ibcs2 i386/ibcs2/ibcs2_isc_sysent.c optional ibcs2 i386/ibcs2/ibcs2_xenix.c optional ibcs2 i386/ibcs2/ibcs2_xenix_sysent.c optional ibcs2 i386/ibcs2/ibcs2_errno.c optional ibcs2 i386/ibcs2/ibcs2_sysent.c optional ibcs2 i386/ibcs2/ibcs2_sysvec.c optional ibcs2 i386/ibcs2/imgact_coff.c optional ibcs2 i386/isa/aha1542.c optional aha device-driver i386/isa/aic6360.c optional aic device-driver i386/isa/alog.c optional alog device-driver i386/isa/b004.c optional bqu device-driver i386/isa/bt5xx-445.c optional bt device-driver i386/isa/clock.c standard i386/isa/cronyx.c optional cx device-driver i386/isa/ctx.c optional ctx device-driver i386/isa/cx.c optional cx device-driver i386/isa/cy.c optional cy device-driver i386/isa/diskslice_machdep.c standard i386/isa/elink.c optional ep device-driver i386/isa/elink.c optional ie device-driver i386/isa/fd.c optional fd device-driver i386/isa/ft.c optional ft device-driver i386/isa/gpib.c optional gp device-driver i386/isa/asc.c optional asc device-driver i386/isa/gsc.c optional gsc device-driver i386/isa/if_ar.c optional ar device-driver i386/isa/if_cs.c optional cs device-driver i386/isa/if_cx.c optional cx device-driver i386/isa/if_ed.c optional ed device-driver i386/isa/if_eg.c optional eg device-driver i386/isa/if_el.c optional el device-driver i386/isa/if_ep.c optional ep device-driver i386/isa/if_ex.c optional ex device-driver i386/isa/if_fe.c optional fe device-driver i386/isa/if_ie.c optional ie device-driver i386/isa/if_le.c optional le device-driver i386/isa/if_lnc.c optional lnc device-driver i386/isa/if_sr.c optional sr device-driver i386/isa/if_wl.c optional wl device-driver i386/isa/if_ze.c optional ze device-driver i386/isa/if_zp.c optional zp device-driver i386/isa/ipl_funcs.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} $<" i386/isa/intr_machdep.c standard i386/isa/isa.c optional isa device-driver i386/isa/istallion.c optional stli device-driver i386/isa/joy.c optional joy device-driver i386/isa/kbdio.c optional psm device-driver i386/isa/kbdio.c optional sc device-driver i386/isa/kbdio.c optional vt device-driver i386/isa/loran.c optional loran device-driver i386/isa/lpt.c optional lpt device-driver i386/isa/labpc.c optional labpc device-driver i386/isa/mcd.c optional mcd device-driver i386/isa/mse.c optional mse device-driver i386/isa/ncr5380.c optional nca device-driver i386/isa/npx.c mandatory npx device-driver i386/isa/pcaudio.c optional pca device-driver i386/isa/matcd/matcd.c optional matcd device-driver i386/isa/pcibus.c optional pci device-driver i386/isa/pcicx.c optional ze device-driver i386/isa/pcicx.c optional zp device-driver i386/isa/pcvt/pcvt_drv.c optional vt device-driver i386/isa/pcvt/pcvt_ext.c optional vt device-driver i386/isa/pcvt/pcvt_kbd.c optional vt device-driver i386/isa/pcvt/pcvt_out.c optional vt device-driver i386/isa/pcvt/pcvt_sup.c optional vt device-driver i386/isa/pcvt/pcvt_vtf.c optional vt device-driver i386/isa/pnp.c optional pnp device-driver i386/isa/prof_machdep.c optional profiling-routine i386/isa/ppc.c optional ppc device-driver i386/isa/pcf.c optional pcf device-driver i386/isa/psm.c optional psm device-driver i386/isa/random_machdep.c standard i386/isa/rc.c optional rc device-driver i386/isa/rp.c optional rp device-driver i386/isa/scd.c optional scd device-driver i386/isa/seagate.c optional sea device-driver i386/isa/si.c optional si device-driver i386/isa/si2_z280.c optional si device-driver i386/isa/si3_t225.c optional si device-driver i386/isa/sio.c optional sio device-driver i386/isa/snd/sound.c optional pcm device-driver i386/isa/snd/dmabuf.c optional pcm device-driver i386/isa/snd/ad1848.c optional pcm device-driver i386/isa/snd/sb_dsp.c optional pcm device-driver i386/isa/snd/clones.c optional pcm device-driver i386/isa/sound/dev_table.c optional snd device-driver i386/isa/sound/soundcard.c optional snd device-driver i386/isa/sound/sound_switch.c optional snd device-driver i386/isa/sound/audio.c optional snd device-driver i386/isa/sound/dmabuf.c optional snd device-driver i386/isa/sound/sys_timer.c optional snd device-driver i386/isa/sound/sequencer.c optional snd device-driver i386/isa/sound/patmgr.c optional snd device-driver i386/isa/sound/adlib_card.c optional opl device-driver i386/isa/sound/opl3.c optional opl device-driver i386/isa/sound/gus_card.c optional gus device-driver i386/isa/sound/gus_midi.c optional gus device-driver i386/isa/sound/gus_vol.c optional gus device-driver i386/isa/sound/gus_wave.c optional gus device-driver i386/isa/sound/ics2101.c optional gus device-driver i386/isa/sound/sound_timer.c optional gus device-driver i386/isa/sound/sound_timer.c optional css device-driver i386/isa/sound/sound_timer.c optional mss device-driver i386/isa/sound/midi_synth.c optional gus device-driver i386/isa/sound/midibuf.c optional gus device-driver i386/isa/sound/ad1848.c optional gusxvi device-driver i386/isa/sound/ad1848.c optional gus device-driver i386/isa/sound/ad1848.c optional mss device-driver i386/isa/sound/ad1848.c optional css device-driver i386/isa/sound/sound_timer.c optional mss device-driver i386/isa/sound/midi_synth.c optional mss device-driver i386/isa/sound/midibuf.c optional mss device-driver i386/isa/sound/mpu401.c optional mpu device-driver i386/isa/sound/midi_synth.c optional mpu device-driver i386/isa/sound/midibuf.c optional mpu device-driver i386/isa/sound/pas2_card.c optional pas device-driver i386/isa/sound/pas2_midi.c optional pas device-driver i386/isa/sound/pas2_mixer.c optional pas device-driver i386/isa/sound/pas2_pcm.c optional pas device-driver i386/isa/sound/midi_synth.c optional pas device-driver i386/isa/sound/midibuf.c optional pas device-driver i386/isa/sound/sb_card.c optional sb device-driver i386/isa/sound/sb_dsp.c optional sb device-driver i386/isa/sound/sb_midi.c optional sb device-driver i386/isa/sound/sb_mixer.c optional sb device-driver i386/isa/sound/midi_synth.c optional sb device-driver i386/isa/sound/midibuf.c optional sb device-driver i386/isa/sound/sb16_dsp.c optional sbxvi device-driver i386/isa/sound/sb16_midi.c optional sbmidi device-driver i386/isa/sound/uart6850.c optional uart device-driver i386/isa/sound/midi_synth.c optional uart device-driver i386/isa/sound/midi_synth.c optional css device-driver i386/isa/sound/midibuf.c optional uart device-driver i386/isa/sound/midibuf.c optional css device-driver i386/isa/sound/trix.c optional trix device-driver i386/isa/sound/adlib_card.c optional trix device-driver i386/isa/sound/opl3.c optional trix device-driver i386/isa/sound/ad1848.c optional trix device-driver i386/isa/sound/sound_timer.c optional trix device-driver i386/isa/sound/sscape.c optional sscape device-driver i386/isa/sound/ad1848.c optional sscape device-driver i386/isa/sound/sound_timer.c optional sscape device-driver i386/isa/sound/mpu401.c optional sscape device-driver i386/isa/sound/midi_synth.c optional sscape device-driver i386/isa/sound/midibuf.c optional sscape device-driver i386/isa/sound/cs4232.c optional css device-driver i386/isa/spigot.c optional spigot device-driver i386/isa/spkr.c optional speaker device-driver i386/isa/stallion.c optional stl device-driver i386/isa/syscons.c optional sc device-driver i386/isa/tw.c optional tw device-driver i386/isa/ultra14f.c optional uha device-driver i386/isa/wd.c optional wdc device-driver i386/isa/wd.c optional wd device-driver i386/isa/atapi.c optional atapi device-driver +i386/isa/atapi-cd.c optional acd device-driver i386/isa/wcd.c optional wcd device-driver i386/isa/wfd.c optional wfd device-driver i386/isa/wst.c optional wst device-driver i386/isa/wd7000.c optional wds device-driver i386/isa/wt.c optional wt device-driver i386/linux/imgact_linux.c optional compat_linux i386/linux/linux_dummy.c optional compat_linux i386/linux/linux_file.c optional compat_linux i386/linux/linux_ioctl.c optional compat_linux i386/linux/linux_ipc.c optional compat_linux i386/linux/linux_locore.s optional compat_linux \ dependency "linux_assym.h" i386/linux/linux_misc.c optional compat_linux i386/linux/linux_signal.c optional compat_linux i386/linux/linux_socket.c optional compat_linux i386/linux/linux_stats.c optional compat_linux i386/linux/linux_sysent.c optional compat_linux i386/linux/linux_sysvec.c optional compat_linux i386/linux/linux_util.c optional compat_linux i386/scsi/93cx6.c optional ahc device-driver i386/scsi/aic7xxx.c optional ahc device-driver \ dependency "aic7xxx_{reg,seq}.h" i386/scsi/bt.c optional bt device-driver libkern/bcd.c standard libkern/divdi3.c standard libkern/inet_ntoa.c standard libkern/index.c standard libkern/mcount.c optional profiling-routine libkern/moddi3.c standard libkern/qdivrem.c standard libkern/qsort.c standard libkern/random.c standard libkern/scanc.c standard libkern/skpc.c standard libkern/strcat.c standard libkern/strcmp.c standard libkern/strcpy.c standard libkern/strlen.c standard libkern/strncmp.c standard libkern/strncpy.c standard libkern/udivdi3.c standard libkern/umoddi3.c standard gnu/i386/fpemul/div_small.s optional gpl_math_emulate gnu/i386/fpemul/errors.c optional gpl_math_emulate gnu/i386/fpemul/fpu_arith.c optional gpl_math_emulate gnu/i386/fpemul/fpu_aux.c optional gpl_math_emulate gnu/i386/fpemul/fpu_entry.c optional gpl_math_emulate gnu/i386/fpemul/fpu_etc.c optional gpl_math_emulate gnu/i386/fpemul/fpu_trig.c optional gpl_math_emulate gnu/i386/fpemul/get_address.c optional gpl_math_emulate gnu/i386/fpemul/load_store.c optional gpl_math_emulate gnu/i386/fpemul/poly_2xm1.c optional gpl_math_emulate gnu/i386/fpemul/poly_atan.c optional gpl_math_emulate gnu/i386/fpemul/poly_div.s optional gpl_math_emulate gnu/i386/fpemul/poly_l2.c optional gpl_math_emulate gnu/i386/fpemul/poly_mul64.s optional gpl_math_emulate gnu/i386/fpemul/poly_sin.c optional gpl_math_emulate gnu/i386/fpemul/poly_tan.c optional gpl_math_emulate gnu/i386/fpemul/polynomial.s optional gpl_math_emulate gnu/i386/fpemul/reg_add_sub.c optional gpl_math_emulate gnu/i386/fpemul/reg_compare.c optional gpl_math_emulate gnu/i386/fpemul/reg_constant.c optional gpl_math_emulate gnu/i386/fpemul/reg_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_ld_str.c optional gpl_math_emulate gnu/i386/fpemul/reg_mul.c optional gpl_math_emulate gnu/i386/fpemul/reg_norm.s optional gpl_math_emulate gnu/i386/fpemul/reg_round.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_add.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_mul.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_sub.s optional gpl_math_emulate gnu/i386/fpemul/wm_shrx.s optional gpl_math_emulate gnu/i386/fpemul/wm_sqrt.s optional gpl_math_emulate gnu/i386/isa/dgb.c optional dgb device-driver gnu/i386/isa/dgm.c optional dgm device-driver gnu/i386/isa/sound/awe_wave.c optional awe device-driver pci/ide_pci.c optional wd device-driver diff --git a/sys/i386/isa/atapi-cd.c b/sys/i386/isa/atapi-cd.c new file mode 100644 index 000000000000..46fa888a58cb --- /dev/null +++ b/sys/i386/isa/atapi-cd.c @@ -0,0 +1,1588 @@ +/*- + * Copyright (c) 1998 Søren Schmidt + * All rights reserved. + * + * 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, + * without modification, immediately at the beginning of the file. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. + * + * $Id: atapi-cd.c,v 1.2 1998/09/02 08:47:31 sos Exp sos $ + */ + +#include "wdc.h" +#include "acd.h" +#include "opt_atapi.h" +#include "opt_devfs.h" + +#if NACD > 0 && NWDC > 0 && defined(ATAPI) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef DEVFS +#include +#endif +#include +#include + +static d_open_t acdopen; +static d_close_t acdclose; +static d_write_t acdwrite; +static d_read_t acdread; +static d_ioctl_t acdioctl; +static d_strategy_t acdstrategy; + +#define CDEV_MAJOR 69 +#define BDEV_MAJOR 19 +static struct cdevsw acd_cdevsw = { + acdopen, acdclose, acdread, acdwrite, + acdioctl, nostop, nullreset, nodevtotty, + seltrue, nommap, acdstrategy, "acd", + NULL, -1, nodump, nopsize, + D_DISK, 0, -1 +}; + +#define NUNIT 16 /* Max # of devices */ + +#define F_BOPEN 0x0001 /* The block device is opened */ +#define F_MEDIA_CHANGED 0x0002 /* The media have changed since open */ +#define F_DEBUG 0x0004 /* Print debug info */ +#define F_LOCKED 0x0008 /* This unit is locked (or should be) */ +#define F_TRACK_PREP 0x0010 /* Track should be prep'ed */ +#define F_TRACK_PREPED 0x0020 /* Track has been prep'ed */ +#define F_DISK_PREPED 0x0040 /* Disk has been prep'ed */ +#define F_WRITTEN 0x0080 /* The medium has been written to */ + +static struct acd *acdtab[NUNIT]; +static int acdnlun = 0; /* Number of configured drives */ +static u_int next_writeable_lba = 0; + +#ifndef ATAPI_STATIC +static +#endif +int acdattach(struct atapi *, int, struct atapi_params *, int); +static struct acd *acd_init_lun(struct atapi *, int, struct atapi_params *,int); +static void acd_start(struct acd *); +static void acd_done(struct acd *, struct buf *, int, struct atapires); +static int acd_read_toc(struct acd *); +static int acd_request_wait(struct acd *, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, char *, int); +static void acd_describe(struct acd *); +static int acd_open(dev_t, int, int); +static int acd_setchan(struct acd *, u_char, u_char, u_char, u_char); +static int acd_eject(struct acd *, int); +static void acd_select_slot(struct acd *); +static int acd_rezero_unit(struct acd *); +static int acd_open_disk(struct acd *, int); +static int acd_open_track(struct acd *, struct wormio_prepare_track *); +static int acd_close_track(struct acd *); +static int acd_close_disk(struct acd *); +static int acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info); +static int acd_blank_disk(struct acd *); +static void atapi_dump(int ctrlr, int lun, char *label, void *data, int len); +static void atapi_error(struct atapi *ata, int unit, struct atapires result); + +struct acd * +acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun) +{ + struct acd *ptr; + + if (!(ptr = malloc(sizeof(struct acd), M_TEMP, M_NOWAIT))) + return NULL; + bzero(ptr, sizeof(struct acd)); + bufq_init(&ptr->buf_queue); + ptr->ata = ata; + ptr->unit = unit; + ptr->lun = lun; + ptr->param = ap; + ptr->flags = F_MEDIA_CHANGED; + ptr->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + ptr->block_size = 2048; + ptr->refcnt = 0; + ptr->slot = -1; + ptr->changer_info = NULL; +#ifdef DEVFS + ptr->ra_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, 0), + DV_CHR, UID_ROOT, GID_OPERATOR, 0640, + "racd%da", lun); + ptr->rc_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART), + DV_CHR, UID_ROOT, GID_OPERATOR, 0640, + "racd%dc", lun); + ptr->a_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, 0), + DV_BLK, UID_ROOT, GID_OPERATOR, 0640, + "acd%da", lun); + ptr->c_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART), + DV_BLK, UID_ROOT, GID_OPERATOR, 0640, + "acd%dc", lun); +#endif + return ptr; +} + +#ifndef ATAPI_STATIC +static +#endif +int +acdattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug) +{ + struct acd *cdp; + struct atapires result; + struct changer *chp; + int i, count; + + if (acdnlun >= NUNIT) { + printf("acd: too many units\n"); + return 0; + } + if (!atapi_request_immediate) { + printf("acd: configuration error, ATAPI code not present!\n"); + return 0; + } + if ((cdp = acd_init_lun(ata, unit, ap, acdnlun)) == NULL) { + printf("acd: out of memory\n"); + return 0; + } + acdtab[acdnlun] = cdp; + + if (debug) { + cdp->flags |= F_DEBUG; + atapi_dump(cdp->ata->ctrlr, cdp->lun, "info", ap, sizeof(*ap)); + } + + /* Get drive capabilities, some drives needs this repeated */ + for (count = 0 ; count < 5 ; count++) { + result = atapi_request_immediate(ata, unit, + ATAPI_MODE_SENSE, + 0, ATAPI_CDROM_CAP_PAGE, + 0, 0, 0, 0, + sizeof(cdp->cap)>>8, sizeof(cdp->cap), + 0, 0, 0, 0, 0, 0, 0, + (char *)&cdp->cap, sizeof(cdp->cap)); + if (result.code == 0 || result.code == RES_UNDERRUN) + break; + } + + /* Some drives have shorter capabilities page. */ + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code == 0) { + cdp->cap.max_speed = ntohs(cdp->cap.max_speed); + cdp->cap.max_vol_levels = ntohs(cdp->cap.max_vol_levels); + cdp->cap.buf_size = ntohs(cdp->cap.buf_size); + cdp->cap.cur_speed = ntohs(cdp->cap.cur_speed); + acd_describe(cdp); + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "cap", &cdp->cap, + sizeof(cdp->cap)); + } + /* If this is a changer device, allocate the neeeded lun's */ + if (cdp->cap.mech == MST_MECH_CHANGER) { + chp = malloc(sizeof(struct changer), M_TEMP, M_NOWAIT); + if (chp == NULL) { + printf("acd: out of memory\n"); + return 0; + } + bzero(chp, sizeof(struct changer)); + result = atapi_request_immediate(ata, unit, ATAPI_MECH_STATUS, + 0, 0, 0, 0, 0, 0, 0, + sizeof(struct changer)>>8, + sizeof(struct changer), + 0, 0, 0, 0, 0, 0, + (char *)chp, sizeof(struct changer)); + if (cdp->flags & F_DEBUG) { + printf("result.code=%d curr=%02x slots=%d len=%d\n", + result.code, chp->current_slot, chp->slots, + htons(chp->table_length)); + } + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code == 0) { + chp->table_length = htons(chp->table_length); + for (i = 0; i < chp->slots && acdnlun < NUNIT; i++) { + if (i > 0) { + cdp = acd_init_lun(ata, unit, ap, acdnlun); + if (cdp == NULL) { + printf("acd: out of memory\n"); + return 0; + } + } + cdp->slot = i; + cdp->changer_info = chp; + printf("acd%d: changer slot %d %s\n", acdnlun, i, + (chp->slot[i].present ? "disk present" : "no disk")); + acdtab[acdnlun++] = cdp; + } + if (acdnlun >= NUNIT) { + printf("acd: too many units\n"); + return 0; + } + } + } else + acdnlun++; + return 1; +} + +void +acd_describe(struct acd *cdp) +{ + int comma; + char *mechanism; + + printf("acd%d: drive speed ", cdp->lun); + if (cdp->cap.cur_speed != cdp->cap.max_speed) + printf("%d - ", cdp->cap.cur_speed * 1000 / 1024); + printf("%dKb/sec", cdp->cap.max_speed * 1000 / 1024); + if (cdp->cap.buf_size) + printf(", %dKb cache\n", cdp->cap.buf_size); + + printf("acd%d: supported read types:", cdp->lun); + comma = 0; + if (cdp->cap.read_cdr) { + printf(" CD-R"); comma = 1; + } + if (cdp->cap.read_cdrw) { + printf("%s CD-RW", comma ? "," : ""); comma = 1; + } + if (cdp->cap.cd_da) { + printf("%s CD-DA", comma ? "," : ""); comma = 1; + } + if (cdp->cap.method2) + printf("%s packet track", comma ? "," : ""); + if (cdp->cap.write_cdr || cdp->cap.write_cdrw) { + printf("\nacd%d: supported write types:", cdp->lun); + comma = 0; + if (cdp->cap.write_cdr) { + printf(" CD-R" ); comma = 1; + } + if (cdp->cap.write_cdrw) { + printf("%s CD-RW", comma ? "," : ""); comma = 1; + } + if (cdp->cap.test_write) { + printf("%s test write", comma ? "," : ""); comma = 1; + } + } + if (cdp->cap.audio_play) { + printf("\nacd%d: Audio: ", cdp->lun); + if (cdp->cap.audio_play) + printf("play"); + if (cdp->cap.max_vol_levels) + printf(", %d volume levels", cdp->cap.max_vol_levels); + } + printf("\nacd%d: Mechanism: ", cdp->lun); + switch (cdp->cap.mech) { + case MST_MECH_CADDY: + mechanism = "caddy"; break; + case MST_MECH_TRAY: + mechanism = "tray"; break; + case MST_MECH_POPUP: + mechanism = "popup"; break; + case MST_MECH_CHANGER: + mechanism = "changer"; break; + case MST_MECH_CARTRIDGE: + mechanism = "cartridge"; break; + default: + mechanism = 0; break; + } + if (mechanism) + printf("%s%s", cdp->cap.eject ? "ejectable " : "", mechanism); + else if (cdp->cap.eject) + printf("ejectable"); + + if (cdp->cap.mech != MST_MECH_CHANGER) { + printf("\nacd%d: Medium: ", cdp->lun); + switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) { + case MST_CDROM: + printf("CD-ROM "); break; + case MST_CDR: + printf("CD-R "); break; + case MST_CDRW: + printf("CD-RW "); break; + case MST_DOOR_OPEN: + printf("door open"); break; + case MST_NO_DISC: + printf("no/blank disc inside"); break; + case MST_FMT_ERROR: + printf("medium format error"); break; + } + if ((cdp->cap.medium_type & MST_TYPE_MASK_HIGH) < MST_TYPE_MASK_HIGH) { + switch (cdp->cap.medium_type & MST_TYPE_MASK_LOW) { + case MST_DATA_120: + printf("120mm data disc loaded"); break; + case MST_AUDIO_120: + printf("120mm audio disc loaded"); break; + case MST_COMB_120: + printf("120mm data/audio disc loaded"); break; + case MST_PHOTO_120: + printf("120mm photo disc loaded"); break; + case MST_DATA_80: + printf("80mm data disc loaded"); break; + case MST_AUDIO_80: + printf("80mm audio disc loaded"); break; + case MST_COMB_80: + printf("80mm data/audio disc loaded"); break; + case MST_PHOTO_80: + printf("80mm photo disc loaded"); break; + case MST_FMT_NONE: + switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) { + case MST_CDROM: + printf("unknown medium"); break; + case MST_CDR: + case MST_CDRW: + printf("blank medium"); break; + } + break; + default: + printf("unknown type=0x%x", cdp->cap.medium_type); break; + } + } + } + if (cdp->cap.lock) + printf(cdp->cap.locked ? ", locked" : ", unlocked"); + if (cdp->cap.prevent) + printf(", lock protected"); + printf("\n"); +} + +static int +acdopen(dev_t dev, int flags, int fmt, struct proc *p) +{ + int lun = dkunit(dev); + struct acd *cdp; + + if (lun >= acdnlun || !atapi_request_immediate) + return ENXIO; + cdp = acdtab[lun]; + + if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) { + /* Prevent user eject */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + } + if (fmt == S_IFBLK) + cdp->flags |= F_BOPEN; + else + ++cdp->refcnt; + + if ((flags & O_NONBLOCK) == 0) { + if ((flags & FWRITE) != 0) { + /* read/write */ + if (acd_rezero_unit(cdp)) { + printf("acd%d: rezero failed\n", lun); + return EIO; + } + } else { + /* read only */ + if (acd_read_toc(cdp) < 0) { + printf("acd%d: read_toc failed\n", lun); + /* return EIO; */ + } + } + } + return 0; +} + +int +acdclose(dev_t dev, int flags, int fmt, struct proc *p) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + if (fmt == S_IFBLK) + cdp->flags &= ~F_BOPEN; + else + --cdp->refcnt; + + /* Are we the last open ?? */ + if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) { + /* Yup, do we need to close any written tracks */ + if ((flags & FWRITE) != 0) { + if ((cdp->flags & F_TRACK_PREPED) != 0) { + acd_close_track(cdp); + cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP); + } + } + /* Allow the user eject */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + cdp->flags &= ~F_LOCKED; + return 0; +} + +static int +acdread(dev_t dev, struct uio *uio, int ioflag) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + return physio(acdstrategy, NULL, dev, 1, minphys, uio); +} + +static int +acdwrite(dev_t dev, struct uio *uio, int ioflag) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + return physio(acdstrategy, NULL, dev, 0, minphys, uio); +} + +void +acdstrategy(struct buf *bp) +{ + int lun = dkunit(bp->b_dev); + struct acd *cdp = acdtab[lun]; + int x; + +#ifdef NOTYET + /* allow write only on CD-R/RW media */ /* all for now SOS */ + if (!(bp->b_flags & B_READ) && !(writeable_media)) { + bp->b_error = EROFS; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } +#endif + + if (bp->b_bcount == 0) { + bp->b_resid = 0; + biodone(bp); + return; + } + + bp->b_pblkno = bp->b_blkno; + bp->b_resid = bp->b_bcount; + + x = splbio(); + bufqdisksort(&cdp->buf_queue, bp); + acd_start(cdp); + splx(x); +} + +static void +acd_start(struct acd *cdp) +{ + struct buf *bp = bufq_first(&cdp->buf_queue); + u_long lba, blocks; + int cmd; + int count; + + if (!bp) + return; + + bufq_remove(&cdp->buf_queue, bp); + + /* Should reject all queued entries if media have changed. */ + if (cdp->flags & F_MEDIA_CHANGED) { + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } + acd_select_slot(cdp); + + if ((bp->b_flags & B_READ) == B_WRITE) { + if ((cdp->flags & F_TRACK_PREPED) == 0) { + if ((cdp->flags & F_TRACK_PREP) == 0) { + printf("acd%d: sequence error\n", cdp->lun); + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } else { + if (acd_open_track(cdp, &cdp->preptrack) != 0) { + biodone(bp); + return; + } + cdp->flags |= F_TRACK_PREPED; + } + } + } + + if (bp->b_flags & B_READ) +#ifdef NOTYET + lba = bp->b_offset / cdp->block_size; +#else + lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE); +#endif + else + lba = next_writeable_lba + (bp->b_offset / cdp->block_size); + blocks = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size; + + if ((bp->b_flags & B_READ) == B_WRITE) { + cmd = ATAPI_WRITE_BIG; + count = -bp->b_bcount; + } else { + cmd = ATAPI_READ_BIG; + count = bp->b_bcount; + } + + atapi_request_callback(cdp->ata, cdp->unit, cmd, 0, + lba>>24, lba>>16, lba>>8, lba, 0, + blocks>>8, blocks, 0, 0, 0, 0, 0, 0, 0, + (u_char *)bp->b_data, count, + (atapi_callback_t *)acd_done, cdp, bp); +} + +static void +acd_done(struct acd *cdp, struct buf *bp, int resid, struct atapires result) +{ + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + } else { + bp->b_resid = resid; + if ((bp->b_flags & B_READ) == B_WRITE) + cdp->flags |= F_WRITTEN; + } + biodone(bp); + acd_start(cdp); +} + +static int +acd_request_wait(struct acd *cdp, u_char cmd, u_char a1, u_char a2, + u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, + u_char a9, char *addr, int count) +{ + struct atapires result; + + result = atapi_request_wait(cdp->ata, cdp->unit, cmd, a1, a2, a3, a4, a5, + a6, a7, a8, a9, 0, 0, 0, 0, 0, 0, addr, count); + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + return 0; +} + +static __inline void +lba2msf(int lba, u_char *m, u_char *s, u_char *f) +{ + lba += 150; + lba &= 0xffffff; + *m = lba / (60 * 75); + lba %= (60 * 75); + *s = lba / 75; + *f = lba % 75; +} + +static __inline int +msf2lba(u_char m, u_char s, u_char f) +{ + return (m * 60 + s) * 75 + f - 150; +} + +int +acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +{ + int lun = dkunit(dev); + struct acd *cdp = acdtab[lun]; + int error = 0; + + if (cdp->flags & F_MEDIA_CHANGED) + switch (cmd) { + case CDIOCRESET: + break; + default: + acd_read_toc(cdp); + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + break; + } + switch (cmd) { +/* + case CDIOCRESUME: + bzero(cdb); + cdb->cmd = ATAPI_PAUSE; + cdb->b8 = 0x01; + return atapi_cmd_wait(cdp->ata, cdp->unit, cdb, 0, 0, timout, 0); +*/ + case CDIOCRESUME: + return acd_request_wait(cdp, ATAPI_PAUSE, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0); + + case CDIOCPAUSE: + return acd_request_wait(cdp, ATAPI_PAUSE, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCSTART: + return acd_request_wait(cdp, ATAPI_START_STOP, + 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCSTOP: + return acd_request_wait(cdp, ATAPI_START_STOP, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCALLOW: + acd_select_slot(cdp); + cdp->flags &= ~F_LOCKED; + return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCPREVENT: + acd_select_slot(cdp); + cdp->flags |= F_LOCKED; + return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCRESET: + if (p->p_cred->pc_ucred->cr_uid) + return EPERM; + return acd_request_wait(cdp, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCEJECT: + if ((cdp->flags & F_BOPEN) && cdp->refcnt) + return EBUSY; + return acd_eject(cdp, 0); + + case CDIOCCLOSE: + if ((cdp->flags & F_BOPEN) && cdp->refcnt) + return 0; + return acd_eject(cdp, 1); + + case CDIOREADTOCHEADER: + if (!cdp->toc.hdr.ending_track) + return EIO; + bcopy(&cdp->toc.hdr, addr, sizeof(cdp->toc.hdr)); + break; + + case CDIOREADTOCENTRYS: + { + struct ioc_read_toc_entry *te = (struct ioc_read_toc_entry *)addr; + struct toc *toc = &cdp->toc; + struct toc buf; + u_long len; + u_char starting_track = te->starting_track; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (te->data_len < sizeof(toc->tab[0]) || + (te->data_len % sizeof(toc->tab[0])) != 0 || + te->address_format != CD_MSF_FORMAT && + te->address_format != CD_LBA_FORMAT) + return EINVAL; + + if (!starting_track) + starting_track = toc->hdr.starting_track; + else if (starting_track == 170) + starting_track = toc->hdr.ending_track + 1; + else if (starting_track < toc->hdr.starting_track || + starting_track > toc->hdr.ending_track + 1) + return EINVAL; + + len = ((toc->hdr.ending_track + 1 - starting_track) + 1) * + sizeof(toc->tab[0]); + if (te->data_len < len) + len = te->data_len; + if (len > sizeof(toc->tab)) + return EINVAL; + + if (te->address_format == CD_MSF_FORMAT) { + struct cd_toc_entry *entry; + + buf = cdp->toc; + toc = &buf; + entry = toc->tab + (toc->hdr.ending_track + 1 - + toc->hdr.starting_track) + 1; + while (--entry >= toc->tab) + lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute, + &entry->addr.msf.second, &entry->addr.msf.frame); + } + return copyout(toc->tab + starting_track - toc->hdr.starting_track, + te->data, len); + } + + case CDIOREADTOCENTRY: + { + struct ioc_read_toc_single_entry *te = + (struct ioc_read_toc_single_entry *)addr; + struct toc *toc = &cdp->toc; + struct toc buf; + u_char track = te->track; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (te->address_format != CD_MSF_FORMAT && + te->address_format != CD_LBA_FORMAT) + return EINVAL; + + if (!track) + track = toc->hdr.starting_track; + else if (track == 170) + track = toc->hdr.ending_track + 1; + else if (track < toc->hdr.starting_track || + track > toc->hdr.ending_track + 1) + return EINVAL; + + if (te->address_format == CD_MSF_FORMAT) { + struct cd_toc_entry *entry; + + buf = cdp->toc; + toc = &buf; + entry = toc->tab + (track - toc->hdr.starting_track); + lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute, + &entry->addr.msf.second, &entry->addr.msf.frame); + } + bcopy(toc->tab + track - toc->hdr.starting_track, + &te->entry, sizeof(struct cd_toc_entry)); + } + break; + + case CDIOCREADSUBCHANNEL: + { + struct ioc_read_subchannel *args = + (struct ioc_read_subchannel *)addr; + struct cd_sub_channel_info data; + u_long len = args->data_len; + int abslba, rellba; + + if (len > sizeof(data) || + len < sizeof(struct cd_sub_channel_header)) + return EINVAL; + + if (acd_request_wait(cdp, ATAPI_READ_SUBCHANNEL, + 0, 0x40, 1, 0, 0, 0, + sizeof(cdp->subchan)>>8, sizeof(cdp->subchan), + 0, + (char *)&cdp->subchan, + sizeof(cdp->subchan)) != 0) + return EIO; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "subchan", &cdp->subchan, + sizeof(cdp->subchan)); + + abslba = cdp->subchan.abslba; + rellba = cdp->subchan.rellba; + if (args->address_format == CD_MSF_FORMAT) { + lba2msf(ntohl(abslba), + &data.what.position.absaddr.msf.minute, + &data.what.position.absaddr.msf.second, + &data.what.position.absaddr.msf.frame); + lba2msf(ntohl(rellba), + &data.what.position.reladdr.msf.minute, + &data.what.position.reladdr.msf.second, + &data.what.position.reladdr.msf.frame); + } else { + data.what.position.absaddr.lba = abslba; + data.what.position.reladdr.lba = rellba; + } + data.header.audio_status = cdp->subchan.audio_status; + data.what.position.control = cdp->subchan.control & 0xf; + data.what.position.addr_type = cdp->subchan.control >> 4; + data.what.position.track_number = cdp->subchan.track; + data.what.position.index_number = cdp->subchan.indx; + return copyout(&data, args->data, len); + } + + case CDIOCPLAYMSF: + { + struct ioc_play_msf *args = (struct ioc_play_msf *)addr; + + return acd_request_wait(cdp, ATAPI_PLAY_MSF, 0, 0, + args->start_m, args->start_s, args->start_f, + args->end_m, args->end_s, args->end_f, + 0, 0, 0); + } + + case CDIOCPLAYBLOCKS: + { + struct ioc_play_blocks *args = (struct ioc_play_blocks *)addr; + + return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0, + args->blk>>24 & 0xff, args->blk>>16 & 0xff, + args->blk>>8 & 0xff, args->blk & 0xff, + args->len>>24 & 0xff, args->len>>16 & 0xff, + args->len>>8 & 0xff, args->len & 0xff, + 0, 0); + } + + case CDIOCPLAYTRACKS: + { + struct ioc_play_track *args = (struct ioc_play_track *)addr; + u_long start, len; + int t1, t2; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (args->end_track < cdp->toc.hdr.ending_track + 1) + ++args->end_track; + if (args->end_track > cdp->toc.hdr.ending_track + 1) + args->end_track = cdp->toc.hdr.ending_track + 1; + t1 = args->start_track - cdp->toc.hdr.starting_track; + t2 = args->end_track - cdp->toc.hdr.starting_track; + if (t1 < 0 || t2 < 0) + return EINVAL; + start = ntohl(cdp->toc.tab[t1].addr.lba); + len = ntohl(cdp->toc.tab[t2].addr.lba) - start; + + return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0, + start>>24 & 0xff, start>>16 & 0xff, + start>>8 & 0xff, start & 0xff, + len>>24 & 0xff, len>>16 & 0xff, + len>>8 & 0xff, len & 0xff, 0, 0); + } + + case CDIOCREADAUDIO: + { + struct ioc_read_audio* args = (struct ioc_read_audio*) addr; + int lba, frames, result = 0; + u_char *buffer, *ubuf = args->buffer; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if ((frames = args->nframes) < 0) + return EINVAL; + + if (args->address_format == CD_LBA_FORMAT) + lba = args->address.lba; + else if (args->address_format == CD_MSF_FORMAT) + lba = msf2lba(args->address.msf.minute, + args->address.msf.second, + args->address.msf.frame); + else + return EINVAL; +#ifndef CD_BUFFER_BLOCKS +#define CD_BUFFER_BLOCKS 8 +#endif + if (!(buffer = malloc(CD_BUFFER_BLOCKS * 2352, M_TEMP, M_NOWAIT))) + return ENOMEM; + + while (frames > 0) { + u_char blocks; + int size; + + blocks = (frames>CD_BUFFER_BLOCKS) ? CD_BUFFER_BLOCKS : frames; + size = blocks * 2352; + + result = acd_request_wait(cdp, ATAPI_READ_CD, 4, + lba>>24, (lba>>16)&0xff, + (lba>>8)&0xff, lba&0xff, 0, 0, + blocks, 0xf0, buffer, size); + if (result != 0) + break; + + result = copyout(buffer, ubuf, size); + if (result != 0) + break; + + ubuf += size; + frames -= blocks; + lba += blocks; + } + + free(buffer, M_TEMP); + return result; + } + + case CDIOCGETVOL: + { + struct ioc_vol *arg = (struct ioc_vol *)addr; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, + sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + arg->vol[0] = cdp->au.port[0].volume; + arg->vol[1] = cdp->au.port[1].volume; + arg->vol[2] = cdp->au.port[2].volume; + arg->vol[3] = cdp->au.port[3].volume; + } + break; + + case CDIOCSETVOL: + { + struct ioc_vol *arg = (struct ioc_vol *)addr; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, + sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, + CDROM_AUDIO_PAGE_MASK, 0, 0, 0, 0, + sizeof(cdp->aumask)>>8,sizeof(cdp->aumask), + 0, + (char *)&cdp->aumask, sizeof(cdp->aumask)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "mask", &cdp->aumask, + sizeof(cdp->aumask)); + + cdp->au.data_length = 0; + cdp->au.port[0].channels = CHANNEL_0; + cdp->au.port[1].channels = CHANNEL_1; + cdp->au.port[0].volume = arg->vol[0] & cdp->aumask.port[0].volume; + cdp->au.port[1].volume = arg->vol[1] & cdp->aumask.port[1].volume; + cdp->au.port[2].volume = arg->vol[2] & cdp->aumask.port[2].volume; + cdp->au.port[3].volume = arg->vol[3] & cdp->aumask.port[3].volume; + return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10, + 0, 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), + 0, (char *)&cdp->au, -sizeof(cdp->au)); + } + + case CDIOCSETPATCH: + { + struct ioc_patch *arg = (struct ioc_patch *)addr; + + return acd_setchan(cdp, arg->patch[0], arg->patch[1], + arg->patch[2], arg->patch[3]); + } + + case CDIOCSETMONO: + return acd_setchan(cdp, CHANNEL_0|CHANNEL_1, CHANNEL_0|CHANNEL_1, 0, 0); + + case CDIOCSETSTEREO: + return acd_setchan(cdp, CHANNEL_0, CHANNEL_1, 0, 0); + + case CDIOCSETMUTE: + return acd_setchan(cdp, 0, 0, 0, 0); + + case CDIOCSETLEFT: + return acd_setchan(cdp, CHANNEL_0, CHANNEL_0, 0, 0); + + case CDIOCSETRIGHT: + return acd_setchan(cdp, CHANNEL_1, CHANNEL_1, 0, 0); + + case CDRIOCNEXTWRITEABLEADDR: + { + struct acd_track_info track_info; + + if ((error = acd_read_track_info(cdp, 0xff, &track_info))) + break; + if (!track_info.nwa_valid) + return EINVAL; + next_writeable_lba = track_info.next_writeable_addr; + *(int*)addr = track_info.next_writeable_addr; + } + break; + + case WORMIOCPREPDISK: + { + struct wormio_prepare_disk *w = (struct wormio_prepare_disk *)addr; + + if (w->dummy != 0 && w->dummy != 1) + error = EINVAL; + else { + error = acd_open_disk(cdp, w->dummy); + if (error == 0) { + cdp->flags |= F_DISK_PREPED; + cdp->dummy = w->dummy; + cdp->speed = w->speed; + } + } + } + break; + + case WORMIOCPREPTRACK: + { + struct wormio_prepare_track *w =(struct wormio_prepare_track *)addr; + + if (w->audio != 0 && w->audio != 1) + error = EINVAL; + else if (w->audio == 0 && w->preemp) + error = EINVAL; + else if ((cdp->flags & F_DISK_PREPED) == 0) { + error = EINVAL; + printf("acd%d: sequence error (PREP_TRACK)\n", cdp->lun); + } else { + cdp->flags |= F_TRACK_PREP; + cdp->preptrack = *w; + } + } + break; + + case WORMIOCFINISHTRACK: + if ((cdp->flags & F_TRACK_PREPED) != 0) + error = acd_close_track(cdp); + cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP); + break; + + case WORMIOCFIXATION: + { + struct wormio_fixation *w = + (struct wormio_fixation *)addr; + + if ((cdp->flags & F_WRITTEN) == 0) + error = EINVAL; + else if (w->toc_type < 0 /* WORM_TOC_TYPE_AUDIO */ || + w->toc_type > 4 /* WORM_TOC_TYPE_CDI */ ) + error = EINVAL; + else if (w->onp != 0 && w->onp != 1) + error = EINVAL; + else { + /* no fixation needed if dummy write */ + if (cdp->dummy == 0) + error = acd_close_disk(cdp); + cdp->flags &= + ~(F_WRITTEN|F_DISK_PREPED|F_TRACK_PREP|F_TRACK_PREPED); + } + } + break; + + case CDRIOCBLANK: + return acd_blank_disk(cdp); + + default: + return ENOTTY; + } + return error; +} + +static int +acd_read_toc(struct acd *cdp) +{ + int ntracks, len; + struct atapires result; + + bzero(&cdp->toc, sizeof(cdp->toc)); + bzero(&cdp->info, sizeof(cdp->info)); + + acd_select_slot(cdp); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + + if (result.code == RES_ERR && + (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION) { + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + + cdp->flags &= ~F_MEDIA_CHANGED; + + len = sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry); + if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, + len>>8, len & 0xff, 0, (char *)&cdp->toc, len) != 0) { + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + ntracks = cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1; + if (ntracks <= 0 || ntracks > MAXTRK) { + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + + len = sizeof(struct ioc_toc_header) + ntracks * sizeof(struct cd_toc_entry); + if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, + len>>8, len & 0xff, 0, (char *)&cdp->toc, len) & 0xff){ + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + + cdp->toc.hdr.len = ntohs(cdp->toc.hdr.len); + + if (acd_request_wait(cdp, ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0, + (char *)&cdp->info, sizeof(cdp->info)) != 0) + bzero(&cdp->info, sizeof(cdp->info)); + + cdp->toc.tab[ntracks].control = cdp->toc.tab[ntracks - 1].control; + cdp->toc.tab[ntracks].addr_type = cdp->toc.tab[ntracks - 1].addr_type; + cdp->toc.tab[ntracks].track = 170; + cdp->toc.tab[ntracks].addr.lba = cdp->info.volsize; + + cdp->info.volsize = ntohl(cdp->info.volsize); + cdp->info.blksize = ntohl(cdp->info.blksize); + + if (cdp->info.volsize && cdp->toc.hdr.ending_track + /* && (cdp->flags & F_DEBUG) */) { + printf("acd%d: ", cdp->lun); + if (cdp->toc.tab[0].control & 4) + printf("%ldMB ", cdp->info.volsize / 512); + else + printf("%ld:%ld audio ", cdp->info.volsize / 75 / 60, + cdp->info.volsize / 75 % 60); + printf("(%ld sectors (%d bytes)), %d tracks\n", + cdp->info.volsize, cdp->info.blksize, + cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1); + } + return 0; +} + +/* + * Set up the audio channel masks. + */ +static int +acd_setchan(struct acd *cdp, u_char c0, u_char c1, u_char c2, u_char c3) +{ + int error; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + + cdp->au.data_length = 0; + cdp->au.port[0].channels = c0; + cdp->au.port[1].channels = c1; + cdp->au.port[2].channels = c2; + cdp->au.port[3].channels = c3; + return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10, + 0, 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, -sizeof(cdp->au)); +} + +static int +acd_eject(struct acd *cdp, int close) +{ + struct atapires result; + + acd_select_slot(cdp); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_START_STOP, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + if (result.code == RES_ERR && + ((result.error & AER_SKEY) == AER_SK_NOT_READY || + (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) { + int err; + + if (!close) + return 0; + err = acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 3, + 0, 0, 0, 0, 0, 0, 0); + if (err) + return err; + + acd_read_toc(cdp); + + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + return 0; + } + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + if (close) + return 0; + + tsleep((caddr_t) &lbolt, PRIBIO, "acdej1", 0); + tsleep((caddr_t) &lbolt, PRIBIO, "acdej2", 0); + + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + cdp->flags &= ~F_LOCKED; + + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + return acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0); +} + +static void +acd_select_slot(struct acd *cdp) +{ + if (cdp->slot < 0 || cdp->changer_info->current_slot == cdp->slot) + return; + + /* Unlock (might not be needed but its cheaper than asking) */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + /* Unload the current media from player */ + acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 2, + 0, 0, 0, cdp->changer_info->current_slot, 0, 0, 0); + + /* load the wanted slot */ + acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 3, + 0, 0, 0, cdp->slot, 0, 0, 0); + + cdp->changer_info->current_slot = cdp->slot; + + /* Lock the media if needed */ + if (cdp->flags & F_LOCKED) { + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0); + } +} + +static int +acd_rezero_unit(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_REZERO_UNIT, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0); +} + +static int +acd_open_disk(struct acd *cdp, int test) +{ + next_writeable_lba = 0; + return 0; +} + +static int +acd_close_disk(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_CLOSE_TRACK, 0x00, + 0x02, 0, 0, 0/*track*/, 0, 0, 0, 0, 0, 0); +} + +static int +acd_open_track(struct acd *cdp, struct wormio_prepare_track *ptp) +{ + struct write_param param; + struct atapires result; + int error; + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SENSE, + 0, 0x05, 0, 0, 0, 0, + sizeof(param)>>8, sizeof(param), + 0, 0, 0, 0, 0, 0, 0, + (char *)¶m, sizeof(param)); + + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", ¶m, sizeof(param)); + + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + param.page_code = 0x05; + param.page_length = 0x32; + param.test_write = cdp->dummy ? 1 : 0; + param.write_type = CDR_WTYPE_TRACK; + + switch (ptp->audio) { +/* switch (data_type) { */ + + case 0: +/* case CDR_DATA: */ + cdp->block_size = 2048; + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_ROM_MODE1; + param.session_format = CDR_SESS_CDROM; + break; + + default: +/* case CDR_AUDIO: */ + cdp->block_size = 2352; + if (ptp->preemp) + param.track_mode = CDR_TMODE_AUDIO; + else + param.track_mode = 0; + param.data_block_type = CDR_DB_RAW; + param.session_format = CDR_SESS_CDROM; + break; + +/* + case CDR_MODE2: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_ROM_MODE2; + param.session_format = CDR_SESS_CDROM; + break; + + case CDR_XA1: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE1; + param.session_format = CDR_SESS_CDROM_XA; + break; + + case CDR_XA2: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE2_F1; + param.session_format = CDR_SESS_CDROM_XA; + break; + + case CDR_CDI: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE2_F1; + param.session_format = CDR_SESS_CDI; + break; +*/ + } + + param.multi_session = CDR_MSES_NONE; + param.fp = 0; + param.packet_size = 0; + + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", ¶m, sizeof(param)); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SELECT, + 0x10, 0, 0, 0, 0, 0, + sizeof(param)>>8, sizeof(param), + 0, 0, 0, 0, 0, 0, 0, + (char *)¶m, -sizeof(param)); + + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + return 0; +} + +static int +acd_close_track(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_SYNCHRONIZE_CACHE, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +static int +acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info) +{ + int error; + + error = acd_request_wait(cdp, ATAPI_READ_TRACK_INFO, 0x01, + lba>>24, (lba>>16)&0xff, + (lba>>8)&0xff, lba&0xff, + 0, + sizeof(*info)>>8, sizeof(*info), 0, + (char *)info, sizeof(*info)); + if (error) + return error; + info->track_start_addr = ntohl(info->track_start_addr); + info->next_writeable_addr = ntohl(info->next_writeable_addr); + info->free_blocks = ntohl(info->free_blocks); + info->fixed_packet_size = ntohl(info->fixed_packet_size); + info->track_length = ntohl(info->track_length); + return 0; +} + +static int +acd_blank_disk(struct acd *cdp) +{ + int error; + + error = acd_request_wait(cdp, 0xa1, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + return error; +} + +static void +atapi_error(struct atapi *ata, int unit, struct atapires result) +{ + if (result.code != RES_ERR) { + printf("atapi%d:%d: ERROR %d, status=%b, error=%b\n", + ata->ctrlr, unit, result.code, result.status, + ARS_BITS, result.error, AER_BITS); + return; + } + switch (result.error & AER_SKEY) { + case AER_SK_NOT_READY: + if (ata->debug) + printf("atapi%d:%d: not ready\n", ata->ctrlr, unit); + break; + + case AER_SK_BLANK_CHECK: + if (ata->debug) + printf("atapi%d:%d: blank check\n", ata->ctrlr, unit); + break; + + case AER_SK_MEDIUM_ERROR: + if (ata->debug) + printf("atapi%d:%d: medium error\n", ata->ctrlr, unit); + break; + + case AER_SK_HARDWARE_ERROR: + if (ata->debug) + printf("atapi%d:%d: hardware error\n", ata->ctrlr, unit); + break; + + case AER_SK_ILLEGAL_REQUEST: + if (ata->debug) + printf("atapi%d:%d: illegal request\n", ata->ctrlr, unit); + break; + + case AER_SK_UNIT_ATTENTION: + if (ata->debug) + printf("atapi%d:%d: unit attention\n", ata->ctrlr, unit); + break; + + case AER_SK_DATA_PROTECT: + if (ata->debug) + printf("atapi%d:%d: reading protected data\n", ata->ctrlr, unit); + break; + + case AER_SK_ABORTED_COMMAND: + if (ata->debug) + printf("atapi%d:%d: command aborted\n", ata->ctrlr, unit); + break; + + case AER_SK_MISCOMPARE: + if (ata->debug) + printf("atapi%d:%d: data don't match medium\n", ata->ctrlr, unit); + break; + + default: + if (ata->debug) + printf("atapi%d:%d: unknown error, status=%b, error=%b\n", + ata->ctrlr, unit, result.status, ARS_BITS, + result.error, AER_BITS); + } +} + +static void +atapi_dump(int ctrlr, int lun, char *label, void *data, int len) +{ + u_char *p = data; + + printf ("atapi%d%d: %s %x", ctrlr, lun, label, *p++); + while (--len > 0) printf ("-%x", *p++); + printf ("\n"); +} + +#ifdef ACD_MODULE +#include +#include +#include + +MOD_DEV(acd, LM_DT_BLOCK, BDEV_MAJOR, &acd_bdevsw); +MOD_DEV(racd, LM_DT_CHAR, CDEV_MAJOR, &acd_cdevsw); + +int +acd_load(struct lkm_table *lkmtp, int cmd) +{ + struct atapi *ata; + int n, u; + + if (!atapi_start) + return EPROTONOSUPPORT; + n = 0; + for (ata = atapi_tab; ata < atapi_tab + 2; ++ata) + if (ata->port) + for (u = 0; u < 2; ++u) + if (ata->params[u] && !ata->attached[u] && + acdattach(ata, u, ata->params[u], + ata->debug) >= 0) { + ata->attached[u] = 1; + ++n; + } + if (!n) + return ENXIO; + return 0; +} + +int +acd_unload(struct lkm_table *lkmtp, int cmd) +{ + struct acd **cdpp; + + for (cdpp = acdtab; cdpp < acdtab + acdnlun; ++cdpp) + if (((*cdpp)->flags & F_BOPEN) || (*cdpp)->refcnt) + return EBUSY; + for (cdpp = acdtab; cdpp < acdtab + acdnlun; ++t) { + (*cdpp)->ata->attached[(*cdpp)->unit] = 0; + free(*cdpp, M_TEMP); + } + acdnlun = 0; + bzero(acdtab, sizeof(acdtab)); + return 0; +} + +int +acd_mod(struct lkm_table *lkmtp, int cmd, int ver) +{ + int err = 0; + + if (ver != LKM_VERSION) + return EINVAL; + + if (cmd == LKM_E_LOAD) + err = acd_load(lkmtp, cmd); + else if (cmd == LKM_E_UNLOAD) + err = acd_unload(lkmtp, cmd); + if (err) + return err; + + lkmtp->private.lkm_dev = &MOD_PRIVATE(racd); + err = lkmdispatch(lkmtp, cmd); + if (err) + return err; + + lkmtp->private.lkm_dev = &MOD_PRIVATE(acd); + return lkmdispatch(lkmtp, cmd); +} + +#endif /* ACD_MODULE */ + +static acd_devsw_installed = 0; + +static void +acd_drvinit(void *unused) +{ + dev_t dev; + + if (!acd_devsw_installed) { + cdevsw_add_generic(BDEV_MAJOR, CDEV_MAJOR, &acd_cdevsw); + acd_devsw_installed = 1; + } +} + +SYSINIT(acddev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE + CDEV_MAJOR, acd_drvinit, NULL) +#endif /* NACD && NWDC && ATAPI */ diff --git a/sys/i386/isa/atapi-cd.h b/sys/i386/isa/atapi-cd.h new file mode 100644 index 000000000000..29da547dc56f --- /dev/null +++ b/sys/i386/isa/atapi-cd.h @@ -0,0 +1,357 @@ +/*- + * Copyright (c) 1998 Søren Schmidt + * All rights reserved. + * + * 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, + * without modification, immediately at the beginning of the file. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. + * + * $Id: atapi-cd.h,v 1.2 1998/09/02 08:47:31 sos Exp sos $ + */ + +/* + * CDROM Table Of Contents + */ +#define MAXTRK 99 +struct toc { + struct ioc_toc_header hdr; + struct cd_toc_entry tab[MAXTRK + 1]; +}; + +/* + * CDROM Audio Control Parameters Page + */ +struct audiopage { + /* Mode Page data header */ + u_short data_length; + u_char medium_type; + u_char dev_spec; + u_char unused[2]; + u_short blk_desc_len; + + /* Audio control page */ + u_char page_code; +#define CDROM_AUDIO_PAGE 0x0e +#define CDROM_AUDIO_PAGE_MASK 0x4e + + u_char param_len; + u_char flags; +#define CD_PA_SOTC 0x02 +#define CD_PA_IMMED 0x04 + + u_char reserved3; + u_char reserved4; + u_char reserved5; + u_short lb_per_sec; + struct port_control { + u_char channels:4; +#define CHANNEL_0 1 +#define CHANNEL_1 2 +#define CHANNEL_2 4 +#define CHANNEL_3 8 + u_char volume; + } port[4]; +}; + +/* + * CDROM Capabilities and Mechanical Status Page + */ +struct cappage { + /* Mode data header */ + u_short data_length; + u_char medium_type; /* Present media type */ +#define MST_TYPE_MASK_LOW 0x0f +#define MST_FMT_NONE 0x00 +#define MST_DATA_120 0x01 +#define MST_AUDIO_120 0x02 +#define MST_COMB_120 0x03 +#define MST_PHOTO_120 0x04 +#define MST_DATA_80 0x05 +#define MST_AUDIO_80 0x06 +#define MST_COMB_80 0x07 +#define MST_PHOTO_80 0x08 + +#define MST_TYPE_MASK_HIGH 0x70 +#define MST_CDROM 0x00 +#define MST_CDR 0x10 +#define MST_CDRW 0x20 + +#define MST_NO_DISC 0x70 +#define MST_DOOR_OPEN 0x71 +#define MST_FMT_ERROR 0x72 + + u_char dev_spec; + u_char unused[2]; + u_short blk_desc_len; + + /* Capabilities page */ + u_char page_code; +#define ATAPI_CDROM_CAP_PAGE 0x2a + + u_char param_len; + u_char read_cdr:1; /* Supports CD-R read */ + u_char read_cdrw:1; /* Supports CD-RW read */ + u_char method2:1; /* Supports reading packet tracks */ + u_char byte2_37:5; + u_char write_cdr:1; /* Supports CD-R write */ + u_char write_cdrw:1; /* Supports CD-RW write */ + u_char test_write:1; /* Supports test writing */ + u_char byte3_37:5; + u_char audio_play:1; /* Audio play supported */ + u_char composite:1; /* Composite audio/video supported */ + u_char dport1:1; /* Digital audio on port 1 */ + u_char dport2:1; /* Digital audio on port 2 */ + u_char mode2_form1:1; /* Mode 2 form 1 (XA) read */ + u_char mode2_form2:1; /* Mode 2 form 2 format */ + u_char multisession:1; /* Multi-session photo-CD */ + u_char:1; + u_char cd_da:1; /* Audio-CD read supported */ + u_char cd_da_stream:1; /* CD-DA streaming */ + u_char rw:1; /* Combined R-W subchannels */ + u_char rw_corr:1; /* R-W subchannel data corrected */ + u_char c2:1; /* C2 error pointers supported */ + u_char isrc:1; /* Can return the ISRC info */ + u_char upc:1; /* Can return the catalog number UPC */ + u_char:1; + u_char lock:1; /* Can be locked */ + u_char locked:1; /* Current lock state */ + u_char prevent:1; /* Prevent jumper installed */ + u_char eject:1; /* Can eject */ + u_char:1; + u_char mech:3; /* Loading mechanism type */ +#define MST_MECH_CADDY 0 +#define MST_MECH_TRAY 1 +#define MST_MECH_POPUP 2 +#define MST_MECH_CHANGER 4 +#define MST_MECH_CARTRIDGE 5 + + u_char sep_vol:1; /* Independent volume of channels */ + u_char sep_mute:1; /* Independent mute of channels */ + u_char:6; + + u_short max_speed; /* Max raw data rate in bytes/1000 */ + u_short max_vol_levels; /* Number of discrete volume levels */ + u_short buf_size; /* Internal buffer size in bytes/1024 */ + u_short cur_speed; /* Current data rate in bytes/1000 */ + + u_char reserved3; + u_char bckf:1; /* Data valid on failing edge of BCK */ + u_char rch:1; /* High LRCK indicates left channel */ + u_char lsbf:1; /* Set if LSB first */ + u_char dlen:2; +#define MST_DLEN_32 0 +#define MST_DLEN_16 1 +#define MST_DLEN_24 2 +#define MST_DLEN_24_I2S 3 + + u_char:3; + u_char reserved4[2]; +}; + +/* + * CDROM Changer mechanism status structure + */ +struct changer { + u_char current_slot:5; /* Active changer slot */ + u_char mech_state:2; /* Current changer state */ +#define CH_READY 0 +#define CH_LOADING 1 +#define CH_UNLOADING 2 +#define CH_INITIALIZING 3 + + u_char fault:1; /* Fault in last operation */ + u_char reserved0:5; + u_char cd_state:3; /* Current mechanism state */ +#define CD_IDLE 0 +#define CD_AUDIO_ACTIVE 1 +#define CD_AUDIO_SCAN 2 +#define CD_HOST_ACTIVE 3 +#define CD_NO_STATE 7 + + u_char current_lba[3]; /* Current LBA */ + u_char slots; /* Number of available slots */ + u_short table_length; /* Slot table length */ + struct { + u_char changed:1; /* Media has changed in this slot */ + u_char unused:6; + u_char present:1; /* Slot has a CD present */ + u_char reserved0; + u_char reserved1; + u_char reserved2; + } slot[32]; +}; + +/* + * CDROM Write Parameters Mode Page (Burners ONLY) + */ +struct write_param { + /* Mode Page data header */ + u_short data_length; + u_char medium_type; + u_char dev_spec; + u_char unused[2]; + u_short blk_desc_len; + + /* Write Parameters mode page */ + u_char page_code; /* 0x05 */ + u_char page_length; /* 0x32 */ + u_char write_type:4; /* Write stream type */ +#define CDR_WTYPE_PACKET 0x00 +#define CDR_WTYPE_TRACK 0x01 +#define CDR_WTYPE_SESSION 0x02 +#define CDR_WTYPE_RAW 0x03 + + u_char test_write:1; /* Test write enable */ + u_char reserved2_567:3; + u_char track_mode:4; /* Track mode */ +#define CDR_TMODE_AUDIO 0x01 +#define CDR_TMODE_INCR_DATA 0x01 +#define CDR_TMODE_ALLOW_COPY 0x02 +#define CDR_TMODE_DATA 0x04 +#define CDR_TMODE_QUAD_AUDIO 0x08 + + u_char copy:1; /* Generation stamp */ + u_char fp:1; /* Fixed packet type */ + u_char multi_session:2; /* Multi-session type */ +#define CDR_MSES_NONE 0x00 +#define CDR_MSES_FINAL 0x01 +#define CDR_MSES_RESERVED 0x02 +#define CDR_MSES_NULTI 0x03 + + u_char data_block_type:4; /* Data block type code */ +#define CDR_DB_RAW 0x0 /* 2352 bytes of raw data */ +#define CDR_DB_RAW_PQ 0x1 /* 2368 bytes raw data + P/Q subchan */ +#define CDR_DB_RAW_PW 0x2 /* 2448 bytes raw data + P-W subchan */ +#define CDR_DB_RAW_PW_R 0x3 /* 2448 bytes raw data + P-W raw sub */ +#define CDR_DB_RES_4 0x4 /* Reserved */ +#define CDR_DB_RES_5 0x5 /* Reserved */ +#define CDR_DB_RES_6 0x6 /* Reserved */ +#define CDR_DB_VS_7 0x7 /* Vendor specific */ +#define CDR_DB_ROM_MODE1 0x8 /* 2048 bytes Mode 1 (ISO/IEC 10149) */ +#define CDR_DB_ROM_MODE2 0x9 /* 2336 bytes Mode 2 (ISO/IEC 10149) */ +#define CDR_DB_XA_MODE1 0x10 /* 2048 bytes Mode 1 (CD-ROM XA 1) */ +#define CDR_DB_XA_MODE2_F1 0x11 /* 2056 bytes Mode 2 (CD-ROM XA 1) */ +#define CDR_DB_XA_MODE2_F2 0x12 /* 2324 bytes Mode 2 (CD-ROM XA 2) */ +#define CDR_DB_XA_MODE2_MIX 0x13 /* 2332 bytes Mode 2 (CD-ROM XA 1/2) */ +#define CDR_DB_RES_14 0x14 /* Reserved */ +#define CDR_DB_VS_15 0x15 /* Vendor specific */ + + u_char reserved4_4567:4; + u_char reserved5; + u_char reserved6; + u_char host_app_code:6; /* Host application code */ + u_char reserved7_67:2; + u_char session_format; /* Session format */ +#define CDR_SESS_CDROM 0x00 +#define CDR_SESS_CDI 0x10 +#define CDR_SESS_CDROM_XA 0x20 + + u_char reserved9; + u_int packet_size; /* Packet size in bytes */ + u_short audio_pause_length; /* Audio pause length in secs */ + u_char media_catalog_number[16]; + u_char isr_code[16]; + u_char sub_hdr_byte0; + u_char sub_hdr_byte1; + u_char sub_hdr_byte2; + u_char sub_hdr_byte3; +/* + u_char vendor_specific_byte0; + u_char vendor_specific_byte1; + u_char vendor_specific_byte2; + u_char vendor_specific_byte3; +*/ + +} __attribute__((packed)); +/* + * CDROM Read Track Information structure + */ +struct acd_track_info { + u_short data_length; + u_char track_number; /* Current track number */ + u_char session_number; /* Current session number */ + u_char reserved4; + u_char track_mode:4; /* Mode of this track */ + u_char copy:1; /* Generation stamp */ + u_char damage:1; /* Damaged track */ + u_char reserved5_67:2; + u_char data_mode:4; /* Data mode of this disc */ + u_char fp:1; /* Fixed packet */ + u_char packet:1; /* Packet track */ + u_char blank:1; /* Blank (empty) track */ + u_char rt:1; /* Reserved track */ + u_char nwa_valid:1; /* next_writeable_addr field valid */ + u_char reserved7_17:7; + u_int track_start_addr; /* Start of this track */ + u_int next_writeable_addr; /* Next writeable addr on this disc */ + u_int free_blocks; /* Free block on this disc */ + u_int fixed_packet_size; /* Size of packets on this track */ + u_int track_length; /* Length of this track */ +}; + +/* + * Structure describing an ATAPI CDROM device + */ +struct acd { + int unit; /* IDE bus drive unit */ + int lun; /* Logical device unit */ + int flags; /* Device state flags */ + int refcnt; /* The number of raw opens */ + struct atapi *ata; /* Controller structure */ + struct buf_queue_head buf_queue; /* Queue of i/o requests */ + struct atapi_params *param; /* Drive parameters table */ + struct toc toc; /* Table of disc contents */ + struct { + u_long volsize; /* Volume size in blocks */ + u_long blksize; /* Block size in bytes */ + } info; + struct audiopage au; /* Audio page info */ + struct cappage cap; /* Capabilities page info */ + struct audiopage aumask; /* Audio page mask */ + struct { /* Subchannel info */ + u_char void0; + u_char audio_status; + u_short data_length; + u_char data_format; + u_char control; + u_char track; + u_char indx; + u_long abslba; + u_long rellba; + } subchan; + struct changer *changer_info; /* Changer info */ + int slot; /* This lun's slot number */ + u_int block_size; /* Blocksize currently used */ + u_char dummy; /* Use dummy writes */ + u_char speed; /* Select drive speed */ + struct wormio_prepare_track preptrack; /* Scratch region */ + +#ifdef DEVFS + void *ra_devfs_token; + void *rc_devfs_token; + void *a_devfs_token; + void *c_devfs_token; +#endif +}; + +#define CDRIOCBLANK _IO('c',100) /* Blank a CDRW disc */ +#define CDRIOCNEXTWRITEABLEADDR _IOR('c',101,int) diff --git a/sys/i386/isa/atapi.c b/sys/i386/isa/atapi.c index 5752587aa5a4..298e7ee2b529 100644 --- a/sys/i386/isa/atapi.c +++ b/sys/i386/isa/atapi.c @@ -1,1113 +1,1137 @@ /* * Device-independent level for ATAPI drivers. * * Copyright (C) 1995 Cronyx Ltd. * Author Serge Vakulenko, * * This software is distributed with NO WARRANTIES, not even the implied * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Authors grant any other persons or organisations permission to use * or modify this software as long as this message is kept with the software, * all derivative works or modified versions. * * Version 1.9, Mon Oct 9 22:34:47 MSK 1995 */ /* * The ATAPI level is implemented as a machine-dependent layer * between the device driver and the IDE controller. * All the machine- and controller dependency is isolated inside * the ATAPI level, while all the device dependency is located * in the device subdriver. * * It seems that an ATAPI bus will became popular for medium-speed * storage devices such as CD-ROMs, magneto-optical disks, tape streamers etc. * * To ease the development of new ATAPI drivers, the subdriver * interface was designed to be as simple as possible. * * Three routines are available for the subdriver to access the device: * * struct atapires atapi_request_wait (ata, unit, cmd, a1, a2, a3, a4, a5, * a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, addr, count); * struct atapi *ata; -- atapi controller descriptor * int unit; -- device unit number on the IDE bus * u_char cmd; -- ATAPI command code * u_char a1..a15; -- ATAPI command arguments * char *addr; -- address of the data buffer for i/o * int count; -- data length, >0 for read ops, <0 for write ops * * The atapi_request_wait() function puts the op in the queue of ATAPI * commands for the IDE controller, starts the controller, the waits for * operation to be completed (using tsleep). * The function should be called from the user phase only (open(), close(), * ioctl() etc). * Ata and unit args are the values which the subdriver gets from the ATAPI * level via attach() call. * Buffer pointed to by *addr should be placed in core memory, static * or dynamic, but not in stack. * The function returns the error code structure, which consists of: * - atapi driver code value * - controller status port value * - controller error port value * * struct atapires atapi_request_immediate (ata, unit, cmd, a1, a2, a3, * a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, * addr, count); * * The atapi_request_immediate() function is similar to atapi_request_wait(), * but it does not use interrupts for performing the request. * It should be used during an attach phase to get parameters from the device. * * void atapi_request_callback (ata, unit, cmd, a1, a2, a3, a4, a5, * a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, * addr, count, done, x, y); * struct atapi *ata; -- atapi controller descriptor * int unit; -- device unit number on the IDE bus * u_char cmd; -- ATAPI command code * u_char a1..a15; -- ATAPI command arguments * char *addr; -- address of the data buffer for i/o * int count; -- data length, >0 for read ops, <0 for write ops * void (*done)(); -- function to call when op finished * void *x, *y; -- arguments for done() function * * The atapi_request_callback() function puts the op in the queue of ATAPI * commands for the IDE controller, starts the controller, then returns. * When the operation finishes, then the callback function done() * will be called on the interrupt level. * The function is designed to be callable from the interrupt phase. * The done() functions is called with the following arguments: * (void) (*done) (x, y, count, errcode) * void *x, *y; -- arguments from the atapi_request_callback() * int count; -- the data residual count * struct atapires errcode; -- error code structure, see above * * The new driver could be added in three steps: * 1. Add entries for the new driver to bdevsw and cdevsw tables in conf.c. * You will need to make at least three routines: open(), close(), * strategy() and possibly ioctl(). * 2. Make attach() routine, which should allocate all the needed data * structures and print the device description string (see wcdattach()). * 3. Add an appropriate case to the switch in atapi_attach() routine, * call attach() routine of the new driver here. Add the appropriate * #include line at the top of attach.c. * That's all! * * Use #define DEBUG in atapi.c to enable tracing of all i/o operations * on the IDE bus. */ #undef DEBUG #include "wdc.h" #include "opt_atapi.h" #ifndef ATAPI_MODULE +# include "acd.h" # include "wcd.h" # include "wfd.h" # include "wst.h" /* # include "wmd.h" -- add your driver here */ #endif #if NWDC > 0 && defined (ATAPI) #include #include #include #include #ifdef ATAPI_MODULE # define ATAPI_STATIC #endif #include #ifndef ATAPI_STATIC /* this code is compiled as part of the kernel if options ATAPI */ /* * In the case of loadable ATAPI driver we need to store * the probe info for delayed attaching. */ struct atapidrv atapi_drvtab[4]; int atapi_ndrv; struct atapi *atapi_tab; int atapi_attach (int ctlr, int unit, int port) { atapi_drvtab[atapi_ndrv].ctlr = ctlr; atapi_drvtab[atapi_ndrv].unit = unit; atapi_drvtab[atapi_ndrv].port = port; atapi_drvtab[atapi_ndrv].attached = 0; ++atapi_ndrv; return (1); } #else /* ATAPI_STATIC */ /* this code is compiled part of the module */ #ifdef DEBUG # define print(s) printf s #else # define print(s) {/*void*/} #endif /* * ATAPI packet command phase. */ #define PHASE_CMDOUT (ARS_DRQ | ARI_CMD) #define PHASE_DATAIN (ARS_DRQ | ARI_IN) #define PHASE_DATAOUT ARS_DRQ #define PHASE_COMPLETED (ARI_IN | ARI_CMD) #define PHASE_ABORTED 0 /* nonstandard - for NEC 260 */ static struct atapi atapitab[NWDC]; static struct atapi_params *atapi_probe (int port, int unit); static int atapi_wait (int port, u_char bits_wanted); static void atapi_send_cmd (struct atapi *ata, struct atapicmd *ac); static int atapi_io (struct atapi *ata, struct atapicmd *ac); static int atapi_start_cmd (struct atapi *ata, struct atapicmd *ac); static int atapi_wait_cmd (struct atapi *ata, struct atapicmd *ac); static void atapi_poll_dsc(struct atapi *ata); extern int wdstart (int ctrlr); +extern int acdattach(struct atapi*, int, struct atapi_params*, int); extern int wcdattach(struct atapi*, int, struct atapi_params*, int); extern int wfdattach(struct atapi*, int, struct atapi_params*, int); extern int wstattach(struct atapi*, int, struct atapi_params*, int); /* * Probe the ATAPI device at IDE controller `ctlr', drive `unit'. * Called at splbio(). */ #ifdef ATAPI_MODULE static #endif int atapi_attach (int ctlr, int unit, int port) { struct atapi *ata = atapitab + ctlr; struct atapi_params *ap; char buf [sizeof(ap->model) + 1]; char revbuf [sizeof(ap->revision) + 1]; struct atapicmd *ac; print (("atapi%d.%d at 0x%x: attach called\n", ctlr, unit, port)); ap = atapi_probe (port, unit); if (! ap) return (0); bcopy (ap->model, buf, sizeof(buf)-1); buf[sizeof(buf)-1] = 0; bcopy (ap->revision, revbuf, sizeof(revbuf)-1); revbuf[sizeof(revbuf)-1] = 0; printf ("wdc%d: unit %d (atapi): <%s/%s>", ctlr, unit, buf, revbuf); /* device is removable */ if (ap->removable) printf (", removable"); /* packet command size */ switch (ap->cmdsz) { case AT_PSIZE_12: break; case AT_PSIZE_16: printf (", cmd16"); ata->cmd16 = 1; break; default: printf (", cmd%d", ap->cmdsz); } /* DRQ type */ switch (ap->drqtype) { case AT_DRQT_MPROC: ata->slow = 1; break; case AT_DRQT_INTR: printf (", intr"); ata->intrcmd = 1; break; case AT_DRQT_ACCEL: printf (", accel"); ata->accel = 1; break; default: printf (", drq%d", ap->drqtype); } if (ata->slow) ata->intrcmd = 0; /* * If we have two devices, one supporting INTR and one ACCEL, we * have to pessimise - clear INTR and set slow. */ if (ata->accel && ata->intrcmd) { ata->intrcmd = 0; ata->slow = 1; } /* overlap operation supported */ if (ap->ovlapflag) printf (", ovlap"); /* interleaved DMA supported */ if (ap->idmaflag) printf (", idma"); /* DMA supported */ else if (ap->dmaflag) printf (", dma"); /* IORDY can be disabled */ if (ap->iordydis) printf (", iordis"); /* IORDY supported */ else if (ap->iordyflag) printf (", iordy"); printf ("\n"); ata->port = port; ata->ctrlr = ctlr; ata->attached[unit] = 0; #ifdef DEBUG ata->debug = 1; #else ata->debug = 0; #endif /* Initialize free queue. */ ata->cmdrq[15].next = 0; for (ac = ata->cmdrq+14; ac >= ata->cmdrq; --ac) ac->next = ac+1; ata->free = ata->cmdrq; if (ap->proto != AT_PROTO_ATAPI) { printf ("wdc%d: unit %d: unknown ATAPI protocol=%d\n", ctlr, unit, ap->proto); free (ap, M_TEMP); return (0); } #ifdef ATAPI_MODULE ata->params[unit] = ap; return (1); #else switch (ap->devtype) { default: /* unknown ATAPI device */ printf ("wdc%d: unit %d: unknown ATAPI type=%d\n", ctlr, unit, ap->devtype); break; case AT_TYPE_DIRECT: /* direct-access */ #if NWFD > 0 /* ATAPI Floppy(LS-120) */ if (wfdattach (ata, unit, ap, ata->debug) >= 0) { /* Device attached successfully. */ ata->attached[unit] = 1; return (1); } #endif case AT_TYPE_CDROM: /* CD-ROM device */ +#if NACD > 0 + /* ATAPI CD-ROM & CD-R/RW drives */ + if (acdattach (ata, unit, ap, ata->debug) < 0) + break; + ata->attached[unit] = 1; + return (1); +#else #if NWCD > 0 - /* ATAPI CD-ROM */ + /* ATAPI CD-ROM drives */ if (wcdattach (ata, unit, ap, ata->debug) < 0) break; - /* Device attached successfully. */ ata->attached[unit] = 1; return (1); #else printf ("wdc%d: ATAPI CD-ROMs not configured\n", ctlr); break; +#endif #endif case AT_TYPE_TAPE: /* streaming tape */ #if NWST > 0 /* ATAPI Streaming Tape */ if (wstattach (ata, unit, ap, ata->debug) < 0) break; /* Device attached successfully. */ ata->attached[unit] = 1; return (1); #else printf ("wdc%d: ATAPI streaming tapes not configured\n", ctlr); #endif break; case AT_TYPE_OPTICAL: /* optical disk */ #if NWMD > 0 /* Add your driver here */ #else printf ("wdc%d: ATAPI optical disks not supported yet\n", ctlr); #endif break; } /* Attach failed. */ free (ap, M_TEMP); return (0); #endif /* ATAPI_MODULE */ } static char *cmdname (u_char cmd) { static char buf[8]; switch (cmd) { case 0x00: return ("TEST_UNIT_READY"); + case 0x01: return ("REZERO_UNIT"); case 0x03: return ("REQUEST_SENSE"); + case 0x04: return ("FORMAT_UNIT"); case 0x1b: return ("START_STOP"); case 0x1e: return ("PREVENT_ALLOW"); case 0x25: return ("READ_CAPACITY"); case 0x28: return ("READ_BIG"); case 0x2a: return ("WRITE_BIG"); - case 0x43: return ("READ_TOC"); + case 0x35: return ("SYNCHRONIZE_CACHE"); case 0x42: return ("READ_SUBCHANNEL"); - case 0x55: return ("MODE_SELECT_BIG"); + case 0x43: return ("READ_TOC"); + case 0x51: return ("READ_DISC_INFO"); + case 0x52: return ("READ_TRACK_INFO"); + case 0x53: return ("RESERVE_TRACK"); + case 0x54: return ("SEND_OPC_INFO"); + case 0x55: return ("MODE_SELECT"); + case 0x58: return ("REPAIR_TRACK"); + case 0x59: return ("READ_MASTER_CUE"); case 0x5a: return ("MODE_SENSE"); - case 0xb4: return ("PLAY_CD"); + case 0x5b: return ("CLOSE_TRACK/SESSION"); + case 0x5c: return ("READ_BUFFER_CAPACITY"); + case 0x5d: return ("SEND_CUE_SHEET"); case 0x47: return ("PLAY_MSF"); case 0x4b: return ("PAUSE"); case 0x48: return ("PLAY_TRACK"); + case 0xa1: return ("BLANK_CMD"); case 0xa5: return ("PLAY_BIG"); + case 0xb4: return ("PLAY_CD"); + case 0xbd: return ("ATAPI_MECH_STATUS"); + case 0xbe: return ("READ_CD"); } sprintf (buf, "[0x%x]", cmd); return (buf); } static void bswap (char *buf, int len) { u_short *p = (u_short*) (buf + len); while (--p >= (u_short*) buf) *p = ntohs (*p); } static void btrim (char *buf, int len) { char *p; /* Remove the trailing spaces. */ for (p=buf; p=buf && *p==' '; --p) *p = 0; } /* * Issue IDENTIFY command to ATAPI drive to ask it what it is. */ static struct atapi_params *atapi_probe (int port, int unit) { struct atapi_params *ap; char tb [DEV_BSIZE]; #ifdef PC98 int cnt; outb(0x432,unit%2); print(("unit = %d,select %d\n",unit,unit%2)); #endif /* Wait for controller not busy. */ #ifdef PC98 outb (port + AR_DRIVE, unit / 2 ? ARD_DRIVE1 : ARD_DRIVE0); #else outb (port + AR_DRIVE, unit ? ARD_DRIVE1 : ARD_DRIVE0); #endif if (atapi_wait (port, 0) < 0) { print (("atapiX.%d at 0x%x: controller busy, status=%b\n", unit, port, inb (port + AR_STATUS), ARS_BITS)); return (0); } /* Issue ATAPI IDENTIFY command. */ #ifdef PC98 outb (port + AR_DRIVE, unit/2 ? ARD_DRIVE1 : ARD_DRIVE0); /* Wait for DRQ deassert. */ for (cnt=2000; cnt>0; --cnt) if (! (inb (port + AR_STATUS) & ARS_DRQ)) break; outb (port + AR_COMMAND, ATAPIC_IDENTIFY); DELAY(500); #else outb (port + AR_DRIVE, unit ? ARD_DRIVE1 : ARD_DRIVE0); outb (port + AR_COMMAND, ATAPIC_IDENTIFY); #endif /* Check that device is present. */ if (inb (port + AR_STATUS) == 0xff) { print (("atapiX.%d at 0x%x: no device\n", unit, port)); if (unit == 1) /* Select unit 0. */ outb (port + AR_DRIVE, ARD_DRIVE0); return (0); } /* Wait for data ready. */ if (atapi_wait (port, ARS_DRQ) != 0) { print (("atapiX.%d at 0x%x: identify not ready, status=%b\n", unit, port, inb (port + AR_STATUS), ARS_BITS)); if (unit == 1) /* Select unit 0. */ outb (port + AR_DRIVE, ARD_DRIVE0); return (0); } /* check that DRQ isn't a fake */ if (inb (port + AR_STATUS) == 0xff) { print (("atapiX.%d at 0x%x: no device\n", unit, port)); if (unit == 1) /* Select unit 0. */ outb (port + AR_DRIVE, ARD_DRIVE0); return (0); } /* Obtain parameters. */ insw (port + AR_DATA, tb, sizeof(tb) / sizeof(short)); ap = malloc (sizeof *ap, M_TEMP, M_NOWAIT); if (! ap) return (0); bcopy (tb, ap, sizeof *ap); /* * Shuffle string byte order. * Mitsumi and NEC drives don't need this. */ if (! ((ap->model[0] == 'N' && ap->model[1] == 'E') || (ap->model[0] == 'F' && ap->model[1] == 'X'))) bswap (ap->model, sizeof(ap->model)); bswap (ap->serial, sizeof(ap->serial)); bswap (ap->revision, sizeof(ap->revision)); /* Clean up the model name, serial and revision numbers. */ btrim (ap->model, sizeof(ap->model)); btrim (ap->serial, sizeof(ap->serial)); btrim (ap->revision, sizeof(ap->revision)); return (ap); } /* * Wait uninterruptibly until controller is not busy and certain * status bits are set. * The wait is usually short unless it is for the controller to process * an entire critical command. * Return 1 for (possibly stale) controller errors, -1 for timeout errors, * or 0 for no errors. */ static int atapi_wait (int port, u_char bits_wanted) { int cnt; u_char s; /* Wait 5 sec for BUSY deassert. */ for (cnt=500000; cnt>0; --cnt) { s = inb (port + AR_STATUS); if (! (s & ARS_BSY)) break; DELAY (10); } if (cnt <= 0) return (-1); if (! bits_wanted) return (s & ARS_CHECK); /* Wait 50 msec for bits wanted. */ for (cnt=5000; cnt>0; --cnt) { s = inb (port + AR_STATUS); if ((s & bits_wanted) == bits_wanted) return (s & ARS_CHECK); DELAY (10); } return (-1); } void atapi_debug (struct atapi *ata, int on) { ata->debug = on; } static struct atapicmd *atapi_alloc (struct atapi *ata) { struct atapicmd *ac; while (! ata->free) tsleep ((caddr_t)ata, PRIBIO, "atacmd", 100); ac = ata->free; ata->free = ac->next; ac->busy = 1; return (ac); } static void atapi_free (struct atapi *ata, struct atapicmd *ac) { if (! ata->free) wakeup ((caddr_t)&ata); ac->busy = 0; ac->next = ata->free; ata->free = ac; } /* * Add new command request to the end of the queue. */ static void atapi_enqueue (struct atapi *ata, struct atapicmd *ac) { ac->next = 0; if (ata->tail) ata->tail->next = ac; else ata->queue = ac; ata->tail = ac; } static void atapi_done (struct atapi *ata) { struct atapicmd *ac = ata->queue; if (! ac) return; /* cannot happen */ ata->queue = ac->next; if (! ata->queue) ata->tail = 0; if (ac->callback) { (*ac->callback) (ac->cbarg1, ac->cbarg2, ac->count, ac->result); atapi_free (ata, ac); } else wakeup ((caddr_t)ac); } /* * Start new packet op. Called from wdstart(). * Return 1 if op started, and we are waiting for interrupt. * Return 0 when idle. */ int atapi_start (int ctrlr) { struct atapi *ata = atapitab + ctrlr; struct atapicmd *ac; again: ac = ata->queue; if (! ac) return (0); /* Start packet command. */ if (atapi_start_cmd (ata, ac) < 0) { atapi_done (ata); goto again; } if (ata->intrcmd) /* Wait for interrupt before sending packet command */ return (1); /* Wait for DRQ. */ if (atapi_wait_cmd (ata, ac) < 0) { atapi_done (ata); goto again; } /* Send packet command. */ atapi_send_cmd (ata, ac); return (1); } /* * Start new packet op. Returns -1 on errors. */ int atapi_start_cmd (struct atapi *ata, struct atapicmd *ac) { ac->result.error = 0; ac->result.status = 0; #ifdef PC98 outb(0x432,(ac->unit)%2); print(("(ac->unit) = %d,select %d (2) \n",(ac->unit),(ac->unit)%2)); outb (ata->port + AR_DRIVE, (ac->unit)/2 ? ARD_DRIVE1 : ARD_DRIVE0); #else outb (ata->port + AR_DRIVE, ac->unit ? ARD_DRIVE1 : ARD_DRIVE0); #endif if (atapi_wait (ata->port, 0) < 0) { printf ("atapi%d.%d: controller not ready for cmd\n", ata->ctrlr, ac->unit); ac->result.code = RES_NOTRDY; return (-1); } /* Set up the controller registers. */ outb (ata->port + AR_FEATURES, 0); outb (ata->port + AR_IREASON, 0); outb (ata->port + AR_TAG, 0); outb (ata->port + AR_CNTLO, ac->count & 0xff); outb (ata->port + AR_CNTHI, ac->count >> 8); outb (ata->port + AR_COMMAND, ATAPIC_PACKET); if (ata->debug) printf ("atapi%d.%d: start\n", ata->ctrlr, ac->unit); return (0); } /* * Wait for DRQ before sending packet cmd. Returns -1 on errors. */ int atapi_wait_cmd (struct atapi *ata, struct atapicmd *ac) { /* Wait for DRQ from 50 usec to 3 msec for slow devices */ int cnt = ata->intrcmd ? 10000 : ata->slow ? 3000 : 50; int ireason = 0, phase = 0; /* Wait for command phase. */ for (; cnt>0; cnt-=10) { ireason = inb (ata->port + AR_IREASON); ac->result.status = inb (ata->port + AR_STATUS); phase = (ireason & (ARI_CMD | ARI_IN)) | (ac->result.status & (ARS_DRQ | ARS_BSY)); if (phase == PHASE_CMDOUT) break; DELAY (10); } if (phase != PHASE_CMDOUT) { ac->result.code = RES_NODRQ; ac->result.error = inb (ata->port + AR_ERROR); printf ("atapi%d.%d: invalid command phase, ireason=0x%x, status=%b, error=%b\n", ata->ctrlr, ac->unit, ireason, ac->result.status, ARS_BITS, ac->result.error, AER_BITS); return (-1); } return (0); } /* * Send packet cmd. */ void atapi_send_cmd (struct atapi *ata, struct atapicmd *ac) { outsw (ata->port + AR_DATA, ac->cmd, ata->cmd16 ? 8 : 6); if (ata->debug) printf ("atapi%d.%d: send cmd %s %x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x\n", ata->ctrlr, ac->unit, cmdname (ac->cmd[0]), ac->cmd[0], ac->cmd[1], ac->cmd[2], ac->cmd[3], ac->cmd[4], ac->cmd[5], ac->cmd[6], ac->cmd[7], ac->cmd[8], ac->cmd[9], ac->cmd[10], ac->cmd[11], ac->cmd[12], ac->cmd[13], ac->cmd[14], ac->cmd[15]); } /* * Interrupt routine for the controller. Called from wdintr(). * Finish the started op, wakeup wait-type commands, * run callbacks for callback-type commands, then return. * Do not start new op here, it will be done by wdstart, * which is called just after us. * Return 1 if op continues, and we are waiting for new interrupt. * Return 0 when idle. */ int atapi_intr (int ctrlr) { struct atapi *ata = atapitab + ctrlr; struct atapicmd *ac = ata->queue; #ifdef PC98 outb(0x432,(ac->unit)%2); print(("atapi_intr:(ac->unit)= %d,select %d\n",ac->unit,(ac->unit)%2)); #endif if (! ac) { printf ("atapi%d: stray interrupt\n", ata->ctrlr); return (0); } if (atapi_io (ata, ac) > 0) return (1); atapi_done (ata); return (0); } /* * Process the i/o phase, transferring the command/data to/from the device. * Return 1 if op continues, and we are waiting for new interrupt. * Return 0 when idle. */ int atapi_io (struct atapi *ata, struct atapicmd *ac) { u_char ireason; u_short len, i; if (atapi_wait (ata->port, 0) < 0) { ac->result.status = inb (ata->port + AR_STATUS); ac->result.error = inb (ata->port + AR_ERROR); ac->result.code = RES_NOTRDY; printf ("atapi%d.%d: controller not ready, status=%b, error=%b\n", ata->ctrlr, ac->unit, ac->result.status, ARS_BITS, ac->result.error, AER_BITS); return (0); } ac->result.status = inb (ata->port + AR_STATUS); ac->result.error = inb (ata->port + AR_ERROR); len = inb (ata->port + AR_CNTLO); len |= inb (ata->port + AR_CNTHI) << 8; ireason = inb (ata->port + AR_IREASON); if (ata->debug) { printf ("atapi%d.%d: intr ireason=0x%x, len=%d, status=%b, error=%b\n", ata->ctrlr, ac->unit, ireason, len, ac->result.status, ARS_BITS, ac->result.error, AER_BITS); } switch ((ireason & (ARI_CMD | ARI_IN)) | (ac->result.status & ARS_DRQ)) { default: printf ("atapi%d.%d: unknown phase\n", ata->ctrlr, ac->unit); ac->result.code = RES_ERR; break; case PHASE_CMDOUT: /* Send packet command. */ if (! (ac->result.status & ARS_DRQ)) { printf ("atapi%d.%d: no cmd drq\n", ata->ctrlr, ac->unit); ac->result.code = RES_NODRQ; break; } atapi_send_cmd (ata, ac); return (1); case PHASE_DATAOUT: /* Write data */ if (ac->count > 0) { printf ("atapi%d.%d: invalid data direction\n", ata->ctrlr, ac->unit); ac->result.code = RES_INVDIR; break; } if (-ac->count < len) { print (("atapi%d.%d: send data underrun, %d bytes left\n", ata->ctrlr, ac->unit, -ac->count)); ac->result.code = RES_UNDERRUN; outsw (ata->port + AR_DATA, ac->addr, -ac->count / sizeof(short)); for (i= -ac->count; iport + AR_DATA, 0); } else outsw (ata->port + AR_DATA, ac->addr, len / sizeof(short)); ac->addr += len; ac->count += len; return (1); case PHASE_DATAIN: /* Read data */ if (ac->count < 0) { printf ("atapi%d.%d: invalid data direction\n", ata->ctrlr, ac->unit); ac->result.code = RES_INVDIR; break; } if (ac->count < len) { print (("atapi%d.%d: recv data overrun, %d bytes left\n", ata->ctrlr, ac->unit, ac->count)); ac->result.code = RES_OVERRUN; insw (ata->port + AR_DATA, ac->addr, ac->count / sizeof(short)); for (i=ac->count; iport + AR_DATA); } else insw (ata->port + AR_DATA, ac->addr, len / sizeof(short)); ac->addr += len; ac->count -= len; return (1); case PHASE_ABORTED: case PHASE_COMPLETED: if (ac->result.status & (ARS_CHECK | ARS_DF)) ac->result.code = RES_ERR; else if (ac->count < 0) { print (("atapi%d.%d: send data overrun, %d bytes left\n", ata->ctrlr, ac->unit, -ac->count)); ac->result.code = RES_OVERRUN; } else if (ac->count > 0) { print (("atapi%d.%d: recv data underrun, %d bytes left\n", ata->ctrlr, ac->unit, ac->count)); ac->result.code = RES_UNDERRUN; bzero (ac->addr, ac->count); } else ac->result.code = RES_OK; break; } return (0); } /* * Queue new packet request, then call wdstart(). * Called on splbio(). */ void atapi_request_callback (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count, atapi_callback_t *done, void *x, void *y) { struct atapicmd *ac; ac = atapi_alloc (ata); ac->cmd[0] = cmd; ac->cmd[1] = a1; ac->cmd[2] = a2; ac->cmd[3] = a3; ac->cmd[4] = a4; ac->cmd[5] = a5; ac->cmd[6] = a6; ac->cmd[7] = a7; ac->cmd[8] = a8; ac->cmd[9] = a9; ac->cmd[10] = a10; ac->cmd[11] = a11; ac->cmd[12] = a12; ac->cmd[13] = a13; ac->cmd[14] = a14; ac->cmd[15] = a15; ac->unit = unit; ac->addr = addr; ac->count = count; ac->callback = done; ac->cbarg1 = x; ac->cbarg2 = y; if (ata->debug) printf ("atapi%d.%d: req cb %x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x len=%d\n", ata->ctrlr, ac->unit, ac->cmd[0], ac->cmd[1], ac->cmd[2], ac->cmd[3], ac->cmd[4], ac->cmd[5], ac->cmd[6], ac->cmd[7], ac->cmd[8], ac->cmd[9], ac->cmd[10], ac->cmd[11], ac->cmd[12], ac->cmd[13], ac->cmd[14], ac->cmd[15], count); atapi_enqueue (ata, ac); wdstart (ata->ctrlr); } /* * Queue new packet request, then call wdstart(). * Wait until the request is finished. * Called on spl0(). * Return atapi error. * Buffer pointed to by *addr should be placed in core memory, not in stack! */ struct atapires atapi_request_wait (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count) { struct atapicmd *ac; int x = splbio (); struct atapires result; ac = atapi_alloc (ata); ac->cmd[0] = cmd; ac->cmd[1] = a1; ac->cmd[2] = a2; ac->cmd[3] = a3; ac->cmd[4] = a4; ac->cmd[5] = a5; ac->cmd[6] = a6; ac->cmd[7] = a7; ac->cmd[8] = a8; ac->cmd[9] = a9; ac->cmd[10] = a10; ac->cmd[11] = a11; ac->cmd[12] = a12; ac->cmd[13] = a13; ac->cmd[14] = a14; ac->cmd[15] = a15; ac->unit = unit; ac->addr = addr; ac->count = count; ac->callback = 0; ac->cbarg1 = 0; ac->cbarg2 = 0; if (ata->debug) printf ("atapi%d.%d: req w %x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x len=%d\n", ata->ctrlr, ac->unit, ac->cmd[0], ac->cmd[1], ac->cmd[2], ac->cmd[3], ac->cmd[4], ac->cmd[5], ac->cmd[6], ac->cmd[7], ac->cmd[8], ac->cmd[9], ac->cmd[10], ac->cmd[11], ac->cmd[12], ac->cmd[13], ac->cmd[14], ac->cmd[15], count); atapi_enqueue (ata, ac); wdstart (ata->ctrlr); tsleep ((caddr_t)ac, PRIBIO, "atareq", 0); result = ac->result; atapi_free (ata, ac); splx (x); return (result); } /* * Perform a packet command on the device. * Should be called on splbio(). * Return atapi error. */ struct atapires atapi_request_immediate (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count) { struct atapicmd cmdbuf, *ac = &cmdbuf; int cnt; ac->cmd[0] = cmd; ac->cmd[1] = a1; ac->cmd[2] = a2; ac->cmd[3] = a3; ac->cmd[4] = a4; ac->cmd[5] = a5; ac->cmd[6] = a6; ac->cmd[7] = a7; ac->cmd[8] = a8; ac->cmd[9] = a9; ac->cmd[10] = a10; ac->cmd[11] = a11; ac->cmd[12] = a12; ac->cmd[13] = a13; ac->cmd[14] = a14; ac->cmd[15] = a15; ac->unit = unit; ac->addr = addr; ac->count = count; ac->callback = 0; ac->cbarg1 = 0; ac->cbarg2 = 0; if (ata->debug) printf ("atapi%d.%d: req im %x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x-%x len=%d\n", ata->ctrlr, ac->unit, ac->cmd[0], ac->cmd[1], ac->cmd[2], ac->cmd[3], ac->cmd[4], ac->cmd[5], ac->cmd[6], ac->cmd[7], ac->cmd[8], ac->cmd[9], ac->cmd[10], ac->cmd[11], ac->cmd[12], ac->cmd[13], ac->cmd[14], ac->cmd[15], count); /* Start packet command, wait for DRQ. */ if (atapi_start_cmd (ata, ac) >= 0 && atapi_wait_cmd (ata, ac) >= 0) { /* Send packet command. */ atapi_send_cmd (ata, ac); /* Wait for data i/o phase. */ for (cnt=20000; cnt>0; --cnt) if (((inb (ata->port + AR_IREASON) & (ARI_CMD | ARI_IN)) | (inb (ata->port + AR_STATUS) & ARS_DRQ)) != PHASE_CMDOUT) break; /* Do all needed i/o. */ while (atapi_io (ata, ac)) /* Wait for DRQ deassert. */ for (cnt=2000; cnt>0; --cnt) { if (! (inb (ata->port + AR_STATUS) & ARS_DRQ)) break; DELAY(10); } } return (ac->result); } #endif /* ATAPI_STATIC */ #if defined (ATAPI_MODULE) || !defined(ATAPI_STATIC) int (*atapi_start_ptr) (int ctrlr); int (*atapi_intr_ptr) (int ctrlr); void (*atapi_debug_ptr) (struct atapi *ata, int on); struct atapires (*atapi_request_wait_ptr) (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count); void (*atapi_request_callback_ptr) (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count, atapi_callback_t *done, void *x, void *y); struct atapires (*atapi_request_immediate_ptr) (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count); #endif #ifdef ATAPI_MODULE /* * ATAPI loadable driver stubs. */ #include #include #include extern int atapi_lock (int ctlr); /* * XXX "ioconf.h" is not included by for lkms, so we need this * misplaced declaration. */ extern void wdintr (int); /* * Construct lkm_misc structure (see lkm.h). */ MOD_MISC(atapi); int atapi_locked; int atapi_lock (int ctlr) { atapi_locked = 1; wakeup (&atapi_locked); return (1); } /* * Function called when loading the driver. */ static int atapi_load (struct lkm_table *lkmtp, int cmd) { struct atapidrv *d; int n, x; /* * Probe all free IDE units, searching for ATAPI drives. */ n = 0; for (d=atapi_drvtab; dport; ++d) { /* Lock the controller. */ x = splbio (); atapi_locked = 0; atapi_start_ptr = atapi_lock; wdstart (d->ctlr); while (! atapi_locked) tsleep (&atapi_locked, PRIBIO, "atach", 0); /* Probe the drive. */ if (atapi_attach (d->ctlr, d->unit, d->port)) { d->attached = 1; ++n; } /* Unlock the controller. */ atapi_start_ptr = 0; wdintr (d->ctlr); splx (x); } if (! n) return ENXIO; atapi_start_ptr = atapi_start; atapi_intr_ptr = atapi_intr; atapi_debug_ptr = atapi_debug; atapi_request_wait_ptr = atapi_request_wait; atapi_request_callback_ptr = atapi_request_callback; atapi_request_immediate_ptr = atapi_request_immediate; atapi_tab = atapitab; return 0; } /* * Function called when unloading the driver. */ static int atapi_unload (struct lkm_table *lkmtp, int cmd) { struct atapi *ata; int u; for (ata=atapi_tab; ataport) for (u=0; u<2; ++u) if (ata->attached[u]) return EBUSY; for (ata=atapi_tab; ataport) for (u=0; u<2; ++u) if (ata->params[u]) { free (ata->params[u], M_TEMP); ata->params[u] = 0; } atapi_start_ptr = 0; atapi_intr_ptr = 0; atapi_debug_ptr = 0; atapi_request_wait_ptr = 0; atapi_request_callback_ptr = 0; atapi_request_immediate_ptr = 0; atapi_tab = 0; return 0; } /* * Dispatcher function for the module (load/unload/stat). */ int atapi_mod (struct lkm_table *lkmtp, int cmd, int ver) { MOD_DISPATCH (atapi, lkmtp, cmd, ver, atapi_load, atapi_unload, lkm_nullcmd); } #endif /* ATAPI_MODULE */ #endif /* NWDC && ATAPI */ diff --git a/sys/i386/isa/atapi.h b/sys/i386/isa/atapi.h index 14f3de51e0fd..dce85fbc883b 100644 --- a/sys/i386/isa/atapi.h +++ b/sys/i386/isa/atapi.h @@ -1,302 +1,306 @@ /* * Device-independent level for ATAPI drivers. * * Copyright (C) 1995 Cronyx Ltd. * Author Serge Vakulenko, * * This software is distributed with NO WARRANTIES, not even the implied * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Authors grant any other persons or organizations permission to use * or modify this software as long as this message is kept with the software, * all derivative works or modified versions. * * Version 1.9, Thu Oct 12 15:53:50 MSK 1995 */ /* * Disk Controller ATAPI register definitions. */ #ifdef PC98 #define AR_DATA 0x0 /* RW - data register (16 bits) */ #define AR_ERROR 0x2 /* R - error register */ #define AR_FEATURES 0x2 /* W - features */ #define AR_IREASON 0x4 /* RW - interrupt reason */ #define AR_TAG 0x6 /* - reserved for SAM TAG byte */ #define AR_CNTLO 0x8 /* RW - byte count, low byte */ #define AR_CNTHI 0xa /* RW - byte count, high byte */ #define AR_DRIVE 0xc /* RW - drive select */ #define AR_COMMAND 0xe /* W - command register */ #define AR_STATUS 0xe /* R - immediate status */ #else #define AR_DATA 0x0 /* RW - data register (16 bits) */ #define AR_ERROR 0x1 /* R - error register */ #define AR_FEATURES 0x1 /* W - features */ #define AR_IREASON 0x2 /* RW - interrupt reason */ #define AR_TAG 0x3 /* - reserved for SAM TAG byte */ #define AR_CNTLO 0x4 /* RW - byte count, low byte */ #define AR_CNTHI 0x5 /* RW - byte count, high byte */ #define AR_DRIVE 0x6 /* RW - drive select */ #define AR_COMMAND 0x7 /* W - command register */ #define AR_STATUS 0x7 /* R - immediate status */ #endif /* * Status register bits */ #define ARS_CHECK 0x01 /* error occured, see sense key/code */ /* bit 0x02 reserved */ #define ARS_CORR 0x04 /* correctable error occured */ #define ARS_DRQ 0x08 /* data request / ireason valid */ #define ARS_DSC 0x10 /* immediate operation completed */ #define ARS_DF 0x20 /* drive fault */ #define ARS_DRDY 0x40 /* ready to get command */ #define ARS_BSY 0x80 /* registers busy */ /* for overlap mode only: */ #define ARS_SERVICE 0x10 /* service is requested */ #define ARS_DMARDY 0x20 /* ready to start a DMA transfer */ #define ARS_BITS "\20\010busy\7ready\6fault\5opdone\4drq\3corr\1check" /* * Error register bits */ #define AER_ILI 0x01 /* illegal length indication */ #define AER_EOM 0x02 /* end of media detected */ #define AER_ABRT 0x04 /* command aborted */ #define AER_MCR 0x08 /* media change requested */ #define AER_SKEY 0xf0 /* sense key mask */ #define AER_SK_NO_SENSE 0x00 /* no specific sense key info */ #define AER_SK_RECOVERED_ERROR 0x10 /* command succeeded, data recovered */ #define AER_SK_NOT_READY 0x20 /* no access to drive */ #define AER_SK_MEDIUM_ERROR 0x30 /* non-recovered data error */ #define AER_SK_HARDWARE_ERROR 0x40 /* non-recoverable hardware failure */ #define AER_SK_ILLEGAL_REQUEST 0x50 /* invalid command parameter(s) */ #define AER_SK_UNIT_ATTENTION 0x60 /* media changed */ #define AER_SK_DATA_PROTECT 0x70 /* reading read-protected sector */ #define AER_SK_BLANK_CHECK 0x80 /* blank check */ #define AER_SK_VENDOR_SPECIFIC 0x90 /* vendor specific skey */ #define AER_SK_COPY_ABORTED 0xa0 /* copy aborted */ #define AER_SK_ABORTED_COMMAND 0xb0 /* command aborted, try again */ #define AER_SK_EQUAL 0xc0 /* equal */ #define AER_SK_VOLUME_OVERFLOW 0xd0 /* volume overflow */ #define AER_SK_MISCOMPARE 0xe0 /* data did not match the medium */ #define AER_SK_RESERVED 0xf0 #define AER_BITS "\20\4mchg\3abort\2eom\1ili" /* * Feature register bits */ #define ARF_DMA 0x01 /* transfer data via DMA */ #define ARF_OVERLAP 0x02 /* release the bus until completion */ /* * Interrupt reason register bits */ #define ARI_CMD 0x01 /* command(1) or data(0) */ #define ARI_IN 0x02 /* transfer to(1) or from(0) the host */ #define ARI_RELEASE 0x04 /* bus released until completion */ /* * Drive register values */ #define ARD_DRIVE0 0xa0 /* drive 0 selected */ #define ARD_DRIVE1 0xb0 /* drive 1 selected */ /* * ATA commands */ #define ATAPIC_IDENTIFY 0xa1 /* get drive parameters */ #define ATAPIC_PACKET 0xa0 /* execute packet command */ /* * Mandatory packet commands */ #define ATAPI_TEST_UNIT_READY 0x00 /* check if the device is ready */ +#define ATAPI_REZERO_UNIT 0x01 /* reinit device */ #define ATAPI_REQUEST_SENSE 0x03 /* get sense data */ #define ATAPI_START_STOP 0x1b /* start/stop the media */ #define ATAPI_PREVENT_ALLOW 0x1e /* prevent/allow media removal */ #define ATAPI_READ_CAPACITY 0x25 /* get volume capacity */ #define ATAPI_READ_BIG 0x28 /* read data */ #define ATAPI_WRITE_BIG 0x2a /* write data */ -#define ATAPI_READ_TOC 0x43 /* get table of contents */ +#define ATAPI_SYNCHRONIZE_CACHE 0x35 /* flush write buf, close write chan */ #define ATAPI_READ_SUBCHANNEL 0x42 /* get subchannel info */ -#define ATAPI_MODE_SELECT_BIG 0x55 /* set device parameters */ +#define ATAPI_READ_TOC 0x43 /* get table of contents */ +#define ATAPI_READ_TRACK_INFO 0x52 /* get track information structure */ +#define ATAPI_MODE_SELECT 0x55 /* set device parameters */ #define ATAPI_MODE_SENSE 0x5a /* get device parameters */ +#define ATAPI_CLOSE_TRACK 0x5b /* close track/session */ +#define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */ #define ATAPI_PLAY_CD 0xb4 /* universal play command */ #define ATAPI_MECH_STATUS 0xbd /* get changer mechanism status */ -#define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */ - +#define ATAPI_READ_CD 0xbe /* read data */ /* * Optional packet commands */ #define ATAPI_PLAY_MSF 0x47 /* play by MSF address */ #define ATAPI_PAUSE 0x4b /* stop/start audio operation */ /* * Nonstandard packet commands */ #define ATAPI_PLAY_TRACK 0x48 /* play by track number */ #define ATAPI_PLAY_BIG 0xa5 /* play by logical block address */ #define DSC_POLL_INTERVAL 10 /* * Drive parameter information */ struct atapi_params { unsigned cmdsz : 2; /* packet command size */ #define AT_PSIZE_12 0 /* 12 bytes */ #define AT_PSIZE_16 1 /* 16 bytes */ unsigned : 3; unsigned drqtype : 2; /* DRQ type */ #define AT_DRQT_MPROC 0 /* microprocessor DRQ - 3 msec delay */ #define AT_DRQT_INTR 1 /* interrupt DRQ - 10 msec delay */ #define AT_DRQT_ACCEL 2 /* accelerated DRQ - 50 usec delay */ unsigned removable : 1; /* device is removable */ unsigned devtype : 5; /* device type */ #define AT_TYPE_DIRECT 0 /* direct-access (magnetic disk) */ #define AT_TYPE_TAPE 1 /* streaming tape (QIC-121 model) */ #define AT_TYPE_CDROM 5 /* CD-ROM device */ #define AT_TYPE_OPTICAL 7 /* optical disk */ unsigned : 1; unsigned proto : 2; /* command protocol */ #define AT_PROTO_ATAPI 2 short reserved1[9]; char serial[20]; /* serial number - optional */ short reserved2[3]; char revision[8]; /* firmware revision */ char model[40]; /* model name */ short reserved3[2]; u_char vendor_cap; /* vendor unique capabilities */ unsigned dmaflag : 1; /* DMA supported */ unsigned lbaflag : 1; /* LBA supported - always 1 */ unsigned iordydis : 1; /* IORDY can be disabled */ unsigned iordyflag : 1; /* IORDY supported */ unsigned : 1; unsigned ovlapflag : 1; /* overlap operation supported */ unsigned : 1; unsigned idmaflag : 1; /* interleaved DMA supported */ short reserved4; u_short pio_timing; /* PIO cycle timing */ u_short dma_timing; /* DMA cycle timing */ u_short flags; #define AT_FLAG_54_58 1 /* words 54-58 valid */ #define AT_FLAG_64_70 2 /* words 64-70 valid */ short reserved5[8]; u_char swdma_flag; /* singleword DMA mode supported */ u_char swdma_active; /* singleword DMA mode active */ u_char mwdma_flag; /* multiword DMA mode supported */ u_char mwdma_active; /* multiword DMA mode active */ u_char apio_flag; /* advanced PIO mode supported */ u_char reserved6; u_short mwdma_min; /* min. M/W DMA time per word (ns) */ u_short mwdma_dflt; /* recommended M/W DMA time (ns) - optional */ u_short pio_nfctl_min; /* min. PIO cycle time w/o flow ctl - optional */ u_short pio_iordy_min; /* min. PIO c/t with IORDY flow ctl - optional */ short reserved7[2]; u_short rls_ovlap; /* release time (us) for overlap cmd - optional */ u_short rls_service; /* release time (us) for service cmd - optional */ }; /* * ATAPI operation result structure */ struct atapires { u_char code; /* result code */ #define RES_OK 0 /* i/o done */ #define RES_ERR 1 /* i/o finished with error */ #define RES_NOTRDY 2 /* controller not ready */ #define RES_NODRQ 3 /* no data request */ #define RES_INVDIR 4 /* invalid bus phase direction */ #define RES_OVERRUN 5 /* data overrun */ #define RES_UNDERRUN 6 /* data underrun */ u_char status; /* status register contents */ u_char error; /* error register contents */ }; struct atapidrv { /* delayed attach info */ int ctlr; /* IDE controller, 0/1 */ int unit; /* drive unit, 0/1 */ int port; /* controller base port */ int attached; /* the drive is attached */ }; struct buf; struct wcd; typedef void atapi_callback_t(struct wcd *, struct buf *, int, struct atapires); struct atapicmd { /* ATAPI command block */ struct atapicmd *next; /* next command in queue */ int busy; /* busy flag */ u_char cmd[16]; /* command and args */ int unit; /* drive unit number */ int count; /* byte count, >0 - read, <0 - write */ char *addr; /* data to transfer */ atapi_callback_t *callback; /* call when done */ void *cbarg1; /* callback arg 1 */ void *cbarg2; /* callback arg 1 */ struct atapires result; /* resulting error code */ }; struct atapi { /* ATAPI controller data */ u_short port; /* i/o port base */ u_char ctrlr; /* physical controller number */ - u_int debug : 1; /* trace enable flag */ - u_int cmd16 : 1; /* 16-byte command flag */ - u_int intrcmd : 1; /* interrupt before cmd flag */ - u_int slow : 1; /* slow reaction device */ - u_int accel : 1; /* accelerated reaction device */ - u_int use_dsc : 1; /* use DSC completition handeling */ - u_int wait_for_dsc : 1; + u_char debug : 1; /* trace enable flag */ + u_char cmd16 : 1; /* 16-byte command flag */ + u_char intrcmd : 1; /* interrupt before cmd flag */ + u_char slow : 1; /* slow reaction device */ + u_char accel : 1; /* accelerated reaction device */ + u_char use_dsc : 1; /* use DSC completition handeling */ + u_char wait_for_dsc : 1; u_int dsc_timeout; u_char attached[2]; /* units are attached to subdrivers */ struct atapi_params *params[2]; /* params for units 0,1 */ struct atapicmd *queue; /* queue of commands to perform */ struct atapicmd *tail; /* tail of queue */ struct atapicmd *free; /* queue of free command blocks */ struct atapicmd cmdrq[16]; /* pool of command requests */ }; #ifdef KERNEL struct atapi; extern struct atapidrv atapi_drvtab[4]; /* delayed attach info */ extern int atapi_ndrv; /* the number of potential drives */ extern struct atapi *atapi_tab; /* the table of atapi controllers */ #ifndef ATAPI_STATIC # define atapi_start (*atapi_start_ptr) # define atapi_intr (*atapi_intr_ptr) # define atapi_debug (*atapi_debug_ptr) # define atapi_request_wait (*atapi_request_wait_ptr) # define atapi_request_callback (*atapi_request_callback_ptr) # define atapi_request_immediate (*atapi_request_immediate_ptr) #endif #ifndef ATAPI_MODULE int atapi_attach (int ctlr, int unit, int port); #endif /* * These "functions" are declared with archaic `extern's because they are * actually pointers in the !ATAPI_STATIC case. */ extern int atapi_start (int ctrlr); extern int atapi_intr (int ctrlr); extern void atapi_debug (struct atapi *ata, int on); extern struct atapires atapi_request_wait (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count); extern void atapi_request_callback (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count, atapi_callback_t *done, void *x, void *y); extern struct atapires atapi_request_immediate (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count); #endif diff --git a/sys/i386/isa/wcd.c b/sys/i386/isa/wcd.c index d58640b1f843..8c7075036162 100644 --- a/sys/i386/isa/wcd.c +++ b/sys/i386/isa/wcd.c @@ -1,1381 +1,1381 @@ /* * IDE CD-ROM driver for FreeBSD. * Supports ATAPI-compatible drives. * * Copyright (C) 1995 Cronyx Ltd. * Author Serge Vakulenko, * * This software is distributed with NO WARRANTIES, not even the implied * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Authors grant any other persons or organisations permission to use * or modify this software as long as this message is kept with the software, * all derivative works or modified versions. * * From: Version 1.9, Mon Oct 9 20:27:42 MSK 1995 - * $Id: wcd.c,v 1.56 1998/06/26 18:13:57 phk Exp $ + * $Id: wcd.c,v 1.57 1998/07/04 22:30:18 julian Exp $ */ #include "wdc.h" #include "wcd.h" #include "opt_atapi.h" #include "opt_devfs.h" #if NWCD > 0 && NWDC > 0 && defined (ATAPI) #include #include #include #include #include #include #include #include #include #include #ifdef DEVFS #include #endif /*DEVFS*/ #include static d_open_t wcdopen; static d_read_t wcdread; static d_close_t wcdclose; static d_ioctl_t wcdioctl; static d_strategy_t wcdstrategy; #define CDEV_MAJOR 69 #define BDEV_MAJOR 19 static struct cdevsw wcd_cdevsw = { wcdopen, wcdclose, wcdread, nowrite, /*69*/ wcdioctl, nostop, nullreset, nodevtotty,/* atapi */ seltrue, nommap, wcdstrategy, "wcd", NULL, -1, nodump, nopsize, D_DISK, 0, -1 }; #ifndef ATAPI_STATIC static #endif int wcdattach(struct atapi*, int, struct atapi_params*, int); #define NUNIT 16 /* Max. number of devices */ #define SECSIZE 2048 /* CD-ROM sector size in bytes */ #define F_BOPEN 0x0001 /* The block device is opened */ #define F_MEDIA_CHANGED 0x0002 /* The media have changed since open */ #define F_DEBUG 0x0004 /* Print debug info */ #define F_LOCKED 0x0008 /* This unit is locked (or should be) */ /* * Disc table of contents. */ #define MAXTRK 99 struct toc { struct ioc_toc_header hdr; struct cd_toc_entry tab[MAXTRK+1]; /* One extra for the leadout */ }; /* * Volume size info. */ struct volinfo { u_long volsize; /* Volume size in blocks */ u_long blksize; /* Block size in bytes */ }; /* * Current subchannel status. */ struct subchan { u_char void0; u_char audio_status; u_short data_length; u_char data_format; u_char control; u_char track; u_char indx; u_long abslba; u_long rellba; }; /* * Audio Control Parameters Page */ struct audiopage { /* Mode data header */ u_short data_length; u_char medium_type; u_char reserved1[5]; /* Audio control page */ u_char page_code; #define AUDIO_PAGE 0x0e #define AUDIO_PAGE_MASK 0x4e /* changeable values */ u_char param_len; u_char flags; #define CD_PA_SOTC 0x02 /* mandatory */ #define CD_PA_IMMED 0x04 /* always 1 */ u_char reserved3[3]; u_short lb_per_sec; struct port_control { u_char channels : 4; #define CHANNEL_0 1 /* mandatory */ #define CHANNEL_1 2 /* mandatory */ #define CHANNEL_2 4 /* optional */ #define CHANNEL_3 8 /* optional */ u_char volume; } port[4]; }; /* * CD-ROM Capabilities and Mechanical Status Page */ struct cappage { /* Mode data header */ u_short data_length; u_char medium_type; #define MDT_UNKNOWN 0x00 #define MDT_DATA_120 0x01 #define MDT_AUDIO_120 0x02 #define MDT_COMB_120 0x03 #define MDT_PHOTO_120 0x04 #define MDT_DATA_80 0x05 #define MDT_AUDIO_80 0x06 #define MDT_COMB_80 0x07 #define MDT_PHOTO_80 0x08 #define MDT_NO_DISC 0x70 #define MDT_DOOR_OPEN 0x71 #define MDT_FMT_ERROR 0x72 u_char reserved1[5]; /* Capabilities page */ u_char page_code; #define CAP_PAGE 0x2a u_char param_len; u_char reserved2[2]; u_int audio_play : 1; /* audio play supported */ u_int composite : 1; /* composite audio/video supported */ u_int dport1 : 1; /* digital audio on port 1 */ u_int dport2 : 1; /* digital audio on port 2 */ u_int mode2_form1 : 1; /* mode 2 form 1 (XA) read */ u_int mode2_form2 : 1; /* mode 2 form 2 format */ u_int multisession : 1; /* multi-session photo-CD */ u_int : 1; u_int cd_da : 1; /* audio-CD read supported */ u_int cd_da_stream : 1; /* CD-DA streaming */ u_int rw : 1; /* combined R-W subchannels */ u_int rw_corr : 1; /* R-W subchannel data corrected */ u_int c2 : 1; /* C2 error pointers supported */ u_int isrc : 1; /* can return the ISRC info */ u_int upc : 1; /* can return the catalog number UPC */ u_int : 1; u_int lock : 1; /* could be locked */ u_int locked : 1; /* current lock state */ u_int prevent : 1; /* prevent jumper installed */ u_int eject : 1; /* can eject */ u_int : 1; u_int mech : 3; /* loading mechanism type */ #define MECH_CADDY 0 #define MECH_TRAY 1 #define MECH_POPUP 2 #define MECH_CHANGER 4 #define MECH_CARTRIDGE 5 u_int sep_vol : 1; /* independent volume of channels */ u_int sep_mute : 1; /* independent mute of channels */ u_int : 6; u_short max_speed; /* max raw data rate in bytes/1000 */ u_short max_vol_levels; /* number of discrete volume levels */ u_short buf_size; /* internal buffer size in bytes/1024 */ u_short cur_speed; /* current data rate in bytes/1000 */ /* Digital drive output format description (optional?) */ u_char reserved3; u_int bckf : 1; /* data valid on failing edge of BCK */ u_int rch : 1; /* high LRCK indicates left channel */ u_int lsbf : 1; /* set if LSB first */ u_int dlen: 2; #define DLEN_32 0 /* 32 BCKs */ #define DLEN_16 1 /* 16 BCKs */ #define DLEN_24 2 /* 24 BCKs */ #define DLEN_24_I2S 3 /* 24 BCKs (I2S) */ u_int : 3; u_char reserved4[2]; }; /* * CDROM changer mechanism status structure */ struct changer { u_int current_slot : 5; /* active changer slot */ u_int mech_state : 2; /* current changer state */ #define CH_READY 0 #define CH_LOADING 1 #define CH_UNLOADING 2 #define CH_INITIALIZING 3 u_int fault : 1; /* fault in last operation */ u_int reserved0 : 5; u_int cd_state : 3; /* current mechanism state */ #define CD_IDLE 0 #define CD_AUDIO_ACTIVE 1 #define CD_AUDIO_SCAN 2 #define CD_HOST_ACTIVE 3 #define CD_NO_STATE 7 u_char current_lba[3]; /* current LBA */ u_char slots; /* number of available slots */ u_short table_length; /* slot table length */ struct { u_int changed : 1; /* media has changed in this slot */ u_int unused : 6; u_int present : 1; /* slot has a CD present */ u_char reserved0; u_char reserved1; u_char reserved2; } slot[32]; }; struct wcd { struct atapi *ata; /* Controller structure */ int unit; /* IDE bus drive unit */ int lun; /* Logical device unit */ int flags; /* Device state flags */ int refcnt; /* The number of raw opens */ struct buf_queue_head buf_queue;/* Queue of i/o requests */ struct atapi_params *param; /* Drive parameters table */ struct toc toc; /* Table of disc contents */ struct volinfo info; /* Volume size info */ struct audiopage au; /* Audio page info */ struct cappage cap; /* Capabilities page info */ struct audiopage aumask; /* Audio page mask */ struct subchan subchan; /* Subchannel info */ char description[80]; /* Device description */ struct changer *changer_info; /* changer info */ int slot; /* this lun's slot number */ #ifdef DEVFS void *ra_devfs_token; void *rc_devfs_token; void *a_devfs_token; void *c_devfs_token; #endif }; static struct wcd *wcdtab[NUNIT]; /* Drive info by unit number */ static int wcdnlun = 0; /* Number of configured drives */ static struct wcd *wcd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun); static void wcd_start (struct wcd *t); static void wcd_done (struct wcd *t, struct buf *bp, int resid, struct atapires result); static void wcd_error (struct wcd *t, struct atapires result); static int wcd_read_toc (struct wcd *t); static int wcd_request_wait (struct wcd *t, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, char *addr, int count); static void wcd_describe (struct wcd *t); static int wcd_setchan (struct wcd *t, u_char c0, u_char c1, u_char c2, u_char c3); static int wcd_eject (struct wcd *t, int closeit); static void wcd_select_slot(struct wcd *cdp); /* * Dump the array in hexadecimal format for debugging purposes. */ static void wcd_dump (int lun, char *label, void *data, int len) { u_char *p = data; printf ("wcd%d: %s %x", lun, label, *p++); while (--len > 0) printf ("-%x", *p++); printf ("\n"); } struct wcd * wcd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun) { struct wcd *ptr; ptr = malloc(sizeof(struct wcd), M_TEMP, M_NOWAIT); if (!ptr) return NULL; bzero(ptr, sizeof(struct wcd)); bufq_init(&ptr->buf_queue); ptr->ata = ata; ptr->unit = unit; ptr->lun = lun; ptr->param = ap; ptr->flags = F_MEDIA_CHANGED; ptr->refcnt = 0; ptr->slot = -1; ptr->changer_info = NULL; #ifdef DEVFS ptr->ra_devfs_token = devfs_add_devswf(&wcd_cdevsw, dkmakeminor(lun, 0, 0), DV_CHR, UID_ROOT, GID_OPERATOR, 0640, "rwcd%da", lun); ptr->rc_devfs_token = devfs_add_devswf(&wcd_cdevsw, dkmakeminor(lun, 0, RAW_PART), DV_CHR, UID_ROOT, GID_OPERATOR, 0640, "rwcd%dc", lun); ptr->a_devfs_token = devfs_add_devswf(&wcd_cdevsw, dkmakeminor(lun, 0, 0), DV_BLK, UID_ROOT, GID_OPERATOR, 0640, "wcd%da", lun); ptr->c_devfs_token = devfs_add_devswf(&wcd_cdevsw, dkmakeminor(lun, 0, RAW_PART), DV_BLK, UID_ROOT, GID_OPERATOR, 0640, "wcd%dc", lun); #endif return ptr; } #ifndef ATAPI_STATIC static #endif int wcdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug) { struct wcd *cdp; struct atapires result; struct changer *chp; int i; if (wcdnlun >= NUNIT) { printf ("wcd: too many units\n"); return (0); } if (!atapi_request_immediate) { printf("wcd: configuration error, ATAPI core code not present!\n"); printf("wcd: check `options ATAPI_STATIC' in your kernel config file!\n"); return (0); } if ((cdp = wcd_init_lun(ata, unit, ap, wcdnlun)) == NULL) { printf("wcd: out of memory\n"); return 0; } wcdtab[wcdnlun] = cdp; if (debug) { cdp->flags |= F_DEBUG; /* Print params. */ wcd_dump (cdp->lun, "info", ap, sizeof *ap); } /* Get drive capabilities. */ result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE, 0, CAP_PAGE, 0, 0, 0, 0, sizeof (cdp->cap) >> 8, sizeof (cdp->cap), 0, 0, 0, 0, 0, 0, 0, (char*) &cdp->cap, sizeof (cdp->cap)); /* Do it twice to avoid the stale media changed state. */ if (result.code == RES_ERR && (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION) result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE, 0, CAP_PAGE, 0, 0, 0, 0, sizeof (cdp->cap) >> 8, sizeof (cdp->cap), 0, 0, 0, 0, 0, 0, 0, (char*) &cdp->cap, sizeof (cdp->cap)); /* Some drives have shorter capabilities page. */ if (result.code == RES_UNDERRUN) result.code = 0; if (result.code == 0) { wcd_describe (cdp); if (cdp->flags & F_DEBUG) wcd_dump (cdp->lun, "cap", &cdp->cap, sizeof(cdp->cap)); } /* If this is a changer device, allocate the neeeded lun's */ if (cdp->cap.mech == MECH_CHANGER) { chp = malloc(sizeof(struct changer), M_TEMP, M_NOWAIT); if (chp == NULL) { printf("wcd: out of memory\n"); return 0; } bzero(chp, sizeof(struct changer)); result = atapi_request_immediate(ata, unit, ATAPI_MECH_STATUS, 0, 0, 0, 0, 0, 0, 0, sizeof(struct changer)> 8, sizeof(struct changer), 0, 0, 0, 0, 0, 0, (char*) chp, sizeof(struct changer)); if (cdp->flags & F_DEBUG) { printf("result.code=%d curr=%02x slots=%d len=%d\n", result.code, chp->current_slot, chp->slots, htons(chp->table_length)); } if (result.code == RES_UNDERRUN) result.code = 0; if (result.code == 0) { chp->table_length = htons(chp->table_length); for (i=0; islots && wcdnlun0) { cdp = wcd_init_lun(ata,unit,ap,wcdnlun); if (cdp == NULL) { printf("wcd: out of memory\n"); return 0; } } cdp->slot = i; cdp->changer_info = chp; printf("wcd%d: changer slot %d %s\n", wcdnlun, i, (chp->slot[i].present ? "disk present" : "no disk")); wcdtab[wcdnlun++] = cdp; } if (wcdnlun >= NUNIT) { printf ("wcd: too many units\n"); return (0); } } } else wcdnlun++; return (1); } void wcd_describe (struct wcd *t) { char *m; t->cap.max_speed = ntohs (t->cap.max_speed); t->cap.max_vol_levels = ntohs (t->cap.max_vol_levels); t->cap.buf_size = ntohs (t->cap.buf_size); t->cap.cur_speed = ntohs (t->cap.cur_speed); printf ("wcd%d: ", t->lun); if (t->cap.cur_speed != t->cap.max_speed) printf ("%d/", t->cap.cur_speed * 1000 / 1024); printf ("%dKb/sec", t->cap.max_speed * 1000 / 1024); if (t->cap.buf_size) printf (", %dKb cache", t->cap.buf_size); if (t->cap.audio_play) printf (", audio play"); if (t->cap.max_vol_levels) printf (", %d volume levels", t->cap.max_vol_levels); switch (t->cap.mech) { default: m = 0; break; case MECH_CADDY: m = "caddy"; break; case MECH_TRAY: m = "tray"; break; case MECH_POPUP: m = "popup"; break; case MECH_CHANGER: m = "changer"; break; case MECH_CARTRIDGE: m = "cartridge"; break; } if (m) printf (", %s%s", t->cap.eject ? "ejectable " : "", m); else if (t->cap.eject) printf (", eject"); printf ("\n"); if (t->cap.mech != MECH_CHANGER) { printf ("wcd%d: ", t->lun); switch (t->cap.medium_type) { case MDT_UNKNOWN: printf ("medium type unknown"); break; case MDT_DATA_120: printf ("120mm data disc loaded"); break; case MDT_AUDIO_120: printf ("120mm audio disc loaded"); break; case MDT_COMB_120: printf ("120mm data/audio disc loaded"); break; case MDT_PHOTO_120: printf ("120mm photo disc loaded"); break; case MDT_DATA_80: printf ("80mm data disc loaded"); break; case MDT_AUDIO_80: printf ("80mm audio disc loaded"); break; case MDT_COMB_80: printf ("80mm data/audio disc loaded"); break; case MDT_PHOTO_80: printf ("80mm photo disc loaded"); break; case MDT_NO_DISC: printf ("no disc inside"); break; case MDT_DOOR_OPEN: printf ("door open"); break; case MDT_FMT_ERROR: printf ("medium format error"); break; default: printf ("medium type=0x%x", t->cap.medium_type); break; } } if (t->cap.lock) printf (t->cap.locked ? ", locked" : ", unlocked"); if (t->cap.prevent) printf (", lock protected"); printf ("\n"); } static int wcdopen (dev_t dev, int flags, int fmt, struct proc *p) { int lun = dkunit(dev); struct wcd *t; /* Check device number is legal and ATAPI driver is loaded. */ if (lun >= wcdnlun || ! atapi_request_immediate) return (ENXIO); t = wcdtab[lun]; /* On the first open, read the table of contents. */ if (! (t->flags & F_BOPEN) && ! t->refcnt) { /* Read table of contents. */ if (wcd_read_toc (t) < 0) return (EIO); /* Lock the media. */ wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); t->flags |= F_LOCKED; } if (fmt == S_IFCHR) ++t->refcnt; else t->flags |= F_BOPEN; return (0); } /* * Close the device. Only called if we are the LAST * occurence of an open device. */ static int wcdclose (dev_t dev, int flags, int fmt, struct proc *p) { int lun = dkunit(dev); struct wcd *t = wcdtab[lun]; if (fmt == S_IFBLK) { /* If we were the last open of the entire device, release it. */ if (! t->refcnt) wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); t->flags &= ~(F_BOPEN|F_LOCKED); } else { /* If we were the last open of the entire device, release it. */ if (! (t->flags & F_BOPEN) && t->refcnt == 1) wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); t->flags &= ~F_LOCKED; --t->refcnt; } return (0); } static int wcdread(dev_t dev, struct uio *uio, int ioflag) { return (physio(wcdstrategy, NULL, dev, 1, minphys, uio)); } /* * Actually translate the requested transfer into one the physical driver can * understand. The transfer is described by a buf and will include only one * physical transfer. */ void wcdstrategy (struct buf *bp) { int lun = dkunit(bp->b_dev); struct wcd *t = wcdtab[lun]; int x; /* Can't ever write to a CD. */ if (! (bp->b_flags & B_READ)) { bp->b_error = EROFS; bp->b_flags |= B_ERROR; biodone (bp); return; } /* If it's a null transfer, return immediatly. */ if (bp->b_bcount == 0) { bp->b_resid = 0; biodone (bp); return; } /* Process transfer request. */ bp->b_pblkno = bp->b_blkno; bp->b_resid = bp->b_bcount; x = splbio(); /* Place it in the queue of disk activities for this disk. */ bufqdisksort (&t->buf_queue, bp); /* Tell the device to get going on the transfer if it's * not doing anything, otherwise just wait for completion. */ wcd_start (t); splx(x); } /* * Look to see if there is a buf waiting for the device * and that the device is not already busy. If both are true, * It dequeues the buf and creates an ATAPI command to perform the * transfer in the buf. * The bufs are queued by the strategy routine (wcdstrategy). * Must be called at the correct (splbio) level. */ static void wcd_start (struct wcd *t) { struct buf *bp = bufq_first(&t->buf_queue); u_long blkno, nblk; /* See if there is a buf to do and we are not already doing one. */ if (! bp) return; /* Unqueue the request. */ bufq_remove(&t->buf_queue, bp); /* Should reject all queued entries if media have changed. */ if (t->flags & F_MEDIA_CHANGED) { bp->b_error = EIO; bp->b_flags |= B_ERROR; biodone (bp); return; } wcd_select_slot(t); /* We have a buf, now we should make a command * First, translate the block to absolute and put it in terms of the * logical blocksize of the device. * What if something asks for 512 bytes not on a 2k boundary? */ blkno = bp->b_blkno / (SECSIZE / 512); nblk = (bp->b_bcount + (SECSIZE - 1)) / SECSIZE; atapi_request_callback (t->ata, t->unit, ATAPI_READ_BIG, 0, blkno>>24, blkno>>16, blkno>>8, blkno, 0, nblk>>8, nblk, 0, 0, 0, 0, 0, 0, 0, (u_char*) bp->b_data, bp->b_bcount, wcd_done, t, bp); } static void wcd_done (struct wcd *t, struct buf *bp, int resid, struct atapires result) { if (result.code) { wcd_error (t, result); bp->b_error = EIO; bp->b_flags |= B_ERROR; } else bp->b_resid = resid; biodone (bp); wcd_start (t); } static void wcd_error (struct wcd *t, struct atapires result) { if (result.code != RES_ERR) return; switch (result.error & AER_SKEY) { case AER_SK_NOT_READY: if (result.error & ~AER_SKEY) { /* Audio disc. */ printf ("wcd%d: cannot read audio disc\n", t->lun); return; } /* Tray open. */ if (! (t->flags & F_MEDIA_CHANGED)) printf ("wcd%d: tray open\n", t->lun); t->flags |= F_MEDIA_CHANGED; return; case AER_SK_UNIT_ATTENTION: /* Media changed. */ if (! (t->flags & F_MEDIA_CHANGED)) printf ("wcd%d: media changed\n", t->lun); t->flags |= F_MEDIA_CHANGED; return; case AER_SK_ILLEGAL_REQUEST: /* Unknown command or invalid command arguments. */ if (t->flags & F_DEBUG) printf ("wcd%d: invalid command\n", t->lun); return; } printf ("wcd%d: i/o error, status=%b, error=%b\n", t->lun, result.status, ARS_BITS, result.error, AER_BITS); } static int wcd_request_wait (struct wcd *t, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, char *addr, int count) { struct atapires result; result = atapi_request_wait (t->ata, t->unit, cmd, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0, 0, 0, 0, 0, 0, addr, count); if (result.code) { wcd_error (t, result); return (EIO); } return (0); } static __inline void lba2msf (int lba, u_char *m, u_char *s, u_char *f) { lba += 150; /* offset of first logical frame */ lba &= 0xffffff; /* negative lbas use only 24 bits */ *m = lba / (60 * 75); lba %= (60 * 75); *s = lba / 75; *f = lba % 75; } /* * Perform special action on behalf of the user. * Knows about the internals of this device */ int wcdioctl (dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) { int lun = dkunit(dev); struct wcd *t = wcdtab[lun]; int error = 0; if (t->flags & F_MEDIA_CHANGED) switch (cmd) { case CDIOCSETDEBUG: case CDIOCCLRDEBUG: case CDIOCRESET: /* These ops are media change transparent. */ break; default: /* Read table of contents. */ wcd_read_toc (t); /* Lock the media. */ wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); t->flags |= F_LOCKED; break; } switch (cmd) { default: return (ENOTTY); case CDIOCSETDEBUG: if (p->p_cred->pc_ucred->cr_uid) return (EPERM); t->flags |= F_DEBUG; atapi_debug (t->ata, 1); return 0; case CDIOCCLRDEBUG: if (p->p_cred->pc_ucred->cr_uid) return (EPERM); t->flags &= ~F_DEBUG; atapi_debug (t->ata, 0); return 0; case CDIOCRESUME: return wcd_request_wait (t, ATAPI_PAUSE, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0); case CDIOCPAUSE: return wcd_request_wait (t, ATAPI_PAUSE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); case CDIOCSTART: return wcd_request_wait (t, ATAPI_START_STOP, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); case CDIOCSTOP: return wcd_request_wait (t, ATAPI_START_STOP, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); case CDIOCALLOW: wcd_select_slot(t); t->flags &= ~F_LOCKED; return wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); case CDIOCPREVENT: wcd_select_slot(t); t->flags |= F_LOCKED; return wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); case CDIOCRESET: if (p->p_cred->pc_ucred->cr_uid) return (EPERM); return wcd_request_wait (t, ATAPI_TEST_UNIT_READY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); case CDIOCEJECT: /* Don't allow eject if the device is opened * by somebody (not us) in block mode. */ if ((t->flags & F_BOPEN) && t->refcnt) return (EBUSY); return wcd_eject (t, 0); case CDIOCCLOSE: if ((t->flags & F_BOPEN) && t->refcnt) return (0); return wcd_eject (t, 1); case CDIOREADTOCHEADER: if (! t->toc.hdr.ending_track) return (EIO); bcopy (&t->toc.hdr, addr, sizeof t->toc.hdr); break; case CDIOREADTOCENTRYS: { struct ioc_read_toc_entry *te = (struct ioc_read_toc_entry*) addr; struct toc *toc = &t->toc; struct toc buf; u_long len; u_char starting_track = te->starting_track; if (! t->toc.hdr.ending_track) return (EIO); if ( te->data_len < sizeof(toc->tab[0]) || (te->data_len % sizeof(toc->tab[0])) != 0 || te->address_format != CD_MSF_FORMAT && te->address_format != CD_LBA_FORMAT ) return EINVAL; if (starting_track == 0) starting_track = toc->hdr.starting_track; else if (starting_track == 170) /* Handle leadout request */ starting_track = toc->hdr.ending_track + 1; else if (starting_track < toc->hdr.starting_track || starting_track > toc->hdr.ending_track + 1) return (EINVAL); len = ((toc->hdr.ending_track + 1 - starting_track) + 1) * sizeof(toc->tab[0]); if (te->data_len < len) len = te->data_len; if (len > sizeof(toc->tab)) return EINVAL; /* Convert to MSF format, if needed. */ if (te->address_format == CD_MSF_FORMAT) { struct cd_toc_entry *e; buf = t->toc; toc = &buf; e = toc->tab + (toc->hdr.ending_track + 1 - toc->hdr.starting_track) + 1; while (--e >= toc->tab) lba2msf (ntohl(e->addr.lba), &e->addr.msf.minute, &e->addr.msf.second, &e->addr.msf.frame); } return copyout (toc->tab + starting_track - toc->hdr.starting_track, te->data, len); } case CDIOREADTOCENTRY: { struct ioc_read_toc_single_entry *te = (struct ioc_read_toc_single_entry*) addr; struct toc *toc = &t->toc; struct toc buf; u_char track = te->track; if (! t->toc.hdr.ending_track) return (EIO); if (te->address_format != CD_MSF_FORMAT && te->address_format != CD_LBA_FORMAT) return EINVAL; if (track == 0) track = toc->hdr.starting_track; else if (track == 170) /* Handle leadout request */ track = toc->hdr.ending_track + 1; else if (track < toc->hdr.starting_track || track > toc->hdr.ending_track + 1) return (EINVAL); /* Convert to MSF format, if needed. */ if (te->address_format == CD_MSF_FORMAT) { struct cd_toc_entry *e; buf = t->toc; toc = &buf; e = toc->tab + (track - toc->hdr.starting_track); lba2msf (ntohl(e->addr.lba), &e->addr.msf.minute, &e->addr.msf.second, &e->addr.msf.frame); } bcopy(toc->tab + track - toc->hdr.starting_track, &te->entry, sizeof(struct cd_toc_entry)); } case CDIOCREADSUBCHANNEL: { struct ioc_read_subchannel *args = (struct ioc_read_subchannel*) addr; struct cd_sub_channel_info data; u_long len = args->data_len; int abslba, rellba; if (len > sizeof(data) || len < sizeof(struct cd_sub_channel_header)) return (EINVAL); if (wcd_request_wait (t, ATAPI_READ_SUBCHANNEL, 0, 0x40, 1, 0, 0, 0, sizeof (t->subchan) >> 8, sizeof (t->subchan), 0, (char*)&t->subchan, sizeof (t->subchan)) != 0) return (EIO); if (t->flags & F_DEBUG) wcd_dump (t->lun, "subchan", &t->subchan, sizeof t->subchan); abslba = t->subchan.abslba; rellba = t->subchan.rellba; if (args->address_format == CD_MSF_FORMAT) { lba2msf (ntohl(abslba), &data.what.position.absaddr.msf.minute, &data.what.position.absaddr.msf.second, &data.what.position.absaddr.msf.frame); lba2msf (ntohl(rellba), &data.what.position.reladdr.msf.minute, &data.what.position.reladdr.msf.second, &data.what.position.reladdr.msf.frame); } else { data.what.position.absaddr.lba = abslba; data.what.position.reladdr.lba = rellba; } data.header.audio_status = t->subchan.audio_status; data.what.position.control = t->subchan.control & 0xf; data.what.position.addr_type = t->subchan.control >> 4; data.what.position.track_number = t->subchan.track; data.what.position.index_number = t->subchan.indx; return copyout (&data, args->data, len); } case CDIOCPLAYMSF: { struct ioc_play_msf *args = (struct ioc_play_msf*) addr; return wcd_request_wait (t, ATAPI_PLAY_MSF, 0, 0, args->start_m, args->start_s, args->start_f, args->end_m, args->end_s, args->end_f, 0, 0, 0); } case CDIOCPLAYBLOCKS: { struct ioc_play_blocks *args = (struct ioc_play_blocks*) addr; return wcd_request_wait (t, ATAPI_PLAY_BIG, 0, args->blk >> 24 & 0xff, args->blk >> 16 & 0xff, args->blk >> 8 & 0xff, args->blk & 0xff, args->len >> 24 & 0xff, args->len >> 16 & 0xff, args->len >> 8 & 0xff, args->len & 0xff, 0, 0); } case CDIOCPLAYTRACKS: { struct ioc_play_track *args = (struct ioc_play_track*) addr; u_long start, len; int t1, t2; if (! t->toc.hdr.ending_track) return (EIO); /* Ignore index fields, * play from start_track to end_track inclusive. */ if (args->end_track < t->toc.hdr.ending_track+1) ++args->end_track; if (args->end_track > t->toc.hdr.ending_track+1) args->end_track = t->toc.hdr.ending_track+1; t1 = args->start_track - t->toc.hdr.starting_track; t2 = args->end_track - t->toc.hdr.starting_track; if (t1 < 0 || t2 < 0) return (EINVAL); start = ntohl(t->toc.tab[t1].addr.lba); len = ntohl(t->toc.tab[t2].addr.lba) - start; return wcd_request_wait (t, ATAPI_PLAY_BIG, 0, start >> 24 & 0xff, start >> 16 & 0xff, start >> 8 & 0xff, start & 0xff, len >> 24 & 0xff, len >> 16 & 0xff, len >> 8 & 0xff, len & 0xff, 0, 0); } case CDIOCGETVOL: { struct ioc_vol *arg = (struct ioc_vol*) addr; error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0, AUDIO_PAGE, 0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0, (char*) &t->au, sizeof (t->au)); if (error) return (error); if (t->flags & F_DEBUG) wcd_dump (t->lun, "au", &t->au, sizeof t->au); if (t->au.page_code != AUDIO_PAGE) return (EIO); arg->vol[0] = t->au.port[0].volume; arg->vol[1] = t->au.port[1].volume; arg->vol[2] = t->au.port[2].volume; arg->vol[3] = t->au.port[3].volume; break; } case CDIOCSETVOL: { struct ioc_vol *arg = (struct ioc_vol*) addr; error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0, AUDIO_PAGE, 0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0, (char*) &t->au, sizeof (t->au)); if (error) return (error); if (t->flags & F_DEBUG) wcd_dump (t->lun, "au", &t->au, sizeof t->au); if (t->au.page_code != AUDIO_PAGE) return (EIO); error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0, AUDIO_PAGE_MASK, 0, 0, 0, 0, sizeof (t->aumask) >> 8, sizeof (t->aumask), 0, (char*) &t->aumask, sizeof (t->aumask)); if (error) return (error); if (t->flags & F_DEBUG) wcd_dump (t->lun, "mask", &t->aumask, sizeof t->aumask); /* Sony-55E requires the data length field to be zeroed. */ t->au.data_length = 0; t->au.port[0].channels = CHANNEL_0; t->au.port[1].channels = CHANNEL_1; t->au.port[0].volume = arg->vol[0] & t->aumask.port[0].volume; t->au.port[1].volume = arg->vol[1] & t->aumask.port[1].volume; t->au.port[2].volume = arg->vol[2] & t->aumask.port[2].volume; t->au.port[3].volume = arg->vol[3] & t->aumask.port[3].volume; - return wcd_request_wait (t, ATAPI_MODE_SELECT_BIG, 0x10, + return wcd_request_wait (t, ATAPI_MODE_SELECT, 0x10, 0, 0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0, (char*) &t->au, - sizeof (t->au)); } case CDIOCSETPATCH: { struct ioc_patch *arg = (struct ioc_patch*) addr; return wcd_setchan (t, arg->patch[0], arg->patch[1], arg->patch[2], arg->patch[3]); } case CDIOCSETMONO: return wcd_setchan (t, CHANNEL_0 | CHANNEL_1, CHANNEL_0 | CHANNEL_1, 0, 0); case CDIOCSETSTERIO: return wcd_setchan (t, CHANNEL_0, CHANNEL_1, 0, 0); case CDIOCSETMUTE: return wcd_setchan (t, 0, 0, 0, 0); case CDIOCSETLEFT: return wcd_setchan (t, CHANNEL_0, CHANNEL_0, 0, 0); case CDIOCSETRIGHT: return wcd_setchan (t, CHANNEL_1, CHANNEL_1, 0, 0); } return (error); } /* * Read the entire TOC for the disc into our internal buffer. */ static int wcd_read_toc (struct wcd *t) { int ntracks, len; struct atapires result; bzero (&t->toc, sizeof (t->toc)); bzero (&t->info, sizeof (t->info)); wcd_select_slot(t); /* Check for the media. * Do it twice to avoid the stale media changed state. */ result = atapi_request_wait (t->ata, t->unit, ATAPI_TEST_UNIT_READY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (result.code == RES_ERR && (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION) { t->flags |= F_MEDIA_CHANGED; result = atapi_request_wait (t->ata, t->unit, ATAPI_TEST_UNIT_READY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } if (result.code) { wcd_error (t, result); return (EIO); } t->flags &= ~F_MEDIA_CHANGED; /* First read just the header, so we know how long the TOC is. */ len = sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry); if (wcd_request_wait (t, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0, (char*)&t->toc, len) != 0) { err: bzero (&t->toc, sizeof (t->toc)); return (0); } ntracks = t->toc.hdr.ending_track - t->toc.hdr.starting_track + 1; if (ntracks <= 0 || ntracks > MAXTRK) goto err; /* Now read the whole schmeer. */ len = sizeof(struct ioc_toc_header) + ntracks * sizeof(struct cd_toc_entry); if (wcd_request_wait (t, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0, (char*)&t->toc, len) & 0xff) goto err; NTOHS(t->toc.hdr.len); /* Read disc capacity. */ if (wcd_request_wait (t, ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, sizeof(t->info), 0, (char*)&t->info, sizeof(t->info)) != 0) bzero (&t->info, sizeof (t->info)); /* make fake leadout entry */ t->toc.tab[ntracks].control = t->toc.tab[ntracks-1].control; t->toc.tab[ntracks].addr_type = t->toc.tab[ntracks-1].addr_type; t->toc.tab[ntracks].track = 170; /* magic */ t->toc.tab[ntracks].addr.lba = t->info.volsize; NTOHL(t->info.volsize); NTOHL(t->info.blksize); /* Print the disc description string on every disc change. * It would help to track the history of disc changes. */ if (t->info.volsize && t->toc.hdr.ending_track && (t->flags & F_MEDIA_CHANGED) && (t->flags & F_DEBUG)) { printf ("wcd%d: ", t->lun); if (t->toc.tab[0].control & 4) printf ("%ldMB ", t->info.volsize / 512); else printf ("%ld:%ld audio ", t->info.volsize/75/60, t->info.volsize/75%60); printf ("(%ld sectors), %d tracks\n", t->info.volsize, t->toc.hdr.ending_track - t->toc.hdr.starting_track + 1); } return (0); } /* * Set up the audio channel masks. */ static int wcd_setchan (struct wcd *t, u_char c0, u_char c1, u_char c2, u_char c3) { int error; error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0, AUDIO_PAGE, 0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0, (char*) &t->au, sizeof (t->au)); if (error) return (error); if (t->flags & F_DEBUG) wcd_dump (t->lun, "au", &t->au, sizeof t->au); if (t->au.page_code != AUDIO_PAGE) return (EIO); /* Sony-55E requires the data length field to be zeroed. */ t->au.data_length = 0; t->au.port[0].channels = c0; t->au.port[1].channels = c1; t->au.port[2].channels = c2; t->au.port[3].channels = c3; - return wcd_request_wait (t, ATAPI_MODE_SELECT_BIG, 0x10, + return wcd_request_wait (t, ATAPI_MODE_SELECT, 0x10, 0, 0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0, (char*) &t->au, - sizeof (t->au)); } static int wcd_eject (struct wcd *t, int closeit) { struct atapires result; wcd_select_slot(t); /* Try to stop the disc. */ result = atapi_request_wait (t->ata, t->unit, ATAPI_START_STOP, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (result.code == RES_ERR && ((result.error & AER_SKEY) == AER_SK_NOT_READY || (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) { int err; if (!closeit) return (0); /* * The disc was unloaded. * Load it (close tray). * Read the table of contents. */ err = wcd_request_wait (t, ATAPI_START_STOP, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0); if (err) return (err); /* Read table of contents. */ wcd_read_toc (t); /* Lock the media. */ wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); t->flags |= F_LOCKED; return (0); } if (result.code) { wcd_error (t, result); return (EIO); } if (closeit) return (0); /* Give it some time to stop spinning. */ tsleep ((caddr_t)&lbolt, PRIBIO, "wcdej1", 0); tsleep ((caddr_t)&lbolt, PRIBIO, "wcdej2", 0); /* Unlock. */ wcd_request_wait (t, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); t->flags &= ~F_LOCKED; /* Eject. */ t->flags |= F_MEDIA_CHANGED; return wcd_request_wait (t, ATAPI_START_STOP, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0); } static void wcd_select_slot(struct wcd *cdp) { if (cdp->slot < 0 || cdp->changer_info->current_slot == cdp->slot) return; /* Unlock (might not be needed but its cheaper than asking) */ wcd_request_wait (cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); /* Unload the current media from player */ wcd_request_wait (cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 2, 0, 0, 0, cdp->changer_info->current_slot, 0, 0, 0); /* load the wanted slot */ wcd_request_wait (cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 3, 0, 0, 0, cdp->slot, 0, 0, 0); cdp->changer_info->current_slot = cdp->slot; /* Lock the media if needed */ if (cdp->flags & F_LOCKED) { wcd_request_wait (cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); } } #ifdef WCD_MODULE /* * Loadable ATAPI CD-ROM driver stubs. */ #include #include #include /* * Construct lkm_dev structures (see lkm.h). * Our bdevsw/cdevsw slot numbers are 19/69. */ MOD_DEV(wcd, LM_DT_BLOCK, BDEV_MAJOR, &wcd_cdevsw); MOD_DEV(rwcd, LM_DT_CHAR, CDEV_MAJOR, &wcd_cdevsw); /* * Function called when loading the driver. */ int wcd_load (struct lkm_table *lkmtp, int cmd) { struct atapi *ata; int n, u; if (! atapi_start) /* No ATAPI driver available. */ return EPROTONOSUPPORT; n = 0; for (ata=atapi_tab; ataport) for (u=0; u<2; ++u) /* Probing controller ata->ctrlr, unit u. */ if (ata->params[u] && ! ata->attached[u] && wcdattach (ata, u, ata->params[u], ata->debug) >= 0) { /* Drive found. */ ata->attached[u] = 1; ++n; } if (! n) /* No IDE CD-ROMs found. */ return ENXIO; return 0; } /* * Function called when unloading the driver. */ int wcd_unload (struct lkm_table *lkmtp, int cmd) { struct wcd **t; for (t=wcdtab; tflags & F_BOPEN) || (*t)->refcnt) /* The device is opened, cannot unload the driver. */ return EBUSY; for (t=wcdtab; tata->attached[(*t)->unit] = 0; free (*t, M_TEMP); } wcdnlun = 0; bzero (wcdtab, sizeof(wcdtab)); return 0; } /* * Dispatcher function for the module (load/unload/stat). */ int wcd_mod (struct lkm_table *lkmtp, int cmd, int ver) { int err = 0; if (ver != LKM_VERSION) return EINVAL; if (cmd == LKM_E_LOAD) err = wcd_load (lkmtp, cmd); else if (cmd == LKM_E_UNLOAD) err = wcd_unload (lkmtp, cmd); if (err) return err; /* XXX Poking around in the LKM internals like this is bad. */ /* Register the cdevsw entry. */ lkmtp->private.lkm_dev = & MOD_PRIVATE(rwcd); err = lkmdispatch (lkmtp, cmd); if (err) return err; /* Register the bdevsw entry. */ lkmtp->private.lkm_dev = & MOD_PRIVATE(wcd); return lkmdispatch (lkmtp, cmd); } #endif /* WCD_MODULE */ static wcd_devsw_installed = 0; static void wcd_drvinit(void *unused) { if( ! wcd_devsw_installed ) { cdevsw_add_generic(BDEV_MAJOR, CDEV_MAJOR, &wcd_cdevsw); wcd_devsw_installed = 1; } } SYSINIT(wcddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,wcd_drvinit,NULL) #endif /* NWCD && NWDC && ATAPI */ diff --git a/sys/i386/isa/wd_cd.c b/sys/i386/isa/wd_cd.c new file mode 100644 index 000000000000..46fa888a58cb --- /dev/null +++ b/sys/i386/isa/wd_cd.c @@ -0,0 +1,1588 @@ +/*- + * Copyright (c) 1998 Søren Schmidt + * All rights reserved. + * + * 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, + * without modification, immediately at the beginning of the file. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. + * + * $Id: atapi-cd.c,v 1.2 1998/09/02 08:47:31 sos Exp sos $ + */ + +#include "wdc.h" +#include "acd.h" +#include "opt_atapi.h" +#include "opt_devfs.h" + +#if NACD > 0 && NWDC > 0 && defined(ATAPI) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef DEVFS +#include +#endif +#include +#include + +static d_open_t acdopen; +static d_close_t acdclose; +static d_write_t acdwrite; +static d_read_t acdread; +static d_ioctl_t acdioctl; +static d_strategy_t acdstrategy; + +#define CDEV_MAJOR 69 +#define BDEV_MAJOR 19 +static struct cdevsw acd_cdevsw = { + acdopen, acdclose, acdread, acdwrite, + acdioctl, nostop, nullreset, nodevtotty, + seltrue, nommap, acdstrategy, "acd", + NULL, -1, nodump, nopsize, + D_DISK, 0, -1 +}; + +#define NUNIT 16 /* Max # of devices */ + +#define F_BOPEN 0x0001 /* The block device is opened */ +#define F_MEDIA_CHANGED 0x0002 /* The media have changed since open */ +#define F_DEBUG 0x0004 /* Print debug info */ +#define F_LOCKED 0x0008 /* This unit is locked (or should be) */ +#define F_TRACK_PREP 0x0010 /* Track should be prep'ed */ +#define F_TRACK_PREPED 0x0020 /* Track has been prep'ed */ +#define F_DISK_PREPED 0x0040 /* Disk has been prep'ed */ +#define F_WRITTEN 0x0080 /* The medium has been written to */ + +static struct acd *acdtab[NUNIT]; +static int acdnlun = 0; /* Number of configured drives */ +static u_int next_writeable_lba = 0; + +#ifndef ATAPI_STATIC +static +#endif +int acdattach(struct atapi *, int, struct atapi_params *, int); +static struct acd *acd_init_lun(struct atapi *, int, struct atapi_params *,int); +static void acd_start(struct acd *); +static void acd_done(struct acd *, struct buf *, int, struct atapires); +static int acd_read_toc(struct acd *); +static int acd_request_wait(struct acd *, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, char *, int); +static void acd_describe(struct acd *); +static int acd_open(dev_t, int, int); +static int acd_setchan(struct acd *, u_char, u_char, u_char, u_char); +static int acd_eject(struct acd *, int); +static void acd_select_slot(struct acd *); +static int acd_rezero_unit(struct acd *); +static int acd_open_disk(struct acd *, int); +static int acd_open_track(struct acd *, struct wormio_prepare_track *); +static int acd_close_track(struct acd *); +static int acd_close_disk(struct acd *); +static int acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info); +static int acd_blank_disk(struct acd *); +static void atapi_dump(int ctrlr, int lun, char *label, void *data, int len); +static void atapi_error(struct atapi *ata, int unit, struct atapires result); + +struct acd * +acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun) +{ + struct acd *ptr; + + if (!(ptr = malloc(sizeof(struct acd), M_TEMP, M_NOWAIT))) + return NULL; + bzero(ptr, sizeof(struct acd)); + bufq_init(&ptr->buf_queue); + ptr->ata = ata; + ptr->unit = unit; + ptr->lun = lun; + ptr->param = ap; + ptr->flags = F_MEDIA_CHANGED; + ptr->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + ptr->block_size = 2048; + ptr->refcnt = 0; + ptr->slot = -1; + ptr->changer_info = NULL; +#ifdef DEVFS + ptr->ra_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, 0), + DV_CHR, UID_ROOT, GID_OPERATOR, 0640, + "racd%da", lun); + ptr->rc_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART), + DV_CHR, UID_ROOT, GID_OPERATOR, 0640, + "racd%dc", lun); + ptr->a_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, 0), + DV_BLK, UID_ROOT, GID_OPERATOR, 0640, + "acd%da", lun); + ptr->c_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART), + DV_BLK, UID_ROOT, GID_OPERATOR, 0640, + "acd%dc", lun); +#endif + return ptr; +} + +#ifndef ATAPI_STATIC +static +#endif +int +acdattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug) +{ + struct acd *cdp; + struct atapires result; + struct changer *chp; + int i, count; + + if (acdnlun >= NUNIT) { + printf("acd: too many units\n"); + return 0; + } + if (!atapi_request_immediate) { + printf("acd: configuration error, ATAPI code not present!\n"); + return 0; + } + if ((cdp = acd_init_lun(ata, unit, ap, acdnlun)) == NULL) { + printf("acd: out of memory\n"); + return 0; + } + acdtab[acdnlun] = cdp; + + if (debug) { + cdp->flags |= F_DEBUG; + atapi_dump(cdp->ata->ctrlr, cdp->lun, "info", ap, sizeof(*ap)); + } + + /* Get drive capabilities, some drives needs this repeated */ + for (count = 0 ; count < 5 ; count++) { + result = atapi_request_immediate(ata, unit, + ATAPI_MODE_SENSE, + 0, ATAPI_CDROM_CAP_PAGE, + 0, 0, 0, 0, + sizeof(cdp->cap)>>8, sizeof(cdp->cap), + 0, 0, 0, 0, 0, 0, 0, + (char *)&cdp->cap, sizeof(cdp->cap)); + if (result.code == 0 || result.code == RES_UNDERRUN) + break; + } + + /* Some drives have shorter capabilities page. */ + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code == 0) { + cdp->cap.max_speed = ntohs(cdp->cap.max_speed); + cdp->cap.max_vol_levels = ntohs(cdp->cap.max_vol_levels); + cdp->cap.buf_size = ntohs(cdp->cap.buf_size); + cdp->cap.cur_speed = ntohs(cdp->cap.cur_speed); + acd_describe(cdp); + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "cap", &cdp->cap, + sizeof(cdp->cap)); + } + /* If this is a changer device, allocate the neeeded lun's */ + if (cdp->cap.mech == MST_MECH_CHANGER) { + chp = malloc(sizeof(struct changer), M_TEMP, M_NOWAIT); + if (chp == NULL) { + printf("acd: out of memory\n"); + return 0; + } + bzero(chp, sizeof(struct changer)); + result = atapi_request_immediate(ata, unit, ATAPI_MECH_STATUS, + 0, 0, 0, 0, 0, 0, 0, + sizeof(struct changer)>>8, + sizeof(struct changer), + 0, 0, 0, 0, 0, 0, + (char *)chp, sizeof(struct changer)); + if (cdp->flags & F_DEBUG) { + printf("result.code=%d curr=%02x slots=%d len=%d\n", + result.code, chp->current_slot, chp->slots, + htons(chp->table_length)); + } + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code == 0) { + chp->table_length = htons(chp->table_length); + for (i = 0; i < chp->slots && acdnlun < NUNIT; i++) { + if (i > 0) { + cdp = acd_init_lun(ata, unit, ap, acdnlun); + if (cdp == NULL) { + printf("acd: out of memory\n"); + return 0; + } + } + cdp->slot = i; + cdp->changer_info = chp; + printf("acd%d: changer slot %d %s\n", acdnlun, i, + (chp->slot[i].present ? "disk present" : "no disk")); + acdtab[acdnlun++] = cdp; + } + if (acdnlun >= NUNIT) { + printf("acd: too many units\n"); + return 0; + } + } + } else + acdnlun++; + return 1; +} + +void +acd_describe(struct acd *cdp) +{ + int comma; + char *mechanism; + + printf("acd%d: drive speed ", cdp->lun); + if (cdp->cap.cur_speed != cdp->cap.max_speed) + printf("%d - ", cdp->cap.cur_speed * 1000 / 1024); + printf("%dKb/sec", cdp->cap.max_speed * 1000 / 1024); + if (cdp->cap.buf_size) + printf(", %dKb cache\n", cdp->cap.buf_size); + + printf("acd%d: supported read types:", cdp->lun); + comma = 0; + if (cdp->cap.read_cdr) { + printf(" CD-R"); comma = 1; + } + if (cdp->cap.read_cdrw) { + printf("%s CD-RW", comma ? "," : ""); comma = 1; + } + if (cdp->cap.cd_da) { + printf("%s CD-DA", comma ? "," : ""); comma = 1; + } + if (cdp->cap.method2) + printf("%s packet track", comma ? "," : ""); + if (cdp->cap.write_cdr || cdp->cap.write_cdrw) { + printf("\nacd%d: supported write types:", cdp->lun); + comma = 0; + if (cdp->cap.write_cdr) { + printf(" CD-R" ); comma = 1; + } + if (cdp->cap.write_cdrw) { + printf("%s CD-RW", comma ? "," : ""); comma = 1; + } + if (cdp->cap.test_write) { + printf("%s test write", comma ? "," : ""); comma = 1; + } + } + if (cdp->cap.audio_play) { + printf("\nacd%d: Audio: ", cdp->lun); + if (cdp->cap.audio_play) + printf("play"); + if (cdp->cap.max_vol_levels) + printf(", %d volume levels", cdp->cap.max_vol_levels); + } + printf("\nacd%d: Mechanism: ", cdp->lun); + switch (cdp->cap.mech) { + case MST_MECH_CADDY: + mechanism = "caddy"; break; + case MST_MECH_TRAY: + mechanism = "tray"; break; + case MST_MECH_POPUP: + mechanism = "popup"; break; + case MST_MECH_CHANGER: + mechanism = "changer"; break; + case MST_MECH_CARTRIDGE: + mechanism = "cartridge"; break; + default: + mechanism = 0; break; + } + if (mechanism) + printf("%s%s", cdp->cap.eject ? "ejectable " : "", mechanism); + else if (cdp->cap.eject) + printf("ejectable"); + + if (cdp->cap.mech != MST_MECH_CHANGER) { + printf("\nacd%d: Medium: ", cdp->lun); + switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) { + case MST_CDROM: + printf("CD-ROM "); break; + case MST_CDR: + printf("CD-R "); break; + case MST_CDRW: + printf("CD-RW "); break; + case MST_DOOR_OPEN: + printf("door open"); break; + case MST_NO_DISC: + printf("no/blank disc inside"); break; + case MST_FMT_ERROR: + printf("medium format error"); break; + } + if ((cdp->cap.medium_type & MST_TYPE_MASK_HIGH) < MST_TYPE_MASK_HIGH) { + switch (cdp->cap.medium_type & MST_TYPE_MASK_LOW) { + case MST_DATA_120: + printf("120mm data disc loaded"); break; + case MST_AUDIO_120: + printf("120mm audio disc loaded"); break; + case MST_COMB_120: + printf("120mm data/audio disc loaded"); break; + case MST_PHOTO_120: + printf("120mm photo disc loaded"); break; + case MST_DATA_80: + printf("80mm data disc loaded"); break; + case MST_AUDIO_80: + printf("80mm audio disc loaded"); break; + case MST_COMB_80: + printf("80mm data/audio disc loaded"); break; + case MST_PHOTO_80: + printf("80mm photo disc loaded"); break; + case MST_FMT_NONE: + switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) { + case MST_CDROM: + printf("unknown medium"); break; + case MST_CDR: + case MST_CDRW: + printf("blank medium"); break; + } + break; + default: + printf("unknown type=0x%x", cdp->cap.medium_type); break; + } + } + } + if (cdp->cap.lock) + printf(cdp->cap.locked ? ", locked" : ", unlocked"); + if (cdp->cap.prevent) + printf(", lock protected"); + printf("\n"); +} + +static int +acdopen(dev_t dev, int flags, int fmt, struct proc *p) +{ + int lun = dkunit(dev); + struct acd *cdp; + + if (lun >= acdnlun || !atapi_request_immediate) + return ENXIO; + cdp = acdtab[lun]; + + if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) { + /* Prevent user eject */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + } + if (fmt == S_IFBLK) + cdp->flags |= F_BOPEN; + else + ++cdp->refcnt; + + if ((flags & O_NONBLOCK) == 0) { + if ((flags & FWRITE) != 0) { + /* read/write */ + if (acd_rezero_unit(cdp)) { + printf("acd%d: rezero failed\n", lun); + return EIO; + } + } else { + /* read only */ + if (acd_read_toc(cdp) < 0) { + printf("acd%d: read_toc failed\n", lun); + /* return EIO; */ + } + } + } + return 0; +} + +int +acdclose(dev_t dev, int flags, int fmt, struct proc *p) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + if (fmt == S_IFBLK) + cdp->flags &= ~F_BOPEN; + else + --cdp->refcnt; + + /* Are we the last open ?? */ + if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) { + /* Yup, do we need to close any written tracks */ + if ((flags & FWRITE) != 0) { + if ((cdp->flags & F_TRACK_PREPED) != 0) { + acd_close_track(cdp); + cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP); + } + } + /* Allow the user eject */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + cdp->flags &= ~F_LOCKED; + return 0; +} + +static int +acdread(dev_t dev, struct uio *uio, int ioflag) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + return physio(acdstrategy, NULL, dev, 1, minphys, uio); +} + +static int +acdwrite(dev_t dev, struct uio *uio, int ioflag) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + return physio(acdstrategy, NULL, dev, 0, minphys, uio); +} + +void +acdstrategy(struct buf *bp) +{ + int lun = dkunit(bp->b_dev); + struct acd *cdp = acdtab[lun]; + int x; + +#ifdef NOTYET + /* allow write only on CD-R/RW media */ /* all for now SOS */ + if (!(bp->b_flags & B_READ) && !(writeable_media)) { + bp->b_error = EROFS; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } +#endif + + if (bp->b_bcount == 0) { + bp->b_resid = 0; + biodone(bp); + return; + } + + bp->b_pblkno = bp->b_blkno; + bp->b_resid = bp->b_bcount; + + x = splbio(); + bufqdisksort(&cdp->buf_queue, bp); + acd_start(cdp); + splx(x); +} + +static void +acd_start(struct acd *cdp) +{ + struct buf *bp = bufq_first(&cdp->buf_queue); + u_long lba, blocks; + int cmd; + int count; + + if (!bp) + return; + + bufq_remove(&cdp->buf_queue, bp); + + /* Should reject all queued entries if media have changed. */ + if (cdp->flags & F_MEDIA_CHANGED) { + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } + acd_select_slot(cdp); + + if ((bp->b_flags & B_READ) == B_WRITE) { + if ((cdp->flags & F_TRACK_PREPED) == 0) { + if ((cdp->flags & F_TRACK_PREP) == 0) { + printf("acd%d: sequence error\n", cdp->lun); + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } else { + if (acd_open_track(cdp, &cdp->preptrack) != 0) { + biodone(bp); + return; + } + cdp->flags |= F_TRACK_PREPED; + } + } + } + + if (bp->b_flags & B_READ) +#ifdef NOTYET + lba = bp->b_offset / cdp->block_size; +#else + lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE); +#endif + else + lba = next_writeable_lba + (bp->b_offset / cdp->block_size); + blocks = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size; + + if ((bp->b_flags & B_READ) == B_WRITE) { + cmd = ATAPI_WRITE_BIG; + count = -bp->b_bcount; + } else { + cmd = ATAPI_READ_BIG; + count = bp->b_bcount; + } + + atapi_request_callback(cdp->ata, cdp->unit, cmd, 0, + lba>>24, lba>>16, lba>>8, lba, 0, + blocks>>8, blocks, 0, 0, 0, 0, 0, 0, 0, + (u_char *)bp->b_data, count, + (atapi_callback_t *)acd_done, cdp, bp); +} + +static void +acd_done(struct acd *cdp, struct buf *bp, int resid, struct atapires result) +{ + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + } else { + bp->b_resid = resid; + if ((bp->b_flags & B_READ) == B_WRITE) + cdp->flags |= F_WRITTEN; + } + biodone(bp); + acd_start(cdp); +} + +static int +acd_request_wait(struct acd *cdp, u_char cmd, u_char a1, u_char a2, + u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, + u_char a9, char *addr, int count) +{ + struct atapires result; + + result = atapi_request_wait(cdp->ata, cdp->unit, cmd, a1, a2, a3, a4, a5, + a6, a7, a8, a9, 0, 0, 0, 0, 0, 0, addr, count); + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + return 0; +} + +static __inline void +lba2msf(int lba, u_char *m, u_char *s, u_char *f) +{ + lba += 150; + lba &= 0xffffff; + *m = lba / (60 * 75); + lba %= (60 * 75); + *s = lba / 75; + *f = lba % 75; +} + +static __inline int +msf2lba(u_char m, u_char s, u_char f) +{ + return (m * 60 + s) * 75 + f - 150; +} + +int +acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +{ + int lun = dkunit(dev); + struct acd *cdp = acdtab[lun]; + int error = 0; + + if (cdp->flags & F_MEDIA_CHANGED) + switch (cmd) { + case CDIOCRESET: + break; + default: + acd_read_toc(cdp); + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + break; + } + switch (cmd) { +/* + case CDIOCRESUME: + bzero(cdb); + cdb->cmd = ATAPI_PAUSE; + cdb->b8 = 0x01; + return atapi_cmd_wait(cdp->ata, cdp->unit, cdb, 0, 0, timout, 0); +*/ + case CDIOCRESUME: + return acd_request_wait(cdp, ATAPI_PAUSE, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0); + + case CDIOCPAUSE: + return acd_request_wait(cdp, ATAPI_PAUSE, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCSTART: + return acd_request_wait(cdp, ATAPI_START_STOP, + 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCSTOP: + return acd_request_wait(cdp, ATAPI_START_STOP, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCALLOW: + acd_select_slot(cdp); + cdp->flags &= ~F_LOCKED; + return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCPREVENT: + acd_select_slot(cdp); + cdp->flags |= F_LOCKED; + return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCRESET: + if (p->p_cred->pc_ucred->cr_uid) + return EPERM; + return acd_request_wait(cdp, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCEJECT: + if ((cdp->flags & F_BOPEN) && cdp->refcnt) + return EBUSY; + return acd_eject(cdp, 0); + + case CDIOCCLOSE: + if ((cdp->flags & F_BOPEN) && cdp->refcnt) + return 0; + return acd_eject(cdp, 1); + + case CDIOREADTOCHEADER: + if (!cdp->toc.hdr.ending_track) + return EIO; + bcopy(&cdp->toc.hdr, addr, sizeof(cdp->toc.hdr)); + break; + + case CDIOREADTOCENTRYS: + { + struct ioc_read_toc_entry *te = (struct ioc_read_toc_entry *)addr; + struct toc *toc = &cdp->toc; + struct toc buf; + u_long len; + u_char starting_track = te->starting_track; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (te->data_len < sizeof(toc->tab[0]) || + (te->data_len % sizeof(toc->tab[0])) != 0 || + te->address_format != CD_MSF_FORMAT && + te->address_format != CD_LBA_FORMAT) + return EINVAL; + + if (!starting_track) + starting_track = toc->hdr.starting_track; + else if (starting_track == 170) + starting_track = toc->hdr.ending_track + 1; + else if (starting_track < toc->hdr.starting_track || + starting_track > toc->hdr.ending_track + 1) + return EINVAL; + + len = ((toc->hdr.ending_track + 1 - starting_track) + 1) * + sizeof(toc->tab[0]); + if (te->data_len < len) + len = te->data_len; + if (len > sizeof(toc->tab)) + return EINVAL; + + if (te->address_format == CD_MSF_FORMAT) { + struct cd_toc_entry *entry; + + buf = cdp->toc; + toc = &buf; + entry = toc->tab + (toc->hdr.ending_track + 1 - + toc->hdr.starting_track) + 1; + while (--entry >= toc->tab) + lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute, + &entry->addr.msf.second, &entry->addr.msf.frame); + } + return copyout(toc->tab + starting_track - toc->hdr.starting_track, + te->data, len); + } + + case CDIOREADTOCENTRY: + { + struct ioc_read_toc_single_entry *te = + (struct ioc_read_toc_single_entry *)addr; + struct toc *toc = &cdp->toc; + struct toc buf; + u_char track = te->track; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (te->address_format != CD_MSF_FORMAT && + te->address_format != CD_LBA_FORMAT) + return EINVAL; + + if (!track) + track = toc->hdr.starting_track; + else if (track == 170) + track = toc->hdr.ending_track + 1; + else if (track < toc->hdr.starting_track || + track > toc->hdr.ending_track + 1) + return EINVAL; + + if (te->address_format == CD_MSF_FORMAT) { + struct cd_toc_entry *entry; + + buf = cdp->toc; + toc = &buf; + entry = toc->tab + (track - toc->hdr.starting_track); + lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute, + &entry->addr.msf.second, &entry->addr.msf.frame); + } + bcopy(toc->tab + track - toc->hdr.starting_track, + &te->entry, sizeof(struct cd_toc_entry)); + } + break; + + case CDIOCREADSUBCHANNEL: + { + struct ioc_read_subchannel *args = + (struct ioc_read_subchannel *)addr; + struct cd_sub_channel_info data; + u_long len = args->data_len; + int abslba, rellba; + + if (len > sizeof(data) || + len < sizeof(struct cd_sub_channel_header)) + return EINVAL; + + if (acd_request_wait(cdp, ATAPI_READ_SUBCHANNEL, + 0, 0x40, 1, 0, 0, 0, + sizeof(cdp->subchan)>>8, sizeof(cdp->subchan), + 0, + (char *)&cdp->subchan, + sizeof(cdp->subchan)) != 0) + return EIO; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "subchan", &cdp->subchan, + sizeof(cdp->subchan)); + + abslba = cdp->subchan.abslba; + rellba = cdp->subchan.rellba; + if (args->address_format == CD_MSF_FORMAT) { + lba2msf(ntohl(abslba), + &data.what.position.absaddr.msf.minute, + &data.what.position.absaddr.msf.second, + &data.what.position.absaddr.msf.frame); + lba2msf(ntohl(rellba), + &data.what.position.reladdr.msf.minute, + &data.what.position.reladdr.msf.second, + &data.what.position.reladdr.msf.frame); + } else { + data.what.position.absaddr.lba = abslba; + data.what.position.reladdr.lba = rellba; + } + data.header.audio_status = cdp->subchan.audio_status; + data.what.position.control = cdp->subchan.control & 0xf; + data.what.position.addr_type = cdp->subchan.control >> 4; + data.what.position.track_number = cdp->subchan.track; + data.what.position.index_number = cdp->subchan.indx; + return copyout(&data, args->data, len); + } + + case CDIOCPLAYMSF: + { + struct ioc_play_msf *args = (struct ioc_play_msf *)addr; + + return acd_request_wait(cdp, ATAPI_PLAY_MSF, 0, 0, + args->start_m, args->start_s, args->start_f, + args->end_m, args->end_s, args->end_f, + 0, 0, 0); + } + + case CDIOCPLAYBLOCKS: + { + struct ioc_play_blocks *args = (struct ioc_play_blocks *)addr; + + return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0, + args->blk>>24 & 0xff, args->blk>>16 & 0xff, + args->blk>>8 & 0xff, args->blk & 0xff, + args->len>>24 & 0xff, args->len>>16 & 0xff, + args->len>>8 & 0xff, args->len & 0xff, + 0, 0); + } + + case CDIOCPLAYTRACKS: + { + struct ioc_play_track *args = (struct ioc_play_track *)addr; + u_long start, len; + int t1, t2; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (args->end_track < cdp->toc.hdr.ending_track + 1) + ++args->end_track; + if (args->end_track > cdp->toc.hdr.ending_track + 1) + args->end_track = cdp->toc.hdr.ending_track + 1; + t1 = args->start_track - cdp->toc.hdr.starting_track; + t2 = args->end_track - cdp->toc.hdr.starting_track; + if (t1 < 0 || t2 < 0) + return EINVAL; + start = ntohl(cdp->toc.tab[t1].addr.lba); + len = ntohl(cdp->toc.tab[t2].addr.lba) - start; + + return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0, + start>>24 & 0xff, start>>16 & 0xff, + start>>8 & 0xff, start & 0xff, + len>>24 & 0xff, len>>16 & 0xff, + len>>8 & 0xff, len & 0xff, 0, 0); + } + + case CDIOCREADAUDIO: + { + struct ioc_read_audio* args = (struct ioc_read_audio*) addr; + int lba, frames, result = 0; + u_char *buffer, *ubuf = args->buffer; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if ((frames = args->nframes) < 0) + return EINVAL; + + if (args->address_format == CD_LBA_FORMAT) + lba = args->address.lba; + else if (args->address_format == CD_MSF_FORMAT) + lba = msf2lba(args->address.msf.minute, + args->address.msf.second, + args->address.msf.frame); + else + return EINVAL; +#ifndef CD_BUFFER_BLOCKS +#define CD_BUFFER_BLOCKS 8 +#endif + if (!(buffer = malloc(CD_BUFFER_BLOCKS * 2352, M_TEMP, M_NOWAIT))) + return ENOMEM; + + while (frames > 0) { + u_char blocks; + int size; + + blocks = (frames>CD_BUFFER_BLOCKS) ? CD_BUFFER_BLOCKS : frames; + size = blocks * 2352; + + result = acd_request_wait(cdp, ATAPI_READ_CD, 4, + lba>>24, (lba>>16)&0xff, + (lba>>8)&0xff, lba&0xff, 0, 0, + blocks, 0xf0, buffer, size); + if (result != 0) + break; + + result = copyout(buffer, ubuf, size); + if (result != 0) + break; + + ubuf += size; + frames -= blocks; + lba += blocks; + } + + free(buffer, M_TEMP); + return result; + } + + case CDIOCGETVOL: + { + struct ioc_vol *arg = (struct ioc_vol *)addr; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, + sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + arg->vol[0] = cdp->au.port[0].volume; + arg->vol[1] = cdp->au.port[1].volume; + arg->vol[2] = cdp->au.port[2].volume; + arg->vol[3] = cdp->au.port[3].volume; + } + break; + + case CDIOCSETVOL: + { + struct ioc_vol *arg = (struct ioc_vol *)addr; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, + sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, + CDROM_AUDIO_PAGE_MASK, 0, 0, 0, 0, + sizeof(cdp->aumask)>>8,sizeof(cdp->aumask), + 0, + (char *)&cdp->aumask, sizeof(cdp->aumask)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "mask", &cdp->aumask, + sizeof(cdp->aumask)); + + cdp->au.data_length = 0; + cdp->au.port[0].channels = CHANNEL_0; + cdp->au.port[1].channels = CHANNEL_1; + cdp->au.port[0].volume = arg->vol[0] & cdp->aumask.port[0].volume; + cdp->au.port[1].volume = arg->vol[1] & cdp->aumask.port[1].volume; + cdp->au.port[2].volume = arg->vol[2] & cdp->aumask.port[2].volume; + cdp->au.port[3].volume = arg->vol[3] & cdp->aumask.port[3].volume; + return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10, + 0, 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), + 0, (char *)&cdp->au, -sizeof(cdp->au)); + } + + case CDIOCSETPATCH: + { + struct ioc_patch *arg = (struct ioc_patch *)addr; + + return acd_setchan(cdp, arg->patch[0], arg->patch[1], + arg->patch[2], arg->patch[3]); + } + + case CDIOCSETMONO: + return acd_setchan(cdp, CHANNEL_0|CHANNEL_1, CHANNEL_0|CHANNEL_1, 0, 0); + + case CDIOCSETSTEREO: + return acd_setchan(cdp, CHANNEL_0, CHANNEL_1, 0, 0); + + case CDIOCSETMUTE: + return acd_setchan(cdp, 0, 0, 0, 0); + + case CDIOCSETLEFT: + return acd_setchan(cdp, CHANNEL_0, CHANNEL_0, 0, 0); + + case CDIOCSETRIGHT: + return acd_setchan(cdp, CHANNEL_1, CHANNEL_1, 0, 0); + + case CDRIOCNEXTWRITEABLEADDR: + { + struct acd_track_info track_info; + + if ((error = acd_read_track_info(cdp, 0xff, &track_info))) + break; + if (!track_info.nwa_valid) + return EINVAL; + next_writeable_lba = track_info.next_writeable_addr; + *(int*)addr = track_info.next_writeable_addr; + } + break; + + case WORMIOCPREPDISK: + { + struct wormio_prepare_disk *w = (struct wormio_prepare_disk *)addr; + + if (w->dummy != 0 && w->dummy != 1) + error = EINVAL; + else { + error = acd_open_disk(cdp, w->dummy); + if (error == 0) { + cdp->flags |= F_DISK_PREPED; + cdp->dummy = w->dummy; + cdp->speed = w->speed; + } + } + } + break; + + case WORMIOCPREPTRACK: + { + struct wormio_prepare_track *w =(struct wormio_prepare_track *)addr; + + if (w->audio != 0 && w->audio != 1) + error = EINVAL; + else if (w->audio == 0 && w->preemp) + error = EINVAL; + else if ((cdp->flags & F_DISK_PREPED) == 0) { + error = EINVAL; + printf("acd%d: sequence error (PREP_TRACK)\n", cdp->lun); + } else { + cdp->flags |= F_TRACK_PREP; + cdp->preptrack = *w; + } + } + break; + + case WORMIOCFINISHTRACK: + if ((cdp->flags & F_TRACK_PREPED) != 0) + error = acd_close_track(cdp); + cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP); + break; + + case WORMIOCFIXATION: + { + struct wormio_fixation *w = + (struct wormio_fixation *)addr; + + if ((cdp->flags & F_WRITTEN) == 0) + error = EINVAL; + else if (w->toc_type < 0 /* WORM_TOC_TYPE_AUDIO */ || + w->toc_type > 4 /* WORM_TOC_TYPE_CDI */ ) + error = EINVAL; + else if (w->onp != 0 && w->onp != 1) + error = EINVAL; + else { + /* no fixation needed if dummy write */ + if (cdp->dummy == 0) + error = acd_close_disk(cdp); + cdp->flags &= + ~(F_WRITTEN|F_DISK_PREPED|F_TRACK_PREP|F_TRACK_PREPED); + } + } + break; + + case CDRIOCBLANK: + return acd_blank_disk(cdp); + + default: + return ENOTTY; + } + return error; +} + +static int +acd_read_toc(struct acd *cdp) +{ + int ntracks, len; + struct atapires result; + + bzero(&cdp->toc, sizeof(cdp->toc)); + bzero(&cdp->info, sizeof(cdp->info)); + + acd_select_slot(cdp); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + + if (result.code == RES_ERR && + (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION) { + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + + cdp->flags &= ~F_MEDIA_CHANGED; + + len = sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry); + if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, + len>>8, len & 0xff, 0, (char *)&cdp->toc, len) != 0) { + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + ntracks = cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1; + if (ntracks <= 0 || ntracks > MAXTRK) { + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + + len = sizeof(struct ioc_toc_header) + ntracks * sizeof(struct cd_toc_entry); + if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, + len>>8, len & 0xff, 0, (char *)&cdp->toc, len) & 0xff){ + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + + cdp->toc.hdr.len = ntohs(cdp->toc.hdr.len); + + if (acd_request_wait(cdp, ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0, + (char *)&cdp->info, sizeof(cdp->info)) != 0) + bzero(&cdp->info, sizeof(cdp->info)); + + cdp->toc.tab[ntracks].control = cdp->toc.tab[ntracks - 1].control; + cdp->toc.tab[ntracks].addr_type = cdp->toc.tab[ntracks - 1].addr_type; + cdp->toc.tab[ntracks].track = 170; + cdp->toc.tab[ntracks].addr.lba = cdp->info.volsize; + + cdp->info.volsize = ntohl(cdp->info.volsize); + cdp->info.blksize = ntohl(cdp->info.blksize); + + if (cdp->info.volsize && cdp->toc.hdr.ending_track + /* && (cdp->flags & F_DEBUG) */) { + printf("acd%d: ", cdp->lun); + if (cdp->toc.tab[0].control & 4) + printf("%ldMB ", cdp->info.volsize / 512); + else + printf("%ld:%ld audio ", cdp->info.volsize / 75 / 60, + cdp->info.volsize / 75 % 60); + printf("(%ld sectors (%d bytes)), %d tracks\n", + cdp->info.volsize, cdp->info.blksize, + cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1); + } + return 0; +} + +/* + * Set up the audio channel masks. + */ +static int +acd_setchan(struct acd *cdp, u_char c0, u_char c1, u_char c2, u_char c3) +{ + int error; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + + cdp->au.data_length = 0; + cdp->au.port[0].channels = c0; + cdp->au.port[1].channels = c1; + cdp->au.port[2].channels = c2; + cdp->au.port[3].channels = c3; + return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10, + 0, 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, -sizeof(cdp->au)); +} + +static int +acd_eject(struct acd *cdp, int close) +{ + struct atapires result; + + acd_select_slot(cdp); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_START_STOP, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + if (result.code == RES_ERR && + ((result.error & AER_SKEY) == AER_SK_NOT_READY || + (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) { + int err; + + if (!close) + return 0; + err = acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 3, + 0, 0, 0, 0, 0, 0, 0); + if (err) + return err; + + acd_read_toc(cdp); + + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + return 0; + } + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + if (close) + return 0; + + tsleep((caddr_t) &lbolt, PRIBIO, "acdej1", 0); + tsleep((caddr_t) &lbolt, PRIBIO, "acdej2", 0); + + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + cdp->flags &= ~F_LOCKED; + + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + return acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0); +} + +static void +acd_select_slot(struct acd *cdp) +{ + if (cdp->slot < 0 || cdp->changer_info->current_slot == cdp->slot) + return; + + /* Unlock (might not be needed but its cheaper than asking) */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + /* Unload the current media from player */ + acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 2, + 0, 0, 0, cdp->changer_info->current_slot, 0, 0, 0); + + /* load the wanted slot */ + acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 3, + 0, 0, 0, cdp->slot, 0, 0, 0); + + cdp->changer_info->current_slot = cdp->slot; + + /* Lock the media if needed */ + if (cdp->flags & F_LOCKED) { + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0); + } +} + +static int +acd_rezero_unit(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_REZERO_UNIT, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0); +} + +static int +acd_open_disk(struct acd *cdp, int test) +{ + next_writeable_lba = 0; + return 0; +} + +static int +acd_close_disk(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_CLOSE_TRACK, 0x00, + 0x02, 0, 0, 0/*track*/, 0, 0, 0, 0, 0, 0); +} + +static int +acd_open_track(struct acd *cdp, struct wormio_prepare_track *ptp) +{ + struct write_param param; + struct atapires result; + int error; + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SENSE, + 0, 0x05, 0, 0, 0, 0, + sizeof(param)>>8, sizeof(param), + 0, 0, 0, 0, 0, 0, 0, + (char *)¶m, sizeof(param)); + + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", ¶m, sizeof(param)); + + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + param.page_code = 0x05; + param.page_length = 0x32; + param.test_write = cdp->dummy ? 1 : 0; + param.write_type = CDR_WTYPE_TRACK; + + switch (ptp->audio) { +/* switch (data_type) { */ + + case 0: +/* case CDR_DATA: */ + cdp->block_size = 2048; + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_ROM_MODE1; + param.session_format = CDR_SESS_CDROM; + break; + + default: +/* case CDR_AUDIO: */ + cdp->block_size = 2352; + if (ptp->preemp) + param.track_mode = CDR_TMODE_AUDIO; + else + param.track_mode = 0; + param.data_block_type = CDR_DB_RAW; + param.session_format = CDR_SESS_CDROM; + break; + +/* + case CDR_MODE2: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_ROM_MODE2; + param.session_format = CDR_SESS_CDROM; + break; + + case CDR_XA1: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE1; + param.session_format = CDR_SESS_CDROM_XA; + break; + + case CDR_XA2: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE2_F1; + param.session_format = CDR_SESS_CDROM_XA; + break; + + case CDR_CDI: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE2_F1; + param.session_format = CDR_SESS_CDI; + break; +*/ + } + + param.multi_session = CDR_MSES_NONE; + param.fp = 0; + param.packet_size = 0; + + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", ¶m, sizeof(param)); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SELECT, + 0x10, 0, 0, 0, 0, 0, + sizeof(param)>>8, sizeof(param), + 0, 0, 0, 0, 0, 0, 0, + (char *)¶m, -sizeof(param)); + + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + return 0; +} + +static int +acd_close_track(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_SYNCHRONIZE_CACHE, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +static int +acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info) +{ + int error; + + error = acd_request_wait(cdp, ATAPI_READ_TRACK_INFO, 0x01, + lba>>24, (lba>>16)&0xff, + (lba>>8)&0xff, lba&0xff, + 0, + sizeof(*info)>>8, sizeof(*info), 0, + (char *)info, sizeof(*info)); + if (error) + return error; + info->track_start_addr = ntohl(info->track_start_addr); + info->next_writeable_addr = ntohl(info->next_writeable_addr); + info->free_blocks = ntohl(info->free_blocks); + info->fixed_packet_size = ntohl(info->fixed_packet_size); + info->track_length = ntohl(info->track_length); + return 0; +} + +static int +acd_blank_disk(struct acd *cdp) +{ + int error; + + error = acd_request_wait(cdp, 0xa1, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + return error; +} + +static void +atapi_error(struct atapi *ata, int unit, struct atapires result) +{ + if (result.code != RES_ERR) { + printf("atapi%d:%d: ERROR %d, status=%b, error=%b\n", + ata->ctrlr, unit, result.code, result.status, + ARS_BITS, result.error, AER_BITS); + return; + } + switch (result.error & AER_SKEY) { + case AER_SK_NOT_READY: + if (ata->debug) + printf("atapi%d:%d: not ready\n", ata->ctrlr, unit); + break; + + case AER_SK_BLANK_CHECK: + if (ata->debug) + printf("atapi%d:%d: blank check\n", ata->ctrlr, unit); + break; + + case AER_SK_MEDIUM_ERROR: + if (ata->debug) + printf("atapi%d:%d: medium error\n", ata->ctrlr, unit); + break; + + case AER_SK_HARDWARE_ERROR: + if (ata->debug) + printf("atapi%d:%d: hardware error\n", ata->ctrlr, unit); + break; + + case AER_SK_ILLEGAL_REQUEST: + if (ata->debug) + printf("atapi%d:%d: illegal request\n", ata->ctrlr, unit); + break; + + case AER_SK_UNIT_ATTENTION: + if (ata->debug) + printf("atapi%d:%d: unit attention\n", ata->ctrlr, unit); + break; + + case AER_SK_DATA_PROTECT: + if (ata->debug) + printf("atapi%d:%d: reading protected data\n", ata->ctrlr, unit); + break; + + case AER_SK_ABORTED_COMMAND: + if (ata->debug) + printf("atapi%d:%d: command aborted\n", ata->ctrlr, unit); + break; + + case AER_SK_MISCOMPARE: + if (ata->debug) + printf("atapi%d:%d: data don't match medium\n", ata->ctrlr, unit); + break; + + default: + if (ata->debug) + printf("atapi%d:%d: unknown error, status=%b, error=%b\n", + ata->ctrlr, unit, result.status, ARS_BITS, + result.error, AER_BITS); + } +} + +static void +atapi_dump(int ctrlr, int lun, char *label, void *data, int len) +{ + u_char *p = data; + + printf ("atapi%d%d: %s %x", ctrlr, lun, label, *p++); + while (--len > 0) printf ("-%x", *p++); + printf ("\n"); +} + +#ifdef ACD_MODULE +#include +#include +#include + +MOD_DEV(acd, LM_DT_BLOCK, BDEV_MAJOR, &acd_bdevsw); +MOD_DEV(racd, LM_DT_CHAR, CDEV_MAJOR, &acd_cdevsw); + +int +acd_load(struct lkm_table *lkmtp, int cmd) +{ + struct atapi *ata; + int n, u; + + if (!atapi_start) + return EPROTONOSUPPORT; + n = 0; + for (ata = atapi_tab; ata < atapi_tab + 2; ++ata) + if (ata->port) + for (u = 0; u < 2; ++u) + if (ata->params[u] && !ata->attached[u] && + acdattach(ata, u, ata->params[u], + ata->debug) >= 0) { + ata->attached[u] = 1; + ++n; + } + if (!n) + return ENXIO; + return 0; +} + +int +acd_unload(struct lkm_table *lkmtp, int cmd) +{ + struct acd **cdpp; + + for (cdpp = acdtab; cdpp < acdtab + acdnlun; ++cdpp) + if (((*cdpp)->flags & F_BOPEN) || (*cdpp)->refcnt) + return EBUSY; + for (cdpp = acdtab; cdpp < acdtab + acdnlun; ++t) { + (*cdpp)->ata->attached[(*cdpp)->unit] = 0; + free(*cdpp, M_TEMP); + } + acdnlun = 0; + bzero(acdtab, sizeof(acdtab)); + return 0; +} + +int +acd_mod(struct lkm_table *lkmtp, int cmd, int ver) +{ + int err = 0; + + if (ver != LKM_VERSION) + return EINVAL; + + if (cmd == LKM_E_LOAD) + err = acd_load(lkmtp, cmd); + else if (cmd == LKM_E_UNLOAD) + err = acd_unload(lkmtp, cmd); + if (err) + return err; + + lkmtp->private.lkm_dev = &MOD_PRIVATE(racd); + err = lkmdispatch(lkmtp, cmd); + if (err) + return err; + + lkmtp->private.lkm_dev = &MOD_PRIVATE(acd); + return lkmdispatch(lkmtp, cmd); +} + +#endif /* ACD_MODULE */ + +static acd_devsw_installed = 0; + +static void +acd_drvinit(void *unused) +{ + dev_t dev; + + if (!acd_devsw_installed) { + cdevsw_add_generic(BDEV_MAJOR, CDEV_MAJOR, &acd_cdevsw); + acd_devsw_installed = 1; + } +} + +SYSINIT(acddev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE + CDEV_MAJOR, acd_drvinit, NULL) +#endif /* NACD && NWDC && ATAPI */ diff --git a/sys/i386/isa/wd_cd.h b/sys/i386/isa/wd_cd.h new file mode 100644 index 000000000000..29da547dc56f --- /dev/null +++ b/sys/i386/isa/wd_cd.h @@ -0,0 +1,357 @@ +/*- + * Copyright (c) 1998 Søren Schmidt + * All rights reserved. + * + * 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, + * without modification, immediately at the beginning of the file. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. + * + * $Id: atapi-cd.h,v 1.2 1998/09/02 08:47:31 sos Exp sos $ + */ + +/* + * CDROM Table Of Contents + */ +#define MAXTRK 99 +struct toc { + struct ioc_toc_header hdr; + struct cd_toc_entry tab[MAXTRK + 1]; +}; + +/* + * CDROM Audio Control Parameters Page + */ +struct audiopage { + /* Mode Page data header */ + u_short data_length; + u_char medium_type; + u_char dev_spec; + u_char unused[2]; + u_short blk_desc_len; + + /* Audio control page */ + u_char page_code; +#define CDROM_AUDIO_PAGE 0x0e +#define CDROM_AUDIO_PAGE_MASK 0x4e + + u_char param_len; + u_char flags; +#define CD_PA_SOTC 0x02 +#define CD_PA_IMMED 0x04 + + u_char reserved3; + u_char reserved4; + u_char reserved5; + u_short lb_per_sec; + struct port_control { + u_char channels:4; +#define CHANNEL_0 1 +#define CHANNEL_1 2 +#define CHANNEL_2 4 +#define CHANNEL_3 8 + u_char volume; + } port[4]; +}; + +/* + * CDROM Capabilities and Mechanical Status Page + */ +struct cappage { + /* Mode data header */ + u_short data_length; + u_char medium_type; /* Present media type */ +#define MST_TYPE_MASK_LOW 0x0f +#define MST_FMT_NONE 0x00 +#define MST_DATA_120 0x01 +#define MST_AUDIO_120 0x02 +#define MST_COMB_120 0x03 +#define MST_PHOTO_120 0x04 +#define MST_DATA_80 0x05 +#define MST_AUDIO_80 0x06 +#define MST_COMB_80 0x07 +#define MST_PHOTO_80 0x08 + +#define MST_TYPE_MASK_HIGH 0x70 +#define MST_CDROM 0x00 +#define MST_CDR 0x10 +#define MST_CDRW 0x20 + +#define MST_NO_DISC 0x70 +#define MST_DOOR_OPEN 0x71 +#define MST_FMT_ERROR 0x72 + + u_char dev_spec; + u_char unused[2]; + u_short blk_desc_len; + + /* Capabilities page */ + u_char page_code; +#define ATAPI_CDROM_CAP_PAGE 0x2a + + u_char param_len; + u_char read_cdr:1; /* Supports CD-R read */ + u_char read_cdrw:1; /* Supports CD-RW read */ + u_char method2:1; /* Supports reading packet tracks */ + u_char byte2_37:5; + u_char write_cdr:1; /* Supports CD-R write */ + u_char write_cdrw:1; /* Supports CD-RW write */ + u_char test_write:1; /* Supports test writing */ + u_char byte3_37:5; + u_char audio_play:1; /* Audio play supported */ + u_char composite:1; /* Composite audio/video supported */ + u_char dport1:1; /* Digital audio on port 1 */ + u_char dport2:1; /* Digital audio on port 2 */ + u_char mode2_form1:1; /* Mode 2 form 1 (XA) read */ + u_char mode2_form2:1; /* Mode 2 form 2 format */ + u_char multisession:1; /* Multi-session photo-CD */ + u_char:1; + u_char cd_da:1; /* Audio-CD read supported */ + u_char cd_da_stream:1; /* CD-DA streaming */ + u_char rw:1; /* Combined R-W subchannels */ + u_char rw_corr:1; /* R-W subchannel data corrected */ + u_char c2:1; /* C2 error pointers supported */ + u_char isrc:1; /* Can return the ISRC info */ + u_char upc:1; /* Can return the catalog number UPC */ + u_char:1; + u_char lock:1; /* Can be locked */ + u_char locked:1; /* Current lock state */ + u_char prevent:1; /* Prevent jumper installed */ + u_char eject:1; /* Can eject */ + u_char:1; + u_char mech:3; /* Loading mechanism type */ +#define MST_MECH_CADDY 0 +#define MST_MECH_TRAY 1 +#define MST_MECH_POPUP 2 +#define MST_MECH_CHANGER 4 +#define MST_MECH_CARTRIDGE 5 + + u_char sep_vol:1; /* Independent volume of channels */ + u_char sep_mute:1; /* Independent mute of channels */ + u_char:6; + + u_short max_speed; /* Max raw data rate in bytes/1000 */ + u_short max_vol_levels; /* Number of discrete volume levels */ + u_short buf_size; /* Internal buffer size in bytes/1024 */ + u_short cur_speed; /* Current data rate in bytes/1000 */ + + u_char reserved3; + u_char bckf:1; /* Data valid on failing edge of BCK */ + u_char rch:1; /* High LRCK indicates left channel */ + u_char lsbf:1; /* Set if LSB first */ + u_char dlen:2; +#define MST_DLEN_32 0 +#define MST_DLEN_16 1 +#define MST_DLEN_24 2 +#define MST_DLEN_24_I2S 3 + + u_char:3; + u_char reserved4[2]; +}; + +/* + * CDROM Changer mechanism status structure + */ +struct changer { + u_char current_slot:5; /* Active changer slot */ + u_char mech_state:2; /* Current changer state */ +#define CH_READY 0 +#define CH_LOADING 1 +#define CH_UNLOADING 2 +#define CH_INITIALIZING 3 + + u_char fault:1; /* Fault in last operation */ + u_char reserved0:5; + u_char cd_state:3; /* Current mechanism state */ +#define CD_IDLE 0 +#define CD_AUDIO_ACTIVE 1 +#define CD_AUDIO_SCAN 2 +#define CD_HOST_ACTIVE 3 +#define CD_NO_STATE 7 + + u_char current_lba[3]; /* Current LBA */ + u_char slots; /* Number of available slots */ + u_short table_length; /* Slot table length */ + struct { + u_char changed:1; /* Media has changed in this slot */ + u_char unused:6; + u_char present:1; /* Slot has a CD present */ + u_char reserved0; + u_char reserved1; + u_char reserved2; + } slot[32]; +}; + +/* + * CDROM Write Parameters Mode Page (Burners ONLY) + */ +struct write_param { + /* Mode Page data header */ + u_short data_length; + u_char medium_type; + u_char dev_spec; + u_char unused[2]; + u_short blk_desc_len; + + /* Write Parameters mode page */ + u_char page_code; /* 0x05 */ + u_char page_length; /* 0x32 */ + u_char write_type:4; /* Write stream type */ +#define CDR_WTYPE_PACKET 0x00 +#define CDR_WTYPE_TRACK 0x01 +#define CDR_WTYPE_SESSION 0x02 +#define CDR_WTYPE_RAW 0x03 + + u_char test_write:1; /* Test write enable */ + u_char reserved2_567:3; + u_char track_mode:4; /* Track mode */ +#define CDR_TMODE_AUDIO 0x01 +#define CDR_TMODE_INCR_DATA 0x01 +#define CDR_TMODE_ALLOW_COPY 0x02 +#define CDR_TMODE_DATA 0x04 +#define CDR_TMODE_QUAD_AUDIO 0x08 + + u_char copy:1; /* Generation stamp */ + u_char fp:1; /* Fixed packet type */ + u_char multi_session:2; /* Multi-session type */ +#define CDR_MSES_NONE 0x00 +#define CDR_MSES_FINAL 0x01 +#define CDR_MSES_RESERVED 0x02 +#define CDR_MSES_NULTI 0x03 + + u_char data_block_type:4; /* Data block type code */ +#define CDR_DB_RAW 0x0 /* 2352 bytes of raw data */ +#define CDR_DB_RAW_PQ 0x1 /* 2368 bytes raw data + P/Q subchan */ +#define CDR_DB_RAW_PW 0x2 /* 2448 bytes raw data + P-W subchan */ +#define CDR_DB_RAW_PW_R 0x3 /* 2448 bytes raw data + P-W raw sub */ +#define CDR_DB_RES_4 0x4 /* Reserved */ +#define CDR_DB_RES_5 0x5 /* Reserved */ +#define CDR_DB_RES_6 0x6 /* Reserved */ +#define CDR_DB_VS_7 0x7 /* Vendor specific */ +#define CDR_DB_ROM_MODE1 0x8 /* 2048 bytes Mode 1 (ISO/IEC 10149) */ +#define CDR_DB_ROM_MODE2 0x9 /* 2336 bytes Mode 2 (ISO/IEC 10149) */ +#define CDR_DB_XA_MODE1 0x10 /* 2048 bytes Mode 1 (CD-ROM XA 1) */ +#define CDR_DB_XA_MODE2_F1 0x11 /* 2056 bytes Mode 2 (CD-ROM XA 1) */ +#define CDR_DB_XA_MODE2_F2 0x12 /* 2324 bytes Mode 2 (CD-ROM XA 2) */ +#define CDR_DB_XA_MODE2_MIX 0x13 /* 2332 bytes Mode 2 (CD-ROM XA 1/2) */ +#define CDR_DB_RES_14 0x14 /* Reserved */ +#define CDR_DB_VS_15 0x15 /* Vendor specific */ + + u_char reserved4_4567:4; + u_char reserved5; + u_char reserved6; + u_char host_app_code:6; /* Host application code */ + u_char reserved7_67:2; + u_char session_format; /* Session format */ +#define CDR_SESS_CDROM 0x00 +#define CDR_SESS_CDI 0x10 +#define CDR_SESS_CDROM_XA 0x20 + + u_char reserved9; + u_int packet_size; /* Packet size in bytes */ + u_short audio_pause_length; /* Audio pause length in secs */ + u_char media_catalog_number[16]; + u_char isr_code[16]; + u_char sub_hdr_byte0; + u_char sub_hdr_byte1; + u_char sub_hdr_byte2; + u_char sub_hdr_byte3; +/* + u_char vendor_specific_byte0; + u_char vendor_specific_byte1; + u_char vendor_specific_byte2; + u_char vendor_specific_byte3; +*/ + +} __attribute__((packed)); +/* + * CDROM Read Track Information structure + */ +struct acd_track_info { + u_short data_length; + u_char track_number; /* Current track number */ + u_char session_number; /* Current session number */ + u_char reserved4; + u_char track_mode:4; /* Mode of this track */ + u_char copy:1; /* Generation stamp */ + u_char damage:1; /* Damaged track */ + u_char reserved5_67:2; + u_char data_mode:4; /* Data mode of this disc */ + u_char fp:1; /* Fixed packet */ + u_char packet:1; /* Packet track */ + u_char blank:1; /* Blank (empty) track */ + u_char rt:1; /* Reserved track */ + u_char nwa_valid:1; /* next_writeable_addr field valid */ + u_char reserved7_17:7; + u_int track_start_addr; /* Start of this track */ + u_int next_writeable_addr; /* Next writeable addr on this disc */ + u_int free_blocks; /* Free block on this disc */ + u_int fixed_packet_size; /* Size of packets on this track */ + u_int track_length; /* Length of this track */ +}; + +/* + * Structure describing an ATAPI CDROM device + */ +struct acd { + int unit; /* IDE bus drive unit */ + int lun; /* Logical device unit */ + int flags; /* Device state flags */ + int refcnt; /* The number of raw opens */ + struct atapi *ata; /* Controller structure */ + struct buf_queue_head buf_queue; /* Queue of i/o requests */ + struct atapi_params *param; /* Drive parameters table */ + struct toc toc; /* Table of disc contents */ + struct { + u_long volsize; /* Volume size in blocks */ + u_long blksize; /* Block size in bytes */ + } info; + struct audiopage au; /* Audio page info */ + struct cappage cap; /* Capabilities page info */ + struct audiopage aumask; /* Audio page mask */ + struct { /* Subchannel info */ + u_char void0; + u_char audio_status; + u_short data_length; + u_char data_format; + u_char control; + u_char track; + u_char indx; + u_long abslba; + u_long rellba; + } subchan; + struct changer *changer_info; /* Changer info */ + int slot; /* This lun's slot number */ + u_int block_size; /* Blocksize currently used */ + u_char dummy; /* Use dummy writes */ + u_char speed; /* Select drive speed */ + struct wormio_prepare_track preptrack; /* Scratch region */ + +#ifdef DEVFS + void *ra_devfs_token; + void *rc_devfs_token; + void *a_devfs_token; + void *c_devfs_token; +#endif +}; + +#define CDRIOCBLANK _IO('c',100) /* Blank a CDRW disc */ +#define CDRIOCNEXTWRITEABLEADDR _IOR('c',101,int) diff --git a/sys/pc98/pc98/atapi.h b/sys/pc98/pc98/atapi.h index 14f3de51e0fd..dce85fbc883b 100644 --- a/sys/pc98/pc98/atapi.h +++ b/sys/pc98/pc98/atapi.h @@ -1,302 +1,306 @@ /* * Device-independent level for ATAPI drivers. * * Copyright (C) 1995 Cronyx Ltd. * Author Serge Vakulenko, * * This software is distributed with NO WARRANTIES, not even the implied * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Authors grant any other persons or organizations permission to use * or modify this software as long as this message is kept with the software, * all derivative works or modified versions. * * Version 1.9, Thu Oct 12 15:53:50 MSK 1995 */ /* * Disk Controller ATAPI register definitions. */ #ifdef PC98 #define AR_DATA 0x0 /* RW - data register (16 bits) */ #define AR_ERROR 0x2 /* R - error register */ #define AR_FEATURES 0x2 /* W - features */ #define AR_IREASON 0x4 /* RW - interrupt reason */ #define AR_TAG 0x6 /* - reserved for SAM TAG byte */ #define AR_CNTLO 0x8 /* RW - byte count, low byte */ #define AR_CNTHI 0xa /* RW - byte count, high byte */ #define AR_DRIVE 0xc /* RW - drive select */ #define AR_COMMAND 0xe /* W - command register */ #define AR_STATUS 0xe /* R - immediate status */ #else #define AR_DATA 0x0 /* RW - data register (16 bits) */ #define AR_ERROR 0x1 /* R - error register */ #define AR_FEATURES 0x1 /* W - features */ #define AR_IREASON 0x2 /* RW - interrupt reason */ #define AR_TAG 0x3 /* - reserved for SAM TAG byte */ #define AR_CNTLO 0x4 /* RW - byte count, low byte */ #define AR_CNTHI 0x5 /* RW - byte count, high byte */ #define AR_DRIVE 0x6 /* RW - drive select */ #define AR_COMMAND 0x7 /* W - command register */ #define AR_STATUS 0x7 /* R - immediate status */ #endif /* * Status register bits */ #define ARS_CHECK 0x01 /* error occured, see sense key/code */ /* bit 0x02 reserved */ #define ARS_CORR 0x04 /* correctable error occured */ #define ARS_DRQ 0x08 /* data request / ireason valid */ #define ARS_DSC 0x10 /* immediate operation completed */ #define ARS_DF 0x20 /* drive fault */ #define ARS_DRDY 0x40 /* ready to get command */ #define ARS_BSY 0x80 /* registers busy */ /* for overlap mode only: */ #define ARS_SERVICE 0x10 /* service is requested */ #define ARS_DMARDY 0x20 /* ready to start a DMA transfer */ #define ARS_BITS "\20\010busy\7ready\6fault\5opdone\4drq\3corr\1check" /* * Error register bits */ #define AER_ILI 0x01 /* illegal length indication */ #define AER_EOM 0x02 /* end of media detected */ #define AER_ABRT 0x04 /* command aborted */ #define AER_MCR 0x08 /* media change requested */ #define AER_SKEY 0xf0 /* sense key mask */ #define AER_SK_NO_SENSE 0x00 /* no specific sense key info */ #define AER_SK_RECOVERED_ERROR 0x10 /* command succeeded, data recovered */ #define AER_SK_NOT_READY 0x20 /* no access to drive */ #define AER_SK_MEDIUM_ERROR 0x30 /* non-recovered data error */ #define AER_SK_HARDWARE_ERROR 0x40 /* non-recoverable hardware failure */ #define AER_SK_ILLEGAL_REQUEST 0x50 /* invalid command parameter(s) */ #define AER_SK_UNIT_ATTENTION 0x60 /* media changed */ #define AER_SK_DATA_PROTECT 0x70 /* reading read-protected sector */ #define AER_SK_BLANK_CHECK 0x80 /* blank check */ #define AER_SK_VENDOR_SPECIFIC 0x90 /* vendor specific skey */ #define AER_SK_COPY_ABORTED 0xa0 /* copy aborted */ #define AER_SK_ABORTED_COMMAND 0xb0 /* command aborted, try again */ #define AER_SK_EQUAL 0xc0 /* equal */ #define AER_SK_VOLUME_OVERFLOW 0xd0 /* volume overflow */ #define AER_SK_MISCOMPARE 0xe0 /* data did not match the medium */ #define AER_SK_RESERVED 0xf0 #define AER_BITS "\20\4mchg\3abort\2eom\1ili" /* * Feature register bits */ #define ARF_DMA 0x01 /* transfer data via DMA */ #define ARF_OVERLAP 0x02 /* release the bus until completion */ /* * Interrupt reason register bits */ #define ARI_CMD 0x01 /* command(1) or data(0) */ #define ARI_IN 0x02 /* transfer to(1) or from(0) the host */ #define ARI_RELEASE 0x04 /* bus released until completion */ /* * Drive register values */ #define ARD_DRIVE0 0xa0 /* drive 0 selected */ #define ARD_DRIVE1 0xb0 /* drive 1 selected */ /* * ATA commands */ #define ATAPIC_IDENTIFY 0xa1 /* get drive parameters */ #define ATAPIC_PACKET 0xa0 /* execute packet command */ /* * Mandatory packet commands */ #define ATAPI_TEST_UNIT_READY 0x00 /* check if the device is ready */ +#define ATAPI_REZERO_UNIT 0x01 /* reinit device */ #define ATAPI_REQUEST_SENSE 0x03 /* get sense data */ #define ATAPI_START_STOP 0x1b /* start/stop the media */ #define ATAPI_PREVENT_ALLOW 0x1e /* prevent/allow media removal */ #define ATAPI_READ_CAPACITY 0x25 /* get volume capacity */ #define ATAPI_READ_BIG 0x28 /* read data */ #define ATAPI_WRITE_BIG 0x2a /* write data */ -#define ATAPI_READ_TOC 0x43 /* get table of contents */ +#define ATAPI_SYNCHRONIZE_CACHE 0x35 /* flush write buf, close write chan */ #define ATAPI_READ_SUBCHANNEL 0x42 /* get subchannel info */ -#define ATAPI_MODE_SELECT_BIG 0x55 /* set device parameters */ +#define ATAPI_READ_TOC 0x43 /* get table of contents */ +#define ATAPI_READ_TRACK_INFO 0x52 /* get track information structure */ +#define ATAPI_MODE_SELECT 0x55 /* set device parameters */ #define ATAPI_MODE_SENSE 0x5a /* get device parameters */ +#define ATAPI_CLOSE_TRACK 0x5b /* close track/session */ +#define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */ #define ATAPI_PLAY_CD 0xb4 /* universal play command */ #define ATAPI_MECH_STATUS 0xbd /* get changer mechanism status */ -#define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */ - +#define ATAPI_READ_CD 0xbe /* read data */ /* * Optional packet commands */ #define ATAPI_PLAY_MSF 0x47 /* play by MSF address */ #define ATAPI_PAUSE 0x4b /* stop/start audio operation */ /* * Nonstandard packet commands */ #define ATAPI_PLAY_TRACK 0x48 /* play by track number */ #define ATAPI_PLAY_BIG 0xa5 /* play by logical block address */ #define DSC_POLL_INTERVAL 10 /* * Drive parameter information */ struct atapi_params { unsigned cmdsz : 2; /* packet command size */ #define AT_PSIZE_12 0 /* 12 bytes */ #define AT_PSIZE_16 1 /* 16 bytes */ unsigned : 3; unsigned drqtype : 2; /* DRQ type */ #define AT_DRQT_MPROC 0 /* microprocessor DRQ - 3 msec delay */ #define AT_DRQT_INTR 1 /* interrupt DRQ - 10 msec delay */ #define AT_DRQT_ACCEL 2 /* accelerated DRQ - 50 usec delay */ unsigned removable : 1; /* device is removable */ unsigned devtype : 5; /* device type */ #define AT_TYPE_DIRECT 0 /* direct-access (magnetic disk) */ #define AT_TYPE_TAPE 1 /* streaming tape (QIC-121 model) */ #define AT_TYPE_CDROM 5 /* CD-ROM device */ #define AT_TYPE_OPTICAL 7 /* optical disk */ unsigned : 1; unsigned proto : 2; /* command protocol */ #define AT_PROTO_ATAPI 2 short reserved1[9]; char serial[20]; /* serial number - optional */ short reserved2[3]; char revision[8]; /* firmware revision */ char model[40]; /* model name */ short reserved3[2]; u_char vendor_cap; /* vendor unique capabilities */ unsigned dmaflag : 1; /* DMA supported */ unsigned lbaflag : 1; /* LBA supported - always 1 */ unsigned iordydis : 1; /* IORDY can be disabled */ unsigned iordyflag : 1; /* IORDY supported */ unsigned : 1; unsigned ovlapflag : 1; /* overlap operation supported */ unsigned : 1; unsigned idmaflag : 1; /* interleaved DMA supported */ short reserved4; u_short pio_timing; /* PIO cycle timing */ u_short dma_timing; /* DMA cycle timing */ u_short flags; #define AT_FLAG_54_58 1 /* words 54-58 valid */ #define AT_FLAG_64_70 2 /* words 64-70 valid */ short reserved5[8]; u_char swdma_flag; /* singleword DMA mode supported */ u_char swdma_active; /* singleword DMA mode active */ u_char mwdma_flag; /* multiword DMA mode supported */ u_char mwdma_active; /* multiword DMA mode active */ u_char apio_flag; /* advanced PIO mode supported */ u_char reserved6; u_short mwdma_min; /* min. M/W DMA time per word (ns) */ u_short mwdma_dflt; /* recommended M/W DMA time (ns) - optional */ u_short pio_nfctl_min; /* min. PIO cycle time w/o flow ctl - optional */ u_short pio_iordy_min; /* min. PIO c/t with IORDY flow ctl - optional */ short reserved7[2]; u_short rls_ovlap; /* release time (us) for overlap cmd - optional */ u_short rls_service; /* release time (us) for service cmd - optional */ }; /* * ATAPI operation result structure */ struct atapires { u_char code; /* result code */ #define RES_OK 0 /* i/o done */ #define RES_ERR 1 /* i/o finished with error */ #define RES_NOTRDY 2 /* controller not ready */ #define RES_NODRQ 3 /* no data request */ #define RES_INVDIR 4 /* invalid bus phase direction */ #define RES_OVERRUN 5 /* data overrun */ #define RES_UNDERRUN 6 /* data underrun */ u_char status; /* status register contents */ u_char error; /* error register contents */ }; struct atapidrv { /* delayed attach info */ int ctlr; /* IDE controller, 0/1 */ int unit; /* drive unit, 0/1 */ int port; /* controller base port */ int attached; /* the drive is attached */ }; struct buf; struct wcd; typedef void atapi_callback_t(struct wcd *, struct buf *, int, struct atapires); struct atapicmd { /* ATAPI command block */ struct atapicmd *next; /* next command in queue */ int busy; /* busy flag */ u_char cmd[16]; /* command and args */ int unit; /* drive unit number */ int count; /* byte count, >0 - read, <0 - write */ char *addr; /* data to transfer */ atapi_callback_t *callback; /* call when done */ void *cbarg1; /* callback arg 1 */ void *cbarg2; /* callback arg 1 */ struct atapires result; /* resulting error code */ }; struct atapi { /* ATAPI controller data */ u_short port; /* i/o port base */ u_char ctrlr; /* physical controller number */ - u_int debug : 1; /* trace enable flag */ - u_int cmd16 : 1; /* 16-byte command flag */ - u_int intrcmd : 1; /* interrupt before cmd flag */ - u_int slow : 1; /* slow reaction device */ - u_int accel : 1; /* accelerated reaction device */ - u_int use_dsc : 1; /* use DSC completition handeling */ - u_int wait_for_dsc : 1; + u_char debug : 1; /* trace enable flag */ + u_char cmd16 : 1; /* 16-byte command flag */ + u_char intrcmd : 1; /* interrupt before cmd flag */ + u_char slow : 1; /* slow reaction device */ + u_char accel : 1; /* accelerated reaction device */ + u_char use_dsc : 1; /* use DSC completition handeling */ + u_char wait_for_dsc : 1; u_int dsc_timeout; u_char attached[2]; /* units are attached to subdrivers */ struct atapi_params *params[2]; /* params for units 0,1 */ struct atapicmd *queue; /* queue of commands to perform */ struct atapicmd *tail; /* tail of queue */ struct atapicmd *free; /* queue of free command blocks */ struct atapicmd cmdrq[16]; /* pool of command requests */ }; #ifdef KERNEL struct atapi; extern struct atapidrv atapi_drvtab[4]; /* delayed attach info */ extern int atapi_ndrv; /* the number of potential drives */ extern struct atapi *atapi_tab; /* the table of atapi controllers */ #ifndef ATAPI_STATIC # define atapi_start (*atapi_start_ptr) # define atapi_intr (*atapi_intr_ptr) # define atapi_debug (*atapi_debug_ptr) # define atapi_request_wait (*atapi_request_wait_ptr) # define atapi_request_callback (*atapi_request_callback_ptr) # define atapi_request_immediate (*atapi_request_immediate_ptr) #endif #ifndef ATAPI_MODULE int atapi_attach (int ctlr, int unit, int port); #endif /* * These "functions" are declared with archaic `extern's because they are * actually pointers in the !ATAPI_STATIC case. */ extern int atapi_start (int ctrlr); extern int atapi_intr (int ctrlr); extern void atapi_debug (struct atapi *ata, int on); extern struct atapires atapi_request_wait (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count); extern void atapi_request_callback (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count, atapi_callback_t *done, void *x, void *y); extern struct atapires atapi_request_immediate (struct atapi *ata, int unit, u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, u_char a9, u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15, char *addr, int count); #endif diff --git a/sys/pc98/pc98/wd_cd.c b/sys/pc98/pc98/wd_cd.c new file mode 100644 index 000000000000..46fa888a58cb --- /dev/null +++ b/sys/pc98/pc98/wd_cd.c @@ -0,0 +1,1588 @@ +/*- + * Copyright (c) 1998 Søren Schmidt + * All rights reserved. + * + * 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, + * without modification, immediately at the beginning of the file. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. + * + * $Id: atapi-cd.c,v 1.2 1998/09/02 08:47:31 sos Exp sos $ + */ + +#include "wdc.h" +#include "acd.h" +#include "opt_atapi.h" +#include "opt_devfs.h" + +#if NACD > 0 && NWDC > 0 && defined(ATAPI) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef DEVFS +#include +#endif +#include +#include + +static d_open_t acdopen; +static d_close_t acdclose; +static d_write_t acdwrite; +static d_read_t acdread; +static d_ioctl_t acdioctl; +static d_strategy_t acdstrategy; + +#define CDEV_MAJOR 69 +#define BDEV_MAJOR 19 +static struct cdevsw acd_cdevsw = { + acdopen, acdclose, acdread, acdwrite, + acdioctl, nostop, nullreset, nodevtotty, + seltrue, nommap, acdstrategy, "acd", + NULL, -1, nodump, nopsize, + D_DISK, 0, -1 +}; + +#define NUNIT 16 /* Max # of devices */ + +#define F_BOPEN 0x0001 /* The block device is opened */ +#define F_MEDIA_CHANGED 0x0002 /* The media have changed since open */ +#define F_DEBUG 0x0004 /* Print debug info */ +#define F_LOCKED 0x0008 /* This unit is locked (or should be) */ +#define F_TRACK_PREP 0x0010 /* Track should be prep'ed */ +#define F_TRACK_PREPED 0x0020 /* Track has been prep'ed */ +#define F_DISK_PREPED 0x0040 /* Disk has been prep'ed */ +#define F_WRITTEN 0x0080 /* The medium has been written to */ + +static struct acd *acdtab[NUNIT]; +static int acdnlun = 0; /* Number of configured drives */ +static u_int next_writeable_lba = 0; + +#ifndef ATAPI_STATIC +static +#endif +int acdattach(struct atapi *, int, struct atapi_params *, int); +static struct acd *acd_init_lun(struct atapi *, int, struct atapi_params *,int); +static void acd_start(struct acd *); +static void acd_done(struct acd *, struct buf *, int, struct atapires); +static int acd_read_toc(struct acd *); +static int acd_request_wait(struct acd *, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, char *, int); +static void acd_describe(struct acd *); +static int acd_open(dev_t, int, int); +static int acd_setchan(struct acd *, u_char, u_char, u_char, u_char); +static int acd_eject(struct acd *, int); +static void acd_select_slot(struct acd *); +static int acd_rezero_unit(struct acd *); +static int acd_open_disk(struct acd *, int); +static int acd_open_track(struct acd *, struct wormio_prepare_track *); +static int acd_close_track(struct acd *); +static int acd_close_disk(struct acd *); +static int acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info); +static int acd_blank_disk(struct acd *); +static void atapi_dump(int ctrlr, int lun, char *label, void *data, int len); +static void atapi_error(struct atapi *ata, int unit, struct atapires result); + +struct acd * +acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun) +{ + struct acd *ptr; + + if (!(ptr = malloc(sizeof(struct acd), M_TEMP, M_NOWAIT))) + return NULL; + bzero(ptr, sizeof(struct acd)); + bufq_init(&ptr->buf_queue); + ptr->ata = ata; + ptr->unit = unit; + ptr->lun = lun; + ptr->param = ap; + ptr->flags = F_MEDIA_CHANGED; + ptr->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + ptr->block_size = 2048; + ptr->refcnt = 0; + ptr->slot = -1; + ptr->changer_info = NULL; +#ifdef DEVFS + ptr->ra_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, 0), + DV_CHR, UID_ROOT, GID_OPERATOR, 0640, + "racd%da", lun); + ptr->rc_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART), + DV_CHR, UID_ROOT, GID_OPERATOR, 0640, + "racd%dc", lun); + ptr->a_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, 0), + DV_BLK, UID_ROOT, GID_OPERATOR, 0640, + "acd%da", lun); + ptr->c_devfs_token = + devfs_add_devswf(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART), + DV_BLK, UID_ROOT, GID_OPERATOR, 0640, + "acd%dc", lun); +#endif + return ptr; +} + +#ifndef ATAPI_STATIC +static +#endif +int +acdattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug) +{ + struct acd *cdp; + struct atapires result; + struct changer *chp; + int i, count; + + if (acdnlun >= NUNIT) { + printf("acd: too many units\n"); + return 0; + } + if (!atapi_request_immediate) { + printf("acd: configuration error, ATAPI code not present!\n"); + return 0; + } + if ((cdp = acd_init_lun(ata, unit, ap, acdnlun)) == NULL) { + printf("acd: out of memory\n"); + return 0; + } + acdtab[acdnlun] = cdp; + + if (debug) { + cdp->flags |= F_DEBUG; + atapi_dump(cdp->ata->ctrlr, cdp->lun, "info", ap, sizeof(*ap)); + } + + /* Get drive capabilities, some drives needs this repeated */ + for (count = 0 ; count < 5 ; count++) { + result = atapi_request_immediate(ata, unit, + ATAPI_MODE_SENSE, + 0, ATAPI_CDROM_CAP_PAGE, + 0, 0, 0, 0, + sizeof(cdp->cap)>>8, sizeof(cdp->cap), + 0, 0, 0, 0, 0, 0, 0, + (char *)&cdp->cap, sizeof(cdp->cap)); + if (result.code == 0 || result.code == RES_UNDERRUN) + break; + } + + /* Some drives have shorter capabilities page. */ + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code == 0) { + cdp->cap.max_speed = ntohs(cdp->cap.max_speed); + cdp->cap.max_vol_levels = ntohs(cdp->cap.max_vol_levels); + cdp->cap.buf_size = ntohs(cdp->cap.buf_size); + cdp->cap.cur_speed = ntohs(cdp->cap.cur_speed); + acd_describe(cdp); + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "cap", &cdp->cap, + sizeof(cdp->cap)); + } + /* If this is a changer device, allocate the neeeded lun's */ + if (cdp->cap.mech == MST_MECH_CHANGER) { + chp = malloc(sizeof(struct changer), M_TEMP, M_NOWAIT); + if (chp == NULL) { + printf("acd: out of memory\n"); + return 0; + } + bzero(chp, sizeof(struct changer)); + result = atapi_request_immediate(ata, unit, ATAPI_MECH_STATUS, + 0, 0, 0, 0, 0, 0, 0, + sizeof(struct changer)>>8, + sizeof(struct changer), + 0, 0, 0, 0, 0, 0, + (char *)chp, sizeof(struct changer)); + if (cdp->flags & F_DEBUG) { + printf("result.code=%d curr=%02x slots=%d len=%d\n", + result.code, chp->current_slot, chp->slots, + htons(chp->table_length)); + } + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code == 0) { + chp->table_length = htons(chp->table_length); + for (i = 0; i < chp->slots && acdnlun < NUNIT; i++) { + if (i > 0) { + cdp = acd_init_lun(ata, unit, ap, acdnlun); + if (cdp == NULL) { + printf("acd: out of memory\n"); + return 0; + } + } + cdp->slot = i; + cdp->changer_info = chp; + printf("acd%d: changer slot %d %s\n", acdnlun, i, + (chp->slot[i].present ? "disk present" : "no disk")); + acdtab[acdnlun++] = cdp; + } + if (acdnlun >= NUNIT) { + printf("acd: too many units\n"); + return 0; + } + } + } else + acdnlun++; + return 1; +} + +void +acd_describe(struct acd *cdp) +{ + int comma; + char *mechanism; + + printf("acd%d: drive speed ", cdp->lun); + if (cdp->cap.cur_speed != cdp->cap.max_speed) + printf("%d - ", cdp->cap.cur_speed * 1000 / 1024); + printf("%dKb/sec", cdp->cap.max_speed * 1000 / 1024); + if (cdp->cap.buf_size) + printf(", %dKb cache\n", cdp->cap.buf_size); + + printf("acd%d: supported read types:", cdp->lun); + comma = 0; + if (cdp->cap.read_cdr) { + printf(" CD-R"); comma = 1; + } + if (cdp->cap.read_cdrw) { + printf("%s CD-RW", comma ? "," : ""); comma = 1; + } + if (cdp->cap.cd_da) { + printf("%s CD-DA", comma ? "," : ""); comma = 1; + } + if (cdp->cap.method2) + printf("%s packet track", comma ? "," : ""); + if (cdp->cap.write_cdr || cdp->cap.write_cdrw) { + printf("\nacd%d: supported write types:", cdp->lun); + comma = 0; + if (cdp->cap.write_cdr) { + printf(" CD-R" ); comma = 1; + } + if (cdp->cap.write_cdrw) { + printf("%s CD-RW", comma ? "," : ""); comma = 1; + } + if (cdp->cap.test_write) { + printf("%s test write", comma ? "," : ""); comma = 1; + } + } + if (cdp->cap.audio_play) { + printf("\nacd%d: Audio: ", cdp->lun); + if (cdp->cap.audio_play) + printf("play"); + if (cdp->cap.max_vol_levels) + printf(", %d volume levels", cdp->cap.max_vol_levels); + } + printf("\nacd%d: Mechanism: ", cdp->lun); + switch (cdp->cap.mech) { + case MST_MECH_CADDY: + mechanism = "caddy"; break; + case MST_MECH_TRAY: + mechanism = "tray"; break; + case MST_MECH_POPUP: + mechanism = "popup"; break; + case MST_MECH_CHANGER: + mechanism = "changer"; break; + case MST_MECH_CARTRIDGE: + mechanism = "cartridge"; break; + default: + mechanism = 0; break; + } + if (mechanism) + printf("%s%s", cdp->cap.eject ? "ejectable " : "", mechanism); + else if (cdp->cap.eject) + printf("ejectable"); + + if (cdp->cap.mech != MST_MECH_CHANGER) { + printf("\nacd%d: Medium: ", cdp->lun); + switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) { + case MST_CDROM: + printf("CD-ROM "); break; + case MST_CDR: + printf("CD-R "); break; + case MST_CDRW: + printf("CD-RW "); break; + case MST_DOOR_OPEN: + printf("door open"); break; + case MST_NO_DISC: + printf("no/blank disc inside"); break; + case MST_FMT_ERROR: + printf("medium format error"); break; + } + if ((cdp->cap.medium_type & MST_TYPE_MASK_HIGH) < MST_TYPE_MASK_HIGH) { + switch (cdp->cap.medium_type & MST_TYPE_MASK_LOW) { + case MST_DATA_120: + printf("120mm data disc loaded"); break; + case MST_AUDIO_120: + printf("120mm audio disc loaded"); break; + case MST_COMB_120: + printf("120mm data/audio disc loaded"); break; + case MST_PHOTO_120: + printf("120mm photo disc loaded"); break; + case MST_DATA_80: + printf("80mm data disc loaded"); break; + case MST_AUDIO_80: + printf("80mm audio disc loaded"); break; + case MST_COMB_80: + printf("80mm data/audio disc loaded"); break; + case MST_PHOTO_80: + printf("80mm photo disc loaded"); break; + case MST_FMT_NONE: + switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) { + case MST_CDROM: + printf("unknown medium"); break; + case MST_CDR: + case MST_CDRW: + printf("blank medium"); break; + } + break; + default: + printf("unknown type=0x%x", cdp->cap.medium_type); break; + } + } + } + if (cdp->cap.lock) + printf(cdp->cap.locked ? ", locked" : ", unlocked"); + if (cdp->cap.prevent) + printf(", lock protected"); + printf("\n"); +} + +static int +acdopen(dev_t dev, int flags, int fmt, struct proc *p) +{ + int lun = dkunit(dev); + struct acd *cdp; + + if (lun >= acdnlun || !atapi_request_immediate) + return ENXIO; + cdp = acdtab[lun]; + + if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) { + /* Prevent user eject */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + } + if (fmt == S_IFBLK) + cdp->flags |= F_BOPEN; + else + ++cdp->refcnt; + + if ((flags & O_NONBLOCK) == 0) { + if ((flags & FWRITE) != 0) { + /* read/write */ + if (acd_rezero_unit(cdp)) { + printf("acd%d: rezero failed\n", lun); + return EIO; + } + } else { + /* read only */ + if (acd_read_toc(cdp) < 0) { + printf("acd%d: read_toc failed\n", lun); + /* return EIO; */ + } + } + } + return 0; +} + +int +acdclose(dev_t dev, int flags, int fmt, struct proc *p) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + if (fmt == S_IFBLK) + cdp->flags &= ~F_BOPEN; + else + --cdp->refcnt; + + /* Are we the last open ?? */ + if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) { + /* Yup, do we need to close any written tracks */ + if ((flags & FWRITE) != 0) { + if ((cdp->flags & F_TRACK_PREPED) != 0) { + acd_close_track(cdp); + cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP); + } + } + /* Allow the user eject */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + cdp->flags &= ~F_LOCKED; + return 0; +} + +static int +acdread(dev_t dev, struct uio *uio, int ioflag) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + return physio(acdstrategy, NULL, dev, 1, minphys, uio); +} + +static int +acdwrite(dev_t dev, struct uio *uio, int ioflag) +{ + struct acd *cdp = acdtab[dkunit(dev)]; + + return physio(acdstrategy, NULL, dev, 0, minphys, uio); +} + +void +acdstrategy(struct buf *bp) +{ + int lun = dkunit(bp->b_dev); + struct acd *cdp = acdtab[lun]; + int x; + +#ifdef NOTYET + /* allow write only on CD-R/RW media */ /* all for now SOS */ + if (!(bp->b_flags & B_READ) && !(writeable_media)) { + bp->b_error = EROFS; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } +#endif + + if (bp->b_bcount == 0) { + bp->b_resid = 0; + biodone(bp); + return; + } + + bp->b_pblkno = bp->b_blkno; + bp->b_resid = bp->b_bcount; + + x = splbio(); + bufqdisksort(&cdp->buf_queue, bp); + acd_start(cdp); + splx(x); +} + +static void +acd_start(struct acd *cdp) +{ + struct buf *bp = bufq_first(&cdp->buf_queue); + u_long lba, blocks; + int cmd; + int count; + + if (!bp) + return; + + bufq_remove(&cdp->buf_queue, bp); + + /* Should reject all queued entries if media have changed. */ + if (cdp->flags & F_MEDIA_CHANGED) { + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } + acd_select_slot(cdp); + + if ((bp->b_flags & B_READ) == B_WRITE) { + if ((cdp->flags & F_TRACK_PREPED) == 0) { + if ((cdp->flags & F_TRACK_PREP) == 0) { + printf("acd%d: sequence error\n", cdp->lun); + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } else { + if (acd_open_track(cdp, &cdp->preptrack) != 0) { + biodone(bp); + return; + } + cdp->flags |= F_TRACK_PREPED; + } + } + } + + if (bp->b_flags & B_READ) +#ifdef NOTYET + lba = bp->b_offset / cdp->block_size; +#else + lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE); +#endif + else + lba = next_writeable_lba + (bp->b_offset / cdp->block_size); + blocks = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size; + + if ((bp->b_flags & B_READ) == B_WRITE) { + cmd = ATAPI_WRITE_BIG; + count = -bp->b_bcount; + } else { + cmd = ATAPI_READ_BIG; + count = bp->b_bcount; + } + + atapi_request_callback(cdp->ata, cdp->unit, cmd, 0, + lba>>24, lba>>16, lba>>8, lba, 0, + blocks>>8, blocks, 0, 0, 0, 0, 0, 0, 0, + (u_char *)bp->b_data, count, + (atapi_callback_t *)acd_done, cdp, bp); +} + +static void +acd_done(struct acd *cdp, struct buf *bp, int resid, struct atapires result) +{ + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + bp->b_error = EIO; + bp->b_flags |= B_ERROR; + } else { + bp->b_resid = resid; + if ((bp->b_flags & B_READ) == B_WRITE) + cdp->flags |= F_WRITTEN; + } + biodone(bp); + acd_start(cdp); +} + +static int +acd_request_wait(struct acd *cdp, u_char cmd, u_char a1, u_char a2, + u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8, + u_char a9, char *addr, int count) +{ + struct atapires result; + + result = atapi_request_wait(cdp->ata, cdp->unit, cmd, a1, a2, a3, a4, a5, + a6, a7, a8, a9, 0, 0, 0, 0, 0, 0, addr, count); + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + return 0; +} + +static __inline void +lba2msf(int lba, u_char *m, u_char *s, u_char *f) +{ + lba += 150; + lba &= 0xffffff; + *m = lba / (60 * 75); + lba %= (60 * 75); + *s = lba / 75; + *f = lba % 75; +} + +static __inline int +msf2lba(u_char m, u_char s, u_char f) +{ + return (m * 60 + s) * 75 + f - 150; +} + +int +acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +{ + int lun = dkunit(dev); + struct acd *cdp = acdtab[lun]; + int error = 0; + + if (cdp->flags & F_MEDIA_CHANGED) + switch (cmd) { + case CDIOCRESET: + break; + default: + acd_read_toc(cdp); + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + break; + } + switch (cmd) { +/* + case CDIOCRESUME: + bzero(cdb); + cdb->cmd = ATAPI_PAUSE; + cdb->b8 = 0x01; + return atapi_cmd_wait(cdp->ata, cdp->unit, cdb, 0, 0, timout, 0); +*/ + case CDIOCRESUME: + return acd_request_wait(cdp, ATAPI_PAUSE, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0); + + case CDIOCPAUSE: + return acd_request_wait(cdp, ATAPI_PAUSE, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCSTART: + return acd_request_wait(cdp, ATAPI_START_STOP, + 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCSTOP: + return acd_request_wait(cdp, ATAPI_START_STOP, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCALLOW: + acd_select_slot(cdp); + cdp->flags &= ~F_LOCKED; + return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCPREVENT: + acd_select_slot(cdp); + cdp->flags |= F_LOCKED; + return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCRESET: + if (p->p_cred->pc_ucred->cr_uid) + return EPERM; + return acd_request_wait(cdp, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + case CDIOCEJECT: + if ((cdp->flags & F_BOPEN) && cdp->refcnt) + return EBUSY; + return acd_eject(cdp, 0); + + case CDIOCCLOSE: + if ((cdp->flags & F_BOPEN) && cdp->refcnt) + return 0; + return acd_eject(cdp, 1); + + case CDIOREADTOCHEADER: + if (!cdp->toc.hdr.ending_track) + return EIO; + bcopy(&cdp->toc.hdr, addr, sizeof(cdp->toc.hdr)); + break; + + case CDIOREADTOCENTRYS: + { + struct ioc_read_toc_entry *te = (struct ioc_read_toc_entry *)addr; + struct toc *toc = &cdp->toc; + struct toc buf; + u_long len; + u_char starting_track = te->starting_track; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (te->data_len < sizeof(toc->tab[0]) || + (te->data_len % sizeof(toc->tab[0])) != 0 || + te->address_format != CD_MSF_FORMAT && + te->address_format != CD_LBA_FORMAT) + return EINVAL; + + if (!starting_track) + starting_track = toc->hdr.starting_track; + else if (starting_track == 170) + starting_track = toc->hdr.ending_track + 1; + else if (starting_track < toc->hdr.starting_track || + starting_track > toc->hdr.ending_track + 1) + return EINVAL; + + len = ((toc->hdr.ending_track + 1 - starting_track) + 1) * + sizeof(toc->tab[0]); + if (te->data_len < len) + len = te->data_len; + if (len > sizeof(toc->tab)) + return EINVAL; + + if (te->address_format == CD_MSF_FORMAT) { + struct cd_toc_entry *entry; + + buf = cdp->toc; + toc = &buf; + entry = toc->tab + (toc->hdr.ending_track + 1 - + toc->hdr.starting_track) + 1; + while (--entry >= toc->tab) + lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute, + &entry->addr.msf.second, &entry->addr.msf.frame); + } + return copyout(toc->tab + starting_track - toc->hdr.starting_track, + te->data, len); + } + + case CDIOREADTOCENTRY: + { + struct ioc_read_toc_single_entry *te = + (struct ioc_read_toc_single_entry *)addr; + struct toc *toc = &cdp->toc; + struct toc buf; + u_char track = te->track; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (te->address_format != CD_MSF_FORMAT && + te->address_format != CD_LBA_FORMAT) + return EINVAL; + + if (!track) + track = toc->hdr.starting_track; + else if (track == 170) + track = toc->hdr.ending_track + 1; + else if (track < toc->hdr.starting_track || + track > toc->hdr.ending_track + 1) + return EINVAL; + + if (te->address_format == CD_MSF_FORMAT) { + struct cd_toc_entry *entry; + + buf = cdp->toc; + toc = &buf; + entry = toc->tab + (track - toc->hdr.starting_track); + lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute, + &entry->addr.msf.second, &entry->addr.msf.frame); + } + bcopy(toc->tab + track - toc->hdr.starting_track, + &te->entry, sizeof(struct cd_toc_entry)); + } + break; + + case CDIOCREADSUBCHANNEL: + { + struct ioc_read_subchannel *args = + (struct ioc_read_subchannel *)addr; + struct cd_sub_channel_info data; + u_long len = args->data_len; + int abslba, rellba; + + if (len > sizeof(data) || + len < sizeof(struct cd_sub_channel_header)) + return EINVAL; + + if (acd_request_wait(cdp, ATAPI_READ_SUBCHANNEL, + 0, 0x40, 1, 0, 0, 0, + sizeof(cdp->subchan)>>8, sizeof(cdp->subchan), + 0, + (char *)&cdp->subchan, + sizeof(cdp->subchan)) != 0) + return EIO; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "subchan", &cdp->subchan, + sizeof(cdp->subchan)); + + abslba = cdp->subchan.abslba; + rellba = cdp->subchan.rellba; + if (args->address_format == CD_MSF_FORMAT) { + lba2msf(ntohl(abslba), + &data.what.position.absaddr.msf.minute, + &data.what.position.absaddr.msf.second, + &data.what.position.absaddr.msf.frame); + lba2msf(ntohl(rellba), + &data.what.position.reladdr.msf.minute, + &data.what.position.reladdr.msf.second, + &data.what.position.reladdr.msf.frame); + } else { + data.what.position.absaddr.lba = abslba; + data.what.position.reladdr.lba = rellba; + } + data.header.audio_status = cdp->subchan.audio_status; + data.what.position.control = cdp->subchan.control & 0xf; + data.what.position.addr_type = cdp->subchan.control >> 4; + data.what.position.track_number = cdp->subchan.track; + data.what.position.index_number = cdp->subchan.indx; + return copyout(&data, args->data, len); + } + + case CDIOCPLAYMSF: + { + struct ioc_play_msf *args = (struct ioc_play_msf *)addr; + + return acd_request_wait(cdp, ATAPI_PLAY_MSF, 0, 0, + args->start_m, args->start_s, args->start_f, + args->end_m, args->end_s, args->end_f, + 0, 0, 0); + } + + case CDIOCPLAYBLOCKS: + { + struct ioc_play_blocks *args = (struct ioc_play_blocks *)addr; + + return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0, + args->blk>>24 & 0xff, args->blk>>16 & 0xff, + args->blk>>8 & 0xff, args->blk & 0xff, + args->len>>24 & 0xff, args->len>>16 & 0xff, + args->len>>8 & 0xff, args->len & 0xff, + 0, 0); + } + + case CDIOCPLAYTRACKS: + { + struct ioc_play_track *args = (struct ioc_play_track *)addr; + u_long start, len; + int t1, t2; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if (args->end_track < cdp->toc.hdr.ending_track + 1) + ++args->end_track; + if (args->end_track > cdp->toc.hdr.ending_track + 1) + args->end_track = cdp->toc.hdr.ending_track + 1; + t1 = args->start_track - cdp->toc.hdr.starting_track; + t2 = args->end_track - cdp->toc.hdr.starting_track; + if (t1 < 0 || t2 < 0) + return EINVAL; + start = ntohl(cdp->toc.tab[t1].addr.lba); + len = ntohl(cdp->toc.tab[t2].addr.lba) - start; + + return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0, + start>>24 & 0xff, start>>16 & 0xff, + start>>8 & 0xff, start & 0xff, + len>>24 & 0xff, len>>16 & 0xff, + len>>8 & 0xff, len & 0xff, 0, 0); + } + + case CDIOCREADAUDIO: + { + struct ioc_read_audio* args = (struct ioc_read_audio*) addr; + int lba, frames, result = 0; + u_char *buffer, *ubuf = args->buffer; + + if (!cdp->toc.hdr.ending_track) + return EIO; + + if ((frames = args->nframes) < 0) + return EINVAL; + + if (args->address_format == CD_LBA_FORMAT) + lba = args->address.lba; + else if (args->address_format == CD_MSF_FORMAT) + lba = msf2lba(args->address.msf.minute, + args->address.msf.second, + args->address.msf.frame); + else + return EINVAL; +#ifndef CD_BUFFER_BLOCKS +#define CD_BUFFER_BLOCKS 8 +#endif + if (!(buffer = malloc(CD_BUFFER_BLOCKS * 2352, M_TEMP, M_NOWAIT))) + return ENOMEM; + + while (frames > 0) { + u_char blocks; + int size; + + blocks = (frames>CD_BUFFER_BLOCKS) ? CD_BUFFER_BLOCKS : frames; + size = blocks * 2352; + + result = acd_request_wait(cdp, ATAPI_READ_CD, 4, + lba>>24, (lba>>16)&0xff, + (lba>>8)&0xff, lba&0xff, 0, 0, + blocks, 0xf0, buffer, size); + if (result != 0) + break; + + result = copyout(buffer, ubuf, size); + if (result != 0) + break; + + ubuf += size; + frames -= blocks; + lba += blocks; + } + + free(buffer, M_TEMP); + return result; + } + + case CDIOCGETVOL: + { + struct ioc_vol *arg = (struct ioc_vol *)addr; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, + sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + arg->vol[0] = cdp->au.port[0].volume; + arg->vol[1] = cdp->au.port[1].volume; + arg->vol[2] = cdp->au.port[2].volume; + arg->vol[3] = cdp->au.port[3].volume; + } + break; + + case CDIOCSETVOL: + { + struct ioc_vol *arg = (struct ioc_vol *)addr; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, + sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, + CDROM_AUDIO_PAGE_MASK, 0, 0, 0, 0, + sizeof(cdp->aumask)>>8,sizeof(cdp->aumask), + 0, + (char *)&cdp->aumask, sizeof(cdp->aumask)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "mask", &cdp->aumask, + sizeof(cdp->aumask)); + + cdp->au.data_length = 0; + cdp->au.port[0].channels = CHANNEL_0; + cdp->au.port[1].channels = CHANNEL_1; + cdp->au.port[0].volume = arg->vol[0] & cdp->aumask.port[0].volume; + cdp->au.port[1].volume = arg->vol[1] & cdp->aumask.port[1].volume; + cdp->au.port[2].volume = arg->vol[2] & cdp->aumask.port[2].volume; + cdp->au.port[3].volume = arg->vol[3] & cdp->aumask.port[3].volume; + return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10, + 0, 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), + 0, (char *)&cdp->au, -sizeof(cdp->au)); + } + + case CDIOCSETPATCH: + { + struct ioc_patch *arg = (struct ioc_patch *)addr; + + return acd_setchan(cdp, arg->patch[0], arg->patch[1], + arg->patch[2], arg->patch[3]); + } + + case CDIOCSETMONO: + return acd_setchan(cdp, CHANNEL_0|CHANNEL_1, CHANNEL_0|CHANNEL_1, 0, 0); + + case CDIOCSETSTEREO: + return acd_setchan(cdp, CHANNEL_0, CHANNEL_1, 0, 0); + + case CDIOCSETMUTE: + return acd_setchan(cdp, 0, 0, 0, 0); + + case CDIOCSETLEFT: + return acd_setchan(cdp, CHANNEL_0, CHANNEL_0, 0, 0); + + case CDIOCSETRIGHT: + return acd_setchan(cdp, CHANNEL_1, CHANNEL_1, 0, 0); + + case CDRIOCNEXTWRITEABLEADDR: + { + struct acd_track_info track_info; + + if ((error = acd_read_track_info(cdp, 0xff, &track_info))) + break; + if (!track_info.nwa_valid) + return EINVAL; + next_writeable_lba = track_info.next_writeable_addr; + *(int*)addr = track_info.next_writeable_addr; + } + break; + + case WORMIOCPREPDISK: + { + struct wormio_prepare_disk *w = (struct wormio_prepare_disk *)addr; + + if (w->dummy != 0 && w->dummy != 1) + error = EINVAL; + else { + error = acd_open_disk(cdp, w->dummy); + if (error == 0) { + cdp->flags |= F_DISK_PREPED; + cdp->dummy = w->dummy; + cdp->speed = w->speed; + } + } + } + break; + + case WORMIOCPREPTRACK: + { + struct wormio_prepare_track *w =(struct wormio_prepare_track *)addr; + + if (w->audio != 0 && w->audio != 1) + error = EINVAL; + else if (w->audio == 0 && w->preemp) + error = EINVAL; + else if ((cdp->flags & F_DISK_PREPED) == 0) { + error = EINVAL; + printf("acd%d: sequence error (PREP_TRACK)\n", cdp->lun); + } else { + cdp->flags |= F_TRACK_PREP; + cdp->preptrack = *w; + } + } + break; + + case WORMIOCFINISHTRACK: + if ((cdp->flags & F_TRACK_PREPED) != 0) + error = acd_close_track(cdp); + cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP); + break; + + case WORMIOCFIXATION: + { + struct wormio_fixation *w = + (struct wormio_fixation *)addr; + + if ((cdp->flags & F_WRITTEN) == 0) + error = EINVAL; + else if (w->toc_type < 0 /* WORM_TOC_TYPE_AUDIO */ || + w->toc_type > 4 /* WORM_TOC_TYPE_CDI */ ) + error = EINVAL; + else if (w->onp != 0 && w->onp != 1) + error = EINVAL; + else { + /* no fixation needed if dummy write */ + if (cdp->dummy == 0) + error = acd_close_disk(cdp); + cdp->flags &= + ~(F_WRITTEN|F_DISK_PREPED|F_TRACK_PREP|F_TRACK_PREPED); + } + } + break; + + case CDRIOCBLANK: + return acd_blank_disk(cdp); + + default: + return ENOTTY; + } + return error; +} + +static int +acd_read_toc(struct acd *cdp) +{ + int ntracks, len; + struct atapires result; + + bzero(&cdp->toc, sizeof(cdp->toc)); + bzero(&cdp->info, sizeof(cdp->info)); + + acd_select_slot(cdp); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + + if (result.code == RES_ERR && + (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION) { + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + + cdp->flags &= ~F_MEDIA_CHANGED; + + len = sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry); + if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, + len>>8, len & 0xff, 0, (char *)&cdp->toc, len) != 0) { + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + ntracks = cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1; + if (ntracks <= 0 || ntracks > MAXTRK) { + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + + len = sizeof(struct ioc_toc_header) + ntracks * sizeof(struct cd_toc_entry); + if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0, + len>>8, len & 0xff, 0, (char *)&cdp->toc, len) & 0xff){ + bzero(&cdp->toc, sizeof(cdp->toc)); + return 0; + } + + cdp->toc.hdr.len = ntohs(cdp->toc.hdr.len); + + if (acd_request_wait(cdp, ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0, + (char *)&cdp->info, sizeof(cdp->info)) != 0) + bzero(&cdp->info, sizeof(cdp->info)); + + cdp->toc.tab[ntracks].control = cdp->toc.tab[ntracks - 1].control; + cdp->toc.tab[ntracks].addr_type = cdp->toc.tab[ntracks - 1].addr_type; + cdp->toc.tab[ntracks].track = 170; + cdp->toc.tab[ntracks].addr.lba = cdp->info.volsize; + + cdp->info.volsize = ntohl(cdp->info.volsize); + cdp->info.blksize = ntohl(cdp->info.blksize); + + if (cdp->info.volsize && cdp->toc.hdr.ending_track + /* && (cdp->flags & F_DEBUG) */) { + printf("acd%d: ", cdp->lun); + if (cdp->toc.tab[0].control & 4) + printf("%ldMB ", cdp->info.volsize / 512); + else + printf("%ld:%ld audio ", cdp->info.volsize / 75 / 60, + cdp->info.volsize / 75 % 60); + printf("(%ld sectors (%d bytes)), %d tracks\n", + cdp->info.volsize, cdp->info.blksize, + cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1); + } + return 0; +} + +/* + * Set up the audio channel masks. + */ +static int +acd_setchan(struct acd *cdp, u_char c0, u_char c1, u_char c2, u_char c3) +{ + int error; + + error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE, + 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, sizeof(cdp->au)); + if (error) + return error; + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, sizeof(cdp->au)); + if (cdp->au.page_code != CDROM_AUDIO_PAGE) + return EIO; + + cdp->au.data_length = 0; + cdp->au.port[0].channels = c0; + cdp->au.port[1].channels = c1; + cdp->au.port[2].channels = c2; + cdp->au.port[3].channels = c3; + return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10, + 0, 0, 0, 0, 0, + sizeof(cdp->au)>>8, sizeof(cdp->au), 0, + (char *)&cdp->au, -sizeof(cdp->au)); +} + +static int +acd_eject(struct acd *cdp, int close) +{ + struct atapires result; + + acd_select_slot(cdp); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_START_STOP, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + if (result.code == RES_ERR && + ((result.error & AER_SKEY) == AER_SK_NOT_READY || + (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) { + int err; + + if (!close) + return 0; + err = acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 3, + 0, 0, 0, 0, 0, 0, 0); + if (err) + return err; + + acd_read_toc(cdp); + + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_LOCKED; + return 0; + } + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + if (close) + return 0; + + tsleep((caddr_t) &lbolt, PRIBIO, "acdej1", 0); + tsleep((caddr_t) &lbolt, PRIBIO, "acdej2", 0); + + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + cdp->flags &= ~F_LOCKED; + + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + return acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0); +} + +static void +acd_select_slot(struct acd *cdp) +{ + if (cdp->slot < 0 || cdp->changer_info->current_slot == cdp->slot) + return; + + /* Unlock (might not be needed but its cheaper than asking) */ + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + /* Unload the current media from player */ + acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 2, + 0, 0, 0, cdp->changer_info->current_slot, 0, 0, 0); + + /* load the wanted slot */ + acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 3, + 0, 0, 0, cdp->slot, 0, 0, 0); + + cdp->changer_info->current_slot = cdp->slot; + + /* Lock the media if needed */ + if (cdp->flags & F_LOCKED) { + acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0); + } +} + +static int +acd_rezero_unit(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_REZERO_UNIT, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0); +} + +static int +acd_open_disk(struct acd *cdp, int test) +{ + next_writeable_lba = 0; + return 0; +} + +static int +acd_close_disk(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_CLOSE_TRACK, 0x00, + 0x02, 0, 0, 0/*track*/, 0, 0, 0, 0, 0, 0); +} + +static int +acd_open_track(struct acd *cdp, struct wormio_prepare_track *ptp) +{ + struct write_param param; + struct atapires result; + int error; + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SENSE, + 0, 0x05, 0, 0, 0, 0, + sizeof(param)>>8, sizeof(param), + 0, 0, 0, 0, 0, 0, 0, + (char *)¶m, sizeof(param)); + + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", ¶m, sizeof(param)); + + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + param.page_code = 0x05; + param.page_length = 0x32; + param.test_write = cdp->dummy ? 1 : 0; + param.write_type = CDR_WTYPE_TRACK; + + switch (ptp->audio) { +/* switch (data_type) { */ + + case 0: +/* case CDR_DATA: */ + cdp->block_size = 2048; + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_ROM_MODE1; + param.session_format = CDR_SESS_CDROM; + break; + + default: +/* case CDR_AUDIO: */ + cdp->block_size = 2352; + if (ptp->preemp) + param.track_mode = CDR_TMODE_AUDIO; + else + param.track_mode = 0; + param.data_block_type = CDR_DB_RAW; + param.session_format = CDR_SESS_CDROM; + break; + +/* + case CDR_MODE2: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_ROM_MODE2; + param.session_format = CDR_SESS_CDROM; + break; + + case CDR_XA1: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE1; + param.session_format = CDR_SESS_CDROM_XA; + break; + + case CDR_XA2: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE2_F1; + param.session_format = CDR_SESS_CDROM_XA; + break; + + case CDR_CDI: + param.track_mode = CDR_TMODE_DATA; + param.data_block_type = CDR_DB_XA_MODE2_F1; + param.session_format = CDR_SESS_CDI; + break; +*/ + } + + param.multi_session = CDR_MSES_NONE; + param.fp = 0; + param.packet_size = 0; + + if (cdp->flags & F_DEBUG) + atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", ¶m, sizeof(param)); + + result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SELECT, + 0x10, 0, 0, 0, 0, 0, + sizeof(param)>>8, sizeof(param), + 0, 0, 0, 0, 0, 0, 0, + (char *)¶m, -sizeof(param)); + + if (result.code == RES_UNDERRUN) + result.code = 0; + + if (result.code) { + atapi_error(cdp->ata, cdp->unit, result); + return EIO; + } + return 0; +} + +static int +acd_close_track(struct acd *cdp) +{ + return acd_request_wait(cdp, ATAPI_SYNCHRONIZE_CACHE, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +static int +acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info) +{ + int error; + + error = acd_request_wait(cdp, ATAPI_READ_TRACK_INFO, 0x01, + lba>>24, (lba>>16)&0xff, + (lba>>8)&0xff, lba&0xff, + 0, + sizeof(*info)>>8, sizeof(*info), 0, + (char *)info, sizeof(*info)); + if (error) + return error; + info->track_start_addr = ntohl(info->track_start_addr); + info->next_writeable_addr = ntohl(info->next_writeable_addr); + info->free_blocks = ntohl(info->free_blocks); + info->fixed_packet_size = ntohl(info->fixed_packet_size); + info->track_length = ntohl(info->track_length); + return 0; +} + +static int +acd_blank_disk(struct acd *cdp) +{ + int error; + + error = acd_request_wait(cdp, 0xa1, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + cdp->flags |= F_MEDIA_CHANGED; + cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); + return error; +} + +static void +atapi_error(struct atapi *ata, int unit, struct atapires result) +{ + if (result.code != RES_ERR) { + printf("atapi%d:%d: ERROR %d, status=%b, error=%b\n", + ata->ctrlr, unit, result.code, result.status, + ARS_BITS, result.error, AER_BITS); + return; + } + switch (result.error & AER_SKEY) { + case AER_SK_NOT_READY: + if (ata->debug) + printf("atapi%d:%d: not ready\n", ata->ctrlr, unit); + break; + + case AER_SK_BLANK_CHECK: + if (ata->debug) + printf("atapi%d:%d: blank check\n", ata->ctrlr, unit); + break; + + case AER_SK_MEDIUM_ERROR: + if (ata->debug) + printf("atapi%d:%d: medium error\n", ata->ctrlr, unit); + break; + + case AER_SK_HARDWARE_ERROR: + if (ata->debug) + printf("atapi%d:%d: hardware error\n", ata->ctrlr, unit); + break; + + case AER_SK_ILLEGAL_REQUEST: + if (ata->debug) + printf("atapi%d:%d: illegal request\n", ata->ctrlr, unit); + break; + + case AER_SK_UNIT_ATTENTION: + if (ata->debug) + printf("atapi%d:%d: unit attention\n", ata->ctrlr, unit); + break; + + case AER_SK_DATA_PROTECT: + if (ata->debug) + printf("atapi%d:%d: reading protected data\n", ata->ctrlr, unit); + break; + + case AER_SK_ABORTED_COMMAND: + if (ata->debug) + printf("atapi%d:%d: command aborted\n", ata->ctrlr, unit); + break; + + case AER_SK_MISCOMPARE: + if (ata->debug) + printf("atapi%d:%d: data don't match medium\n", ata->ctrlr, unit); + break; + + default: + if (ata->debug) + printf("atapi%d:%d: unknown error, status=%b, error=%b\n", + ata->ctrlr, unit, result.status, ARS_BITS, + result.error, AER_BITS); + } +} + +static void +atapi_dump(int ctrlr, int lun, char *label, void *data, int len) +{ + u_char *p = data; + + printf ("atapi%d%d: %s %x", ctrlr, lun, label, *p++); + while (--len > 0) printf ("-%x", *p++); + printf ("\n"); +} + +#ifdef ACD_MODULE +#include +#include +#include + +MOD_DEV(acd, LM_DT_BLOCK, BDEV_MAJOR, &acd_bdevsw); +MOD_DEV(racd, LM_DT_CHAR, CDEV_MAJOR, &acd_cdevsw); + +int +acd_load(struct lkm_table *lkmtp, int cmd) +{ + struct atapi *ata; + int n, u; + + if (!atapi_start) + return EPROTONOSUPPORT; + n = 0; + for (ata = atapi_tab; ata < atapi_tab + 2; ++ata) + if (ata->port) + for (u = 0; u < 2; ++u) + if (ata->params[u] && !ata->attached[u] && + acdattach(ata, u, ata->params[u], + ata->debug) >= 0) { + ata->attached[u] = 1; + ++n; + } + if (!n) + return ENXIO; + return 0; +} + +int +acd_unload(struct lkm_table *lkmtp, int cmd) +{ + struct acd **cdpp; + + for (cdpp = acdtab; cdpp < acdtab + acdnlun; ++cdpp) + if (((*cdpp)->flags & F_BOPEN) || (*cdpp)->refcnt) + return EBUSY; + for (cdpp = acdtab; cdpp < acdtab + acdnlun; ++t) { + (*cdpp)->ata->attached[(*cdpp)->unit] = 0; + free(*cdpp, M_TEMP); + } + acdnlun = 0; + bzero(acdtab, sizeof(acdtab)); + return 0; +} + +int +acd_mod(struct lkm_table *lkmtp, int cmd, int ver) +{ + int err = 0; + + if (ver != LKM_VERSION) + return EINVAL; + + if (cmd == LKM_E_LOAD) + err = acd_load(lkmtp, cmd); + else if (cmd == LKM_E_UNLOAD) + err = acd_unload(lkmtp, cmd); + if (err) + return err; + + lkmtp->private.lkm_dev = &MOD_PRIVATE(racd); + err = lkmdispatch(lkmtp, cmd); + if (err) + return err; + + lkmtp->private.lkm_dev = &MOD_PRIVATE(acd); + return lkmdispatch(lkmtp, cmd); +} + +#endif /* ACD_MODULE */ + +static acd_devsw_installed = 0; + +static void +acd_drvinit(void *unused) +{ + dev_t dev; + + if (!acd_devsw_installed) { + cdevsw_add_generic(BDEV_MAJOR, CDEV_MAJOR, &acd_cdevsw); + acd_devsw_installed = 1; + } +} + +SYSINIT(acddev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE + CDEV_MAJOR, acd_drvinit, NULL) +#endif /* NACD && NWDC && ATAPI */ diff --git a/sys/sys/cdio.h b/sys/sys/cdio.h index 30a328ad18dc..516e67abe0b8 100644 --- a/sys/sys/cdio.h +++ b/sys/sys/cdio.h @@ -1,276 +1,286 @@ /* * 16 Feb 93 Julian Elischer (julian@dialix.oz.au) * - * $Id: cdio.h,v 1.17 1997/05/04 15:24:23 joerg Exp $ + * $Id: cdio.h,v 1.18 1998/06/08 09:47:47 bde Exp $ */ /* <1> Fixed a conflict with ioctl usage. There were two different functions using code #25. Made file formatting consistent. Added two new ioctl codes: door closing and audio pitch playback. Added a STEREO union called STEREO. 5-Mar-95 Frank Durda IV bsdmail@nemesis.lonestar.org <2> Added a new ioctl that allows you to find out what capabilities a drive has and what commands it will accept. This allows a user application to only offer controls (buttons, sliders, etc) for functions that drive can actually do. Things it can't do can disappear or be greyed-out (like some other system). If the driver doesn't respond to this call, well, handle it the way you used to do it. 2-Apr-95 Frank Durda IV bsdmail@nemesis.lonestar.org */ /* Shared between kernel & process */ #ifndef _SYS_CDIO_H_ #define _SYS_CDIO_H_ #ifndef KERNEL #include #endif #include union msf_lba { struct { unsigned char unused; unsigned char minute; unsigned char second; unsigned char frame; } msf; int lba; /* network byte order */ u_char addr[4]; }; struct cd_toc_entry { u_int :8; u_int control:4; u_int addr_type:4; u_char track; u_int :8; union msf_lba addr; }; struct cd_sub_channel_header { u_int :8; u_char audio_status; #define CD_AS_AUDIO_INVALID 0x00 #define CD_AS_PLAY_IN_PROGRESS 0x11 #define CD_AS_PLAY_PAUSED 0x12 #define CD_AS_PLAY_COMPLETED 0x13 #define CD_AS_PLAY_ERROR 0x14 #define CD_AS_NO_STATUS 0x15 u_char data_len[2]; }; struct cd_sub_channel_position_data { u_char data_format; u_int control:4; u_int addr_type:4; u_char track_number; u_char index_number; union msf_lba absaddr; union msf_lba reladdr; }; struct cd_sub_channel_media_catalog { u_char data_format; u_int :8; u_int :8; u_int :8; u_int :7; u_int mc_valid:1; u_char mc_number[15]; }; struct cd_sub_channel_track_info { u_char data_format; u_int :8; u_char track_number; u_int :8; u_int :7; u_int ti_valid:1; u_char ti_number[15]; }; struct cd_sub_channel_info { struct cd_sub_channel_header header; union { struct cd_sub_channel_position_data position; struct cd_sub_channel_media_catalog media_catalog; struct cd_sub_channel_track_info track_info; } what; }; /***************************************************************\ * Ioctls for the CD drive * \***************************************************************/ struct ioc_play_track { u_char start_track; u_char start_index; u_char end_track; u_char end_index; }; #define CDIOCPLAYTRACKS _IOW('c',1,struct ioc_play_track) struct ioc_play_blocks { int blk; int len; }; #define CDIOCPLAYBLOCKS _IOW('c',2,struct ioc_play_blocks) struct ioc_read_subchannel { u_char address_format; #define CD_LBA_FORMAT 1 #define CD_MSF_FORMAT 2 u_char data_format; #define CD_SUBQ_DATA 0 #define CD_CURRENT_POSITION 1 #define CD_MEDIA_CATALOG 2 #define CD_TRACK_INFO 3 u_char track; int data_len; struct cd_sub_channel_info *data; }; #define CDIOCREADSUBCHANNEL _IOWR('c', 3 , struct ioc_read_subchannel ) struct ioc_toc_header { u_short len; u_char starting_track; u_char ending_track; }; #define CDIOREADTOCHEADER _IOR('c',4,struct ioc_toc_header) struct ioc_read_toc_entry { u_char address_format; u_char starting_track; u_short data_len; struct cd_toc_entry *data; }; #define CDIOREADTOCENTRYS _IOWR('c',5,struct ioc_read_toc_entry) struct ioc_read_toc_single_entry { u_char address_format; u_char track; struct cd_toc_entry entry; }; #define CDIOREADTOCENTRY _IOWR('c',6,struct ioc_read_toc_single_entry) struct ioc_patch { u_char patch[4]; /* one for each channel */ }; #define CDIOCSETPATCH _IOW('c',9,struct ioc_patch) struct ioc_vol { u_char vol[4]; /* one for each channel */ }; #define CDIOCGETVOL _IOR('c',10,struct ioc_vol) #define CDIOCSETVOL _IOW('c',11,struct ioc_vol) #define CDIOCSETMONO _IO('c',12) #define CDIOCSETSTERIO _IO('c',13) #define CDIOCSETSTEREO _IO('c',13) #define CDIOCSETMUTE _IO('c',14) #define CDIOCSETLEFT _IO('c',15) #define CDIOCSETRIGHT _IO('c',16) #define CDIOCSETDEBUG _IO('c',17) #define CDIOCCLRDEBUG _IO('c',18) #define CDIOCPAUSE _IO('c',19) #define CDIOCRESUME _IO('c',20) #define CDIOCRESET _IO('c',21) #define CDIOCSTART _IO('c',22) #define CDIOCSTOP _IO('c',23) #define CDIOCEJECT _IO('c',24) struct ioc_play_msf { u_char start_m; u_char start_s; u_char start_f; u_char end_m; u_char end_s; u_char end_f; }; #define CDIOCPLAYMSF _IOW('c',25,struct ioc_play_msf) #define CDIOCALLOW _IO('c',26) #define CDIOCPREVENT _IO('c',27) /*<1>For drives that support it, this*/ /*<1>causes the drive to close its door*/ /*<1>and make the media (if any) ready*/ #define CDIOCCLOSE _IO('c',28) /*<1>*/ struct ioc_pitch /*<1>For drives that support it, this*/ { /*<1>call instructs the drive to play the*/ short speed; /*<1>audio at a faster or slower-than-normal*/ }; /*<1>rate. -32767 to -1 is slower, 0==normal,*/ /*<1>and 1 to 32767 is faster. LSB bits are*/ /*<1>discarded first by drives with less res.*/ #define CDIOCPITCH _IOW('c',29,struct ioc_pitch) /*<1>*/ struct ioc_capability { /*<2>*/ u_long play_function; /*<2>*/ #define CDDOPLAYTRK 0x00000001 /*<2>Can Play tracks/index*/ #define CDDOPLAYMSF 0x00000002 /*<2>Can Play msf to msf*/ #define CDDOPLAYBLOCKS 0x00000004 /*<2>Can Play range of blocks*/ #define CDDOPAUSE 0x00000100 /*<2>Output can be paused*/ #define CDDORESUME 0x00000200 /*<2>Output can be resumed*/ #define CDDORESET 0x00000400 /*<2>Drive can be completely reset*/ #define CDDOSTART 0x00000800 /*<2>Audio can be started*/ #define CDDOSTOP 0x00001000 /*<2>Audio can be stopped*/ #define CDDOPITCH 0x00002000 /*<2>Audio pitch */ u_long routing_function; /*<2>*/ #define CDREADVOLUME 0x00000001 /*<2>Volume settings can be read*/ #define CDSETVOLUME 0x00000002 /*<2>Volume settings can be set*/ #define CDSETMONO 0x00000100 /*<2>Output can be set to mono*/ #define CDSETSTEREO 0x00000200 /*<2>Output can be set to stereo (def)*/ #define CDSETLEFT 0x00000400 /*<2>Output can be set to left only*/ #define CDSETRIGHT 0x00000800 /*<2>Output can be set to right only*/ #define CDSETMUTE 0x00001000 /*<2>Output can be muted*/ #define CDSETPATCH 0x00008000 /*<2>Direct routing control allowed*/ u_long special_function; /*<2>*/ #define CDDOEJECT 0x00000001 /*<2>The tray can be opened*/ #define CDDOCLOSE 0x00000002 /*<2>The tray can be closed*/ #define CDDOLOCK 0x00000004 /*<2>The tray can be locked*/ #define CDREADHEADER 0x00000100 /*<2>Can read Table of Contents*/ #define CDREADENTRIES 0x00000200 /*<2>Can read TOC Entries*/ #define CDREADSUBQ 0x00000200 /*<2>Can read Subchannel info*/ #define CDREADRW 0x00000400 /*<2>Can read subcodes R-W*/ #define CDHASDEBUG 0x00004000 /*<2>The tray has dynamic debugging*/ }; /*<2>*/ #define CDIOCCAPABILITY _IOR('c',30,struct ioc_capability) /*<2>*/ +struct ioc_read_audio +{ + u_char address_format; + union msf_lba address; + int nframes; + u_char* buffer; +}; + +#define CDIOCREADAUDIO _IOWR('c',31,struct ioc_read_audio) + #endif /* !_SYS_CDIO_H_ */