1 /* $NetBSD: sh_boot.cpp,v 1.9 2005/12/11 12:17:28 christos Exp $ */
4 * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
37 #include <sh3/sh_arch.h>
38 #include <sh3/sh_mmu.h>
39 #include <sh3/sh_console.h>
40 #include <sh3/sh_boot.h>
59 struct HpcMenuInterface::HpcMenuPreferences
&pref
= HPC_PREFERENCE
;
62 platid
.dw
.dw0
= pref
.platid_hi
;
63 platid
.dw
.dw1
= pref
.platid_lo
;
65 if (platid_match(&platid
, &platid_mask_CPU_SH_3_7707
)) {
66 args
.architecture
= ARCHITECTURE_SH3_7707
;
67 } else if (platid_match(&platid
, &platid_mask_CPU_SH_3_7709
)) {
68 args
.architecture
= ARCHITECTURE_SH3_7709
;
69 } else if (platid_match(&platid
, &platid_mask_CPU_SH_3_7709A
)) {
70 args
.architecture
= ARCHITECTURE_SH3_7709A
;
71 } else if (platid_match(&platid
, &platid_mask_CPU_SH_4_7750
)) {
72 args
.architecture
= ARCHITECTURE_SH4_7750
;
74 DPRINTF((TEXT("CPU not supported.")));
78 return super::setup();
84 BOOL(*lock_pages
)(LPVOID
, DWORD
, PDWORD
, int);
85 BOOL(*unlock_pages
)(LPVOID
, DWORD
);
88 // Setup console. this setting is passed to kernel bootinfo.
89 if (args
.console
== CONSOLE_SERIAL
) {
90 _cons
= new SHConsole
;
92 _cons
= Console::Instance();
93 DPRINTF((TEXT("use LCD console instead.\n")));
96 _cons
= Console::Instance();
97 SHConsole::selectBootConsole(*_cons
, SHConsole::VIDEO
);
100 // Architecture dependent ops.
101 switch(args
.architecture
) {
103 DPRINTF((TEXT("unsupported architecture.\n")));
105 case ARCHITECTURE_SH3_7707
:
106 _arch
= new SH7707(_cons
, _mem
, SH7707::boot_func
);
107 page_size
= SH3_PAGE_SIZE
;
108 if (SHArchitecture::cpu_type() != 3)
111 case ARCHITECTURE_SH3_7709
:
112 _arch
= new SH7709(_cons
, _mem
, SH7709::boot_func
);
113 page_size
= SH3_PAGE_SIZE
;
114 if (SHArchitecture::cpu_type() != 3)
117 case ARCHITECTURE_SH3_7709A
:
118 _arch
= new SH7709A(_cons
, _mem
, SH7709A::boot_func
);
119 page_size
= SH3_PAGE_SIZE
;
120 if (SHArchitecture::cpu_type() != 3)
123 case ARCHITECTURE_SH4_7750
:
124 _arch
= new SH7750(_cons
, _mem
, SH7750::boot_func
);
125 page_size
= SH4_PAGE_SIZE
;
126 if (SHArchitecture::cpu_type() != 4)
130 _arch
->setDebug() = args
.architectureDebug
;
132 lock_pages
= _arch
->_load_LockPages();
133 unlock_pages
= _arch
->_load_UnlockPages();
134 if (lock_pages
== 0 || unlock_pages
== 0)
135 args
.memory
= MEMORY_MANAGER_HARDMMU
;
137 args
.memory
= MEMORY_MANAGER_LOCKPAGES
;
140 switch(args
.memory
) {
142 case MEMORY_MANAGER_VIRTUALCOPY
:
143 // VirtualCopy method causes Windows CE unstable.
145 case MEMORY_MANAGER_SOFTMMU
:
146 DPRINTF((TEXT("unsupported address detection method.\n")));
148 case MEMORY_MANAGER_HARDMMU
:
149 if (args
.architecture
== ARCHITECTURE_SH4_7750
) {
150 DPRINTF((TEXT("No SH4 MMU code.\n")));
154 _mem
= new MemoryManager_SHMMU(_cons
, page_size
);
156 case MEMORY_MANAGER_LOCKPAGES
:
157 _mem
= new MemoryManager_LockPages(lock_pages
, unlock_pages
,
161 _mem
->setDebug() = args
.memorymanagerDebug
;
163 // File Manager, Loader
164 return super::create();
167 DPRINTF((TEXT("CPU mismatch. CPU is SH%d\n"),
168 SHArchitecture::cpu_type()));