1*283e4408Snonaka /* $NetBSD: arm_boot.cpp,v 1.10 2009/01/29 21:23:38 nonaka 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
349173eae7Such #include <arch.h>
359173eae7Such #include <memory.h>
369173eae7Such
379173eae7Such #include <arm/arm_arch.h>
383af75740Srafal #include <arm/arm_sa1100.h>
393af75740Srafal #include <arm/arm_pxa2x0.h>
409173eae7Such #include <arm/arm_boot.h>
419173eae7Such #include <arm/arm_console.h>
429173eae7Such
ARMBoot()43bd926f64Such ARMBoot::ARMBoot()
449173eae7Such {
459173eae7Such }
469173eae7Such
~ARMBoot()47bd926f64Such ARMBoot::~ARMBoot()
489173eae7Such {
499173eae7Such if (_mem)
509173eae7Such delete _mem;
519173eae7Such if (_arch)
529173eae7Such delete _arch;
539173eae7Such
549173eae7Such ARMConsole::Destroy();
559173eae7Such }
569173eae7Such
579173eae7Such BOOL
setup()58bd926f64Such ARMBoot::setup()
599173eae7Such {
60bd926f64Such struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
61bd926f64Such
629173eae7Such platid_t platid;
639173eae7Such platid.dw.dw0 = pref.platid_hi;
649173eae7Such platid.dw.dw1 = pref.platid_lo;
659173eae7Such
669173eae7Such if (platid_match(&platid, &platid_mask_CPU_ARM_STRONGARM_SA1100))
679173eae7Such args.architecture = ARCHITECTURE_ARM_SA1100;
6843d63b4dStoshii else if (platid_match(&platid, &platid_mask_CPU_ARM_STRONGARM_SA1110))
6943d63b4dStoshii args.architecture = ARCHITECTURE_ARM_SA1100;
703af75740Srafal else if (platid_match(&platid, &platid_mask_CPU_ARM_XSCALE_PXA250))
713af75740Srafal args.architecture = ARCHITECTURE_ARM_PXA250;
72*283e4408Snonaka else if (platid_match(&platid, &platid_mask_CPU_ARM_XSCALE_PXA270))
73*283e4408Snonaka args.architecture = ARCHITECTURE_ARM_PXA270;
749173eae7Such else
759173eae7Such return FALSE;
769173eae7Such
779173eae7Such args.memory = MEMORY_MANAGER_LOCKPAGES;
789173eae7Such
79bd926f64Such return super::setup();
809173eae7Such }
819173eae7Such
829173eae7Such BOOL
create()83bd926f64Such ARMBoot::create()
849173eae7Such {
859173eae7Such BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
869173eae7Such BOOL(*unlock_pages)(LPVOID, DWORD);
879173eae7Such
883af75740Srafal // Architecture dependent ops.
893af75740Srafal switch (args.architecture) {
903af75740Srafal default:
913af75740Srafal DPRINTF((TEXT("Unsupported architecture.\n")));
923af75740Srafal return FALSE;
933af75740Srafal case ARCHITECTURE_ARM_SA1100:
943af75740Srafal _arch = new SA1100Architecture(_cons, _mem);
953af75740Srafal break;
963af75740Srafal case ARCHITECTURE_ARM_PXA250:
97*283e4408Snonaka case ARCHITECTURE_ARM_PXA270:
983af75740Srafal _arch = new PXA2X0Architecture(_cons, _mem);
993af75740Srafal break;
1003af75740Srafal }
1019173eae7Such _arch->setDebug() = args.architectureDebug;
1029173eae7Such
1039173eae7Such lock_pages = _arch->_load_LockPages();
1049173eae7Such unlock_pages = _arch->_load_UnlockPages();
1059173eae7Such if (lock_pages == 0 || unlock_pages == 0) {
1069173eae7Such
1079173eae7Such DPRINTF((TEXT("couldn't find LockPages/UnlockPages.\n")));
1089173eae7Such return FALSE;
1099173eae7Such }
1109173eae7Such
1119173eae7Such // Memory manager.
1129173eae7Such switch(args.memory)
1139173eae7Such {
1149173eae7Such default:
1159173eae7Such case MEMORY_MANAGER_VIRTUALCOPY:
1169173eae7Such // FALLTHROUGH
1179173eae7Such case MEMORY_MANAGER_SOFTMMU:
1189173eae7Such // FALLTHROUGH
1199173eae7Such case MEMORY_MANAGER_HARDMMU:
1209173eae7Such DPRINTF((TEXT("unsupported memory address detection method.\n")));
1219173eae7Such return FALSE;
1229173eae7Such case MEMORY_MANAGER_LOCKPAGES:
1239173eae7Such _mem = new MemoryManager_LockPages(lock_pages, unlock_pages,
1249173eae7Such _cons, 4096);
1259173eae7Such break;
1269173eae7Such }
1279173eae7Such _mem->setDebug() = args.memorymanagerDebug;
1289173eae7Such
1299173eae7Such // Console
1309173eae7Such if (args.console == CONSOLE_SERIAL) {
1313af75740Srafal _cons = ARMConsole::Instance(_mem, args.architecture);
1323af75740Srafal if (_cons == NULL || !_cons->init()) {
1339173eae7Such _cons = Console::Instance();
1349173eae7Such DPRINTF((TEXT("use LCD console instead.\n")));
1359173eae7Such }
136376c55b2Such } else {
137376c55b2Such _cons = Console::Instance();
1389173eae7Such }
1399173eae7Such
1409173eae7Such // File Manager, Loader
141bd926f64Such return super::create();
1429173eae7Such }
143