env.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
  13. * Author: Wu Zhangjin, wuzj@lemote.com
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. */
  20. #include <asm/bootinfo.h>
  21. #include <loongson.h>
  22. unsigned long bus_clock, cpu_clock_freq;
  23. unsigned long memsize, highmemsize;
  24. /* pmon passes arguments in 32bit pointers */
  25. int *_prom_envp;
  26. #define parse_even_earlier(res, option, p) \
  27. do { \
  28. if (strncmp(option, (char *)p, strlen(option)) == 0) \
  29. strict_strtol((char *)p + strlen(option"="), \
  30. 10, &res); \
  31. } while (0)
  32. void __init prom_init_env(void)
  33. {
  34. long l;
  35. /* firmware arguments are initialized in head.S */
  36. _prom_envp = (int *)fw_arg2;
  37. l = (long)*_prom_envp;
  38. while (l != 0) {
  39. parse_even_earlier(bus_clock, "busclock", l);
  40. parse_even_earlier(cpu_clock_freq, "cpuclock", l);
  41. parse_even_earlier(memsize, "memsize", l);
  42. parse_even_earlier(highmemsize, "highmemsize", l);
  43. _prom_envp++;
  44. l = (long)*_prom_envp;
  45. }
  46. if (memsize == 0)
  47. memsize = 256;
  48. pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
  49. bus_clock, cpu_clock_freq, memsize, highmemsize);
  50. }