setup.c

来自「h内核」· C语言 代码 · 共 612 行 · 第 1/2 页

C
612
字号
	    ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec,			       &drift);	if (status != 0 || ticks_per_sec < 100000) {		printk(KERN_WARNING		       "unable to determine platform RTC clock frequency, guessing.\n");		/* PROM gives wrong value for clock freq. so guess */		sn_rtc_cycles_per_second = 1000000000000UL / 30000UL;	} else		sn_rtc_cycles_per_second = ticks_per_sec;	platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR;	/*	 * we set the default root device to /dev/hda	 * to make simulation easy	 */	ROOT_DEV = Root_HDA1;	/*	 * Create the PDAs and NODEPDAs for all the cpus.	 */	sn_init_pdas(cmdline_p);	ia64_mark_idle = &snidle;	/* 	 * For the bootcpu, we do this here. All other cpus will make the	 * call as part of cpu_init in slave cpu initialization.	 */	sn_cpu_init();#ifdef CONFIG_SMP	init_smp_config();#endif	screen_info = sn_screen_info;	sn_timer_init();}/** * sn_init_pdas - setup node data areas * * One time setup for Node Data Area.  Called by sn_setup(). */static void __init sn_init_pdas(char **cmdline_p){	cnodeid_t cnode;	memset(pda->cnodeid_to_nasid_table, -1,	       sizeof(pda->cnodeid_to_nasid_table));	for_each_online_node(cnode)		pda->cnodeid_to_nasid_table[cnode] =		    pxm_to_nasid(nid_to_pxm_map[cnode]);	numionodes = num_online_nodes();	scan_for_ionodes();	/*	 * Allocate & initalize the nodepda for each node.	 */	for_each_online_node(cnode) {		nodepdaindr[cnode] =		    alloc_bootmem_node(NODE_DATA(cnode), sizeof(nodepda_t));		memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));		memset(nodepdaindr[cnode]->phys_cpuid, -1, 		    sizeof(nodepdaindr[cnode]->phys_cpuid));	}	/*	 * Allocate & initialize nodepda for TIOs.  For now, put them on node 0.	 */	for (cnode = num_online_nodes(); cnode < numionodes; cnode++) {		nodepdaindr[cnode] =		    alloc_bootmem_node(NODE_DATA(0), sizeof(nodepda_t));		memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));	}	/*	 * Now copy the array of nodepda pointers to each nodepda.	 */	for (cnode = 0; cnode < numionodes; cnode++)		memcpy(nodepdaindr[cnode]->pernode_pdaindr, nodepdaindr,		       sizeof(nodepdaindr));	/*	 * Set up IO related platform-dependent nodepda fields.	 * The following routine actually sets up the hubinfo struct	 * in nodepda.	 */	for_each_online_node(cnode) {		bte_init_node(nodepdaindr[cnode], cnode);	}	/*	 * Initialize the per node hubdev.  This includes IO Nodes and 	 * headless/memless nodes.	 */	for (cnode = 0; cnode < numionodes; cnode++) {		hubdev_init_node(nodepdaindr[cnode], cnode);	}}/** * sn_cpu_init - initialize per-cpu data areas * @cpuid: cpuid of the caller * * Called during cpu initialization on each cpu as it starts. * Currently, initializes the per-cpu data area for SNIA. * Also sets up a few fields in the nodepda.  Also known as * platform_cpu_init() by the ia64 machvec code. */void __init sn_cpu_init(void){	int cpuid;	int cpuphyid;	int nasid;	int subnode;	int slice;	int cnode;	int i;	u64 shubtype, nasid_bitmask, nasid_shift;	static int wars_have_been_checked;	memset(pda, 0, sizeof(pda));	if (ia64_sn_get_hub_info(0, &shubtype, &nasid_bitmask, &nasid_shift))		BUG();	pda->shub2 = (u8)shubtype;	pda->nasid_bitmask = (u16)nasid_bitmask;	pda->nasid_shift = (u8)nasid_shift;	pda->as_shift = pda->nasid_shift - 2;	/*	 * The boot cpu makes this call again after platform initialization is	 * complete.	 */	if (nodepdaindr[0] == NULL)		return;	cpuid = smp_processor_id();	cpuphyid = get_sapicid();	if (ia64_sn_get_sapic_info(cpuphyid, &nasid, &subnode, &slice))		BUG();	for (i=0; i < MAX_NUMNODES; i++) {		if (nodepdaindr[i]) {			nodepdaindr[i]->phys_cpuid[cpuid].nasid = nasid;			nodepdaindr[i]->phys_cpuid[cpuid].slice = slice;			nodepdaindr[i]->phys_cpuid[cpuid].subnode = subnode;		}	}	cnode = nasid_to_cnodeid(nasid);	pda->p_nodepda = nodepdaindr[cnode];	pda->led_address =	    (typeof(pda->led_address)) (LED0 + (slice << LED_CPU_SHIFT));	pda->led_state = LED_ALWAYS_SET;	pda->hb_count = HZ / 2;	pda->hb_state = 0;	pda->idle_flag = 0;	if (cpuid != 0) {		memcpy(pda->cnodeid_to_nasid_table,		       pdacpu(0)->cnodeid_to_nasid_table,		       sizeof(pda->cnodeid_to_nasid_table));	}	/*	 * Check for WARs.	 * Only needs to be done once, on BSP.	 * Has to be done after loop above, because it uses pda.cnodeid_to_nasid_table[i].	 * Has to be done before assignment below.	 */	if (!wars_have_been_checked) {		sn_check_for_wars();		wars_have_been_checked = 1;	}	pda->shub_1_1_found = shub_1_1_found;	/*	 * Set up addresses of PIO/MEM write status registers.	 */	{		u64 pio1[] = {SH1_PIO_WRITE_STATUS_0, 0, SH1_PIO_WRITE_STATUS_1, 0};		u64 pio2[] = {SH2_PIO_WRITE_STATUS_0, SH2_PIO_WRITE_STATUS_1, 			SH2_PIO_WRITE_STATUS_2, SH2_PIO_WRITE_STATUS_3};		u64 *pio;		pio = is_shub1() ? pio1 : pio2;		pda->pio_write_status_addr = (volatile unsigned long *) LOCAL_MMR_ADDR(pio[slice]);		pda->pio_write_status_val = is_shub1() ? SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK : 0;	}	/*	 * WAR addresses for SHUB 1.x.	 */	if (local_node_data->active_cpu_count++ == 0 && is_shub1()) {		int buddy_nasid;		buddy_nasid =		    cnodeid_to_nasid(numa_node_id() ==				     num_online_nodes() - 1 ? 0 : numa_node_id() + 1);		pda->pio_shub_war_cam_addr =		    (volatile unsigned long *)GLOBAL_MMR_ADDR(nasid,							      SH1_PI_CAM_CONTROL);	}}/* * Scan klconfig for ionodes.  Add the nasids to the * physical_node_map and the pda and increment numionodes. */static void __init scan_for_ionodes(void){	int nasid = 0;	lboard_t *brd;	/* Setup ionodes with memory */	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {		char *klgraph_header;		cnodeid_t cnodeid;		if (physical_node_map[nasid] == -1)			continue;		cnodeid = -1;		klgraph_header = __va(ia64_sn_get_klconfig_addr(nasid));		if (!klgraph_header) {			if (IS_RUNNING_ON_SIMULATOR())				continue;			BUG();	/* All nodes must have klconfig tables! */		}		cnodeid = nasid_to_cnodeid(nasid);		root_lboard[cnodeid] = (lboard_t *)		    NODE_OFFSET_TO_LBOARD((nasid),					  ((kl_config_hdr_t					    *) (klgraph_header))->					  ch_board_info);	}	/* Scan headless/memless IO Nodes. */	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {		/* if there's no nasid, don't try to read the klconfig on the node */		if (physical_node_map[nasid] == -1)			continue;		brd = find_lboard_any((lboard_t *)				      root_lboard[nasid_to_cnodeid(nasid)],				      KLTYPE_SNIA);		if (brd) {			brd = KLCF_NEXT_ANY(brd);	/* Skip this node's lboard */			if (!brd)				continue;		}		brd = find_lboard_any(brd, KLTYPE_SNIA);		while (brd) {			pda->cnodeid_to_nasid_table[numionodes] =			    brd->brd_nasid;			physical_node_map[brd->brd_nasid] = numionodes;			root_lboard[numionodes] = brd;			numionodes++;			brd = KLCF_NEXT_ANY(brd);			if (!brd)				break;			brd = find_lboard_any(brd, KLTYPE_SNIA);		}	}	/* Scan for TIO nodes. */	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {		/* if there's no nasid, don't try to read the klconfig on the node */		if (physical_node_map[nasid] == -1)			continue;		brd = find_lboard_any((lboard_t *)				      root_lboard[nasid_to_cnodeid(nasid)],				      KLTYPE_TIO);		while (brd) {			pda->cnodeid_to_nasid_table[numionodes] =			    brd->brd_nasid;			physical_node_map[brd->brd_nasid] = numionodes;			root_lboard[numionodes] = brd;			numionodes++;			brd = KLCF_NEXT_ANY(brd);			if (!brd)				break;			brd = find_lboard_any(brd, KLTYPE_TIO);		}	}}intnasid_slice_to_cpuid(int nasid, int slice){	long cpu;		for (cpu=0; cpu < NR_CPUS; cpu++) 		if (nodepda->phys_cpuid[cpu].nasid == nasid && nodepda->phys_cpuid[cpu].slice == slice)			return cpu;	return -1;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?