root / prex-0.9.0 / bsp / boot / common / bootinfo.c @ 03e9c04a
History | View | Annotate | Download (2.99 KB)
1 |
/*-
|
---|---|
2 |
* Copyright (c) 2005-2009, Kohsuke Ohtani
|
3 |
* All rights reserved.
|
4 |
*
|
5 |
* Redistribution and use in source and binary forms, with or without
|
6 |
* modification, are permitted provided that the following conditions
|
7 |
* are met:
|
8 |
* 1. Redistributions of source code must retain the above copyright
|
9 |
* notice, this list of conditions and the following disclaimer.
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright
|
11 |
* notice, this list of conditions and the following disclaimer in the
|
12 |
* documentation and/or other materials provided with the distribution.
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors
|
14 |
* may be used to endorse or promote products derived from this software
|
15 |
* without specific prior written permission.
|
16 |
*
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27 |
* SUCH DAMAGE.
|
28 |
*/
|
29 |
|
30 |
/*
|
31 |
* bootinfo.c - Boot information
|
32 |
*/
|
33 |
|
34 |
#include <boot.h> |
35 |
#include <sys/bootinfo.h> |
36 |
#include <machine/syspage.h> |
37 |
|
38 |
/*
|
39 |
* Boot information holds various platform dependent data that
|
40 |
* can be referred by kernel/drivers.
|
41 |
*/
|
42 |
struct bootinfo *const bootinfo = (struct bootinfo *)kvtop(BOOTINFO); |
43 |
|
44 |
|
45 |
#if defined(DEBUG) && defined(DEBUG_BOOTINFO)
|
46 |
static void |
47 |
print_module(struct module *m)
|
48 |
{ |
49 |
|
50 |
printf("%lx %lx %x %lx %lx %x %x %x %s\n",
|
51 |
m->entry, m->phys, m->size, |
52 |
m->text, m->data, m->textsz, |
53 |
m->datasz, m->bsssz, m->name); |
54 |
} |
55 |
|
56 |
void
|
57 |
dump_bootinfo(void)
|
58 |
{ |
59 |
static const char strtype[][9] = \ |
60 |
{ "", "USABLE", "MEMHOLE", "RESERVED", "BOOTDISK" }; |
61 |
struct module *m;
|
62 |
struct bootinfo *bi = bootinfo;
|
63 |
int i;
|
64 |
|
65 |
printf("[Boot information]\n");
|
66 |
|
67 |
printf("nr_rams=%d\n", bi->nr_rams);
|
68 |
for (i = 0; i < bi->nr_rams; i++) { |
69 |
if (bi->ram[i].type != 0) { |
70 |
printf("ram[%d]: base=%lx size=%x type=%s\n", i,
|
71 |
bi->ram[i].base, |
72 |
bi->ram[i].size, |
73 |
strtype[bi->ram[i].type]); |
74 |
} |
75 |
} |
76 |
|
77 |
printf("bootdisk: base=%lx size=%x\n",
|
78 |
bi->bootdisk.base, |
79 |
bi->bootdisk.size); |
80 |
|
81 |
printf("entry phys size text data textsz datasz bsssz module\n");
|
82 |
printf("-------- -------- -------- -------- -------- -------- -------- -------- ------\n");
|
83 |
print_module(&bi->kernel); |
84 |
print_module(&bi->driver); |
85 |
|
86 |
m = (struct module *)&bi->tasks[0]; |
87 |
for (i = 0; i < bi->nr_tasks; i++, m++) |
88 |
print_module(m); |
89 |
} |
90 |
#else
|
91 |
void
|
92 |
dump_bootinfo(void)
|
93 |
{ |
94 |
} |
95 |
#endif
|