1 /* $NetBSD: boot.cpp,v 1.6 2005/12/11 12:17:28 christos Exp $ */
4 * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
38 #include <load_coff.h>
39 #undef DPRINTF // trash coff_machdep.h's DPRINTF
46 #include <arm/arm_boot.h>
49 #include <mips/mips_boot.h>
52 #include <sh3/sh_boot.h>
55 Boot
*Boot::_instance
= 0;
64 // register bootloader to menu system.
65 // (will be invoked by boot button)
66 struct HpcMenuInterface::boot_hook_args bha
;
69 HPC_MENU
.register_boot_hook(bha
);
72 _instance
= new ARMBoot();
75 _instance
= new MIPSBoot();
78 _instance
= new SHBoot();
81 memset(&_instance
->args
, 0, sizeof(struct BootSetupArgs
));
82 _instance
->args
.consoleEnable
= TRUE
;
98 struct HpcMenuInterface::HpcMenuPreferences
&pref
= HPC_PREFERENCE
;
100 args
.console
= pref
.boot_serial
? CONSOLE_SERIAL
: CONSOLE_LCD
;
103 TCHAR
*dir
= pref
.dir_user_path
;
104 if (wcsstr(dir
, TEXT("http://")))
105 args
.file
= FILE_HTTP
;
107 args
.file
= wcschr(dir
, TEXT('/')) ? FILE_UFS
: FILE_FAT
;
108 wcscpy(args
.fileRoot
, dir
);
111 wcscpy(args
.fileName
, pref
.kernel_user_file
);
112 args
.loadmfs
= (pref
.rootfs
== 2);
114 wcscpy(args
.mfsName
, pref
.rootfs_file
);
117 args
.loaderDebug
= FALSE
;
118 args
.architectureDebug
= FALSE
;
119 args
.memorymanagerDebug
= FALSE
;
120 args
.fileDebug
= FALSE
;
131 // set default console
132 _cons
= Console::Instance();
148 // Set this console (setuped by machine dependent part) as default.
149 Console::changeConsole(*_cons
);
152 _file
= new FileManager(_cons
, args
.file
);
153 _file
->setDebug() = args
.fileDebug
;
162 switch (Loader::objectFormat(*_file
)) {
164 _loader
= new ElfLoader(_cons
, _mem
);
167 _loader
= new CoffLoader(_cons
, _mem
);
170 DPRINTF((TEXT("unknown file format.\n")));