3 * Per Hallsmark, per.hallsmark@mvista.com
5 * Based on jmr3927/common/prom.c
7 * 2004 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/string.h>
16 #include <linux/serial_ip3106.h>
18 #include <asm/bootinfo.h>
21 /* #define DEBUG_CMDLINE */
24 extern char **prom_argv, **prom_envp;
33 char * prom_getcmdline(void)
35 return &(arcs_cmdline[0]);
38 void prom_init_cmdline(void)
43 actr = 1; /* Always ignore argv[0] */
45 cp = &(arcs_cmdline[0]);
46 while(actr < prom_argc) {
47 strcpy(cp, prom_argv[actr]);
48 cp += strlen(prom_argv[actr]);
52 if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
57 char *prom_getenv(char *envname)
60 * Return a pointer to the given environment variable.
61 * Environment variables are stored in the form of "memsize=64".
64 t_env_var *env = (t_env_var *)prom_envp;
70 if(strncmp(envname, env->name, i) == 0) {
71 return(env->name + strlen(envname) + 1);
78 inline unsigned char str2hexnum(unsigned char c)
80 if(c >= '0' && c <= '9')
82 if(c >= 'a' && c <= 'f')
84 if(c >= 'A' && c <= 'F')
89 inline void str2eaddr(unsigned char *ea, unsigned char *str)
93 for(i = 0; i < 6; i++) {
96 if((*str == '.') || (*str == ':'))
98 num = str2hexnum(*str++) << 4;
99 num |= (str2hexnum(*str++));
104 int get_ethernet_addr(char *ethernet_addr)
108 ethaddr_str = prom_getenv("ethaddr");
110 printk("ethaddr not set in boot prom\n");
113 str2eaddr(ethernet_addr, ethaddr_str);
117 unsigned long __init prom_free_prom_memory(void)
122 extern int pnx8550_console_port;
124 /* used by prom_printf */
125 void prom_putchar(char c)
127 if (pnx8550_console_port != -1) {
128 /* Wait until FIFO not full */
129 while( ((ip3106_fifo(UART_BASE, pnx8550_console_port) & IP3106_UART_FIFO_TXFIFO) >> 16) >= 16)
132 ip3106_fifo(UART_BASE, pnx8550_console_port) = c;
136 EXPORT_SYMBOL(prom_getcmdline);
137 EXPORT_SYMBOL(get_ethernet_addr);
138 EXPORT_SYMBOL(str2eaddr);