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