xref: /netbsd-src/sys/arch/sparc/stand/common/promdev.h (revision fdecd6a253f999ae92b139670d9e15cc9df4497c)
1 /*	$NetBSD: promdev.h,v 1.1 1997/06/01 03:39:39 mrg Exp $ */
2 
3 /*
4  * Copyright (c) 1993 Paul Kranenburg
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Paul Kranenburg.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <machine/bsd_openprom.h>
34 
35 struct promdata {
36 	int	fd;			/* Openboot descriptor */
37 	struct	saioreq *si;		/* Oldmon IO request */
38 	int	devtype;		/* Kind of device we're booting from */
39 #define DT_BLOCK	1
40 #define DT_NET		2
41 #define DT_BYTE		3
42 	/* Hooks for netif.c */
43 	int	(*xmit) __P((struct promdata *, void *, size_t));
44 	int	(*recv) __P((struct promdata *, void *, size_t));
45 };
46 
47 #define LOADADDR	((caddr_t)0x4000)
48 #define DDB_MAGIC	( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('0') )
49 
50 extern struct promvec	*promvec;
51 extern char	*prom_bootdevice;
52 extern char	*prom_bootfile;
53 extern int	prom_boothow;
54 extern int	hz;
55 extern int	cputyp, nbpg, pgofset, pgshift;
56 extern int	debug;
57 
58 extern void	prom_init __P((void));
59 
60 /* Note: dvma_*() routines are for "oldmon" machines only */
61 extern char	*dvma_mapin __P((char *, size_t));
62 extern char	*dvma_mapout __P((char *, size_t));
63 extern char	*dvma_alloc __P((int));
64 
65 /*
66  * duplicates from pmap.c for mapping device on "oldmon" machines.
67  */
68 #include <sparc/sparc/asm.h>
69 
70 #define getcontext()		lduba(AC_CONTEXT, ASI_CONTROL)
71 #define setcontext(c)		stba(AC_CONTEXT, ASI_CONTROL, c)
72 #define getsegmap(va)		(cputyp == CPU_SUN4C \
73 					? lduba(va, ASI_SEGMAP) \
74 					: lduha(va, ASI_SEGMAP))
75 #define setsegmap(va, pmeg)	(cputyp == CPU_SUN4C \
76 					? stba(va, ASI_SEGMAP, pmeg) \
77 					: stha(va, ASI_SEGMAP, pmeg))
78 #define getregmap(va)		((unsigned)lduha(va+2, ASI_REGMAP) >> 8)
79 #define setregmap(va, smeg)	stha(va+2, ASI_REGMAP, (smeg << 8))
80 
81 #define getpte(va)		lda(va, ASI_PTE)
82 #define setpte(va, pte)		sta(va, ASI_PTE, pte)
83