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
6 * Copyright (C) 1995 Linus Torvalds
7 * Copyright (C) 1995 Waldorf Electronics
8 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 Ralf Baechle
9 * Copyright (C) 1996 Stoned Elipot
10 * Copyright (C) 2000, 2001, 2002 Maciej W. Rozycki
12 #include <linux/config.h>
13 #include <linux/errno.h>
14 #include <linux/hdreg.h>
15 #include <linux/init.h>
16 #include <linux/ioport.h>
17 #include <linux/sched.h>
18 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/stddef.h>
22 #include <linux/string.h>
23 #include <linux/unistd.h>
24 #include <linux/slab.h>
25 #include <linux/user.h>
26 #include <linux/utsname.h>
27 #include <linux/a.out.h>
28 #include <linux/tty.h>
29 #include <linux/bootmem.h>
30 #include <linux/blk.h>
31 #include <linux/ide.h>
32 #include <linux/timex.h>
35 #include <asm/bootinfo.h>
36 #include <asm/cachectl.h>
39 #include <asm/ptrace.h>
40 #include <asm/system.h>
42 struct cpuinfo_mips cpu_data
[NR_CPUS
];
43 EXPORT_SYMBOL(cpu_data
);
46 * There are several bus types available for MIPS machines. "RISC PC"
47 * type machines have ISA, EISA, VLB or PCI available, DECstations
48 * have Turbochannel or Q-Bus, SGI has GIO, there are lots of VME
50 * This flag is set if a EISA slots are available.
56 struct screen_info screen_info
;
58 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
59 #include <asm/floppy.h>
60 extern struct fd_ops no_fd_ops
;
61 struct fd_ops
*fd_ops
;
64 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
65 extern struct ide_ops no_ide_ops
;
66 struct ide_ops
*ide_ops
;
69 extern void * __rd_start
, * __rd_end
;
71 extern struct rtc_ops no_rtc_ops
;
72 struct rtc_ops
*rtc_ops
;
75 struct kbd_ops
*kbd_ops
;
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 unsigned char aux_device_present
;
89 extern char _ftext
, _etext
, _fdata
, _edata
, _end
;
91 static char command_line
[CL_SIZE
];
92 char saved_command_line
[CL_SIZE
];
93 extern char arcs_cmdline
[CL_SIZE
];
96 * mips_io_port_base is the begin of the address space to which x86 style
97 * I/O ports are mapped.
99 const unsigned long mips_io_port_base
= -1;
100 EXPORT_SYMBOL(mips_io_port_base
);
104 * isa_slot_offset is the address where E(ISA) busaddress 0 is mapped
107 unsigned long isa_slot_offset
;
108 EXPORT_SYMBOL(isa_slot_offset
);
110 extern void SetUpBootInfo(void);
111 extern void load_mmu(void);
112 extern asmlinkage
void start_kernel(void);
113 extern void prom_init(int, char **, char **, int *);
115 static struct resource code_resource
= { "Kernel code" };
116 static struct resource data_resource
= { "Kernel data" };
118 asmlinkage
void __init
119 init_arch(int argc
, char **argv
, char **envp
, int *prom_vec
)
121 /* Determine which MIPS variant we are running on. */
124 prom_init(argc
, argv
, envp
, prom_vec
);
129 * Determine the mmu/cache attached to this machine,
130 * then flush the tlb and caches. On the r4xx0
131 * variants this also sets CP0_WIRED to zero.
135 /* Disable coprocessors and set FPU for 16/32 FPR register model */
136 clear_c0_status(ST0_CU1
|ST0_CU2
|ST0_CU3
|ST0_KX
|ST0_SX
|ST0_FR
);
137 set_c0_status(ST0_CU0
);
142 void __init
add_memory_region(phys_t start
, phys_t size
,
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");
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)
162 for (i
= 0; i
< boot_mem_map
.nr_map
; i
++) {
163 printk(" memory: %08Lx @ %08Lx ",
164 (u64
) boot_mem_map
.map
[i
].size
,
165 (u64
) boot_mem_map
.map
[i
].addr
);
167 switch (boot_mem_map
.map
[i
].type
) {
169 printk("(usable)\n");
171 case BOOT_MEM_ROM_DATA
:
172 printk("(ROM data)\n");
174 case BOOT_MEM_RESERVED
:
175 printk("(reserved)\n");
178 printk("type %lu\n", boot_mem_map
.map
[i
].type
);
184 static inline void parse_mem_cmdline(void)
186 char c
= ' ', *to
= command_line
, *from
= saved_command_line
;
187 unsigned long start_at
, mem_size
;
191 printk("Determined physical RAM map:\n");
196 * "mem=XXX[kKmM]" defines a memory region from
197 * 0 to <XXX>, overriding the determined size.
198 * "mem=XXX[KkmM]@YYY[KkmM]" defines a memory region from
199 * <YYY> to <YYY>+<XXX>, overriding the determined size.
201 if (c
== ' ' && !memcmp(from
, "mem=", 4)) {
202 if (to
!= command_line
)
205 * If a user specifies memory size, we
206 * blow away any automatically generated
210 boot_mem_map
.nr_map
= 0;
213 mem_size
= memparse(from
+ 4, &from
);
215 start_at
= memparse(from
+ 1, &from
);
218 add_memory_region(start_at
, mem_size
, BOOT_MEM_RAM
);
223 if (CL_SIZE
<= ++len
)
230 printk("User-defined physical RAM map:\n");
236 #define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
237 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
238 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
240 #define MAXMEM HIGHMEM_START
241 #define MAXMEM_PFN PFN_DOWN(MAXMEM)
243 static inline void bootmem_init(void)
245 #ifdef CONFIG_BLK_DEV_INITRD
247 unsigned long *initrd_header
;
249 unsigned long bootmap_size
;
250 unsigned long start_pfn
, max_pfn
, max_low_pfn
, first_usable_pfn
;
253 #ifdef CONFIG_BLK_DEV_INITRD
254 tmp
= (((unsigned long)&_end
+ PAGE_SIZE
-1) & PAGE_MASK
) - 8;
255 if (tmp
< (unsigned long)&_end
)
257 initrd_header
= (unsigned long *)tmp
;
258 if (initrd_header
[0] == 0x494E5244) {
259 initrd_start
= (unsigned long)&initrd_header
[2];
260 initrd_end
= initrd_start
+ initrd_header
[1];
262 start_pfn
= PFN_UP(__pa((&_end
)+(initrd_end
- initrd_start
) + PAGE_SIZE
));
265 * Partially used pages are not usable - thus
266 * we are rounding upwards.
268 start_pfn
= PFN_UP(__pa(&_end
));
269 #endif /* CONFIG_BLK_DEV_INITRD */
271 /* Find the highest page frame number we have available. */
273 first_usable_pfn
= -1UL;
274 for (i
= 0; i
< boot_mem_map
.nr_map
; i
++) {
275 unsigned long start
, end
;
277 if (boot_mem_map
.map
[i
].type
!= BOOT_MEM_RAM
)
280 start
= PFN_UP(boot_mem_map
.map
[i
].addr
);
281 end
= PFN_DOWN(boot_mem_map
.map
[i
].addr
282 + boot_mem_map
.map
[i
].size
);
288 if (start
< first_usable_pfn
) {
289 if (start
> start_pfn
) {
290 first_usable_pfn
= start
;
291 } else if (end
> start_pfn
) {
292 first_usable_pfn
= start_pfn
;
298 * Determine low and high memory ranges
300 max_low_pfn
= max_pfn
;
301 if (max_low_pfn
> MAXMEM_PFN
) {
302 max_low_pfn
= MAXMEM_PFN
;
303 #ifndef CONFIG_HIGHMEM
304 /* Maximum memory usable is what is directly addressable */
305 printk(KERN_WARNING
"Warning only %ldMB will be used.\n",
307 printk(KERN_WARNING
"Use a HIGHMEM enabled kernel.\n");
311 #ifdef CONFIG_HIGHMEM
313 * Crude, we really should make a better attempt at detecting
316 highstart_pfn
= highend_pfn
= max_pfn
;
317 if (max_pfn
> MAXMEM_PFN
) {
318 highstart_pfn
= MAXMEM_PFN
;
319 printk(KERN_NOTICE
"%ldMB HIGHMEM available.\n",
320 (highend_pfn
- highstart_pfn
) >> (20 - PAGE_SHIFT
));
324 /* Initialize the boot-time allocator with low memory only. */
325 bootmap_size
= init_bootmem(first_usable_pfn
, max_low_pfn
);
328 * Register fully available low RAM pages with the bootmem allocator.
330 for (i
= 0; i
< boot_mem_map
.nr_map
; i
++) {
331 unsigned long curr_pfn
, last_pfn
, size
;
334 * Reserve usable memory.
336 if (boot_mem_map
.map
[i
].type
!= BOOT_MEM_RAM
)
340 * We are rounding up the start address of usable memory:
342 curr_pfn
= PFN_UP(boot_mem_map
.map
[i
].addr
);
343 if (curr_pfn
>= max_low_pfn
)
345 if (curr_pfn
< start_pfn
)
346 curr_pfn
= start_pfn
;
349 * ... and at the end of the usable range downwards:
351 last_pfn
= PFN_DOWN(boot_mem_map
.map
[i
].addr
352 + boot_mem_map
.map
[i
].size
);
354 if (last_pfn
> max_low_pfn
)
355 last_pfn
= max_low_pfn
;
358 * Only register lowmem part of lowmem segment with bootmem.
360 size
= last_pfn
- curr_pfn
;
361 if (curr_pfn
> PFN_DOWN(HIGHMEM_START
))
363 if (curr_pfn
+ size
- 1 > PFN_DOWN(HIGHMEM_START
))
364 size
= PFN_DOWN(HIGHMEM_START
) - curr_pfn
;
369 * ... finally, did all the rounding and playing
370 * around just make the area go away?
372 if (last_pfn
<= curr_pfn
)
375 /* Register lowmem ranges */
376 free_bootmem(PFN_PHYS(curr_pfn
), PFN_PHYS(size
));
379 /* Reserve the bootmap memory. */
380 reserve_bootmem(PFN_PHYS(first_usable_pfn
), bootmap_size
);
382 #ifdef CONFIG_BLK_DEV_INITRD
383 /* Board specific code should have set up initrd_start and initrd_end */
384 ROOT_DEV
= MKDEV(RAMDISK_MAJOR
, 0);
385 if (&__rd_start
!= &__rd_end
) {
386 initrd_start
= (unsigned long)&__rd_start
;
387 initrd_end
= (unsigned long)&__rd_end
;
389 initrd_below_start_ok
= 1;
391 unsigned long initrd_size
= ((unsigned char *)initrd_end
) - ((unsigned char *)initrd_start
);
392 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
393 (void *)initrd_start
,
395 if (PHYSADDR(initrd_end
) > PFN_PHYS(max_low_pfn
)) {
396 printk("initrd extends beyond end of memory "
397 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
398 (unsigned long) PHYSADDR(initrd_end
),
399 PFN_PHYS(max_low_pfn
));
400 initrd_start
= initrd_end
= 0;
403 #endif /* CONFIG_BLK_DEV_INITRD */
406 static inline void resource_init(void)
410 code_resource
.start
= virt_to_bus(&_ftext
);
411 code_resource
.end
= virt_to_bus(&_etext
) - 1;
412 data_resource
.start
= virt_to_bus(&_fdata
);
413 data_resource
.end
= virt_to_bus(&_edata
) - 1;
416 * Request address space for all standard RAM.
418 for (i
= 0; i
< boot_mem_map
.nr_map
; i
++) {
419 struct resource
*res
;
420 unsigned long start
, end
;
422 start
= boot_mem_map
.map
[i
].addr
;
423 end
= boot_mem_map
.map
[i
].addr
+ boot_mem_map
.map
[i
].size
- 1;
429 res
= alloc_bootmem(sizeof(struct resource
));
430 switch (boot_mem_map
.map
[i
].type
) {
432 case BOOT_MEM_ROM_DATA
:
433 res
->name
= "System RAM";
435 case BOOT_MEM_RESERVED
:
437 res
->name
= "reserved";
443 res
->flags
= IORESOURCE_MEM
| IORESOURCE_BUSY
;
444 request_resource(&iomem_resource
, res
);
447 * We dont't know which RAM region contains kernel data,
448 * so we try it repeatedly and let the resource manager
451 request_resource(res
, &code_resource
);
452 request_resource(res
, &data_resource
);
464 void __init
setup_arch(char **cmdline_p
)
466 void atlas_setup(void);
467 void baget_setup(void);
468 void cobalt_setup(void);
469 void lasat_setup(void);
470 void ddb_setup(void);
471 void decstation_setup(void);
472 void deskstation_setup(void);
473 void jazz_setup(void);
474 void sni_rm200_pci_setup(void);
475 void ip22_setup(void);
476 void ev96100_setup(void);
477 void malta_setup(void);
478 void sead_setup(void);
479 void ikos_setup(void);
480 void momenco_ocelot_setup(void);
481 void momenco_ocelot_g_setup(void);
482 void momenco_ocelot_c_setup(void);
483 void momenco_jaguar_atx_setup(void);
484 void nino_setup(void);
485 void nec_osprey_setup(void);
486 void nec_eagle_setup(void);
487 void zao_capcella_setup(void);
488 void victor_mpc30x_setup(void);
489 void ibm_workpad_setup(void);
490 void casio_e55_setup(void);
491 void tanbac_tb0226_setup(void);
492 void jmr3927_setup(void);
493 void tx4927_setup(void);
494 void it8172_setup(void);
495 void swarm_setup(void);
497 void au1x00_setup(void);
498 void frame_info_init(void);
501 #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
505 #ifdef CONFIG_BLK_DEV_IDE
506 ide_ops
= &no_ide_ops
;
509 rtc_ops
= &no_rtc_ops
;
511 switch(mips_machgroup
)
513 #ifdef CONFIG_BAGET_MIPS
514 case MACH_GROUP_BAGET
:
518 #ifdef CONFIG_MIPS_COBALT
519 case MACH_GROUP_COBALT
:
523 #ifdef CONFIG_DECSTATION
528 #ifdef CONFIG_MIPS_ATLAS
529 case MACH_GROUP_UNKNOWN
:
533 #ifdef CONFIG_MIPS_JAZZ
534 case MACH_GROUP_JAZZ
:
538 #ifdef CONFIG_MIPS_MALTA
539 case MACH_GROUP_UNKNOWN
:
543 #ifdef CONFIG_MOMENCO_OCELOT
544 case MACH_GROUP_MOMENCO
:
545 momenco_ocelot_setup();
548 #ifdef CONFIG_MOMENCO_OCELOT_G
549 case MACH_GROUP_MOMENCO
:
550 momenco_ocelot_g_setup();
553 #ifdef CONFIG_MOMENCO_OCELOT_C
554 case MACH_GROUP_MOMENCO
:
555 momenco_ocelot_c_setup();
558 #ifdef CONFIG_MOMENCO_JAGUAR_ATX
559 case MACH_GROUP_MOMENCO
:
560 momenco_jaguar_atx_setup();
563 #ifdef CONFIG_MIPS_SEAD
564 case MACH_GROUP_UNKNOWN
:
568 #ifdef CONFIG_SGI_IP22
569 /* As of now this is only IP22. */
574 #ifdef CONFIG_SNI_RM200_PCI
575 case MACH_GROUP_SNI_RM
:
576 sni_rm200_pci_setup();
579 #ifdef CONFIG_DDB5074
580 case MACH_GROUP_NEC_DDB
:
584 #ifdef CONFIG_DDB5476
585 case MACH_GROUP_NEC_DDB
:
589 #ifdef CONFIG_DDB5477
590 case MACH_GROUP_NEC_DDB
:
594 #ifdef CONFIG_CPU_VR41XX
595 case MACH_GROUP_NEC_VR41XX
:
596 switch (mips_machtype
) {
597 #ifdef CONFIG_NEC_OSPREY
598 case MACH_NEC_OSPREY
:
602 #ifdef CONFIG_NEC_EAGLE
607 #ifdef CONFIG_ZAO_CAPCELLA
608 case MACH_ZAO_CAPCELLA
:
609 zao_capcella_setup();
612 #ifdef CONFIG_VICTOR_MPC30X
613 case MACH_VICTOR_MPC30X
:
614 victor_mpc30x_setup();
617 #ifdef CONFIG_IBM_WORKPAD
618 case MACH_IBM_WORKPAD
:
622 #ifdef CONFIG_CASIO_E55
627 #ifdef CONFIG_TANBAC_TB0226
628 case MACH_TANBAC_TB0226
:
629 tanbac_tb0226_setup();
632 #ifdef CONFIG_TANBAC_TB0229
633 case MACH_TANBAC_TB0229
:
634 tanbac_tb0229_setup();
640 #ifdef CONFIG_MIPS_EV96100
641 case MACH_GROUP_GALILEO
:
645 #ifdef CONFIG_MIPS_EV64120
646 case MACH_GROUP_GALILEO
:
650 #if defined(CONFIG_MIPS_IVR) || defined(CONFIG_MIPS_ITE8172)
652 case MACH_GROUP_GLOBESPAN
:
657 case MACH_GROUP_PHILIPS
:
662 case MACH_GROUP_LASAT
:
666 #ifdef CONFIG_SOC_AU1X00
667 case MACH_GROUP_ALCHEMY
:
671 #ifdef CONFIG_TOSHIBA_JMR3927
672 case MACH_GROUP_TOSHIBA
:
676 #ifdef CONFIG_TOSHIBA_RBTX4927
677 case MACH_GROUP_TOSHIBA
:
681 #ifdef CONFIG_SIBYTE_BOARD
682 case MACH_GROUP_SIBYTE
:
686 #ifdef CONFIG_HP_LASERJET
687 case MACH_GROUP_HP_LJ
:
691 #ifdef CONFIG_PMC_YOSEMITE
692 case MACH_GROUP_TITAN
:
693 pmc_yosemite_setup();
697 panic("Unsupported architecture");
700 strncpy(command_line
, arcs_cmdline
, sizeof command_line
);
701 command_line
[sizeof command_line
- 1] = 0;
702 strcpy(saved_command_line
, command_line
);
703 *cmdline_p
= command_line
;
714 static int __init
fpu_disable(char *s
)
716 cpu_data
[0].options
&= ~MIPS_CPU_FPU
;
720 __setup("nofpu", fpu_disable
);