Rev 3984 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3984 | svoboda | 1 | /* |
2 | * Copyright (c) 2009 Jiri Svoboda |
||
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 | /** @addtogroup ia32 |
||
30 | * @{ |
||
31 | */ |
||
32 | /** @file |
||
33 | */ |
||
34 | |||
35 | #include <main/main.h> |
||
36 | #include <arch/boot/boot.h> |
||
37 | #include <arch/boot/cboot.h> |
||
38 | #include <arch/boot/memmap.h> |
||
39 | #include <config.h> |
||
40 | #include <memstr.h> |
||
41 | |||
42 | /* This is a symbol so the type is only dummy. Obtain the value using &. */ |
||
43 | extern int _hardcoded_unmapped_size; |
||
44 | |||
45 | /** C part of ia32 boot sequence. |
||
46 | * @param signature Should contain the multiboot signature. |
||
47 | * @param mi Pointer to the multiboot information structure. |
||
48 | */ |
||
49 | void ia32_cboot(uint32_t signature, const mb_info_t *mi) |
||
50 | { |
||
51 | uint32_t flags; |
||
52 | mb_mod_t *mods; |
||
53 | uint32_t i; |
||
54 | |||
3985 | svoboda | 55 | if (signature == MULTIBOOT_LOADER_MAGIC) { |
56 | flags = mi->flags; |
||
57 | } else { |
||
58 | /* No multiboot info available. */ |
||
59 | flags = 0; |
||
60 | } |
||
3984 | svoboda | 61 | |
62 | /* Copy module information. */ |
||
63 | |||
64 | if ((flags & MBINFO_FLAGS_MODS) != 0) { |
||
65 | init.cnt = mi->mods_count; |
||
66 | mods = mi->mods_addr; |
||
67 | |||
68 | for (i = 0; i < init.cnt; i++) { |
||
69 | init.tasks[i].addr = mods[i].start + 0x80000000; |
||
70 | init.tasks[i].size = mods[i].end - mods[i].start; |
||
71 | } |
||
72 | } else { |
||
73 | init.cnt = 0; |
||
74 | } |
||
75 | |||
76 | /* Copy memory map. */ |
||
77 | |||
78 | int32_t mmap_length; |
||
79 | mb_mmap_t *mme; |
||
80 | uint32_t size; |
||
81 | |||
82 | if ((flags & MBINFO_FLAGS_MMAP) != 0) { |
||
83 | mmap_length = mi->mmap_length; |
||
84 | mme = mi->mmap_addr; |
||
85 | e820counter = 0; |
||
86 | |||
87 | i = 0; |
||
88 | while (mmap_length > 0) { |
||
89 | e820table[i++] = mme->mm_info; |
||
90 | |||
91 | /* Compute address of next structure. */ |
||
92 | size = sizeof(mme->size) + mme->size; |
||
93 | mme = ((void *) mme) + size; |
||
94 | mmap_length -= size; |
||
95 | } |
||
96 | |||
97 | e820counter = i; |
||
98 | } else { |
||
99 | e820counter = 0; |
||
100 | } |
||
101 | |||
102 | #ifdef CONFIG_SMP |
||
103 | /* Copy AP bootstrap routines below 1 MB. */ |
||
104 | memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, |
||
105 | (size_t) &_hardcoded_unmapped_size); |
||
106 | #endif |
||
107 | |||
108 | main_bsp(); |
||
109 | } |
||
110 | |||
111 | /** @} |
||
112 | */ |