xref: /netbsd-src/sys/arch/hpcmips/stand/lcboot/extern.h (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1 /* $NetBSD: extern.h,v 1.2 2003/06/24 12:27:04 igy Exp $ */
2 
3 /*
4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Naoto Shimazaki of YOKOGAWA Electric Corporation.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef _LOCORE
40 #include <sys/types.h>
41 #include <mips/cpuregs.h>
42 
43 #include <dev/ic/comreg.h>
44 #include <dev/ic/ns16550reg.h>
45 #include <dev/ic/st16650reg.h>
46 #define com_lcr com_cfcr
47 
48 struct bootmenu_command {
49 	const char	*c_name;
50 	void (*c_fn)(char*);
51 };
52 
53 #define ROMCS0_BASE	0xbe000000U
54 #define ROMCS3_BASE	0xbf800000U
55 #define FLASH_BASE	ROMCS0_BASE
56 
57 #ifdef ROMICE
58 #define KERN_ROMBASE	0x80800000U
59 #else
60 #define KERN_ROMBASE	0xbf800000U
61 #endif
62 
63 #define __REG_1(reg)	*((volatile u_int8_t*) (reg))
64 #define __REG_2(reg)	*((volatile u_int16_t*) (reg))
65 #define __REG_4(reg)	*((volatile u_int32_t*) (reg))
66 
67 #define ISSET(t, f)	((t) & (f))
68 
69 #define REGWRITE_1(base, off, val)	\
70 		(__REG_1(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))) \
71 		 = (val))
72 #define REGWRITE_2(base, off, val)	\
73 		(__REG_2(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))) \
74 		 = (val))
75 #define REGWRITE_4(base, off, val)	\
76 		(__REG_4(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))) \
77 		 = (val))
78 
79 #define REGREAD_1(base, off)	\
80 		(__REG_1(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))))
81 #define REGREAD_2(base, off)	\
82 		(__REG_2(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))))
83 #define REGREAD_4(base, off)	\
84 		(__REG_4(MIPS_PHYS_TO_KSEG1((u_int32_t) (base) + (off))))
85 
86 #define ISKEY	ISSET(REGREAD_1(VR4181_SIU_ADDR, com_lsr), LSR_RXRDY)
87 
88 #define bus_space_write_1(iot, ioh, off, val)	REGWRITE_1((ioh), (off), (val))
89 #define bus_space_write_2(iot, ioh, off, val)	REGWRITE_2((ioh), (off), (val))
90 #define bus_space_write_4(iot, ioh, off, val)	REGWRITE_4((ioh), (off), (val))
91 #define bus_space_read_1(iot, ioh, off)	REGREAD_1((ioh), (off))
92 #define bus_space_read_2(iot, ioh, off)	REGREAD_2((ioh), (off))
93 #define bus_space_read_4(iot, ioh, off)	REGREAD_4((ioh), (off))
94 typedef void		*bus_space_tag_t;
95 typedef u_int32_t	bus_space_handle_t;
96 typedef size_t		bus_size_t;
97 
98 void comcninit(void);
99 int iskey(void);
100 void start_netbsd(void);
101 int i28f128_probe(void *base);
102 int i28f128_region_write(void *dst, const void *src, size_t len);
103 
104 /* dev_flash */
105 int flash_strategy(void *, int, daddr_t, size_t, void *, size_t *);
106 int flash_open(struct open_file *, ...);
107 int flash_close(struct open_file *);
108 int flash_ioctl(struct open_file *, u_long, void *);
109 
110 #endif /* !_LOCORE */
111 
112 #define	LCBOOT_STARTADDR	0x80001000
113 #define	LCBOOT_ROMSTARTADDR	0xbfd01000
114 #define	NETBSD_STARTADDR	0x80040000
115