No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hpc / stand / hpcboot / arm / arm_boot.cpp
blob351e540221da77bb7fcbb467af16c93b02356751
1 /* $NetBSD: arm_boot.cpp,v 1.9 2008/04/28 20:23:20 martin Exp $ */
3 /*-
4 * Copyright (c) 2001 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 <arm/arm_arch.h>
38 #include <arm/arm_sa1100.h>
39 #include <arm/arm_pxa2x0.h>
40 #include <arm/arm_boot.h>
41 #include <arm/arm_console.h>
43 ARMBoot::ARMBoot()
47 ARMBoot::~ARMBoot()
49 if (_mem)
50 delete _mem;
51 if (_arch)
52 delete _arch;
54 ARMConsole::Destroy();
57 BOOL
58 ARMBoot::setup()
60 struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
62 platid_t platid;
63 platid.dw.dw0 = pref.platid_hi;
64 platid.dw.dw1 = pref.platid_lo;
66 if (platid_match(&platid, &platid_mask_CPU_ARM_STRONGARM_SA1100))
67 args.architecture = ARCHITECTURE_ARM_SA1100;
68 else if (platid_match(&platid, &platid_mask_CPU_ARM_STRONGARM_SA1110))
69 args.architecture = ARCHITECTURE_ARM_SA1100;
70 else if (platid_match(&platid, &platid_mask_CPU_ARM_XSCALE_PXA250))
71 args.architecture = ARCHITECTURE_ARM_PXA250;
72 else if (platid_match(&platid, &platid_mask_CPU_ARM_XSCALE_PXA270))
73 args.architecture = ARCHITECTURE_ARM_PXA270;
74 else
75 return FALSE;
77 args.memory = MEMORY_MANAGER_LOCKPAGES;
79 return super::setup();
82 BOOL
83 ARMBoot::create()
85 BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
86 BOOL(*unlock_pages)(LPVOID, DWORD);
88 // Architecture dependent ops.
89 switch (args.architecture) {
90 default:
91 DPRINTF((TEXT("Unsupported architecture.\n")));
92 return FALSE;
93 case ARCHITECTURE_ARM_SA1100:
94 _arch = new SA1100Architecture(_cons, _mem);
95 break;
96 case ARCHITECTURE_ARM_PXA250:
97 case ARCHITECTURE_ARM_PXA270:
98 _arch = new PXA2X0Architecture(_cons, _mem);
99 break;
101 _arch->setDebug() = args.architectureDebug;
103 lock_pages = _arch->_load_LockPages();
104 unlock_pages = _arch->_load_UnlockPages();
105 if (lock_pages == 0 || unlock_pages == 0) {
107 DPRINTF((TEXT("couldn't find LockPages/UnlockPages.\n")));
108 return FALSE;
111 // Memory manager.
112 switch(args.memory)
114 default:
115 case MEMORY_MANAGER_VIRTUALCOPY:
116 // FALLTHROUGH
117 case MEMORY_MANAGER_SOFTMMU:
118 // FALLTHROUGH
119 case MEMORY_MANAGER_HARDMMU:
120 DPRINTF((TEXT("unsupported memory address detection method.\n")));
121 return FALSE;
122 case MEMORY_MANAGER_LOCKPAGES:
123 _mem = new MemoryManager_LockPages(lock_pages, unlock_pages,
124 _cons, 4096);
125 break;
127 _mem->setDebug() = args.memorymanagerDebug;
129 // Console
130 if (args.console == CONSOLE_SERIAL) {
131 _cons = ARMConsole::Instance(_mem, args.architecture);
132 if (_cons == NULL || !_cons->init()) {
133 _cons = Console::Instance();
134 DPRINTF((TEXT("use LCD console instead.\n")));
136 } else {
137 _cons = Console::Instance();
140 // File Manager, Loader
141 return super::create();