xref: /openbmc/linux/arch/sparc/kernel/setup_32.c (revision b7afdb7e)
1d670bd4fSSam Ravnborg /*
2d670bd4fSSam Ravnborg  *  linux/arch/sparc/kernel/setup.c
3d670bd4fSSam Ravnborg  *
4d670bd4fSSam Ravnborg  *  Copyright (C) 1995  David S. Miller (davem@caip.rutgers.edu)
5d670bd4fSSam Ravnborg  *  Copyright (C) 2000  Anton Blanchard (anton@samba.org)
6d670bd4fSSam Ravnborg  */
7d670bd4fSSam Ravnborg 
8d670bd4fSSam Ravnborg #include <linux/errno.h>
9d670bd4fSSam Ravnborg #include <linux/sched.h>
10d670bd4fSSam Ravnborg #include <linux/kernel.h>
11d670bd4fSSam Ravnborg #include <linux/mm.h>
12d670bd4fSSam Ravnborg #include <linux/stddef.h>
13d670bd4fSSam Ravnborg #include <linux/unistd.h>
14d670bd4fSSam Ravnborg #include <linux/ptrace.h>
15d670bd4fSSam Ravnborg #include <linux/slab.h>
16d670bd4fSSam Ravnborg #include <linux/initrd.h>
17d670bd4fSSam Ravnborg #include <asm/smp.h>
18d670bd4fSSam Ravnborg #include <linux/user.h>
19d670bd4fSSam Ravnborg #include <linux/screen_info.h>
20d670bd4fSSam Ravnborg #include <linux/delay.h>
21d670bd4fSSam Ravnborg #include <linux/fs.h>
22d670bd4fSSam Ravnborg #include <linux/seq_file.h>
23d670bd4fSSam Ravnborg #include <linux/syscalls.h>
24d670bd4fSSam Ravnborg #include <linux/kdev_t.h>
25d670bd4fSSam Ravnborg #include <linux/major.h>
26d670bd4fSSam Ravnborg #include <linux/string.h>
27d670bd4fSSam Ravnborg #include <linux/init.h>
28d670bd4fSSam Ravnborg #include <linux/interrupt.h>
29d670bd4fSSam Ravnborg #include <linux/console.h>
30d670bd4fSSam Ravnborg #include <linux/spinlock.h>
31d670bd4fSSam Ravnborg #include <linux/root_dev.h>
32d670bd4fSSam Ravnborg #include <linux/cpu.h>
33d670bd4fSSam Ravnborg #include <linux/kdebug.h>
34d670bd4fSSam Ravnborg 
35d670bd4fSSam Ravnborg #include <asm/system.h>
36d670bd4fSSam Ravnborg #include <asm/io.h>
37d670bd4fSSam Ravnborg #include <asm/processor.h>
38d670bd4fSSam Ravnborg #include <asm/oplib.h>
39d670bd4fSSam Ravnborg #include <asm/page.h>
40d670bd4fSSam Ravnborg #include <asm/pgtable.h>
41d670bd4fSSam Ravnborg #include <asm/traps.h>
42d670bd4fSSam Ravnborg #include <asm/vaddrs.h>
43d670bd4fSSam Ravnborg #include <asm/mbus.h>
44d670bd4fSSam Ravnborg #include <asm/idprom.h>
45d670bd4fSSam Ravnborg #include <asm/machines.h>
46d670bd4fSSam Ravnborg #include <asm/cpudata.h>
47d670bd4fSSam Ravnborg #include <asm/setup.h>
48d670bd4fSSam Ravnborg 
4953ae3419SSam Ravnborg #include "kernel.h"
5053ae3419SSam Ravnborg 
51d670bd4fSSam Ravnborg struct screen_info screen_info = {
52d670bd4fSSam Ravnborg 	0, 0,			/* orig-x, orig-y */
53d670bd4fSSam Ravnborg 	0,			/* unused */
54d670bd4fSSam Ravnborg 	0,			/* orig-video-page */
55d670bd4fSSam Ravnborg 	0,			/* orig-video-mode */
56d670bd4fSSam Ravnborg 	128,			/* orig-video-cols */
57d670bd4fSSam Ravnborg 	0,0,0,			/* ega_ax, ega_bx, ega_cx */
58d670bd4fSSam Ravnborg 	54,			/* orig-video-lines */
59d670bd4fSSam Ravnborg 	0,                      /* orig-video-isVGA */
60d670bd4fSSam Ravnborg 	16                      /* orig-video-points */
61d670bd4fSSam Ravnborg };
62d670bd4fSSam Ravnborg 
63d670bd4fSSam Ravnborg /* Typing sync at the prom prompt calls the function pointed to by
64d670bd4fSSam Ravnborg  * romvec->pv_synchook which I set to the following function.
65d670bd4fSSam Ravnborg  * This should sync all filesystems and return, for now it just
66d670bd4fSSam Ravnborg  * prints out pretty messages and returns.
67d670bd4fSSam Ravnborg  */
68d670bd4fSSam Ravnborg 
69d670bd4fSSam Ravnborg extern unsigned long trapbase;
70d670bd4fSSam Ravnborg 
71d670bd4fSSam Ravnborg /* Pretty sick eh? */
72d670bd4fSSam Ravnborg static void prom_sync_me(void)
73d670bd4fSSam Ravnborg {
74d670bd4fSSam Ravnborg 	unsigned long prom_tbr, flags;
75d670bd4fSSam Ravnborg 
76d670bd4fSSam Ravnborg 	/* XXX Badly broken. FIX! - Anton */
77d670bd4fSSam Ravnborg 	local_irq_save(flags);
78d670bd4fSSam Ravnborg 	__asm__ __volatile__("rd %%tbr, %0\n\t" : "=r" (prom_tbr));
79d670bd4fSSam Ravnborg 	__asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
80d670bd4fSSam Ravnborg 			     "nop\n\t"
81d670bd4fSSam Ravnborg 			     "nop\n\t"
82d670bd4fSSam Ravnborg 			     "nop\n\t" : : "r" (&trapbase));
83d670bd4fSSam Ravnborg 
84d670bd4fSSam Ravnborg 	prom_printf("PROM SYNC COMMAND...\n");
85d670bd4fSSam Ravnborg 	show_free_areas();
86d670bd4fSSam Ravnborg 	if(current->pid != 0) {
87d670bd4fSSam Ravnborg 		local_irq_enable();
88d670bd4fSSam Ravnborg 		sys_sync();
89d670bd4fSSam Ravnborg 		local_irq_disable();
90d670bd4fSSam Ravnborg 	}
91d670bd4fSSam Ravnborg 	prom_printf("Returning to prom\n");
92d670bd4fSSam Ravnborg 
93d670bd4fSSam Ravnborg 	__asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
94d670bd4fSSam Ravnborg 			     "nop\n\t"
95d670bd4fSSam Ravnborg 			     "nop\n\t"
96d670bd4fSSam Ravnborg 			     "nop\n\t" : : "r" (prom_tbr));
97d670bd4fSSam Ravnborg 	local_irq_restore(flags);
98d670bd4fSSam Ravnborg }
99d670bd4fSSam Ravnborg 
100d670bd4fSSam Ravnborg static unsigned int boot_flags __initdata = 0;
101d670bd4fSSam Ravnborg #define BOOTME_DEBUG  0x1
102d670bd4fSSam Ravnborg 
103d670bd4fSSam Ravnborg /* Exported for mm/init.c:paging_init. */
104d670bd4fSSam Ravnborg unsigned long cmdline_memory_size __initdata = 0;
105d670bd4fSSam Ravnborg 
106d670bd4fSSam Ravnborg static void
107d670bd4fSSam Ravnborg prom_console_write(struct console *con, const char *s, unsigned n)
108d670bd4fSSam Ravnborg {
109d670bd4fSSam Ravnborg 	prom_write(s, n);
110d670bd4fSSam Ravnborg }
111d670bd4fSSam Ravnborg 
112d670bd4fSSam Ravnborg static struct console prom_debug_console = {
113d670bd4fSSam Ravnborg 	.name =		"debug",
114d670bd4fSSam Ravnborg 	.write =	prom_console_write,
115d670bd4fSSam Ravnborg 	.flags =	CON_PRINTBUFFER,
116d670bd4fSSam Ravnborg 	.index =	-1,
117d670bd4fSSam Ravnborg };
118d670bd4fSSam Ravnborg 
119d670bd4fSSam Ravnborg /*
120d670bd4fSSam Ravnborg  * Process kernel command line switches that are specific to the
121d670bd4fSSam Ravnborg  * SPARC or that require special low-level processing.
122d670bd4fSSam Ravnborg  */
123d670bd4fSSam Ravnborg static void __init process_switch(char c)
124d670bd4fSSam Ravnborg {
125d670bd4fSSam Ravnborg 	switch (c) {
126d670bd4fSSam Ravnborg 	case 'd':
127d670bd4fSSam Ravnborg 		boot_flags |= BOOTME_DEBUG;
128d670bd4fSSam Ravnborg 		break;
129d670bd4fSSam Ravnborg 	case 's':
130d670bd4fSSam Ravnborg 		break;
131d670bd4fSSam Ravnborg 	case 'h':
132d670bd4fSSam Ravnborg 		prom_printf("boot_flags_init: Halt!\n");
133d670bd4fSSam Ravnborg 		prom_halt();
134d670bd4fSSam Ravnborg 		break;
135d670bd4fSSam Ravnborg 	case 'p':
136d670bd4fSSam Ravnborg 		/* Use PROM debug console. */
137d670bd4fSSam Ravnborg 		register_console(&prom_debug_console);
138d670bd4fSSam Ravnborg 		break;
139d670bd4fSSam Ravnborg 	default:
140d670bd4fSSam Ravnborg 		printk("Unknown boot switch (-%c)\n", c);
141d670bd4fSSam Ravnborg 		break;
142d670bd4fSSam Ravnborg 	}
143d670bd4fSSam Ravnborg }
144d670bd4fSSam Ravnborg 
145d670bd4fSSam Ravnborg static void __init boot_flags_init(char *commands)
146d670bd4fSSam Ravnborg {
147d670bd4fSSam Ravnborg 	while (*commands) {
148d670bd4fSSam Ravnborg 		/* Move to the start of the next "argument". */
149d670bd4fSSam Ravnborg 		while (*commands && *commands == ' ')
150d670bd4fSSam Ravnborg 			commands++;
151d670bd4fSSam Ravnborg 
152d670bd4fSSam Ravnborg 		/* Process any command switches, otherwise skip it. */
153d670bd4fSSam Ravnborg 		if (*commands == '\0')
154d670bd4fSSam Ravnborg 			break;
155d670bd4fSSam Ravnborg 		if (*commands == '-') {
156d670bd4fSSam Ravnborg 			commands++;
157d670bd4fSSam Ravnborg 			while (*commands && *commands != ' ')
158d670bd4fSSam Ravnborg 				process_switch(*commands++);
159d670bd4fSSam Ravnborg 			continue;
160d670bd4fSSam Ravnborg 		}
161d670bd4fSSam Ravnborg 		if (!strncmp(commands, "mem=", 4)) {
162d670bd4fSSam Ravnborg 			/*
163d670bd4fSSam Ravnborg 			 * "mem=XXX[kKmM] overrides the PROM-reported
164d670bd4fSSam Ravnborg 			 * memory size.
165d670bd4fSSam Ravnborg 			 */
166d670bd4fSSam Ravnborg 			cmdline_memory_size = simple_strtoul(commands + 4,
167d670bd4fSSam Ravnborg 						     &commands, 0);
168d670bd4fSSam Ravnborg 			if (*commands == 'K' || *commands == 'k') {
169d670bd4fSSam Ravnborg 				cmdline_memory_size <<= 10;
170d670bd4fSSam Ravnborg 				commands++;
171d670bd4fSSam Ravnborg 			} else if (*commands=='M' || *commands=='m') {
172d670bd4fSSam Ravnborg 				cmdline_memory_size <<= 20;
173d670bd4fSSam Ravnborg 				commands++;
174d670bd4fSSam Ravnborg 			}
175d670bd4fSSam Ravnborg 		}
176d670bd4fSSam Ravnborg 		while (*commands && *commands != ' ')
177d670bd4fSSam Ravnborg 			commands++;
178d670bd4fSSam Ravnborg 	}
179d670bd4fSSam Ravnborg }
180d670bd4fSSam Ravnborg 
181d670bd4fSSam Ravnborg /* This routine will in the future do all the nasty prom stuff
182d670bd4fSSam Ravnborg  * to probe for the mmu type and its parameters, etc. This will
183d670bd4fSSam Ravnborg  * also be where SMP things happen.
184d670bd4fSSam Ravnborg  */
185d670bd4fSSam Ravnborg 
186d670bd4fSSam Ravnborg extern void sun4c_probe_vac(void);
187d670bd4fSSam Ravnborg 
188d670bd4fSSam Ravnborg extern unsigned short root_flags;
189d670bd4fSSam Ravnborg extern unsigned short root_dev;
190d670bd4fSSam Ravnborg extern unsigned short ram_flags;
191d670bd4fSSam Ravnborg #define RAMDISK_IMAGE_START_MASK	0x07FF
192d670bd4fSSam Ravnborg #define RAMDISK_PROMPT_FLAG		0x8000
193d670bd4fSSam Ravnborg #define RAMDISK_LOAD_FLAG		0x4000
194d670bd4fSSam Ravnborg 
195d670bd4fSSam Ravnborg extern int root_mountflags;
196d670bd4fSSam Ravnborg 
197d670bd4fSSam Ravnborg char reboot_command[COMMAND_LINE_SIZE];
1986943f3daSSam Ravnborg 
199d670bd4fSSam Ravnborg enum sparc_cpu sparc_cpu_model;
2006943f3daSSam Ravnborg EXPORT_SYMBOL(sparc_cpu_model);
201d670bd4fSSam Ravnborg 
202d670bd4fSSam Ravnborg struct tt_entry *sparc_ttable;
203d670bd4fSSam Ravnborg 
204d670bd4fSSam Ravnborg struct pt_regs fake_swapper_regs;
205d670bd4fSSam Ravnborg 
206d670bd4fSSam Ravnborg void __init setup_arch(char **cmdline_p)
207d670bd4fSSam Ravnborg {
208d670bd4fSSam Ravnborg 	int i;
209d670bd4fSSam Ravnborg 	unsigned long highest_paddr;
210d670bd4fSSam Ravnborg 
211e405ae76SSam Ravnborg 	sparc_ttable = (struct tt_entry *) &trapbase;
212d670bd4fSSam Ravnborg 
213d670bd4fSSam Ravnborg 	/* Initialize PROM console and command line. */
214d670bd4fSSam Ravnborg 	*cmdline_p = prom_getbootargs();
215d670bd4fSSam Ravnborg 	strcpy(boot_command_line, *cmdline_p);
216d670bd4fSSam Ravnborg 	parse_early_param();
217d670bd4fSSam Ravnborg 
218d670bd4fSSam Ravnborg 	/* Set sparc_cpu_model */
219d670bd4fSSam Ravnborg 	sparc_cpu_model = sun_unknown;
220b7afdb7eSSam Ravnborg 	if (!strcmp(&cputypval[0], "sun4 "))
221d670bd4fSSam Ravnborg 		sparc_cpu_model = sun4;
222b7afdb7eSSam Ravnborg 	if (!strcmp(&cputypval[0], "sun4c"))
223d670bd4fSSam Ravnborg 		sparc_cpu_model = sun4c;
224b7afdb7eSSam Ravnborg 	if (!strcmp(&cputypval[0], "sun4m"))
225d670bd4fSSam Ravnborg 		sparc_cpu_model = sun4m;
226b7afdb7eSSam Ravnborg 	if (!strcmp(&cputypval[0], "sun4s"))
227d670bd4fSSam Ravnborg 		sparc_cpu_model = sun4m; /* CP-1200 with PROM 2.30 -E */
228b7afdb7eSSam Ravnborg 	if (!strcmp(&cputypval[0], "sun4d"))
229d670bd4fSSam Ravnborg 		sparc_cpu_model = sun4d;
230b7afdb7eSSam Ravnborg 	if (!strcmp(&cputypval[0], "sun4e"))
231d670bd4fSSam Ravnborg 		sparc_cpu_model = sun4e;
232b7afdb7eSSam Ravnborg 	if (!strcmp(&cputypval[0], "sun4u"))
233d670bd4fSSam Ravnborg 		sparc_cpu_model = sun4u;
234b7afdb7eSSam Ravnborg 	if (!strncmp(&cputypval[0], "leon" , 4))
2350fd7ef1fSKonrad Eisele 		sparc_cpu_model = sparc_leon;
236d670bd4fSSam Ravnborg 
237d670bd4fSSam Ravnborg 	printk("ARCH: ");
238d670bd4fSSam Ravnborg 	switch(sparc_cpu_model) {
239d670bd4fSSam Ravnborg 	case sun4:
240d670bd4fSSam Ravnborg 		printk("SUN4\n");
241d670bd4fSSam Ravnborg 		break;
242d670bd4fSSam Ravnborg 	case sun4c:
243d670bd4fSSam Ravnborg 		printk("SUN4C\n");
244d670bd4fSSam Ravnborg 		break;
245d670bd4fSSam Ravnborg 	case sun4m:
246d670bd4fSSam Ravnborg 		printk("SUN4M\n");
247d670bd4fSSam Ravnborg 		break;
248d670bd4fSSam Ravnborg 	case sun4d:
249d670bd4fSSam Ravnborg 		printk("SUN4D\n");
250d670bd4fSSam Ravnborg 		break;
251d670bd4fSSam Ravnborg 	case sun4e:
252d670bd4fSSam Ravnborg 		printk("SUN4E\n");
253d670bd4fSSam Ravnborg 		break;
254d670bd4fSSam Ravnborg 	case sun4u:
255d670bd4fSSam Ravnborg 		printk("SUN4U\n");
256d670bd4fSSam Ravnborg 		break;
2570fd7ef1fSKonrad Eisele 	case sparc_leon:
2580fd7ef1fSKonrad Eisele 		printk("LEON\n");
2590fd7ef1fSKonrad Eisele 		break;
260d670bd4fSSam Ravnborg 	default:
261d670bd4fSSam Ravnborg 		printk("UNKNOWN!\n");
262d670bd4fSSam Ravnborg 		break;
263d670bd4fSSam Ravnborg 	};
264d670bd4fSSam Ravnborg 
265d670bd4fSSam Ravnborg #ifdef CONFIG_DUMMY_CONSOLE
266d670bd4fSSam Ravnborg 	conswitchp = &dummy_con;
267d670bd4fSSam Ravnborg #endif
268d670bd4fSSam Ravnborg 	boot_flags_init(*cmdline_p);
269d670bd4fSSam Ravnborg 
270d670bd4fSSam Ravnborg 	idprom_init();
271d670bd4fSSam Ravnborg 	if (ARCH_SUN4C)
272d670bd4fSSam Ravnborg 		sun4c_probe_vac();
273d670bd4fSSam Ravnborg 	load_mmu();
274d670bd4fSSam Ravnborg 
275d670bd4fSSam Ravnborg 	phys_base = 0xffffffffUL;
276d670bd4fSSam Ravnborg 	highest_paddr = 0UL;
277d670bd4fSSam Ravnborg 	for (i = 0; sp_banks[i].num_bytes != 0; i++) {
278d670bd4fSSam Ravnborg 		unsigned long top;
279d670bd4fSSam Ravnborg 
280d670bd4fSSam Ravnborg 		if (sp_banks[i].base_addr < phys_base)
281d670bd4fSSam Ravnborg 			phys_base = sp_banks[i].base_addr;
282d670bd4fSSam Ravnborg 		top = sp_banks[i].base_addr +
283d670bd4fSSam Ravnborg 			sp_banks[i].num_bytes;
284d670bd4fSSam Ravnborg 		if (highest_paddr < top)
285d670bd4fSSam Ravnborg 			highest_paddr = top;
286d670bd4fSSam Ravnborg 	}
287d670bd4fSSam Ravnborg 	pfn_base = phys_base >> PAGE_SHIFT;
288d670bd4fSSam Ravnborg 
289d670bd4fSSam Ravnborg 	if (!root_flags)
290d670bd4fSSam Ravnborg 		root_mountflags &= ~MS_RDONLY;
291d670bd4fSSam Ravnborg 	ROOT_DEV = old_decode_dev(root_dev);
292d670bd4fSSam Ravnborg #ifdef CONFIG_BLK_DEV_RAM
293d670bd4fSSam Ravnborg 	rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
294d670bd4fSSam Ravnborg 	rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
295d670bd4fSSam Ravnborg 	rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
296d670bd4fSSam Ravnborg #endif
297d670bd4fSSam Ravnborg 
298d670bd4fSSam Ravnborg 	prom_setsync(prom_sync_me);
299d670bd4fSSam Ravnborg 
300d670bd4fSSam Ravnborg 	if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) &&
301d670bd4fSSam Ravnborg 	   ((*(short *)linux_dbvec) != -1)) {
302d670bd4fSSam Ravnborg 		printk("Booted under KADB. Syncing trap table.\n");
303d670bd4fSSam Ravnborg 		(*(linux_dbvec->teach_debugger))();
304d670bd4fSSam Ravnborg 	}
305d670bd4fSSam Ravnborg 
306d670bd4fSSam Ravnborg 	init_mm.context = (unsigned long) NO_CONTEXT;
307d670bd4fSSam Ravnborg 	init_task.thread.kregs = &fake_swapper_regs;
308d670bd4fSSam Ravnborg 
309d670bd4fSSam Ravnborg 	paging_init();
310d670bd4fSSam Ravnborg 
311d670bd4fSSam Ravnborg 	smp_setup_cpu_possible_map();
312d670bd4fSSam Ravnborg }
313d670bd4fSSam Ravnborg 
314d670bd4fSSam Ravnborg static int ncpus_probed;
315d670bd4fSSam Ravnborg 
316d670bd4fSSam Ravnborg static int show_cpuinfo(struct seq_file *m, void *__unused)
317d670bd4fSSam Ravnborg {
318d670bd4fSSam Ravnborg 	seq_printf(m,
319d670bd4fSSam Ravnborg 		   "cpu\t\t: %s\n"
320d670bd4fSSam Ravnborg 		   "fpu\t\t: %s\n"
321d670bd4fSSam Ravnborg 		   "promlib\t\t: Version %d Revision %d\n"
322d670bd4fSSam Ravnborg 		   "prom\t\t: %d.%d\n"
323d670bd4fSSam Ravnborg 		   "type\t\t: %s\n"
324d670bd4fSSam Ravnborg 		   "ncpus probed\t: %d\n"
325d670bd4fSSam Ravnborg 		   "ncpus active\t: %d\n"
326d670bd4fSSam Ravnborg #ifndef CONFIG_SMP
327d670bd4fSSam Ravnborg 		   "CPU0Bogo\t: %lu.%02lu\n"
328d670bd4fSSam Ravnborg 		   "CPU0ClkTck\t: %ld\n"
329d670bd4fSSam Ravnborg #endif
330d670bd4fSSam Ravnborg 		   ,
3316c6bd8b6SSam Ravnborg 		   sparc_cpu_type,
3326c6bd8b6SSam Ravnborg 		   sparc_fpu_type ,
333d670bd4fSSam Ravnborg 		   romvec->pv_romvers,
334d670bd4fSSam Ravnborg 		   prom_rev,
335d670bd4fSSam Ravnborg 		   romvec->pv_printrev >> 16,
336d670bd4fSSam Ravnborg 		   romvec->pv_printrev & 0xffff,
337b7afdb7eSSam Ravnborg 		   &cputypval[0],
338d670bd4fSSam Ravnborg 		   ncpus_probed,
339d670bd4fSSam Ravnborg 		   num_online_cpus()
340d670bd4fSSam Ravnborg #ifndef CONFIG_SMP
341d670bd4fSSam Ravnborg 		   , cpu_data(0).udelay_val/(500000/HZ),
342d670bd4fSSam Ravnborg 		   (cpu_data(0).udelay_val/(5000/HZ)) % 100,
343d670bd4fSSam Ravnborg 		   cpu_data(0).clock_tick
344d670bd4fSSam Ravnborg #endif
345d670bd4fSSam Ravnborg 		);
346d670bd4fSSam Ravnborg 
347d670bd4fSSam Ravnborg #ifdef CONFIG_SMP
348d670bd4fSSam Ravnborg 	smp_bogo(m);
349d670bd4fSSam Ravnborg #endif
350d670bd4fSSam Ravnborg 	mmu_info(m);
351d670bd4fSSam Ravnborg #ifdef CONFIG_SMP
352d670bd4fSSam Ravnborg 	smp_info(m);
353d670bd4fSSam Ravnborg #endif
354d670bd4fSSam Ravnborg 	return 0;
355d670bd4fSSam Ravnborg }
356d670bd4fSSam Ravnborg 
357d670bd4fSSam Ravnborg static void *c_start(struct seq_file *m, loff_t *pos)
358d670bd4fSSam Ravnborg {
359d670bd4fSSam Ravnborg 	/* The pointer we are returning is arbitrary,
360d670bd4fSSam Ravnborg 	 * it just has to be non-NULL and not IS_ERR
361d670bd4fSSam Ravnborg 	 * in the success case.
362d670bd4fSSam Ravnborg 	 */
363d670bd4fSSam Ravnborg 	return *pos == 0 ? &c_start : NULL;
364d670bd4fSSam Ravnborg }
365d670bd4fSSam Ravnborg 
366d670bd4fSSam Ravnborg static void *c_next(struct seq_file *m, void *v, loff_t *pos)
367d670bd4fSSam Ravnborg {
368d670bd4fSSam Ravnborg 	++*pos;
369d670bd4fSSam Ravnborg 	return c_start(m, pos);
370d670bd4fSSam Ravnborg }
371d670bd4fSSam Ravnborg 
372d670bd4fSSam Ravnborg static void c_stop(struct seq_file *m, void *v)
373d670bd4fSSam Ravnborg {
374d670bd4fSSam Ravnborg }
375d670bd4fSSam Ravnborg 
376d670bd4fSSam Ravnborg const struct seq_operations cpuinfo_op = {
377d670bd4fSSam Ravnborg 	.start =c_start,
378d670bd4fSSam Ravnborg 	.next =	c_next,
379d670bd4fSSam Ravnborg 	.stop =	c_stop,
380d670bd4fSSam Ravnborg 	.show =	show_cpuinfo,
381d670bd4fSSam Ravnborg };
382d670bd4fSSam Ravnborg 
383d670bd4fSSam Ravnborg extern int stop_a_enabled;
384d670bd4fSSam Ravnborg 
385d670bd4fSSam Ravnborg void sun_do_break(void)
386d670bd4fSSam Ravnborg {
387d670bd4fSSam Ravnborg 	if (!stop_a_enabled)
388d670bd4fSSam Ravnborg 		return;
389d670bd4fSSam Ravnborg 
390d670bd4fSSam Ravnborg 	printk("\n");
391d670bd4fSSam Ravnborg 	flush_user_windows();
392d670bd4fSSam Ravnborg 
393d670bd4fSSam Ravnborg 	prom_cmdline();
394d670bd4fSSam Ravnborg }
3956943f3daSSam Ravnborg EXPORT_SYMBOL(sun_do_break);
396d670bd4fSSam Ravnborg 
397d670bd4fSSam Ravnborg int stop_a_enabled = 1;
398d670bd4fSSam Ravnborg 
399d670bd4fSSam Ravnborg static int __init topology_init(void)
400d670bd4fSSam Ravnborg {
401d670bd4fSSam Ravnborg 	int i, ncpus, err;
402d670bd4fSSam Ravnborg 
403d670bd4fSSam Ravnborg 	/* Count the number of physically present processors in
404d670bd4fSSam Ravnborg 	 * the machine, even on uniprocessor, so that /proc/cpuinfo
405d670bd4fSSam Ravnborg 	 * output is consistent with 2.4.x
406d670bd4fSSam Ravnborg 	 */
407d670bd4fSSam Ravnborg 	ncpus = 0;
408d670bd4fSSam Ravnborg 	while (!cpu_find_by_instance(ncpus, NULL, NULL))
409d670bd4fSSam Ravnborg 		ncpus++;
410d670bd4fSSam Ravnborg 	ncpus_probed = ncpus;
411d670bd4fSSam Ravnborg 
412d670bd4fSSam Ravnborg 	err = 0;
413d670bd4fSSam Ravnborg 	for_each_online_cpu(i) {
414d670bd4fSSam Ravnborg 		struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
415d670bd4fSSam Ravnborg 		if (!p)
416d670bd4fSSam Ravnborg 			err = -ENOMEM;
417d670bd4fSSam Ravnborg 		else
418d670bd4fSSam Ravnborg 			register_cpu(p, i);
419d670bd4fSSam Ravnborg 	}
420d670bd4fSSam Ravnborg 
421d670bd4fSSam Ravnborg 	return err;
422d670bd4fSSam Ravnborg }
423d670bd4fSSam Ravnborg 
424d670bd4fSSam Ravnborg subsys_initcall(topology_init);
425