Changeset 5d8d71e in mainline
- Timestamp:
- 2009-03-03T21:17:45Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 06f96234
- Parents:
- c22e964
- Files:
-
- 1 added
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
rc22e964 r5d8d71e 282 282 ! [PLATFORM=sparc64] CONFIG_OFW_TREE (y) 283 283 284 % Multiboot standard support 285 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_MULTIBOOT (y) 286 284 287 % FPU support 285 288 ! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=ia64|PLATFORM=sparc64] CONFIG_FPU (y) -
kernel/arch/amd64/include/arch.h
rc22e964 r5d8d71e 36 36 #define KERN_amd64_ARCH_H_ 37 37 38 #include <genarch/multiboot/multiboot.h> 39 40 extern void arch_pre_main(uint32_t, const multiboot_info_t *); 41 38 42 #endif 39 43 -
kernel/arch/amd64/include/boot/boot.h
rc22e964 r5d8d71e 43 43 #define MULTIBOOT_HEADER_FLAGS 0x00010003 44 44 45 #define MULTIBOOT_LOADER_MAGIC 0x2BADB002 45 #ifndef __ASM__ 46 47 #ifdef CONFIG_SMP 48 49 /* This is only a symbol so the type is dummy. Obtain the value using &. */ 50 extern int _hardcoded_unmapped_size; 51 52 #endif /* CONFIG_SMP */ 53 54 #endif /* __ASM__ */ 46 55 47 56 #endif -
kernel/arch/amd64/src/amd64.c
rc22e964 r5d8d71e 40 40 41 41 #include <proc/thread.h> 42 #include <genarch/multiboot/multiboot.h> 42 43 #include <genarch/drivers/legacy/ia32/io.h> 43 44 #include <genarch/drivers/ega/ega.h> … … 46 47 #include <arch/drivers/i8254.h> 47 48 #include <arch/drivers/i8259.h> 49 #include <arch/boot/boot.h> 48 50 49 51 #ifdef CONFIG_SMP … … 66 68 #include <sysinfo/sysinfo.h> 67 69 68 69 70 /** Disable I/O on non-privileged levels 70 71 * … … 95 96 ::: "%rax" 96 97 ); 98 } 99 100 /** Perform amd64-specific initialization before main_bsp() is called. 101 * 102 * @param signature Should contain the multiboot signature. 103 * @param mi Pointer to the multiboot information structure. 104 */ 105 void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) 106 { 107 /* Parse multiboot information obtained from the bootloader. */ 108 multiboot_info_parse(signature, mi); 109 110 #ifdef CONFIG_SMP 111 /* Copy AP bootstrap routines below 1 MB. */ 112 memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, 113 (size_t) &_hardcoded_unmapped_size); 114 #endif 97 115 } 98 116 -
kernel/arch/amd64/src/boot/boot.S
rc22e964 r5d8d71e 176 176 start64: 177 177 movq $(PA2KA(START_STACK)), %rsp 178 movl grub_eax, %eax 179 movl grub_ebx, %ebx 180 181 cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature 182 je valid_boot 183 184 xorl %ecx, %ecx # no memory size or map available 185 movl %ecx, e820counter 186 187 jmp invalid_boot 188 189 valid_boot: 190 191 movl (%ebx), %eax # ebx = physical address of struct multiboot_info 192 193 bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid) 194 jc mods_valid 195 196 xorq %rcx, %rcx 197 movq %rcx, init 198 jmp mods_end 199 200 mods_valid: 201 202 xorq %rcx, %rcx 203 movl 20(%ebx), %ecx # mbi->mods_count 204 movq %rcx, init 205 206 cmpl $0, %ecx 207 je mods_end 208 209 movl 24(%ebx), %esi # mbi->mods_addr 210 movq $init, %rdi 211 212 mods_loop: 213 214 xorq %rdx, %rdx 215 movl 0(%esi), %edx # mods->mod_start 216 movq $0xffff800000000000, %r10 217 addq %r10, %rdx 218 movq %rdx, 8(%rdi) 219 220 xorq %rdx, %rdx 221 movl 4(%esi), %edx 222 subl 0(%esi), %edx # mods->mod_end - mods->mod_start 223 movq %rdx, 16(%rdi) 224 225 addl $16, %esi 226 addq $48, %rdi 227 228 loop mods_loop 229 230 mods_end: 231 232 bt $6, %eax # mbi->flags[6] (mmap_length, mmap_addr valid) 233 jc mmap_valid 234 235 xorl %edx, %edx 236 jmp mmap_invalid 237 238 mmap_valid: 239 movl 44(%ebx), %ecx # mbi->mmap_length 240 movl 48(%ebx), %esi # mbi->mmap_addr 241 movq $e820table, %rdi 242 xorl %edx, %edx 243 244 mmap_loop: 245 cmpl $0, %ecx 246 jle mmap_end 247 248 movl 4(%esi), %eax # mmap->base_addr_low 249 movl %eax, (%rdi) 250 251 movl 8(%esi), %eax # mmap->base_addr_high 252 movl %eax, 4(%rdi) 253 254 movl 12(%esi), %eax # mmap->length_low 255 movl %eax, 8(%rdi) 256 257 movl 16(%esi), %eax # mmap->length_high 258 movl %eax, 12(%rdi) 259 260 movl 20(%esi), %eax # mmap->type 261 movl %eax, 16(%rdi) 262 263 movl (%esi), %eax # mmap->size 264 addl $0x4, %eax 265 addl %eax, %esi 266 subl %eax, %ecx 267 addq $MEMMAP_E820_RECORD_SIZE, %rdi 268 incl %edx 269 jmp mmap_loop 270 271 mmap_end: 272 273 mmap_invalid: 274 movl %edx, e820counter 275 276 invalid_boot: 277 278 #ifdef CONFIG_SMP 279 280 # copy AP bootstrap routines below 1 MB 281 282 movq $BOOT_OFFSET, %rsi 283 movq $AP_BOOT_OFFSET, %rdi 284 movq $_hardcoded_unmapped_size, %rcx 285 rep movsb 286 287 #endif 288 289 call main_bsp # never returns 178 179 # arch_pre_main(grub_eax, grub_ebx) 180 xorq %rdi, %rdi 181 movl grub_eax, %edi 182 xorq %rsi, %rsi 183 movl grub_ebx, %esi 184 call arch_pre_main 185 186 call main_bsp 187 188 # Not reached. 290 189 291 190 cli -
kernel/arch/ia32/include/arch.h
rc22e964 r5d8d71e 1 1 /* 2 * Copyright (c) 200 5Martin Decky2 * Copyright (c) 2009 Martin Decky 3 3 * All rights reserved. 4 4 * … … 36 36 #define KERN_ia32_ARCH_H_ 37 37 38 #include < arch/boot/multiboot.h>38 #include <genarch/multiboot/multiboot.h> 39 39 40 extern void arch_pre_main(uint32_t signature, const mb_info_t *mi);40 extern void arch_pre_main(uint32_t, const multiboot_info_t *); 41 41 42 42 #endif -
kernel/arch/ia32/include/boot/boot.h
rc22e964 r5d8d71e 43 43 #define MULTIBOOT_HEADER_FLAGS 0x00010003 44 44 45 #define MULTIBOOT_LOADER_MAGIC 0x2BADB00246 47 45 #ifndef __ASM__ 48 46 49 47 #ifdef CONFIG_SMP 50 48 49 /* This is only a symbol so the type is dummy. Obtain the value using &. */ 51 50 extern int _hardcoded_unmapped_size; 52 51 -
kernel/arch/ia32/src/ia32.c
rc22e964 r5d8d71e 41 41 #include <arch/pm.h> 42 42 43 #include <genarch/multiboot/multiboot.h> 43 44 #include <genarch/drivers/legacy/ia32/io.h> 44 45 #include <genarch/drivers/ega/ega.h> … … 67 68 #include <sysinfo/sysinfo.h> 68 69 #include <arch/boot/boot.h> 69 #include <string.h>70 #include <macros.h>71 70 72 71 #ifdef CONFIG_SMP … … 74 73 #endif 75 74 76 /** Extract command name from the multiboot module command line. 77 * 78 * @param buf Destination buffer (will always null-terminate). 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. 75 /** Perform ia32-specific initialization before main_bsp() is called. 114 76 * 115 77 * @param signature Should contain the multiboot signature. 116 78 * @param mi Pointer to the multiboot information structure. 117 79 */ 118 void arch_pre_main(uint32_t signature, const mb_info_t *mi) 119 { 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. */ 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; 169 mme = ((void *) mme) + size; 170 mmap_length -= size; 171 } 172 173 e820counter = i; 174 } else 175 e820counter = 0; 80 void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) 81 { 82 /* Parse multiboot information obtained from the bootloader. */ 83 multiboot_info_parse(signature, mi); 176 84 177 85 #ifdef CONFIG_SMP -
kernel/genarch/Makefile.inc
rc22e964 r5d8d71e 102 102 endif 103 103 104 ifeq ($(CONFIG_MULTIBOOT), y) 105 GENARCH_SOURCES += \ 106 genarch/src/multiboot/multiboot.c 107 endif 108 104 109 ifeq ($(CONFIG_EGA), y) 105 110 GENARCH_SOURCES += \ -
kernel/genarch/include/multiboot/multiboot.h
rc22e964 r5d8d71e 1 1 /* 2 * Copyright (c) 200 5 Martin Decky2 * Copyright (c) 2009 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup ia3229 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_ ia32_MULTIBOOT_H__36 #define KERN_ ia32_MULTIBOOT_H_35 #ifndef KERN_MULTIBOOT_H_ 36 #define KERN_MULTIBOOT_H_ 37 37 38 38 #include <arch/types.h> 39 39 #include <arch/boot/memmap.h> 40 40 41 /** Multiboot 32-bit address. */ 42 typedef uint32_t mbaddr_t; 43 41 44 /** Multiboot mod structure */ 42 45 typedef struct { 43 uintptr_t start;44 uintptr_t end;45 char *string;46 mbaddr_t start; 47 mbaddr_t end; 48 mbaddr_t string; 46 49 uint32_t reserved; 47 } __attribute__ ((packed)) m b_mod_t;50 } __attribute__ ((packed)) multiboot_mod_t; 48 51 49 52 /** Multiboot mmap structure */ … … 51 54 uint32_t size; 52 55 e820memmap_t mm_info; 53 } __attribute__ ((packed)) m b_mmap_t;56 } __attribute__ ((packed)) multiboot_mmap_t; 54 57 55 58 /** Multiboot information structure */ 56 59 typedef struct { 57 60 uint32_t flags; 58 uint ptr_t mem_lower;59 uint ptr_t mem_upper;61 uint32_t mem_lower; 62 uint32_t mem_upper; 60 63 61 64 uint32_t boot_device; 62 char *cmdline;65 uint32_t cmdline; 63 66 64 67 uint32_t mods_count; 65 mb _mod_t *mods_addr;68 mbaddr_t mods_addr; 66 69 67 70 uint32_t syms[4]; 68 71 69 72 uint32_t mmap_length; 70 mb _mmap_t *mmap_addr;73 mbaddr_t mmap_addr; 71 74 72 75 /* ... */ 73 } __attribute__ ((packed)) m b_info_t;76 } __attribute__ ((packed)) multiboot_info_t; 74 77 75 enum m b_info_flags {78 enum multiboot_info_flags { 76 79 MBINFO_FLAGS_MEM = 0x01, 77 80 MBINFO_FLAGS_BOOT = 0x02, … … 85 88 }; 86 89 90 #define MULTIBOOT_LOADER_MAGIC 0x2BADB002 91 92 /** Convert 32-bit multiboot address to a pointer. */ 93 #define MULTIBOOT_PTR(mba) ((void *)(uintptr_t) (mba)) 94 95 extern void multiboot_info_parse(uint32_t, const multiboot_info_t *); 96 87 97 #endif 88 98
Note:
See TracChangeset
for help on using the changeset viewer.