arm_boot.cpp revision 1.9 1 /* $NetBSD: arm_boot.cpp,v 1.9 2008/04/28 20:23:20 martin Exp $ */
2
3 /*-
4 * Copyright (c) 2001 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 #include <hpcboot.h>
33
34 #include <arch.h>
35 #include <memory.h>
36
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>
42
43 ARMBoot::ARMBoot()
44 {
45 }
46
47 ARMBoot::~ARMBoot()
48 {
49 if (_mem)
50 delete _mem;
51 if (_arch)
52 delete _arch;
53
54 ARMConsole::Destroy();
55 }
56
57 BOOL
58 ARMBoot::setup()
59 {
60 struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
61
62 platid_t platid;
63 platid.dw.dw0 = pref.platid_hi;
64 platid.dw.dw1 = pref.platid_lo;
65
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
73 return FALSE;
74
75 args.memory = MEMORY_MANAGER_LOCKPAGES;
76
77 return super::setup();
78 }
79
80 BOOL
81 ARMBoot::create()
82 {
83 BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
84 BOOL(*unlock_pages)(LPVOID, DWORD);
85
86 // Architecture dependent ops.
87 switch (args.architecture) {
88 default:
89 DPRINTF((TEXT("Unsupported architecture.\n")));
90 return FALSE;
91 case ARCHITECTURE_ARM_SA1100:
92 _arch = new SA1100Architecture(_cons, _mem);
93 break;
94 case ARCHITECTURE_ARM_PXA250:
95 _arch = new PXA2X0Architecture(_cons, _mem);
96 break;
97 }
98 _arch->setDebug() = args.architectureDebug;
99
100 lock_pages = _arch->_load_LockPages();
101 unlock_pages = _arch->_load_UnlockPages();
102 if (lock_pages == 0 || unlock_pages == 0) {
103
104 DPRINTF((TEXT("couldn't find LockPages/UnlockPages.\n")));
105 return FALSE;
106 }
107
108 // Memory manager.
109 switch(args.memory)
110 {
111 default:
112 case MEMORY_MANAGER_VIRTUALCOPY:
113 // FALLTHROUGH
114 case MEMORY_MANAGER_SOFTMMU:
115 // FALLTHROUGH
116 case MEMORY_MANAGER_HARDMMU:
117 DPRINTF((TEXT("unsupported memory address detection method.\n")));
118 return FALSE;
119 case MEMORY_MANAGER_LOCKPAGES:
120 _mem = new MemoryManager_LockPages(lock_pages, unlock_pages,
121 _cons, 4096);
122 break;
123 }
124 _mem->setDebug() = args.memorymanagerDebug;
125
126 // Console
127 if (args.console == CONSOLE_SERIAL) {
128 _cons = ARMConsole::Instance(_mem, args.architecture);
129 if (_cons == NULL || !_cons->init()) {
130 _cons = Console::Instance();
131 DPRINTF((TEXT("use LCD console instead.\n")));
132 }
133 } else {
134 _cons = Console::Instance();
135 }
136
137 // File Manager, Loader
138 return super::create();
139 }
140