3b5c3bdc091e7577fb49d5f9799205f6bd3c70e6
[openwrt.git] / target / linux / adm5120 / files / arch / mips / adm5120 / prom / generic.c
1 /*
2  *  $Id$
3  *
4  *  Generic PROM routines
5  *
6  *  Copyright (C) 2007 OpenWrt.org
7  *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
8  *
9  *  This program is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU General Public License
11  *  as published by the Free Software Foundation; either version 2
12  *  of the License, or (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the
21  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA  02110-1301, USA.
23  */
24
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/string.h>
28
29 #include <asm/bootinfo.h>
30
31 #include <prom/generic.h>
32
33 static int *_prom_argc;
34 static char **_prom_argv;
35 static char **_prom_envp;
36
37 char *generic_prom_getenv(char *envname)
38 {
39         char **env;
40         char *ret;
41
42         ret = NULL;
43         for (env = _prom_envp; *env != NULL; env++) {
44                 if (strcmp(envname, *env++) == 0) {
45                         ret = *env;
46                         break;
47                 }
48         }
49
50         return ret;
51 }
52
53 int generic_prom_present(void)
54 {
55         _prom_argc = (int *)fw_arg0;
56         _prom_argv = (char **)fw_arg1;
57         _prom_envp = (char **)fw_arg2;
58
59         return 1;
60 }