static void sfi_ap_init(sfi_info_t *sfi_info) { #ifndef NO_SMP u32 ebx; size_t i; cpuid (1, 0, NULL, &ebx, NULL, NULL); uint8 this_apic_id = ebx >> 24; for(i = 0; i < SFI_NUM_CPUS_ENTRIES(sfi_info->cpus_table); i++) { uint8 apic_id = sfi_info->cpus_table->lapic_ids[i]; if (this_apic_id == apic_id) { com1_printf("Skipping apic_id = %u\n", (size_t)apic_id); continue; } if (smp_boot_cpu (apic_id, APIC_VER_NEW)) { CPU_to_APIC[mp_num_cpus] = apic_id; APIC_to_CPU[apic_id] = mp_num_cpus; mp_num_cpus++; } else { com1_printf("Failed to initialize AP core\n"); panic("Failed to initialize AP core\n"); } } #else #endif }
void vmx_vm_exit_reason (void) { uint32 reason = vmread (VMXENC_EXIT_REASON); uint32 qualif = vmread (VMXENC_EXIT_QUAL); uint32 intinf = vmread (VMXENC_VM_EXIT_INTERRUPT_INFO); uint32 ercode = vmread (VMXENC_VM_EXIT_INTERRUPT_ERRCODE); /******************************************************* * uint32 inslen = vmread (VMXENC_VM_EXIT_INSTR_LEN); * * uint32 insinf = vmread (VMXENC_VM_EXIT_INSTR_INFO); * *******************************************************/ uint8 crnum, type, reg, vec; switch (reason) { case 0x0: /* Exception or NMI */ if (intinf & 0x80000000) { char *cause; vec = intinf & 0xFF; type = (intinf & 0x700) >> 8; switch (type) { case 0: cause = "external interrupt"; break; case 2: cause = "NMI"; break; case 3: cause = "hardware exception"; break; case 6: cause = "software exception"; break; default: cause = "unknown"; break; } com1_printf (" EXCEPTION: vector=%.2X code=%X cause=%s\n", vec, (intinf & 0x800) ? ercode : 0, cause); if (vec == 0xE && type == 3) { /* Page fault */ com1_printf (" Page Fault at %.8X\n", qualif); } } break; case 0x1C: /* Control Register access */ crnum = qualif & 0xF; type = (qualif & 0x30) >> 4; reg = (qualif & 0xF00) >> 8; switch (type) { case 0: com1_printf (" CR WRITE: MOV %%%s, %%CR%d\n", vmx_cr_access_register_names[reg], crnum); break; case 1: com1_printf (" CR READ: MOV %%CR%d, %%%s\n", crnum, vmx_cr_access_register_names[reg]); break; case 2: com1_printf (" CLTS\n"); break; case 3: com1_printf (" LMSW\n"); break; } break; }
void cstart(APTR load_addr, APTR real_addr, ULONG kernel_size, APTR residual, APTR ofw, ULONG orig_MSR) { int i=1; struct CallOS callos; /* Define CallOS on stack temporarly. It is allowed since Launch kernel from this function while local variables remains reserved */ CallOS = &callos; ULONG mem_avail; //=findMem(); /* Assume 16MB of ram */ com1_printf("\n%s\n",&core_id); com1_printf("\n[startup] load_addr : $%x" "\n[startup] real_addr : $%x" "\n[startup] kernel_size: %dKB" "\n[startup] residual : $%x" "\n[startup] ofw_iface : $%x\n", load_addr, real_addr, (kernel_size+1023) >> 10, residual, ofw); mem_avail = findMem(ofw, orig_MSR); com1_printf("[startup] memory detected: %dMB\n", mem_avail >> 20); /* Multiboot structure is forced to appear at physical address location 0x00000008. It is allowable since the exception vectors are at 0xfff00100 and will be fixed later. By this time we create multiboot here. */ struct multiboot *mb = (struct multiboot*)0x8; struct mb_mmap *mmap = (struct mb_mmap*)(0x8 + sizeof(struct multiboot)); /* Prepare multiboot structure */ mb->flags = MB_FLAGS_LDRNAME | MB_FLAGS_CMDLINE | MB_FLAGS_MMAP; mb->loader_name = "PowerPC bootloader"; mb->cmdline = ""; mb->mmap_addr = (ULONG)mmap; mb->mmap_length = ((mem_avail > 16*1024*1024) ? 2 : 1) * sizeof(struct mb_mmap); /* Do mmap setup. Usually we have 1 or 2 entries, the first is the DMA memory and the second is everything else. */ mmap[0].size = sizeof(struct mb_mmap) - 4; mmap[0].type = MMAP_TYPE_RAM; mmap[0].addr = 0x4000; mmap[0].addr_high = 0; mmap[0].len = (ULONG)real_addr - 0x4000; mmap[0].len_high = 0; if (mem_avail > 16*1024*1024) { mmap[1].size = sizeof(struct mb_mmap) - 4; mmap[1].type = MMAP_TYPE_RAM; mmap[1].addr = 16*1024*1024; mmap[1].addr_high = 0; mmap[1].len = mem_avail - 16*1024*1024; mmap[1].len_high = 0; } // cmain(MULTIBOOT_BOOTLOADER_MAGIC, (ULONG)mb); do {} while(1); }