xref: /csrg-svn/sys/stand.att/saio.h (revision 25440)
123240Smckusick /*
223240Smckusick  * Copyright (c) 1982 Regents of the University of California.
323240Smckusick  * All rights reserved.  The Berkeley software License Agreement
423240Smckusick  * specifies the terms and conditions for redistribution.
523240Smckusick  *
6*25440Skarels  *	@(#)saio.h	6.4 (Berkeley) 11/08/85
723240Smckusick  */
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_SSI		0x40	/* set skip sector inhibit */
4610022Ssam /* io types */
4710022Ssam #define	F_RDDATA	0x0100	/* read data */
4810022Ssam #define	F_WRDATA	0x0200	/* write data */
4910022Ssam #define F_HDR		0x0400	/* include header on next i/o */
5010022Ssam #define F_CHECK		0x0800	/* perform check of data read/write */
5110022Ssam #define F_HCHECK	0x1000	/* perform check of header and data */
52325Sbill 
5310022Ssam #define	F_TYPEMASK	0xff00
5410022Ssam 
55325Sbill /*
5611363Ssam  * Device switch.
57325Sbill  */
58325Sbill struct devsw {
59325Sbill 	char	*dv_name;
60325Sbill 	int	(*dv_strategy)();
61325Sbill 	int	(*dv_open)();
62325Sbill 	int	(*dv_close)();
6310022Ssam 	int	(*dv_ioctl)();
64325Sbill };
65325Sbill 
66325Sbill struct devsw devsw[];
67325Sbill 
6811139Ssam /*
6911139Ssam  * Drive description table.
7011139Ssam  * Returned from SAIODEVDATA call.
7111139Ssam  */
7210351Shelge struct st {
7311139Ssam 	short	nsect;		/* # sectors/track */
7411363Ssam 	short	ntrak;		/* # tracks/surfaces/heads */
7511139Ssam 	short	nspc;		/* # sectors/cylinder */
7611139Ssam 	short	ncyl;		/* # cylinders */
7711139Ssam 	short	*off;		/* partition offset table (cylinders) */
7810333Shelge };
7910333Shelge 
80325Sbill /*
8111363Ssam  * Request codes. Must be the same a F_XXX above
82325Sbill  */
83325Sbill #define	READ	1
84325Sbill #define	WRITE	2
85325Sbill 
86325Sbill #define	NBUFS	4
87325Sbill 
886004Smckusic char	b[NBUFS][MAXBSIZE];
89325Sbill daddr_t	blknos[NBUFS];
90325Sbill 
9111363Ssam #define	NFILES	4
92325Sbill struct	iob iob[NFILES];
936373Smckusic 
9410022Ssam extern	int errno;	/* just like unix */
9510022Ssam 
9610022Ssam /* error codes */
9710022Ssam #define	EBADF	1	/* bad file descriptor */
9810022Ssam #define	EOFFSET	2	/* relative seek not supported */
9910022Ssam #define	EDEV	3	/* improper device specification on open */
10010022Ssam #define	ENXIO	4	/* unknown device specified */
10110022Ssam #define	EUNIT	5	/* improper unit specification */
10210022Ssam #define	ESRCH	6	/* directory search for file failed */
10310022Ssam #define	EIO	7	/* generic error */
10411363Ssam #define	ECMD	10	/* undefined driver command */
10511363Ssam #define	EBSE	11	/* bad sector error */
10611363Ssam #define	EWCK	12	/* write check error */
10711363Ssam #define	EECC	13	/* uncorrectable ecc error */
10811363Ssam #define	EHER	14	/* hard error */
10910022Ssam 
11010022Ssam /* ioctl's -- for disks just now */
11110333Shelge #define	SAIOHDR		(('d'<<8)|1)	/* next i/o includes header */
11210022Ssam #define	SAIOCHECK	(('d'<<8)|2)	/* next i/o checks data */
11310022Ssam #define	SAIOHCHECK	(('d'<<8)|3)	/* next i/o checks header & data */
11410333Shelge #define	SAIONOBAD	(('d'<<8)|4)	/* inhibit bad sector forwarding */
11511139Ssam #define	SAIODOBAD	(('d'<<8)|5)	/* enable bad sector forwarding */
116*25440Skarels #define	SAIOECCLIM	(('d'<<8)|6)	/* set limit to ecc correction, bits */
117*25440Skarels #define	SAIORETRIES	(('d'<<8)|7)	/* set retry count for unit */
11811363Ssam #define	SAIODEVDATA	(('d'<<8)|8)	/* get device data */
11911363Ssam #define	SAIOSSI		(('d'<<8)|9)	/* set skip sector inhibit */
12011363Ssam #define	SAIONOSSI	(('d'<<8)|10)	/* inhibit skip sector handling */
12111363Ssam #define	SAIOSSDEV	(('d'<<8)|11)	/* is device skip sector type? */
12211363Ssam #define	SAIODEBUG	(('d'<<8)|12)	/* enable/disable debugging */
123*25440Skarels #define	SAIOGBADINFO	(('d'<<8)|13)	/* get bad-sector table */
124