Home | History | Annotate | Line # | Download | only in hpcboot
hpcmenu.h revision 1.11
      1  1.11    uch /* -*-C++-*-	$NetBSD: hpcmenu.h,v 1.11 2004/08/06 18:33:09 uch Exp $	*/
      2   1.1    uch 
      3   1.1    uch /*-
      4  1.10    uch  * Copyright (c) 2001, 2004 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.11    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.11    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.11    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.11    uch #define	MAX_BOOT_STR 256
    122   1.8    uch 		TCHAR	boot_extra[MAX_BOOT_STR];
    123   1.1    uch 	};
    124   1.3    uch 	struct support_status {
    125   1.3    uch 		u_int32_t cpu, machine;
    126   1.3    uch 		const TCHAR *cause;
    127   1.3    uch 	};
    128   1.3    uch 	static struct support_status _unsupported[];
    129   1.1    uch 
    130   1.1    uch 	RootWindow		*_root;
    131   1.1    uch 	MainTabWindow		*_main;
    132   1.5    uch 	OptionTabWindow		*_option;
    133   1.1    uch 	ConsoleTabWindow	*_console;
    134   1.1    uch 	struct HpcMenuPreferences _pref;
    135   1.1    uch 
    136   1.1    uch 	struct boot_hook_args {
    137   1.5    uch 		void(*func)(void *);
    138   1.1    uch 		void *arg;
    139   1.1    uch 	} _boot_hook;
    140   1.1    uch 
    141   1.1    uch 	struct cons_hook_args {
    142   1.1    uch 		void(*func)(void *, unsigned char);
    143   1.1    uch 		void *arg;
    144   1.1    uch 	} _cons_hook [4];
    145   1.2    uch 	int _cons_parameter; // Console tab window check buttons.
    146   1.1    uch 
    147   1.1    uch private:
    148   1.1    uch 	static HpcMenuInterface *_instance;
    149   1.1    uch 
    150   1.5    uch 	void _set_default_pref(void);
    151   1.1    uch 	enum _platform_op {
    152   1.1    uch 		_PLATFORM_OP_GET,
    153   1.1    uch 		_PLATFORM_OP_SET,
    154   1.1    uch 		_PLATFORM_OP_DEFAULT
    155   1.1    uch 	};
    156   1.1    uch 	void *_platform(int, enum _platform_op);
    157   1.1    uch 
    158   1.1    uch protected:
    159   1.5    uch 	HpcMenuInterface(void);
    160   1.1    uch 	virtual ~HpcMenuInterface(void) { /* NO-OP */ }
    161   1.1    uch 
    162   1.1    uch public:
    163   1.1    uch 	static HpcMenuInterface &Instance(void);
    164   1.1    uch 	static void Destroy(void);
    165   1.1    uch 
    166   1.1    uch 	// preferences.
    167   1.1    uch 	BOOL load(void);
    168   1.1    uch 	BOOL save(void);
    169  1.11    uch 
    170   1.1    uch 	// Boot button
    171   1.1    uch 	// when user click `boot button' inquires all options.
    172   1.1    uch 	void get_options(void);
    173   1.1    uch 	enum { MAX_KERNEL_ARGS = 16 };
    174   1.8    uch 	int setup_kernel_args(vaddr_t, paddr_t, size_t);
    175   1.1    uch 	void setup_bootinfo(struct bootinfo &bi);
    176   1.1    uch 	void register_boot_hook(struct boot_hook_args &arg) {
    177   1.1    uch 		_boot_hook = arg;
    178   1.1    uch 	}
    179   1.1    uch 	// call architecture dependent boot function.
    180   1.3    uch 	void boot(void);
    181   1.9    uwe 
    182   1.1    uch 	// Progress bar.
    183  1.10    uch 	void progress(const char * = NULL);
    184   1.9    uwe 	void unprogress(void);
    185   1.1    uch 
    186   1.1    uch 	// Console window interface.
    187   1.1    uch 	void print(TCHAR *);
    188   1.1    uch 	void register_cons_hook(struct cons_hook_args &arg, int id) {
    189   1.1    uch 		if (id >= 0 && id < 4)
    190   1.1    uch 			_cons_hook[id] = arg;
    191   1.1    uch 	}
    192   1.1    uch 
    193   1.1    uch 	// Main window options
    194   1.1    uch 	TCHAR *dir(int);
    195   1.1    uch 	int dir_default(void);
    196  1.11    uch 
    197   1.1    uch 	// platform
    198   1.1    uch 	TCHAR *platform_get(int n) {
    199   1.1    uch 		return reinterpret_cast <TCHAR *>
    200   1.6    uch 		    (_platform(n, _PLATFORM_OP_GET));
    201   1.1    uch 	}
    202   1.1    uch 	int platform_default(void) {
    203   1.1    uch 		return reinterpret_cast <int>
    204   1.6    uch 		    (_platform(0, _PLATFORM_OP_DEFAULT));
    205   1.1    uch 	}
    206   1.1    uch 	void platform_set(int n) { _platform(n, _PLATFORM_OP_SET); }
    207   1.1    uch };
    208   1.5    uch 
    209   1.5    uch /* Global access macro */
    210  1.11    uch #define	HPC_MENU	(HpcMenuInterface::Instance())
    211  1.11    uch #define	HPC_PREFERENCE	(HPC_MENU._pref)
    212   1.1    uch 
    213   1.1    uch #endif // _HPCBOOT_MENU_H_
    214