setup.c 16 KB

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