source: mainline/boot/arch/arm32/loader/main.c@ d7f8796c

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

add support for larger boot images (up to 8 MB)

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2007 Michal Kebrt
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
30/** @addtogroup arm32boot
31 * @{
32 */
33/** @file
34 * @brief Bootstrap.
35 */
36
37
38#include "main.h"
39#include "asm.h"
40#include "_components.h"
41#include <printf.h>
42#include <align.h>
43#include <macros.h>
44#include <string.h>
45#include <memstr.h>
46
47#include "mm.h"
48
49/** Kernel entry point address. */
50#define KERNEL_VIRTUAL_ADDRESS 0x80800000
51
52
53char *release = STRING(RELEASE);
54
55#ifdef REVISION
56 char *revision = ", revision " STRING(REVISION);
57#else
58 char *revision = "";
59#endif
60
61#ifdef TIMESTAMP
62 char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
63#else
64 char *timestamp = "";
65#endif
66
67
68/** Prints bootloader version information. */
69static void version_print(void)
70{
71 printf("HelenOS ARM32 Bootloader\nRelease %s%s%s\nCopyright (c) 2009 HelenOS project\n",
72 release, revision, timestamp);
73}
74
75
76/** Copies all images (kernel + user tasks) to #KERNEL_VIRTUAL_ADDRESS and jumps there. */
77void bootstrap(void)
78{
79 mmu_start();
80 version_print();
81
82 component_t components[COMPONENTS];
83 init_components(components);
84
85 bootinfo_t bootinfo;
86
87 printf("\nMemory statistics\n");
88 printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS);
89 printf(" %L: boot info structure\n", &bootinfo);
90
91 unsigned int top = 0;
92 bootinfo.cnt = 0;
93 unsigned int i, j;
94 for (i = 0; i < COMPONENTS; i++) {
95 top = ALIGN_UP(top, KERNEL_PAGE_SIZE);
96 if (i > 0) {
97 bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top;
98 bootinfo.tasks[bootinfo.cnt].size = components[i].size;
99 strncpy(bootinfo.tasks[bootinfo.cnt].name,
100 components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
101 bootinfo.cnt++;
102 }
103 top += components[i].size;
104 }
105 j = bootinfo.cnt - 1;
106
107 printf("\nCopying components\n");
108 printf("Component\tAddress\t\tSize (Bytes)\n");
109 printf("============================================\n");
110 for (i = COMPONENTS - 1; i > 0; i--, j--) {
111 printf("%s\t\t0x%x\t%d\n", components[i].name, bootinfo.tasks[j].addr, components[i].size);
112 memcpy((void *)bootinfo.tasks[j].addr, components[i].start,
113 components[i].size);
114 }
115 printf("KERNEL\t\t0x%x\t%d\n", KERNEL_VIRTUAL_ADDRESS, components[0].size);
116
117 memcpy((void *)KERNEL_VIRTUAL_ADDRESS, components[0].start,
118 components[0].size);
119
120 printf("\nBooting the kernel...\n");
121 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo);
122}
123
124/** @}
125 */
126
Note: See TracBrowser for help on using the repository browser.