* First baby steps in letting our drivers use the new I/O request/scheduler

architecture: for now, we do this on the lowest layer only, therefore all
  requests are handled synchronously (ie. in the scheduler's thread).
* Instead of using the block_io module, scsi_disk (and scsi_cd) are now
  exporting a device on their own, and use an I/O scheduler with an appropriate
  DMA resource.
* There are still lots of TODOs, and it can easily panic - don't update if
  you intend to demo Haiku.
* scsi_periph now only has an io() function that get an io_operation, instead
  of the previous read/write functions, moved preferred CCB size from those
  functions into the device registration.
* Changed all scsi_periph files to C++.
* scsi_cd ported, too, but untested.
* Removed block_io from image - it will be removed completely soon.
* Temporarily commented an ASSERT() in the ATA bus manager (in case you use
  it); it's sometimes triggered by the code now, and I haven't yet looked into
  the issue -- doesn't seem to harm, at least.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26828 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-08-05 21:11:51 +00:00
parent 34faa5f214
commit 24593e2c79
19 changed files with 814 additions and 751 deletions
+1
View File
@@ -134,6 +134,7 @@ typedef struct scsi_ccb {
uint16 sg_count; // number of S/G entries
uint32 data_length; // length of data
int32 data_resid; // data transfer residual length: 2's comp
void *io_operation;
uchar sense[SCSI_MAX_SENSE_SIZE]; // autosense data
uchar sense_resid; // autosense resid length: 2's comp
+32 -46
View File
@@ -7,8 +7,7 @@
#ifndef _SCSI_PERIPH_H
#define _SCSI_PERIPH_H
/*
Use this module to minimize work required to write a SCSI
/*! Use this module to minimize work required to write a SCSI
peripheral driver.
It takes care of:
@@ -64,21 +63,21 @@ typedef struct periph_device_info *periph_device_cookie;
// cookie issued by driver per file handle
typedef struct periph_handle_info *periph_handle_cookie;
typedef struct IOOperation io_operation;
// callbacks to be provided by peripheral driver
typedef struct scsi_periph_callbacks {
// *** block devices ***
// informs of new size of medium
// (set to NULL if not a block device)
void (*set_capacity)( periph_device_cookie periph_device, uint64 capacity,
uint32 block_size );
void (*set_capacity)(periph_device_cookie cookie, uint64 capacity,
uint32 blockSize);
// *** removable devices
// called when media got changed (can be NULL if medium is not changable)
// (you don't need to call periph->media_changed, but it's doesn't if you do)
// ccb - request at your disposal
void (*media_changed)( periph_device_cookie periph_device,
scsi_ccb *request );
void (*media_changed)(periph_device_cookie cookie, scsi_ccb *request);
} scsi_periph_callbacks;
@@ -87,73 +86,61 @@ typedef struct scsi_periph_interface {
module_info info;
// *** init/cleanup ***
status_t (*register_device)(
periph_device_cookie periph_device,
scsi_periph_callbacks *callbacks,
scsi_device scsi_device,
scsi_device_interface *scsi,
device_node *node,
bool removable,
scsi_periph_device *driver );
status_t (*unregister_device)( scsi_periph_device driver );
// preferred_ccb_size - preferred command size; if zero, the shortest is used
status_t (*register_device)(periph_device_cookie cookie,
scsi_periph_callbacks *callbacks, scsi_device scsiDevice,
scsi_device_interface *scsi, device_node *node, bool removable,
int preferredCcbSize, scsi_periph_device *driver);
status_t (*unregister_device)(scsi_periph_device driver);
// *** basic command execution ***
// exec command, retrying on problems
status_t (*safe_exec)(
scsi_periph_device periph_device,
scsi_ccb *request );
status_t (*safe_exec)(scsi_periph_device periphCookie, scsi_ccb *request);
// exec simple command
status_t (*simple_exec)( scsi_periph_device device,
void *cdb, uchar cdb_len, void *data, size_t data_len,
int ccb_flags );
status_t (*simple_exec)(scsi_periph_device device, void *cdb,
uint8 cdbLength, void *data, size_t dataLength, int ccbFlags);
// *** file handling ***
// to be called when a new file is opened
status_t (*handle_open)( scsi_periph_device device,
periph_handle_cookie periph_handle, scsi_periph_handle *res_handle );
status_t (*handle_open)(scsi_periph_device device,
periph_handle_cookie periph_handle, scsi_periph_handle *_handle);
// to be called when a file is closed
status_t (*handle_close)( scsi_periph_handle handle );
status_t (*handle_close)(scsi_periph_handle handle);
// to be called when a file is freed
status_t (*handle_free)( scsi_periph_handle handle );
status_t (*handle_free)(scsi_periph_handle handle);
// *** default implementation for block devices ***
// block read
// preferred_ccb_size - preferred command size; if zero, the shortest is used
status_t (*read)( scsi_periph_handle handle, const phys_vecs *vecs,
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred,
int preferred_ccb_size );
// block write
// (see block_read)
status_t (*write)( scsi_periph_handle handle, const phys_vecs *vecs,
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred,
int preferred_ccb_size );
status_t (*io)(scsi_periph_device device, io_operation *operation,
size_t *_bytesTransferred);
// block ioctls
status_t (*ioctl)( scsi_periph_handle handle, int op, void *buf, size_t len );
status_t (*ioctl)(scsi_periph_handle handle, int op, void *buffer,
size_t length);
// check medium capacity (calls set_capacity callback on success)
// request - ccb for this device; is used to talk to device
status_t (*check_capacity)( scsi_periph_device device, scsi_ccb *request );
status_t (*check_capacity)(scsi_periph_device device, scsi_ccb *request);
// *** removable media ***
// to be called when a medium change is detected to block subsequent commands
void (*media_changed)( scsi_periph_device device );
void (*media_changed)(scsi_periph_device device);
// convert result of *request to err_res
err_res (*check_error)( scsi_periph_device device, scsi_ccb *request );
err_res (*check_error)(scsi_periph_device device, scsi_ccb *request);
// send start or stop command to device
// with_LoEj = true - include loading/ejecting,
// false - only do allow/deny
err_res (*send_start_stop)( scsi_periph_device device, scsi_ccb *request,
bool start, bool with_LoEj );
// withLoadEject = true - include loading/ejecting,
// false - only do allow/deny
err_res (*send_start_stop)(scsi_periph_device device, scsi_ccb *request,
bool start, bool withLoadEject);
// checks media status and waits for device to become ready
// returns: B_OK, B_DEV_MEDIA_CHANGE_REQUESTED, B_NO_MEMORY or
// pending error reported by handle_get_error
status_t (*get_media_status)( scsi_periph_handle handle );
status_t (*get_media_status)(scsi_periph_handle handle);
// compose device name consisting of prefix and path/target/LUN
// (result must be freed by caller)
char *(*compose_device_name)(device_node *device_node, const char *prefix);
// fill data with icon (for B_GET_ICON ioctl)
status_t (*get_icon)( icon_type type, device_icon *data );
status_t (*get_icon)(icon_type type, device_icon *data);
// synchronizes (flush) the device cache
err_res(*synchronize_cache)(scsi_periph_device device, scsi_ccb *request);
@@ -162,4 +149,3 @@ typedef struct scsi_periph_interface {
#define SCSI_PERIPH_MODULE_NAME "generic/scsi_periph/v1"
#endif /* _SCSI_PERIPH_H */