xref: /netbsd/sys/arch/hpc/stand/hpcboot/hpcboot.h (revision 283e4408)
1 /*	$NetBSD: hpcboot.h,v 1.12 2009/01/29 21:23:38 nonaka Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by UCHIYAMA Yasushi.
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  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _HPCBOOT_H_
33 #define	_HPCBOOT_H_
34 
35 #include <hpcdefs.h>
36 #include <res/resource.h>
37 
38 #include <machine/bootinfo.h>
39 #include <machine/platid.h>
40 #include <machine/platid_mask.h>
41 #include <machine/platid_generated.h>
42 
43 enum { KERNEL_PAGE_SIZE = 0x1000 };
44 
45 enum ArchitectureOps {
46 #ifdef ARM
47 	ARCHITECTURE_ARM_SA1100	= PLATID_CPU_ARM_STRONGARM_SA1100,
48 	ARCHITECTURE_ARM_PXA250 = PLATID_CPU_ARM_XSCALE_PXA250,
49 	ARCHITECTURE_ARM_PXA270 = PLATID_CPU_ARM_XSCALE_PXA270,
50 #endif
51 #ifdef SHx
52 	ARCHITECTURE_SH3_7707	= PLATID_CPU_SH_3_7707,
53 	ARCHITECTURE_SH3_7709	= PLATID_CPU_SH_3_7709,
54 	ARCHITECTURE_SH3_7709A	= PLATID_CPU_SH_3_7709A,
55 	ARCHITECTURE_SH4_7750	= PLATID_CPU_SH_4_7750,
56 #endif
57 #ifdef MIPS
58 	ARCHITECTURE_MIPS_TX3900= PLATID_CPU_MIPS_TX_3900,
59 	ARCHITECTURE_MIPS_TX3920= PLATID_CPU_MIPS_TX_3920,
60 	ARCHITECTURE_MIPS_VR41	= PLATID_CPU_MIPS_VR_41XX
61 #endif
62 };
63 
64 enum ConsoleOps {
65 	CONSOLE_LCD,
66 	CONSOLE_SERIAL
67 };
68 
69 enum MemoryManagerOps {
70 	MEMORY_MANAGER_VIRTUALCOPY,
71 	MEMORY_MANAGER_LOCKPAGES,
72 	MEMORY_MANAGER_SOFTMMU,
73 	MEMORY_MANAGER_HARDMMU
74 };
75 
76 enum FileOps {
77 	FILE_FAT,
78 	FILE_UFS,
79 	FILE_HTTP
80 };
81 
82 enum LoaderOps {
83 	LOADER_UNKNOWN,
84 	LOADER_ELF,
85 	LOADER_COFF,
86 	LOADER_AOUT
87 };
88 
89 struct BootSetupArgs {
90 	enum ArchitectureOps architecture;
91 	BOOL architectureDebug;
92 	enum ConsoleOps console;
93 	BOOL consoleEnable;
94 	enum MemoryManagerOps memory;
95 	BOOL memorymanagerDebug;
96 	enum FileOps file;
97 	BOOL fileDebug;
98 	TCHAR fileRoot[MAX_PATH];
99 	TCHAR fileName[MAX_PATH];
100 	BOOL loadmfs;
101 	TCHAR mfsName[MAX_PATH];
102 	enum LoaderOps loader;
103 	BOOL loaderDebug;
104 };
105 
106 struct PageTag {
107 	uint32_t next;	/* next tagged page kernel virtual address; */
108 	uint32_t src;	/* kernel virtual or physical address */
109 	uint32_t dst;	/* kernel virtual or physical address */
110 	uint32_t sz;	/* copy size or zero-clear size; */
111 };
112 
113 struct BootArgs {
114 	kaddr_t kernel_entry;
115 	kaddr_t argc;
116 	kaddr_t argv;
117 	kaddr_t bootinfo;
118 	struct bootinfo bi;
119 };
120 
121 #define	VOLATILE_REF(x)			(*(volatile uint32_t *)(x))
122 #define	VOLATILE_REF16(x)		(*(volatile uint16_t *)(x))
123 #define	VOLATILE_REF8(x)		(*(volatile uint8_t *)(x))
124 #define	_reg_read_1(a)		(*(volatile uint8_t *)(a))
125 #define	_reg_read_2(a)		(*(volatile uint16_t *)(a))
126 #define	_reg_read_4(a)		(*(volatile uint32_t *)(a))
127 #define	_reg_write_1(a, v)	(*(volatile uint8_t *)(a) = (v))
128 #define	_reg_write_2(a, v)	(*(volatile uint16_t *)(a) = (v))
129 #define	_reg_write_4(a, v)	(*(volatile uint32_t *)(a) = (v))
130 
131 #ifdef ARM
132 #define	ptokv(x)	(x)			/* UNCACHED FLAT */
133 #elif defined SHx
134 #define	ptokv(x)	((x) | 0x80000000)	/* CACHED P1 */
135 #elif defined MIPS
136 #define	ptokv(x)	((x) | 0x80000000)	/* CACHED kseg0 */
137 #else
138 #error "physical address to kernel virtual macro not defined."
139 #endif
140 
141 __BEGIN_DECLS
142 /* Windows CE API */
143 BOOL VirtualCopy(LPVOID, LPVOID, DWORD, DWORD);
144 BOOL SetKMode(BOOL);
145 BOOL LockPages(LPVOID, DWORD, PDWORD, int);
146 BOOL UnlockPages(LPVOID, DWORD);
147 void CacheSync(int);
148 #define	CACHE_D_WBINV	1
149 #define	CACHE_I_INV	2
150 /* ExtEscape */
151 #define	GETVFRAMEPHYSICAL	6144
152 #define	GETVFRAMELEN		6145
153 
154 /* debug utility */
155 void _bitdisp(uint32_t, int, int, int, int);
156 void _dbg_bit_print(uint32_t, uint32_t, const char *);
157 #define	bitdisp(a) _bitdisp((a), 0, 0, 0, 1)
158 __END_DECLS
159 
160 /* Runtime Windows CE version */
161 #if _WIN32_WCE <= 200
162 extern OSVERSIONINFO WinCEVersion;
163 #else
164 extern OSVERSIONINFOW WinCEVersion;
165 #endif
166 
167 #endif /* _HPCBOOT_H_ */
168