source: mainline/boot/arch/mips32/loader/main.c@ 86018c1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 86018c1 was e731b0d, checked in by Martin Decky <martin@…>, 16 years ago

make ppc32 OFW usage on par with sparc64, make appropriate modifications elsewhere

  • introduce ofw_tree_walk_by_device_type() to gather all OFW devices of a given type
  • ppc32 uses canonized OFW tree, mac-io and display devices are detected in kernel (not by the boot loader) by means of device type
  • various busses (PCI, EBUS, etc.) stay sparc64 specific for now
  • boot memcpy() is defined in a common way
  • BALLOC_MAX_SIZE is platform-dependent
  • ppc32 and sparc64 boot loaders cleanup (removal of obsolete stuff, data is not passed by global variables if not necessary, etc.)
  • balloc and OFW tree canonizer have now a provision to support different mapping of the data during boot time and kernel run-time
  • OFW tree canonizer uses balloc_rebase() to store pointers suitable for access during kernel run-time (with potentially different memory mapping than during boot time)
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2005 Martin Decky
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 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "main.h"
30#include <printf.h>
31#include <align.h>
32#include <macros.h>
33#include <string.h>
34#include <memstr.h>
35#include "msim.h"
36#include "asm.h"
37#include "_components.h"
38
39#define KERNEL_VIRTUAL_ADDRESS 0x80100000
40
41char *release = STRING(RELEASE);
42
43#ifdef REVISION
44 char *revision = ", revision " STRING(REVISION);
45#else
46 char *revision = "";
47#endif
48
49#ifdef TIMESTAMP
50 char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
51#else
52 char *timestamp = "";
53#endif
54
55/** Print version information. */
56static void version_print(void)
57{
58 printf("HelenOS MIPS32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n", release, revision, timestamp);
59}
60
61void bootstrap(void)
62{
63 version_print();
64
65 component_t components[COMPONENTS];
66 init_components(components);
67
68 bootinfo_t bootinfo;
69
70 printf("\nMemory statistics\n");
71 printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS);
72 printf(" %L: boot info structure\n", &bootinfo);
73
74 unsigned int i;
75 for (i = 0; i < COMPONENTS; i++)
76 printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
77
78 printf("\nCopying components\n");
79
80 unsigned int top = 0;
81 bootinfo.cnt = 0;
82 for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
83 printf(" %s...", components[i].name);
84 top = ALIGN_UP(top, PAGE_SIZE);
85 memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size);
86 if (i > 0) {
87 bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top;
88 bootinfo.tasks[bootinfo.cnt].size = components[i].size;
89 strncpy(bootinfo.tasks[bootinfo.cnt].name,
90 components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
91 bootinfo.cnt++;
92 }
93 top += components[i].size;
94 printf("done.\n");
95 }
96
97 unsigned int *cpumap = (unsigned int *) CPUMAP;
98 bootinfo.cpumap = 0;
99 for (i = 0; i < CPUMAP_MAX_RECORDS; i++) {
100 if (cpumap[i] != 0)
101 bootinfo.cpumap |= (1 << i);
102 }
103
104 printf("\nBooting the kernel...\n");
105 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo);
106}
Note: See TracBrowser for help on using the repository browser.