hpcboot.h revision 1.10 1 /* $NetBSD: hpcboot.h,v 1.10 2008/03/08 02:26:03 rafal 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 * 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 _HPCBOOT_H_
40 #define _HPCBOOT_H_
41
42 #include <hpcdefs.h>
43 #include <res/resource.h>
44
45 #include <machine/bootinfo.h>
46 #include <machine/platid.h>
47 #include <machine/platid_mask.h>
48 #include <machine/platid_generated.h>
49
50 enum { KERNEL_PAGE_SIZE = 0x1000 };
51
52 enum ArchitectureOps {
53 #ifdef ARM
54 ARCHITECTURE_ARM_SA1100 = PLATID_CPU_ARM_STRONGARM_SA1100,
55 ARCHITECTURE_ARM_PXA250 = PLATID_CPU_ARM_XSCALE_PXA250,
56 #endif
57 #ifdef SHx
58 ARCHITECTURE_SH3_7707 = PLATID_CPU_SH_3_7707,
59 ARCHITECTURE_SH3_7709 = PLATID_CPU_SH_3_7709,
60 ARCHITECTURE_SH3_7709A = PLATID_CPU_SH_3_7709A,
61 ARCHITECTURE_SH4_7750 = PLATID_CPU_SH_4_7750,
62 #endif
63 #ifdef MIPS
64 ARCHITECTURE_MIPS_TX3900= PLATID_CPU_MIPS_TX_3900,
65 ARCHITECTURE_MIPS_TX3920= PLATID_CPU_MIPS_TX_3920,
66 ARCHITECTURE_MIPS_VR41 = PLATID_CPU_MIPS_VR_41XX
67 #endif
68 };
69
70 enum ConsoleOps {
71 CONSOLE_LCD,
72 CONSOLE_SERIAL
73 };
74
75 enum MemoryManagerOps {
76 MEMORY_MANAGER_VIRTUALCOPY,
77 MEMORY_MANAGER_LOCKPAGES,
78 MEMORY_MANAGER_SOFTMMU,
79 MEMORY_MANAGER_HARDMMU
80 };
81
82 enum FileOps {
83 FILE_FAT,
84 FILE_UFS,
85 FILE_HTTP
86 };
87
88 enum LoaderOps {
89 LOADER_UNKNOWN,
90 LOADER_ELF,
91 LOADER_COFF,
92 LOADER_AOUT
93 };
94
95 struct BootSetupArgs {
96 enum ArchitectureOps architecture;
97 BOOL architectureDebug;
98 enum ConsoleOps console;
99 BOOL consoleEnable;
100 enum MemoryManagerOps memory;
101 BOOL memorymanagerDebug;
102 enum FileOps file;
103 BOOL fileDebug;
104 TCHAR fileRoot[MAX_PATH];
105 TCHAR fileName[MAX_PATH];
106 BOOL loadmfs;
107 TCHAR mfsName[MAX_PATH];
108 enum LoaderOps loader;
109 BOOL loaderDebug;
110 };
111
112 struct PageTag {
113 uint32_t next; /* next tagged page kernel virtual address; */
114 uint32_t src; /* kernel virtual or physical address */
115 uint32_t dst; /* kernel virtual or physical address */
116 uint32_t sz; /* copy size or zero-clear size; */
117 };
118
119 struct BootArgs {
120 kaddr_t kernel_entry;
121 kaddr_t argc;
122 kaddr_t argv;
123 kaddr_t bootinfo;
124 struct bootinfo bi;
125 };
126
127 #define VOLATILE_REF(x) (*(volatile uint32_t *)(x))
128 #define VOLATILE_REF16(x) (*(volatile uint16_t *)(x))
129 #define VOLATILE_REF8(x) (*(volatile uint8_t *)(x))
130 #define _reg_read_1(a) (*(volatile uint8_t *)(a))
131 #define _reg_read_2(a) (*(volatile uint16_t *)(a))
132 #define _reg_read_4(a) (*(volatile uint32_t *)(a))
133 #define _reg_write_1(a, v) (*(volatile uint8_t *)(a) = (v))
134 #define _reg_write_2(a, v) (*(volatile uint16_t *)(a) = (v))
135 #define _reg_write_4(a, v) (*(volatile uint32_t *)(a) = (v))
136
137 #ifdef ARM
138 #define ptokv(x) (x) /* UNCACHED FLAT */
139 #elif defined SHx
140 #define ptokv(x) ((x) | 0x80000000) /* CACHED P1 */
141 #elif defined MIPS
142 #define ptokv(x) ((x) | 0x80000000) /* CACHED kseg0 */
143 #else
144 #error "physical address to kernel virtual macro not defined."
145 #endif
146
147 __BEGIN_DECLS
148 /* Windows CE API */
149 BOOL VirtualCopy(LPVOID, LPVOID, DWORD, DWORD);
150 BOOL SetKMode(BOOL);
151 BOOL LockPages(LPVOID, DWORD, PDWORD, int);
152 BOOL UnlockPages(LPVOID, DWORD);
153 void CacheSync(int);
154 #define CACHE_D_WBINV 1
155 #define CACHE_I_INV 2
156 /* ExtEscape */
157 #define GETVFRAMEPHYSICAL 6144
158 #define GETVFRAMELEN 6145
159
160 /* debug utility */
161 void _bitdisp(uint32_t, int, int, int, int);
162 void _dbg_bit_print(uint32_t, uint32_t, const char *);
163 #define bitdisp(a) _bitdisp((a), 0, 0, 0, 1)
164 __END_DECLS
165
166 /* Runtime Windows CE version */
167 #if _WIN32_WCE <= 200
168 extern OSVERSIONINFO WinCEVersion;
169 #else
170 extern OSVERSIONINFOW WinCEVersion;
171 #endif
172
173 #endif /* _HPCBOOT_H_ */
174