cmdline.c 2.3 KB

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