Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / hpc / stand / hpcboot / sh3 / sh_boot.cpp
blob5f3324a9d8dc9c38fff97bf4032a52d5a7c29d40
1 /* $NetBSD: sh_boot.cpp,v 1.9 2005/12/11 12:17:28 christos Exp $ */
3 /*-
4 * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
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.
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.
32 #include <hpcboot.h>
34 #include <arch.h>
35 #include <memory.h>
37 #include <sh3/sh_arch.h>
38 #include <sh3/sh_mmu.h>
39 #include <sh3/sh_console.h>
40 #include <sh3/sh_boot.h>
42 SHBoot::SHBoot()
46 SHBoot::~SHBoot()
48 if (_mem)
49 delete _mem;
50 if (_arch)
51 delete _arch;
53 SHConsole::Destroy();
56 BOOL
57 SHBoot::setup()
59 struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
61 platid_t platid;
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;
73 } else {
74 DPRINTF((TEXT("CPU not supported.")));
75 return FALSE;
78 return super::setup();
81 BOOL
82 SHBoot::create()
84 BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
85 BOOL(*unlock_pages)(LPVOID, DWORD);
86 size_t page_size;
88 // Setup console. this setting is passed to kernel bootinfo.
89 if (args.console == CONSOLE_SERIAL) {
90 _cons = new SHConsole;
91 if (!_cons->init()) {
92 _cons = Console::Instance();
93 DPRINTF((TEXT("use LCD console instead.\n")));
95 } else {
96 _cons = Console::Instance();
97 SHConsole::selectBootConsole(*_cons, SHConsole::VIDEO);
100 // Architecture dependent ops.
101 switch(args.architecture) {
102 default:
103 DPRINTF((TEXT("unsupported architecture.\n")));
104 return FALSE;
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)
109 goto cpu_mismatch;
110 break;
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)
115 goto cpu_mismatch;
116 break;
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)
121 goto cpu_mismatch;
122 break;
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)
127 goto cpu_mismatch;
128 break;
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;
136 else
137 args.memory = MEMORY_MANAGER_LOCKPAGES;
139 // Memory manager.
140 switch(args.memory) {
141 default:
142 case MEMORY_MANAGER_VIRTUALCOPY:
143 // VirtualCopy method causes Windows CE unstable.
144 /* FALLTHROUGH */
145 case MEMORY_MANAGER_SOFTMMU:
146 DPRINTF((TEXT("unsupported address detection method.\n")));
147 return FALSE;
148 case MEMORY_MANAGER_HARDMMU:
149 if (args.architecture == ARCHITECTURE_SH4_7750) {
150 DPRINTF((TEXT("No SH4 MMU code.\n")));
151 return FALSE;
154 _mem = new MemoryManager_SHMMU(_cons, page_size);
155 break;
156 case MEMORY_MANAGER_LOCKPAGES:
157 _mem = new MemoryManager_LockPages(lock_pages, unlock_pages,
158 _cons, page_size);
159 break;
161 _mem->setDebug() = args.memorymanagerDebug;
163 // File Manager, Loader
164 return super::create();
166 cpu_mismatch:
167 DPRINTF((TEXT("CPU mismatch. CPU is SH%d\n"),
168 SHArchitecture::cpu_type()));
170 return FALSE;