예제 #1
0
/*
 * get_board_mac_addr
 *
 * Read the MAC address in a board specific way
 *
 */
error_t get_board_mac_addr(unsigned char mac_addr[6])
{
  error_t error = 0;
  alt_u32 signature;

  /* Get the flash sector with the MAC address. */
  error = FindLastFlashSectorOffset(&last_flash_sector_offset);
  if (!error)
    last_flash_sector = CFI_FLASH_BASE + last_flash_sector_offset;
  else
    printf ("Could not locate flash sector with MAC address.\n");

/* This last_flash_sector region of flash is examined to see if 
 * valid network settings are present, indicated by a signature of 0x00005afe at 
 * the first address of the last flash sector.  This hex value is chosen as the 
 * signature since it looks like the english word "SAFE", meaning that it is 
 * safe to use these network address values.  
*/
  ///*
  if (!error)
  {
    signature = IORD_32DIRECT(last_flash_sector, 0);
    if (signature != 0x00005afe)
    {
      error = generate_and_store_mac_addr();
    }
  }
  //*/
//    mac_addr[0] = 0x00;
//    mac_addr[1] = 0x07;
//    mac_addr[2] = 0xed;
//    mac_addr[3] = 0x12;
//    mac_addr[4] = 0x8f;
//    mac_addr[5] = 0xff;
  if (!error)
  {
    mac_addr[0] = IORD_8DIRECT(last_flash_sector, 4);
    mac_addr[1] = IORD_8DIRECT(last_flash_sector, 5);
    mac_addr[2] = IORD_8DIRECT(last_flash_sector, 6);
    mac_addr[3] = IORD_8DIRECT(last_flash_sector, 7);
    mac_addr[4] = IORD_8DIRECT(last_flash_sector, 8);
    mac_addr[5] = IORD_8DIRECT(last_flash_sector, 9);
    
    printf("Your Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n", 
            mac_addr[0],
            mac_addr[1],
            mac_addr[2],
            mac_addr[3],
            mac_addr[4],
            mac_addr[5]);

  }

  return error;
}
예제 #2
0
/*
* get_board_mac_addr
*
* Read the MAC address in a board specific way
*
*/
error_t get_board_mac_addr(unsigned char mac_addr[6])
{
    error_t error = 0;
    alt_u32 signature;
#if 0
    /* Get the flash sector with the MAC address. */
    error = FindLastFlashSectorOffset(&last_flash_sector_offset);
    if (!error)
        last_flash_sector = EXT_FLASH_BASE + last_flash_sector_offset;

    /* This last_flash_sector region of flash is examined to see if 
     * valid network settings are present, indicated by a signature of 0x00005afe at 
     * the first address of the last flash sector.  This hex value is chosen as the 
     * signature since it looks like the english word "SAFE", meaning that it is 
     * safe to use these network address values.  
    */
    if (!error)
    {
        signature = IORD_32DIRECT(last_flash_sector, 0);
        if (signature != 0x00005afe)
        {
          error = generate_and_store_mac_addr();
        }
    }
#endif  
    if (!error)
    {
  	/* Hard code MAC address here $$ */
    mac_addr[0] = 0x00;
    mac_addr[1] = 0x15;
    mac_addr[2] = 0x17;
    mac_addr[3] = 0x26;
    mac_addr[4] = 0x63;
    mac_addr[5] = 0xf9;
    
        printf("Your Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n", 
            mac_addr[0],
            mac_addr[1],
            mac_addr[2],
            mac_addr[3],
            mac_addr[4],
            mac_addr[5]);
    
    }
    
    return error;
}
예제 #3
0
/*
* get_board_mac_addr
*
* Read the MAC address in a board specific way
*
*/
error_t get_board_mac_addr(unsigned char mac_addr[6])
{
  error_t error = 0;

  alt_u32 signature;
  alt_u32 mac_addr_ptr = EXT_FLASH_BASE + ETHERNET_OPTION_BITS;
  
/* This last_flash_sector region of flash is examined to see if 
 * valid network settings are present, indicated by a signature of 0x00005afe at 
 * the first address of the last flash sector.  This hex value is chosen as the 
 * signature since it looks like the english word "SAFE", meaning that it is 
 * safe to use these network address values.  
*/

  /* Get the flash sector with the MAC address. */
  signature = IORD_32DIRECT(mac_addr_ptr, 0);
    
  if (signature != 0x00005afe)
  {
    error = generate_and_store_mac_addr();
  }
  
  if (!error)
  {
    mac_addr[0] = IORD_8DIRECT(mac_addr_ptr, 4);
    mac_addr[1] = IORD_8DIRECT(mac_addr_ptr, 5);
    mac_addr[2] = IORD_8DIRECT(mac_addr_ptr, 6);
    mac_addr[3] = IORD_8DIRECT(mac_addr_ptr, 7);
    mac_addr[4] = IORD_8DIRECT(mac_addr_ptr, 8);
    mac_addr[5] = IORD_8DIRECT(mac_addr_ptr, 9);
    
    printf("Your Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n", 
            mac_addr[0],
            mac_addr[1],
            mac_addr[2],
            mac_addr[3],
            mac_addr[4],
            mac_addr[5]);

  }

  return error;
}