source: mainline/boot/arch/mips32/src/main.c@ 009c485

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 009c485 was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

  • Property mode set to 100644
File size: 4.2 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 <arch/main.h>
30#include <arch/arch.h>
31#include <arch/asm.h>
32#include <halt.h>
33#include <printf.h>
34#include <memstr.h>
35#include <version.h>
36#include <macros.h>
37#include <align.h>
38#include <str.h>
39#include <errno.h>
40#include <inflate.h>
41#include "../../components.h"
42
43#define TOP2ADDR(top) (((void *) PA2KA(BOOT_OFFSET)) + (top))
44
45static bootinfo_t *bootinfo = (bootinfo_t *) PA2KA(BOOTINFO_OFFSET);
46static uint32_t *cpumap = (uint32_t *) PA2KA(CPUMAP_OFFSET);
47
48void bootstrap(void)
49{
50 version_print();
51
52 printf("\nMemory statistics\n");
53 printf(" %p|%p: CPU map\n", (void *) PA2KA(CPUMAP_OFFSET),
54 (void *) CPUMAP_OFFSET);
55 printf(" %p|%p: bootstrap stack\n", (void *) PA2KA(STACK_OFFSET),
56 (void *) STACK_OFFSET);
57 printf(" %p|%p: boot info structure\n",
58 (void *) PA2KA(BOOTINFO_OFFSET), (void *) BOOTINFO_OFFSET);
59 printf(" %p|%p: kernel entry point\n", (void *) PA2KA(BOOT_OFFSET),
60 (void *) BOOT_OFFSET);
61 printf(" %p|%p: bootloader entry point\n",
62 (void *) PA2KA(LOADER_OFFSET), (void *) LOADER_OFFSET);
63
64 size_t i;
65 for (i = 0; i < COMPONENTS; i++)
66 printf(" %p|%p: %s image (%zu/%zu bytes)\n", components[i].addr,
67 (uintptr_t) components[i].addr >= PA2KSEG(0) ?
68 (void *) KSEG2PA(components[i].addr) :
69 (void *) KA2PA(components[i].addr),
70 components[i].name, components[i].inflated,
71 components[i].size);
72
73 void *dest[COMPONENTS];
74 size_t top = 0;
75 size_t cnt = 0;
76 bootinfo->cnt = 0;
77 for (i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
78 top = ALIGN_UP(top, PAGE_SIZE);
79
80 if (i > 0) {
81 bootinfo->tasks[bootinfo->cnt].addr = TOP2ADDR(top);
82 bootinfo->tasks[bootinfo->cnt].size = components[i].inflated;
83
84 str_cpy(bootinfo->tasks[bootinfo->cnt].name,
85 BOOTINFO_TASK_NAME_BUFLEN, components[i].name);
86
87 bootinfo->cnt++;
88 }
89
90 dest[i] = TOP2ADDR(top);
91 top += components[i].inflated;
92 cnt++;
93 }
94
95 printf("\nInflating components ... ");
96
97 for (i = cnt; i > 0; i--) {
98#ifdef MACHINE_msim
99 void *tail = dest[i - 1] + components[i].inflated;
100 if (tail >= ((void *) PA2KA(LOADER_OFFSET))) {
101 printf("\n%s: Image too large to fit (%p >= %p), halting.\n",
102 components[i].name, tail, (void *) PA2KA(LOADER_OFFSET));
103 halt();
104 }
105#endif
106
107 printf("%s ", components[i - 1].name);
108
109 int err = inflate(components[i - 1].addr, components[i - 1].size,
110 dest[i - 1], components[i - 1].inflated);
111
112 if (err != EOK) {
113 printf("\n%s: Inflating error %d, halting.\n",
114 components[i - 1].name, err);
115 halt();
116 }
117 }
118
119 printf(".\n");
120
121 printf("Copying CPU map ... \n");
122
123 bootinfo->cpumap = 0;
124 for (i = 0; i < CPUMAP_MAX_RECORDS; i++) {
125 if (cpumap[i] != 0)
126 bootinfo->cpumap |= (1 << i);
127 }
128
129 printf("Booting the kernel ... \n");
130 jump_to_kernel((void *) PA2KA(BOOT_OFFSET), bootinfo);
131}
Note: See TracBrowser for help on using the repository browser.