hpcmenu.h revision 1.7 1 1.7 enami /* -*-C++-*- $NetBSD: hpcmenu.h,v 1.7 2001/05/17 01:50:35 enami Exp $ */
2 1.1 uch
3 1.1 uch /*-
4 1.1 uch * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.1 uch * All rights reserved.
6 1.1 uch *
7 1.1 uch * This code is derived from software contributed to The NetBSD Foundation
8 1.1 uch * by UCHIYAMA Yasushi.
9 1.1 uch *
10 1.1 uch * Redistribution and use in source and binary forms, with or without
11 1.1 uch * modification, are permitted provided that the following conditions
12 1.1 uch * are met:
13 1.1 uch * 1. Redistributions of source code must retain the above copyright
14 1.1 uch * notice, this list of conditions and the following disclaimer.
15 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 uch * notice, this list of conditions and the following disclaimer in the
17 1.1 uch * documentation and/or other materials provided with the distribution.
18 1.1 uch * 3. All advertising materials mentioning features or use of this software
19 1.1 uch * must display the following acknowledgement:
20 1.1 uch * This product includes software developed by the NetBSD
21 1.1 uch * Foundation, Inc. and its contributors.
22 1.1 uch * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 uch * contributors may be used to endorse or promote products derived
24 1.1 uch * from this software without specific prior written permission.
25 1.1 uch *
26 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 uch * POSSIBILITY OF SUCH DAMAGE.
37 1.1 uch */
38 1.1 uch
39 1.1 uch #ifndef _HPCBOOT_MENU_H_
40 1.1 uch #define _HPCBOOT_MENU_H_
41 1.1 uch
42 1.1 uch #include <hpcdefs.h>
43 1.1 uch
44 1.1 uch // forward declaration.
45 1.1 uch class Console;
46 1.1 uch class HpcBootApp;
47 1.1 uch class RootWindow;
48 1.1 uch class BootButton;
49 1.1 uch class CancelButton;
50 1.1 uch class ProgressBar;
51 1.1 uch class TabWindowBase;
52 1.1 uch class MainTabWindow;
53 1.1 uch class OptionTabWindow;
54 1.1 uch class ConsoleTabWindow;
55 1.1 uch struct bootinfo;
56 1.1 uch
57 1.1 uch // Application
58 1.1 uch class HpcBootApp {
59 1.1 uch public:
60 1.1 uch HINSTANCE _instance;
61 1.1 uch HWND _cmdbar;
62 1.1 uch RootWindow *_root;
63 1.5 uch Console *_cons;
64 1.1 uch int _cx_char, _cy_char; // 5, 14
65 1.1 uch
66 1.1 uch private:
67 1.1 uch void _get_font_size(void) {
68 1.1 uch HDC hdc = GetDC(0);
69 1.1 uch TEXTMETRIC tm;
70 1.1 uch SelectObject(hdc, GetStockObject(SYSTEM_FONT));
71 1.1 uch GetTextMetrics(hdc, &tm);
72 1.1 uch _cx_char = tm.tmAveCharWidth;
73 1.1 uch _cy_char = tm.tmHeight + tm.tmExternalLeading;
74 1.1 uch ReleaseDC(0, hdc);
75 1.1 uch }
76 1.1 uch
77 1.1 uch public:
78 1.1 uch explicit HpcBootApp(HINSTANCE instance) : _instance(instance) {
79 1.1 uch _root = 0;
80 1.1 uch _cmdbar = 0;
81 1.1 uch _get_font_size();
82 1.1 uch }
83 1.1 uch virtual ~HpcBootApp(void) { /* NO-OP */ }
84 1.1 uch
85 1.1 uch BOOL registerClass(WNDPROC proc);
86 1.1 uch int run(void);
87 1.1 uch };
88 1.1 uch
89 1.1 uch // internal representation of user input.
90 1.1 uch class HpcMenuInterface
91 1.1 uch {
92 1.1 uch public:
93 1.1 uch struct HpcMenuPreferences {
94 1.1 uch #define HPCBOOT_MAGIC 0x177d5753
95 1.1 uch int _magic;
96 1.1 uch int _version;
97 1.1 uch size_t _size; // size of HpcMenuPreferences structure.
98 1.1 uch int dir;
99 1.1 uch BOOL dir_user;
100 1.1 uch TCHAR dir_user_path[MAX_PATH];
101 1.1 uch BOOL kernel_user;
102 1.1 uch TCHAR kernel_user_file[MAX_PATH];
103 1.1 uch unsigned platid_hi;
104 1.1 uch unsigned platid_lo;
105 1.1 uch int rootfs;
106 1.1 uch TCHAR rootfs_file[MAX_PATH];
107 1.1 uch // kernel options.
108 1.1 uch BOOL boot_serial;
109 1.1 uch BOOL boot_verbose;
110 1.1 uch BOOL boot_single_user;
111 1.1 uch BOOL boot_ask_for_name;
112 1.7 enami BOOL boot_debugger;
113 1.1 uch // boot loader options.
114 1.1 uch int auto_boot;
115 1.1 uch BOOL reverse_video;
116 1.1 uch BOOL pause_before_boot;
117 1.1 uch BOOL load_debug_info;
118 1.1 uch BOOL safety_message;
119 1.4 uch // serial console speed
120 1.4 uch int serial_speed;
121 1.1 uch };
122 1.3 uch struct support_status {
123 1.3 uch u_int32_t cpu, machine;
124 1.3 uch const TCHAR *cause;
125 1.3 uch };
126 1.3 uch static struct support_status _unsupported[];
127 1.1 uch
128 1.1 uch RootWindow *_root;
129 1.1 uch MainTabWindow *_main;
130 1.5 uch OptionTabWindow *_option;
131 1.1 uch ConsoleTabWindow *_console;
132 1.1 uch struct HpcMenuPreferences _pref;
133 1.1 uch
134 1.1 uch struct boot_hook_args {
135 1.5 uch void(*func)(void *);
136 1.1 uch void *arg;
137 1.1 uch } _boot_hook;
138 1.1 uch
139 1.1 uch struct cons_hook_args {
140 1.1 uch void(*func)(void *, unsigned char);
141 1.1 uch void *arg;
142 1.1 uch } _cons_hook [4];
143 1.2 uch int _cons_parameter; // Console tab window check buttons.
144 1.1 uch
145 1.1 uch private:
146 1.1 uch static HpcMenuInterface *_instance;
147 1.1 uch
148 1.5 uch void _set_default_pref(void);
149 1.1 uch enum _platform_op {
150 1.1 uch _PLATFORM_OP_GET,
151 1.1 uch _PLATFORM_OP_SET,
152 1.1 uch _PLATFORM_OP_DEFAULT
153 1.1 uch };
154 1.1 uch void *_platform(int, enum _platform_op);
155 1.1 uch
156 1.1 uch protected:
157 1.5 uch HpcMenuInterface(void);
158 1.1 uch virtual ~HpcMenuInterface(void) { /* NO-OP */ }
159 1.1 uch
160 1.1 uch public:
161 1.1 uch static HpcMenuInterface &Instance(void);
162 1.1 uch static void Destroy(void);
163 1.1 uch
164 1.1 uch // preferences.
165 1.1 uch BOOL load(void);
166 1.1 uch BOOL save(void);
167 1.1 uch
168 1.1 uch // Boot button
169 1.1 uch // when user click `boot button' inquires all options.
170 1.1 uch void get_options(void);
171 1.1 uch enum { MAX_KERNEL_ARGS = 16 };
172 1.1 uch int setup_kernel_args(vaddr_t, paddr_t);
173 1.1 uch void setup_bootinfo(struct bootinfo &bi);
174 1.1 uch void register_boot_hook(struct boot_hook_args &arg) {
175 1.1 uch _boot_hook = arg;
176 1.1 uch }
177 1.1 uch // call architecture dependent boot function.
178 1.3 uch void boot(void);
179 1.1 uch // Progress bar.
180 1.1 uch void progress(void);
181 1.1 uch
182 1.1 uch // Console window interface.
183 1.1 uch void print(TCHAR *);
184 1.1 uch void register_cons_hook(struct cons_hook_args &arg, int id) {
185 1.1 uch if (id >= 0 && id < 4)
186 1.1 uch _cons_hook[id] = arg;
187 1.1 uch }
188 1.1 uch
189 1.1 uch // Main window options
190 1.1 uch TCHAR *dir(int);
191 1.1 uch int dir_default(void);
192 1.1 uch
193 1.1 uch // platform
194 1.1 uch TCHAR *platform_get(int n) {
195 1.1 uch return reinterpret_cast <TCHAR *>
196 1.6 uch (_platform(n, _PLATFORM_OP_GET));
197 1.1 uch }
198 1.1 uch int platform_default(void) {
199 1.1 uch return reinterpret_cast <int>
200 1.6 uch (_platform(0, _PLATFORM_OP_DEFAULT));
201 1.1 uch }
202 1.1 uch void platform_set(int n) { _platform(n, _PLATFORM_OP_SET); }
203 1.1 uch };
204 1.5 uch
205 1.5 uch /* Global access macro */
206 1.5 uch #define HPC_MENU (HpcMenuInterface::Instance())
207 1.5 uch #define HPC_PREFERENCE (HPC_MENU._pref)
208 1.1 uch
209 1.1 uch #endif // _HPCBOOT_MENU_H_
210