Changeset 5133
- Timestamp:
- Feb 20, 2010 10:38:16 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/cpu/x86/lapic/lapic_cpu_init.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cpu/x86/lapic/lapic_cpu_init.c
r4890 r5133 20 20 #if CONFIG_RAMBASE >= 0x100000 21 21 /* This is a lot more paranoid now, since Linux can NOT handle 22 * being told there is a CPU when none exists. So any errors 23 * will return 0, meaning no CPU. 22 * being told there is a CPU when none exists. So any errors 23 * will return 0, meaning no CPU. 24 24 * 25 25 * We actually handling that case by noting which cpus startup 26 26 * and not telling anyone about the ones that dont. 27 */ 27 */ 28 28 static unsigned long get_valid_start_eip(unsigned long orig_start_eip) 29 29 { 30 return (unsigned long)orig_start_eip & 0xffff; // 16 bit to avoid 0xa0000 30 return (unsigned long)orig_start_eip & 0xffff; // 16 bit to avoid 0xa0000 31 31 } 32 32 #endif … … 40 40 extern char _secondary_start[]; 41 41 42 static void copy_secondary_start_to_1m_below(void) 42 static void copy_secondary_start_to_1m_below(void) 43 43 { 44 44 #if CONFIG_RAMBASE >= 0x100000 45 extern char _secondary_start_end[];46 unsigned long code_size;47 unsigned long start_eip;48 49 /* _secondary_start need to be masked 20 above bit, because 16 bit code in secondary.S50 Also We need to copy the _secondary_start to the below 1M region51 */52 start_eip = get_valid_start_eip((unsigned long)_secondary_start);53 code_size = (unsigned long)_secondary_start_end - (unsigned long)_secondary_start;45 extern char _secondary_start_end[]; 46 unsigned long code_size; 47 unsigned long start_eip; 48 49 /* _secondary_start need to be masked 20 above bit, because 16 bit code in secondary.S 50 Also We need to copy the _secondary_start to the below 1M region 51 */ 52 start_eip = get_valid_start_eip((unsigned long)_secondary_start); 53 code_size = (unsigned long)_secondary_start_end - (unsigned long)_secondary_start; 54 54 55 55 #if CONFIG_HAVE_ACPI_RESUME == 1 … … 58 58 lowmem_backup = malloc(code_size); 59 59 lowmem_backup_ptr = (char *)start_eip; 60 60 61 61 if (lowmem_backup == NULL) 62 62 die("Out of backup memory\n"); 63 63 64 memcpy(lowmem_backup, lowmem_backup_ptr, lowmem_backup_size);65 #endif 66 /* copy the _secondary_start to the ram below 1M*/67 memcpy((unsigned char *)start_eip, (unsigned char *)_secondary_start, code_size);68 69 printk_debug("start_eip=0x%08lx, offset=0x%08lx, code_size=0x%08lx\n", start_eip, ((unsigned long)_secondary_start - start_eip), code_size);64 memcpy(lowmem_backup, lowmem_backup_ptr, lowmem_backup_size); 65 #endif 66 /* copy the _secondary_start to the ram below 1M*/ 67 memcpy((unsigned char *)start_eip, (unsigned char *)_secondary_start, code_size); 68 69 printk_debug("start_eip=0x%08lx, offset=0x%08lx, code_size=0x%08lx\n", start_eip, ((unsigned long)_secondary_start - start_eip), code_size); 70 70 #endif 71 71 } … … 76 76 unsigned long send_status, accept_status, start_eip; 77 77 int j, num_starts, maxlvt; 78 78 79 79 /* 80 80 * Starting actual IPI sequence... … … 91 91 * Send IPI 92 92 */ 93 93 94 94 lapic_write_around(LAPIC_ICR, LAPIC_INT_LEVELTRIG | LAPIC_INT_ASSERT 95 95 | LAPIC_DM_INIT); … … 105 105 printk_err("CPU %ld: First apic write timed out. Disabling\n", 106 106 apicid); 107 // too bad. 107 // too bad. 108 108 printk_err("ESR is 0x%lx\n", lapic_read(LAPIC_ESR)); 109 109 if (lapic_read(LAPIC_ESR)) { … … 123 123 /* Send IPI */ 124 124 lapic_write_around(LAPIC_ICR, LAPIC_INT_LEVELTRIG | LAPIC_DM_INIT); 125 125 126 126 printk_spew("Waiting for send to finish...\n"); 127 127 timeout = 0; … … 134 134 printk_err("CPU %ld: Second apic write timed out. Disabling\n", 135 135 apicid); 136 // too bad. 136 // too bad. 137 137 return 0; 138 138 } … … 245 245 /* Get an index for the new processor */ 246 246 index = ++last_cpu_index; 247 247 248 248 /* Find end of the new processors stack */ 249 249 #if (CONFIG_RAMTOP>0x100000) && (CONFIG_RAMBASE < 0x100000) && ((CONFIG_CONSOLE_VGA==1) || (CONFIG_PCI_ROM_RUN == 1)) 250 if(index<1) { // only keep bsp on low 250 if(index<1) { // only keep bsp on low 251 251 stack_end = ((unsigned long)_estack) - (CONFIG_STACK_SIZE*index) - sizeof(struct cpu_info); 252 252 } else { … … 266 266 #endif 267 267 268 268 269 269 /* Record the index and which cpu structure we are using */ 270 270 info = (struct cpu_info *)stack_end; … … 340 340 printk_spew("Deasserting INIT.\n"); 341 341 /* Deassert the LAPIC INIT */ 342 lapic_write_around(LAPIC_ICR2, SET_LAPIC_DEST_FIELD(id)); 342 lapic_write_around(LAPIC_ICR2, SET_LAPIC_DEST_FIELD(id)); 343 343 lapic_write_around(LAPIC_ICR, LAPIC_INT_LEVELTRIG | LAPIC_DM_INIT); 344 344 … … 392 392 #if CONFIG_SERIAL_CPU_INIT == 0 393 393 if(cpu==bsp_cpu) { 394 continue; 394 continue; 395 395 } 396 396 #endif … … 438 438 } 439 439 if (!cpu->initialized) { 440 printk_err("CPU 0x%02x did not initialize!\n", 440 printk_err("CPU 0x%02x did not initialize!\n", 441 441 cpu->path.apic.apic_id); 442 442 } … … 481 481 #endif 482 482 483 cpus_ready_for_init(); 483 cpus_ready_for_init(); 484 484 485 485 #if CONFIG_SMP == 1 486 486 #if CONFIG_SERIAL_CPU_INIT == 0 487 487 /* start all aps at first, so we can init ECC all together */ 488 start_other_cpus(cpu_bus, info->cpu);488 start_other_cpus(cpu_bus, info->cpu); 489 489 #endif 490 490 #endif 491 491 492 /* Initialize the bootstrap processor */493 cpu_initialize();492 /* Initialize the bootstrap processor */ 493 cpu_initialize(); 494 494 495 495 #if CONFIG_SMP == 1 496 #if CONFIG_SERIAL_CPU_INIT == 1497 start_other_cpus(cpu_bus, info->cpu);498 #endif496 #if CONFIG_SERIAL_CPU_INIT == 1 497 start_other_cpus(cpu_bus, info->cpu); 498 #endif 499 499 500 500 /* Now wait the rest of the cpus stop*/
Note: See TracChangeset
for help on using the changeset viewer.
