Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hpc/stand/hpcboot code clean up.



details:   https://anonhg.NetBSD.org/src/rev/777309c957fa
branches:  trunk
changeset: 509018:777309c957fa
user:      uch <uch%NetBSD.org@localhost>
date:      Tue Apr 24 19:27:58 2001 +0000

description:
code clean up.

diffstat:

 sys/arch/hpc/stand/hpcboot/arm/arm_boot.cpp      |   16 +-
 sys/arch/hpc/stand/hpcboot/arm/arm_boot.h        |    7 +-
 sys/arch/hpc/stand/hpcboot/arm/arm_console.cpp   |   15 +-
 sys/arch/hpc/stand/hpcboot/arm/arm_console.h     |    4 +-
 sys/arch/hpc/stand/hpcboot/boot.cpp              |   18 +-
 sys/arch/hpc/stand/hpcboot/boot.h                |   17 +-
 sys/arch/hpc/stand/hpcboot/console.cpp           |   40 +-
 sys/arch/hpc/stand/hpcboot/console.h             |   21 +-
 sys/arch/hpc/stand/hpcboot/framebuffer.cpp       |    5 +-
 sys/arch/hpc/stand/hpcboot/hpcboot.config        |    4 +-
 sys/arch/hpc/stand/hpcboot/hpcboot.cpp           |   28 +-
 sys/arch/hpc/stand/hpcboot/hpcmenu.cpp           |  507 ++--------------------
 sys/arch/hpc/stand/hpcboot/hpcmenu.h             |   48 +-
 sys/arch/hpc/stand/hpcboot/menu/menu.cpp         |  454 ++++++++++++++++++++
 sys/arch/hpc/stand/hpcboot/menu/menu.h           |  106 ++++
 sys/arch/hpc/stand/hpcboot/mips/mips_arch.h      |    4 +-
 sys/arch/hpc/stand/hpcboot/mips/mips_boot.cpp    |   26 +-
 sys/arch/hpc/stand/hpcboot/mips/mips_boot.h      |    7 +-
 sys/arch/hpc/stand/hpcboot/mips/mips_console.cpp |   61 ++
 sys/arch/hpc/stand/hpcboot/mips/mips_console.h   |   54 ++
 sys/arch/hpc/stand/hpcboot/sh3/sh_arch.cpp       |    4 +-
 sys/arch/hpc/stand/hpcboot/sh3/sh_boot.cpp       |   16 +-
 sys/arch/hpc/stand/hpcboot/sh3/sh_boot.h         |    7 +-
 sys/arch/hpc/stand/hpcboot/sh3/sh_console.cpp    |   23 +-
 sys/arch/hpc/stand/hpcboot/sh3/sh_console.h      |    6 +-
 25 files changed, 895 insertions(+), 603 deletions(-)

diffs (truncated from 2119 to 300 lines):

diff -r 8c513ecdce19 -r 777309c957fa sys/arch/hpc/stand/hpcboot/arm/arm_boot.cpp
--- a/sys/arch/hpc/stand/hpcboot/arm/arm_boot.cpp       Tue Apr 24 19:02:06 2001 +0000
+++ b/sys/arch/hpc/stand/hpcboot/arm/arm_boot.cpp       Tue Apr 24 19:27:58 2001 +0000
@@ -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 @@
 }
 
 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 @@
 
        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 @@
        }
   
        // File Manager, Loader
-       return Boot::create();
+       return super::create();
 }
diff -r 8c513ecdce19 -r 777309c957fa sys/arch/hpc/stand/hpcboot/arm/arm_boot.h
--- a/sys/arch/hpc/stand/hpcboot/arm/arm_boot.h Tue Apr 24 19:02:06 2001 +0000
+++ b/sys/arch/hpc/stand/hpcboot/arm/arm_boot.h Tue Apr 24 19:27:58 2001 +0000
@@ -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);
 };
 
diff -r 8c513ecdce19 -r 777309c957fa sys/arch/hpc/stand/hpcboot/arm/arm_console.cpp
--- a/sys/arch/hpc/stand/hpcboot/arm/arm_console.cpp    Tue Apr 24 19:02:06 2001 +0000
+++ b/sys/arch/hpc/stand/hpcboot/arm/arm_console.cpp    Tue Apr 24 19:27:58 2001 +0000
@@ -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 @@
                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++) {
diff -r 8c513ecdce19 -r 777309c957fa sys/arch/hpc/stand/hpcboot/arm/arm_console.h
--- a/sys/arch/hpc/stand/hpcboot/arm/arm_console.h      Tue Apr 24 19:02:06 2001 +0000
+++ b/sys/arch/hpc/stand/hpcboot/arm/arm_console.h      Tue Apr 24 19:27:58 2001 +0000
@@ -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;
diff -r 8c513ecdce19 -r 777309c957fa sys/arch/hpc/stand/hpcboot/boot.cpp
--- a/sys/arch/hpc/stand/hpcboot/boot.cpp       Tue Apr 24 19:02:06 2001 +0000
+++ b/sys/arch/hpc/stand/hpcboot/boot.cpp       Tue Apr 24 19:27:58 2001 +0000
@@ -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 @@
        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 @@
 }
 
 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::Boot()
 {
-       _arch           = 0;
-       _mem            = 0;
-       _file           = 0;
+       _arch   = 0;
+       _mem    = 0;
+       _file   = 0;
        _loader = 0;
        // set default console
        _cons = Console::Instance();
diff -r 8c513ecdce19 -r 777309c957fa sys/arch/hpc/stand/hpcboot/boot.h
--- a/sys/arch/hpc/stand/hpcboot/boot.h Tue Apr 24 19:02:06 2001 +0000
+++ b/sys/arch/hpc/stand/hpcboot/boot.h Tue Apr 24 19:27:58 2001 +0000
@@ -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 @@
        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);
 };
diff -r 8c513ecdce19 -r 777309c957fa sys/arch/hpc/stand/hpcboot/console.cpp
--- a/sys/arch/hpc/stand/hpcboot/console.cpp    Tue Apr 24 19:02:06 2001 +0000
+++ b/sys/arch/hpc/stand/hpcboot/console.cpp    Tue Apr 24 19:27:58 2001 +0000
@@ -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 @@
 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 @@
        return TRUE;
 }
 
+void
+SerialConsole::print(const TCHAR *fmt, ...)
+{
+       SETUP_WIDECHAR_BUFFER();
+
+       if (!setupMultibyteBuffer())
+               return;
+
+       genericPrint(_bufm);
+}
+
 BOOL
 SerialConsole::openCOM1()
 {
-       HpcMenuInterface &menu = HpcMenuInterface::Instance();



Home | Main Index | Thread Index | Old Index