1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * %sccs.include.noredist.c% 9 * 10 * @(#)saio.h 7.1 (Berkeley) 04/24/90 11 */ 12 13 /* 14 * Header file for standalone package 15 */ 16 17 /* 18 * Io block: includes an 19 * inode, cells for the use of seek, etc, 20 * and a buffer. 21 */ 22 struct iob { 23 int i_flgs; /* see F_ below */ 24 struct inode i_ino; /* inode, if file */ 25 int i_unit; /* pseudo device unit */ 26 daddr_t i_boff; /* block offset on device */ 27 off_t i_offset; /* seek offset in file */ 28 daddr_t i_bn; /* 1st block # of next read */ 29 char *i_ma; /* memory address of i/o buffer */ 30 int i_cc; /* character count of transfer */ 31 int i_error; /* error # return */ 32 int i_errcnt; /* error count for driver retries */ 33 int i_errblk; /* block # in error for error reporting */ 34 struct fs i_fs; /* file system super block info */ 35 char i_buf[MAXBSIZE];/* i/o buffer */ 36 }; 37 38 /* 39 * Macros to handle conversion from unit and partition to dev_t's. 40 */ 41 #define minor_partition(s) (s & 7) 42 #define minor_unit(s) ((s>>3) & 31) 43 #define make_minor(u,p) ((u<<3) | p) 44 45 #define NULL 0 46 47 #define F_READ 0x1 /* file opened for reading */ 48 #define F_WRITE 0x2 /* file opened for writing */ 49 #define F_ALLOC 0x4 /* buffer allocated */ 50 #define F_FILE 0x8 /* file instead of device */ 51 #define F_NBSF 0x10 /* no bad sector forwarding */ 52 #define F_ECCLM 0x20 /* limit # of bits in ecc correction */ 53 #define F_SSI 0x40 /* set skip sector inhibit */ 54 #define F_SEVRE 0x80 /* Severe burnin (no retries, no ECC) */ 55 /* io types */ 56 #define F_RDDATA 0x0100 /* read data */ 57 #define F_WRDATA 0x0200 /* write data */ 58 #define F_HDR 0x0400 /* include header on next i/o */ 59 #define F_CHECK 0x0800 /* perform check of data read/write */ 60 #define F_HCHECK 0x1000 /* perform check of header and data */ 61 62 #define F_TYPEMASK 0xff00 63 64 /* 65 * Device switch. 66 */ 67 struct devsw { 68 char *dv_name; 69 int (*dv_strategy)(); 70 int (*dv_open)(); 71 int (*dv_close)(); 72 int (*dv_ioctl)(); 73 }; 74 75 struct devsw devsw[]; 76 77 /* 78 * Drive description table. 79 * Returned from SAIODEVDATA call. 80 */ 81 struct st { 82 short nsect; /* # sectors/track */ 83 short ntrak; /* # tracks/surfaces/heads */ 84 short nspc; /* # sectors/cylinder */ 85 short ncyl; /* # cylinders */ 86 short *off; /* partition offset table (cylinders) */ 87 }; 88 89 /* 90 * Request codes. Must be the same a F_XXX above 91 */ 92 #define READ 1 93 #define WRITE 2 94 95 #define NFILES 2 96 struct iob iob[NFILES]; 97 98 extern int errno; /* just like unix */ 99 100 /* error codes */ 101 #define EBADF 1 /* bad file descriptor */ 102 #define EOFFSET 2 /* relative seek not supported */ 103 #define EDEV 3 /* improper device specification on open */ 104 #define ENXIO 4 /* unknown device specified */ 105 #define EUNIT 5 /* improper unit specification */ 106 #define ESRCH 6 /* directory search for file failed */ 107 #define EIO 7 /* generic error */ 108 #define ECMD 10 /* undefined driver command */ 109 #define EBSE 11 /* bad sector error */ 110 #define EWCK 12 /* write check error */ 111 #define EECC 13 /* uncorrectable ecc error */ 112 #define EHER 14 /* hard error */ 113 114 /* ioctl's -- for disks just now */ 115 #define SAIOHDR (('d'<<8)|1) /* next i/o includes header */ 116 #define SAIOCHECK (('d'<<8)|2) /* next i/o checks data */ 117 #define SAIOHCHECK (('d'<<8)|3) /* next i/o checks header & data */ 118 #define SAIONOBAD (('d'<<8)|4) /* inhibit bad sector forwarding */ 119 #define SAIODOBAD (('d'<<8)|5) /* enable bad sector forwarding */ 120 #define SAIOECCLIM (('d'<<8)|6) /* limit ecc correction to 5 bits */ 121 #define SAIOECCUNL (('d'<<8)|7) /* use standard ecc procedures */ 122 #define SAIODEVDATA (('d'<<8)|8) /* get device data */ 123 #define SAIOSSI (('d'<<8)|9) /* set skip sector inhibit */ 124 #define SAIONOSSI (('d'<<8)|10) /* inhibit skip sector handling */ 125 #define SAIOSSDEV (('d'<<8)|11) /* is device skip sector type? */ 126 #define SAIODEBUG (('d'<<8)|12) /* enable/disable debugging */ 127 #define SAIOSEVRE (('d'<<8)|13) /* severe burnin, no ECC, no retries */ 128 #define SAIONSEVRE (('d'<<8)|14) /* clear severe burnin */ 129