cmdline.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 (davem@davemloft.net)
  9. */
  10. #include <linux/bug.h>
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/string.h>
  14. #include <asm/sgialib.h>
  15. #include <asm/bootinfo.h>
  16. #undef DEBUG_CMDLINE
  17. static char *ignored[] = {
  18. "ConsoleIn=",
  19. "ConsoleOut=",
  20. "SystemPartition=",
  21. "OSLoader=",
  22. "OSLoadPartition=",
  23. "OSLoadFilename=",
  24. "OSLoadOptions="
  25. };
  26. static char *used_arc[][2] = {
  27. { "OSLoadPartition=", "root=" },
  28. { "OSLoadOptions=", "" }
  29. };
  30. static char * __init move_firmware_args(char* cp)
  31. {
  32. char *s;
  33. int actr, i;
  34. actr = 1; /* Always ignore argv[0] */
  35. while (actr < prom_argc) {
  36. for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
  37. int len = strlen(used_arc[i][0]);
  38. if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
  39. /* Ok, we want it. First append the replacement... */
  40. strcat(cp, used_arc[i][1]);
  41. cp += strlen(used_arc[i][1]);
  42. /* ... and now the argument */
  43. s = strchr(prom_argv(actr), '=');
  44. if (s) {
  45. s++;
  46. strcpy(cp, s);
  47. cp += strlen(s);
  48. }
  49. *cp++ = ' ';
  50. break;
  51. }
  52. }
  53. actr++;
  54. }
  55. return cp;
  56. }
  57. void __init prom_init_cmdline(void)
  58. {
  59. char *cp;
  60. int actr, i;
  61. actr = 1; /* Always ignore argv[0] */
  62. cp = arcs_cmdline;
  63. /*
  64. * Move ARC variables to the beginning to make sure they can be
  65. * overridden by later arguments.
  66. */
  67. cp = move_firmware_args(cp);
  68. while (actr < prom_argc) {
  69. for (i = 0; i < ARRAY_SIZE(ignored); i++) {
  70. int len = strlen(ignored[i]);
  71. if (!strncmp(prom_argv(actr), ignored[i], len))
  72. goto pic_cont;
  73. }
  74. /* Ok, we want it. */
  75. strcpy(cp, prom_argv(actr));
  76. cp += strlen(prom_argv(actr));
  77. *cp++ = ' ';
  78. pic_cont:
  79. actr++;
  80. }
  81. if (cp != arcs_cmdline) /* get rid of trailing space */
  82. --cp;
  83. *cp = '\0';
  84. #ifdef DEBUG_CMDLINE
  85. printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
  86. #endif
  87. }