ftp.nice.ch/pub/next/tools/cdrom/mCD.96Sep09.s.tar.gz#/mCD/scsi_cd.subproj/scsi_commands.h

This is scsi_commands.h in view mode; [Download] [Up]

/*
 * scsi_commands.h: header file for scsi_command.c
 *
 * History
 * -------
 * Tue Sep  3 15:00:13 PDT 1991 James C. Lee at NeXT
 *  Created (copied a lot of data structures & functions calls from
 *   perftest.c by Mike DeMoney)
 */

#ifndef SCSI_COMMANDS
#define SCSI_COMMANDS

#import <sys/time.h>
#import <bsd/dev/disk.h>
#import <sys/types.h>

/* I use a copy of the NS-3.1 version of bsd/dev/scsireg.h, because
 * at some point I think I want to split it apart into "field values"
 * (such as #define DEVTYPE_DISK), and actual structure definitions.
 */
/* #import <bsd/dev/scsireg.h> */
#import "scsireg_31.h"		/* garance... */

#define Version "0.00"


struct mode_sense_cmd {
	u_int	msc_opcode:8,
		msc_lun:3,
		msc_mbz1:5,
		msc_pcf:2,
		msc_page:6,
		msc_mbz2:8;
	u_char	msc_len;
	u_char	msc_ctrl;
};

struct param_list_header {
	u_char	plh_len;
	u_char	plh_medium;
	u_char	plh_wp:1,
		plh_reserved:7;
	u_char	plh_blkdesclen;
};

struct block_descriptor {
	u_int	bd_density:8,
		bd_nblk:24;
	u_int	bd_reserved:8,
		bd_blklen:24;
};

struct device_format_params {
	u_char	dfp_savable:1,
		dfp_reserved:1,
		dfp_pagecode:6;
	u_char	dfp_pagelen;
	u_short	dfp_trkszone;
	u_short	dfp_altsecszone;
	u_short	dfp_alttrkszone;
	u_short	dfp_alttrksvol;
	u_short	dfp_sectors;
	u_short	dfp_bytessector;
	u_short	dfp_interleave;
	u_short	dfp_trkskew;
	u_short	dfp_cylskew;
	u_char	dfp_ssec:1,
		dfp_hsec:1,
		dfp_rmb:1,
		dfp_surf:1,
		dfp_reserved2:4;
	u_char	dfp_reserved3;
	u_char	dfp_reserved4;
	u_char	dfp_reserved5;
};

struct rigid_drive_params {
	u_char	rdp_savable:1,
		rdp_reserved:1,
		rdp_pagecode:6;
	u_char	rdp_pagelen;

	u_char	rdp_maxcylmsb;
	u_char	rdp_maxcylinb;
	u_char	rdp_maxcyllsb;

	u_char	rdp_maxheads;

	u_char	rdp_wpstartmsb;
	u_char	rdp_wpstartinb;
	u_char	rdp_wpstartlsb;

	u_char	rdp_rwcstartmsb;
	u_char	rdp_rwcstartinb;
	u_char	rdp_rwcstartlsb;

	u_char	rdp_stepratemsb;
	u_char	rdp_stepratelsb;

	u_char	rdp_landcylmsb;
	u_char	rdp_landcylinb;
	u_char	rdp_landcyllsb;

	u_char	rdp_reserved2;
	u_char	rdp_reserved3;
	u_char	rdp_reserved4;
};

#define	THREE_BYTE(x)	\
		(((x##msb)<<16)|((x##inb)<<8)|(x##lsb))

#define	TWO_BYTE(x)	\
		(((x##msb)<<8)|(x##lsb))

struct mode_sense_reply {
	struct param_list_header msr_plh;
	struct block_descriptor msr_bd;
	union {
		struct device_format_params u_msr_dfp;
		struct rigid_drive_params u_msr_rdp;
	}u;
};

/* two variables for about the same thing, just so references to
 * the number are clear about which number they really mean.
 */
#define INQ_ALL_MAX_SCSI_ID   7		/* SCSI ID's are 0 to 7 */ 
#define INQ_ALL_MAX_SCSI_CNT  8		/* so there are 8 of them */

struct inquiry_all_entry {
	int	devIoStat;		/* copy of sr_io_status */
	int	deviceNumber;		/* ie, the 0 in "sd0" */
	struct	inquiry_reply inqResult;
};
struct inquiry_all_reply {
	int	maxScsiCount;		/* note: max scsi count */
	struct inquiry_all_entry  scsiArray[INQ_ALL_MAX_SCSI_CNT];
};

/* C functions */
void fatal(const char *msg, ...);
int do_inquiry(int fd, struct inquiry_reply *irp, struct esense_reply *erp);
int do_inquiryall(int replyCount, struct inquiry_all_reply *all,
	struct esense_reply *erp);
int do_testunitready(int fd, struct timeval *tvp, struct esense_reply *erp);
int do_modesense(int fd, struct mode_sense_reply *msrp, int page,
	struct esense_reply *erp);
int do_readcapacity(int fd, struct capacity_reply *crp,
	struct esense_reply *erp);
int do_seek(int fd, int lba, struct timeval *tvp, struct esense_reply *erp);
int do_read(int fd, int lba, int nblks, struct timeval *tvp,
	struct esense_reply *erp);
int do_write(int fd, int lba, int nblks, struct timeval *tvp,
	struct esense_reply *erp);

#endif	/* #ifndef SCSI_COMMANDS */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.