/* * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * * Kernel command line creation using the prom monitor (YAMON) argc/argv. */ #include #include #include #include #include #include /*--- #define prom_printf printk ---*/ extern int prom_argc; extern int *_prom_argv; /* * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer. * This macro take care of sign extension. */ #define prom_argv(index) ((char *)(long)_prom_argv[(index)]) char * prom_getcmdline(void) { return &(arcs_cmdline[0]); } void __init prom_init_cmdline(void) { char *cp; int actr; unsigned int test = 0; #if defined(CONFIG_MIPS_OHIO) || defined(CONFIG_MIPS_AR7) || defined(CONFIG_MIPS_UR8) unsigned int root_found = 0; #endif /*--- #if defined(CONFIG_MIPS_OHIO) || defined(CONFIG_MIPS_AR7) || defined(CONFIG_MIPS_UR8) ---*/ /*--- prom_printf("[prom_init_cmdline] 1\n"); ---*/ actr = 1; /* Always ignore argv[0] */ cp = &(arcs_cmdline[0]); /*--- prom_printf("[prom_init_cmdline] 2 prom_argc=%u\n"); ---*/ while(actr < prom_argc) { if(prom_argv(actr) == NULL) break; #if defined(CONFIG_MIPS_OHIO) || defined(CONFIG_MIPS_AR7) || defined(CONFIG_MIPS_UR8) if(strstr(prom_argv(actr), "root=")) root_found = 1; #endif /*--- #if defined(CONFIG_MIPS_OHIO) || defined(CONFIG_MIPS_AR7) || defined(CONFIG_MIPS_UR8) ---*/ test++; /*--- prom_printf("[prom_init_cmdline] 2.%u next: strcpy(cp=0x%x, prom_argv=0x%x)\n", test, cp, prom_argv(actr)); ---*/ strcpy(cp, prom_argv(actr)); /*--- prom_printf("[prom_init_cmdline] 3.%u\n", test); ---*/ /*--- prom_printf("[prom_init_cmdline] 4.%u cp=%s\n", test, cp); ---*/ cp += strlen(prom_argv(actr)); *cp++ = ' '; actr++; /*--- prom_printf("[prom_init_cmdline] 5.%u\n", test); ---*/ } #if defined(CONFIG_MIPS_OHIO) || defined(CONFIG_MIPS_AR7) || defined(CONFIG_MIPS_UR8) if(root_found == 0) { strcpy(cp, "root=/dev/mtdblock3"); *cp++ = ' '; actr++; /*--- prom_printf("[prom_init_cmdline] root added\n"); ---*/ } #endif /*--- #if defined(CONFIG_MIPS_OHIO) || defined(CONFIG_MIPS_AR7) || defined(CONFIG_MIPS_UR8) ---*/ /*--- prom_printf("[prom_init_cmdline] 4\n"); ---*/ if (cp != &(arcs_cmdline[0])) { /* get rid of trailing space */ --cp; *cp = '\0'; } /*--- prom_printf("[prom_init_cmdline] 5\n"); ---*/ } EXPORT_SYMBOL(prom_getcmdline);