1 /* -*-C++-*- $NetBSD: hpcmenu.h,v 1.13 2006/03/05 04:05:39 uwe 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.
32 #ifndef _HPCBOOT_MENU_H_
33 #define _HPCBOOT_MENU_H_
37 // forward declaration.
46 class OptionTabWindow
;
47 class ConsoleTabWindow
;
57 int _cx_char
, _cy_char
; // 5, 14
60 void _get_font_size(void) {
63 SelectObject(hdc
, GetStockObject(SYSTEM_FONT
));
64 GetTextMetrics(hdc
, &tm
);
65 _cx_char
= tm
.tmAveCharWidth
;
66 _cy_char
= tm
.tmHeight
+ tm
.tmExternalLeading
;
71 explicit HpcBootApp(HINSTANCE instance
) : _instance(instance
) {
76 virtual ~HpcBootApp(void) { /* NO-OP */ }
78 BOOL
registerClass(WNDPROC proc
);
82 // internal representation of user input.
83 class HpcMenuInterface
86 struct HpcMenuPreferences
{
87 #define HPCBOOT_MAGIC 0x177d5753
90 size_t _size
; // size of HpcMenuPreferences structure.
93 TCHAR dir_user_path
[MAX_PATH
];
95 TCHAR kernel_user_file
[MAX_PATH
];
99 TCHAR rootfs_file
[MAX_PATH
];
103 BOOL boot_single_user
;
104 BOOL boot_ask_for_name
;
106 // boot loader options.
109 BOOL pause_before_boot
;
110 BOOL load_debug_info
;
112 // serial console speed
114 #define MAX_BOOT_STR 256
115 TCHAR boot_extra
[MAX_BOOT_STR
];
117 struct support_status
{
118 uint32_t cpu
, machine
;
121 static struct support_status _unsupported
[];
124 MainTabWindow
*_main
;
125 OptionTabWindow
*_option
;
126 ConsoleTabWindow
*_console
;
127 struct HpcMenuPreferences _pref
;
129 struct boot_hook_args
{
134 struct cons_hook_args
{
135 void(*func
)(void *, unsigned char);
138 int _cons_parameter
; // Console tab window check buttons.
141 static HpcMenuInterface
*_instance
;
143 void _set_default_pref(void);
149 void *_platform(int, enum _platform_op
);
152 HpcMenuInterface(void);
153 virtual ~HpcMenuInterface(void) { /* NO-OP */ }
156 static HpcMenuInterface
&Instance(void);
157 static void Destroy(void);
164 // when user click `boot button' inquires all options.
165 void get_options(void);
166 enum { MAX_KERNEL_ARGS
= 16 };
167 int setup_kernel_args(vaddr_t
, paddr_t
, size_t);
168 void setup_bootinfo(struct bootinfo
&bi
);
169 void register_boot_hook(struct boot_hook_args
&arg
) {
172 // call architecture dependent boot function.
176 void progress(const char * = NULL
);
177 void unprogress(void);
179 // Console window interface.
181 void register_cons_hook(struct cons_hook_args
&arg
, int id
) {
182 if (id
>= 0 && id
< 4)
183 _cons_hook
[id
] = arg
;
186 // Main window options
188 int dir_default(void);
191 TCHAR
*platform_get(int n
) {
192 return reinterpret_cast <TCHAR
*>
193 (_platform(n
, _PLATFORM_OP_GET
));
195 int platform_default(void) {
196 return reinterpret_cast <int>
197 (_platform(0, _PLATFORM_OP_DEFAULT
));
199 void platform_set(int n
) { _platform(n
, _PLATFORM_OP_SET
); }
202 /* Global access macro */
203 #define HPC_MENU (HpcMenuInterface::Instance())
204 #define HPC_PREFERENCE (HPC_MENU._pref)
206 #endif // _HPCBOOT_MENU_H_