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
RevLine 
[032a9b3]1/*
[df4ed85]2 * Copyright (c) 2005 Martin Decky
[032a9b3]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
[e731b0d]29#include "main.h"
[ce8725be]30#include <printf.h>
[96e0748d]31#include <align.h>
[fa024ce]32#include <macros.h>
[89b1b64]33#include <string.h>
[e731b0d]34#include <memstr.h>
[032a9b3]35#include "msim.h"
36#include "asm.h"
[25f089b]37#include "_components.h"
[032a9b3]38
39#define KERNEL_VIRTUAL_ADDRESS 0x80100000
40
[fa024ce]41char *release = STRING(RELEASE);
[22f851e]42
43#ifdef REVISION
[fa024ce]44 char *revision = ", revision " STRING(REVISION);
[22f851e]45#else
46 char *revision = "";
47#endif
48
49#ifdef TIMESTAMP
[fa024ce]50 char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
[22f851e]51#else
52 char *timestamp = "";
53#endif
54
55/** Print version information. */
56static void version_print(void)
57{
[df4ed85]58 printf("HelenOS MIPS32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n", release, revision, timestamp);
[22f851e]59}
60
[032a9b3]61void bootstrap(void)
62{
[22f851e]63 version_print();
[032a9b3]64
[25f089b]65 component_t components[COMPONENTS];
66 init_components(components);
67
[e19d667]68 bootinfo_t bootinfo;
69
[25f089b]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");
[96e0748d]79
[25f089b]80 unsigned int top = 0;
81 bootinfo.cnt = 0;
[96e0748d]82 for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
[25f089b]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;
[89b1b64]89 strncpy(bootinfo.tasks[bootinfo.cnt].name,
90 components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
[25f089b]91 bootinfo.cnt++;
92 }
93 top += components[i].size;
94 printf("done.\n");
[032a9b3]95 }
96
[96e0748d]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
[032a9b3]104 printf("\nBooting the kernel...\n");
[96e0748d]105 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo);
[032a9b3]106}
Note: See TracBrowser for help on using the repository browser.