Rev 4015 | Rev 4026 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4015 | Rev 4022 | ||
|---|---|---|---|
| Line 38... | Line 38... | ||
| 38 | 38 | ||
| 39 | #include <arch/types.h> |
39 | #include <arch/types.h> |
| 40 | 40 | ||
| 41 | #include <arch/pm.h> |
41 | #include <arch/pm.h> |
| 42 | 42 | ||
| - | 43 | #include <genarch/multiboot/multiboot.h> |
|
| 43 | #include <genarch/drivers/legacy/ia32/io.h> |
44 | #include <genarch/drivers/legacy/ia32/io.h> |
| 44 | #include <genarch/drivers/ega/ega.h> |
45 | #include <genarch/drivers/ega/ega.h> |
| 45 | #include <arch/drivers/vesa.h> |
46 | #include <arch/drivers/vesa.h> |
| 46 | #include <genarch/kbd/i8042.h> |
47 | #include <genarch/kbd/i8042.h> |
| 47 | #include <arch/drivers/i8254.h> |
48 | #include <arch/drivers/i8254.h> |
| Line 64... | Line 65... | ||
| 64 | #include <syscall/syscall.h> |
65 | #include <syscall/syscall.h> |
| 65 | #include <console/console.h> |
66 | #include <console/console.h> |
| 66 | #include <ddi/device.h> |
67 | #include <ddi/device.h> |
| 67 | #include <sysinfo/sysinfo.h> |
68 | #include <sysinfo/sysinfo.h> |
| 68 | #include <arch/boot/boot.h> |
69 | #include <arch/boot/boot.h> |
| 69 | #include <string.h> |
- | |
| 70 | #include <macros.h> |
- | |
| 71 | 70 | ||
| 72 | #ifdef CONFIG_SMP |
71 | #ifdef CONFIG_SMP |
| 73 | #include <arch/smp/apic.h> |
72 | #include <arch/smp/apic.h> |
| 74 | #endif |
73 | #endif |
| 75 | 74 | ||
| 76 | /** Extract command name from the multiboot module command line. |
- | |
| 77 | * |
- | |
| 78 | * @param buf Destination buffer (will always null-terminate). |
75 | /** Perform ia32-specific initialization before main_bsp() is called. |
| 79 | * @param n Size of destination buffer. |
- | |
| 80 | * @param cmd_line Input string (the command line). |
- | |
| 81 | * |
- | |
| 82 | */ |
- | |
| 83 | static void extract_command(char *buf, size_t n, const char *cmd_line) |
- | |
| 84 | { |
- | |
| 85 | const char *start, *end, *cp; |
- | |
| 86 | size_t max_len; |
- | |
| 87 | - | ||
| 88 | /* Find the first space. */ |
- | |
| 89 | end = strchr(cmd_line, ' '); |
- | |
| 90 | if (end == NULL) |
- | |
| 91 | end = cmd_line + strlen(cmd_line); |
- | |
| 92 | - | ||
| 93 | /* |
- | |
| 94 | * Find last occurence of '/' before 'end'. If found, place start at |
- | |
| 95 | * next character. Otherwise, place start at beginning of buffer. |
- | |
| 96 | */ |
- | |
| 97 | cp = end; |
- | |
| 98 | start = buf; |
- | |
| 99 | while (cp != start) { |
- | |
| 100 | if (*cp == '/') { |
- | |
| 101 | start = cp + 1; |
- | |
| 102 | break; |
- | |
| 103 | } |
- | |
| 104 | --cp; |
- | |
| 105 | } |
- | |
| 106 | - | ||
| 107 | /* Copy the command and null-terminate the string. */ |
- | |
| 108 | max_len = min(n - 1, (size_t) (end - start)); |
- | |
| 109 | strncpy(buf, start, max_len + 1); |
- | |
| 110 | buf[max_len] = '\0'; |
- | |
| 111 | } |
- | |
| 112 | - | ||
| 113 | /** C part of ia32 boot sequence. |
- | |
| 114 | * |
76 | * |
| 115 | * @param signature Should contain the multiboot signature. |
77 | * @param signature Should contain the multiboot signature. |
| 116 | * @param mi Pointer to the multiboot information structure. |
78 | * @param mi Pointer to the multiboot information structure. |
| 117 | */ |
79 | */ |
| 118 | void arch_pre_main(uint32_t signature, const mb_info_t *mi) |
80 | void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) |
| 119 | { |
81 | { |
| 120 | uint32_t flags; |
- | |
| 121 | mb_mod_t *mods; |
- | |
| 122 | uint32_t i; |
- | |
| 123 | - | ||
| 124 | if (signature == MULTIBOOT_LOADER_MAGIC) |
- | |
| 125 | flags = mi->flags; |
- | |
| 126 | else { |
- | |
| 127 | /* No multiboot info available. */ |
82 | /* Parse multiboot information obtained from the bootloader. */ |
| 128 | flags = 0; |
- | |
| 129 | } |
- | |
| 130 | - | ||
| 131 | /* Copy module information. */ |
- | |
| 132 | - | ||
| 133 | if ((flags & MBINFO_FLAGS_MODS) != 0) { |
- | |
| 134 | init.cnt = mi->mods_count; |
- | |
| 135 | mods = mi->mods_addr; |
- | |
| 136 | - | ||
| 137 | for (i = 0; i < init.cnt; i++) { |
- | |
| 138 | init.tasks[i].addr = mods[i].start + 0x80000000; |
- | |
| 139 | init.tasks[i].size = mods[i].end - mods[i].start; |
- | |
| 140 | - | ||
| 141 | /* Copy command line, if available. */ |
- | |
| 142 | if (mods[i].string) { |
- | |
| 143 | extract_command(init.tasks[i].name, |
- | |
| 144 | CONFIG_TASK_NAME_BUFLEN, |
- | |
| 145 | mods[i].string); |
- | |
| 146 | } else |
- | |
| 147 | init.tasks[i].name[0] = '\0'; |
- | |
| 148 | } |
- | |
| 149 | } else |
- | |
| 150 | init.cnt = 0; |
- | |
| 151 | - | ||
| 152 | /* Copy memory map. */ |
- | |
| 153 | - | ||
| 154 | int32_t mmap_length; |
- | |
| 155 | mb_mmap_t *mme; |
- | |
| 156 | uint32_t size; |
- | |
| 157 | - | ||
| 158 | if ((flags & MBINFO_FLAGS_MMAP) != 0) { |
- | |
| 159 | mmap_length = mi->mmap_length; |
- | |
| 160 | mme = mi->mmap_addr; |
- | |
| 161 | e820counter = 0; |
- | |
| 162 | - | ||
| 163 | i = 0; |
- | |
| 164 | while (mmap_length > 0) { |
- | |
| 165 | e820table[i++] = mme->mm_info; |
- | |
| 166 | - | ||
| 167 | /* Compute address of next structure. */ |
- | |
| 168 | size = sizeof(mme->size) + mme->size; |
83 | multiboot_info_parse(signature, mi); |
| 169 | mme = ((void *) mme) + size; |
- | |
| 170 | mmap_length -= size; |
- | |
| 171 | } |
- | |
| 172 | - | ||
| 173 | e820counter = i; |
- | |
| 174 | } else |
- | |
| 175 | e820counter = 0; |
- | |
| 176 | 84 | ||
| 177 | #ifdef CONFIG_SMP |
85 | #ifdef CONFIG_SMP |
| 178 | /* Copy AP bootstrap routines below 1 MB. */ |
86 | /* Copy AP bootstrap routines below 1 MB. */ |
| 179 | memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, |
87 | memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, |
| 180 | (size_t) &_hardcoded_unmapped_size); |
88 | (size_t) &_hardcoded_unmapped_size); |