Remove remains of old style PS/2 support.
[linux-2.6/linux-mips.git] / arch / mips64 / kernel / setup.c
blob2a18bbff48cb1448b3fd22416786bcaa8e48e500
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 1995 Linus Torvalds
7 * Copyright (C) 1995 Waldorf Electronics
8 * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Ralf Baechle
9 * Copyright (C) 1996 Stoned Elipot
10 * Copyright (C) 1999 Silicon Graphics, Inc.
11 * Copyright (C) 2002 Maciej W. Rozycki
13 #include <linux/config.h>
14 #include <linux/errno.h>
15 #include <linux/init.h>
16 #include <linux/ioport.h>
17 #include <linux/sched.h>
18 #include <linux/kernel.h>
19 #include <linux/mm.h>
20 #include <linux/module.h>
21 #include <linux/stddef.h>
22 #include <linux/string.h>
23 #include <linux/unistd.h>
24 #include <linux/ptrace.h>
25 #include <linux/slab.h>
26 #include <linux/user.h>
27 #include <linux/utsname.h>
28 #include <linux/a.out.h>
29 #include <linux/tty.h>
30 #include <linux/bootmem.h>
31 #ifdef CONFIG_BLK_DEV_RAM
32 #include <linux/blk.h>
33 #endif
34 #include <linux/major.h>
35 #include <linux/kdev_t.h>
36 #include <linux/root_dev.h>
38 #include <asm/addrspace.h>
39 #include <asm/bootinfo.h>
40 #include <asm/cpu.h>
41 #include <asm/mipsregs.h>
42 #include <asm/stackframe.h>
43 #include <asm/system.h>
44 #include <asm/sections.h>
45 #include <asm/pgalloc.h>
47 struct cpuinfo_mips cpu_data[NR_CPUS];
49 #ifdef CONFIG_VT
50 struct screen_info screen_info;
51 #endif
54 * Set if box has EISA slots.
56 #ifdef CONFIG_EISA
57 int EISA_bus = 0;
58 #endif
60 #ifdef CONFIG_BLK_DEV_FD
61 extern struct fd_ops no_fd_ops;
62 struct fd_ops *fd_ops;
63 #endif
65 #ifdef CONFIG_BLK_DEV_IDE
66 extern struct ide_ops no_ide_ops;
67 struct ide_ops *ide_ops;
68 #endif
70 extern void * __rd_start, * __rd_end;
72 extern struct rtc_ops no_rtc_ops;
73 struct rtc_ops *rtc_ops;
75 extern struct kbd_ops no_kbd_ops;
76 struct kbd_ops *kbd_ops;
79 * Setup information
81 * These are initialized so they are in the .data section
83 unsigned long mips_machtype = MACH_UNKNOWN;
84 unsigned long mips_machgroup = MACH_GROUP_UNKNOWN;
86 struct boot_mem_map boot_mem_map;
88 static char command_line[CL_SIZE] = { 0, };
89 char saved_command_line[CL_SIZE];
90 extern char arcs_cmdline[CL_SIZE];
93 * mips_io_port_base is the begin of the address space to which x86 style
94 * I/O ports are mapped.
96 const unsigned long mips_io_port_base = -1;
97 EXPORT_SYMBOL(mips_io_port_base);
100 * isa_slot_offset is the address where E(ISA) busaddress 0 is mapped
101 * for the processor.
103 unsigned long isa_slot_offset;
104 EXPORT_SYMBOL(isa_slot_offset);
106 extern void SetUpBootInfo(void);
107 extern void load_mmu(void);
108 extern ATTRIB_NORET asmlinkage void start_kernel(void);
109 extern void prom_init(int, char **, char **, int *);
111 static struct resource code_resource = { "Kernel code" };
112 static struct resource data_resource = { "Kernel data" };
114 asmlinkage void __init init_arch(int argc, char **argv, char **envp,
115 int *prom_vec)
117 /* Determine which MIPS variant we are running on. */
118 cpu_probe();
120 prom_init(argc, argv, envp, prom_vec);
122 cpu_report();
125 * Determine the mmu/cache attached to this machine, then flush the
126 * tlb and caches. On the r4xx0 variants this also sets CP0_WIRED to
127 * zero.
129 load_mmu();
132 * On IP27, I am seeing the TS bit set when the kernel is loaded.
133 * Maybe because the kernel is in ckseg0 and not xkphys? Clear it
134 * anyway ...
136 clear_c0_status(ST0_BEV|ST0_TS|ST0_CU1|ST0_CU2|ST0_CU3);
137 set_c0_status(ST0_CU0|ST0_KX|ST0_SX|ST0_FR);
139 start_kernel();
142 void __init add_memory_region(phys_t start, phys_t size,
143 long type)
145 int x = boot_mem_map.nr_map;
147 if (x == BOOT_MEM_MAP_MAX) {
148 printk("Ooops! Too many entries in the memory map!\n");
149 return;
152 boot_mem_map.map[x].addr = start;
153 boot_mem_map.map[x].size = size;
154 boot_mem_map.map[x].type = type;
155 boot_mem_map.nr_map++;
158 static void __init print_memory_map(void)
160 int i;
162 for (i = 0; i < boot_mem_map.nr_map; i++) {
163 printk(" memory: %016Lx @ %016Lx ",
164 (unsigned long long) boot_mem_map.map[i].size,
165 (unsigned long long) boot_mem_map.map[i].addr);
166 switch (boot_mem_map.map[i].type) {
167 case BOOT_MEM_RAM:
168 printk("(usable)\n");
169 break;
170 case BOOT_MEM_ROM_DATA:
171 printk("(ROM data)\n");
172 break;
173 case BOOT_MEM_RESERVED:
174 printk("(reserved)\n");
175 break;
176 default:
177 printk("type %lu\n", boot_mem_map.map[i].type);
178 break;
183 static inline void parse_cmdline_early(void)
185 char c = ' ', *to = command_line, *from = saved_command_line;
186 unsigned long start_at, mem_size;
187 int len = 0;
188 int usermem = 0;
190 printk("Determined physical RAM map:\n");
191 print_memory_map();
193 for (;;) {
195 * "mem=XXX[kKmM]" defines a memory region from
196 * 0 to <XXX>, overriding the determined size.
197 * "mem=XXX[KkmM]@YYY[KkmM]" defines a memory region from
198 * <YYY> to <YYY>+<XXX>, overriding the determined size.
200 if (c == ' ' && !memcmp(from, "mem=", 4)) {
201 if (to != command_line)
202 to--;
204 * If a user specifies memory size, we
205 * blow away any automatically generated
206 * size.
208 if (usermem == 0) {
209 boot_mem_map.nr_map = 0;
210 usermem = 1;
212 mem_size = memparse(from + 4, &from);
213 if (*from == '@')
214 start_at = memparse(from + 1, &from);
215 else
216 start_at = 0;
217 add_memory_region(start_at, mem_size, BOOT_MEM_RAM);
219 c = *(from++);
220 if (!c)
221 break;
222 if (CL_SIZE <= ++len)
223 break;
224 *(to++) = c;
226 *to = '\0';
228 if (usermem) {
229 printk("User-defined physical RAM map:\n");
230 print_memory_map();
235 #define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
236 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
237 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
239 static inline void bootmem_init(void)
241 #ifdef CONFIG_BLK_DEV_INITRD
242 unsigned long tmp;
243 unsigned long *initrd_header;
244 #endif
245 unsigned long bootmap_size;
246 unsigned long start_pfn, max_pfn;
247 int i;
249 #ifdef CONFIG_BLK_DEV_INITRD
250 tmp = (((unsigned long)&_end + PAGE_SIZE-1) & PAGE_MASK) - 8;
251 if (tmp < (unsigned long)&_end)
252 tmp += PAGE_SIZE;
253 initrd_header = (unsigned long *)tmp;
254 if (initrd_header[0] == 0x494E5244) {
255 initrd_start = (unsigned long)&initrd_header[2];
256 initrd_end = initrd_start + initrd_header[1];
258 start_pfn = PFN_UP(CPHYSADDR((&_end)+(initrd_end - initrd_start) + PAGE_SIZE));
259 #else
261 * Partially used pages are not usable - thus
262 * we are rounding upwards.
264 start_pfn = PFN_UP(CPHYSADDR(&_end));
265 #endif /* CONFIG_BLK_DEV_INITRD */
267 #ifndef CONFIG_SGI_IP27
268 /* Find the highest page frame number we have available. */
269 max_pfn = 0;
270 for (i = 0; i < boot_mem_map.nr_map; i++) {
271 unsigned long start, end;
273 if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
274 continue;
276 start = PFN_UP(boot_mem_map.map[i].addr);
277 end = PFN_DOWN(boot_mem_map.map[i].addr
278 + boot_mem_map.map[i].size);
280 if (start >= end)
281 continue;
282 if (end > max_pfn)
283 max_pfn = end;
286 /* Initialize the boot-time allocator. */
287 bootmap_size = init_bootmem(start_pfn, max_pfn);
290 * Register fully available low RAM pages with the bootmem allocator.
292 for (i = 0; i < boot_mem_map.nr_map; i++) {
293 unsigned long curr_pfn, last_pfn, size;
296 * Reserve usable memory.
298 if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
299 continue;
302 * We are rounding up the start address of usable memory:
304 curr_pfn = PFN_UP(boot_mem_map.map[i].addr);
305 if (curr_pfn >= max_pfn)
306 continue;
307 if (curr_pfn < start_pfn)
308 curr_pfn = start_pfn;
311 * ... and at the end of the usable range downwards:
313 last_pfn = PFN_DOWN(boot_mem_map.map[i].addr
314 + boot_mem_map.map[i].size);
316 if (last_pfn > max_pfn)
317 last_pfn = max_pfn;
320 * ... finally, did all the rounding and playing
321 * around just make the area go away?
323 if (last_pfn <= curr_pfn)
324 continue;
326 size = last_pfn - curr_pfn;
327 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
330 /* Reserve the bootmap memory. */
331 reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size);
332 #endif
334 #ifdef CONFIG_BLK_DEV_INITRD
335 /* Board specific code should have set up initrd_start and initrd_end */
336 ROOT_DEV = Root_RAM0;
337 if (&__rd_start != &__rd_end) {
338 initrd_start = (unsigned long)&__rd_start;
339 initrd_end = (unsigned long)&__rd_end;
341 initrd_below_start_ok = 1;
342 if (initrd_start) {
343 unsigned long initrd_size = ((unsigned char *)initrd_end) - ((unsigned char *)initrd_start);
344 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
345 (void *)initrd_start,
346 initrd_size);
347 /* FIXME: is this right? */
348 #ifndef CONFIG_SGI_IP27
349 if (CPHYSADDR(initrd_end) > PFN_PHYS(max_pfn)) {
350 printk("initrd extends beyond end of memory "
351 "(0x%p > 0x%p)\ndisabling initrd\n",
352 (void *)CPHYSADDR(initrd_end),
353 (void *)PFN_PHYS(max_pfn));
354 initrd_start = 0;
356 #endif /* !CONFIG_SGI_IP27 */
358 #endif
361 static inline void resource_init(void)
363 int i;
365 code_resource.start = virt_to_bus(&_text);
366 code_resource.end = virt_to_bus(&_etext) - 1;
367 data_resource.start = virt_to_bus(&_etext);
368 data_resource.end = virt_to_bus(&_edata) - 1;
371 * Request address space for all standard RAM.
373 for (i = 0; i < boot_mem_map.nr_map; i++) {
374 struct resource *res;
376 res = alloc_bootmem(sizeof(struct resource));
377 switch (boot_mem_map.map[i].type) {
378 case BOOT_MEM_RAM:
379 case BOOT_MEM_ROM_DATA:
380 res->name = "System RAM";
381 break;
382 case BOOT_MEM_RESERVED:
383 default:
384 res->name = "reserved";
387 res->start = boot_mem_map.map[i].addr;
388 res->end = boot_mem_map.map[i].addr +
389 boot_mem_map.map[i].size - 1;
391 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
392 request_resource(&iomem_resource, res);
395 * We don't know which RAM region contains kernel data,
396 * so we try it repeatedly and let the resource manager
397 * test it.
399 request_resource(res, &code_resource);
400 request_resource(res, &data_resource);
404 #undef PFN_UP
405 #undef PFN_DOWN
406 #undef PFN_PHYS
409 void __init setup_arch(char **cmdline_p)
411 extern void decstation_setup(void);
412 extern void ip22_setup(void);
413 extern void ip27_setup(void);
414 extern void ip32_setup(void);
415 extern void swarm_setup(void);
416 extern void malta_setup(void);
417 extern void momenco_ocelot_setup(void);
418 extern void momenco_ocelot_g_setup(void);
419 extern void momenco_ocelot_c_setup(void);
420 extern void swarm_setup(void);
421 void frame_info_init(void);
423 frame_info_init();
424 #ifdef CONFIG_DECSTATION
425 decstation_setup();
426 #endif
427 #ifdef CONFIG_SGI_IP22
428 ip22_setup();
429 #endif
430 #ifdef CONFIG_SGI_IP27
431 ip27_setup();
432 #endif
433 #ifdef CONFIG_SGI_IP32
434 ip32_setup();
435 #endif
436 #ifdef CONFIG_SIBYTE_BOARD
437 swarm_setup();
438 #endif
439 #ifdef CONFIG_MIPS_MALTA
440 malta_setup();
441 #endif
442 #ifdef CONFIG_MOMENCO_OCELOT
443 case MACH_GROUP_MOMENCO:
444 momenco_ocelot_setup();
445 break;
446 #endif
447 #ifdef CONFIG_MOMENCO_OCELOT_G
448 case MACH_GROUP_MOMENCO:
449 momenco_ocelot_g_setup();
450 break;
451 #endif
452 #ifdef CONFIG_MOMENCO_OCELOT_C
453 case MACH_GROUP_MOMENCO:
454 momenco_ocelot_c_setup();
455 break;
456 #endif
459 strlcpy(command_line, arcs_cmdline, sizeof(command_line));
460 strlcpy(saved_command_line, command_line, sizeof(saved_command_line));
462 *cmdline_p = command_line;
464 parse_cmdline_early();
466 bootmem_init();
468 paging_init();
470 resource_init();
473 int __init fpu_disable(char *s)
475 cpu_data[0].options &= ~MIPS_CPU_FPU;
477 return 1;
480 __setup("nofpu", fpu_disable);