setup_64.c

来自「LINUX 2.6.17.4的源码」· C语言 代码 · 共 627 行 · 第 1/2 页

C
627
字号
				lsize = *lsizep;			if (sizep == 0 || lsizep == 0)				DBG("Argh, can't find dcache properties ! "				    "sizep: %p, lsizep: %p\n", sizep, lsizep);			ppc64_caches.dsize = size;			ppc64_caches.dline_size = lsize;			ppc64_caches.log_dline_size = __ilog2(lsize);			ppc64_caches.dlines_per_page = PAGE_SIZE / lsize;			size = 0;			lsize = cur_cpu_spec->icache_bsize;			sizep = (u32 *)get_property(np, "i-cache-size", NULL);			if (sizep != NULL)				size = *sizep;			lsizep = (u32 *)get_property(np, ic, NULL);			if (lsizep != NULL)				lsize = *lsizep;			if (sizep == 0 || lsizep == 0)				DBG("Argh, can't find icache properties ! "				    "sizep: %p, lsizep: %p\n", sizep, lsizep);			ppc64_caches.isize = size;			ppc64_caches.iline_size = lsize;			ppc64_caches.log_iline_size = __ilog2(lsize);			ppc64_caches.ilines_per_page = PAGE_SIZE / lsize;		}	}	DBG(" <- initialize_cache_info()\n");}/* * Do some initial setup of the system.  The parameters are those which  * were passed in from the bootloader. */void __init setup_system(void){	DBG(" -> setup_system()\n");#ifdef CONFIG_KEXEC	kdump_move_device_tree();#endif	/*	 * Unflatten the device-tree passed by prom_init or kexec	 */	unflatten_device_tree();#ifdef CONFIG_KEXEC	kexec_setup();	/* requires unflattened device tree. */#endif	/*	 * Fill the ppc64_caches & systemcfg structures with informations	 * retrieved from the device-tree. Need to be called before	 * finish_device_tree() since the later requires some of the	 * informations filled up here to properly parse the interrupt	 * tree.	 * It also sets up the cache line sizes which allows to call	 * routines like flush_icache_range (used by the hash init	 * later on).	 */	initialize_cache_info();#ifdef CONFIG_PPC_RTAS	/*	 * Initialize RTAS if available	 */	rtas_initialize();#endif /* CONFIG_PPC_RTAS */	/*	 * Check if we have an initrd provided via the device-tree	 */	check_for_initrd();	/*	 * Do some platform specific early initializations, that includes	 * setting up the hash table pointers. It also sets up some interrupt-mapping	 * related options that will be used by finish_device_tree()	 */	ppc_md.init_early(); 	/*	 * We can discover serial ports now since the above did setup the	 * hash table management for us, thus ioremap works. We do that early	 * so that further code can be debugged	 */	find_legacy_serial_ports();	/*	 * "Finish" the device-tree, that is do the actual parsing of	 * some of the properties like the interrupt map	 */	finish_device_tree();	/*	 * Initialize xmon	 */#ifdef CONFIG_XMON_DEFAULT	xmon_init(1);#endif	/*	 * Register early console	 */	register_early_udbg_console();	/* Save unparsed command line copy for /proc/cmdline */	strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);	parse_early_param();	check_smt_enabled();	smp_setup_cpu_maps();#ifdef CONFIG_SMP	/* Release secondary cpus out of their spinloops at 0x60 now that	 * we can map physical -> logical CPU ids	 */	smp_release_cpus();#endif	printk("Starting Linux PPC64 %s\n", system_utsname.version);	printk("-----------------------------------------------------\n");	printk("ppc64_pft_size                = 0x%lx\n", ppc64_pft_size);	printk("ppc64_interrupt_controller    = 0x%ld\n",	       ppc64_interrupt_controller);	printk("physicalMemorySize            = 0x%lx\n", lmb_phys_mem_size());	printk("ppc64_caches.dcache_line_size = 0x%x\n",	       ppc64_caches.dline_size);	printk("ppc64_caches.icache_line_size = 0x%x\n",	       ppc64_caches.iline_size);	printk("htab_address                  = 0x%p\n", htab_address);	printk("htab_hash_mask                = 0x%lx\n", htab_hash_mask);#if PHYSICAL_START > 0	printk("physical_start                = 0x%x\n", PHYSICAL_START);#endif	printk("-----------------------------------------------------\n");	DBG(" <- setup_system()\n");}static int ppc64_panic_event(struct notifier_block *this,                             unsigned long event, void *ptr){	ppc_md.panic((char *)ptr);  /* May not return */	return NOTIFY_DONE;}#ifdef CONFIG_IRQSTACKSstatic void __init irqstack_early_init(void){	unsigned int i;	/*	 * interrupt stacks must be under 256MB, we cannot afford to take	 * SLB misses on them.	 */	for_each_possible_cpu(i) {		softirq_ctx[i] = (struct thread_info *)			__va(lmb_alloc_base(THREAD_SIZE,					    THREAD_SIZE, 0x10000000));		hardirq_ctx[i] = (struct thread_info *)			__va(lmb_alloc_base(THREAD_SIZE,					    THREAD_SIZE, 0x10000000));	}}#else#define irqstack_early_init()#endif/* * Stack space used when we detect a bad kernel stack pointer, and * early in SMP boots before relocation is enabled. */static void __init emergency_stack_init(void){	unsigned long limit;	unsigned int i;	/*	 * Emergency stacks must be under 256MB, we cannot afford to take	 * SLB misses on them. The ABI also requires them to be 128-byte	 * aligned.	 *	 * Since we use these as temporary stacks during secondary CPU	 * bringup, we need to get at them in real mode. This means they	 * must also be within the RMO region.	 */	limit = min(0x10000000UL, lmb.rmo_size);	for_each_possible_cpu(i)		paca[i].emergency_sp =		__va(lmb_alloc_base(HW_PAGE_SIZE, 128, limit)) + HW_PAGE_SIZE;}/* * Called into from start_kernel, after lock_kernel has been called. * Initializes bootmem, which is unsed to manage page allocation until * mem_init is called. */void __init setup_arch(char **cmdline_p){	extern void do_init_bootmem(void);	ppc64_boot_msg(0x12, "Setup Arch");	*cmdline_p = cmd_line;	/*	 * Set cache line size based on type of cpu as a default.	 * Systems with OF can look in the properties on the cpu node(s)	 * for a possibly more accurate value.	 */	dcache_bsize = ppc64_caches.dline_size;	icache_bsize = ppc64_caches.iline_size;	/* reboot on panic */	panic_timeout = 180;	if (ppc_md.panic)		atomic_notifier_chain_register(&panic_notifier_list,				&ppc64_panic_block);	init_mm.start_code = PAGE_OFFSET;	init_mm.end_code = (unsigned long) _etext;	init_mm.end_data = (unsigned long) _edata;	init_mm.brk = klimit;		irqstack_early_init();	emergency_stack_init();	stabs_alloc();	/* set up the bootmem stuff with available memory */	do_init_bootmem();	sparse_init();#ifdef CONFIG_DUMMY_CONSOLE	conswitchp = &dummy_con;#endif	ppc_md.setup_arch();	paging_init();	ppc64_boot_msg(0x15, "Setup Done");}/* ToDo: do something useful if ppc_md is not yet setup. */#define PPC64_LINUX_FUNCTION 0x0f000000#define PPC64_IPL_MESSAGE 0xc0000000#define PPC64_TERM_MESSAGE 0xb0000000static void ppc64_do_msg(unsigned int src, const char *msg){	if (ppc_md.progress) {		char buf[128];		sprintf(buf, "%08X\n", src);		ppc_md.progress(buf, 0);		snprintf(buf, 128, "%s", msg);		ppc_md.progress(buf, 0);	}}/* Print a boot progress message. */void ppc64_boot_msg(unsigned int src, const char *msg){	ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_IPL_MESSAGE|src, msg);	printk("[boot]%04x %s\n", src, msg);}/* Print a termination message (print only -- does not stop the kernel) */void ppc64_terminate_msg(unsigned int src, const char *msg){	ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_TERM_MESSAGE|src, msg);	printk("[terminate]%04x %s\n", src, msg);}void cpu_die(void){	if (ppc_md.cpu_die)		ppc_md.cpu_die();}#ifdef CONFIG_SMPvoid __init setup_per_cpu_areas(void){	int i;	unsigned long size;	char *ptr;	/* Copy section for each CPU (we discard the original) */	size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);#ifdef CONFIG_MODULES	if (size < PERCPU_ENOUGH_ROOM)		size = PERCPU_ENOUGH_ROOM;#endif	for_each_possible_cpu(i) {		ptr = alloc_bootmem_node(NODE_DATA(cpu_to_node(i)), size);		if (!ptr)			panic("Cannot allocate cpu data for CPU %d\n", i);		paca[i].data_offset = ptr - __per_cpu_start;		memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);	}}#endif

⌨️ 快捷键说明

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