score: add old syscall support
[safe/jmp/linux-2.6] / arch / score / kernel / setup.c
1 /*
2  * arch/score/kernel/setup.c
3  *
4  * Score Processor version.
5  *
6  * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
7  *  Chen Liqin <liqin.chen@sunplusct.com>
8  *  Lennox Wu <lennox.wu@sunplusct.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, see the file COPYING, or write
22  * to the Free Software Foundation, Inc.,
23  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24  */
25
26 #include <linux/bootmem.h>
27 #include <linux/initrd.h>
28 #include <linux/ioport.h>
29 #include <linux/mm.h>
30 #include <linux/seq_file.h>
31 #include <linux/screen_info.h>
32
33 #include <asm-generic/sections.h>
34 #include <asm/setup.h>
35
36 struct screen_info screen_info;
37 unsigned long kernelsp;
38
39 static char command_line[COMMAND_LINE_SIZE];
40 static struct resource code_resource = { .name = "Kernel code",};
41 static struct resource data_resource = { .name = "Kernel data",};
42
43 static void __init bootmem_init(void)
44 {
45         unsigned long start_pfn, bootmap_size;
46         unsigned long size = initrd_end - initrd_start;
47
48         start_pfn = PFN_UP(__pa(&_end));
49
50         min_low_pfn = PFN_UP(MEMORY_START);
51         max_low_pfn = PFN_UP(MEMORY_START + MEMORY_SIZE);
52
53         /* Initialize the boot-time allocator with low memory only. */
54         bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
55                                          min_low_pfn, max_low_pfn);
56         add_active_range(0, min_low_pfn, max_low_pfn);
57
58         free_bootmem(PFN_PHYS(start_pfn),
59                      (max_low_pfn - start_pfn) << PAGE_SHIFT);
60         memory_present(0, start_pfn, max_low_pfn);
61
62         /* Reserve space for the bootmem bitmap. */
63         reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT);
64
65         if (size == 0) {
66                 printk(KERN_INFO "Initrd not found or empty");
67                 goto disable;
68         }
69
70         if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) {
71                 printk(KERN_ERR "Initrd extends beyond end of memory");
72                 goto disable;
73         }
74
75         /* Reserve space for the initrd bitmap. */
76         reserve_bootmem(__pa(initrd_start), size, BOOTMEM_DEFAULT);
77         initrd_below_start_ok = 1;
78
79         pr_info("Initial ramdisk at: 0x%lx (%lu bytes)\n",
80                  initrd_start, size);
81         return;
82 disable:
83         printk(KERN_CONT " - disabling initrd\n");
84         initrd_start = 0;
85         initrd_end = 0;
86 }
87
88 static void __init resource_init(void)
89 {
90         struct resource *res;
91
92         code_resource.start = __pa(&_text);
93         code_resource.end = __pa(&_etext) - 1;
94         data_resource.start = __pa(&_etext);
95         data_resource.end = __pa(&_edata) - 1;
96
97         res = alloc_bootmem(sizeof(struct resource));
98         res->name = "System RAM";
99         res->start = MEMORY_START;
100         res->end = MEMORY_START + MEMORY_SIZE - 1;
101         res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
102         request_resource(&iomem_resource, res);
103
104         request_resource(res, &code_resource);
105         request_resource(res, &data_resource);
106 }
107
108 void __init setup_arch(char **cmdline_p)
109 {
110         randomize_va_space = 0;
111         *cmdline_p = command_line;
112
113         cpu_cache_init();
114         tlb_init();
115         bootmem_init();
116         paging_init();
117         resource_init();
118 }
119
120 static int show_cpuinfo(struct seq_file *m, void *v)
121 {
122         unsigned long n = (unsigned long) v - 1;
123
124         seq_printf(m, "processor\t\t: %ld\n", n);
125         seq_printf(m, "\n");
126
127         return 0;
128 }
129
130 static void *c_start(struct seq_file *m, loff_t *pos)
131 {
132         unsigned long i = *pos;
133
134         return i < 1 ? (void *) (i + 1) : NULL;
135 }
136
137 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
138 {
139         ++*pos;
140         return c_start(m, pos);
141 }
142
143 static void c_stop(struct seq_file *m, void *v)
144 {
145 }
146
147 const struct seq_operations cpuinfo_op = {
148         .start  = c_start,
149         .next   = c_next,
150         .stop   = c_stop,
151         .show   = show_cpuinfo,
152 };
153
154 static int __init topology_init(void)
155 {
156         return 0;
157 }
158
159 subsys_initcall(topology_init);