1 /* -*-C++-*- $NetBSD: mips_boot.cpp,v 1.1 2001/02/09 18:35:06 uch 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 #include <console.h> 41 42 #include <arch.h> 43 #include <memory.h> 44 45 #include <mips/mips_arch.h> 46 #include <mips/mips_boot.h> 47 #include <mips/mips_vr41.h> 48 #include <mips/mips_tx39.h> 49 50 MIPSBoot::MIPSBoot(void) 51 { 52 } 53 54 MIPSBoot::~MIPSBoot(void) 55 { 56 if (_mem) 57 delete _mem; 58 if (_arch) 59 delete _arch; 60 } 61 62 BOOL 63 MIPSBoot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref) 64 { 65 platid_t platid; 66 platid.dw.dw0 = pref.platid_hi; 67 platid.dw.dw1 = pref.platid_lo; 68 69 if (platid_match(&platid, &platid_mask_CPU_MIPS_VR)) { 70 args.architecture = ARCHITECTURE_MIPS_VR41; 71 } else if (platid_match(&platid, &platid_mask_CPU_MIPS_TX_3900)) { 72 args.architecture = ARCHITECTURE_MIPS_TX3900; 73 } else if (platid_match(&platid, &platid_mask_CPU_MIPS_TX_3920)) { 74 args.architecture = ARCHITECTURE_MIPS_TX3920; 75 } else { 76 DPRINTF((TEXT("unknown MIPS variants.\n"))); 77 return FALSE; 78 } 79 80 return Boot::setup(pref); 81 } 82 83 BOOL 84 MIPSBoot::create(void) 85 { 86 size_t pagesz; 87 int shift; 88 BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int); 89 BOOL(*unlock_pages)(LPVOID, DWORD); 90 91 // Console 92 if (args.console == CONSOLE_SERIAL) { 93 _cons = Console::Instance(); 94 DPRINTF((TEXT("use LCD console instead.\n"))); 95 } 96 97 // Architercure dependent ops. 98 switch(args.architecture) { 99 default: 100 DPRINTF((TEXT("unsupported architecture.\n"))); 101 return FALSE; 102 case ARCHITECTURE_MIPS_TX3900: 103 // FALLTHROUGH 104 case ARCHITECTURE_MIPS_TX3920: 105 _arch = new TX39XX(_cons, _mem, args.architecture); 106 pagesz = 4096; 107 shift = 0; 108 break; 109 case ARCHITECTURE_MIPS_VR41: 110 _arch = new VR41XX(_cons, _mem); 111 pagesz = 1024; 112 shift = 4; // VR41 specific shift. for LockPages() 113 break; 114 } 115 _arch->setDebug() = args.architectureDebug; 116 117 // Memory manager. 118 // LockPages API exists in Windows CE 2.11 or later. check it. 119 lock_pages = _arch->_load_LockPages(); 120 unlock_pages = _arch->_load_UnlockPages(); 121 if (lock_pages == 0 || unlock_pages == 0) 122 args.memory = MEMORY_MANAGER_VIRTUALCOPY; 123 else 124 args.memory = MEMORY_MANAGER_LOCKPAGES; 125 126 switch(args.memory) { 127 default: 128 break; 129 case MEMORY_MANAGER_SOFTMMU: 130 // FALLTHROUGH 131 case MEMORY_MANAGER_HARDMMU: 132 DPRINTF((TEXT("unsupported memory address detection method.\n"))); 133 return FALSE; 134 case MEMORY_MANAGER_LOCKPAGES: 135 _mem = new MemoryManager_LockPages(lock_pages, unlock_pages, 136 _cons, pagesz, shift); 137 break; 138 case MEMORY_MANAGER_VIRTUALCOPY: 139 _mem = new MemoryManager_VirtualCopy(_cons, pagesz); 140 break; 141 } 142 _mem->setDebug() = args.memorymanagerDebug; 143 144 145 // File Manager, Loader 146 return Boot::create(); 147 } 148