xref: /netbsd-src/sys/arch/hppa/stand/common/ct.c (revision 6d3ceb1d619615401b17c9aa3e4bc674a1cb048b)
1 /*	$NetBSD: ct.c,v 1.1 2014/02/24 07:23:43 skrll Exp $	*/
2 
3 /*	$OpenBSD: ct.c,v 1.5 1999/04/20 20:01:01 mickey Exp $	*/
4 
5 /*
6  * Copyright (c) 1998-2004 Michael Shalayeff
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 /*
31  * Copyright 1996 1995 by Open Software Foundation, Inc.
32  *              All Rights Reserved
33  *
34  * Permission to use, copy, modify, and distribute this software and
35  * its documentation for any purpose and without fee is hereby granted,
36  * provided that the above copyright notice appears in all copies and
37  * that both the copyright notice and this permission notice appear in
38  * supporting documentation.
39  *
40  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
41  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42  * FOR A PARTICULAR PURPOSE.
43  *
44  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
45  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
46  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
47  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
48  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49  *
50  */
51 
52 #include "libsa.h"
53 
54 #include <sys/param.h>
55 #include <sys/disklabel.h>
56 #include <sys/reboot.h>
57 
58 #include <machine/pdc.h>
59 #include <machine/iomod.h>
60 
61 #include "dev_hppa.h"
62 
63 struct pz_device ctdev;
64 iodcio_t ctiodc;	/* cartridge tape IODC entry point */
65 int ctcode[IODC_MAXSIZE/sizeof(int)];
66 
67 int
ctopen(struct open_file * f,...)68 ctopen(struct open_file *f, ...)
69 {
70 	struct hppa_dev *dp = f->f_devdata;
71 	int ret;
72 
73 	if (ctiodc == 0) {
74 
75 		if ((ret = (*pdc)(PDC_IODC, PDC_IODC_READ, pdcbuf, ctdev.pz_hpa,
76 				  IODC_IO, ctcode, IODC_MAXSIZE)) < 0) {
77 			printf("ct: device ENTRY_IO Read ret'd %d\n", ret);
78 			return (EIO);
79 		} else
80 			ctdev.pz_iodc_io = ctiodc = (iodcio_t) ctcode;
81 	}
82 
83 	dp->pz_dev = &ctdev;
84 
85 	if (ctiodc != NULL)
86 		if ((ret = (*ctiodc)(ctdev.pz_hpa, IODC_IO_READ, ctdev.pz_spa,
87 				     ctdev.pz_layers, pdcbuf, 0,
88 				     dp->buf, 0, 0)) < 0)
89 			printf("ct: device rewind ret'd %d\n", ret);
90 
91 	return (0);
92 }
93 
94 /*ARGSUSED*/
95 int
ctclose(struct open_file * f)96 ctclose(struct open_file *f)
97 {
98 	dealloc(f->f_devdata, sizeof(struct hppa_dev));
99 	f->f_devdata = NULL;
100 	return 0;
101 }
102