Commit | Line | Data |
---|---|---|
711fa809 | 1 | /* |
1da177e4 LT |
2 | * linux/arch/sh/kernel/setup.c |
3 | * | |
4 | * Copyright (C) 1999 Niibe Yutaka | |
5 | * Copyright (C) 2002, 2003 Paul Mundt | |
6 | */ | |
7 | ||
8 | /* | |
9 | * This file handles the architecture-dependent parts of initialization | |
10 | */ | |
11 | ||
894673ee | 12 | #include <linux/screen_info.h> |
1da177e4 LT |
13 | #include <linux/ioport.h> |
14 | #include <linux/init.h> | |
15 | #include <linux/initrd.h> | |
16 | #include <linux/bootmem.h> | |
17 | #include <linux/console.h> | |
18 | #include <linux/seq_file.h> | |
19 | #include <linux/root_dev.h> | |
20 | #include <linux/utsname.h> | |
21 | #include <linux/cpu.h> | |
22a9835c | 22 | #include <linux/pfn.h> |
711fa809 | 23 | #include <linux/fs.h> |
1da177e4 LT |
24 | #include <asm/uaccess.h> |
25 | #include <asm/io.h> | |
1da177e4 LT |
26 | #include <asm/sections.h> |
27 | #include <asm/irq.h> | |
28 | #include <asm/setup.h> | |
de02797a | 29 | #include <asm/clock.h> |
1da177e4 LT |
30 | |
31 | #ifdef CONFIG_SH_KGDB | |
32 | #include <asm/kgdb.h> | |
33 | static int kgdb_parse_options(char *options); | |
34 | #endif | |
35 | extern void * __rd_start, * __rd_end; | |
36 | /* | |
37 | * Machine setup.. | |
38 | */ | |
39 | ||
40 | /* | |
41 | * Initialize loops_per_jiffy as 10000000 (1000MIPS). | |
42 | * This value will be used at the very early stage of serial setup. | |
43 | * The bigger value means no problem. | |
44 | */ | |
de02797a | 45 | struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, }; |
2c7834a6 | 46 | #ifdef CONFIG_VT |
1da177e4 | 47 | struct screen_info screen_info; |
2c7834a6 | 48 | #endif |
1da177e4 LT |
49 | |
50 | #if defined(CONFIG_SH_UNKNOWN) | |
51 | struct sh_machine_vector sh_mv; | |
52 | #endif | |
53 | ||
1da177e4 LT |
54 | extern int root_mountflags; |
55 | ||
56 | #define MV_NAME_SIZE 32 | |
57 | ||
58 | static struct sh_machine_vector* __init get_mv_byname(const char* name); | |
59 | ||
60 | /* | |
61 | * This is set up by the setup-routine at boot-time | |
62 | */ | |
63 | #define PARAM ((unsigned char *)empty_zero_page) | |
64 | ||
65 | #define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000)) | |
66 | #define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004)) | |
67 | #define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008)) | |
68 | #define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c)) | |
69 | #define INITRD_START (*(unsigned long *) (PARAM+0x010)) | |
70 | #define INITRD_SIZE (*(unsigned long *) (PARAM+0x014)) | |
71 | /* ... */ | |
72 | #define COMMAND_LINE ((char *) (PARAM+0x100)) | |
73 | ||
65463b73 | 74 | #define RAMDISK_IMAGE_START_MASK 0x07FF |
1da177e4 | 75 | #define RAMDISK_PROMPT_FLAG 0x8000 |
65463b73 | 76 | #define RAMDISK_LOAD_FLAG 0x4000 |
1da177e4 LT |
77 | |
78 | static char command_line[COMMAND_LINE_SIZE] = { 0, }; | |
79 | ||
2c7834a6 PM |
80 | static struct resource code_resource = { .name = "Kernel code", }; |
81 | static struct resource data_resource = { .name = "Kernel data", }; | |
1da177e4 LT |
82 | |
83 | unsigned long memory_start, memory_end; | |
84 | ||
85 | static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE], | |
86 | struct sh_machine_vector** mvp, | |
b641fe01 | 87 | unsigned long *mv_io_base) |
1da177e4 LT |
88 | { |
89 | char c = ' ', *to = command_line, *from = COMMAND_LINE; | |
90 | int len = 0; | |
91 | ||
92 | /* Save unparsed command line copy for /proc/cmdline */ | |
93 | memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); | |
94 | saved_command_line[COMMAND_LINE_SIZE-1] = '\0'; | |
95 | ||
96 | memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; | |
97 | memory_end = memory_start + __MEMORY_SIZE; | |
98 | ||
99 | for (;;) { | |
100 | /* | |
101 | * "mem=XXX[kKmM]" defines a size of memory. | |
102 | */ | |
103 | if (c == ' ' && !memcmp(from, "mem=", 4)) { | |
104 | if (to != command_line) | |
105 | to--; | |
106 | { | |
107 | unsigned long mem_size; | |
108 | ||
109 | mem_size = memparse(from+4, &from); | |
110 | memory_end = memory_start + mem_size; | |
111 | } | |
112 | } | |
a80fd21e | 113 | |
1da177e4 LT |
114 | if (c == ' ' && !memcmp(from, "sh_mv=", 6)) { |
115 | char* mv_end; | |
116 | char* mv_comma; | |
117 | int mv_len; | |
118 | if (to != command_line) | |
119 | to--; | |
120 | from += 6; | |
121 | mv_end = strchr(from, ' '); | |
122 | if (mv_end == NULL) | |
123 | mv_end = from + strlen(from); | |
124 | ||
125 | mv_comma = strchr(from, ','); | |
126 | if ((mv_comma != NULL) && (mv_comma < mv_end)) { | |
127 | int ints[3]; | |
128 | get_options(mv_comma+1, ARRAY_SIZE(ints), ints); | |
129 | *mv_io_base = ints[1]; | |
1da177e4 LT |
130 | mv_len = mv_comma - from; |
131 | } else { | |
132 | mv_len = mv_end - from; | |
133 | } | |
134 | if (mv_len > (MV_NAME_SIZE-1)) | |
135 | mv_len = MV_NAME_SIZE-1; | |
136 | memcpy(mv_name, from, mv_len); | |
137 | mv_name[mv_len] = '\0'; | |
138 | from = mv_end; | |
139 | ||
140 | *mvp = get_mv_byname(mv_name); | |
141 | } | |
b641fe01 | 142 | |
1da177e4 LT |
143 | c = *(from++); |
144 | if (!c) | |
145 | break; | |
146 | if (COMMAND_LINE_SIZE <= ++len) | |
147 | break; | |
148 | *(to++) = c; | |
149 | } | |
150 | *to = '\0'; | |
151 | *cmdline_p = command_line; | |
152 | } | |
153 | ||
154 | static int __init sh_mv_setup(char **cmdline_p) | |
155 | { | |
50373c1b | 156 | #ifdef CONFIG_SH_UNKNOWN |
1da177e4 LT |
157 | extern struct sh_machine_vector mv_unknown; |
158 | #endif | |
159 | struct sh_machine_vector *mv = NULL; | |
160 | char mv_name[MV_NAME_SIZE] = ""; | |
161 | unsigned long mv_io_base = 0; | |
1da177e4 | 162 | |
b641fe01 | 163 | parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base); |
1da177e4 | 164 | |
50373c1b | 165 | #ifdef CONFIG_SH_UNKNOWN |
1da177e4 LT |
166 | if (mv == NULL) { |
167 | mv = &mv_unknown; | |
168 | if (*mv_name != '\0') { | |
169 | printk("Warning: Unsupported machine %s, using unknown\n", | |
170 | mv_name); | |
171 | } | |
172 | } | |
173 | sh_mv = *mv; | |
174 | #endif | |
1da177e4 LT |
175 | |
176 | /* | |
177 | * Manually walk the vec, fill in anything that the board hasn't yet | |
178 | * by hand, wrapping to the generic implementation. | |
179 | */ | |
180 | #define mv_set(elem) do { \ | |
181 | if (!sh_mv.mv_##elem) \ | |
182 | sh_mv.mv_##elem = generic_##elem; \ | |
183 | } while (0) | |
184 | ||
185 | mv_set(inb); mv_set(inw); mv_set(inl); | |
186 | mv_set(outb); mv_set(outw); mv_set(outl); | |
187 | ||
188 | mv_set(inb_p); mv_set(inw_p); mv_set(inl_p); | |
189 | mv_set(outb_p); mv_set(outw_p); mv_set(outl_p); | |
190 | ||
191 | mv_set(insb); mv_set(insw); mv_set(insl); | |
192 | mv_set(outsb); mv_set(outsw); mv_set(outsl); | |
193 | ||
194 | mv_set(readb); mv_set(readw); mv_set(readl); | |
195 | mv_set(writeb); mv_set(writew); mv_set(writel); | |
196 | ||
50373c1b PM |
197 | mv_set(ioport_map); |
198 | mv_set(ioport_unmap); | |
1da177e4 LT |
199 | mv_set(irq_demux); |
200 | ||
201 | #ifdef CONFIG_SH_UNKNOWN | |
202 | __set_io_port_base(mv_io_base); | |
203 | #endif | |
204 | ||
2c7834a6 PM |
205 | if (!sh_mv.mv_nr_irqs) |
206 | sh_mv.mv_nr_irqs = NR_IRQS; | |
207 | ||
1da177e4 LT |
208 | return 0; |
209 | } | |
210 | ||
211 | void __init setup_arch(char **cmdline_p) | |
212 | { | |
213 | unsigned long bootmap_size; | |
214 | unsigned long start_pfn, max_pfn, max_low_pfn; | |
215 | ||
1da177e4 LT |
216 | #ifdef CONFIG_CMDLINE_BOOL |
217 | strcpy(COMMAND_LINE, CONFIG_CMDLINE); | |
218 | #endif | |
219 | ||
220 | ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV); | |
221 | ||
222 | #ifdef CONFIG_BLK_DEV_RAM | |
223 | rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK; | |
224 | rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0); | |
225 | rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0); | |
226 | #endif | |
227 | ||
228 | if (!MOUNT_ROOT_RDONLY) | |
229 | root_mountflags &= ~MS_RDONLY; | |
230 | init_mm.start_code = (unsigned long) _text; | |
231 | init_mm.end_code = (unsigned long) _etext; | |
232 | init_mm.end_data = (unsigned long) _edata; | |
233 | init_mm.brk = (unsigned long) _end; | |
234 | ||
de02797a PM |
235 | code_resource.start = (unsigned long)virt_to_phys(_text); |
236 | code_resource.end = (unsigned long)virt_to_phys(_etext)-1; | |
237 | data_resource.start = (unsigned long)virt_to_phys(_etext); | |
238 | data_resource.end = (unsigned long)virt_to_phys(_edata)-1; | |
1da177e4 LT |
239 | |
240 | sh_mv_setup(cmdline_p); | |
241 | ||
b641fe01 | 242 | |
1da177e4 LT |
243 | /* |
244 | * Find the highest page frame number we have available | |
245 | */ | |
246 | max_pfn = PFN_DOWN(__pa(memory_end)); | |
247 | ||
248 | /* | |
249 | * Determine low and high memory ranges: | |
250 | */ | |
251 | max_low_pfn = max_pfn; | |
252 | ||
65463b73 | 253 | /* |
1da177e4 LT |
254 | * Partially used pages are not usable - thus |
255 | * we are rounding upwards: | |
65463b73 | 256 | */ |
1da177e4 LT |
257 | start_pfn = PFN_UP(__pa(_end)); |
258 | ||
259 | /* | |
260 | * Find a proper area for the bootmem bitmap. After this | |
261 | * bootstrap step all allocations (until the page allocator | |
262 | * is intact) must be done via bootmem_alloc(). | |
263 | */ | |
264 | bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, | |
265 | __MEMORY_START>>PAGE_SHIFT, | |
266 | max_low_pfn); | |
267 | /* | |
268 | * Register fully available low RAM pages with the bootmem allocator. | |
269 | */ | |
270 | { | |
271 | unsigned long curr_pfn, last_pfn, pages; | |
272 | ||
273 | /* | |
274 | * We are rounding up the start address of usable memory: | |
275 | */ | |
276 | curr_pfn = PFN_UP(__MEMORY_START); | |
277 | /* | |
278 | * ... and at the end of the usable range downwards: | |
279 | */ | |
280 | last_pfn = PFN_DOWN(__pa(memory_end)); | |
281 | ||
282 | if (last_pfn > max_low_pfn) | |
283 | last_pfn = max_low_pfn; | |
284 | ||
285 | pages = last_pfn - curr_pfn; | |
286 | free_bootmem_node(NODE_DATA(0), PFN_PHYS(curr_pfn), | |
287 | PFN_PHYS(pages)); | |
288 | } | |
289 | ||
b641fe01 | 290 | |
1da177e4 LT |
291 | /* |
292 | * Reserve the kernel text and | |
293 | * Reserve the bootmem bitmap. We do this in two steps (first step | |
294 | * was init_bootmem()), because this catches the (definitely buggy) | |
295 | * case of us accidentally initializing the bootmem allocator with | |
296 | * an invalid RAM area. | |
297 | */ | |
298 | reserve_bootmem_node(NODE_DATA(0), __MEMORY_START+PAGE_SIZE, | |
299 | (PFN_PHYS(start_pfn)+bootmap_size+PAGE_SIZE-1)-__MEMORY_START); | |
300 | ||
301 | /* | |
302 | * reserve physical page 0 - it's a special BIOS page on many boxes, | |
303 | * enabling clean reboots, SMP operation, laptop functions. | |
304 | */ | |
305 | reserve_bootmem_node(NODE_DATA(0), __MEMORY_START, PAGE_SIZE); | |
306 | ||
307 | #ifdef CONFIG_BLK_DEV_INITRD | |
65463b73 PM |
308 | ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); |
309 | if (&__rd_start != &__rd_end) { | |
1da177e4 | 310 | LOADER_TYPE = 1; |
41504c39 PM |
311 | INITRD_START = PHYSADDR((unsigned long)&__rd_start) - |
312 | __MEMORY_START; | |
313 | INITRD_SIZE = (unsigned long)&__rd_end - | |
314 | (unsigned long)&__rd_start; | |
65463b73 | 315 | } |
1da177e4 LT |
316 | |
317 | if (LOADER_TYPE && INITRD_START) { | |
318 | if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { | |
41504c39 PM |
319 | reserve_bootmem_node(NODE_DATA(0), INITRD_START + |
320 | __MEMORY_START, INITRD_SIZE); | |
321 | initrd_start = INITRD_START + PAGE_OFFSET + | |
322 | __MEMORY_START; | |
1da177e4 LT |
323 | initrd_end = initrd_start + INITRD_SIZE; |
324 | } else { | |
325 | printk("initrd extends beyond end of memory " | |
326 | "(0x%08lx > 0x%08lx)\ndisabling initrd\n", | |
327 | INITRD_START + INITRD_SIZE, | |
328 | max_low_pfn << PAGE_SHIFT); | |
329 | initrd_start = 0; | |
330 | } | |
331 | } | |
332 | #endif | |
333 | ||
334 | #ifdef CONFIG_DUMMY_CONSOLE | |
335 | conswitchp = &dummy_con; | |
336 | #endif | |
337 | ||
338 | /* Perform the machine specific initialisation */ | |
2c7834a6 PM |
339 | if (likely(sh_mv.mv_setup)) |
340 | sh_mv.mv_setup(cmdline_p); | |
1da177e4 LT |
341 | |
342 | paging_init(); | |
343 | } | |
344 | ||
345 | struct sh_machine_vector* __init get_mv_byname(const char* name) | |
346 | { | |
1da177e4 LT |
347 | extern long __machvec_start, __machvec_end; |
348 | struct sh_machine_vector *all_vecs = | |
349 | (struct sh_machine_vector *)&__machvec_start; | |
350 | ||
351 | int i, n = ((unsigned long)&__machvec_end | |
352 | - (unsigned long)&__machvec_start)/ | |
353 | sizeof(struct sh_machine_vector); | |
354 | ||
355 | for (i = 0; i < n; ++i) { | |
356 | struct sh_machine_vector *mv = &all_vecs[i]; | |
357 | if (mv == NULL) | |
358 | continue; | |
359 | if (strcasecmp(name, get_system_type()) == 0) { | |
360 | return mv; | |
361 | } | |
362 | } | |
363 | return NULL; | |
364 | } | |
365 | ||
366 | static struct cpu cpu[NR_CPUS]; | |
367 | ||
368 | static int __init topology_init(void) | |
369 | { | |
370 | int cpu_id; | |
371 | ||
bc83db4f | 372 | for_each_possible_cpu(cpu_id) |
76b67ed9 | 373 | register_cpu(&cpu[cpu_id], cpu_id); |
1da177e4 LT |
374 | |
375 | return 0; | |
376 | } | |
377 | ||
378 | subsys_initcall(topology_init); | |
379 | ||
380 | static const char *cpu_name[] = { | |
b552c7e8 | 381 | [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619", |
e5723e0e PM |
382 | [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300", |
383 | [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706", | |
384 | [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708", | |
385 | [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710", | |
386 | [CPU_SH7729] = "SH7729", [CPU_SH7750] = "SH7750", | |
387 | [CPU_SH7750S] = "SH7750S", [CPU_SH7750R] = "SH7750R", | |
388 | [CPU_SH7751] = "SH7751", [CPU_SH7751R] = "SH7751R", | |
389 | [CPU_SH7760] = "SH7760", [CPU_SH73180] = "SH73180", | |
390 | [CPU_ST40RA] = "ST40RA", [CPU_ST40GX1] = "ST40GX1", | |
391 | [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501", | |
392 | [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780", | |
393 | [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343", | |
41504c39 | 394 | [CPU_SH7785] = "SH7785", [CPU_SH7722] = "SH7722", |
1da177e4 LT |
395 | [CPU_SH_NONE] = "Unknown" |
396 | }; | |
397 | ||
398 | const char *get_cpu_subtype(void) | |
399 | { | |
400 | return cpu_name[boot_cpu_data.type]; | |
401 | } | |
402 | ||
403 | #ifdef CONFIG_PROC_FS | |
2220d164 | 404 | /* Symbolic CPU flags, keep in sync with asm/cpu-features.h */ |
1da177e4 | 405 | static const char *cpu_flags[] = { |
2220d164 | 406 | "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr", |
72c35543 | 407 | "ptea", "llsc", "l2", NULL |
1da177e4 LT |
408 | }; |
409 | ||
410 | static void show_cpuflags(struct seq_file *m) | |
411 | { | |
412 | unsigned long i; | |
413 | ||
414 | seq_printf(m, "cpu flags\t:"); | |
415 | ||
416 | if (!cpu_data->flags) { | |
417 | seq_printf(m, " %s\n", cpu_flags[0]); | |
418 | return; | |
419 | } | |
420 | ||
de02797a | 421 | for (i = 0; cpu_flags[i]; i++) |
1da177e4 LT |
422 | if ((cpu_data->flags & (1 << i))) |
423 | seq_printf(m, " %s", cpu_flags[i+1]); | |
424 | ||
425 | seq_printf(m, "\n"); | |
426 | } | |
427 | ||
2c7834a6 PM |
428 | static void show_cacheinfo(struct seq_file *m, const char *type, |
429 | struct cache_info info) | |
1da177e4 LT |
430 | { |
431 | unsigned int cache_size; | |
432 | ||
433 | cache_size = info.ways * info.sets * info.linesz; | |
434 | ||
de02797a PM |
435 | seq_printf(m, "%s size\t: %2dKiB (%d-way)\n", |
436 | type, cache_size >> 10, info.ways); | |
1da177e4 LT |
437 | } |
438 | ||
439 | /* | |
440 | * Get CPU information for use by the procfs. | |
441 | */ | |
442 | static int show_cpuinfo(struct seq_file *m, void *v) | |
443 | { | |
444 | unsigned int cpu = smp_processor_id(); | |
445 | ||
446 | if (!cpu && cpu_online(cpu)) | |
447 | seq_printf(m, "machine\t\t: %s\n", get_system_type()); | |
448 | ||
449 | seq_printf(m, "processor\t: %d\n", cpu); | |
96b644bd | 450 | seq_printf(m, "cpu family\t: %s\n", init_utsname()->machine); |
1da177e4 LT |
451 | seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype()); |
452 | ||
453 | show_cpuflags(m); | |
454 | ||
455 | seq_printf(m, "cache type\t: "); | |
456 | ||
457 | /* | |
458 | * Check for what type of cache we have, we support both the | |
459 | * unified cache on the SH-2 and SH-3, as well as the harvard | |
460 | * style cache on the SH-4. | |
461 | */ | |
0f08f338 | 462 | if (boot_cpu_data.icache.flags & SH_CACHE_COMBINED) { |
1da177e4 LT |
463 | seq_printf(m, "unified\n"); |
464 | show_cacheinfo(m, "cache", boot_cpu_data.icache); | |
465 | } else { | |
466 | seq_printf(m, "split (harvard)\n"); | |
467 | show_cacheinfo(m, "icache", boot_cpu_data.icache); | |
468 | show_cacheinfo(m, "dcache", boot_cpu_data.dcache); | |
469 | } | |
470 | ||
72c35543 PM |
471 | /* Optional secondary cache */ |
472 | if (boot_cpu_data.flags & CPU_HAS_L2_CACHE) | |
473 | show_cacheinfo(m, "scache", boot_cpu_data.scache); | |
474 | ||
1da177e4 LT |
475 | seq_printf(m, "bogomips\t: %lu.%02lu\n", |
476 | boot_cpu_data.loops_per_jiffy/(500000/HZ), | |
477 | (boot_cpu_data.loops_per_jiffy/(5000/HZ)) % 100); | |
478 | ||
de02797a | 479 | return show_clocks(m); |
1da177e4 LT |
480 | } |
481 | ||
1da177e4 LT |
482 | static void *c_start(struct seq_file *m, loff_t *pos) |
483 | { | |
484 | return *pos < NR_CPUS ? cpu_data + *pos : NULL; | |
485 | } | |
486 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | |
487 | { | |
488 | ++*pos; | |
489 | return c_start(m, pos); | |
490 | } | |
491 | static void c_stop(struct seq_file *m, void *v) | |
492 | { | |
493 | } | |
494 | struct seq_operations cpuinfo_op = { | |
495 | .start = c_start, | |
496 | .next = c_next, | |
497 | .stop = c_stop, | |
498 | .show = show_cpuinfo, | |
499 | }; | |
500 | #endif /* CONFIG_PROC_FS */ | |
501 | ||
502 | #ifdef CONFIG_SH_KGDB | |
503 | /* | |
504 | * Parse command-line kgdb options. By default KGDB is enabled, | |
505 | * entered on error (or other action) using default serial info. | |
506 | * The command-line option can include a serial port specification | |
507 | * and an action to override default or configured behavior. | |
508 | */ | |
509 | struct kgdb_sermap kgdb_sci_sermap = | |
510 | { "ttySC", 5, kgdb_sci_setup, NULL }; | |
511 | ||
512 | struct kgdb_sermap *kgdb_serlist = &kgdb_sci_sermap; | |
513 | struct kgdb_sermap *kgdb_porttype = &kgdb_sci_sermap; | |
514 | ||
515 | void kgdb_register_sermap(struct kgdb_sermap *map) | |
516 | { | |
517 | struct kgdb_sermap *last; | |
518 | ||
519 | for (last = kgdb_serlist; last->next; last = last->next) | |
520 | ; | |
521 | last->next = map; | |
522 | if (!map->namelen) { | |
523 | map->namelen = strlen(map->name); | |
524 | } | |
525 | } | |
526 | ||
527 | static int __init kgdb_parse_options(char *options) | |
528 | { | |
529 | char c; | |
530 | int baud; | |
531 | ||
532 | /* Check for port spec (or use default) */ | |
533 | ||
534 | /* Determine port type and instance */ | |
535 | if (!memcmp(options, "tty", 3)) { | |
536 | struct kgdb_sermap *map = kgdb_serlist; | |
537 | ||
538 | while (map && memcmp(options, map->name, map->namelen)) | |
539 | map = map->next; | |
540 | ||
541 | if (!map) { | |
542 | KGDB_PRINTK("unknown port spec in %s\n", options); | |
543 | return -1; | |
544 | } | |
545 | ||
546 | kgdb_porttype = map; | |
547 | kgdb_serial_setup = map->setup_fn; | |
548 | kgdb_portnum = options[map->namelen] - '0'; | |
549 | options += map->namelen + 1; | |
550 | ||
551 | options = (*options == ',') ? options+1 : options; | |
de02797a | 552 | |
1da177e4 LT |
553 | /* Read optional parameters (baud/parity/bits) */ |
554 | baud = simple_strtoul(options, &options, 10); | |
555 | if (baud != 0) { | |
556 | kgdb_baud = baud; | |
557 | ||
558 | c = toupper(*options); | |
559 | if (c == 'E' || c == 'O' || c == 'N') { | |
560 | kgdb_parity = c; | |
561 | options++; | |
562 | } | |
563 | ||
564 | c = *options; | |
565 | if (c == '7' || c == '8') { | |
566 | kgdb_bits = c; | |
567 | options++; | |
568 | } | |
569 | options = (*options == ',') ? options+1 : options; | |
570 | } | |
571 | } | |
572 | ||
573 | /* Check for action specification */ | |
574 | if (!memcmp(options, "halt", 4)) { | |
575 | kgdb_halt = 1; | |
576 | options += 4; | |
577 | } else if (!memcmp(options, "disabled", 8)) { | |
578 | kgdb_enabled = 0; | |
579 | options += 8; | |
580 | } | |
581 | ||
582 | if (*options) { | |
583 | KGDB_PRINTK("ignored unknown options: %s\n", options); | |
584 | return 0; | |
585 | } | |
586 | return 1; | |
587 | } | |
588 | __setup("kgdb=", kgdb_parse_options); | |
589 | #endif /* CONFIG_SH_KGDB */ |