xref: /csrg-svn/sys/luna68k/stand/saio.h (revision 63199)
157095Sakito /*
257095Sakito  * Copyright (c) 1992 OMRON Corporation.
3*63199Sbostic  * Copyright (c) 1992, 1993
4*63199Sbostic  *	The Regents of the University of California.  All rights reserved.
557095Sakito  *
657095Sakito  * This code is derived from software contributed to Berkeley by
757095Sakito  * OMRON Corporation.
857095Sakito  *
957095Sakito  * %sccs.include.redist.c%
1057095Sakito  *
11*63199Sbostic  *	@(#)saio.h	8.1 (Berkeley) 06/10/93
1257095Sakito  */
1357095Sakito 
1457095Sakito /*
1557095Sakito  * Header file for standalone package
1657095Sakito  */
1757095Sakito 
1857095Sakito #include <sys/param.h>
1957095Sakito #include "ufs/ufs/dinode.h"
2057095Sakito #include "ufs/ffs/fs.h"
2157095Sakito 
2257095Sakito /*
2357095Sakito  * Io block: includes a
2457095Sakito  * dinode, cells for the use of seek, etc,
2557095Sakito  * and a buffer.
2657095Sakito  */
2757095Sakito struct	iob {
2857095Sakito 	int	i_flgs;		/* see F_ below */
2957095Sakito 	struct	dinode i_ino;	/* dinode, if file */
3057095Sakito 	int	i_unit;		/* pseudo device unit */
3157095Sakito 	daddr_t	i_boff;		/* block offset on device */
3257095Sakito 	daddr_t	i_cyloff;	/* cylinder offset on device */
3357095Sakito 	off_t	i_offset;	/* seek offset in file */
3457095Sakito 	dev_t	i_dev;		/* associated device */
3557095Sakito 	daddr_t	i_bn;		/* 1st block # of next read */
3657095Sakito 	char	*i_ma;		/* memory address of i/o buffer */
3757095Sakito 	int	i_cc;		/* character count of transfer */
3857095Sakito 	int	i_error;	/* error # return */
3957095Sakito 	int	i_errcnt;	/* error count for driver retries */
4057095Sakito 	int	i_errblk;	/* block # in error for error reporting */
4157095Sakito 	char	i_buf[MAXBSIZE];/* i/o buffer */
4257095Sakito 	union {
4357095Sakito 		struct fs ui_fs;	/* file system super block info */
4457095Sakito 		char dummy[SBSIZE];
4557095Sakito 	} i_un;
4657095Sakito };
4757095Sakito #define i_fs i_un.ui_fs
4857095Sakito #define NULL 0
4957095Sakito 
5057095Sakito #define F_READ		0x1	/* file opened for reading */
5157095Sakito #define F_WRITE		0x2	/* file opened for writing */
5257095Sakito #define F_ALLOC		0x4	/* buffer allocated */
5357095Sakito #define F_FILE		0x8	/* file instead of device */
5457095Sakito #define F_NBSF		0x10	/* no bad sector forwarding */
5557095Sakito #define F_SSI		0x40	/* set skip sector inhibit */
5657095Sakito /* io types */
5757095Sakito #define	F_RDDATA	0x0100	/* read data */
5857095Sakito #define	F_WRDATA	0x0200	/* write data */
5957095Sakito #define F_HDR		0x0400	/* include header on next i/o */
6057095Sakito #define F_CHECK		0x0800	/* perform check of data read/write */
6157095Sakito #define F_HCHECK	0x1000	/* perform check of header and data */
6257095Sakito 
6357095Sakito #define	F_TYPEMASK	0xff00
6457095Sakito 
6557095Sakito /*
6657095Sakito  * Device switch.
6757095Sakito  */
6857095Sakito struct devsw {
6957095Sakito 	char	*dv_name;
7057095Sakito 	int	(*dv_strategy)();
7157095Sakito 	int	(*dv_open)();
7257095Sakito 	int	(*dv_close)();
7357095Sakito 	int	(*dv_ioctl)();
7457095Sakito };
7557095Sakito 
7657095Sakito struct devsw devsw[];
7757095Sakito 
7857095Sakito /*
7957095Sakito  * Drive description table.
8057095Sakito  * Returned from SAIODEVDATA call.
8157095Sakito  */
8257095Sakito struct st {
8357095Sakito 	short	nsect;		/* # sectors/track */
8457095Sakito 	short	ntrak;		/* # tracks/surfaces/heads */
8557095Sakito 	short	nspc;		/* # sectors/cylinder */
8657095Sakito 	short	ncyl;		/* # cylinders */
8757095Sakito 	short	*off;		/* partition offset table (cylinders) */
8857095Sakito };
8957095Sakito 
9057095Sakito /*
9157095Sakito  * Request codes. Must be the same a F_XXX above
9257095Sakito  */
9357095Sakito #define	READ	1
9457095Sakito #define	WRITE	2
9557095Sakito 
9657095Sakito #define	NBUFS	4
9757095Sakito 
9857095Sakito char	b[NBUFS][MAXBSIZE];
9957095Sakito daddr_t	blknos[NBUFS];
10057095Sakito 
10157095Sakito #define	NFILES	4
10257095Sakito struct	iob iob[NFILES];
10357095Sakito 
10457095Sakito extern	int errno;	/* just like unix */
10557095Sakito 
10657095Sakito /* error codes */
10757095Sakito 
10857095Sakito /* #define	EBADF	101	/* bad file descriptor */
10957095Sakito #define	EOFFSET	102	/* relative seek not supported */
11057095Sakito #define	EDEV	103	/* improper device specification on open */
11157095Sakito /* #define	ENXIO	104	/* unknown device specified */
11257095Sakito #define	EUNIT	105	/* improper unit specification */
11357095Sakito /* #define	ESRCH	106	/* directory search for file failed */
11457095Sakito /* #define	EIO	107	/* generic error */
11557095Sakito #define	ECMD	110	/* undefined driver command */
11657095Sakito 
11757095Sakito /* ioctl's -- for disks just now */
11857095Sakito #define	SAIOHDR		(('d'<<8)|1)	/* next i/o includes header */
11957095Sakito #define	SAIOCHECK	(('d'<<8)|2)	/* next i/o checks data */
12057095Sakito #define	SAIOHCHECK	(('d'<<8)|3)	/* next i/o checks header & data */
12157095Sakito #define	SAIONOBAD	(('d'<<8)|4)	/* inhibit bad sector forwarding */
12257095Sakito #define	SAIODOBAD	(('d'<<8)|5)	/* enable bad sector forwarding */
12357095Sakito #define	SAIOECCLIM	(('d'<<8)|6)	/* set limit to ecc correction, bits */
12457095Sakito #define	SAIORETRIES	(('d'<<8)|7)	/* set retry count for unit */
12557095Sakito #define	SAIODEVDATA	(('d'<<8)|8)	/* get device data */
12657095Sakito #define	SAIOSSI		(('d'<<8)|9)	/* set skip sector inhibit */
12757095Sakito #define	SAIONOSSI	(('d'<<8)|10)	/* inhibit skip sector handling */
12857095Sakito #define	SAIOSSDEV	(('d'<<8)|11)	/* is device skip sector type? */
12957095Sakito #define	SAIODEBUG	(('d'<<8)|12)	/* enable/disable debugging */
13057095Sakito #define	SAIOGBADINFO	(('d'<<8)|13)	/* get bad-sector table */
131