code clean up.
This commit is contained in:
parent
f7bfe29cb1
commit
bd926f64c6
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: arm_boot.cpp,v 1.2 2001/03/11 11:47:24 toshii Exp $ */
|
||||
/* $NetBSD: arm_boot.cpp,v 1.3 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -45,11 +45,11 @@
|
||||
#include <arm/arm_boot.h>
|
||||
#include <arm/arm_console.h>
|
||||
|
||||
ARMBoot::ARMBoot(void)
|
||||
ARMBoot::ARMBoot()
|
||||
{
|
||||
}
|
||||
|
||||
ARMBoot::~ARMBoot(void)
|
||||
ARMBoot::~ARMBoot()
|
||||
{
|
||||
if (_mem)
|
||||
delete _mem;
|
||||
@ -60,8 +60,10 @@ ARMBoot::~ARMBoot(void)
|
||||
}
|
||||
|
||||
BOOL
|
||||
ARMBoot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
ARMBoot::setup()
|
||||
{
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
|
||||
platid_t platid;
|
||||
platid.dw.dw0 = pref.platid_hi;
|
||||
platid.dw.dw1 = pref.platid_lo;
|
||||
@ -75,11 +77,11 @@ ARMBoot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
|
||||
args.memory = MEMORY_MANAGER_LOCKPAGES;
|
||||
|
||||
return Boot::setup(pref);
|
||||
return super::setup();
|
||||
}
|
||||
|
||||
BOOL
|
||||
ARMBoot::create(void)
|
||||
ARMBoot::create()
|
||||
{
|
||||
BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
|
||||
BOOL(*unlock_pages)(LPVOID, DWORD);
|
||||
@ -124,5 +126,5 @@ ARMBoot::create(void)
|
||||
}
|
||||
|
||||
// File Manager, Loader
|
||||
return Boot::create();
|
||||
return super::create();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: arm_boot.h,v 1.1 2001/02/09 18:34:53 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: arm_boot.h,v 1.2 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -42,10 +42,13 @@
|
||||
#include <boot.h>
|
||||
|
||||
class ARMBoot : public Boot {
|
||||
private:
|
||||
typedef Boot super;
|
||||
|
||||
public:
|
||||
ARMBoot(void);
|
||||
~ARMBoot(void);
|
||||
virtual BOOL setup(struct HpcMenuInterface::HpcMenuPreferences &);
|
||||
virtual BOOL setup(void);
|
||||
virtual BOOL create(void);
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: arm_console.cpp,v 1.1 2001/02/09 18:34:53 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: arm_console.cpp,v 1.2 2001/04/24 19:28:00 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -55,28 +55,27 @@ ARMConsole::Destroy(void)
|
||||
delete _instance;
|
||||
}
|
||||
|
||||
BOOL
|
||||
ARMConsole::init(void)
|
||||
{
|
||||
if (!openCOM1())
|
||||
if (!super::init())
|
||||
return FALSE;
|
||||
|
||||
_uart_base = _mem->mapPhysicalPage(0x80050000, 0x100, PAGE_READWRITE);
|
||||
if (_uart_base == ~0)
|
||||
return FALSE;
|
||||
_uart_busy = _uart_base + 0x20;
|
||||
_uart_transmit = _uart_base + 0x14;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ARMConsole::print(const TCHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
_vsnwprintf(_bufw, CONSOLE_BUFSIZE * sizeof(TCHAR), fmt, ap);
|
||||
va_end(ap);
|
||||
SETUP_WIDECHAR_BUFFER();
|
||||
|
||||
if (!setupBuffer())
|
||||
if (!setupMultibyteBuffer())
|
||||
return;
|
||||
|
||||
for (int i = 0; _bufm[i] != '\0' && i < CONSOLE_BUFSIZE; i++) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: arm_console.h,v 1.1 2001/02/09 18:34:54 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: arm_console.h,v 1.2 2001/04/24 19:28:00 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -45,6 +45,8 @@
|
||||
|
||||
class ARMConsole : public SerialConsole {
|
||||
private:
|
||||
typedef SerialConsole super;
|
||||
|
||||
static ARMConsole *_instance;
|
||||
|
||||
MemoryManager *&_mem;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: boot.cpp,v 1.1 2001/02/09 18:34:34 uch Exp $ */
|
||||
/* $NetBSD: boot.cpp,v 1.2 2001/04/24 19:27:58 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -70,10 +70,12 @@ Boot::Instance()
|
||||
if (_instance)
|
||||
return *_instance;
|
||||
|
||||
// register bootloader to menu system.
|
||||
// (will be invoked by boot button)
|
||||
struct HpcMenuInterface::boot_hook_args bha;
|
||||
bha.func = hpcboot;
|
||||
bha.arg = 0;
|
||||
HpcMenuInterface::Instance().register_boot_hook(bha);
|
||||
bha.arg = 0;
|
||||
HPC_MENU.register_boot_hook(bha);
|
||||
|
||||
#ifdef ARM
|
||||
_instance = new ARMBoot();
|
||||
@ -99,8 +101,10 @@ Boot::Destroy()
|
||||
}
|
||||
|
||||
BOOL
|
||||
Boot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
Boot::setup()
|
||||
{
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
|
||||
args.console = pref.boot_serial ? CONSOLE_SERIAL : CONSOLE_LCD;
|
||||
|
||||
// file path.
|
||||
@ -128,9 +132,9 @@ Boot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
|
||||
Boot::Boot()
|
||||
{
|
||||
_arch = 0;
|
||||
_mem = 0;
|
||||
_file = 0;
|
||||
_arch = 0;
|
||||
_mem = 0;
|
||||
_file = 0;
|
||||
_loader = 0;
|
||||
// set default console
|
||||
_cons = Console::Instance();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: boot.h,v 1.1 2001/02/09 18:34:35 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: boot.h,v 1.2 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -59,20 +59,19 @@ protected:
|
||||
Boot(void);
|
||||
virtual ~Boot(void);
|
||||
|
||||
Console *_cons; // LCD/Serial
|
||||
Architecture *_arch; // StrongARM/VR41XX/TX39XX/SH3/SH4
|
||||
MemoryManager *_mem; // VirtualAlloc/LockPage/MMU
|
||||
File *_file; // FAT/FFS/via HTTP
|
||||
Loader *_loader; // ELF/COFF
|
||||
Console *_cons; // LCD/Serial
|
||||
Architecture *_arch; // StrongARM/VR41XX/TX39XX/SH3/SH4
|
||||
MemoryManager *_mem; // VirtualAlloc/LockPage/MMU
|
||||
File *_file; // FAT/FFS/via HTTP
|
||||
Loader *_loader; // ELF/COFF
|
||||
|
||||
public:
|
||||
static Boot &Instance(void);
|
||||
static void Destroy(void);
|
||||
|
||||
virtual BOOL create(void);
|
||||
virtual BOOL setup(struct HpcMenuInterface::HpcMenuPreferences &);
|
||||
friend void hpcboot(void *,
|
||||
struct HpcMenuInterface::HpcMenuPreferences &);
|
||||
virtual BOOL setup(void);
|
||||
friend void hpcboot(void *);
|
||||
|
||||
BOOL Boot::attachLoader(void);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: console.cpp,v 1.3 2001/03/25 17:13:16 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: console.cpp,v 1.4 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -41,6 +41,9 @@
|
||||
|
||||
Console *Console::_instance = 0;
|
||||
|
||||
//
|
||||
// Display console
|
||||
//
|
||||
Console *
|
||||
Console::Instance()
|
||||
{
|
||||
@ -60,17 +63,28 @@ Console::Destroy()
|
||||
void
|
||||
Console::print(const TCHAR *fmt, ...)
|
||||
{
|
||||
TCHAR tmp[CONSOLE_BUFSIZE];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
wvsprintf(tmp, fmt, ap);
|
||||
wvsprintf(_bufw, fmt, ap);
|
||||
va_end(ap);
|
||||
HpcMenuInterface::Instance().print(tmp);
|
||||
|
||||
// print to `Console Tab Window'
|
||||
HPC_MENU.print(_bufw);
|
||||
}
|
||||
|
||||
//
|
||||
// Serial console.
|
||||
//
|
||||
BOOL
|
||||
SerialConsole::init()
|
||||
{
|
||||
// always open COM1 to supply clock and power for the
|
||||
// sake of kernel serial driver
|
||||
return openCOM1();
|
||||
}
|
||||
|
||||
BOOL
|
||||
SerialConsole::setupBuffer()
|
||||
SerialConsole::setupMultibyteBuffer()
|
||||
{
|
||||
size_t len = WideCharToMultiByte(CP_ACP, 0, _bufw, wcslen(_bufw),
|
||||
0, 0, 0, 0);
|
||||
@ -83,11 +97,21 @@ SerialConsole::setupBuffer()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
SerialConsole::print(const TCHAR *fmt, ...)
|
||||
{
|
||||
SETUP_WIDECHAR_BUFFER();
|
||||
|
||||
if (!setupMultibyteBuffer())
|
||||
return;
|
||||
|
||||
genericPrint(_bufm);
|
||||
}
|
||||
|
||||
BOOL
|
||||
SerialConsole::openCOM1()
|
||||
{
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
int speed = menu._pref.serial_speed;
|
||||
int speed = HPC_PREFERENCE.serial_speed;
|
||||
|
||||
if (_handle == INVALID_HANDLE_VALUE) {
|
||||
_handle = CreateFile(TEXT("COM1:"),
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: console.h,v 1.3 2001/03/22 18:19:09 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: console.h,v 1.4 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -48,9 +48,12 @@ private:
|
||||
|
||||
protected:
|
||||
enum { CONSOLE_BUFSIZE = 256 };
|
||||
TCHAR _bufw[CONSOLE_BUFSIZE]; // wide char buffer.
|
||||
BOOL _on;
|
||||
|
||||
protected:
|
||||
int16_t _boot_console;
|
||||
|
||||
Console(void) { /* NO-OP */ }
|
||||
~Console(void) { /* NO-OP */ }
|
||||
|
||||
@ -69,20 +72,28 @@ private:
|
||||
HANDLE _handle;
|
||||
|
||||
protected:
|
||||
TCHAR _bufw[CONSOLE_BUFSIZE];
|
||||
char _bufm[CONSOLE_BUFSIZE];
|
||||
char _bufm[CONSOLE_BUFSIZE]; // multibyte char buffer.
|
||||
|
||||
protected:
|
||||
SerialConsole(void) { _handle = INVALID_HANDLE_VALUE; }
|
||||
BOOL openCOM1(void);
|
||||
BOOL setupBuffer(void);
|
||||
BOOL setupMultibyteBuffer(void);
|
||||
|
||||
public:
|
||||
void genericPrint(const char *);
|
||||
virtual BOOL init(void) { return TRUE; };
|
||||
virtual BOOL init(void);
|
||||
virtual int16_t getBootConsole(void) { return BI_CNUSE_SERIAL; }
|
||||
virtual void print(const TCHAR *fmt, ...);
|
||||
};
|
||||
|
||||
#define SETUP_WIDECHAR_BUFFER() \
|
||||
__BEGIN_MACRO \
|
||||
va_list ap; \
|
||||
va_start(ap, fmt); \
|
||||
wvsprintf(_bufw, fmt, ap); \
|
||||
va_end(ap); \
|
||||
__END_MACRO
|
||||
|
||||
#define DPRINTF_SETUP() Console *_cons = Console::Instance()
|
||||
#define DPRINTFN(level, x) \
|
||||
if (_debug > level) _cons->print x
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: framebuffer.cpp,v 1.6 2001/03/25 17:14:04 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: framebuffer.cpp,v 1.7 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -85,8 +85,7 @@ FrameBufferInfo::~FrameBufferInfo()
|
||||
int
|
||||
FrameBufferInfo::type()
|
||||
{
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
BOOL reverse = menu._pref.reverse_video;
|
||||
BOOL reverse = HPC_PREFERENCE.reverse_video;
|
||||
int type;
|
||||
|
||||
switch(_fb->bpp) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: hpcboot.config,v 1.3 2001/04/15 12:27:33 takemura Exp $
|
||||
# $NetBSD: hpcboot.config,v 1.4 2001/04/24 19:27:59 uch Exp $
|
||||
# config file/script to generate project file (.dsp/.vcp) for hpcboot
|
||||
|
||||
TYPE=application
|
||||
@ -24,6 +24,7 @@ SRCFILE_LIST='
|
||||
load_elf.cpp
|
||||
load_coff.cpp
|
||||
memory.cpp
|
||||
menu\menu.cpp
|
||||
menu\window.cpp
|
||||
menu\tabwindow.cpp
|
||||
menu\rootwindow.cpp
|
||||
@ -48,6 +49,7 @@ SRCFILE_LIST_SH3='
|
||||
'
|
||||
SRCFILE_LIST_MIPS='
|
||||
mips\mips_arch.cpp
|
||||
mips\mips_console.cpp
|
||||
mips\mips_boot.cpp
|
||||
mips\mips_vr41.cpp
|
||||
mips\mips_tx39.cpp
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hpcboot.cpp,v 1.2 2001/03/22 18:21:02 uch Exp $ */
|
||||
/* $NetBSD: hpcboot.cpp,v 1.3 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -54,8 +54,8 @@ int WINAPI
|
||||
WinMain(HINSTANCE instance, HINSTANCE prev_instance,
|
||||
LPTSTR cmd_line, int window_show)
|
||||
{
|
||||
HpcMenuInterface::Instance();
|
||||
HpcBootApp *app = 0; // Application body.
|
||||
HpcMenuInterface::Instance(); // Menu System
|
||||
HpcBootApp *app = 0; // Application body.
|
||||
int ret = 0;
|
||||
|
||||
InitCommonControls();
|
||||
@ -70,9 +70,9 @@ WinMain(HINSTANCE instance, HINSTANCE prev_instance,
|
||||
if (!app->_root->create(0))
|
||||
goto failed;
|
||||
|
||||
Boot::Instance();
|
||||
Boot::Instance(); // Boot loader
|
||||
|
||||
ret = app->run();
|
||||
ret = app->run(); // Main loop.
|
||||
// NOTREACHED
|
||||
|
||||
failed:
|
||||
@ -87,18 +87,21 @@ WinMain(HINSTANCE instance, HINSTANCE prev_instance,
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// boot sequence.
|
||||
//
|
||||
void
|
||||
hpcboot(void *arg, struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
hpcboot(void *arg)
|
||||
{
|
||||
size_t sz = 0;
|
||||
paddr_t p = 0;
|
||||
Boot &f = Boot::Instance();
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
Console *_cons = Console::Instance();
|
||||
TCHAR *error_message = 0;
|
||||
|
||||
HpcMenuInterface &menu = HPC_MENU;
|
||||
Boot &f = Boot::Instance();
|
||||
|
||||
menu.progress();
|
||||
if (!f.setup(pref))
|
||||
if (!f.setup())
|
||||
return;
|
||||
|
||||
menu.progress();
|
||||
@ -189,7 +192,7 @@ hpcboot(void *arg, struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
f._loader->tagDump(3); // dump page chain.(print first 3 links)
|
||||
|
||||
// jump to kernel entry.
|
||||
if (menu._pref.pause_before_boot) {
|
||||
if (HPC_PREFERENCE.pause_before_boot) {
|
||||
if (MessageBox(menu._root->_window, TEXT("Push OK to boot."),
|
||||
TEXT("Last chance..."), MB_YESNO) != IDYES)
|
||||
goto failed;
|
||||
@ -213,11 +216,10 @@ int
|
||||
HpcBootApp::run(void)
|
||||
{
|
||||
MSG msg;
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
|
||||
while (GetMessage(&msg, 0, 0, 0)) {
|
||||
// cancel auto-boot.
|
||||
if (menu._pref.auto_boot > 0 && _root &&
|
||||
if (HPC_PREFERENCE.auto_boot > 0 && _root &&
|
||||
(msg.message == WM_KEYDOWN ||
|
||||
msg.message == WM_LBUTTONDOWN)) {
|
||||
_root->disableTimer();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: hpcmenu.cpp,v 1.5 2001/03/25 17:13:16 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: hpcmenu.cpp,v 1.6 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -42,442 +42,11 @@
|
||||
#include <menu/window.h>
|
||||
#include <menu/tabwindow.h>
|
||||
#include <menu/rootwindow.h>
|
||||
#include <menu/menu.h>
|
||||
#include <machine/bootinfo.h>
|
||||
#include <framebuffer.h>
|
||||
#include <console.h>
|
||||
|
||||
static BOOL _find_pref_dir(TCHAR *);
|
||||
//
|
||||
// Main window
|
||||
//
|
||||
class MainTabWindow : public TabWindow
|
||||
{
|
||||
private:
|
||||
HWND _edit_md_root;
|
||||
HWND _combobox_serial_speed;
|
||||
|
||||
int _item_idx;
|
||||
void _insert_item(HWND w, TCHAR *name, int id) {
|
||||
int idx = SendDlgItemMessage(w, id, CB_ADDSTRING, 0,
|
||||
reinterpret_cast <LPARAM>(name));
|
||||
if (idx != CB_ERR)
|
||||
SendDlgItemMessage(w, IDC_MAIN_DIR, CB_SETITEMDATA,
|
||||
idx, _item_idx++);
|
||||
}
|
||||
|
||||
public:
|
||||
explicit MainTabWindow(TabWindowBase &base, int id)
|
||||
: TabWindow(base, id, TEXT("WMain")) {
|
||||
_item_idx = 0;
|
||||
}
|
||||
virtual ~MainTabWindow(void) { /* NO-OP */ }
|
||||
virtual void init(HWND w) {
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
struct HpcMenuInterface::HpcMenuPreferences
|
||||
*pref = &menu._pref;
|
||||
_window = w;
|
||||
// insert myself to tab-control
|
||||
TabWindow::init(w);
|
||||
|
||||
// setup child.
|
||||
TCHAR *entry;
|
||||
int i;
|
||||
// kernel directory path
|
||||
for (i = 0; entry = menu.dir(i); i++)
|
||||
_insert_item(w, entry, IDC_MAIN_DIR);
|
||||
SendDlgItemMessage(w, IDC_MAIN_DIR, CB_SETCURSEL,
|
||||
menu.dir_default(), 0);
|
||||
// platform
|
||||
for (i = 0; entry = menu.platform_get(i); i++)
|
||||
_insert_item(w, entry, IDC_MAIN_PLATFORM);
|
||||
SendDlgItemMessage(w, IDC_MAIN_PLATFORM, CB_SETCURSEL,
|
||||
menu.platform_default(), 0);
|
||||
// kernel file name.
|
||||
Edit_SetText(GetDlgItem(w, IDC_MAIN_KERNEL),
|
||||
pref->kernel_user ? pref->kernel_user_file :
|
||||
TEXT("netbsd.gz"));
|
||||
|
||||
// root file system.
|
||||
int fs = pref->rootfs + IDC_MAIN_ROOT_;
|
||||
_set_check(fs, TRUE);
|
||||
|
||||
_edit_md_root = GetDlgItem(w, IDC_MAIN_ROOT_MD_OPS);
|
||||
Edit_SetText(_edit_md_root, pref->rootfs_file);
|
||||
EnableWindow(_edit_md_root, fs == IDC_MAIN_ROOT_MD
|
||||
? TRUE : FALSE);
|
||||
|
||||
// kernel boot options.
|
||||
_set_check(IDC_MAIN_OPTION_A, pref->boot_ask_for_name);
|
||||
_set_check(IDC_MAIN_OPTION_S, pref->boot_single_user);
|
||||
_set_check(IDC_MAIN_OPTION_V, pref->boot_verbose);
|
||||
_set_check(IDC_MAIN_OPTION_H, pref->boot_serial);
|
||||
|
||||
// serial console speed.
|
||||
TCHAR *speed_tab[] = { L"9600", L"19200", L"115200", 0 };
|
||||
int sel = 0;
|
||||
i = 0;
|
||||
for (TCHAR **speed = speed_tab; *speed; speed++, i++) {
|
||||
_insert_item(w, *speed, IDC_MAIN_OPTION_H_SPEED);
|
||||
if (_wtoi(*speed) == pref->serial_speed)
|
||||
sel = i;
|
||||
}
|
||||
_combobox_serial_speed = GetDlgItem(_window,
|
||||
IDC_MAIN_OPTION_H_SPEED);
|
||||
SendDlgItemMessage(w, IDC_MAIN_OPTION_H_SPEED, CB_SETCURSEL,
|
||||
sel, 0);
|
||||
EnableWindow(_combobox_serial_speed, pref->boot_serial);
|
||||
}
|
||||
|
||||
void get(void) {
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
struct HpcMenuInterface::HpcMenuPreferences
|
||||
*pref = &menu._pref;
|
||||
|
||||
HWND w = GetDlgItem(_window, IDC_MAIN_DIR);
|
||||
ComboBox_GetText(w, pref->dir_user_path, MAX_PATH);
|
||||
pref->dir_user = TRUE;
|
||||
w = GetDlgItem(_window, IDC_MAIN_KERNEL);
|
||||
Edit_GetText(w, pref->kernel_user_file, MAX_PATH);
|
||||
pref->kernel_user = TRUE;
|
||||
|
||||
int i = ComboBox_GetCurSel(GetDlgItem(_window,
|
||||
IDC_MAIN_PLATFORM));
|
||||
menu.platform_set(i);
|
||||
|
||||
if (_is_checked(IDC_MAIN_ROOT_WD))
|
||||
pref->rootfs = 0;
|
||||
else if (_is_checked(IDC_MAIN_ROOT_SD))
|
||||
pref->rootfs = 1;
|
||||
else if (_is_checked(IDC_MAIN_ROOT_MD))
|
||||
pref->rootfs = 2;
|
||||
else if (_is_checked(IDC_MAIN_ROOT_NFS))
|
||||
pref->rootfs = 3;
|
||||
|
||||
pref->boot_ask_for_name = _is_checked(IDC_MAIN_OPTION_A);
|
||||
pref->boot_verbose = _is_checked(IDC_MAIN_OPTION_V);
|
||||
pref->boot_single_user = _is_checked(IDC_MAIN_OPTION_S);
|
||||
pref->boot_serial = _is_checked(IDC_MAIN_OPTION_H);
|
||||
Edit_GetText(_edit_md_root, pref->rootfs_file, MAX_PATH);
|
||||
|
||||
TCHAR tmpbuf[8];
|
||||
ComboBox_GetText(_combobox_serial_speed, tmpbuf, 8);
|
||||
pref->serial_speed = _wtoi(tmpbuf);
|
||||
}
|
||||
|
||||
virtual void command(int id, int msg) {
|
||||
switch (id) {
|
||||
case IDC_MAIN_OPTION_H:
|
||||
EnableWindow(_combobox_serial_speed,
|
||||
_is_checked(IDC_MAIN_OPTION_H));
|
||||
break;
|
||||
case IDC_MAIN_ROOT_WD:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_MAIN_ROOT_SD:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_MAIN_ROOT_MD:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_MAIN_ROOT_NFS:
|
||||
EnableWindow(_edit_md_root,
|
||||
_is_checked(IDC_MAIN_ROOT_MD));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Option window
|
||||
//
|
||||
class OptionTabWindow : public TabWindow
|
||||
{
|
||||
public:
|
||||
HWND _spin_edit;
|
||||
HWND _spin;
|
||||
#define IS_CHECKED(x) _is_checked(IDC_OPT_##x)
|
||||
#define SET_CHECK(x, b) _set_check(IDC_OPT_##x,(b))
|
||||
|
||||
public:
|
||||
explicit OptionTabWindow(TabWindowBase &base, int id)
|
||||
: TabWindow(base, id, TEXT("WOption")) {
|
||||
_spin_edit = NULL;
|
||||
_spin = NULL;
|
||||
}
|
||||
virtual ~OptionTabWindow(void) { /* NO-OP */ }
|
||||
virtual void init(HWND w) {
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
struct HpcMenuInterface::HpcMenuPreferences
|
||||
*pref = &menu._pref;
|
||||
_window = w;
|
||||
|
||||
TabWindow::init(_window);
|
||||
_spin_edit = GetDlgItem(_window, IDC_OPT_AUTO_INPUT);
|
||||
_spin = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE |
|
||||
UDS_SETBUDDYINT | UDS_ALIGNRIGHT,
|
||||
80, 0, 50, 50, _window,
|
||||
IDC_OPT_AUTO_UPDOWN,
|
||||
_app._instance, _spin_edit,
|
||||
60, 1, 30);
|
||||
BOOL onoff = pref->auto_boot ? TRUE : FALSE;
|
||||
EnableWindow(_spin_edit, onoff);
|
||||
EnableWindow(_spin, onoff);
|
||||
|
||||
SET_CHECK(AUTO, pref->auto_boot);
|
||||
if (pref->auto_boot)
|
||||
{
|
||||
TCHAR tmp[32];
|
||||
wsprintf(tmp, TEXT("%d"), pref->auto_boot);
|
||||
Edit_SetText(_spin_edit, tmp);
|
||||
}
|
||||
SET_CHECK(VIDEO, pref->reverse_video);
|
||||
SET_CHECK(PAUSE, pref->pause_before_boot);
|
||||
SET_CHECK(DEBUG, pref->load_debug_info);
|
||||
SET_CHECK(SAFETY, pref->safety_message);
|
||||
}
|
||||
|
||||
virtual void command(int id, int msg) {
|
||||
switch (id) {
|
||||
case IDC_OPT_AUTO:
|
||||
if (IS_CHECKED(AUTO)) {
|
||||
EnableWindow(_spin_edit, TRUE);
|
||||
EnableWindow(_spin, TRUE);
|
||||
} else {
|
||||
EnableWindow(_spin_edit, FALSE);
|
||||
EnableWindow(_spin, FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void get(void) {
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
struct HpcMenuInterface::HpcMenuPreferences
|
||||
*pref = &menu._pref;
|
||||
if (IS_CHECKED(AUTO)) {
|
||||
TCHAR tmp[32];
|
||||
Edit_GetText(_spin_edit, tmp, 32);
|
||||
pref->auto_boot = _wtoi(tmp);
|
||||
} else
|
||||
pref->auto_boot = 0;
|
||||
pref->reverse_video = IS_CHECKED(VIDEO);
|
||||
pref->pause_before_boot = IS_CHECKED(PAUSE);
|
||||
pref->load_debug_info = IS_CHECKED(DEBUG);
|
||||
pref->safety_message = IS_CHECKED(SAFETY);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Console window
|
||||
//
|
||||
class ConsoleTabWindow : public TabWindow
|
||||
{
|
||||
private:
|
||||
HWND _filename_edit;
|
||||
BOOL _filesave;
|
||||
HANDLE _logfile;
|
||||
BOOL _open_log_file(void);
|
||||
public:
|
||||
HWND _edit;
|
||||
|
||||
public:
|
||||
explicit ConsoleTabWindow(TabWindowBase &base, int id)
|
||||
: TabWindow(base, id, TEXT("WConsole")) {
|
||||
_edit = NULL;
|
||||
_logfile = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
virtual ~ConsoleTabWindow(void) {
|
||||
if (_logfile != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(_logfile);
|
||||
}
|
||||
virtual void init(HWND);
|
||||
virtual void command(int, int);
|
||||
|
||||
void print(TCHAR *buf, BOOL = FALSE);
|
||||
};
|
||||
|
||||
void
|
||||
ConsoleTabWindow::print(TCHAR *buf, BOOL force_display)
|
||||
{
|
||||
int cr;
|
||||
TCHAR *p;
|
||||
|
||||
if (force_display)
|
||||
goto display;
|
||||
|
||||
if (_filesave) {
|
||||
if (_logfile == INVALID_HANDLE_VALUE && !_open_log_file()) {
|
||||
_filesave = FALSE;
|
||||
_set_check(IDC_CONS_FILESAVE, _filesave);
|
||||
EnableWindow(_filename_edit, _filesave);
|
||||
goto display;
|
||||
}
|
||||
DWORD cnt;
|
||||
char c;
|
||||
for (int i = 0; *buf != TEXT('\0'); buf++) {
|
||||
c = *buf & 0x7f;
|
||||
WriteFile(_logfile, &c, 1, &cnt, 0);
|
||||
}
|
||||
FlushFileBuffers(_logfile);
|
||||
return;
|
||||
}
|
||||
|
||||
display:
|
||||
// count # of '\n'
|
||||
for (cr = 0, p = buf; p = wcschr(p, TEXT('\n')); cr++, p++)
|
||||
;
|
||||
// total length of new buffer('\n' -> "\r\n" + '\0')
|
||||
int ln = wcslen(buf) + cr + 1;
|
||||
|
||||
// get old buffer.
|
||||
int lo = Edit_GetTextLength(_edit);
|
||||
size_t sz =(lo + ln) * sizeof(TCHAR);
|
||||
|
||||
p = reinterpret_cast <TCHAR *>(malloc(sz));
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
memset(p, 0, sz);
|
||||
Edit_GetText(_edit, p, lo + 1);
|
||||
|
||||
// put new buffer to end of old buffer.
|
||||
TCHAR *d = p + lo;
|
||||
while (*buf != TEXT('\0')) {
|
||||
TCHAR c = *buf++;
|
||||
if (c == TEXT('\n'))
|
||||
*d++ = TEXT('\r');
|
||||
*d++ = c;
|
||||
}
|
||||
*d = TEXT('\0');
|
||||
|
||||
// display total buffer.
|
||||
Edit_SetText(_edit, p);
|
||||
// Edit_Scroll(_edit, Edit_GetLineCount(_edit), 0);
|
||||
UpdateWindow(_edit);
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
void
|
||||
ConsoleTabWindow::init(HWND w)
|
||||
{
|
||||
// at this time _window is NULL.
|
||||
// use argument of window procedure.
|
||||
TabWindow::init(w);
|
||||
_edit = GetDlgItem(w, IDC_CONS_EDIT);
|
||||
MoveWindow(_edit, 5, 60, _rect.right - _rect.left - 10,
|
||||
_rect.bottom - _rect.top - 60, TRUE);
|
||||
Edit_FmtLines(_edit, TRUE);
|
||||
|
||||
// log file.
|
||||
_filename_edit = GetDlgItem(w, IDC_CONS_FILENAME);
|
||||
_filesave = FALSE;
|
||||
Edit_SetText(_filename_edit, L"bootlog.txt");
|
||||
EnableWindow(_filename_edit, _filesave);
|
||||
}
|
||||
|
||||
void
|
||||
ConsoleTabWindow::command(int id, int msg)
|
||||
{
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
struct HpcMenuInterface::cons_hook_args *hook = 0;
|
||||
int bit;
|
||||
|
||||
switch(id) {
|
||||
case IDC_CONS_FILESAVE:
|
||||
_filesave = _is_checked(IDC_CONS_FILESAVE);
|
||||
EnableWindow(_filename_edit, _filesave);
|
||||
break;
|
||||
case IDC_CONS_CHK0:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK1:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK2:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK3:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK4:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK5:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK6:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK7:
|
||||
bit = 1 << (id - IDC_CONS_CHK_);
|
||||
if (SendDlgItemMessage(_window, id, BM_GETCHECK, 0, 0))
|
||||
menu._cons_parameter |= bit;
|
||||
else
|
||||
menu._cons_parameter &= ~bit;
|
||||
break;
|
||||
case IDC_CONS_BTN0:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_BTN1:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_BTN2:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_BTN3:
|
||||
hook = &menu._cons_hook[id - IDC_CONS_BTN_];
|
||||
if (hook->func)
|
||||
hook->func(hook->arg, menu._cons_parameter);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
ConsoleTabWindow::_open_log_file()
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
TCHAR filename[MAX_PATH];
|
||||
TCHAR filepath[MAX_PATH];
|
||||
|
||||
if (!_find_pref_dir(path)) {
|
||||
print(L"couldn't find temporary directory.\n", TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Edit_GetText(_filename_edit, filename, MAX_PATH);
|
||||
wsprintf(filepath, TEXT("\\%s\\%s"), path, filename);
|
||||
_logfile = CreateFile(filepath, GENERIC_WRITE, 0, 0,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
|
||||
0);
|
||||
if (_logfile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
|
||||
wsprintf(path, TEXT("log file is %s\n"), filepath);
|
||||
print(path, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TabWindow *
|
||||
TabWindowBase::boot(int id)
|
||||
{
|
||||
TabWindow *w = NULL;
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
|
||||
switch(id) {
|
||||
default:
|
||||
break;
|
||||
case IDC_BASE_MAIN:
|
||||
menu._main = new MainTabWindow(*this, IDC_BASE_MAIN);
|
||||
w = menu._main;
|
||||
break;
|
||||
case IDC_BASE_OPTION:
|
||||
menu._option = new OptionTabWindow(*this, IDC_BASE_OPTION);
|
||||
w = menu._option;
|
||||
break;
|
||||
case IDC_BASE_CONSOLE:
|
||||
menu._console = new ConsoleTabWindow(*this, IDC_BASE_CONSOLE);
|
||||
w = menu._console;
|
||||
break;
|
||||
}
|
||||
|
||||
if (w)
|
||||
w->create(0);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
//
|
||||
// External Interface
|
||||
//
|
||||
HpcMenuInterface *HpcMenuInterface::_instance = 0;
|
||||
|
||||
HpcMenuInterface &
|
||||
@ -495,6 +64,18 @@ HpcMenuInterface::Destroy()
|
||||
delete _instance;
|
||||
}
|
||||
|
||||
HpcMenuInterface::HpcMenuInterface()
|
||||
{
|
||||
if (!load())
|
||||
_set_default_pref();
|
||||
_pref._version = HPCBOOT_VERSION;
|
||||
_pref._size = sizeof(HpcMenuPreferences);
|
||||
|
||||
_cons_parameter = 0;
|
||||
memset(_cons_hook, 0, sizeof(struct cons_hook_args) * 4);
|
||||
memset(&_boot_hook, 0, sizeof(struct boot_hook_args));
|
||||
}
|
||||
|
||||
void
|
||||
HpcMenuInterface::print(TCHAR *buf)
|
||||
{
|
||||
@ -532,6 +113,35 @@ HpcMenuInterface::dir_default()
|
||||
return _pref.dir_user ? IDS_DIR_SEQ(IDS_DIR_USER_DEFINED) : 0;
|
||||
}
|
||||
|
||||
void
|
||||
HpcMenuInterface::_set_default_pref()
|
||||
{
|
||||
_pref._magic = HPCBOOT_MAGIC;
|
||||
_pref.dir = 0;
|
||||
_pref.dir_user = FALSE;
|
||||
_pref.kernel_user = FALSE;
|
||||
_pref.platid_hi = 0;
|
||||
_pref.platid_lo = 0;
|
||||
_pref.rootfs = 0;
|
||||
wsprintf(_pref.rootfs_file, TEXT("miniroot.fs"));
|
||||
_pref.boot_serial = FALSE;
|
||||
_pref.boot_verbose = FALSE;
|
||||
_pref.boot_single_user = FALSE;
|
||||
_pref.boot_ask_for_name = FALSE;
|
||||
_pref.auto_boot = 0;
|
||||
_pref.reverse_video = FALSE;
|
||||
_pref.pause_before_boot = TRUE;
|
||||
_pref.safety_message = TRUE;
|
||||
#ifdef MIPS
|
||||
_pref.serial_speed = 9600; // historical reason.
|
||||
#else
|
||||
_pref.serial_speed = 19200;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// load and save current menu status.
|
||||
//
|
||||
BOOL
|
||||
HpcMenuInterface::load()
|
||||
{
|
||||
@ -685,6 +295,7 @@ HpcMenuInterface::progress()
|
||||
SendMessage(_root->_progress_bar->_window, PBM_STEPIT, 0, 0);
|
||||
}
|
||||
|
||||
// Boot kernel.
|
||||
void
|
||||
HpcMenuInterface::boot()
|
||||
{
|
||||
@ -704,33 +315,5 @@ HpcMenuInterface::boot()
|
||||
}
|
||||
|
||||
if (_boot_hook.func)
|
||||
_boot_hook.func(_boot_hook.arg, _pref);
|
||||
}
|
||||
|
||||
//
|
||||
// Common utility
|
||||
//
|
||||
static BOOL
|
||||
_find_pref_dir(TCHAR *path)
|
||||
{
|
||||
WIN32_FIND_DATA fd;
|
||||
HANDLE find;
|
||||
|
||||
lstrcpy(path, TEXT("\\*.*"));
|
||||
find = FindFirstFile(path, &fd);
|
||||
|
||||
if (find != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
int attr = fd.dwFileAttributes;
|
||||
if ((attr & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||
(attr & FILE_ATTRIBUTE_TEMPORARY)) {
|
||||
wcscpy(path, fd.cFileName);
|
||||
FindClose(find);
|
||||
return TRUE;
|
||||
}
|
||||
} while (FindNextFile(find, &fd));
|
||||
}
|
||||
FindClose(find);
|
||||
|
||||
return FALSE;
|
||||
_boot_hook.func(_boot_hook.arg);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: hpcmenu.h,v 1.4 2001/03/25 17:13:16 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: hpcmenu.h,v 1.5 2001/04/24 19:27:59 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -60,7 +60,7 @@ public:
|
||||
HINSTANCE _instance;
|
||||
HWND _cmdbar;
|
||||
RootWindow *_root;
|
||||
Console *_cons;
|
||||
Console *_cons;
|
||||
int _cx_char, _cy_char; // 5, 14
|
||||
|
||||
private:
|
||||
@ -126,12 +126,12 @@ public:
|
||||
|
||||
RootWindow *_root;
|
||||
MainTabWindow *_main;
|
||||
OptionTabWindow *_option;
|
||||
OptionTabWindow *_option;
|
||||
ConsoleTabWindow *_console;
|
||||
struct HpcMenuPreferences _pref;
|
||||
|
||||
struct boot_hook_args {
|
||||
void(*func)(void *, struct HpcMenuPreferences &);
|
||||
void(*func)(void *);
|
||||
void *arg;
|
||||
} _boot_hook;
|
||||
|
||||
@ -144,30 +144,7 @@ public:
|
||||
private:
|
||||
static HpcMenuInterface *_instance;
|
||||
|
||||
void _set_default_pref(void) {
|
||||
// set default.
|
||||
_pref._magic = HPCBOOT_MAGIC;
|
||||
_pref.dir = 0;
|
||||
_pref.dir_user = FALSE;
|
||||
_pref.kernel_user = FALSE;
|
||||
_pref.platid_hi = 0;
|
||||
_pref.platid_lo = 0;
|
||||
_pref.rootfs = 0;
|
||||
wsprintf(_pref.rootfs_file, TEXT("miniroot.fs"));
|
||||
_pref.boot_serial = FALSE;
|
||||
_pref.boot_verbose = FALSE;
|
||||
_pref.boot_single_user = FALSE;
|
||||
_pref.boot_ask_for_name = FALSE;
|
||||
_pref.auto_boot = 0;
|
||||
_pref.reverse_video = FALSE;
|
||||
_pref.pause_before_boot = TRUE;
|
||||
_pref.safety_message = TRUE;
|
||||
#ifdef MIPS
|
||||
_pref.serial_speed = 9600; // historical reason.
|
||||
#else
|
||||
_pref.serial_speed = 19200;
|
||||
#endif
|
||||
}
|
||||
void _set_default_pref(void);
|
||||
enum _platform_op {
|
||||
_PLATFORM_OP_GET,
|
||||
_PLATFORM_OP_SET,
|
||||
@ -176,16 +153,7 @@ private:
|
||||
void *_platform(int, enum _platform_op);
|
||||
|
||||
protected:
|
||||
HpcMenuInterface(void) {
|
||||
if (!load())
|
||||
_set_default_pref();
|
||||
_pref._version = HPCBOOT_VERSION;
|
||||
_pref._size = sizeof(HpcMenuPreferences);
|
||||
|
||||
_cons_parameter = 0;
|
||||
memset(_cons_hook, 0, sizeof(struct cons_hook_args) * 4);
|
||||
memset(&_boot_hook, 0, sizeof(struct boot_hook_args));
|
||||
}
|
||||
HpcMenuInterface(void);
|
||||
virtual ~HpcMenuInterface(void) { /* NO-OP */ }
|
||||
|
||||
public:
|
||||
@ -233,4 +201,8 @@ public:
|
||||
void platform_set(int n) { _platform(n, _PLATFORM_OP_SET); }
|
||||
};
|
||||
|
||||
/* Global access macro */
|
||||
#define HPC_MENU (HpcMenuInterface::Instance())
|
||||
#define HPC_PREFERENCE (HPC_MENU._pref)
|
||||
|
||||
#endif // _HPCBOOT_MENU_H_
|
||||
|
454
sys/arch/hpc/stand/hpcboot/menu/menu.cpp
Normal file
454
sys/arch/hpc/stand/hpcboot/menu/menu.cpp
Normal file
@ -0,0 +1,454 @@
|
||||
/* -*-C++-*- $NetBSD: menu.cpp,v 1.1 2001/04/24 19:28:00 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <hpcmenu.h>
|
||||
#include <hpcboot.h>
|
||||
#include <res/resource.h>
|
||||
#include <menu/window.h>
|
||||
#include <menu/tabwindow.h>
|
||||
#include <menu/rootwindow.h>
|
||||
#include <machine/bootinfo.h>
|
||||
#include <framebuffer.h>
|
||||
#include <console.h>
|
||||
|
||||
#include <menu/menu.h>
|
||||
|
||||
TabWindow *
|
||||
TabWindowBase::boot(int id)
|
||||
{
|
||||
TabWindow *w = NULL;
|
||||
HpcMenuInterface &menu = HPC_MENU;
|
||||
|
||||
switch(id) {
|
||||
default:
|
||||
break;
|
||||
case IDC_BASE_MAIN:
|
||||
menu._main = new MainTabWindow(*this, IDC_BASE_MAIN);
|
||||
w = menu._main;
|
||||
break;
|
||||
case IDC_BASE_OPTION:
|
||||
menu._option = new OptionTabWindow(*this, IDC_BASE_OPTION);
|
||||
w = menu._option;
|
||||
break;
|
||||
case IDC_BASE_CONSOLE:
|
||||
menu._console = new ConsoleTabWindow(*this, IDC_BASE_CONSOLE);
|
||||
w = menu._console;
|
||||
break;
|
||||
}
|
||||
|
||||
if (w)
|
||||
w->create(0);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
//
|
||||
// Main window
|
||||
//
|
||||
void
|
||||
MainTabWindow::_insert_item(HWND w, TCHAR *name, int id)
|
||||
{
|
||||
int idx = SendDlgItemMessage(w, id, CB_ADDSTRING, 0,
|
||||
reinterpret_cast <LPARAM>(name));
|
||||
if (idx != CB_ERR)
|
||||
SendDlgItemMessage(w, IDC_MAIN_DIR, CB_SETITEMDATA,
|
||||
idx, _item_idx++);
|
||||
}
|
||||
|
||||
void
|
||||
MainTabWindow::init(HWND w)
|
||||
{
|
||||
HpcMenuInterface &menu = HPC_MENU;
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
|
||||
_window = w;
|
||||
// insert myself to tab-control
|
||||
TabWindow::init(w);
|
||||
|
||||
// setup child.
|
||||
TCHAR *entry;
|
||||
int i;
|
||||
// kernel directory path
|
||||
for (i = 0; entry = menu.dir(i); i++)
|
||||
_insert_item(w, entry, IDC_MAIN_DIR);
|
||||
SendDlgItemMessage(w, IDC_MAIN_DIR, CB_SETCURSEL, menu.dir_default(),
|
||||
0);
|
||||
// platform
|
||||
for (i = 0; entry = menu.platform_get(i); i++)
|
||||
_insert_item(w, entry, IDC_MAIN_PLATFORM);
|
||||
SendDlgItemMessage(w, IDC_MAIN_PLATFORM, CB_SETCURSEL,
|
||||
menu.platform_default(), 0);
|
||||
// kernel file name.
|
||||
Edit_SetText(GetDlgItem(w, IDC_MAIN_KERNEL), pref.kernel_user ?
|
||||
pref.kernel_user_file : TEXT("netbsd.gz"));
|
||||
|
||||
// root file system.
|
||||
int fs = pref.rootfs + IDC_MAIN_ROOT_;
|
||||
_set_check(fs, TRUE);
|
||||
|
||||
_edit_md_root = GetDlgItem(w, IDC_MAIN_ROOT_MD_OPS);
|
||||
Edit_SetText(_edit_md_root, pref.rootfs_file);
|
||||
EnableWindow(_edit_md_root, fs == IDC_MAIN_ROOT_MD ? TRUE : FALSE);
|
||||
|
||||
// kernel boot options.
|
||||
_set_check(IDC_MAIN_OPTION_A, pref.boot_ask_for_name);
|
||||
_set_check(IDC_MAIN_OPTION_S, pref.boot_single_user);
|
||||
_set_check(IDC_MAIN_OPTION_V, pref.boot_verbose);
|
||||
_set_check(IDC_MAIN_OPTION_H, pref.boot_serial);
|
||||
|
||||
// serial console speed.
|
||||
TCHAR *speed_tab[] = { L"9600", L"19200", L"115200", 0 };
|
||||
int sel = 0;
|
||||
i = 0;
|
||||
for (TCHAR **speed = speed_tab; *speed; speed++, i++) {
|
||||
_insert_item(w, *speed, IDC_MAIN_OPTION_H_SPEED);
|
||||
if (_wtoi(*speed) == pref.serial_speed)
|
||||
sel = i;
|
||||
}
|
||||
_combobox_serial_speed = GetDlgItem(_window, IDC_MAIN_OPTION_H_SPEED);
|
||||
SendDlgItemMessage(w, IDC_MAIN_OPTION_H_SPEED, CB_SETCURSEL, sel, 0);
|
||||
EnableWindow(_combobox_serial_speed, pref.boot_serial);
|
||||
}
|
||||
|
||||
void
|
||||
MainTabWindow::get()
|
||||
{
|
||||
HpcMenuInterface &menu = HPC_MENU;
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
|
||||
HWND w = GetDlgItem(_window, IDC_MAIN_DIR);
|
||||
ComboBox_GetText(w, pref.dir_user_path, MAX_PATH);
|
||||
pref.dir_user = TRUE;
|
||||
w = GetDlgItem(_window, IDC_MAIN_KERNEL);
|
||||
Edit_GetText(w, pref.kernel_user_file, MAX_PATH);
|
||||
pref.kernel_user = TRUE;
|
||||
|
||||
int i = ComboBox_GetCurSel(GetDlgItem(_window, IDC_MAIN_PLATFORM));
|
||||
menu.platform_set(i);
|
||||
|
||||
if (_is_checked(IDC_MAIN_ROOT_WD))
|
||||
pref.rootfs = 0;
|
||||
else if (_is_checked(IDC_MAIN_ROOT_SD))
|
||||
pref.rootfs = 1;
|
||||
else if (_is_checked(IDC_MAIN_ROOT_MD))
|
||||
pref.rootfs = 2;
|
||||
else if (_is_checked(IDC_MAIN_ROOT_NFS))
|
||||
pref.rootfs = 3;
|
||||
|
||||
pref.boot_ask_for_name = _is_checked(IDC_MAIN_OPTION_A);
|
||||
pref.boot_verbose = _is_checked(IDC_MAIN_OPTION_V);
|
||||
pref.boot_single_user = _is_checked(IDC_MAIN_OPTION_S);
|
||||
pref.boot_serial = _is_checked(IDC_MAIN_OPTION_H);
|
||||
Edit_GetText(_edit_md_root, pref.rootfs_file, MAX_PATH);
|
||||
|
||||
TCHAR tmpbuf[8];
|
||||
ComboBox_GetText(_combobox_serial_speed, tmpbuf, 8);
|
||||
pref.serial_speed = _wtoi(tmpbuf);
|
||||
}
|
||||
|
||||
void
|
||||
MainTabWindow::command(int id, int msg)
|
||||
{
|
||||
switch (id) {
|
||||
case IDC_MAIN_OPTION_H:
|
||||
EnableWindow(_combobox_serial_speed,
|
||||
_is_checked(IDC_MAIN_OPTION_H));
|
||||
break;
|
||||
case IDC_MAIN_ROOT_WD:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_MAIN_ROOT_SD:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_MAIN_ROOT_MD:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_MAIN_ROOT_NFS:
|
||||
EnableWindow(_edit_md_root, _is_checked(IDC_MAIN_ROOT_MD));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Option window
|
||||
//
|
||||
void
|
||||
OptionTabWindow::init(HWND w)
|
||||
{
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
|
||||
_window = w;
|
||||
|
||||
TabWindow::init(_window);
|
||||
_spin_edit = GetDlgItem(_window, IDC_OPT_AUTO_INPUT);
|
||||
_spin = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE |
|
||||
UDS_SETBUDDYINT | UDS_ALIGNRIGHT,
|
||||
80, 0, 50, 50, _window,
|
||||
IDC_OPT_AUTO_UPDOWN,
|
||||
_app._instance, _spin_edit,
|
||||
60, 1, 30);
|
||||
BOOL onoff = pref.auto_boot ? TRUE : FALSE;
|
||||
EnableWindow(_spin_edit, onoff);
|
||||
EnableWindow(_spin, onoff);
|
||||
|
||||
SET_CHECK(AUTO, pref.auto_boot);
|
||||
if (pref.auto_boot) {
|
||||
TCHAR tmp[32];
|
||||
wsprintf(tmp, TEXT("%d"), pref.auto_boot);
|
||||
Edit_SetText(_spin_edit, tmp);
|
||||
}
|
||||
SET_CHECK(VIDEO, pref.reverse_video);
|
||||
SET_CHECK(PAUSE, pref.pause_before_boot);
|
||||
SET_CHECK(DEBUG, pref.load_debug_info);
|
||||
SET_CHECK(SAFETY, pref.safety_message);
|
||||
}
|
||||
|
||||
void
|
||||
OptionTabWindow::command(int id, int msg)
|
||||
{
|
||||
switch (id) {
|
||||
case IDC_OPT_AUTO:
|
||||
if (IS_CHECKED(AUTO)) {
|
||||
EnableWindow(_spin_edit, TRUE);
|
||||
EnableWindow(_spin, TRUE);
|
||||
} else {
|
||||
EnableWindow(_spin_edit, FALSE);
|
||||
EnableWindow(_spin, FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OptionTabWindow::get()
|
||||
{
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
if (IS_CHECKED(AUTO)) {
|
||||
TCHAR tmp[32];
|
||||
Edit_GetText(_spin_edit, tmp, 32);
|
||||
pref.auto_boot = _wtoi(tmp);
|
||||
} else
|
||||
pref.auto_boot = 0;
|
||||
pref.reverse_video = IS_CHECKED(VIDEO);
|
||||
pref.pause_before_boot = IS_CHECKED(PAUSE);
|
||||
pref.load_debug_info = IS_CHECKED(DEBUG);
|
||||
pref.safety_message = IS_CHECKED(SAFETY);
|
||||
}
|
||||
#undef IS_CHECKED
|
||||
#undef SET_CHECK
|
||||
|
||||
|
||||
//
|
||||
// Console window
|
||||
//
|
||||
void
|
||||
ConsoleTabWindow::print(TCHAR *buf, BOOL force_display)
|
||||
{
|
||||
int cr;
|
||||
TCHAR *p;
|
||||
|
||||
if (force_display)
|
||||
goto display;
|
||||
|
||||
if (_filesave) {
|
||||
if (_logfile == INVALID_HANDLE_VALUE && !_open_log_file()) {
|
||||
_filesave = FALSE;
|
||||
_set_check(IDC_CONS_FILESAVE, _filesave);
|
||||
EnableWindow(_filename_edit, _filesave);
|
||||
goto display;
|
||||
}
|
||||
DWORD cnt;
|
||||
char c;
|
||||
for (int i = 0; *buf != TEXT('\0'); buf++) {
|
||||
c = *buf & 0x7f;
|
||||
WriteFile(_logfile, &c, 1, &cnt, 0);
|
||||
}
|
||||
FlushFileBuffers(_logfile);
|
||||
return;
|
||||
}
|
||||
|
||||
display:
|
||||
// count # of '\n'
|
||||
for (cr = 0, p = buf; p = wcschr(p, TEXT('\n')); cr++, p++)
|
||||
;
|
||||
// total length of new buffer('\n' -> "\r\n" + '\0')
|
||||
int ln = wcslen(buf) + cr + 1;
|
||||
|
||||
// get old buffer.
|
||||
int lo = Edit_GetTextLength(_edit);
|
||||
size_t sz =(lo + ln) * sizeof(TCHAR);
|
||||
|
||||
p = reinterpret_cast <TCHAR *>(malloc(sz));
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
memset(p, 0, sz);
|
||||
Edit_GetText(_edit, p, lo + 1);
|
||||
|
||||
// put new buffer to end of old buffer.
|
||||
TCHAR *d = p + lo;
|
||||
while (*buf != TEXT('\0')) {
|
||||
TCHAR c = *buf++;
|
||||
if (c == TEXT('\n'))
|
||||
*d++ = TEXT('\r');
|
||||
*d++ = c;
|
||||
}
|
||||
*d = TEXT('\0');
|
||||
|
||||
// display total buffer.
|
||||
Edit_SetText(_edit, p);
|
||||
// Edit_Scroll(_edit, Edit_GetLineCount(_edit), 0);
|
||||
UpdateWindow(_edit);
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
void
|
||||
ConsoleTabWindow::init(HWND w)
|
||||
{
|
||||
// at this time _window is NULL.
|
||||
// use argument of window procedure.
|
||||
TabWindow::init(w);
|
||||
_edit = GetDlgItem(w, IDC_CONS_EDIT);
|
||||
MoveWindow(_edit, 5, 60, _rect.right - _rect.left - 10,
|
||||
_rect.bottom - _rect.top - 60, TRUE);
|
||||
Edit_FmtLines(_edit, TRUE);
|
||||
|
||||
// log file.
|
||||
_filename_edit = GetDlgItem(w, IDC_CONS_FILENAME);
|
||||
_filesave = FALSE;
|
||||
Edit_SetText(_filename_edit, L"bootlog.txt");
|
||||
EnableWindow(_filename_edit, _filesave);
|
||||
}
|
||||
|
||||
void
|
||||
ConsoleTabWindow::command(int id, int msg)
|
||||
{
|
||||
HpcMenuInterface &menu = HPC_MENU;
|
||||
struct HpcMenuInterface::cons_hook_args *hook = 0;
|
||||
int bit;
|
||||
|
||||
switch(id) {
|
||||
case IDC_CONS_FILESAVE:
|
||||
_filesave = _is_checked(IDC_CONS_FILESAVE);
|
||||
EnableWindow(_filename_edit, _filesave);
|
||||
break;
|
||||
case IDC_CONS_CHK0:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK1:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK2:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK3:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK4:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK5:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK6:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_CHK7:
|
||||
bit = 1 << (id - IDC_CONS_CHK_);
|
||||
if (SendDlgItemMessage(_window, id, BM_GETCHECK, 0, 0))
|
||||
menu._cons_parameter |= bit;
|
||||
else
|
||||
menu._cons_parameter &= ~bit;
|
||||
break;
|
||||
case IDC_CONS_BTN0:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_BTN1:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_BTN2:
|
||||
/* FALLTHROUGH */
|
||||
case IDC_CONS_BTN3:
|
||||
hook = &menu._cons_hook[id - IDC_CONS_BTN_];
|
||||
if (hook->func)
|
||||
hook->func(hook->arg, menu._cons_parameter);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
ConsoleTabWindow::_open_log_file()
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
TCHAR filename[MAX_PATH];
|
||||
TCHAR filepath[MAX_PATH];
|
||||
|
||||
if (!_find_pref_dir(path)) {
|
||||
print(L"couldn't find temporary directory.\n", TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Edit_GetText(_filename_edit, filename, MAX_PATH);
|
||||
wsprintf(filepath, TEXT("\\%s\\%s"), path, filename);
|
||||
_logfile = CreateFile(filepath, GENERIC_WRITE, 0, 0,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (_logfile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
|
||||
wsprintf(path, TEXT("log file is %s\n"), filepath);
|
||||
print(path, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Common utility
|
||||
//
|
||||
BOOL
|
||||
_find_pref_dir(TCHAR *path)
|
||||
{
|
||||
WIN32_FIND_DATA fd;
|
||||
HANDLE find;
|
||||
|
||||
lstrcpy(path, TEXT("\\*.*"));
|
||||
find = FindFirstFile(path, &fd);
|
||||
|
||||
if (find != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
int attr = fd.dwFileAttributes;
|
||||
if ((attr & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||
(attr & FILE_ATTRIBUTE_TEMPORARY)) {
|
||||
wcscpy(path, fd.cFileName);
|
||||
FindClose(find);
|
||||
return TRUE;
|
||||
}
|
||||
} while (FindNextFile(find, &fd));
|
||||
}
|
||||
FindClose(find);
|
||||
|
||||
return FALSE;
|
||||
}
|
106
sys/arch/hpc/stand/hpcboot/menu/menu.h
Normal file
106
sys/arch/hpc/stand/hpcboot/menu/menu.h
Normal file
@ -0,0 +1,106 @@
|
||||
/* -*-C++-*- $NetBSD: menu.h,v 1.1 2001/04/24 19:28:00 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
class MainTabWindow : public TabWindow
|
||||
{
|
||||
private:
|
||||
HWND _edit_md_root;
|
||||
HWND _combobox_serial_speed;
|
||||
|
||||
int _item_idx;
|
||||
void _insert_item(HWND w, TCHAR *name, int id);
|
||||
public:
|
||||
explicit MainTabWindow(TabWindowBase &base, int id)
|
||||
: TabWindow(base, id, TEXT("WMain")) {
|
||||
_item_idx = 0;
|
||||
}
|
||||
virtual ~MainTabWindow(void) { /* NO-OP */ }
|
||||
virtual void init(HWND w);
|
||||
virtual void command(int id, int msg);
|
||||
void get(void);
|
||||
};
|
||||
|
||||
class OptionTabWindow : public TabWindow
|
||||
{
|
||||
public:
|
||||
HWND _spin_edit;
|
||||
HWND _spin;
|
||||
#define IS_CHECKED(x) _is_checked(IDC_OPT_##x)
|
||||
#define SET_CHECK(x, b) _set_check(IDC_OPT_##x,(b))
|
||||
|
||||
public:
|
||||
explicit OptionTabWindow(TabWindowBase &base, int id)
|
||||
: TabWindow(base, id, TEXT("WOption")) {
|
||||
_spin_edit = NULL;
|
||||
_spin = NULL;
|
||||
}
|
||||
virtual ~OptionTabWindow(void) { /* NO-OP */ }
|
||||
virtual void init(HWND w);
|
||||
virtual void command(int id, int msg);
|
||||
void get(void);
|
||||
};
|
||||
|
||||
class ConsoleTabWindow : public TabWindow
|
||||
{
|
||||
private:
|
||||
HWND _filename_edit;
|
||||
BOOL _filesave;
|
||||
HANDLE _logfile;
|
||||
BOOL _open_log_file(void);
|
||||
public:
|
||||
HWND _edit;
|
||||
|
||||
public:
|
||||
explicit ConsoleTabWindow(TabWindowBase &base, int id)
|
||||
: TabWindow(base, id, TEXT("WConsole")) {
|
||||
_edit = NULL;
|
||||
_logfile = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
virtual ~ConsoleTabWindow(void) {
|
||||
if (_logfile != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(_logfile);
|
||||
}
|
||||
virtual void init(HWND);
|
||||
virtual void command(int, int);
|
||||
|
||||
void print(TCHAR *buf, BOOL = FALSE);
|
||||
};
|
||||
|
||||
__BEGIN_DECLS
|
||||
BOOL _find_pref_dir(TCHAR *);
|
||||
__END_DECLS
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: mips_arch.h,v 1.1 2001/02/09 18:35:05 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: mips_arch.h,v 1.2 2001/04/24 19:28:00 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -95,7 +95,7 @@ __declspec(naked) void \
|
||||
x##::boot_func(struct BootArgs *bi, struct PageTag *p) \
|
||||
{ \
|
||||
/* disable interrupt */ \
|
||||
DI(); \
|
||||
DI(); \
|
||||
/* set kernel image */ \
|
||||
__asm(".set noreorder;" \
|
||||
"move t6, a1;" /* p */ \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: mips_boot.cpp,v 1.1 2001/02/09 18:35:06 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: mips_boot.cpp,v 1.2 2001/04/24 19:28:00 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -46,22 +46,27 @@
|
||||
#include <mips/mips_boot.h>
|
||||
#include <mips/mips_vr41.h>
|
||||
#include <mips/mips_tx39.h>
|
||||
#include <mips/mips_console.h>
|
||||
|
||||
MIPSBoot::MIPSBoot(void)
|
||||
MIPSBoot::MIPSBoot()
|
||||
{
|
||||
}
|
||||
|
||||
MIPSBoot::~MIPSBoot(void)
|
||||
MIPSBoot::~MIPSBoot()
|
||||
{
|
||||
if (_mem)
|
||||
delete _mem;
|
||||
if (_arch)
|
||||
delete _arch;
|
||||
|
||||
MIPSConsole::Destroy();
|
||||
}
|
||||
|
||||
BOOL
|
||||
MIPSBoot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
MIPSBoot::setup()
|
||||
{
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
|
||||
platid_t platid;
|
||||
platid.dw.dw0 = pref.platid_hi;
|
||||
platid.dw.dw1 = pref.platid_lo;
|
||||
@ -77,11 +82,11 @@ MIPSBoot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return Boot::setup(pref);
|
||||
return super::setup();
|
||||
}
|
||||
|
||||
BOOL
|
||||
MIPSBoot::create(void)
|
||||
MIPSBoot::create()
|
||||
{
|
||||
size_t pagesz;
|
||||
int shift;
|
||||
@ -90,8 +95,11 @@ MIPSBoot::create(void)
|
||||
|
||||
// Console
|
||||
if (args.console == CONSOLE_SERIAL) {
|
||||
_cons = Console::Instance();
|
||||
DPRINTF((TEXT("use LCD console instead.\n")));
|
||||
_cons = MIPSConsole::Instance();
|
||||
if (!_cons->init()) {
|
||||
_cons = Console::Instance();
|
||||
DPRINTF((TEXT("use LCD console instead.\n")));
|
||||
}
|
||||
}
|
||||
|
||||
// Architercure dependent ops.
|
||||
@ -143,5 +151,5 @@ MIPSBoot::create(void)
|
||||
|
||||
|
||||
// File Manager, Loader
|
||||
return Boot::create();
|
||||
return super::create();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: mips_boot.h,v 1.1 2001/02/09 18:35:06 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: mips_boot.h,v 1.2 2001/04/24 19:28:00 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -42,10 +42,13 @@
|
||||
#include <boot.h>
|
||||
|
||||
class MIPSBoot : public Boot {
|
||||
private:
|
||||
typedef Boot super;
|
||||
|
||||
public:
|
||||
MIPSBoot(void);
|
||||
~MIPSBoot(void);
|
||||
virtual BOOL setup(struct HpcMenuInterface::HpcMenuPreferences &);
|
||||
virtual BOOL setup(void);
|
||||
virtual BOOL create(void);
|
||||
};
|
||||
|
||||
|
61
sys/arch/hpc/stand/hpcboot/mips/mips_console.cpp
Normal file
61
sys/arch/hpc/stand/hpcboot/mips/mips_console.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
/* -*-C++-*- $NetBSD: mips_console.cpp,v 1.1 2001/04/24 19:28:01 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <hpcmenu.h>
|
||||
#include <mips/mips_console.h>
|
||||
|
||||
MIPSConsole *MIPSConsole::_instance = 0;
|
||||
|
||||
MIPSConsole::MIPSConsole()
|
||||
{
|
||||
/* NO-OP */
|
||||
}
|
||||
|
||||
MIPSConsole::~MIPSConsole()
|
||||
{
|
||||
/* NO-OP */
|
||||
}
|
||||
|
||||
MIPSConsole *
|
||||
MIPSConsole::Instance()
|
||||
{
|
||||
if (!_instance)
|
||||
_instance = new MIPSConsole();
|
||||
|
||||
return _instance;
|
||||
}
|
54
sys/arch/hpc/stand/hpcboot/mips/mips_console.h
Normal file
54
sys/arch/hpc/stand/hpcboot/mips/mips_console.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* -*-C++-*- $NetBSD: mips_console.h,v 1.1 2001/04/24 19:28:01 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _HPCBOOT_MIPS_CONSOLE_H_
|
||||
#define _HPCBOOT_MIPS_CONSOLE_H_
|
||||
|
||||
#include <hpcboot.h>
|
||||
#include <console.h>
|
||||
|
||||
class MIPSConsole : public SerialConsole {
|
||||
private:
|
||||
static MIPSConsole *_instance;
|
||||
MIPSConsole(void);
|
||||
|
||||
public:
|
||||
virtual ~MIPSConsole();
|
||||
static MIPSConsole *Instance(void);
|
||||
};
|
||||
#endif //_HPCBOOT_MIPS_CONSOLE_H_
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sh_arch.cpp,v 1.5 2001/03/25 17:13:17 uch Exp $ */
|
||||
/* $NetBSD: sh_arch.cpp,v 1.6 2001/04/24 19:28:01 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -218,7 +218,7 @@ SHArchitecture::systemInfo()
|
||||
pfc_dump();
|
||||
|
||||
// SCIF
|
||||
scif_dump(menu._pref.serial_speed);
|
||||
scif_dump(HPC_PREFERENCE.serial_speed);
|
||||
|
||||
// HD64461
|
||||
platid_t platform;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sh_boot.cpp,v 1.1 2001/02/09 18:35:17 uch Exp $ */
|
||||
/* $NetBSD: sh_boot.cpp,v 1.2 2001/04/24 19:28:01 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -46,11 +46,11 @@
|
||||
#include <sh3/sh_console.h>
|
||||
#include <sh3/sh_boot.h>
|
||||
|
||||
SHBoot::SHBoot(void)
|
||||
SHBoot::SHBoot()
|
||||
{
|
||||
}
|
||||
|
||||
SHBoot::~SHBoot(void)
|
||||
SHBoot::~SHBoot()
|
||||
{
|
||||
if (_mem)
|
||||
delete _mem;
|
||||
@ -61,8 +61,10 @@ SHBoot::~SHBoot(void)
|
||||
}
|
||||
|
||||
BOOL
|
||||
SHBoot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
SHBoot::setup()
|
||||
{
|
||||
struct HpcMenuInterface::HpcMenuPreferences &pref = HPC_PREFERENCE;
|
||||
|
||||
platid_t platid;
|
||||
platid.dw.dw0 = pref.platid_hi;
|
||||
platid.dw.dw1 = pref.platid_lo;
|
||||
@ -74,11 +76,11 @@ SHBoot::setup(struct HpcMenuInterface::HpcMenuPreferences &pref)
|
||||
} else
|
||||
return FALSE;
|
||||
|
||||
return Boot::setup(pref);
|
||||
return super::setup();
|
||||
}
|
||||
|
||||
BOOL
|
||||
SHBoot::create(void)
|
||||
SHBoot::create()
|
||||
{
|
||||
BOOL(*lock_pages)(LPVOID, DWORD, PDWORD, int);
|
||||
BOOL(*unlock_pages)(LPVOID, DWORD);
|
||||
@ -133,5 +135,5 @@ SHBoot::create(void)
|
||||
_mem->setDebug() = args.memorymanagerDebug;
|
||||
|
||||
// File Manager, Loader
|
||||
return Boot::create();
|
||||
return super::create();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: sh_boot.h,v 1.1 2001/02/09 18:35:18 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: sh_boot.h,v 1.2 2001/04/24 19:28:01 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -42,10 +42,13 @@
|
||||
#include <boot.h>
|
||||
|
||||
class SHBoot : public Boot {
|
||||
private:
|
||||
typedef Boot super;
|
||||
|
||||
public:
|
||||
SHBoot(void);
|
||||
~SHBoot(void);
|
||||
virtual BOOL setup(struct HpcMenuInterface::HpcMenuPreferences &);
|
||||
virtual BOOL setup(void);
|
||||
virtual BOOL create(void);
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sh_console.cpp,v 1.4 2001/03/22 18:27:51 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: sh_console.cpp,v 1.5 2001/04/24 19:28:01 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -75,14 +75,16 @@ SHConsole::Instance()
|
||||
BOOL
|
||||
SHConsole::init()
|
||||
{
|
||||
HpcMenuInterface &menu = HpcMenuInterface::Instance();
|
||||
struct console_info *tab = _console_info;
|
||||
platid_mask_t target, entry;
|
||||
|
||||
if (!super::init())
|
||||
return FALSE;
|
||||
|
||||
_kmode = SetKMode(1);
|
||||
|
||||
target.dw.dw0 = menu._pref.platid_hi;
|
||||
target.dw.dw1 = menu._pref.platid_lo;
|
||||
target.dw.dw0 = HPC_PREFERENCE.platid_hi;
|
||||
target.dw.dw1 = HPC_PREFERENCE.platid_lo;
|
||||
|
||||
// search apriori setting if any.
|
||||
for (; tab->cpu; tab++) {
|
||||
@ -95,24 +97,19 @@ SHConsole::init()
|
||||
}
|
||||
}
|
||||
|
||||
// always open COM1 to supply clock and power for the
|
||||
// sake of kernel serial driver
|
||||
return openCOM1();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
SHConsole::print(const TCHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
wvsprintf(_bufw, fmt, ap);
|
||||
va_end(ap);
|
||||
SETUP_WIDECHAR_BUFFER();
|
||||
|
||||
if (!setupBuffer())
|
||||
if (!setupMultibyteBuffer())
|
||||
return;
|
||||
|
||||
if (_print == 0)
|
||||
SerialConsole::genericPrint(_bufm);
|
||||
super::genericPrint(_bufm);
|
||||
else
|
||||
_print(_bufm);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-C++-*- $NetBSD: sh_console.h,v 1.4 2001/03/22 18:27:51 uch Exp $ */
|
||||
/* -*-C++-*- $NetBSD: sh_console.h,v 1.5 2001/04/24 19:28:01 uch Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -45,6 +45,9 @@
|
||||
#include <sh3/sh3.h>
|
||||
|
||||
class SHConsole : public SerialConsole {
|
||||
private:
|
||||
typedef SerialConsole super;
|
||||
|
||||
public:
|
||||
typedef void (*print_func_t)(const char *);
|
||||
struct console_info {
|
||||
@ -61,7 +64,6 @@ private:
|
||||
static SHConsole *_instance;
|
||||
int _kmode;
|
||||
print_func_t _print;
|
||||
int16_t _boot_console;
|
||||
|
||||
SHConsole(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user