xref: /csrg-svn/sys/stand.att/dev.c (revision 33670)
133510Sbostic /*
233510Sbostic  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
333510Sbostic  * All rights reserved.
433510Sbostic  *
533510Sbostic  * Redistribution and use in source and binary forms are permitted
633510Sbostic  * provided that this notice is preserved and that due credit is given
733510Sbostic  * to the University of California at Berkeley. The name of the University
833510Sbostic  * may not be used to endorse or promote products derived from this
933510Sbostic  * software without specific prior written permission. This software
1033510Sbostic  * is provided ``as is'' without express or implied warranty.
1133510Sbostic  *
12*33670Sbostic  *	@(#)dev.c	7.2 (Berkeley) 03/04/88
1333510Sbostic  */
1433510Sbostic 
1533510Sbostic #include "param.h"
1633510Sbostic #include "inode.h"
1733510Sbostic #include "fs.h"
1833510Sbostic #include "saio.h"
1933510Sbostic 
20*33670Sbostic /*
21*33670Sbostic  * NB: the value "io->i_ino.i_dev", used to offset the devsw[] array
22*33670Sbostic  * in the routines below, is munged by the vaxstand Makefile to work
23*33670Sbostic  * for certain boots.
24*33670Sbostic  */
25*33670Sbostic 
2633510Sbostic devread(io)
2733510Sbostic 	register struct iob *io;
2833510Sbostic {
2933510Sbostic 	int cc;
3033510Sbostic 
3133510Sbostic 	io->i_flgs |= F_RDDATA;
3233510Sbostic 	io->i_error = 0;
3333510Sbostic 	cc = (*devsw[io->i_ino.i_dev].dv_strategy)(io, READ);
3433510Sbostic 	io->i_flgs &= ~F_TYPEMASK;
3533510Sbostic 	return (cc);
3633510Sbostic }
3733510Sbostic 
3833510Sbostic devwrite(io)
3933510Sbostic 	register struct iob *io;
4033510Sbostic {
4133510Sbostic 	int cc;
4233510Sbostic 
4333510Sbostic 	io->i_flgs |= F_WRDATA;
4433510Sbostic 	io->i_error = 0;
4533510Sbostic 	cc = (*devsw[io->i_ino.i_dev].dv_strategy)(io, WRITE);
4633510Sbostic 	io->i_flgs &= ~F_TYPEMASK;
4733510Sbostic 	return (cc);
4833510Sbostic }
4933510Sbostic 
5033510Sbostic devopen(io)
5133510Sbostic 	register struct iob *io;
5233510Sbostic {
53*33670Sbostic 	int ret;
54*33670Sbostic 
55*33670Sbostic 	if (!(ret = (*devsw[io->i_ino.i_dev].dv_open)(io)))
56*33670Sbostic 		return (0);
57*33670Sbostic 	printf("%s(%d,%d,%d,%d): ", devsw[io->i_ino.i_dev].dv_name,
58*33670Sbostic 		io->i_adapt, io->i_ctlr, io->i_unit, io->i_part);
59*33670Sbostic 	switch(ret) {
60*33670Sbostic 	case EADAPT:
61*33670Sbostic 		printf("bad adaptor\n");
62*33670Sbostic 		break;
63*33670Sbostic 	case ECTLR:
64*33670Sbostic 		printf("bad controller\n");
65*33670Sbostic 		break;
66*33670Sbostic 	case EUNIT:
67*33670Sbostic 		printf("bad drive\n");
68*33670Sbostic 		break;
69*33670Sbostic 	case EPART:
70*33670Sbostic 		printf("bad partition\n");
71*33670Sbostic 		break;
72*33670Sbostic 	case ERDLAB:
73*33670Sbostic 		printf("can't read disk label\n");
74*33670Sbostic 		break;
75*33670Sbostic 	case EUNLAB:
76*33670Sbostic 		printf("unlabeled\n");
77*33670Sbostic 		break;
78*33670Sbostic 	case ENXIO:
79*33670Sbostic 	default:
80*33670Sbostic 		printf("bad device specification\n");
81*33670Sbostic 	}
82*33670Sbostic 	return (ret);
8333510Sbostic }
8433510Sbostic 
8533510Sbostic devclose(io)
8633510Sbostic 	register struct iob *io;
8733510Sbostic {
8833510Sbostic 	(*devsw[io->i_ino.i_dev].dv_close)(io);
8933510Sbostic }
9033510Sbostic 
9133510Sbostic devioctl(io, cmd, arg)
9233510Sbostic 	register struct iob *io;
9333510Sbostic 	int cmd;
9433510Sbostic 	caddr_t arg;
9533510Sbostic {
9633510Sbostic 	return ((*devsw[io->i_ino.i_dev].dv_ioctl)(io, cmd, arg));
9733510Sbostic }
9833510Sbostic 
9933510Sbostic /*ARGSUSED*/
10033510Sbostic nullsys(io)
10133510Sbostic 	struct iob *io;
10233510Sbostic {}
10333510Sbostic 
10433510Sbostic /*ARGSUSED*/
10533510Sbostic nodev(io)
10633510Sbostic 	struct iob *io;
10733510Sbostic {
10833510Sbostic 	errno = EBADF;
10933510Sbostic }
11033510Sbostic 
11133510Sbostic /*ARGSUSED*/
11233510Sbostic noioctl(io, cmd, arg)
11333510Sbostic 	struct iob *io;
11433510Sbostic 	int cmd;
11533510Sbostic 	caddr_t arg;
11633510Sbostic {
11733510Sbostic 	return (ECMD);
11833510Sbostic }
119