ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / sibyte / sb1250 / prom.c
1 /*
2  * Copyright (C) 2000, 2001 Broadcom Corporation
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #include <linux/config.h>
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/mm.h>
23 #include <linux/blkdev.h>
24 #include <linux/bootmem.h>
25 #include <linux/smp.h>
26
27 #include <asm/bootinfo.h>
28 #include <asm/reboot.h>
29
30 #ifdef CONFIG_EMBEDDED_RAMDISK
31 /* These are symbols defined by the ramdisk linker script */
32 extern unsigned char __rd_start;
33 extern unsigned char __rd_end;
34 #endif
35
36 #define MAX_RAM_SIZE ((CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024) - 1)
37
38 static __init void prom_meminit(void)
39 {
40 #ifdef CONFIG_BLK_DEV_INITRD
41         unsigned long initrd_pstart;
42         unsigned long initrd_pend;
43
44 #ifdef CONFIG_EMBEDDED_RAMDISK
45         /* If we're using an embedded ramdisk, then __rd_start and __rd_end
46            are defined by the linker to be on either side of the ramdisk
47            area.  Otherwise, initrd_start should be defined by kernel command
48            line arguments */
49         if (initrd_start == 0) {
50                 initrd_start = (unsigned long)&__rd_start;
51                 initrd_end = (unsigned long)&__rd_end;
52         }
53 #endif
54
55         initrd_pstart = __pa(initrd_start);
56         initrd_pend = __pa(initrd_end);
57         if (initrd_start &&
58             ((initrd_pstart > MAX_RAM_SIZE)
59              || (initrd_pend > MAX_RAM_SIZE))) {
60                 panic("initrd out of addressable memory");
61         }
62
63         add_memory_region(0, initrd_pstart,
64                           BOOT_MEM_RAM);
65         add_memory_region(initrd_pstart, initrd_pend - initrd_pstart,
66                           BOOT_MEM_RESERVED);
67         add_memory_region(initrd_pend,
68                           (CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024) - initrd_pend,
69                           BOOT_MEM_RAM);
70 #else
71         add_memory_region(0, CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024,
72                           BOOT_MEM_RAM);
73 #endif
74 }
75
76 void prom_cpu0_exit(void *unused)
77 {
78         while (1) ;
79 }
80
81 static void prom_linux_exit(void)
82 {
83 #ifdef CONFIG_SMP
84         if (smp_processor_id()) {
85                 smp_call_function(prom_cpu0_exit,NULL,1,1);
86         }
87 #endif
88         while(1);
89 }
90
91 /*
92  * prom_init is called just after the cpu type is determined, from setup_arch()
93  */
94 void __init prom_init(void)
95 {
96         _machine_restart   = (void (*)(char *))prom_linux_exit;
97         _machine_halt      = prom_linux_exit;
98         _machine_power_off = prom_linux_exit;
99
100         strcpy(arcs_cmdline, "root=/dev/ram0 ");
101
102         mips_machgroup = MACH_GROUP_SIBYTE;
103         prom_meminit();
104 }
105
106 unsigned long __init prom_free_prom_memory(void)
107 {
108         /* Not sure what I'm supposed to do here.  Nothing, I think */
109         return 0;
110 }
111
112 void prom_putchar(char c)
113 {
114 }