[c785296] | 1 | /*
|
---|
| 2 | * Copyright (c) 2005 Martin Decky
|
---|
[fa024ce] | 3 | * Copyright (c) 2006 Jakub Jermar
|
---|
[c785296] | 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | #include "main.h"
|
---|
| 31 | #include <printf.h>
|
---|
| 32 | #include "asm.h"
|
---|
| 33 | #include "_components.h"
|
---|
| 34 | #include <align.h>
|
---|
| 35 | #include <balloc.h>
|
---|
[fa024ce] | 36 | #include <macros.h>
|
---|
[46db10e9] | 37 | #include <string.h>
|
---|
[c785296] | 38 |
|
---|
[59e4864] | 39 | extern bootinfo_t binfo;
|
---|
[c785296] | 40 | component_t components[COMPONENTS];
|
---|
| 41 |
|
---|
[fa024ce] | 42 | char *release = STRING(RELEASE);
|
---|
[c785296] | 43 |
|
---|
| 44 | void write(const char *str, const int len)
|
---|
| 45 | {
|
---|
| 46 | return;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[2b70a6e] | 49 | #define DEFAULT_MEMORY_BASE 0x4000000
|
---|
| 50 | #define DEFAULT_MEMORY_SIZE 0x4000000
|
---|
| 51 | #define DEFAULT_LEGACY_IO_BASE 0x00000FFFFC000000
|
---|
| 52 | #define DEFAULT_LEGACY_IO_SIZE 0x4000000
|
---|
[50b3d30] | 53 |
|
---|
[2b70a6e] | 54 | #define DEFAULT_FREQ_SCALE 0x0000000100000001 /* 1/1 */
|
---|
| 55 | #define DEFAULT_SYS_FREQ 100000000 /* 100MHz */
|
---|
[c785296] | 56 |
|
---|
| 57 | #ifdef REVISION
|
---|
[fa024ce] | 58 | char *revision = ", revision " STRING(REVISION);
|
---|
[c785296] | 59 | #else
|
---|
| 60 | char *revision = "";
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
| 63 | #ifdef TIMESTAMP
|
---|
[fa024ce] | 64 | char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
|
---|
[c785296] | 65 | #else
|
---|
| 66 | char *timestamp = "";
|
---|
| 67 | #endif
|
---|
| 68 |
|
---|
| 69 | /** Print version information. */
|
---|
| 70 | static void version_print(void)
|
---|
| 71 | {
|
---|
[2b70a6e] | 72 | printf("HelenOS IA64 Bootloader\nRelease %s%s%s\n"
|
---|
| 73 | "Copyright (c) 2006 HelenOS project\n", release, revision,
|
---|
| 74 | timestamp);
|
---|
[c785296] | 75 | }
|
---|
| 76 |
|
---|
| 77 | void bootstrap(void)
|
---|
| 78 | {
|
---|
| 79 | int ii;
|
---|
[2b70a6e] | 80 | bootinfo_t *bootinfo = &binfo;
|
---|
[c785296] | 81 |
|
---|
| 82 | version_print();
|
---|
| 83 |
|
---|
| 84 | init_components(components);
|
---|
| 85 |
|
---|
| 86 | printf("\nSystem info\n");
|
---|
| 87 | printf("\nMemory statistics\n");
|
---|
| 88 | printf(" %P: boot info structure\n", &bootinfo);
|
---|
| 89 |
|
---|
| 90 | unsigned int i;
|
---|
| 91 | for (i = 0; i < COMPONENTS; i++)
|
---|
| 92 | printf(" %P: %s image (size %d bytes)\n", components[i].start,
|
---|
| 93 | components[i].name, components[i].size);
|
---|
| 94 |
|
---|
[2b70a6e] | 95 | if (!bootinfo->hello_configured) {
|
---|
[50b3d30] | 96 | /*
|
---|
[2b70a6e] | 97 | * Load configuration defaults for simulators.
|
---|
[50b3d30] | 98 | */
|
---|
[2b70a6e] | 99 | bootinfo->memmap_items = 0;
|
---|
[50b3d30] | 100 |
|
---|
[2b70a6e] | 101 | bootinfo->memmap[bootinfo->memmap_items].base =
|
---|
| 102 | DEFAULT_MEMORY_BASE;
|
---|
| 103 | bootinfo->memmap[bootinfo->memmap_items].size =
|
---|
| 104 | DEFAULT_MEMORY_SIZE;
|
---|
| 105 | bootinfo->memmap[bootinfo->memmap_items].type =
|
---|
| 106 | EFI_MEMMAP_FREE_MEM;
|
---|
[50b3d30] | 107 | bootinfo->memmap_items++;
|
---|
| 108 |
|
---|
[2b70a6e] | 109 | bootinfo->memmap[bootinfo->memmap_items].base =
|
---|
| 110 | DEFAULT_LEGACY_IO_BASE;
|
---|
| 111 | bootinfo->memmap[bootinfo->memmap_items].size =
|
---|
| 112 | DEFAULT_LEGACY_IO_SIZE;
|
---|
| 113 | bootinfo->memmap[bootinfo->memmap_items].type =
|
---|
| 114 | EFI_MEMMAP_IO_PORTS;
|
---|
[50b3d30] | 115 | bootinfo->memmap_items++;
|
---|
| 116 |
|
---|
| 117 | bootinfo->freq_scale = DEFAULT_FREQ_SCALE;
|
---|
| 118 | bootinfo->sys_freq = DEFAULT_SYS_FREQ;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[59e4864] | 121 | bootinfo->taskmap.count = 0;
|
---|
[c785296] | 122 | for (i = 0; i < COMPONENTS; i++) {
|
---|
| 123 | if (i > 0) {
|
---|
[2b70a6e] | 124 | bootinfo->taskmap.tasks[bootinfo->taskmap.count].addr =
|
---|
| 125 | components[i].start;
|
---|
| 126 | bootinfo->taskmap.tasks[bootinfo->taskmap.count].size =
|
---|
| 127 | components[i].size;
|
---|
[46db10e9] | 128 | strncpy(bootinfo->taskmap.tasks[
|
---|
| 129 | bootinfo->taskmap.count].name,
|
---|
| 130 | components[i].name, BOOTINFO_TASK_NAME_BUFLEN);
|
---|
[59e4864] | 131 | bootinfo->taskmap.count++;
|
---|
[c785296] | 132 | }
|
---|
| 133 | }
|
---|
| 134 |
|
---|
[59e4864] | 135 | jump_to_kernel(bootinfo);
|
---|
[c785296] | 136 | }
|
---|
| 137 |
|
---|