1*ce099b40Smartin /* -*-C++-*- $NetBSD: mips_boot.cpp,v 1.8 2008/04/28 20:23:20 martin Exp $ */
29173eae7Such
39173eae7Such /*-
49173eae7Such * Copyright (c) 2001 The NetBSD Foundation, Inc.
59173eae7Such * All rights reserved.
69173eae7Such *
79173eae7Such * This code is derived from software contributed to The NetBSD Foundation
89173eae7Such * by UCHIYAMA Yasushi.
99173eae7Such *
109173eae7Such * Redistribution and use in source and binary forms, with or without
119173eae7Such * modification, are permitted provided that the following conditions
129173eae7Such * are met:
139173eae7Such * 1. Redistributions of source code must retain the above copyright
149173eae7Such * notice, this list of conditions and the following disclaimer.
159173eae7Such * 2. Redistributions in binary form must reproduce the above copyright
169173eae7Such * notice, this list of conditions and the following disclaimer in the
179173eae7Such * documentation and/or other materials provided with the distribution.
189173eae7Such *
199173eae7Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
209173eae7Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
219173eae7Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
229173eae7Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
239173eae7Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
249173eae7Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
259173eae7Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
269173eae7Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
279173eae7Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
289173eae7Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
299173eae7Such * POSSIBILITY OF SUCH DAMAGE.
309173eae7Such */
319173eae7Such
329173eae7Such #include <hpcboot.h>
339173eae7Such #include <console.h>
349173eae7Such
359173eae7Such #include <arch.h>
369173eae7Such #include <memory.h>
379173eae7Such
389173eae7Such #include <mips/mips_arch.h>
399173eae7Such #include <mips/mips_boot.h>
409173eae7Such #include <mips/mips_vr41.h>
419173eae7Such #include <mips/mips_tx39.h>
42bd926f64Such #include <mips/mips_console.h>
439173eae7Such
MIPSBoot()44bd926f64Such MIPSBoot::MIPSBoot()
459173eae7Such {
469173eae7Such }
479173eae7Such
~MIPSBoot()48bd926f64Such MIPSBoot::~MIPSBoot()
499173eae7Such {
509173eae7Such if (_mem)
519173eae7Such delete _mem;
529173eae7Such if (_arch)
539173eae7Such delete _arch;
54bd926f64Such
55bd926f64Such MIPSConsole::Destroy();
569173eae7Such }
579173eae7Such
589173eae7Such BOOL
setup()59bd926f64Such MIPSBoot::setup()
609173eae7Such {
61bd926f64Such struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
62bd926f64Such
639173eae7Such platid_t platid;
649173eae7Such platid.dw.dw0 = pref.platid_hi;
659173eae7Such platid.dw.dw1 = pref.platid_lo;
669173eae7Such
679173eae7Such if (platid_match(&platid, &platid_mask_CPU_MIPS_VR)) {
689173eae7Such args.architecture = ARCHITECTURE_MIPS_VR41;
699173eae7Such } else if (platid_match(&platid, &platid_mask_CPU_MIPS_TX_3900)) {
709173eae7Such args.architecture = ARCHITECTURE_MIPS_TX3900;
719173eae7Such } else if (platid_match(&platid, &platid_mask_CPU_MIPS_TX_3920)) {
729173eae7Such args.architecture = ARCHITECTURE_MIPS_TX3920;
739173eae7Such } else {
749173eae7Such DPRINTF((TEXT("unknown MIPS variants.\n")));
759173eae7Such return FALSE;
769173eae7Such }
779173eae7Such
78bd926f64Such return super::setup();
799173eae7Such }
809173eae7Such
819173eae7Such BOOL
create()82bd926f64Such MIPSBoot::create()
839173eae7Such {
842f39ebbaSenami SYSTEM_INFO sysinfo;
859173eae7Such size_t pagesz;
869173eae7Such int shift;
879173eae7Such BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
889173eae7Such BOOL(*unlock_pages)(LPVOID, DWORD);
899173eae7Such
909173eae7Such // Console
919173eae7Such if (args.console == CONSOLE_SERIAL) {
92bd926f64Such _cons = MIPSConsole::Instance();
93bd926f64Such if (!_cons->init()) {
949173eae7Such _cons = Console::Instance();
959173eae7Such DPRINTF((TEXT("use LCD console instead.\n")));
969173eae7Such }
97376c55b2Such } else {
98376c55b2Such _cons = Console::Instance();
99bd926f64Such }
1009173eae7Such
1019173eae7Such // Architercure dependent ops.
1029173eae7Such switch(args.architecture) {
1039173eae7Such default:
1049173eae7Such DPRINTF((TEXT("unsupported architecture.\n")));
1059173eae7Such return FALSE;
1069173eae7Such case ARCHITECTURE_MIPS_TX3900:
1079173eae7Such // FALLTHROUGH
1089173eae7Such case ARCHITECTURE_MIPS_TX3920:
1099173eae7Such _arch = new TX39XX(_cons, _mem, args.architecture);
1109173eae7Such pagesz = 4096;
1119173eae7Such shift = 0;
1129173eae7Such break;
1139173eae7Such case ARCHITECTURE_MIPS_VR41:
1149173eae7Such _arch = new VR41XX(_cons, _mem);
1152f39ebbaSenami GetSystemInfo(&sysinfo);
1162f39ebbaSenami DPRINTF((TEXT("sysinfo.dwPageSize = %d\n"),
1172f39ebbaSenami sysinfo.dwPageSize));
1182f39ebbaSenami pagesz = sysinfo.dwPageSize;
1199173eae7Such shift = 4; // VR41 specific shift. for LockPages()
1209173eae7Such break;
1219173eae7Such }
1229173eae7Such _arch->setDebug() = args.architectureDebug;
1239173eae7Such
1249173eae7Such // Memory manager.
1259173eae7Such // LockPages API exists in Windows CE 2.11 or later. check it.
1269173eae7Such lock_pages = _arch->_load_LockPages();
1279173eae7Such unlock_pages = _arch->_load_UnlockPages();
1289173eae7Such if (lock_pages == 0 || unlock_pages == 0)
1299173eae7Such args.memory = MEMORY_MANAGER_VIRTUALCOPY;
1309173eae7Such else
1319173eae7Such args.memory = MEMORY_MANAGER_LOCKPAGES;
1329173eae7Such
1339173eae7Such switch(args.memory) {
1349173eae7Such default:
1359173eae7Such break;
1369173eae7Such case MEMORY_MANAGER_SOFTMMU:
1379173eae7Such // FALLTHROUGH
1389173eae7Such case MEMORY_MANAGER_HARDMMU:
1399173eae7Such DPRINTF((TEXT("unsupported memory address detection method.\n")));
1409173eae7Such return FALSE;
1419173eae7Such case MEMORY_MANAGER_LOCKPAGES:
1429173eae7Such _mem = new MemoryManager_LockPages(lock_pages, unlock_pages,
1439173eae7Such _cons, pagesz, shift);
1449173eae7Such break;
1459173eae7Such case MEMORY_MANAGER_VIRTUALCOPY:
1469173eae7Such _mem = new MemoryManager_VirtualCopy(_cons, pagesz);
1479173eae7Such break;
1489173eae7Such }
1499173eae7Such _mem->setDebug() = args.memorymanagerDebug;
1509173eae7Such
1519173eae7Such // File Manager, Loader
152bd926f64Such return super::create();
1539173eae7Such }
154