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_pnx8xxx.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 __init prom_init_cmdline(void)
42 arcs_cmdline[0] = '\0';
43 for (i = 0; i < prom_argc; i++) {
44 strcat(arcs_cmdline, prom_argv[i]);
45 strcat(arcs_cmdline, " ");
49 char *prom_getenv(char *envname)
52 * Return a pointer to the given environment variable.
53 * Environment variables are stored in the form of "memsize=64".
56 t_env_var *env = (t_env_var *)prom_envp;
62 if(strncmp(envname, env->name, i) == 0) {
63 return(env->name + strlen(envname) + 1);
70 inline unsigned char str2hexnum(unsigned char c)
72 if(c >= '0' && c <= '9')
74 if(c >= 'a' && c <= 'f')
76 if(c >= 'A' && c <= 'F')
81 inline void str2eaddr(unsigned char *ea, unsigned char *str)
85 for(i = 0; i < 6; i++) {
88 if((*str == '.') || (*str == ':'))
90 num = str2hexnum(*str++) << 4;
91 num |= (str2hexnum(*str++));
96 int get_ethernet_addr(char *ethernet_addr)
100 ethaddr_str = prom_getenv("ethaddr");
102 printk("ethaddr not set in boot prom\n");
105 str2eaddr(ethernet_addr, ethaddr_str);
109 void __init prom_free_prom_memory(void)
113 extern int pnx8550_console_port;
115 /* used by early printk */
116 void prom_putchar(char c)
118 if (pnx8550_console_port != -1) {
119 /* Wait until FIFO not full */
120 while( ((ip3106_fifo(UART_BASE, pnx8550_console_port) & PNX8XXX_UART_FIFO_TXFIFO) >> 16) >= 16)
123 ip3106_fifo(UART_BASE, pnx8550_console_port) = c;
127 EXPORT_SYMBOL(prom_getcmdline);
128 EXPORT_SYMBOL(get_ethernet_addr);
129 EXPORT_SYMBOL(str2eaddr);