Rev 3987 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3987 | Rev 4011 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2009 Jiri Svoboda |
2 | * Copyright (c) 2009 Jiri Svoboda |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
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 |
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. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
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 |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 |
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. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup ia32 |
29 | /** @addtogroup ia32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <main/main.h> |
35 | #include <main/main.h> |
36 | #include <arch/boot/boot.h> |
36 | #include <arch/boot/boot.h> |
37 | #include <arch/boot/cboot.h> |
37 | #include <arch/boot/cboot.h> |
38 | #include <arch/boot/memmap.h> |
38 | #include <arch/boot/memmap.h> |
39 | #include <config.h> |
39 | #include <config.h> |
40 | #include <memstr.h> |
40 | #include <memstr.h> |
41 | #include <func.h> |
41 | #include <string.h> |
42 | 42 | ||
43 | /* This is a symbol so the type is only dummy. Obtain the value using &. */ |
43 | /* This is a symbol so the type is only dummy. Obtain the value using &. */ |
44 | extern int _hardcoded_unmapped_size; |
44 | extern int _hardcoded_unmapped_size; |
45 | 45 | ||
46 | /** C part of ia32 boot sequence. |
46 | /** C part of ia32 boot sequence. |
47 | * @param signature Should contain the multiboot signature. |
47 | * @param signature Should contain the multiboot signature. |
48 | * @param mi Pointer to the multiboot information structure. |
48 | * @param mi Pointer to the multiboot information structure. |
49 | */ |
49 | */ |
50 | void ia32_cboot(uint32_t signature, const mb_info_t *mi) |
50 | void ia32_cboot(uint32_t signature, const mb_info_t *mi) |
51 | { |
51 | { |
52 | uint32_t flags; |
52 | uint32_t flags; |
53 | mb_mod_t *mods; |
53 | mb_mod_t *mods; |
54 | uint32_t i; |
54 | uint32_t i; |
55 | 55 | ||
56 | if (signature == MULTIBOOT_LOADER_MAGIC) { |
56 | if (signature == MULTIBOOT_LOADER_MAGIC) { |
57 | flags = mi->flags; |
57 | flags = mi->flags; |
58 | } else { |
58 | } else { |
59 | /* No multiboot info available. */ |
59 | /* No multiboot info available. */ |
60 | flags = 0; |
60 | flags = 0; |
61 | } |
61 | } |
62 | 62 | ||
63 | /* Copy module information. */ |
63 | /* Copy module information. */ |
64 | 64 | ||
65 | if ((flags & MBINFO_FLAGS_MODS) != 0) { |
65 | if ((flags & MBINFO_FLAGS_MODS) != 0) { |
66 | init.cnt = mi->mods_count; |
66 | init.cnt = mi->mods_count; |
67 | mods = mi->mods_addr; |
67 | mods = mi->mods_addr; |
68 | 68 | ||
69 | for (i = 0; i < init.cnt; i++) { |
69 | for (i = 0; i < init.cnt; i++) { |
70 | init.tasks[i].addr = mods[i].start + 0x80000000; |
70 | init.tasks[i].addr = mods[i].start + 0x80000000; |
71 | init.tasks[i].size = mods[i].end - mods[i].start; |
71 | init.tasks[i].size = mods[i].end - mods[i].start; |
72 | 72 | ||
73 | /* Copy command line, if available. */ |
73 | /* Copy command line, if available. */ |
74 | if (mods[i].string) { |
74 | if (mods[i].string) { |
75 | strncpy(init.tasks[i].name, mods[i].string, |
75 | strncpy(init.tasks[i].name, mods[i].string, |
76 | CONFIG_TASK_NAME_BUFLEN - 1); |
76 | CONFIG_TASK_NAME_BUFLEN - 1); |
77 | init.tasks[i].name[CONFIG_TASK_NAME_BUFLEN - 1] |
77 | init.tasks[i].name[CONFIG_TASK_NAME_BUFLEN - 1] |
78 | = '\0'; |
78 | = '\0'; |
79 | } else { |
79 | } else { |
80 | init.tasks[i].name[0] = '\0'; |
80 | init.tasks[i].name[0] = '\0'; |
81 | } |
81 | } |
82 | } |
82 | } |
83 | } else { |
83 | } else { |
84 | init.cnt = 0; |
84 | init.cnt = 0; |
85 | } |
85 | } |
86 | 86 | ||
87 | /* Copy memory map. */ |
87 | /* Copy memory map. */ |
88 | 88 | ||
89 | int32_t mmap_length; |
89 | int32_t mmap_length; |
90 | mb_mmap_t *mme; |
90 | mb_mmap_t *mme; |
91 | uint32_t size; |
91 | uint32_t size; |
92 | 92 | ||
93 | if ((flags & MBINFO_FLAGS_MMAP) != 0) { |
93 | if ((flags & MBINFO_FLAGS_MMAP) != 0) { |
94 | mmap_length = mi->mmap_length; |
94 | mmap_length = mi->mmap_length; |
95 | mme = mi->mmap_addr; |
95 | mme = mi->mmap_addr; |
96 | e820counter = 0; |
96 | e820counter = 0; |
97 | 97 | ||
98 | i = 0; |
98 | i = 0; |
99 | while (mmap_length > 0) { |
99 | while (mmap_length > 0) { |
100 | e820table[i++] = mme->mm_info; |
100 | e820table[i++] = mme->mm_info; |
101 | 101 | ||
102 | /* Compute address of next structure. */ |
102 | /* Compute address of next structure. */ |
103 | size = sizeof(mme->size) + mme->size; |
103 | size = sizeof(mme->size) + mme->size; |
104 | mme = ((void *) mme) + size; |
104 | mme = ((void *) mme) + size; |
105 | mmap_length -= size; |
105 | mmap_length -= size; |
106 | } |
106 | } |
107 | 107 | ||
108 | e820counter = i; |
108 | e820counter = i; |
109 | } else { |
109 | } else { |
110 | e820counter = 0; |
110 | e820counter = 0; |
111 | } |
111 | } |
112 | 112 | ||
113 | #ifdef CONFIG_SMP |
113 | #ifdef CONFIG_SMP |
114 | /* Copy AP bootstrap routines below 1 MB. */ |
114 | /* Copy AP bootstrap routines below 1 MB. */ |
115 | memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, |
115 | memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, |
116 | (size_t) &_hardcoded_unmapped_size); |
116 | (size_t) &_hardcoded_unmapped_size); |
117 | #endif |
117 | #endif |
118 | 118 | ||
119 | main_bsp(); |
119 | main_bsp(); |
120 | } |
120 | } |
121 | 121 | ||
122 | /** @} |
122 | /** @} |
123 | */ |
123 | */ |
124 | 124 |