setup_64.c

来自「linux 内核源代码」· C语言 代码 · 共 610 行 · 第 1/2 页

C
610
字号
			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 = of_get_property(np, "i-cache-size", NULL);			if (sizep != NULL)				size = *sizep;			lsizep = of_get_property(np, "i-cache-block-size", NULL);			if (lsizep == NULL)				lsizep = of_get_property(np, "i-cache-line-size", 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");	/* Apply the CPUs-specific and firmware specific fixups to kernel	 * text (nop out sections not relevant to this CPU or this firmware)	 */	do_feature_fixups(cur_cpu_spec->cpu_features,			  &__start___ftr_fixup, &__stop___ftr_fixup);	do_feature_fixups(powerpc_firmware_features,			  &__start___fw_ftr_fixup, &__stop___fw_ftr_fixup);	/*	 * Unflatten the device-tree passed by prom_init or kexec	 */	unflatten_device_tree();	/*	 * Fill the ppc64_caches & systemcfg structures with informations 	 * retrieved from the device-tree.	 */	initialize_cache_info();	/*	 * Initialize irq remapping subsystem	 */	irq_early_init();#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()	 */	if (ppc_md.init_early)		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();	/*	 * Register early console	 */	register_early_udbg_console();	/*	 * Initialize xmon	 */	xmon_setup();	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", init_utsname()->version);	printk("-----------------------------------------------------\n");	printk("ppc64_pft_size                = 0x%lx\n", ppc64_pft_size);	printk("physicalMemorySize            = 0x%lx\n", lmb_phys_mem_size());	if (ppc64_caches.dline_size != 0x80)		printk("ppc64_caches.dcache_line_size = 0x%x\n",		       ppc64_caches.dline_size);	if (ppc64_caches.iline_size != 0x80)		printk("ppc64_caches.icache_line_size = 0x%x\n",		       ppc64_caches.iline_size);	if (htab_address)		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");}#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){	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)		setup_panic();	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	if (ppc_md.setup_arch)		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, PAGE_SIZE);#ifdef CONFIG_MODULES	if (size < PERCPU_ENOUGH_ROOM)		size = PERCPU_ENOUGH_ROOM;#endif	for_each_possible_cpu(i) {		ptr = alloc_bootmem_pages_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);	}	/* Now that per_cpu is setup, initialize cpu_sibling_map */	smp_setup_cpu_sibling_map();}#endif#ifdef CONFIG_PPC_INDIRECT_IOstruct ppc_pci_io ppc_pci_io;EXPORT_SYMBOL(ppc_pci_io);#endif /* CONFIG_PPC_INDIRECT_IO */

⌨️ 快捷键说明

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