aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/au1000/common/prom.c
diff options
context:
space:
mode:
authorDomen Puncer <domen.puncer@ultra.si>2006-07-03 02:17:09 -0400
committerRalf Baechle <ralf@linux-mips.org>2006-07-13 16:26:02 -0400
commit6fe725c01c0c547c4287ba3de5ebc8f884178409 (patch)
treef398808f0e9503e341d7e00523065985d78adf38 /arch/mips/au1000/common/prom.c
parentc36cd4bab5084798b401d529129a950f4a48662d (diff)
[MIPS] au1xxx: Support both YAMON and U-Boot
Signed-off-by: Domen Puncer <domen.puncer@ultra.si> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/au1000/common/prom.c')
-rw-r--r--arch/mips/au1000/common/prom.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c
index ae7d8c57bf3f..b4b010a2fe36 100644
--- a/arch/mips/au1000/common/prom.c
+++ b/arch/mips/au1000/common/prom.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * 2 *
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * PROM library initialisation code, assuming YAMON is the boot loader. 4 * PROM library initialisation code, supports YAMON and U-Boot.
5 * 5 *
6 * Copyright 2000, 2001, 2006 MontaVista Software Inc. 6 * Copyright 2000, 2001, 2006 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc.
@@ -46,12 +46,6 @@
46extern int prom_argc; 46extern int prom_argc;
47extern char **prom_argv, **prom_envp; 47extern char **prom_argv, **prom_envp;
48 48
49typedef struct
50{
51 char *name;
52 char *val;
53} t_env_var;
54
55 49
56char * prom_getcmdline(void) 50char * prom_getcmdline(void)
57{ 51{
@@ -84,13 +78,21 @@ char *prom_getenv(char *envname)
84{ 78{
85 /* 79 /*
86 * Return a pointer to the given environment variable. 80 * Return a pointer to the given environment variable.
81 * YAMON uses "name", "value" pairs, while U-Boot uses "name=value".
87 */ 82 */
88 83
89 t_env_var *env = (t_env_var *)prom_envp; 84 char **env = prom_envp;
90 85 int i = strlen(envname);
91 while (env->name) { 86 int yamon = (*env && strchr(*env, '=') == NULL);
92 if (strcmp(envname, env->name) == 0) 87
93 return env->val; 88 while (*env) {
89 if (yamon) {
90 if (strcmp(envname, *env++) == 0)
91 return *env;
92 } else {
93 if (strncmp(envname, *env, i) == 0 && (*env)[i] == '=')
94 return *env + i + 1;
95 }
94 env++; 96 env++;
95 } 97 }
96 return NULL; 98 return NULL;