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