3 * Common boot and setup code.
5 * Copyright (C) 2001 PPC64 Team, IBM Corp
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
15 #include <linux/config.h>
16 #include <linux/module.h>
17 #include <linux/string.h>
18 #include <linux/sched.h>
19 #include <linux/init.h>
20 #include <linux/reboot.h>
21 #include <linux/delay.h>
22 #include <linux/initrd.h>
23 #include <linux/ide.h>
24 #include <linux/seq_file.h>
25 #include <linux/ioport.h>
26 #include <linux/console.h>
27 #include <linux/version.h>
28 #include <linux/tty.h>
29 #include <linux/root_dev.h>
30 #include <linux/notifier.h>
31 #include <linux/cpu.h>
32 #include <linux/unistd.h>
35 #include <asm/processor.h>
36 #include <asm/pgtable.h>
37 #include <asm/bootinfo.h>
40 #include <asm/machdep.h>
41 #include <asm/iSeries/LparData.h>
44 #include <asm/ppcdebug.h>
46 #include <asm/cputable.h>
47 #include <asm/sections.h>
48 #include <asm/btext.h>
49 #include <asm/nvram.h>
50 #include <asm/setup.h>
51 #include <asm/system.h>
53 #include <asm/iommu.h>
56 #define DBG(fmt...) udbg_printf(fmt)
62 * Here are some early debugging facilities. You can enable one
63 * but your kernel will not boot on anything else if you do so
66 /* This one is for use on LPAR machines that support an HVC console
69 extern void udbg_init_debug_lpar(void);
70 /* This one is for use on Apple G5 machines
72 extern void udbg_init_pmac_realmode(void);
73 /* That's RTAS panel debug */
74 extern void call_rtas_display_status_delay(unsigned char c);
76 #define EARLY_DEBUG_INIT() do {} while(0)
79 #define EARLY_DEBUG_INIT() udbg_init_debug_lpar()
80 #define EARLY_DEBUG_INIT() udbg_init_pmac_realmode()
81 #define EARLY_DEBUG_INIT() \
82 do { ppc_md.udbg_putc = call_rtas_display_status_delay; } while(0)
85 /* extern void *stab; */
86 extern HTAB htab_data;
87 extern unsigned long klimit;
89 extern void mm_init_ppc64(void);
90 extern int idle_setup(void);
91 extern void stab_initialize(unsigned long stab);
92 extern void htab_initialize(void);
93 extern void early_init_devtree(void *flat_dt);
94 extern void unflatten_device_tree(void);
96 unsigned long decr_overclock = 1;
97 unsigned long decr_overclock_proc0 = 1;
98 unsigned long decr_overclock_set = 0;
99 unsigned long decr_overclock_proc0_set = 0;
106 * These are used in binfmt_elf.c to put aux entries on the stack
107 * for each elf executable being started.
113 /* The main machine-dep calls structure
115 struct machdep_calls ppc_md;
117 #ifdef CONFIG_MAGIC_SYSRQ
118 unsigned long SYSRQ_KEY;
119 #endif /* CONFIG_MAGIC_SYSRQ */
122 static int ppc64_panic_event(struct notifier_block *, unsigned long, void *);
123 static struct notifier_block ppc64_panic_block = {
124 .notifier_call = ppc64_panic_event,
125 .priority = INT_MIN /* may not return; must be done last */
129 * Perhaps we can put the pmac screen_info[] here
130 * on pmac as well so we don't need the ifdef's.
131 * Until we get multiple-console support in here
133 * Maybe tie it to serial consoles, since this is really what
134 * these processors use on existing boards. -- Dan
136 struct screen_info screen_info = {
139 .orig_video_cols = 80,
140 .orig_video_lines = 25,
141 .orig_video_isVGA = 1,
142 .orig_video_points = 16
146 * Initialize the PPCDBG state. Called before relocation has been enabled.
148 void __init ppcdbg_initialize(void)
150 naca->debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | */
151 /* PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */;
155 * Early boot console based on udbg
157 static struct console udbg_console = {
159 .write = udbg_console_write,
160 .flags = CON_PRINTBUFFER,
163 static int early_console_initialized;
165 void __init disable_early_printk(void)
167 if (!early_console_initialized)
169 unregister_console(&udbg_console);
170 early_console_initialized = 0;
173 #if defined(CONFIG_PPC_MULTIPLATFORM) && defined(CONFIG_SMP)
175 static int smt_enabled_cmdline;
177 /* Look for ibm,smt-enabled OF option */
178 static void check_smt_enabled(void)
180 struct device_node *dn;
183 /* Allow the command line to overrule the OF option */
184 if (smt_enabled_cmdline)
187 dn = of_find_node_by_path("/options");
190 smt_option = (char *)get_property(dn, "ibm,smt-enabled", NULL);
193 if (!strcmp(smt_option, "on"))
194 smt_enabled_at_boot = 1;
195 else if (!strcmp(smt_option, "off"))
196 smt_enabled_at_boot = 0;
201 /* Look for smt-enabled= cmdline option */
202 static int __init early_smt_enabled(char *p)
204 smt_enabled_cmdline = 1;
209 if (!strcmp(p, "on") || !strcmp(p, "1"))
210 smt_enabled_at_boot = 1;
211 else if (!strcmp(p, "off") || !strcmp(p, "0"))
212 smt_enabled_at_boot = 0;
216 early_param("smt-enabled", early_smt_enabled);
219 * setup_cpu_maps - initialize the following cpu maps:
224 * Having the possible map set up early allows us to restrict allocations
225 * of things like irqstacks to num_possible_cpus() rather than NR_CPUS.
227 * We do not initialize the online map here; cpus set their own bits in
228 * cpu_online_map as they come up.
230 * This function is valid only for Open Firmware systems. finish_device_tree
231 * must be called before using this.
233 * While we're here, we may as well set the "physical" cpu ids in the paca.
235 static void __init setup_cpu_maps(void)
237 struct device_node *dn = NULL;
242 while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) {
244 int j, len = sizeof(u32), nthreads;
246 intserv = (u32 *)get_property(dn, "ibm,ppc-interrupt-server#s",
249 intserv = (u32 *)get_property(dn, "reg", NULL);
251 nthreads = len / sizeof(u32);
253 for (j = 0; j < nthreads && cpu < NR_CPUS; j++) {
255 * Only spin up secondary threads if SMT is enabled.
256 * We must leave space in the logical map for the
259 if (j == 0 || smt_enabled_at_boot) {
260 cpu_set(cpu, cpu_present_map);
261 set_hard_smp_processor_id(cpu, intserv[j]);
263 cpu_set(cpu, cpu_possible_map);
269 * On pSeries LPAR, we need to know how many cpus
270 * could possibly be added to this partition.
272 if (systemcfg->platform == PLATFORM_PSERIES_LPAR &&
273 (dn = of_find_node_by_path("/rtas"))) {
274 int num_addr_cell, num_size_cell, maxcpus;
277 num_addr_cell = prom_n_addr_cells(dn);
278 num_size_cell = prom_n_size_cells(dn);
280 ireg = (unsigned int *)
281 get_property(dn, "ibm,lrdr-capacity", NULL);
286 maxcpus = ireg[num_addr_cell + num_size_cell];
288 /* Double maxcpus for processors which have SMT capability */
289 if (cur_cpu_spec->cpu_features & CPU_FTR_SMT)
292 if (maxcpus > NR_CPUS) {
294 "Partition configured for %d cpus, "
295 "operating system maximum is %d.\n",
299 printk(KERN_INFO "Partition configured for %d cpus.\n",
302 for (cpu = 0; cpu < maxcpus; cpu++)
303 cpu_set(cpu, cpu_possible_map);
309 * Do the sibling map; assume only two threads per processor.
312 cpu_set(cpu, cpu_sibling_map[cpu]);
313 if (cur_cpu_spec->cpu_features & CPU_FTR_SMT)
314 cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]);
317 systemcfg->processorCount = num_present_cpus();
319 #endif /* defined(CONFIG_PPC_MULTIPLATFORM) && defined(CONFIG_SMP) */
322 #ifdef CONFIG_PPC_MULTIPLATFORM
324 extern struct machdep_calls pSeries_md;
325 extern struct machdep_calls pmac_md;
327 /* Ultimately, stuff them in an elf section like initcalls... */
328 static struct machdep_calls __initdata *machines[] = {
329 #ifdef CONFIG_PPC_PSERIES
331 #endif /* CONFIG_PPC_PSERIES */
332 #ifdef CONFIG_PPC_PMAC
334 #endif /* CONFIG_PPC_PMAC */
339 * Early initialization entry point. This is called by head.S
340 * with MMU translation disabled. We rely on the "feature" of
341 * the CPU that ignores the top 2 bits of the address in real
342 * mode so we can access kernel globals normally provided we
343 * only toy with things in the RMO region. From here, we do
344 * some early parsing of the device-tree to setup out LMB
345 * data structures, and allocate & initialize the hash table
346 * and segment tables so we can start running with translation
349 * It is this function which will call the probe() callback of
350 * the various platform types and copy the matching one to the
351 * global ppc_md structure. Your platform can eventually do
352 * some very early initializations from the probe() routine, but
353 * this is not recommended, be very careful as, for example, the
354 * device-tree is not accessible via normal means at this point.
357 void __init early_setup(unsigned long dt_ptr)
359 struct paca_struct *lpaca = get_paca();
360 static struct machdep_calls **mach;
363 * Enable early debugging if any specified (see top of
368 DBG(" -> early_setup()\n");
371 * Fill the default DBG level in naca (do we want to keep
372 * that old mecanism around forever ?)
377 * Do early initializations using the flattened device
378 * tree, like retreiving the physical memory map or
379 * calculating/retreiving the hash table size
381 early_init_devtree(__va(dt_ptr));
384 * Iterate all ppc_md structures until we find the proper
385 * one for the current machine type
387 DBG("Probing machine type for platform %x...\n",
388 systemcfg->platform);
390 for (mach = machines; *mach; mach++) {
391 if ((*mach)->probe(systemcfg->platform))
394 /* What can we do if we didn't find ? */
396 DBG("No suitable machine found !\n");
401 /* our udbg callbacks got overriden by the above, let's put them
402 * back in. Ultimately, I want those things to be split from the
407 DBG("Found, Initializing memory management...\n");
410 * Initialize stab / SLB management
412 stab_initialize(lpaca->stab_real);
415 * Initialize the MMU Hash table and create the linear mapping
420 DBG(" <- early_setup()\n");
425 * Initialize some remaining members of the naca and systemcfg structures
426 * (at least until we get rid of them completely). This is mostly some
427 * cache informations about the CPU that will be used by cache flush
428 * routines and/or provided to userland
430 static void __init initialize_naca(void)
432 struct device_node *np;
433 unsigned long num_cpus = 0;
435 DBG(" -> initialize_naca()\n");
437 for (np = NULL; (np = of_find_node_by_type(np, "cpu"));) {
440 /* We're assuming *all* of the CPUs have the same
441 * d-cache and i-cache sizes... -Peter
444 if ( num_cpus == 1 ) {
449 /* Then read cache informations */
450 if (systemcfg->platform == PLATFORM_POWERMAC) {
451 dc = "d-cache-block-size";
452 ic = "i-cache-block-size";
454 dc = "d-cache-line-size";
455 ic = "i-cache-line-size";
459 lsize = cur_cpu_spec->dcache_bsize;
460 sizep = (u32 *)get_property(np, "d-cache-size", NULL);
463 lsizep = (u32 *) get_property(np, dc, NULL);
467 if (sizep == 0 || lsizep == 0)
468 DBG("Argh, can't find dcache properties ! "
469 "sizep: %p, lsizep: %p\n", sizep, lsizep);
471 systemcfg->dCacheL1Size = size;
472 systemcfg->dCacheL1LineSize = lsize;
473 naca->dCacheL1LogLineSize = __ilog2(lsize);
474 naca->dCacheL1LinesPerPage = PAGE_SIZE/(lsize);
477 lsize = cur_cpu_spec->icache_bsize;
478 sizep = (u32 *)get_property(np, "i-cache-size", NULL);
481 lsizep = (u32 *)get_property(np, ic, NULL);
484 if (sizep == 0 || lsizep == 0)
485 DBG("Argh, can't find icache properties ! "
486 "sizep: %p, lsizep: %p\n", sizep, lsizep);
488 systemcfg->iCacheL1Size = size;
489 systemcfg->iCacheL1LineSize = lsize;
490 naca->iCacheL1LogLineSize = __ilog2(lsize);
491 naca->iCacheL1LinesPerPage = PAGE_SIZE/(lsize);
496 /* Add an eye catcher and the systemcfg layout version number */
497 strcpy(systemcfg->eye_catcher, "SYSTEMCFG:PPC64");
498 systemcfg->version.major = SYSTEMCFG_MAJOR;
499 systemcfg->version.minor = SYSTEMCFG_MINOR;
500 systemcfg->processor = mfspr(SPRN_PVR);
502 DBG(" <- initialize_naca()\n");
505 static void __init check_for_initrd(void)
507 #ifdef CONFIG_BLK_DEV_INITRD
510 DBG(" -> check_for_initrd()\n");
512 prop = (u64 *)get_property(of_chosen, "linux,initrd-start", NULL);
514 initrd_start = (unsigned long)__va(*prop);
515 prop = (u64 *)get_property(of_chosen, "linux,initrd-end", NULL);
517 initrd_end = (unsigned long)__va(*prop);
518 initrd_below_start_ok = 1;
523 /* If we were passed an initrd, set the ROOT_DEV properly if the values
524 * look sensible. If not, clear initrd reference.
526 if (initrd_start >= KERNELBASE && initrd_end >= KERNELBASE &&
527 initrd_end > initrd_start)
528 ROOT_DEV = Root_RAM0;
530 initrd_start = initrd_end = 0;
533 printk("Found initrd at 0x%lx:0x%lx\n", initrd_start, initrd_end);
535 DBG(" <- check_for_initrd()\n");
536 #endif /* CONFIG_BLK_DEV_INITRD */
539 #endif /* CONFIG_PPC_MULTIPLATFORM */
542 * Do some initial setup of the system. The parameters are those which
543 * were passed in from the bootloader.
545 void __init setup_system(void)
547 DBG(" -> setup_system()\n");
549 #ifdef CONFIG_PPC_ISERIES
550 /* pSeries systems are identified in prom.c via OF. */
551 if (itLpNaca.xLparInstalled == 1)
552 systemcfg->platform = PLATFORM_ISERIES_LPAR;
555 #else /* CONFIG_PPC_ISERIES */
558 * Unflatten the device-tree passed by prom_init or kexec
560 unflatten_device_tree();
563 * Fill the naca & systemcfg structures with informations
564 * retreived from the device-tree. Need to be called before
565 * finish_device_tree() since the later requires some of the
566 * informations filled up here to properly parse the interrupt
568 * It also sets up the cache line sizes which allows to call
569 * routines like flush_icache_range (used by the hash init
574 #ifdef CONFIG_PPC_PSERIES
576 * Initialize RTAS if available
579 #endif /* CONFIG_PPC_PSERIES */
582 * Check if we have an initrd provided via the device-tree
587 * Do some platform specific early initializations, that includes
588 * setting up the hash table pointers. It also sets up some interrupt-mapping
589 * related options that will be used by finish_device_tree()
594 * "Finish" the device-tree, that is do the actual parsing of
595 * some of the properties like the interrupt map
597 finish_device_tree();
602 #ifdef CONFIG_XMON_DEFAULT
606 * Register early console
608 early_console_initialized = 1;
609 register_console(&udbg_console);
611 #endif /* !CONFIG_PPC_ISERIES */
613 /* Save unparsed command line copy for /proc/cmdline */
614 strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
618 #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES)
620 * iSeries has already initialized the cpu maps at this point.
623 #endif /* defined(CONFIG_SMP) && !defined(CONFIG_PPC_ISERIES) */
625 printk("Starting Linux PPC64 %s\n", UTS_RELEASE);
627 printk("-----------------------------------------------------\n");
628 printk("naca = 0x%p\n", naca);
629 printk("naca->pftSize = 0x%lx\n", naca->pftSize);
630 printk("naca->debug_switch = 0x%lx\n", naca->debug_switch);
631 printk("naca->interrupt_controller = 0x%ld\n", naca->interrupt_controller);
632 printk("systemcfg = 0x%p\n", systemcfg);
633 printk("systemcfg->processorCount = 0x%lx\n", systemcfg->processorCount);
634 printk("systemcfg->physicalMemorySize = 0x%lx\n", systemcfg->physicalMemorySize);
635 printk("systemcfg->dCacheL1LineSize = 0x%x\n", systemcfg->dCacheL1LineSize);
636 printk("systemcfg->iCacheL1LineSize = 0x%x\n", systemcfg->iCacheL1LineSize);
637 printk("htab_data.htab = 0x%p\n", htab_data.htab);
638 printk("htab_data.num_ptegs = 0x%lx\n", htab_data.htab_num_ptegs);
639 printk("-----------------------------------------------------\n");
643 DBG(" <- setup_system()\n");
647 void machine_restart(char *cmd)
649 if (ppc_md.nvram_sync)
654 EXPORT_SYMBOL(machine_restart);
656 void machine_power_off(void)
658 if (ppc_md.nvram_sync)
663 EXPORT_SYMBOL(machine_power_off);
665 void machine_halt(void)
667 if (ppc_md.nvram_sync)
672 EXPORT_SYMBOL(machine_halt);
674 unsigned long ppc_proc_freq;
675 unsigned long ppc_tb_freq;
677 static int ppc64_panic_event(struct notifier_block *this,
678 unsigned long event, void *ptr)
680 ppc_md.panic((char *)ptr); /* May not return */
686 DEFINE_PER_CPU(unsigned int, pvr);
689 static int show_cpuinfo(struct seq_file *m, void *v)
691 unsigned long cpu_id = (unsigned long)v - 1;
696 if (cpu_id == NR_CPUS) {
697 seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
699 if (ppc_md.get_cpuinfo != NULL)
700 ppc_md.get_cpuinfo(m);
705 /* We only show online cpus: disable preempt (overzealous, I
706 * knew) to prevent cpu going down. */
708 if (!cpu_online(cpu_id)) {
714 pvr = per_cpu(pvr, cpu_id);
716 pvr = mfspr(SPRN_PVR);
718 maj = (pvr >> 8) & 0xFF;
721 seq_printf(m, "processor\t: %lu\n", cpu_id);
722 seq_printf(m, "cpu\t\t: ");
724 if (cur_cpu_spec->pvr_mask)
725 seq_printf(m, "%s", cur_cpu_spec->cpu_name);
727 seq_printf(m, "unknown (%08x)", pvr);
729 #ifdef CONFIG_ALTIVEC
730 if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
731 seq_printf(m, ", altivec supported");
732 #endif /* CONFIG_ALTIVEC */
737 * Assume here that all clock rates are the same in a
738 * smp system. -- Cort
740 seq_printf(m, "clock\t\t: %lu.%06luMHz\n", ppc_proc_freq / 1000000,
741 ppc_proc_freq % 1000000);
743 seq_printf(m, "revision\t: %hd.%hd\n\n", maj, min);
749 static void *c_start(struct seq_file *m, loff_t *pos)
751 return *pos <= NR_CPUS ? (void *)((*pos)+1) : NULL;
753 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
756 return c_start(m, pos);
758 static void c_stop(struct seq_file *m, void *v)
761 struct seq_operations cpuinfo_op = {
765 .show = show_cpuinfo,
768 #if 0 /* XXX not currently used */
769 unsigned long memory_limit;
771 static int __init early_parsemem(char *p)
776 memory_limit = memparse(p, &p);
780 early_param("mem", early_parsemem);
783 #ifdef CONFIG_PPC_MULTIPLATFORM
784 static int __init set_preferred_console(void)
786 struct device_node *prom_stdout;
792 DBG(" -> set_preferred_console()\n");
794 /* The user has requested a console so this is already set up. */
795 if (strstr(saved_command_line, "console=")) {
796 DBG(" console was specified !\n");
801 DBG(" of_chosen is NULL !\n");
804 /* We are getting a weird phandle from OF ... */
806 stdout_ph = (phandle *)get_property(of_chosen, "linux,stdout-package", NULL);
807 if (stdout_ph == NULL) {
808 DBG(" no linux,stdout-package !\n");
811 prom_stdout = of_find_node_by_phandle(*stdout_ph);
813 DBG(" can't find stdout package for phandle 0x%x !\n", *stdout_ph);
817 /* ... So use the full path instead */
819 name = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
821 DBG(" no linux,stdout-path !\n");
824 prom_stdout = of_find_node_by_path(name);
826 DBG(" can't find stdout package %s !\n", name);
830 DBG("stdout is %s\n", prom_stdout->full_name);
832 name = (char *)get_property(prom_stdout, "name", NULL);
834 DBG(" stdout package has no name !\n");
838 if (strcmp(name, "serial") == 0) {
840 u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
856 /* We dont recognise the serial port */
861 #ifdef CONFIG_PPC_PSERIES
862 else if (strcmp(name, "vty") == 0) {
863 u32 *reg = (u32 *)get_property(prom_stdout, "reg", NULL);
864 char *compat = (char *)get_property(prom_stdout, "compatible", NULL);
866 if (reg && compat && (strcmp(compat, "hvterm-protocol") == 0)) {
867 /* Host Virtual Serial Interface */
879 of_node_put(prom_stdout);
880 DBG("Found hvsi console at offset %d\n", offset);
881 return add_preferred_console("hvsi", offset, NULL);
883 /* pSeries LPAR virtual console */
884 of_node_put(prom_stdout);
885 DBG("Found hvc console\n");
886 return add_preferred_console("hvc", 0, NULL);
889 #endif /* CONFIG_PPC_PSERIES */
890 else if (strcmp(name, "ch-a") == 0)
892 else if (strcmp(name, "ch-b") == 0)
896 of_node_put(prom_stdout);
898 DBG("Found serial console at ttyS%d\n", offset);
900 return add_preferred_console("ttyS", offset, NULL);
903 DBG("No preferred console found !\n");
904 of_node_put(prom_stdout);
907 console_initcall(set_preferred_console);
908 #endif /* CONFIG_PPC_MULTIPLATFORM */
910 #ifdef CONFIG_IRQSTACKS
911 static void __init irqstack_early_init(void)
916 * interrupt stacks must be under 256MB, we cannot afford to take
917 * SLB misses on them.
920 softirq_ctx[i] = (struct thread_info *)__va(lmb_alloc_base(THREAD_SIZE,
921 THREAD_SIZE, 0x10000000));
922 hardirq_ctx[i] = (struct thread_info *)__va(lmb_alloc_base(THREAD_SIZE,
923 THREAD_SIZE, 0x10000000));
927 #define irqstack_early_init()
931 * Stack space used when we detect a bad kernel stack pointer, and
932 * early in SMP boots before relocation is enabled.
934 static void __init emergency_stack_init(void)
940 * Emergency stacks must be under 256MB, we cannot afford to take
941 * SLB misses on them. The ABI also requires them to be 128-byte
944 * Since we use these as temporary stacks during secondary CPU
945 * bringup, we need to get at them in real mode. This means they
946 * must also be within the RMO region.
948 limit = min(0x10000000UL, lmb.rmo_size);
951 paca[i].emergency_sp = __va(lmb_alloc_base(PAGE_SIZE, 128,
956 * Called into from start_kernel, after lock_kernel has been called.
957 * Initializes bootmem, which is unsed to manage page allocation until
958 * mem_init is called.
960 void __init setup_arch(char **cmdline_p)
962 extern int panic_timeout;
963 extern void do_init_bootmem(void);
965 ppc64_boot_msg(0x12, "Setup Arch");
967 *cmdline_p = cmd_line;
970 * Set cache line size based on type of cpu as a default.
971 * Systems with OF can look in the properties on the cpu node(s)
972 * for a possibly more accurate value.
974 dcache_bsize = systemcfg->dCacheL1LineSize;
975 icache_bsize = systemcfg->iCacheL1LineSize;
977 /* reboot on panic */
981 notifier_chain_register(&panic_notifier_list, &ppc64_panic_block);
983 init_mm.start_code = PAGE_OFFSET;
984 init_mm.end_code = (unsigned long) _etext;
985 init_mm.end_data = (unsigned long) _edata;
986 init_mm.brk = klimit;
988 irqstack_early_init();
989 emergency_stack_init();
991 /* set up the bootmem stuff with available memory */
994 /* Select the correct idle loop for the platform. */
1000 ppc64_boot_msg(0x15, "Setup Done");
1004 /* ToDo: do something useful if ppc_md is not yet setup. */
1005 #define PPC64_LINUX_FUNCTION 0x0f000000
1006 #define PPC64_IPL_MESSAGE 0xc0000000
1007 #define PPC64_TERM_MESSAGE 0xb0000000
1008 #define PPC64_ATTN_MESSAGE 0xa0000000
1009 #define PPC64_DUMP_MESSAGE 0xd0000000
1011 static void ppc64_do_msg(unsigned int src, const char *msg)
1013 if (ppc_md.progress) {
1016 sprintf(buf, "%08x \n", src);
1017 ppc_md.progress(buf, 0);
1018 sprintf(buf, "%-16s", msg);
1019 ppc_md.progress(buf, 0);
1023 /* Print a boot progress message. */
1024 void ppc64_boot_msg(unsigned int src, const char *msg)
1026 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_IPL_MESSAGE|src, msg);
1027 printk("[boot]%04x %s\n", src, msg);
1030 /* Print a termination message (print only -- does not stop the kernel) */
1031 void ppc64_terminate_msg(unsigned int src, const char *msg)
1033 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_TERM_MESSAGE|src, msg);
1034 printk("[terminate]%04x %s\n", src, msg);
1037 /* Print something that needs attention (device error, etc) */
1038 void ppc64_attention_msg(unsigned int src, const char *msg)
1040 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_ATTN_MESSAGE|src, msg);
1041 printk("[attention]%04x %s\n", src, msg);
1044 /* Print a dump progress message. */
1045 void ppc64_dump_msg(unsigned int src, const char *msg)
1047 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_DUMP_MESSAGE|src, msg);
1048 printk("[dump]%04x %s\n", src, msg);
1051 int set_spread_lpevents( char * str )
1053 /* The parameter is the number of processors to share in processing lp events */
1055 unsigned long val = simple_strtoul( str, NULL, 0 );
1056 if ( ( val > 0 ) && ( val <= NR_CPUS ) ) {
1057 for ( i=1; i<val; ++i )
1058 paca[i].lpqueue_ptr = paca[0].lpqueue_ptr;
1059 printk("lpevent processing spread over %ld processors\n", val);
1062 printk("invalid spreaqd_lpevents %ld\n", val);
1066 /* This should only be called on processor 0 during calibrate decr */
1067 void setup_default_decr(void)
1069 struct paca_struct *lpaca = get_paca();
1071 if ( decr_overclock_set && !decr_overclock_proc0_set )
1072 decr_overclock_proc0 = decr_overclock;
1074 lpaca->default_decr = tb_ticks_per_jiffy / decr_overclock_proc0;
1075 lpaca->next_jiffy_update_tb = get_tb() + tb_ticks_per_jiffy;
1078 int set_decr_overclock_proc0( char * str )
1080 unsigned long val = simple_strtoul( str, NULL, 0 );
1081 if ( ( val >= 1 ) && ( val <= 48 ) ) {
1082 decr_overclock_proc0_set = 1;
1083 decr_overclock_proc0 = val;
1084 printk("proc 0 decrementer overclock factor of %ld\n", val);
1087 printk("invalid proc 0 decrementer overclock factor of %ld\n", val);
1091 int set_decr_overclock( char * str )
1093 unsigned long val = simple_strtoul( str, NULL, 0 );
1094 if ( ( val >= 1 ) && ( val <= 48 ) ) {
1095 decr_overclock_set = 1;
1096 decr_overclock = val;
1097 printk("decrementer overclock factor of %ld\n", val);
1100 printk("invalid decrementer overclock factor of %ld\n", val);
1105 __setup("spread_lpevents=", set_spread_lpevents );
1106 __setup("decr_overclock_proc0=", set_decr_overclock_proc0 );
1107 __setup("decr_overclock=", set_decr_overclock );
1110 static int __init early_xmon(char *p)
1112 /* ensure xmon is enabled */
1118 early_param("xmon", early_xmon);