/* Set the base MAC address of the chassis */ static int c3725_burn_mac_addr(c3725_t *router,n_eth_addr_t *addr) { m_uint8_t eeprom_ver; size_t offset; /* Read EEPROM format version */ cisco_eeprom_get_byte(&router->mb_eeprom,0,&eeprom_ver); switch(eeprom_ver) { case 0: cisco_eeprom_set_region(&router->mb_eeprom,2,addr->eth_addr_byte,6); break; case 4: if (!cisco_eeprom_v4_find_field(&router->mb_eeprom,0xC3,&offset)) { cisco_eeprom_set_region(&router->mb_eeprom,offset, addr->eth_addr_byte,6); } break; default: vm_error(router->vm,"c3725_burn_mac_addr: unable to handle " "EEPROM version %u\n",eeprom_ver); return(-1); } return(0); }
/* Callback for MPC860 SPI Transmit */ static void dev_c1700_mpc860_spi_tx_callback(struct mpc860_data *mpc_data, u_char *buffer,u_int len, void *user_arg) { struct c1700_iofpga_data *d = user_arg; struct cisco_eeprom *eeprom; u_char reply_buf[4]; u_int wic_port; u_int eeprom_offset; if (d->wic_select & 0x20) wic_port = 0x10; else if (d->wic_select & 0x08) wic_port = 0x20; else { #if DEBUG_WIC vm_error(d->router->vm,"unknown value for wic_select (0x%8.8x)\n", d->wic_select); #endif wic_port = 0; } /* No WIC in slot or no EEPROM: fake an empty EEPROM */ if (!wic_port || !(eeprom = vm_slot_get_eeprom(d->router->vm,0,wic_port))) { memset(reply_buf,0xFF,sizeof(reply_buf)); mpc860_spi_receive(mpc_data,reply_buf,sizeof(reply_buf)); return; } /* Read request: 0x03 offset 0x00 0x00 */ eeprom_offset = buffer[1]; reply_buf[0] = 0; reply_buf[1] = 0; cisco_eeprom_get_byte(eeprom,eeprom_offset,&reply_buf[2]); cisco_eeprom_get_byte(eeprom,eeprom_offset+1,&reply_buf[3]); mpc860_spi_receive(mpc_data,reply_buf,sizeof(reply_buf)); }