--- zzzz-none-000/linux-2.4.17/arch/mips/mips-boards/generic/init.c 2001-04-14 03:26:07.000000000 +0000 +++ sangam-fb-322/linux-2.4.17/arch/mips/mips-boards/generic/init.c 2004-11-24 13:22:35.000000000 +0000 @@ -28,38 +28,51 @@ #include #include -/* Environment variable */ -typedef struct -{ - char *name; - char *val; -} t_env_var; +#ifdef CONFIG_MIPS_AVALANCHE_PSPBOOT +#include +#endif + int prom_argc; char **prom_argv, **prom_envp; int init_debug = 0; -char *prom_getenv(char *envname) -{ - /* - * Return a pointer to the given environment variable. - */ - - t_env_var *env = (t_env_var *)prom_envp; +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +#include + +typedef struct _avm_urlader_env { + char *Name; + char *Value; +} t_avm_urlader_env; + +static t_avm_urlader_env local_envp[MAX_ENV_ENTRY]; + +/* */ +extern int avalanche_mtd_ready; + +/*------------------------------------------------------------------------------------------*\ + get an environment variable from the flash region +\*------------------------------------------------------------------------------------------*/ +char *prom_getenv(char *search_name) { + unsigned int count = 0; + t_avm_urlader_env *E = (t_avm_urlader_env *)local_envp; int i; - i = strlen(envname); + i = strlen(search_name); - while(env->name) { - if(strncmp(envname, env->name, i) == 0) { - return(env->val); + while(E->Name) { + if(strncmp(search_name, E->Name, i) == 0) { + return(E->Value); } - env++; + E++, count++; } return(NULL); } +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ static inline unsigned char str2hexnum(unsigned char c) { if(c >= '0' && c <= '9') @@ -83,7 +96,7 @@ ea[i] = num; } } - + int get_ethernet_addr(char *ethernet_addr) { char *ethaddr_str; @@ -106,30 +119,84 @@ return 0; } -int __init prom_init(int argc, char **argv, char **envp) -{ +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +int __init prom_init(int argc, char **argv, char **envp) { + int i; + t_avm_urlader_env *E = (t_avm_urlader_env *)envp; + static char local_env_buffer[2 * 1024]; + char *p; + + /* TODO: Do we need to save the args locally also? */ prom_argc = argc; prom_argv = argv; - prom_envp = envp; + + /* Copy what we need locally so we are not dependent on + * bootloader RAM. In Adam2, the environment paramters + * are in flash but the table that references them is in + * RAM. */ + /*--- printk("prom_init: max %u entries\n", MAX_ENV_ENTRY); ---*/ + for(i = 0, p = local_env_buffer ; i < MAX_ENV_ENTRY ; i++, E++) { + if( E->Name ) { + int name_len; + int val_len; + name_len = strlen(E->Name) + 1; + val_len = strlen(E->Value) + 1; + if(p + name_len + val_len > local_env_buffer + sizeof(local_env_buffer)) { + printk("prom_init: local_env_buffer too small for (%s = %s)\n", E->Name, E->Value); + local_envp[i].Name = NULL; + local_envp[i].Value = NULL; + continue; + } + + local_envp[i].Name = p; + memcpy(p, E->Name, name_len); + p += name_len; + + local_envp[i].Value = p; + memcpy(p, E->Value, val_len); + p += val_len; + + /*--- local_envp[i].name=E->Name; ---*/ + /*--- local_envp[i].val = E->Value; ---*/ + /*--- printk("prom_init[%u]: %s = %s\n", i, local_envp[i].name, local_envp[i].val); ---*/ + } else { + local_envp[i].Name = NULL; + local_envp[i].Value = NULL; + } + } + /*--- printk("prom_init: done\n"); ---*/ + + printk("prom_init: local_env_buffer %u used (max %u)\n", (unsigned int)p - (unsigned int)local_env_buffer, sizeof(local_env_buffer)); mips_display_message("LINUX"); /* - * Setup the North bridge to do Master byte-lane swapping when + * Setup the North bridge to do Master byte-lane swapping when * running in bigendian. */ +#if defined(CONFIG_MIPS_AVALANCHE_SOC) + /*nothing*/ +#else #if defined(__MIPSEL__) GT_WRITE(GT_PCI0_CMD_OFS, GT_PCI0_CMD_MBYTESWAP_BIT | GT_PCI0_CMD_SBYTESWAP_BIT); #else GT_WRITE(GT_PCI0_CMD_OFS, 0); -#endif +#endif /* __MIPSEL__ */ #if defined(CONFIG_MIPS_MALTA) - mips_io_port_base = MALTA_PORT_BASE; + set_io_port_base(MALTA_PORT_BASE); #else - mips_io_port_base = KSEG1; -#endif + set_io_port_base(KSEG1); +#endif /* CONFIG_MIPS_MALTA */ +#endif /* CONFIG_MIPS_AVALANCHE_SOC */ + +#if defined(CONFIG_MIPS_AVALANCHE_SOC) + set_io_port_base(0); +#endif /* CONFIG_MIPS_AVALANCHE_SOC */ + + setup_prom_printf(0); prom_printf("\nLINUX started...\n"); prom_init_cmdline(); @@ -137,3 +204,7 @@ return 0; } + + + +