cmdline.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * cmdline.c: Kernel command line creation using ARCS argc/argv.
  7. *
  8. * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  9. */
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/string.h>
  13. #include <asm/sgialib.h>
  14. #include <asm/bootinfo.h>
  15. #undef DEBUG_CMDLINE
  16. static char *ignored[] = {
  17. "ConsoleIn=",
  18. "ConsoleOut=",
  19. "SystemPartition=",
  20. "OSLoader=",
  21. "OSLoadPartition=",
  22. "OSLoadFilename=",
  23. "OSLoadOptions="
  24. };
  25. static char *used_arc[][2] = {
  26. { "OSLoadPartition=", "root=" },
  27. { "OSLoadOptions=", "" }
  28. };
  29. static char * __init move_firmware_args(char* cp)
  30. {
  31. char *s;
  32. int actr, i;
  33. actr = 1; /* Always ignore argv[0] */
  34. while (actr < prom_argc) {
  35. for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
  36. int len = strlen(used_arc[i][0]);
  37. if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
  38. /* Ok, we want it. First append the replacement... */
  39. strcat(cp, used_arc[i][1]);
  40. cp += strlen(used_arc[i][1]);
  41. /* ... and now the argument */
  42. s = strchr(prom_argv(actr), '=');
  43. if (s) {
  44. s++;
  45. strcpy(cp, s);
  46. cp += strlen(s);
  47. }
  48. *cp++ = ' ';
  49. break;
  50. }
  51. }
  52. actr++;
  53. }
  54. return cp;
  55. }
  56. void __init prom_init_cmdline(void)
  57. {
  58. char *cp;
  59. int actr, i;
  60. actr = 1; /* Always ignore argv[0] */
  61. cp = arcs_cmdline;
  62. /*
  63. * Move ARC variables to the beginning to make sure they can be
  64. * overridden by later arguments.
  65. */
  66. cp = move_firmware_args(cp);
  67. while (actr < prom_argc) {
  68. for (i = 0; i < ARRAY_SIZE(ignored); i++) {
  69. int len = strlen(ignored[i]);
  70. if (!strncmp(prom_argv(actr), ignored[i], len))
  71. goto pic_cont;
  72. }
  73. /* Ok, we want it. */
  74. strcpy(cp, prom_argv(actr));
  75. cp += strlen(prom_argv(actr));
  76. *cp++ = ' ';
  77. pic_cont:
  78. actr++;
  79. }
  80. if (cp != arcs_cmdline) /* get rid of trailing space */
  81. --cp;
  82. *cp = '\0';
  83. #ifdef DEBUG_CMDLINE
  84. printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
  85. #endif
  86. }