Annotation of sys/arch/mvme68k/stand/bootst/dev_tape.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: dev_tape.c,v 1.3 2002/03/14 03:15:56 millert Exp $ */
2: /* $NetBSD: dev_tape.c,v 1.2 1995/10/17 22:58:20 gwr Exp $ */
3:
4: /*
5: * Copyright (c) 1993 Paul Kranenburg
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by Paul Kranenburg.
19: * 4. The name of the author may not be used to endorse or promote products
20: * derived from this software without specific prior written permission
21: *
22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32: */
33:
34: /*
35: * This module implements a "raw device" interface suitable for
36: * use by the stand-alone I/O library UFS file-system code, and
37: * possibly for direct access (i.e. boot from tape).
38: */
39:
40: #include <sys/types.h>
41: #include <machine/prom.h>
42:
43: #include "stand.h"
44: #include "libsa.h"
45:
46:
47: extern int debug;
48:
49: struct mvmeprom_dskio tape_ioreq;
50:
51: /*
52: * This is a special version of devopen() for tape boot.
53: * In this version, the file name is a numeric string of
54: * one digit, which is passed to the device open so it
55: * can open the appropriate tape segment.
56: */
57: int
58: devopen(f, fname, file)
59: struct open_file *f;
60: const char *fname; /* normally "1" */
61: char **file;
62: {
63: struct devsw *dp;
64: int error;
65:
66: *file = (char *)fname;
67: dp = &devsw[0];
68: f->f_dev = dp;
69:
70: /* The following will call tape_open() */
71: return (dp->dv_open(f, fname));
72: }
73:
74: int
75: tape_open(f, fname)
76: struct open_file *f;
77: char *fname; /* partition number, i.e. "1" */
78: {
79: int error, part;
80: struct mvmeprom_dskio *ti;
81:
82: /*
83: * Set the tape segment number to the one indicated
84: * by the single digit fname passed in above.
85: */
86: if ((fname[0] < '0') && (fname[0] > '9')) {
87: return ENOENT;
88: }
89: part = fname[0] - '0';
90:
91: /*
92: * Setup our part of the saioreq.
93: * (determines what gets opened)
94: */
95: ti = &tape_ioreq;
96: bzero((caddr_t)ti, sizeof(*ti));
97:
98: ti->ctrl_lun = bugargs.ctrl_lun;
99: ti->dev_lun = bugargs.dev_lun;
100: ti->status = 0;
101: ti->pbuffer = NULL;
102: ti->blk_num = part;
103: ti->blk_cnt = 0;
104: ti->flag = 0;
105: ti->addr_mod = 0;
106:
107: f->f_devdata = ti;
108:
109: return (error);
110: }
111:
112: int
113: tape_close(f)
114: struct open_file *f;
115: {
116: struct mvmeprom_dskio *ti;
117:
118:
119: ti = f->f_devdata;
120: f->f_devdata = NULL;
121: return 0;
122: }
123:
124: #define MVMEPROM_SCALE (512/MVMEPROM_BLOCK_SIZE)
125:
126: int
127: tape_strategy(devdata, flag, dblk, size, buf, rsize)
128: void *devdata;
129: int flag;
130: daddr_t dblk;
131: u_int size;
132: char *buf;
133: u_int *rsize;
134: {
135: struct mvmeprom_dskio *ti;
136: int ret;
137:
138: ti = devdata;
139:
140: if (flag != F_READ)
141: return(EROFS);
142:
143: ti->status = 0;
144: ti->pbuffer = buf;
145: /* don't change block #, set in open */
146: ti->blk_cnt = size / (512 / MVMEPROM_SCALE);
147:
148: ret = mvmeprom_diskrd(ti);
149:
150: if (ret != 0)
151: return (EIO);
152:
153: *rsize = (ti->blk_cnt / MVMEPROM_SCALE) * 512;
154: ti->flag |= IGNORE_FILENUM; /* ignore next time */
155:
156: return (0);
157: }
158:
159: int
160: tape_ioctl()
161: {
162: return EIO;
163: }
164:
CVSweb