static u32 cpu_to_drc_index(int cpu) { struct device_node *dn = NULL; const int *indexes; int i; int rc = 1; u32 ret = 0; dn = of_find_node_by_path("/cpus"); if (dn == NULL) goto err; indexes = of_get_property(dn, "ibm,drc-indexes", NULL); if (indexes == NULL) goto err_of_node_put; /* Convert logical cpu number to core number */ i = cpu_core_index_of_thread(cpu); /* * The first element indexes[0] is the number of drc_indexes * returned in the list. Hence i+1 will get the drc_index * corresponding to core number i. */ WARN_ON(i > indexes[0]); ret = indexes[i + 1]; rc = 0; err_of_node_put: of_node_put(dn); err: if (rc) printk(KERN_WARNING "cpu_to_drc_index(%d) failed", cpu); return ret; }
static u32 cpu_to_drc_index(int cpu) { struct device_node *dn = NULL; const int *indexes; int i; int rc = 1; u32 ret = 0; dn = of_find_node_by_path("/cpus"); if (dn == NULL) goto err; indexes = of_get_property(dn, "ibm,drc-indexes", NULL); if (indexes == NULL) goto err_of_node_put; /* */ i = cpu_core_index_of_thread(cpu); /* */ WARN_ON(i > indexes[0]); ret = indexes[i + 1]; rc = 0; err_of_node_put: of_node_put(dn); err: if (rc) printk(KERN_WARNING "cpu_to_drc_index(%d) failed", cpu); return ret; }
void spc_context_init(void) { int i; int linux_cpu = 0; // Linux cpu that will handle spc interrupts for (i = 0; i < fusedos_config->nr_spcs; i++) { memset((void*)(&(spc_context[i].regs)), 0, sizeof(regs_t)); // Taken from bgq_cause_ipi() in bic.c spc_context[i].bic_int_send = (void*)(&_puea->interrupt_send); spc_context[i].bic_value = cpu_thread_in_core(linux_cpu) + 1; spc_context[i].bic_value |= BGQ_BIC_C2C_INTTYPE_EXTERNAL << (63 - 60); spc_context[i].bic_value |= 0x0000000000200000ULL >> cpu_core_index_of_thread(linux_cpu); spc_context[i].ipi_wakeup = 0; spc_context[i].id = i; spc_context[i].start = 0; spc_context[i].command = 0; spc_context[i].mem_bot = __pa(spc_memory) + (uint64_t)(i) * (uint64_t)(SPC_MEMORY_SIZE); //printk("FUSEDOS spc_context_init: spc_context[%d].mem_bot %016llx\n", i, spc_context[i].mem_bot); memset((void*)(spc_context[i].tlb_entry), 0, sizeof(tlb_entry_t) * MAX_TLB_ENTRIES); spc_context[i].tlb_entry_count = 0; memset(spc_context[i].spcm_stack, 0, SPCM_STACK_SIZE); spc_context[i].spcm_sp = 0; spc_context[i].spcm_toc = 0; spc_context[i].ex_code = 0; spc_context[i].spcm_func.funcaddr = 0; spc_context[i].spcm_func.r2 = 0; spc_context[i].ipi_message.fcn = 0; spc_context[i].ipi_message.parm1 = 0; spc_context[i].ipi_message.parm2 = 0; spc_context[i].text_pstart = 0; spc_context[i].text_pend = 0; spc_context[i].data_pstart = 0; spc_context[i].data_pend = 0; spc_context[i].heap_pstart = 0; spc_context[i].heap_pend = 0; spc_context[i].scratch0 = 0; spc_context[i].scratch1 = 0; spc_context[i].scratch2 = 0; spc_context[i].scratch3 = 0; memset(spc_context[i].scratch, 0, SCRATCH_SIZE); } }
static u32 cpu_to_drc_index(int cpu) { struct device_node *dn = NULL; int thread_index; int rc = 1; u32 ret = 0; dn = of_find_node_by_path("/cpus"); if (dn == NULL) goto err; /* Convert logical cpu number to core number */ thread_index = cpu_core_index_of_thread(cpu); if (firmware_has_feature(FW_FEATURE_DRC_INFO)) { struct property *info = NULL; struct of_drc_info drc; int j; u32 num_set_entries; const __be32 *value; info = of_find_property(dn, "ibm,drc-info", NULL); if (info == NULL) goto err_of_node_put; value = of_prop_next_u32(info, NULL, &num_set_entries); if (!value) goto err_of_node_put; for (j = 0; j < num_set_entries; j++) { of_read_drc_info_cell(&info, &value, &drc); if (strncmp(drc.drc_type, "CPU", 3)) goto err; if (thread_index < drc.last_drc_index) break; } ret = drc.drc_index_start + (thread_index * drc.sequential_inc); } else { const __be32 *indexes; indexes = of_get_property(dn, "ibm,drc-indexes", NULL); if (indexes == NULL) goto err_of_node_put; /* * The first element indexes[0] is the number of drc_indexes * returned in the list. Hence thread_index+1 will get the * drc_index corresponding to core number thread_index. */ ret = indexes[thread_index + 1]; } rc = 0; err_of_node_put: of_node_put(dn); err: if (rc) printk(KERN_WARNING "cpu_to_drc_index(%d) failed", cpu); return ret; }