prom.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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/mm.h>
  19. #include <linux/sched.h>
  20. #include <linux/bootmem.h>
  21. #include <asm/addrspace.h>
  22. #include <asm/bootinfo.h>
  23. extern unsigned long bus_clock;
  24. extern unsigned long cpu_clock;
  25. extern unsigned int memsize, highmemsize;
  26. extern int putDebugChar(unsigned char byte);
  27. static int argc;
  28. /* pmon passes arguments in 32bit pointers */
  29. static int *arg;
  30. static int *env;
  31. const char *get_system_type(void)
  32. {
  33. return "lemote-fulong";
  34. }
  35. void __init prom_init_cmdline(void)
  36. {
  37. int i;
  38. long l;
  39. /* arg[0] is "g", the rest is boot parameters */
  40. arcs_cmdline[0] = '\0';
  41. for (i = 1; i < argc; i++) {
  42. l = (long)arg[i];
  43. if (strlen(arcs_cmdline) + strlen(((char *)l) + 1)
  44. >= sizeof(arcs_cmdline))
  45. break;
  46. strcat(arcs_cmdline, ((char *)l));
  47. strcat(arcs_cmdline, " ");
  48. }
  49. }
  50. void __init prom_init(void)
  51. {
  52. long l;
  53. argc = fw_arg0;
  54. arg = (int *)fw_arg1;
  55. env = (int *)fw_arg2;
  56. mips_machgroup = MACH_GROUP_LEMOTE;
  57. mips_machtype = MACH_LEMOTE_FULONG;
  58. prom_init_cmdline();
  59. if ((strstr(arcs_cmdline, "console=")) == NULL)
  60. strcat(arcs_cmdline, " console=ttyS0,115200");
  61. if ((strstr(arcs_cmdline, "root=")) == NULL)
  62. strcat(arcs_cmdline, " root=/dev/hda1");
  63. #define parse_even_earlier(res, option, p) \
  64. do { \
  65. if (strncmp(option, (char *)p, strlen(option)) == 0) \
  66. res = simple_strtol((char *)p + strlen(option"="), \
  67. NULL, 10); \
  68. } while (0)
  69. l = (long)*env;
  70. while (l != 0) {
  71. parse_even_earlier(bus_clock, "busclock", l);
  72. parse_even_earlier(cpu_clock, "cpuclock", l);
  73. parse_even_earlier(memsize, "memsize", l);
  74. parse_even_earlier(highmemsize, "highmemsize", l);
  75. env++;
  76. l = (long)*env;
  77. }
  78. if (memsize == 0)
  79. memsize = 256;
  80. pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n",
  81. bus_clock, cpu_clock, memsize, highmemsize);
  82. }
  83. void __init prom_free_prom_memory(void)
  84. {
  85. }
  86. void prom_putchar(char c)
  87. {
  88. putDebugChar(c);
  89. }