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