Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | /* * Carsten Langgaard, carstenl@mips.com * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. * * ######################################################################## * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * * ######################################################################## * * PROM library initialisation code. */ #include <linux/config.h> #include <linux/init.h> #include <linux/string.h> #include <linux/kernel.h> #include <asm/io.h> #include <asm/mips-boards/prom.h> #include <asm/mips-boards/generic.h> #include <asm/mips-boards/gt64120.h> #include <asm/mips-boards/malta.h> /* Environment variable */ typedef struct { char *name; char *val; }t_env_var; int prom_argc; int *_prom_argv, *_prom_envp; /* * A 32-bit PROM pass arguments and environment as 32-bit pointer. * This macro take care of sign extension. */ #define prom_envp(index) ((char *)(((int *)(int)_prom_envp)[(index)])) int init_debug = 0; char *prom_getenv(char *envname) { /* * Return a pointer to the given environment variable. * We're using 64-bit pointers, but all pointers in the PROM * structures are only 32-bit, so we need some workarounds. */ int i, index=0; i = strlen(envname); while(prom_envp(index)) { if(strncmp(envname, prom_envp(index), i) == 0) { return(prom_envp(index+1)); } index += 2; } return(NULL); } static inline unsigned char str2hexnum(unsigned char c) { if(c >= '0' && c <= '9') return c - '0'; if(c >= 'a' && c <= 'f') return c - 'a' + 10; return 0; /* foo */ } static inline void str2eaddr(unsigned char *ea, unsigned char *str) { int i; for(i = 0; i < 6; i++) { unsigned char num; if((*str == '.') || (*str == ':')) str++; num = str2hexnum(*str++) << 4; num |= (str2hexnum(*str++)); ea[i] = num; } } int get_ethernet_addr(char *ethernet_addr) { char *ethaddr_str; ethaddr_str = prom_getenv("ethaddr"); if (!ethaddr_str) { printk("ethaddr not set in boot prom\n"); return -1; } str2eaddr(ethernet_addr, ethaddr_str); if (init_debug > 1) { int i; printk("get_ethernet_addr: "); for (i=0; i<5; i++) printk("%02x:", (unsigned char)*(ethernet_addr+i)); printk("%02x\n", *(ethernet_addr+i)); } return 0; } int __init prom_init(int argc, char **argv, char **envp) { prom_argc = argc; _prom_argv = (int *)argv; _prom_envp = (int *)envp; mips_display_message("LINUX"); /* * Setup the North bridge to do Master byte-lane swapping when * running in bigendian. */ #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 #if defined(CONFIG_MIPS_MALTA) mips_io_port_base = MALTA_PORT_BASE; #else mips_io_port_base = KSEG1; #endif setup_prom_printf(0); prom_printf("\nLINUX started...\n"); prom_init_cmdline(); prom_meminit(); return 0; } |