xref: /original-bsd/sys/stand.att/saio.h (revision 883fb6be)
1 /*
2  * Copyright (c) 1982 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)saio.h	7.3 (Berkeley) 02/21/87
7  */
8 
9 /*
10  * Header file for standalone package
11  */
12 
13 /*
14  * Io block: includes an
15  * inode, cells for the use of seek, etc,
16  * and a buffer.
17  */
18 struct	iob {
19 	int	i_flgs;		/* see F_ below */
20 	struct	inode i_ino;	/* inode, if file */
21 	int	i_unit;		/* pseudo device unit */
22 	daddr_t	i_boff;		/* block offset on device */
23 	daddr_t	i_cyloff;	/* cylinder offset on device */
24 	off_t	i_offset;	/* seek offset in file */
25 	daddr_t	i_bn;		/* 1st block # of next read */
26 	char	*i_ma;		/* memory address of i/o buffer */
27 	int	i_cc;		/* character count of transfer */
28 	int	i_error;	/* error # return */
29 	int	i_errcnt;	/* error count for driver retries */
30 	int	i_errblk;	/* block # in error for error reporting */
31 	char	i_buf[MAXBSIZE];/* i/o buffer */
32 	union {
33 		struct fs ui_fs;	/* file system super block info */
34 		char dummy[SBSIZE];
35 	} i_un;
36 };
37 #define i_fs i_un.ui_fs
38 #define NULL 0
39 
40 #define F_READ		0x1	/* file opened for reading */
41 #define F_WRITE		0x2	/* file opened for writing */
42 #define F_ALLOC		0x4	/* buffer allocated */
43 #define F_FILE		0x8	/* file instead of device */
44 #define F_NBSF		0x10	/* no bad sector forwarding */
45 #define F_SSI		0x40	/* set skip sector inhibit */
46 /* io types */
47 #define	F_RDDATA	0x0100	/* read data */
48 #define	F_WRDATA	0x0200	/* write data */
49 #define F_HDR		0x0400	/* include header on next i/o */
50 #define F_CHECK		0x0800	/* perform check of data read/write */
51 #define F_HCHECK	0x1000	/* perform check of header and data */
52 
53 #define	F_TYPEMASK	0xff00
54 
55 /*
56  * Device switch.
57  */
58 struct devsw {
59 	char	*dv_name;
60 	int	(*dv_strategy)();
61 	int	(*dv_open)();
62 	int	(*dv_close)();
63 	int	(*dv_ioctl)();
64 };
65 
66 struct devsw devsw[];
67 int ndevs;
68 
69 /*
70  * Request codes. Must be the same a F_XXX above
71  */
72 #define	READ	1
73 #define	WRITE	2
74 
75 #define	NBUFS	4
76 
77 char	b[NBUFS][MAXBSIZE];
78 daddr_t	blknos[NBUFS];
79 
80 #define	NFILES	4
81 struct	iob iob[NFILES];
82 
83 extern	int errno;	/* just like unix */
84 
85 /* error codes */
86 #define	EBADF	1	/* bad file descriptor */
87 #define	EOFFSET	2	/* relative seek not supported */
88 #define	EDEV	3	/* improper device specification on open */
89 #define	ENXIO	4	/* unknown device specified */
90 #define	EUNIT	5	/* improper unit specification */
91 #define	ESRCH	6	/* directory search for file failed */
92 #define	EIO	7	/* generic error */
93 #define	ECMD	10	/* undefined driver command */
94 #define	EBSE	11	/* bad sector error */
95 #define	EWCK	12	/* write check error */
96 #define	EECC	13	/* uncorrectable ecc error */
97 #define	EHER	14	/* hard error */
98 
99 /* ioctl's -- for disks just now */
100 #define	SAIOHDR		(('d'<<8)|1)	/* next i/o includes header */
101 #define	SAIOCHECK	(('d'<<8)|2)	/* next i/o checks data */
102 #define	SAIOHCHECK	(('d'<<8)|3)	/* next i/o checks header & data */
103 #define	SAIONOBAD	(('d'<<8)|4)	/* inhibit bad sector forwarding */
104 #define	SAIODOBAD	(('d'<<8)|5)	/* enable bad sector forwarding */
105 #define	SAIOECCLIM	(('d'<<8)|6)	/* set limit to ecc correction, bits */
106 #define	SAIORETRIES	(('d'<<8)|7)	/* set retry count for unit */
107 #define	SAIODEVDATA	(('d'<<8)|8)	/* get pointer to pack label */
108 #define	SAIOSSI		(('d'<<8)|9)	/* set skip sector inhibit */
109 #define	SAIONOSSI	(('d'<<8)|10)	/* inhibit skip sector handling */
110 #define	SAIOSSDEV	(('d'<<8)|11)	/* is device skip sector type? */
111 #define	SAIODEBUG	(('d'<<8)|12)	/* enable/disable debugging */
112 #define	SAIOGBADINFO	(('d'<<8)|13)	/* get bad-sector table */
113