⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ip27-init.c

📁 linux-2.4.29操作系统的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	local_flush_tlb_all();	__flush_cache_all();	local_irq_enable();#if 0	/*	 * Get our bogomips.	 */        calibrate_delay();        smp_store_cpu_info(cpuid);	prom_smp_finish();#endif	printk("Slave cpu booted successfully\n");	CPUMASK_SETB(cpu_online_map, cpu);	atomic_inc(&cpus_booted);	while (!atomic_read(&smp_commenced));	return cpu_idle();}static int __init fork_by_hand(void){	struct pt_regs regs;	/*	 * don't care about the epc and regs settings since	 * we'll never reschedule the forked task.	 */	return do_fork(CLONE_VM|CLONE_PID, 0, &regs, 0);}__init void allowboot(void){	int		num_cpus = 0;	cpuid_t		cpu, mycpuid = getcpuid();	cnodeid_t	cnode;	sn_mp_setup();	/* Master has already done per_cpu_init() */	install_cpuintr(smp_processor_id());#if 0	bte_lateinit();	ecc_init();#endif	replicate_kernel_text(numnodes);	boot_barrier = boot_cpumask;	/* Launch slaves. */	for (cpu = 0; cpu < maxcpus; cpu++) {		struct task_struct *idle;		if (cpu == mycpuid) {			alloc_cpupda(cpu, num_cpus);			num_cpus++;			/* We're already started, clear our bit */			CPUMASK_SETB(cpu_online_map, cpu);			CPUMASK_CLRB(boot_barrier, cpu);			continue;		}		/* Skip holes in CPU space */		if (!CPUMASK_TSTB(boot_cpumask, cpu))			continue;		/*		 * We can't use kernel_thread since we must avoid to		 * reschedule the child.		 */		if (fork_by_hand() < 0)			panic("failed fork for CPU %d", num_cpus);		/*		 * We remove it from the pidhash and the runqueue		 * once we got the process:		 */		idle = init_task.prev_task;		if (!idle)			panic("No idle process for CPU %d", num_cpus);		idle->processor = num_cpus;		idle->cpus_runnable = 1 << cpu; /* we schedule the first task manually */		alloc_cpupda(cpu, num_cpus);		idle->thread.reg31 = (unsigned long) start_secondary;		del_from_runqueue(idle);		unhash_process(idle);		init_tasks[num_cpus] = idle;		/*	 	 * Launch a slave into smp_bootstrap().	 	 * It doesn't take an argument, and we		 * set sp to the kernel stack of the newly		 * created idle process, gp to the proc struct		 * (so that current-> works).	 	 */		LAUNCH_SLAVE(cputonasid(num_cpus),cputoslice(num_cpus),			(launch_proc_t)MAPPED_KERN_RW_TO_K0(smp_bootstrap),			0, (void *)((unsigned long)idle +			KERNEL_STACK_SIZE - 32), (void *)idle);		/*		 * Now optimistically set the mapping arrays. We		 * need to wait here, verify the cpu booted up, then		 * fire up the next cpu.		 */		__cpu_number_map[cpu] = num_cpus;		__cpu_logical_map[num_cpus] = cpu;		CPUMASK_SETB(cpu_online_map, cpu);		num_cpus++;		/*		 * Wait this cpu to start up and initialize its hub,		 * and discover the io devices it will control.		 *		 * XXX: We really want to fire up launch all the CPUs		 * at once.  We have to preserve the order of the		 * devices on the bridges first though.		 */		while (atomic_read(&numstarted) != num_cpus);	}#ifdef LATER	Wait logic goes here.#endif	for (cnode = 0; cnode < numnodes; cnode++) {#if 0		if (cnodetocpu(cnode) == -1) {			printk("Initializing headless hub,cnode %d", cnode);			per_hub_init(cnode);		}#endif	}#if 0	cpu_io_setup();	init_mfhi_war();#endif	smp_num_cpus = num_cpus;}void __init smp_boot_cpus(void){	extern void allowboot(void);	init_new_context(current, &init_mm);	current->processor = 0;	init_idle();	/* smp_tune_scheduling();  XXX */	allowboot();}#else /* CONFIG_SMP */void __init start_secondary(void){	/* XXX Why do we need this empty definition at all?  */}#endif /* CONFIG_SMP */#define	rou_rflag	rou_flagsvoidrouter_recurse(klrou_t *router_a, klrou_t *router_b, int depth){	klrou_t *router;	lboard_t *brd;	int	port;	if (router_a->rou_rflag == 1)		return;	if (depth >= router_distance)		return;	router_a->rou_rflag = 1;	for (port = 1; port <= MAX_ROUTER_PORTS; port++) {		if (router_a->rou_port[port].port_nasid == INVALID_NASID)			continue;		brd = (lboard_t *)NODE_OFFSET_TO_K0(			router_a->rou_port[port].port_nasid,			router_a->rou_port[port].port_offset);		if (brd->brd_type == KLTYPE_ROUTER) {			router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]);			if (router == router_b) {				if (depth < router_distance)					router_distance = depth;			}			else				router_recurse(router, router_b, depth + 1);		}	}	router_a->rou_rflag = 0;}intnode_distance(nasid_t nasid_a, nasid_t nasid_b){	nasid_t nasid;	cnodeid_t cnode;	lboard_t *brd, *dest_brd;	int port;	klrou_t *router, *router_a = NULL, *router_b = NULL;	/* Figure out which routers nodes in question are connected to */	for (cnode = 0; cnode < numnodes; cnode++) {		nasid = COMPACT_TO_NASID_NODEID(cnode);		if (nasid == -1) continue;		brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),					KLTYPE_ROUTER);		if (!brd)			continue;		do {			if (brd->brd_flags & DUPLICATE_BOARD)				continue;			router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]);			router->rou_rflag = 0;			for (port = 1; port <= MAX_ROUTER_PORTS; port++) {				if (router->rou_port[port].port_nasid == INVALID_NASID)					continue;				dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(					router->rou_port[port].port_nasid,					router->rou_port[port].port_offset);				if (dest_brd->brd_type == KLTYPE_IP27) {					if (dest_brd->brd_nasid == nasid_a)						router_a = router;					if (dest_brd->brd_nasid == nasid_b)						router_b = router;				}			}		} while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) );	}	if (router_a == NULL) {		printk("node_distance: router_a NULL\n");		return -1;	}	if (router_b == NULL) {		printk("node_distance: router_b NULL\n");		return -1;	}	if (nasid_a == nasid_b)		return 0;	if (router_a == router_b)		return 1;	router_distance = 100;	router_recurse(router_a, router_b, 2);	return router_distance;}voidinit_topology_matrix(void){	nasid_t nasid, nasid2;	cnodeid_t row, col;	for (row = 0; row < MAX_COMPACT_NODES; row++)		for (col = 0; col < MAX_COMPACT_NODES; col++)			node_distances[row][col] = -1;	for (row = 0; row < numnodes; row++) {		nasid = COMPACT_TO_NASID_NODEID(row);		for (col = 0; col < numnodes; col++) {			nasid2 = COMPACT_TO_NASID_NODEID(col);			node_distances[row][col] = node_distance(nasid, nasid2);		}	}}voiddump_topology(void){	nasid_t nasid;	cnodeid_t cnode;	lboard_t *brd, *dest_brd;	int port;	int router_num = 0;	klrou_t *router;	cnodeid_t row, col;	printk("************** Topology ********************\n");	printk("    ");	for (col = 0; col < numnodes; col++)		printk("%02d ", col);	printk("\n");	for (row = 0; row < numnodes; row++) {		printk("%02d  ", row);		for (col = 0; col < numnodes; col++)			printk("%2d ", node_distances[row][col]);		printk("\n");	}	for (cnode = 0; cnode < numnodes; cnode++) {		nasid = COMPACT_TO_NASID_NODEID(cnode);		if (nasid == -1) continue;		brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),					KLTYPE_ROUTER);		if (!brd)			continue;		do {			if (brd->brd_flags & DUPLICATE_BOARD)				continue;			printk("Router %d:", router_num);			router_num++;			router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]);			for (port = 1; port <= MAX_ROUTER_PORTS; port++) {				if (router->rou_port[port].port_nasid == INVALID_NASID)					continue;				dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(					router->rou_port[port].port_nasid,					router->rou_port[port].port_offset);				if (dest_brd->brd_type == KLTYPE_IP27)					printk(" %d", dest_brd->brd_nasid);				if (dest_brd->brd_type == KLTYPE_ROUTER)					printk(" r");			}			printk("\n");		} while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) );	}}#if 0#define		brd_widgetnum	brd_slot#define NODE_OFFSET_TO_KLINFO(n,off)    ((klinfo_t*) TO_NODE_CAC(n,off))voiddump_klcfg(void){	cnodeid_t       cnode;	int i;	nasid_t         nasid;	lboard_t        *lbptr;	gda_t           *gdap;	gdap = (gda_t *)GDA_ADDR(get_nasid());	if (gdap->g_magic != GDA_MAGIC) {		printk("dumpklcfg_cmd: Invalid GDA MAGIC\n");		return;	}	for (cnode = 0; cnode < MAX_COMPACT_NODES; cnode ++) {		nasid = gdap->g_nasidtable[cnode];		if (nasid == INVALID_NASID)			continue;		printk("\nDumpping klconfig Nasid %d:\n", nasid);		lbptr = KL_CONFIG_INFO(nasid);		while (lbptr) {			printk("    %s, Nasid %d, Module %d, widget 0x%x, partition %d, NIC 0x%x lboard 0x%lx",				"board name here", /* BOARD_NAME(lbptr->brd_type), */				lbptr->brd_nasid, lbptr->brd_module,				lbptr->brd_widgetnum,				lbptr->brd_partition,				(lbptr->brd_nic), lbptr);			if (lbptr->brd_flags & DUPLICATE_BOARD)				printk(" -D");			printk("\n");			for (i = 0; i < lbptr->brd_numcompts; i++) {				klinfo_t *kli;				kli = NODE_OFFSET_TO_KLINFO(NASID_GET(lbptr), lbptr->brd_compts[i]);				printk("        type %2d, flags 0x%04x, diagval %3d, physid %4d, virtid %2d: %s\n",					kli->struct_type,					kli->flags,					kli->diagval,					kli->physid,					kli->virtid,					"comp. name here");					/* COMPONENT_NAME(kli->struct_type)); */			}			lbptr = KLCF_NEXT(lbptr);		}	}	printk("\n");	/* Useful to print router maps also */	for (cnode = 0; cnode < MAX_COMPACT_NODES; cnode ++) {		klrou_t *kr;		int i;        	nasid = gdap->g_nasidtable[cnode];        	if (nasid == INVALID_NASID)            		continue;        	lbptr = KL_CONFIG_INFO(nasid);        	while (lbptr) {			lbptr = find_lboard_class(lbptr, KLCLASS_ROUTER);			if(!lbptr)				break;			if (!KL_CONFIG_DUPLICATE_BOARD(lbptr)) {				printk("%llx -> \n", lbptr->brd_nic);				kr = (klrou_t *)find_first_component(lbptr,					KLSTRUCT_ROU);				for (i = 1; i <= MAX_ROUTER_PORTS; i++) {					printk("[%d, %llx]; ",						kr->rou_port[i].port_nasid,						kr->rou_port[i].port_offset);				}				printk("\n");			}			lbptr = KLCF_NEXT(lbptr);        	}        	printk("\n");    	}	dump_topology();}#endif

⌨️ 快捷键说明

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