diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m32r/kernel/setup.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/m32r/kernel/setup.c')
-rw-r--r-- | arch/m32r/kernel/setup.c | 420 |
1 files changed, 420 insertions, 0 deletions
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c new file mode 100644 index 000000000000..4826cd6e40e8 --- /dev/null +++ b/arch/m32r/kernel/setup.c | |||
@@ -0,0 +1,420 @@ | |||
1 | /* | ||
2 | * linux/arch/m32r/kernel/setup.c | ||
3 | * | ||
4 | * Setup routines for Renesas M32R | ||
5 | * | ||
6 | * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, | ||
7 | * Hitoshi Yamamoto | ||
8 | */ | ||
9 | |||
10 | #include <linux/config.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/stddef.h> | ||
13 | #include <linux/fs.h> | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/ioport.h> | ||
16 | #include <linux/mm.h> | ||
17 | #include <linux/bootmem.h> | ||
18 | #include <linux/console.h> | ||
19 | #include <linux/initrd.h> | ||
20 | #include <linux/major.h> | ||
21 | #include <linux/root_dev.h> | ||
22 | #include <linux/seq_file.h> | ||
23 | #include <linux/timex.h> | ||
24 | #include <linux/tty.h> | ||
25 | #include <linux/cpu.h> | ||
26 | #include <linux/nodemask.h> | ||
27 | |||
28 | #include <asm/processor.h> | ||
29 | #include <asm/pgtable.h> | ||
30 | #include <asm/io.h> | ||
31 | #include <asm/mmu_context.h> | ||
32 | #include <asm/m32r.h> | ||
33 | #include <asm/setup.h> | ||
34 | #include <asm/sections.h> | ||
35 | |||
36 | #ifdef CONFIG_MMU | ||
37 | extern void init_mmu(void); | ||
38 | #endif | ||
39 | |||
40 | #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) \ | ||
41 | || defined(CONFIG_BLK_DEV_IDE_MODULE) \ | ||
42 | || defined(CONFIG_BLK_DEV_HD_MODULE) | ||
43 | struct drive_info_struct { char dummy[32]; } drive_info; | ||
44 | #endif | ||
45 | |||
46 | extern char _end[]; | ||
47 | |||
48 | /* | ||
49 | * Machine setup.. | ||
50 | */ | ||
51 | struct cpuinfo_m32r boot_cpu_data; | ||
52 | |||
53 | #ifdef CONFIG_BLK_DEV_RAM | ||
54 | extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */ | ||
55 | extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */ | ||
56 | extern int rd_image_start; /* starting block # of image */ | ||
57 | #endif | ||
58 | |||
59 | #if defined(CONFIG_VGA_CONSOLE) | ||
60 | struct screen_info screen_info = { | ||
61 | .orig_video_lines = 25, | ||
62 | .orig_video_cols = 80, | ||
63 | .orig_video_mode = 0, | ||
64 | .orig_video_ega_bx = 0, | ||
65 | .orig_video_isVGA = 1, | ||
66 | .orig_video_points = 8 | ||
67 | }; | ||
68 | #endif | ||
69 | |||
70 | extern int root_mountflags; | ||
71 | |||
72 | static char command_line[COMMAND_LINE_SIZE]; | ||
73 | |||
74 | static struct resource data_resource = { | ||
75 | .name = "Kernel data", | ||
76 | .start = 0, | ||
77 | .end = 0, | ||
78 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
79 | }; | ||
80 | |||
81 | static struct resource code_resource = { | ||
82 | .name = "Kernel code", | ||
83 | .start = 0, | ||
84 | .end = 0, | ||
85 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
86 | }; | ||
87 | |||
88 | unsigned long memory_start; | ||
89 | unsigned long memory_end; | ||
90 | |||
91 | void __init setup_arch(char **); | ||
92 | int get_cpuinfo(char *); | ||
93 | |||
94 | static __inline__ void parse_mem_cmdline(char ** cmdline_p) | ||
95 | { | ||
96 | char c = ' '; | ||
97 | char *to = command_line; | ||
98 | char *from = COMMAND_LINE; | ||
99 | int len = 0; | ||
100 | int usermem = 0; | ||
101 | |||
102 | /* Save unparsed command line copy for /proc/cmdline */ | ||
103 | memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); | ||
104 | saved_command_line[COMMAND_LINE_SIZE-1] = '\0'; | ||
105 | |||
106 | memory_start = (unsigned long)CONFIG_MEMORY_START+PAGE_OFFSET; | ||
107 | memory_end = memory_start+(unsigned long)CONFIG_MEMORY_SIZE; | ||
108 | |||
109 | for ( ; ; ) { | ||
110 | if (c == ' ' && !memcmp(from, "mem=", 4)) { | ||
111 | if (to != command_line) | ||
112 | to--; | ||
113 | |||
114 | { | ||
115 | unsigned long mem_size; | ||
116 | |||
117 | usermem = 1; | ||
118 | mem_size = memparse(from+4, &from); | ||
119 | memory_end = memory_start + mem_size; | ||
120 | } | ||
121 | } | ||
122 | c = *(from++); | ||
123 | if (!c) | ||
124 | break; | ||
125 | |||
126 | if (COMMAND_LINE_SIZE <= ++len) | ||
127 | break; | ||
128 | |||
129 | *(to++) = c; | ||
130 | } | ||
131 | *to = '\0'; | ||
132 | *cmdline_p = command_line; | ||
133 | if (usermem) | ||
134 | printk(KERN_INFO "user-defined physical RAM map:\n"); | ||
135 | } | ||
136 | |||
137 | #ifndef CONFIG_DISCONTIGMEM | ||
138 | static unsigned long __init setup_memory(void) | ||
139 | { | ||
140 | unsigned long start_pfn, max_low_pfn, bootmap_size; | ||
141 | |||
142 | start_pfn = PFN_UP( __pa(_end) ); | ||
143 | max_low_pfn = PFN_DOWN( __pa(memory_end) ); | ||
144 | |||
145 | /* | ||
146 | * Initialize the boot-time allocator (with low memory only): | ||
147 | */ | ||
148 | bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, | ||
149 | CONFIG_MEMORY_START>>PAGE_SHIFT, max_low_pfn); | ||
150 | |||
151 | /* | ||
152 | * Register fully available low RAM pages with the bootmem allocator. | ||
153 | */ | ||
154 | { | ||
155 | unsigned long curr_pfn; | ||
156 | unsigned long last_pfn; | ||
157 | unsigned long pages; | ||
158 | |||
159 | /* | ||
160 | * We are rounding up the start address of usable memory: | ||
161 | */ | ||
162 | curr_pfn = PFN_UP(__pa(memory_start)); | ||
163 | |||
164 | /* | ||
165 | * ... and at the end of the usable range downwards: | ||
166 | */ | ||
167 | last_pfn = PFN_DOWN(__pa(memory_end)); | ||
168 | |||
169 | if (last_pfn > max_low_pfn) | ||
170 | last_pfn = max_low_pfn; | ||
171 | |||
172 | pages = last_pfn - curr_pfn; | ||
173 | free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages)); | ||
174 | } | ||
175 | |||
176 | /* | ||
177 | * Reserve the kernel text and | ||
178 | * Reserve the bootmem bitmap. We do this in two steps (first step | ||
179 | * was init_bootmem()), because this catches the (definitely buggy) | ||
180 | * case of us accidentally initializing the bootmem allocator with | ||
181 | * an invalid RAM area. | ||
182 | */ | ||
183 | reserve_bootmem(CONFIG_MEMORY_START + PAGE_SIZE, | ||
184 | (PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE - 1) | ||
185 | - CONFIG_MEMORY_START); | ||
186 | |||
187 | /* | ||
188 | * reserve physical page 0 - it's a special BIOS page on many boxes, | ||
189 | * enabling clean reboots, SMP operation, laptop functions. | ||
190 | */ | ||
191 | reserve_bootmem(CONFIG_MEMORY_START, PAGE_SIZE); | ||
192 | |||
193 | /* | ||
194 | * reserve memory hole | ||
195 | */ | ||
196 | #ifdef CONFIG_MEMHOLE | ||
197 | reserve_bootmem(CONFIG_MEMHOLE_START, CONFIG_MEMHOLE_SIZE); | ||
198 | #endif | ||
199 | |||
200 | #ifdef CONFIG_BLK_DEV_INITRD | ||
201 | if (LOADER_TYPE && INITRD_START) { | ||
202 | if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { | ||
203 | reserve_bootmem(INITRD_START, INITRD_SIZE); | ||
204 | initrd_start = INITRD_START ? | ||
205 | INITRD_START + PAGE_OFFSET : 0; | ||
206 | |||
207 | initrd_end = initrd_start + INITRD_SIZE; | ||
208 | printk("initrd:start[%08lx],size[%08lx]\n", | ||
209 | initrd_start, INITRD_SIZE); | ||
210 | } else { | ||
211 | printk("initrd extends beyond end of memory " | ||
212 | "(0x%08lx > 0x%08lx)\ndisabling initrd\n", | ||
213 | INITRD_START + INITRD_SIZE, | ||
214 | max_low_pfn << PAGE_SHIFT); | ||
215 | |||
216 | initrd_start = 0; | ||
217 | } | ||
218 | } | ||
219 | #endif | ||
220 | |||
221 | return max_low_pfn; | ||
222 | } | ||
223 | #else /* CONFIG_DISCONTIGMEM */ | ||
224 | extern unsigned long setup_memory(void); | ||
225 | #endif /* CONFIG_DISCONTIGMEM */ | ||
226 | |||
227 | #define M32R_PCC_PCATCR 0x00ef7014 /* will move to m32r.h */ | ||
228 | |||
229 | void __init setup_arch(char **cmdline_p) | ||
230 | { | ||
231 | ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV); | ||
232 | |||
233 | boot_cpu_data.cpu_clock = M32R_CPUCLK; | ||
234 | boot_cpu_data.bus_clock = M32R_BUSCLK; | ||
235 | boot_cpu_data.timer_divide = M32R_TIMER_DIVIDE; | ||
236 | |||
237 | #ifdef CONFIG_BLK_DEV_RAM | ||
238 | rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK; | ||
239 | rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0); | ||
240 | rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0); | ||
241 | #endif | ||
242 | |||
243 | if (!MOUNT_ROOT_RDONLY) | ||
244 | root_mountflags &= ~MS_RDONLY; | ||
245 | |||
246 | #ifdef CONFIG_VT | ||
247 | #if defined(CONFIG_VGA_CONSOLE) | ||
248 | conswitchp = &vga_con; | ||
249 | #elif defined(CONFIG_DUMMY_CONSOLE) | ||
250 | conswitchp = &dummy_con; | ||
251 | #endif | ||
252 | #endif | ||
253 | |||
254 | #ifdef CONFIG_DISCONTIGMEM | ||
255 | nodes_clear(node_online_map); | ||
256 | node_set_online(0); | ||
257 | node_set_online(1); | ||
258 | #endif /* CONFIG_DISCONTIGMEM */ | ||
259 | |||
260 | init_mm.start_code = (unsigned long) _text; | ||
261 | init_mm.end_code = (unsigned long) _etext; | ||
262 | init_mm.end_data = (unsigned long) _edata; | ||
263 | init_mm.brk = (unsigned long) _end; | ||
264 | |||
265 | code_resource.start = virt_to_phys(_text); | ||
266 | code_resource.end = virt_to_phys(_etext)-1; | ||
267 | data_resource.start = virt_to_phys(_etext); | ||
268 | data_resource.end = virt_to_phys(_edata)-1; | ||
269 | |||
270 | parse_mem_cmdline(cmdline_p); | ||
271 | |||
272 | setup_memory(); | ||
273 | |||
274 | paging_init(); | ||
275 | } | ||
276 | |||
277 | static struct cpu cpu[NR_CPUS]; | ||
278 | |||
279 | static int __init topology_init(void) | ||
280 | { | ||
281 | int cpu_id; | ||
282 | |||
283 | for (cpu_id = 0; cpu_id < NR_CPUS; cpu_id++) | ||
284 | if (cpu_possible(cpu_id)) | ||
285 | register_cpu(&cpu[cpu_id], cpu_id, NULL); | ||
286 | |||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | subsys_initcall(topology_init); | ||
291 | |||
292 | #ifdef CONFIG_PROC_FS | ||
293 | /* | ||
294 | * Get CPU information for use by the procfs. | ||
295 | */ | ||
296 | static int show_cpuinfo(struct seq_file *m, void *v) | ||
297 | { | ||
298 | struct cpuinfo_m32r *c = v; | ||
299 | unsigned long cpu = c - cpu_data; | ||
300 | |||
301 | #ifdef CONFIG_SMP | ||
302 | if (!cpu_online(cpu)) | ||
303 | return 0; | ||
304 | #endif /* CONFIG_SMP */ | ||
305 | |||
306 | seq_printf(m, "processor\t: %ld\n", cpu); | ||
307 | |||
308 | #ifdef CONFIG_CHIP_VDEC2 | ||
309 | seq_printf(m, "cpu family\t: VDEC2\n" | ||
310 | "cache size\t: Unknown\n"); | ||
311 | #elif CONFIG_CHIP_M32700 | ||
312 | seq_printf(m,"cpu family\t: M32700\n" | ||
313 | "cache size\t: I-8KB/D-8KB\n"); | ||
314 | #elif CONFIG_CHIP_M32102 | ||
315 | seq_printf(m,"cpu family\t: M32102\n" | ||
316 | "cache size\t: I-8KB\n"); | ||
317 | #elif CONFIG_CHIP_OPSP | ||
318 | seq_printf(m,"cpu family\t: OPSP\n" | ||
319 | "cache size\t: I-8KB/D-8KB\n"); | ||
320 | #elif CONFIG_CHIP_MP | ||
321 | seq_printf(m, "cpu family\t: M32R-MP\n" | ||
322 | "cache size\t: I-xxKB/D-xxKB\n"); | ||
323 | #else | ||
324 | seq_printf(m, "cpu family\t: Unknown\n"); | ||
325 | #endif | ||
326 | seq_printf(m, "bogomips\t: %lu.%02lu\n", | ||
327 | c->loops_per_jiffy/(500000/HZ), | ||
328 | (c->loops_per_jiffy/(5000/HZ)) % 100); | ||
329 | #ifdef CONFIG_PLAT_MAPPI | ||
330 | seq_printf(m, "Machine\t\t: Mappi Evaluation board\n"); | ||
331 | #elif CONFIG_PLAT_MAPPI2 | ||
332 | seq_printf(m, "Machine\t\t: Mappi-II Evaluation board\n"); | ||
333 | #elif CONFIG_PLAT_M32700UT | ||
334 | seq_printf(m, "Machine\t\t: M32700UT Evaluation board\n"); | ||
335 | #elif CONFIG_PLAT_OPSPUT | ||
336 | seq_printf(m, "Machine\t\t: OPSPUT Evaluation board\n"); | ||
337 | #elif CONFIG_PLAT_USRV | ||
338 | seq_printf(m, "Machine\t\t: uServer\n"); | ||
339 | #elif CONFIG_PLAT_OAKS32R | ||
340 | seq_printf(m, "Machine\t\t: OAKS32R\n"); | ||
341 | #else | ||
342 | seq_printf(m, "Machine\t\t: Unknown\n"); | ||
343 | #endif | ||
344 | |||
345 | #define PRINT_CLOCK(name, value) \ | ||
346 | seq_printf(m, name " clock\t: %d.%02dMHz\n", \ | ||
347 | ((value) / 1000000), ((value) % 1000000)/10000) | ||
348 | |||
349 | PRINT_CLOCK("CPU", (int)c->cpu_clock); | ||
350 | PRINT_CLOCK("Bus", (int)c->bus_clock); | ||
351 | |||
352 | seq_printf(m, "\n"); | ||
353 | |||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
358 | { | ||
359 | return *pos < NR_CPUS ? cpu_data + *pos : NULL; | ||
360 | } | ||
361 | |||
362 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
363 | { | ||
364 | ++*pos; | ||
365 | return c_start(m, pos); | ||
366 | } | ||
367 | |||
368 | static void c_stop(struct seq_file *m, void *v) | ||
369 | { | ||
370 | } | ||
371 | |||
372 | struct seq_operations cpuinfo_op = { | ||
373 | start: c_start, | ||
374 | next: c_next, | ||
375 | stop: c_stop, | ||
376 | show: show_cpuinfo, | ||
377 | }; | ||
378 | #endif /* CONFIG_PROC_FS */ | ||
379 | |||
380 | unsigned long cpu_initialized __initdata = 0; | ||
381 | |||
382 | /* | ||
383 | * cpu_init() initializes state that is per-CPU. Some data is already | ||
384 | * initialized (naturally) in the bootstrap process. | ||
385 | * We reload them nevertheless, this function acts as a | ||
386 | * 'CPU state barrier', nothing should get across. | ||
387 | */ | ||
388 | #if defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_XNUX2) \ | ||
389 | || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \ | ||
390 | || defined(CONFIG_CHIP_OPSP) | ||
391 | void __init cpu_init (void) | ||
392 | { | ||
393 | int cpu_id = smp_processor_id(); | ||
394 | |||
395 | if (test_and_set_bit(cpu_id, &cpu_initialized)) { | ||
396 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu_id); | ||
397 | for ( ; ; ) | ||
398 | local_irq_enable(); | ||
399 | } | ||
400 | printk(KERN_INFO "Initializing CPU#%d\n", cpu_id); | ||
401 | |||
402 | /* Set up and load the per-CPU TSS and LDT */ | ||
403 | atomic_inc(&init_mm.mm_count); | ||
404 | current->active_mm = &init_mm; | ||
405 | if (current->mm) | ||
406 | BUG(); | ||
407 | |||
408 | /* Force FPU initialization */ | ||
409 | current_thread_info()->status = 0; | ||
410 | clear_used_math(); | ||
411 | |||
412 | #ifdef CONFIG_MMU | ||
413 | /* Set up MMU */ | ||
414 | init_mmu(); | ||
415 | #endif | ||
416 | |||
417 | /* Set up ICUIMASK */ | ||
418 | outl(0x00070000, M32R_ICU_IMASK_PORTL); /* imask=111 */ | ||
419 | } | ||
420 | #endif /* defined(CONFIG_CHIP_VDEC2) ... */ | ||