prom.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Based on Ocelot Linux port, which is
  3. * Copyright 2001 MontaVista Software Inc.
  4. * Author: jsun@mvista.com or jsun@junsun.net
  5. *
  6. * Copyright 2003 ICT CAS
  7. * Author: Michael Guo <guoyi@ict.ac.cn>
  8. *
  9. * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
  10. * Author: Fuxin Zhang, zhangfx@lemote.com
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #include <linux/init.h>
  18. #include <linux/bootmem.h>
  19. #include <asm/bootinfo.h>
  20. extern unsigned long bus_clock;
  21. extern unsigned long cpu_clock_freq;
  22. extern unsigned int memsize, highmemsize;
  23. extern int putDebugChar(unsigned char byte);
  24. static int argc;
  25. /* pmon passes arguments in 32bit pointers */
  26. static int *arg;
  27. static int *env;
  28. const char *get_system_type(void)
  29. {
  30. return "lemote-fulong";
  31. }
  32. void __init prom_init_cmdline(void)
  33. {
  34. int i;
  35. long l;
  36. /* arg[0] is "g", the rest is boot parameters */
  37. arcs_cmdline[0] = '\0';
  38. for (i = 1; i < argc; i++) {
  39. l = (long)arg[i];
  40. if (strlen(arcs_cmdline) + strlen(((char *)l) + 1)
  41. >= sizeof(arcs_cmdline))
  42. break;
  43. strcat(arcs_cmdline, ((char *)l));
  44. strcat(arcs_cmdline, " ");
  45. }
  46. }
  47. void __init prom_init(void)
  48. {
  49. long l;
  50. argc = fw_arg0;
  51. arg = (int *)fw_arg1;
  52. env = (int *)fw_arg2;
  53. mips_machtype = MACH_LEMOTE_FULONG;
  54. prom_init_cmdline();
  55. if ((strstr(arcs_cmdline, "console=")) == NULL)
  56. strcat(arcs_cmdline, " console=ttyS0,115200");
  57. if ((strstr(arcs_cmdline, "root=")) == NULL)
  58. strcat(arcs_cmdline, " root=/dev/hda1");
  59. #define parse_even_earlier(res, option, p) \
  60. do { \
  61. if (strncmp(option, (char *)p, strlen(option)) == 0) \
  62. res = simple_strtol((char *)p + strlen(option"="), \
  63. NULL, 10); \
  64. } while (0)
  65. l = (long)*env;
  66. while (l != 0) {
  67. parse_even_earlier(bus_clock, "busclock", l);
  68. parse_even_earlier(cpu_clock_freq, "cpuclock", l);
  69. parse_even_earlier(memsize, "memsize", l);
  70. parse_even_earlier(highmemsize, "highmemsize", l);
  71. env++;
  72. l = (long)*env;
  73. }
  74. if (memsize == 0)
  75. memsize = 256;
  76. pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n",
  77. bus_clock, cpu_clock_freq, memsize, highmemsize);
  78. }
  79. void __init prom_free_prom_memory(void)
  80. {
  81. }
  82. void prom_putchar(char c)
  83. {
  84. putDebugChar(c);
  85. }