cmdline.c 2.1 KB

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