1*23240Smckusick /* 2*23240Smckusick * Copyright (c) 1982 Regents of the University of California. 3*23240Smckusick * All rights reserved. The Berkeley software License Agreement 4*23240Smckusick * specifies the terms and conditions for redistribution. 5*23240Smckusick * 6*23240Smckusick * @(#)saio.h 6.3 (Berkeley) 06/08/85 7*23240Smckusick */ 8325Sbill 9325Sbill /* 1011363Ssam * Header file for standalone package 11325Sbill */ 12325Sbill 13325Sbill /* 1411363Ssam * Io block: includes an 15325Sbill * inode, cells for the use of seek, etc, 16325Sbill * and a buffer. 17325Sbill */ 18325Sbill struct iob { 1911363Ssam int i_flgs; /* see F_ below */ 2011363Ssam struct inode i_ino; /* inode, if file */ 2111363Ssam int i_unit; /* pseudo device unit */ 2211363Ssam daddr_t i_boff; /* block offset on device */ 2311363Ssam daddr_t i_cyloff; /* cylinder offset on device */ 2411363Ssam off_t i_offset; /* seek offset in file */ 2511363Ssam daddr_t i_bn; /* 1st block # of next read */ 2611363Ssam char *i_ma; /* memory address of i/o buffer */ 2711363Ssam int i_cc; /* character count of transfer */ 2811363Ssam int i_error; /* error # return */ 2911363Ssam int i_errcnt; /* error count for driver retries */ 3011363Ssam int i_errblk; /* block # in error for error reporting */ 3111363Ssam char i_buf[MAXBSIZE];/* i/o buffer */ 326004Smckusic union { 3311363Ssam struct fs ui_fs; /* file system super block info */ 346004Smckusic char dummy[SBSIZE]; 356004Smckusic } i_un; 36325Sbill }; 376004Smckusic #define i_fs i_un.ui_fs 3810333Shelge #define NULL 0 39325Sbill 4010022Ssam #define F_READ 0x1 /* file opened for reading */ 4110022Ssam #define F_WRITE 0x2 /* file opened for writing */ 4210022Ssam #define F_ALLOC 0x4 /* buffer allocated */ 4310022Ssam #define F_FILE 0x8 /* file instead of device */ 4410333Shelge #define F_NBSF 0x10 /* no bad sector forwarding */ 4511139Ssam #define F_ECCLM 0x20 /* limit # of bits in ecc correction */ 4611139Ssam #define F_SSI 0x40 /* set skip sector inhibit */ 4715052Skarels #define F_SEVRE 0x80 /* Severe burnin (no retries, no ECC) */ 4810022Ssam /* io types */ 4910022Ssam #define F_RDDATA 0x0100 /* read data */ 5010022Ssam #define F_WRDATA 0x0200 /* write data */ 5110022Ssam #define F_HDR 0x0400 /* include header on next i/o */ 5210022Ssam #define F_CHECK 0x0800 /* perform check of data read/write */ 5310022Ssam #define F_HCHECK 0x1000 /* perform check of header and data */ 54325Sbill 5510022Ssam #define F_TYPEMASK 0xff00 5610022Ssam 57325Sbill /* 5811363Ssam * Device switch. 59325Sbill */ 60325Sbill struct devsw { 61325Sbill char *dv_name; 62325Sbill int (*dv_strategy)(); 63325Sbill int (*dv_open)(); 64325Sbill int (*dv_close)(); 6510022Ssam int (*dv_ioctl)(); 66325Sbill }; 67325Sbill 68325Sbill struct devsw devsw[]; 69325Sbill 7011139Ssam /* 7111139Ssam * Drive description table. 7211139Ssam * Returned from SAIODEVDATA call. 7311139Ssam */ 7410351Shelge struct st { 7511139Ssam short nsect; /* # sectors/track */ 7611363Ssam short ntrak; /* # tracks/surfaces/heads */ 7711139Ssam short nspc; /* # sectors/cylinder */ 7811139Ssam short ncyl; /* # cylinders */ 7911139Ssam short *off; /* partition offset table (cylinders) */ 8010333Shelge }; 8110333Shelge 82325Sbill /* 8311363Ssam * Request codes. Must be the same a F_XXX above 84325Sbill */ 85325Sbill #define READ 1 86325Sbill #define WRITE 2 87325Sbill 88325Sbill #define NBUFS 4 89325Sbill 906004Smckusic char b[NBUFS][MAXBSIZE]; 91325Sbill daddr_t blknos[NBUFS]; 92325Sbill 9311363Ssam #define NFILES 4 94325Sbill struct iob iob[NFILES]; 956373Smckusic 9610022Ssam extern int errno; /* just like unix */ 9710022Ssam 9810022Ssam /* error codes */ 9910022Ssam #define EBADF 1 /* bad file descriptor */ 10010022Ssam #define EOFFSET 2 /* relative seek not supported */ 10110022Ssam #define EDEV 3 /* improper device specification on open */ 10210022Ssam #define ENXIO 4 /* unknown device specified */ 10310022Ssam #define EUNIT 5 /* improper unit specification */ 10410022Ssam #define ESRCH 6 /* directory search for file failed */ 10510022Ssam #define EIO 7 /* generic error */ 10611363Ssam #define ECMD 10 /* undefined driver command */ 10711363Ssam #define EBSE 11 /* bad sector error */ 10811363Ssam #define EWCK 12 /* write check error */ 10911363Ssam #define EECC 13 /* uncorrectable ecc error */ 11011363Ssam #define EHER 14 /* hard error */ 11110022Ssam 11210022Ssam /* ioctl's -- for disks just now */ 11310333Shelge #define SAIOHDR (('d'<<8)|1) /* next i/o includes header */ 11410022Ssam #define SAIOCHECK (('d'<<8)|2) /* next i/o checks data */ 11510022Ssam #define SAIOHCHECK (('d'<<8)|3) /* next i/o checks header & data */ 11610333Shelge #define SAIONOBAD (('d'<<8)|4) /* inhibit bad sector forwarding */ 11711139Ssam #define SAIODOBAD (('d'<<8)|5) /* enable bad sector forwarding */ 11811139Ssam #define SAIOECCLIM (('d'<<8)|6) /* limit ecc correction to 5 bits */ 11910333Shelge #define SAIOECCUNL (('d'<<8)|7) /* use standard ecc procedures */ 12011363Ssam #define SAIODEVDATA (('d'<<8)|8) /* get device data */ 12111363Ssam #define SAIOSSI (('d'<<8)|9) /* set skip sector inhibit */ 12211363Ssam #define SAIONOSSI (('d'<<8)|10) /* inhibit skip sector handling */ 12311363Ssam #define SAIOSSDEV (('d'<<8)|11) /* is device skip sector type? */ 12411363Ssam #define SAIODEBUG (('d'<<8)|12) /* enable/disable debugging */ 12515052Skarels #define SAIOSEVRE (('d'<<8)|13) /* severe burnin, no ECC, no retries */ 12615052Skarels #define SAIONSEVRE (('d'<<8)|14) /* clear severe burnin */ 12710333Shelge 12810333Shelge /* codes for sector header word 1 */ 12911363Ssam #define HDR1_FMT22 0x1000 /* standard 16 bit format */ 13011363Ssam #define HDR1_OKSCT 0xc000 /* sector ok */ 13111363Ssam #define HDR1_SSF 0x2000 /* skip sector flag */ 132