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