xref: /csrg-svn/sys/stand.att/saio.h (revision 33042)
123240Smckusick /*
230547Skarels  * 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*33042Skarels  *	@(#)saio.h	7.4 (Berkeley) 12/12/87
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[];
6730547Skarels int ndevs;
68325Sbill 
69*33042Skarels #ifdef COMPAT_42
7011139Ssam /*
71*33042Skarels  * Old drive description table.
72*33042Skarels  * still used by some drivers for now.
73*33042Skarels  */
74*33042Skarels struct st {
75*33042Skarels 	short	nsect;		/* # sectors/track */
76*33042Skarels 	short	ntrak;		/* # tracks/surfaces/heads */
77*33042Skarels 	short	nspc;		/* # sectors/cylinder */
78*33042Skarels 	short	ncyl;		/* # cylinders */
79*33042Skarels 	short	*off;		/* partition offset table (cylinders) */
80*33042Skarels };
81*33042Skarels #endif
82*33042Skarels 
83*33042Skarels /*
8411363Ssam  * Request codes. Must be the same a F_XXX above
85325Sbill  */
86325Sbill #define	READ	1
87325Sbill #define	WRITE	2
88325Sbill 
89325Sbill #define	NBUFS	4
90325Sbill 
916004Smckusic char	b[NBUFS][MAXBSIZE];
92325Sbill daddr_t	blknos[NBUFS];
93325Sbill 
9411363Ssam #define	NFILES	4
95325Sbill struct	iob iob[NFILES];
966373Smckusic 
9710022Ssam extern	int errno;	/* just like unix */
9810022Ssam 
9910022Ssam /* error codes */
10010022Ssam #define	EBADF	1	/* bad file descriptor */
10110022Ssam #define	EOFFSET	2	/* relative seek not supported */
10210022Ssam #define	EDEV	3	/* improper device specification on open */
10310022Ssam #define	ENXIO	4	/* unknown device specified */
10410022Ssam #define	EUNIT	5	/* improper unit specification */
10510022Ssam #define	ESRCH	6	/* directory search for file failed */
10610022Ssam #define	EIO	7	/* generic error */
10711363Ssam #define	ECMD	10	/* undefined driver command */
10811363Ssam #define	EBSE	11	/* bad sector error */
10911363Ssam #define	EWCK	12	/* write check error */
11011363Ssam #define	EECC	13	/* uncorrectable ecc error */
11111363Ssam #define	EHER	14	/* hard error */
11210022Ssam 
11310022Ssam /* ioctl's -- for disks just now */
11410333Shelge #define	SAIOHDR		(('d'<<8)|1)	/* next i/o includes header */
11510022Ssam #define	SAIOCHECK	(('d'<<8)|2)	/* next i/o checks data */
11610022Ssam #define	SAIOHCHECK	(('d'<<8)|3)	/* next i/o checks header & data */
11710333Shelge #define	SAIONOBAD	(('d'<<8)|4)	/* inhibit bad sector forwarding */
11811139Ssam #define	SAIODOBAD	(('d'<<8)|5)	/* enable bad sector forwarding */
11925440Skarels #define	SAIOECCLIM	(('d'<<8)|6)	/* set limit to ecc correction, bits */
12025440Skarels #define	SAIORETRIES	(('d'<<8)|7)	/* set retry count for unit */
12130547Skarels #define	SAIODEVDATA	(('d'<<8)|8)	/* get pointer to pack label */
12211363Ssam #define	SAIOSSI		(('d'<<8)|9)	/* set skip sector inhibit */
12311363Ssam #define	SAIONOSSI	(('d'<<8)|10)	/* inhibit skip sector handling */
12411363Ssam #define	SAIOSSDEV	(('d'<<8)|11)	/* is device skip sector type? */
12511363Ssam #define	SAIODEBUG	(('d'<<8)|12)	/* enable/disable debugging */
12625440Skarels #define	SAIOGBADINFO	(('d'<<8)|13)	/* get bad-sector table */
127