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 fix memory size estimation. add e...



details:   https://anonhg.NetBSD.org/src/rev/474f4a338e6c
branches:  trunk
changeset: 522108:474f4a338e6c
user:      uch <uch%NetBSD.org@localhost>
date:      Mon Feb 11 17:05:45 2002 +0000

description:
fix memory size estimation. add error check code.

diffstat:

 sys/arch/hpc/stand/hpcboot/hpcboot.cpp   |  63 +++++++++++++++++++++++++++++--
 sys/arch/hpc/stand/hpcboot/load.cpp      |  16 +++++--
 sys/arch/hpc/stand/hpcboot/load.h        |   6 ++-
 sys/arch/hpc/stand/hpcboot/load_coff.cpp |   7 ++-
 sys/arch/hpc/stand/hpcboot/memory.h      |   4 +-
 5 files changed, 79 insertions(+), 17 deletions(-)

diffs (245 lines):

diff -r 03ac848ac811 -r 474f4a338e6c sys/arch/hpc/stand/hpcboot/hpcboot.cpp
--- a/sys/arch/hpc/stand/hpcboot/hpcboot.cpp    Mon Feb 11 17:01:09 2002 +0000
+++ b/sys/arch/hpc/stand/hpcboot/hpcboot.cpp    Mon Feb 11 17:05:45 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpcboot.cpp,v 1.5 2002/02/04 17:32:02 uch Exp $        */
+/*     $NetBSD: hpcboot.cpp,v 1.6 2002/02/11 17:05:45 uch Exp $        */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -136,6 +136,7 @@
                        goto failed_exit;
                }
                sz = f._file->size();
+               sz = f._mem->roundPage(sz);
                f._file->close();
        }
 
@@ -156,7 +157,7 @@
        }
 
        menu.progress();
-       sz += f._loader->memorySize();
+       sz += f._mem->roundPage(f._loader->memorySize());
 
        // allocate required memory.
        if (!f._arch->allocateMemory(sz)) {
@@ -173,8 +174,7 @@
 
        menu.progress();
        if (!f._loader->load()) {
-               error_message =
-                   TEXT("couldn't load kernel image to memory.\n");
+               error_message = TEXT("couldn't load kernel image to memory.\n");
                goto failed;
        }
        menu.progress();
@@ -183,7 +183,11 @@
        // load file system image to memory
        if (f.args.loadmfs) {
                f._file->open(f.args.mfsName);
-               f._loader->loadExtData();
+               if (!f._loader->loadExtData()) {
+                       error_message =
+                           TEXT("couldn't load filesystem image to memory.\n");
+                       goto failed;
+               }
                f._file->close();
        }
        f._loader->loadEnd();
@@ -255,3 +259,52 @@
 
        return RegisterClass(&wc);
 }
+
+
+//
+// Debug support.
+//
+void
+_bitdisp(u_int32_t a, int s, int e, int m, int c)
+{
+       u_int32_t j, j1;
+       int i, n;
+
+       DPRINTF_SETUP();
+
+       n = 31; // 32bit only.
+       j1 = 1 << n;
+       e = e ? e : n;
+       for (j = j1, i = n; j > 0; j >>=1, i--) {
+               if (i > e || i < s) {
+                       DPRINTF((TEXT("%c"), a & j ? '+' : '-'));
+               } else {
+                       DPRINTF((TEXT("%c"), a & j ? '|' : '.'));
+               }
+       }
+       if (m) {
+               DPRINTF((TEXT("[%s]"),(char*)m));
+       }
+
+       DPRINTF((TEXT(" [0x%08x]"), a));
+
+       if (c) {
+               for (j = j1, i = n; j > 0; j >>=1, i--) {
+                       if (!(i > e || i < s) &&(a & j)) {
+                               DPRINTF((TEXT(" %d"), i));
+                       }
+               }
+       }
+
+       DPRINTF((TEXT(" %d\n"), a));
+}
+
+void
+_dbg_bit_print(u_int32_t reg, u_int32_t mask, const char *name)
+{
+       static const char onoff[3] = "_x";
+
+       DPRINTF_SETUP();
+
+       DPRINTF((TEXT("%S[%c] "), name, onoff[reg & mask ? 1 : 0]));
+}
diff -r 03ac848ac811 -r 474f4a338e6c sys/arch/hpc/stand/hpcboot/load.cpp
--- a/sys/arch/hpc/stand/hpcboot/load.cpp       Mon Feb 11 17:01:09 2002 +0000
+++ b/sys/arch/hpc/stand/hpcboot/load.cpp       Mon Feb 11 17:05:45 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: load.cpp,v 1.4 2001/05/08 18:51:22 uch Exp $   */
+/*     $NetBSD: load.cpp,v 1.5 2002/02/11 17:05:45 uch Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
        return LOADER_UNKNOWN;
 }
 
-void
+BOOL
 Loader::loadExtData(void)
 {
        size_t sz;
@@ -86,6 +86,8 @@
 
        DPRINTF((TEXT("[file system image]")));
        _load_segment(kv, sz, 0, sz);
+
+       return _load_success();
 }
 
 void
@@ -132,11 +134,13 @@
        vaddr_t v;
        paddr_t p;
 
+       _error = FALSE;
        _nload_link = _n0clr_link = 0;
        _tpsz = _mem->getTaggedPageSize();
 
        // start of chain.
-       _mem->getTaggedPage(v, p, &_pvec_clr, _pvec_clr_paddr);
+       if (!_mem->getTaggedPage(v, p, &_pvec_clr, _pvec_clr_paddr))
+               _error = TRUE;
 #ifdef PAGE_LINK_DUMP
        _page_tag_start =(u_int32_t)_pvec_clr;
 #else
@@ -217,7 +221,8 @@
        }
 
        _opvec_prev = _pvec_prev;
-       _mem->getTaggedPage(v, p, &pvec, pvec_paddr);      
+       if (!_mem->getTaggedPage(v, p, &pvec, pvec_paddr))
+               _error = TRUE;
        memcpy((void *)v, data, memsz);
        _pvec_prev->src = ptokv(p);
        _pvec_prev->dst = kv;
@@ -240,7 +245,8 @@
        paddr_t p, pvec_paddr;
        vaddr_t v;
 
-       _mem->getTaggedPage(v, p, &pvec, pvec_paddr);      
+       if (!_mem->getTaggedPage(v, p, &pvec, pvec_paddr))
+               _error = TRUE;
        _file->read((void *)v, sz, ofs);
        prev->src = ptokv(p);
        prev->dst = kv;
diff -r 03ac848ac811 -r 474f4a338e6c sys/arch/hpc/stand/hpcboot/load.h
--- a/sys/arch/hpc/stand/hpcboot/load.h Mon Feb 11 17:01:09 2002 +0000
+++ b/sys/arch/hpc/stand/hpcboot/load.h Mon Feb 11 17:05:45 2002 +0000
@@ -1,4 +1,4 @@
-/* -*-C++-*-   $NetBSD: load.h,v 1.2 2001/03/21 14:06:25 toshii Exp $  */
+/* -*-C++-*-   $NetBSD: load.h,v 1.3 2002/02/11 17:05:45 uch Exp $     */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -54,6 +54,7 @@
        int _nload_link, _n0clr_link;
        size_t _tpsz;
        struct PageTag *_load_page(vaddr_t, off_t, size_t, struct PageTag *);
+       BOOL _error;
 
 protected:
        BOOL            _debug;
@@ -70,6 +71,7 @@
        void _load_segment(vaddr_t, vsize_t, off_t, size_t);
        void _load_memory(vaddr_t, vsize_t, void *);
        void _load_segment_end(void);
+       BOOL _load_success(void) const { return !_error; };
 
 public:
        virtual ~Loader(void) { /* NO-OP */ }
@@ -82,7 +84,7 @@
        virtual kaddr_t jumpAddr(void) = 0;
 
        paddr_t tagStart(void);
-       void loadExtData(void);
+       BOOL loadExtData(void);
        void loadEnd(void);
 
        void tagDump(int);      // for debug
diff -r 03ac848ac811 -r 474f4a338e6c sys/arch/hpc/stand/hpcboot/load_coff.cpp
--- a/sys/arch/hpc/stand/hpcboot/load_coff.cpp  Mon Feb 11 17:01:09 2002 +0000
+++ b/sys/arch/hpc/stand/hpcboot/load_coff.cpp  Mon Feb 11 17:05:45 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: load_coff.cpp,v 1.2 2001/05/08 18:51:23 uch Exp $      */
+/*     $NetBSD: load_coff.cpp,v 1.3 2002/02/11 17:05:45 uch Exp $      */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -79,7 +79,9 @@
 kaddr_t
 CoffLoader::jumpAddr()
 {
+
        DPRINTF((TEXT("kernel entry address: 0x%08x\n"), _ah->a_entry));
+
        return _ah->a_entry;
 }
 
@@ -115,8 +117,7 @@
        _load_segment(kv, memsz, fileofs, filesz);
 
        /* tag chain still opening */
-
-       return TRUE;
+       return _load_success();
 }
 
 BOOL
diff -r 03ac848ac811 -r 474f4a338e6c sys/arch/hpc/stand/hpcboot/memory.h
--- a/sys/arch/hpc/stand/hpcboot/memory.h       Mon Feb 11 17:01:09 2002 +0000
+++ b/sys/arch/hpc/stand/hpcboot/memory.h       Mon Feb 11 17:05:45 2002 +0000
@@ -1,4 +1,4 @@
-/* -*-C++-*-   $NetBSD: memory.h,v 1.3 2001/05/08 18:51:23 uch Exp $   */
+/* -*-C++-*-   $NetBSD: memory.h,v 1.4 2002/02/11 17:05:45 uch Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
                { return _page_size - sizeof(struct PageTag); }
        vsize_t estimateTaggedPageSize(vsize_t sz) {
                vsize_t tsz = getTaggedPageSize();
-               return((sz + tsz - 1) / tsz) * _page_size;
+               return ((sz + tsz - 1) / tsz) * _page_size;
        }
        u_int32_t roundPage(u_int32_t v) { return ROUND(v, _page_size); }
        u_int32_t truncPage(u_int32_t v) { return TRUNC(v, _page_size); }



Home | Main Index | Thread Index | Old Index