// get MAC address from flash and check it
memcpy(buffer, (void *)(CFG_FLASH_BASE + OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6);
- // check LSBit and second LCBit in MSByte of vendor part -> both of them should be 0
+ /*
+ * check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part
+ * both of them should be 0:
+ * I/G bit == 0 -> Individual MAC address (unicast address)
+ * U/L bit == 0 -> Burned-In-Address (BIA) MAC address
+ */
if(CHECK_BIT((buffer[0] & 0xFF), 0) == 0 && CHECK_BIT((buffer[0] & 0xFF), 1) == 0){
mac[0] = (buffer[0] & 0xFF);
mac[1] = (buffer[1] & 0xFF);
mac[3] = 0x09;
mac[4] = 0x0b;
mac[5] = 0xad;
-
- printf("## Error: MAC address stored in flash is invalid!\nUsing fixed address!\n");
}
#else
// 00-03-7F (Atheros Communications, Inc.)
mac[3] = 0x09;
mac[4] = 0x0b;
mac[5] = 0xad;
- printf("## Error: using fixed MAC address!\n");
#endif
}
*/\r
static void ag7240_get_ethaddr(struct eth_device *dev){\r
unsigned char *mac = dev->enetaddr;\r
+#ifdef OFFSET_MAC_ADDRESS\r
unsigned char buffer[6];\r
\r
-#ifdef OFFSET_MAC_ADDRESS\r
// get MAC address from flash and check it\r
memcpy(buffer, (void *)(CFG_FLASH_BASE + OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6);\r
\r
- // check LSBit and second LCBit in MSByte of vendor part -> both of them should be 0\r
+ /*\r
+ * check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part\r
+ * both of them should be 0:\r
+ * I/G bit == 0 -> Individual MAC address (unicast address)\r
+ * U/L bit == 0 -> Burned-In-Address (BIA) MAC address\r
+ */\r
if(CHECK_BIT((buffer[0] & 0xFF), 0) == 0 && CHECK_BIT((buffer[0] & 0xFF), 1) == 0){\r
mac[0] = (buffer[0] & 0xFF);\r
mac[1] = (buffer[1] & 0xFF);\r
mac[3] = 0x09;\r
mac[4] = 0x0b;\r
mac[5] = 0xad;\r
-\r
- printf("## Error: MAC address stored in flash is invalid!\nUsing fixed address!\n");\r
}\r
#else\r
// 00-03-7F (Atheros Communications, Inc.)\r
mac[3] = 0x09;\r
mac[4] = 0x0b;\r
mac[5] = 0xad;\r
- printf("## Error: Using fixed MAC address!\n");\r
#endif\r
}\r
\r
#define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
#endif
+#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
+
extern ulong uboot_end_data;
extern ulong uboot_end;
extern char * env_name_spec;
#endif
bd_t *bd;
- int i;
char *s;
unsigned char buffer[6];
/* board MAC address */
#if defined(OFFSET_MAC_ADDRESS)
memcpy(buffer, (void *)(CFG_FLASH_BASE + OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6);
+
+ /*
+ * check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part
+ * both of them should be 0:
+ * I/G bit == 0 -> Individual MAC address (unicast address)
+ * U/L bit == 0 -> Burned-In-Address (BIA) MAC address
+ */
+ if(CHECK_BIT((buffer[0] & 0xFF), 0) != 0 || CHECK_BIT((buffer[0] & 0xFF), 1) != 0){
+ // 00-03-7F (Atheros Communications, Inc.)
+ bd->bi_enetaddr[0] = 0x00;
+ bd->bi_enetaddr[1] = 0x03;
+ bd->bi_enetaddr[2] = 0x7f;
+ bd->bi_enetaddr[3] = 0x09;
+ bd->bi_enetaddr[4] = 0x0b;
+ bd->bi_enetaddr[5] = 0xad;
+
+ printf("## Error: MAC is invalid, using fixed!\n\n");
+ }
#else
// fake MAC
// 00-03-7F (Atheros Communications, Inc.)
- buffer[0] = 0x00;
- buffer[1] = 0x03;
- buffer[2] = 0x7f;
- buffer[3] = 0x09;
- buffer[4] = 0x0b;
- buffer[5] = 0xad;
+ bd->bi_enetaddr[0] = 0x00;
+ bd->bi_enetaddr[1] = 0x03;
+ bd->bi_enetaddr[2] = 0x7f;
+ bd->bi_enetaddr[3] = 0x09;
+ bd->bi_enetaddr[4] = 0x0b;
+ bd->bi_enetaddr[5] = 0xad;
+
+ printf("** Warning: using fixed MAC address!\n\n");
#endif
- for(i = 0; i < 6; ++i){
- bd->bi_enetaddr[i] = buffer[i];
- }
-
/* IP Address */
bd->bi_ip_addr = getenv_IPaddr("ipaddr");
#ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
unsigned char bi_enetaddr[6];
int reg;
- char *e,*s;
- char tmp[64];
ulong tst1, tst2, sum, m_mask, m_value = 0;
if(BootpTry == 0){
/* get our mac */
- reg = getenv_r("ethaddr", tmp, sizeof(tmp));
- s = (reg > 0) ? tmp : NULL;
-
- for (reg = 0; reg < 6; ++reg) {
- bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
- if(s){
- s = (*e) ? e+1 : e;
- }
- }
+ memcpy(bi_enetaddr, NetOurEther, 6);
#ifdef DEBUG
puts("BootpRequest => Our Mac: ");
#endif /* DEBUG */
/* Mac-Manipulation 2 get seed1 */
- tst1=0;
- tst2=0;
+ tst1 = 0;
+ tst2 = 0;
for(reg = 2; reg < 6; reg++){
tst1 = tst1 << 8;
seed1 = tst1^tst2;
/* Mirror seed1*/
- m_mask=0x1;
+ m_mask = 0x1;
for(reg = 1;reg <= 32; reg++){
m_value |= (m_mask & seed1);