fix memory size estimation. add error check code.
This commit is contained in:
parent
587d245cb8
commit
984e019350
|
@ -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 @@ hpcboot(void *arg)
|
|||
goto failed_exit;
|
||||
}
|
||||
sz = f._file->size();
|
||||
sz = f._mem->roundPage(sz);
|
||||
f._file->close();
|
||||
}
|
||||
|
||||
|
@ -156,7 +157,7 @@ hpcboot(void *arg)
|
|||
}
|
||||
|
||||
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 @@ hpcboot(void *arg)
|
|||
|
||||
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 @@ hpcboot(void *arg)
|
|||
// 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 @@ HpcBootApp::registerClass(WNDPROC proc)
|
|||
|
||||
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]));
|
||||
}
|
||||
|
|
|
@ -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 @@ Loader::objectFormat(File &file)
|
|||
return LOADER_UNKNOWN;
|
||||
}
|
||||
|
||||
void
|
||||
BOOL
|
||||
Loader::loadExtData(void)
|
||||
{
|
||||
size_t sz;
|
||||
|
@ -86,6 +86,8 @@ Loader::loadExtData(void)
|
|||
|
||||
DPRINTF((TEXT("[file system image]")));
|
||||
_load_segment(kv, sz, 0, sz);
|
||||
|
||||
return _load_success();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -132,11 +134,13 @@ Loader::_load_segment_start(void)
|
|||
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 @@ Loader::_load_memory(vaddr_t kv, vsize_t memsz, void *data)
|
|||
}
|
||||
|
||||
_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 @@ Loader::_load_page(vaddr_t kv, off_t ofs, size_t sz, struct PageTag *prev)
|
|||
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;
|
||||
|
|
|
@ -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 @@ private:
|
|||
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 @@ protected:
|
|||
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 @@ public:
|
|||
virtual kaddr_t jumpAddr(void) = 0;
|
||||
|
||||
paddr_t tagStart(void);
|
||||
void loadExtData(void);
|
||||
BOOL loadExtData(void);
|
||||
void loadEnd(void);
|
||||
|
||||
void tagDump(int); // for debug
|
||||
|
|
|
@ -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 @@ CoffLoader::memorySize()
|
|||
kaddr_t
|
||||
CoffLoader::jumpAddr()
|
||||
{
|
||||
|
||||
DPRINTF((TEXT("kernel entry address: 0x%08x\n"), _ah->a_entry));
|
||||
|
||||
return _ah->a_entry;
|
||||
}
|
||||
|
||||
|
@ -115,8 +117,7 @@ CoffLoader::load()
|
|||
_load_segment(kv, memsz, fileofs, filesz);
|
||||
|
||||
/* tag chain still opening */
|
||||
|
||||
return TRUE;
|
||||
return _load_success();
|
||||
}
|
||||
|
||||
BOOL
|
||||
|
|
|
@ -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 @@ public:
|
|||
{ 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); }
|
||||
|
|
Loading…
Reference in New Issue