Home | History | Annotate | Line # | Download | only in common
promdev.h revision 1.1.4.1
      1 /*	$NetBSD: promdev.h,v 1.1.4.1 1997/09/16 03:49:26 thorpej 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_MAGIC0	( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('0') )
     49 #define DDB_MAGIC1	( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('1') )
     50 
     51 
     52 extern struct promvec	*promvec;
     53 extern char	*prom_bootdevice;
     54 extern char	*prom_bootfile;
     55 extern int	prom_boothow;
     56 extern int	hz;
     57 extern int	cputyp, nbpg, pgofset, pgshift;
     58 extern int	debug;
     59 
     60 extern void	prom_init __P((void));
     61 
     62 /* Note: dvma_*() routines are for "oldmon" machines only */
     63 extern char	*dvma_mapin __P((char *, size_t));
     64 extern char	*dvma_mapout __P((char *, size_t));
     65 extern char	*dvma_alloc __P((int));
     66 
     67 /*
     68  * duplicates from pmap.c for mapping device on "oldmon" machines.
     69  */
     70 #include <sparc/sparc/asm.h>
     71 
     72 #define getcontext()		lduba(AC_CONTEXT, ASI_CONTROL)
     73 #define setcontext(c)		stba(AC_CONTEXT, ASI_CONTROL, c)
     74 #define getsegmap(va)		(cputyp == CPU_SUN4C \
     75 					? lduba(va, ASI_SEGMAP) \
     76 					: lduha(va, ASI_SEGMAP))
     77 #define setsegmap(va, pmeg)	(cputyp == CPU_SUN4C \
     78 					? stba(va, ASI_SEGMAP, pmeg) \
     79 					: stha(va, ASI_SEGMAP, pmeg))
     80 #define getregmap(va)		((unsigned)lduha(va+2, ASI_REGMAP) >> 8)
     81 #define setregmap(va, smeg)	stha(va+2, ASI_REGMAP, (smeg << 8))
     82 
     83 #define getpte(va)		lda(va, ASI_PTE)
     84 #define setpte(va, pte)		sta(va, ASI_PTE, pte)
     85