Commit Graph

1219 Commits

Author SHA1 Message Date
christos 4ac9cd5ebe add missing initializer 2006-09-03 05:20:21 +00:00
christos 144543fb61 add missing initializer 2006-09-03 05:18:03 +00:00
matt 49b2425f19 Use an unsigned int for the blksize on read_cd_capacity. 2006-09-01 03:29:32 +00:00
reinoud 0b228f5987 Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.
2006-08-31 21:32:42 +00:00
reinoud e3b1c755c2 Remove two spurious empty lines in functions 2006-08-31 20:22:34 +00:00
reinoud 055cdf5d13 Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.
2006-08-31 19:46:54 +00:00
bjh21 8009229e9b The Fujitsu drive in my A540 supports sync transfers but apparently
doesn't advertise this in INQUIRY.  It makes it nice and obvious with
SDTR, though, so add it to the list.
2006-08-29 20:40:23 +00:00
christos 4e4ed26fac add missing initializer 2006-08-28 00:38:47 +00:00
christos 6ab0a579ce Add missing initializer. 2006-08-28 00:22:15 +00:00
bjh21 286856d098 QAS REQUEST is a one-byte message. Make MSG_IS1BYTE recognise this. 2006-08-26 23:32:55 +00:00
christos f73c6e5980 Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).
2006-08-23 17:19:32 +00:00
reinoud 12283b1fe9 Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.
2006-08-10 14:45:51 +00:00
drochner bf84051422 some fixes for removable media (USB floppies in particular):
-allow to open RAW_PART, even if readdisklabel() doesn't like what it sees
-fix PERIPH_MEDIA_LOADED toggling on every other open attempt
-Don't reset PERIPH_REMOVABLE if prevent/allow fails - this is normal
 for floppy drives. The flag is required for media change detection.
 Honour XS_CTL_SILENT for the "no door lock" printouts, and set that flag
 where scsipi_prevent() is called during open/close.
Tested with a USB floppy and a USB cardreader.
2006-07-09 17:12:21 +00:00
tron 9021894476 Make this build with GCC 4.x. 2006-06-27 10:34:25 +00:00
kardel de4337ab21 merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
2006-06-07 22:33:33 +00:00
nathanw 9822b848e6 Change return type of sdgetdisklabel() from void to int; return an error
if readdisklabel() returned an error.

sdopen(): Return an error if sdgetdisklabel() returns an error. This prevents
a crash in spec_open() (and possibly elsewhere) if a sd device is detached in
the middle of sdopen().
2006-06-01 15:53:09 +00:00
christos fe6055587f void casts to functions whose return values are ignored. 2006-05-21 23:56:09 +00:00
blymn 10df330c85 Prefix iostat structure elements with io_ 2006-04-20 12:13:51 +00:00
nathanw 611b39a8f6 In scsipi_done(), bail out early if the scsipi_xfer has already been
marked as done. Works around one problem with detaching in-use sd
devices, as described on tech-kern:

http://mail-index.netbsd.org/tech-kern/2005/09/22/0002.html
2006-04-17 14:30:40 +00:00
christos c6bb3943dd Coverity CID 1100: Avoid NULL pointer dereferences. 2006-04-14 17:36:51 +00:00
christos 30baf54001 Coverity CID 1101: Protect against address argument being NULL. 2006-04-14 17:33:10 +00:00
blymn 3c0adb7d99 Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.
2006-04-14 13:09:05 +00:00
thorpej 07c30f824f Use device_private(). 2006-03-30 16:09:28 +00:00
thorpej 78ffd948be Replace device_locators() with device_locator(), and use it. 2006-03-29 06:00:46 +00:00
thorpej 39cd836ee1 Use device_unit(). 2006-03-28 17:38:24 +00:00
thorpej dbf31290b3 Use device_parent(). 2006-03-25 23:25:24 +00:00
yamt ec5a93183a merge yamt-uio_vmspace branch.
- use vmspace rather than proc or lwp where appropriate.
  the latter is more natural to specify an address space.
  (and less likely to be abused for random purposes.)
- fix a swdmover race.
2006-03-01 12:38:10 +00:00
thorpej 3ddf26777f Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
2006-02-20 16:50:36 +00:00
perry fbae48b901 Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
2006-02-16 20:17:12 +00:00
reinoud a62dc37d89 Add name of the processed feature like the others have. 2006-02-08 23:09:15 +00:00
reinoud c0dbf19c1e Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.
2006-02-04 21:26:15 +00:00
reinoud 1b09e70fcd Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.
2006-02-02 14:48:02 +00:00
christos a6c7e45e28 fix typo. 2006-01-07 07:18:06 +00:00
yamt 2addc3084c remove B_EINTR as it isn't used anymore. 2006-01-07 00:26:58 +00:00
yamt 690d424f28 - add simple functions to allocate/free a buffer for i/o.
- make bufpool static.
2006-01-04 10:13:05 +00:00
perry 93124077ae Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:27:29 +00:00
reinoud 19eca236e0 Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.
2005-12-21 13:11:27 +00:00
reinoud 4eae0d0cfe The as `unused' specified field in the readdiscinfo SCSI command is really
application_code to be able to write to -RW media when its in restricted
mode.
2005-12-20 01:44:22 +00:00
christos 04735b5d69 delete extraneous verbiage. 2005-12-16 17:54:36 +00:00
reinoud 4cdfa6bead Clean up cdgetdisklabel. It was jumping over a return... 2005-12-15 17:56:32 +00:00
reinoud cdfee8349d Allow SCIOCCOMMAND ioctl that executes a SCSI command to also be issued
within the kernel when the FKIOCTL flag is passed to the ioctl.

No code actually uses this yet but is committed for completion.
2005-12-14 21:55:47 +00:00
simonb ae278e7e7d Remove blank line added to end of file by previous change. 2005-12-11 23:34:27 +00:00
reinoud 700d0843b3 Add SCSI calls for read discinfo and read trackinfo. Also add the various
read toc formats returned.
2005-12-11 23:26:31 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
reinoud 17f915ee27 Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.
2005-12-11 00:01:54 +00:00
reinoud 705000f60a Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.
2005-12-10 21:17:21 +00:00
bouyer 514622c61f Adapt previous change to recent scsipi. Pointed out by Simon Burge. 2005-12-09 09:24:30 +00:00
bouyer dd5eb5979f Some USB devices reports themselves as removable, but have no door and
so don't support the SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL command.
When an "Illegal field in CDB" is reported for this command, mark the
device as non-removable (which is always true for USB keys from the SCSI
point of view), print a message and ignore the error.
For DIOCLOCK, return ENOTTY if the device is not removable instead of
trying a command which will fail.

Fix a problem reported by Hubert Feyrer for some USB umass devices, patch
tested by him.
2005-12-08 22:14:19 +00:00
tsutsui d0c28ccd6d Fix typo (FALLTHOUGH -> FALLTHROUGH). From Jeff Ito. 2005-11-26 13:54:18 +00:00
martin b1134bf887 Rework the funny "user_strat: No ioctl" error messages - the functions
have not been called user_strat for quite some time and the message is
confusing if you do not know the code.
2005-11-01 20:44:04 +00:00
bouyer 1421f4d030 Don't claim there is a data in or out phase if the datalen is 0 (userland
shouldn't claim it either, but a buggy software shouldn't be able to crash
the kernel anyway). Should fix port-sparc64/31925 by Johan A.van Zanten
(which should really be kern/31925).
Analysed and patch tested by Martin Husemann.
2005-11-01 15:40:00 +00:00
yamt 8217506e75 fix ioctl problems after the recent physio changes
in some drivers including wd and scsi.

- physio: if a caller provided a buf, stick to use it
  because some drivers use it as an identifier.
- sprinkle simple_locks.
- scsistrategy: rather than issueing an async request and
  waiting for its completion, simply issue a sync request.
  the way to wait for the completion had an assumption that
  B_CALL is never used.  it isn't the case after the recent
  physio() changes.

pointed/analyzed/tested by Martin Husemann.
2005-10-31 14:36:41 +00:00
yamt aec75b1cc6 - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
  have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
  from sys/bufq.h to sys/bufq_impl.h.
  (is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c.  (not tested)
2005-10-15 17:29:10 +00:00
reinoud 04d00c8e39 Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()
2005-09-06 22:19:14 +00:00
reinoud d462489ea5 Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.
2005-09-05 21:16:24 +00:00
reinoud b28d0c5529 Document executed SCSI commands with the IOCTL's to prevent confusion. 2005-08-28 22:51:01 +00:00
drochner 46ed4b50c4 s/locdesc_t/int/g 2005-08-26 12:42:11 +00:00
drochner e6a178f21f kill a number of autoconf submatch functions which follow the
standard scheme:
if (<configured> != <wildcard> && <configured> != <real>)
	then fail
else
	ask device match function

This is handled by config_stdsubmatch() now.
2005-08-25 22:33:18 +00:00
drochner fa3cb84d62 replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
2005-08-25 18:35:38 +00:00
blymn 110bb51ae7 Split out stats attach code ready for shifting
Add sysctl hooks here for the time being.
2005-08-13 10:50:50 +00:00
blymn 1742ba7763 Add tape statistics structure pointer. 2005-08-07 12:25:08 +00:00
blymn d943093426 Gather statistics for tape drives. 2005-08-07 12:24:30 +00:00
rtr c19cae9065 change output from "rogue" to "quirks apply" - resolves pr#25387 2005-07-16 05:12:26 +00:00
drochner a8dbed44ea tighten the autoconf constraints by passing the atapi/ata/ata_hl attribute
to config_found()
(after some cleanup we might be able to kill SCSIPI_BUSTYPE_*)
2005-07-07 17:51:31 +00:00
bouyer a5bc956f51 Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.
2005-07-06 14:28:39 +00:00
thorpej 527d62e0a2 - When starting an ATA or ATAPI transfer, handle the case where (*dma_init)()
returns EINVAL, indicating that DMA cannot be done for this transfer.
  Fall back to PIO in this case.
- Add a geodeide_dma_init() routine that checks to make sure that transfers
  start on a 16 byte boundary, returning EINVAL if not.  Works around a chip
  bug that causes a hard system hang.

Problem reported and patch tested by Erik Fair.
2005-07-06 01:46:52 +00:00
peter 130e3c23a2 Fix typos. 2005-06-07 13:45:11 +00:00
jdc 7e31a175ec Remove cast to non-const and make this compile again. 2005-06-03 13:44:11 +00:00
xtraeme f55b68d1bd Add missing const. 2005-05-31 02:56:54 +00:00
christos a984bbf91a - remove bogus casts
- add more const
2005-05-30 04:25:32 +00:00
christos 3acb3fe622 - Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
2005-05-29 22:00:50 +00:00
chs a4ef51503f as a stop-gap measure to allow boot-from-disk to work on hppa,
add some padding to the end of struct scsipi_xfer on that platform.
2005-05-18 13:58:10 +00:00
drochner 99c093bad3 fix more SSD_RCODE_VALID misuse introduced in cleanup 2005-04-25 17:52:30 +00:00
drochner d918258c4d Revert the part if 1.236 which comprises a functional change.
While I didn't observe a misbehaviour yet, this _must_ be
wrong because SSD_RCODE_VALID is used incorrectly.
2005-04-25 17:35:26 +00:00
drochner 3214fe94f4 revert the only part of rev. 1.177 which made a functional
change -- it broke error reporting because st->asc(q) are
not set
(actually, I believe that SSD_RCODE_VALID is misnamed)
2005-04-25 17:08:46 +00:00
drochner 6dda78f17a make the scsibus target/lun and the atapibus drive locators optional
(they already had default values; we could kill the [...=N] syntax
completely or at least have config(8) assume that a locator with
a default is optional)
2005-04-15 19:20:24 +00:00
yamt 7abb70e1a5 scsipi_completion_thread:
if we seemt to need more resources after doing ADAPTER_REQ_GROW_RESOURCES,
yield cpu rather than busy-looping.  PR/25164.
2005-04-04 11:26:50 +00:00
yamt 99229e5d39 introduce a function to drain bufq and use it where appropriate. 2005-03-31 11:28:53 +00:00
soren 999e530258 Remove a bit of old cruft. 2005-02-28 22:56:15 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
thorpej df9803ce96 Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding.  Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes.  Place items described
by the SCSI Primary Commands document into scsi_spc.h.
2005-02-21 00:29:06 +00:00
perry 18db93c7f6 de-__P 2005-02-04 02:10:35 +00:00
reinoud f323bc537c Backing out changes to clean up scsipi. I was pointed out there were
problems i hadn't seen. To prevent lossage i'd decided to back off all
changes and let them be reviewed on tech-kern.
2005-02-01 00:19:34 +00:00
simonb c9234f1972 Revert incorrect u_long->uint32_t conversion. 2005-01-31 23:46:33 +00:00
reinoud 4145e39ac7 Fix LP64 problems introduced by my u_long->uint32_t conversion. 2005-01-31 23:39:02 +00:00
reinoud b220d67a3e Part of the cleanup of sys/scsipi's use of types; rename all u_int* to
uint* and change the u_long's to uint32_t's where possible. Note that the
iocl definitions/hooks have to be ulong (or u_long) or they'll bomb out.
2005-01-31 23:06:41 +00:00
reinoud f93ea32254 As part of cleaning up sys/scsipi, replace all u_char by uint8_t and
replace all `short' with int16_t.
2005-01-31 21:13:16 +00:00
reinoud 842f22fc3a As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :( 2005-01-30 23:42:58 +00:00
reinoud 82eee08288 The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.
2005-01-30 23:39:42 +00:00
ginsbach 661eb28d4c Add command to read the defect data from a direct access device. 2005-01-07 02:08:34 +00:00
thorpej 4127c59173 Define SYNCHRONIZE CACHE (16). 2004-12-07 23:21:06 +00:00
thorpej 6ad79ad747 SYNCHRONIZE_CACHE -> SYNCHRONIZE_CACHE_10 2004-12-07 23:16:40 +00:00
thorpej dffe7d8e8d READ_CAPACITY -> READ_CAPACITY_10 2004-12-07 23:14:03 +00:00
thorpej ce91ac7d6b USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).
2004-12-07 23:07:31 +00:00
thorpej 78e83f262c Nothing references "struct scsi_generic" anymore; delete it. 2004-12-07 22:27:17 +00:00
thorpej e0747e9825 Use READ/WRITE (16) if the LBA is larger than 32 bits. Another bit
of kern/28514.
2004-12-04 19:02:25 +00:00
thorpej e112950229 And thus spake SBC-3:
If the number of logical blocks exceeds the maximum value that is able to be
specified in the RETURNED  LOGICAL BLOCK ADDRESS field, the device server
shall set the RETURNED LOGICAL BLOCK ADDRESS field to  FFFFFFFFh. The
application client should then issue a READ CAPACITY (16) command (see 5.11)
to  retrieve the READ CAPACITY (16) parameter data.

Implement this in scsipi_size().

First issue in kern/28514.
2004-12-03 20:20:32 +00:00
thorpej e9818f5b5e When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
2004-10-30 18:08:34 +00:00
yamt 05f25dcc2a move buffer queue related stuffs from buf.h to their own header, bufq.h. 2004-10-28 07:07:35 +00:00
bouyer ccd16ca6dc Adjust some debug printfs after b_bcount was changed from long to int.
From Patrick Welche on current-users@
2004-10-17 17:49:04 +00:00