1 /* $NetBSD: arm_boot.cpp,v 1.10 2009/01/29 21:23:38 nonaka 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 if (platid_match(&platid, &platid_mask_CPU_ARM_XSCALE_PXA270)) 73 args.architecture = ARCHITECTURE_ARM_PXA270; 74 else 75 return FALSE; 76 77 args.memory = MEMORY_MANAGER_LOCKPAGES; 78 79 return super::setup(); 80 } 81 82 BOOL 83 ARMBoot::create() 84 { 85 BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int); 86 BOOL(*unlock_pages)(LPVOID, DWORD); 87 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; 100 } 101 _arch->setDebug() = args.architectureDebug; 102 103 lock_pages = _arch->_load_LockPages(); 104 unlock_pages = _arch->_load_UnlockPages(); 105 if (lock_pages == 0 || unlock_pages == 0) { 106 107 DPRINTF((TEXT("couldn't find LockPages/UnlockPages.\n"))); 108 return FALSE; 109 } 110 111 // Memory manager. 112 switch(args.memory) 113 { 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; 126 } 127 _mem->setDebug() = args.memorymanagerDebug; 128 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"))); 135 } 136 } else { 137 _cons = Console::Instance(); 138 } 139 140 // File Manager, Loader 141 return super::create(); 142 } 143