prom.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. prom_init_cmdline();
  54. if ((strstr(arcs_cmdline, "console=")) == NULL)
  55. strcat(arcs_cmdline, " console=ttyS0,115200");
  56. if ((strstr(arcs_cmdline, "root=")) == NULL)
  57. strcat(arcs_cmdline, " root=/dev/hda1");
  58. #define parse_even_earlier(res, option, p) \
  59. do { \
  60. if (strncmp(option, (char *)p, strlen(option)) == 0) \
  61. res = simple_strtol((char *)p + strlen(option"="), \
  62. NULL, 10); \
  63. } while (0)
  64. l = (long)*env;
  65. while (l != 0) {
  66. parse_even_earlier(bus_clock, "busclock", l);
  67. parse_even_earlier(cpu_clock_freq, "cpuclock", l);
  68. parse_even_earlier(memsize, "memsize", l);
  69. parse_even_earlier(highmemsize, "highmemsize", l);
  70. env++;
  71. l = (long)*env;
  72. }
  73. if (memsize == 0)
  74. memsize = 256;
  75. pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n",
  76. bus_clock, cpu_clock_freq, memsize, highmemsize);
  77. }
  78. void __init prom_free_prom_memory(void)
  79. {
  80. }
  81. void prom_putchar(char c)
  82. {
  83. putDebugChar(c);
  84. }