📄 setup.c
字号:
/* * * Common boot and setup code. * * Copyright (C) 2001 PPC64 Team, IBM Corp * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */#include <linux/config.h>#include <linux/module.h>#include <linux/string.h>#include <linux/sched.h>#include <linux/init.h>#include <linux/reboot.h>#include <linux/delay.h>#include <linux/blk.h>#include <linux/ide.h>#include <linux/seq_file.h>#include <linux/ioport.h>#include <linux/console.h>#include <linux/version.h>#include <asm/init.h>#include <asm/io.h>#include <asm/prom.h>#include <asm/processor.h>#include <asm/pgtable.h>#include <asm/bootinfo.h>#include <asm/smp.h>#include <asm/elf.h>#include <asm/machdep.h>#include <asm/iSeries/LparData.h>#include <asm/naca.h>#include <asm/paca.h>#include <asm/ppcdebug.h>#include <asm/time.h>#ifdef CONFIG_KDB#include <linux/kdb.h>#endifextern unsigned long klimit;/* extern void *stab; */extern HTAB htab_data;extern unsigned long loops_per_jiffy;extern int blk_nohighio;extern unsigned long embedded_sysmap_start;extern unsigned long embedded_sysmap_end;int have_of = 1;extern void chrp_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7);extern void chrp_init_map_io_space( void );extern void iSeries_init( void );extern void iSeries_init_early( void );extern void pSeries_init_early( void );extern void pSeriesLP_init_early(void);extern void mm_init_ppc64( void ); unsigned long decr_overclock = 1;unsigned long decr_overclock_proc0 = 1;unsigned long decr_overclock_set = 0;unsigned long decr_overclock_proc0_set = 0;#ifdef CONFIG_XMONextern void xmon_map_scc(void);#endif#ifdef CONFIG_KDBextern void kdb_map_scc(void);#endifchar saved_command_line[256];unsigned char aux_device_present;void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7);int parse_bootinfo(void);#ifdef CONFIG_MAGIC_SYSRQunsigned long SYSRQ_KEY;#endif /* CONFIG_MAGIC_SYSRQ */struct machdep_calls ppc_md;/* * These are used in binfmt_elf.c to put aux entries on the stack * for each elf executable being started. */int dcache_bsize;int icache_bsize;int ucache_bsize;struct console udbg_console = { name: "udbg", write: udbg_console_write, flags: CON_PRINTBUFFER, index: -1,};/* * Do some initial setup of the system. The paramters are those which * were passed in from the bootloader. */void setup_system(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7){ /* This should be fixed properly in kernel/resource.c */ iomem_resource.end = MEM_SPACE_LIMIT; /* pSeries systems are identified in prom.c via OF. */ if ( itLpNaca.xLparInstalled == 1 ) systemcfg->platform = PLATFORM_ISERIES_LPAR; switch (systemcfg->platform) { case PLATFORM_ISERIES_LPAR: iSeries_init_early(); break;#ifdef CONFIG_PPC_PSERIES case PLATFORM_PSERIES: pSeries_init_early();#ifdef CONFIG_BLK_DEV_INITRD initrd_start = initrd_end = 0;#endif parse_bootinfo(); break; case PLATFORM_PSERIES_LPAR: pSeriesLP_init_early();#ifdef CONFIG_BLK_DEV_INITRD initrd_start = initrd_end = 0;#endif parse_bootinfo(); break;#endif } if (systemcfg->platform & PLATFORM_PSERIES) { register_console(&udbg_console); udbg_printf("---- start early boot console ----\n"); } printk("Starting Linux PPC64 %s\n", UTS_RELEASE); printk("-----------------------------------------------------\n"); printk("naca = 0x%p\n", naca); printk("naca->pftSize = 0x%lx\n", naca->pftSize); printk("naca->paca = 0x%lx\n\n", naca->paca); printk("systemcfg = 0x%p\n", systemcfg); printk("systemcfg->platform = 0x%x\n", systemcfg->platform); printk("systemcfg->processor = 0x%x\n", systemcfg->processor); printk("systemcfg->processorCount = 0x%lx\n", systemcfg->processorCount); printk("systemcfg->physicalMemorySize = 0x%lx\n", systemcfg->physicalMemorySize); printk("systemcfg->dCacheL1LineSize = 0x%x\n", systemcfg->dCacheL1LineSize); printk("systemcfg->iCacheL1LineSize = 0x%x\n", systemcfg->iCacheL1LineSize); printk("htab_data.htab = 0x%p\n", htab_data.htab); printk("htab_data.num_ptegs = 0x%lx\n", htab_data.htab_num_ptegs); printk("-----------------------------------------------------\n"); if (systemcfg->platform & PLATFORM_PSERIES) { finish_device_tree(); chrp_init(r3, r4, r5, r6, r7); } mm_init_ppc64(); switch (systemcfg->platform) { case PLATFORM_ISERIES_LPAR: iSeries_init(); break; default: /* The following relies on the device tree being */ /* fully configured. */ parse_cmd_line(r3, r4, r5, r6, r7); } ppc64_boot_msg(0x10, "Setup System");}/* This is called just before console_init(). * It will be obsolete when Linux gets real early console support (2.5?) */void setup_before_console_init(void){ if (systemcfg->platform & PLATFORM_PSERIES) { unregister_console(&udbg_console); udbg_console.next = NULL; udbg_printf("---- end early boot console ----\n"); }}void machine_restart(char *cmd){ ppc_md.restart(cmd);} void machine_power_off(void){ ppc_md.power_off();} void machine_halt(void){ ppc_md.halt();}unsigned long ppc_proc_freq;unsigned long ppc_tb_freq;static int show_cpuinfo(struct seq_file *m, void *v){ unsigned long cpu_id = (unsigned long)v - 1; unsigned int pvr; unsigned short maj; unsigned short min;#ifdef CONFIG_SMP if (cpu_id == NR_CPUS) { if (ppc_md.get_cpuinfo != NULL) ppc_md.get_cpuinfo(m); return 0; } if (!(cpu_online_map & (1<<cpu_id))) return 0;#endif pvr = paca[cpu_id].pvr; maj = (pvr >> 8) & 0xFF; min = pvr & 0xFF; seq_printf(m, "processor\t: %lu\n", cpu_id); seq_printf(m, "cpu\t\t: "); pvr = paca[cpu_id].pvr; switch (PVR_VER(pvr)) { case PV_NORTHSTAR: seq_printf(m, "RS64-II (northstar)\n"); break; case PV_PULSAR: seq_printf(m, "RS64-III (pulsar)\n"); break; case PV_POWER4: seq_printf(m, "POWER4 (gp)\n"); break; case PV_ICESTAR: seq_printf(m, "RS64-III (icestar)\n"); break; case PV_SSTAR: seq_printf(m, "RS64-IV (sstar)\n"); break; case PV_630: seq_printf(m, "POWER3 (630)\n"); break; case PV_630p: seq_printf(m, "POWER3 (630+)\n"); break; case PV_POWER4p: seq_printf(m, "POWER4+ (gq)\n"); break; default: seq_printf(m, "Unknown (%08x)\n", pvr); break; } /* * Assume here that all clock rates are the same in a * smp system. -- Cort */ if (systemcfg->platform != PLATFORM_ISERIES_LPAR) { struct device_node *cpu_node; int *fp; cpu_node = find_type_devices("cpu"); if (cpu_node) { fp = (int *) get_property(cpu_node, "clock-frequency", NULL); if (fp) seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000); } } if (ppc_md.setup_residual != NULL) ppc_md.setup_residual(m, cpu_id); seq_printf(m, "revision\t: %hd.%hd\n\n", maj, min); return 0;}static void *c_start(struct seq_file *m, loff_t *pos){ return *pos <= NR_CPUS ? (void *)((*pos)+1) : NULL;}static void *c_next(struct seq_file *m, void *v, loff_t *pos){ ++*pos; return c_start(m, pos);}static void c_stop(struct seq_file *m, void *v){}struct seq_operations cpuinfo_op = { .start =c_start, .next = c_next, .stop = c_stop, .show = show_cpuinfo,};/* * Fetch the cmd_line from open firmware. */void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7){ char *p;#ifdef CONFIG_BLK_DEV_INITRD if ((initrd_start == 0) && r3 && r4 && r4 != 0xdeadbeef) { initrd_start = (r3 >= KERNELBASE) ? r3 : (unsigned long)__va(r3); initrd_end = initrd_start + r4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -