示例#1
0
IOReturn AtherosL1Ethernet::setHardwareAddress(const IOEthernetAddress *addr)
{
    DbgPrint("setHardwareAddress()\n");
    memcpy(adapter_.hw.mac_addr, addr->bytes, NODE_ADDRESS_SIZE);
    set_mac_addr(&adapter_.hw);
    return kIOReturnSuccess;
}
void ETH1_init(u8_t *mac_addr)
{

    outpw(REG_CLK_HCLKEN, inpw(REG_CLK_HCLKEN) | (1 << 17));             // EMAC1 clk
    outpw(REG_CLK_DIVCTL8, (inpw(REG_CLK_DIVCTL8) & ~0xFF) | 0xA0);     // MDC clk divider

    // Multi function pin setting
    outpw(REG_SYS_GPE_MFPL, (inpw(REG_SYS_GPE_MFPL) & ~0xFFFFFF00) | 0x11111100);
    outpw(REG_SYS_GPE_MFPH, (inpw(REG_SYS_GPE_MFPH) & ~0xFFFF) | 0x1111);

    // Reset MAC
    outpw(REG_EMAC1_MCMDR, 0x1000000);

    init_tx_desc();
    init_rx_desc();

    set_mac_addr(mac_addr);  // need to reconfigure hardware address 'cos we just RESET emc...
    reset_phy();

    outpw(REG_EMAC1_MCMDR, inpw(REG_EMAC1_MCMDR) | 0x121); // strip CRC, TX on, Rx on
    outpw(REG_EMAC1_MIEN, inpw(REG_EMAC1_MIEN) | 0x01250C11);  // Except tx/rx ok, enable rdu, txabt, tx/rx bus error.

    sysInstallISR(IRQ_LEVEL_1, EMC1_TX_IRQn, (PVOID)ETH1_TX_IRQHandler);
    sysInstallISR(IRQ_LEVEL_1, EMC1_RX_IRQn, (PVOID)ETH1_RX_IRQHandler);
    sysEnableInterrupt(EMC1_TX_IRQn);
    sysEnableInterrupt(EMC1_RX_IRQn);

    ETH1_TRIGGER_RX();

    sysSetTimerEvent(TIMER0, 200, (PVOID)chk_link);  // check link status every 2 sec
}
示例#3
0
static int eeprom_ioctl( struct inode *inode, struct file *file,
			 unsigned int cmd, unsigned long arg )
{
	switch( cmd ){ 
		case SET_MAC_ADDRS: 
				set_mac_addr((u_char*)arg ) ;
				break;
		
		case GET_MAC_ADDRS: 
				get_mac_addr((u_char*)arg ) ;
				break;
		default: 
				return -EINVAL ;
	}

	return 0;
}
示例#4
0
inline
void Ist_run_config()
{
	//FIRST_TIME_CONNECTION_SETTING_PROFILES


	//this is temporary arrangement.
	//TODO: need to implement in a proper way.



		char ip[4]={192,168,39,99};
			unsigned char mac[]={0x0, 0x25, 0xca, 0x03, 0x10, 0xef};

			//do all configurations.
			set_mac_addr(mac);				//EACH DEVICE NEED TO HAVE/SET A UNIQUE ADDR.()
		  // configureGetIpUsingDhcp();
			net_config_ip((unsigned long *)ip); 	//NEED TO CONNECT TO THE REGISTRATION DEVICE WITH OR WITHOUT DHCP.

		   //then connect.
		  // testconnect_unsecured();
			ConnectWithWellKnownAP();				//NEED TO CONNECT TO THE REGISTRATION DEVICE.
}
示例#5
0
/*---------------------------------------------------------------------------*/
void
contiki_init(void)
{
  int i;
  uint8_t addr[sizeof(uip_lladdr.addr)];
  uip_ipaddr_t ipaddr;
  uip_ds6_addr_t *lladdr;
  uip_ip4addr_t ipv4addr, netmask;

  /* Start process handler */
  process_init();

  /* Start Contiki processes */
  process_start(&etimer_process, NULL);
  process_start(&sensors_process, NULL);
  ctimer_init();

  /* Print startup information */
  printf(CONTIKI_VERSION_STRING " started. ");
  if(node_id > 0) {
    printf("Node id is set to %u.\n", node_id);
  } else {
    printf("Node id is not set.\n");
  }

  set_mac_addr();

  queuebuf_init();

  /* Initialize communication stack */
  netstack_init();
  printf("%s/%s/%s, channel check rate %lu Hz\n",
         NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
                         NETSTACK_RDC.channel_check_interval()));

  /* IPv6 CONFIGURATION */


  for(i = 0; i < sizeof(uip_lladdr.addr); i += 2) {
    addr[i + 1] = node_id & 0xff;
    addr[i + 0] = node_id >> 8;
  }
  linkaddr_copy(addr, &linkaddr_node_addr);
  memcpy(&uip_lladdr.addr, addr, sizeof(uip_lladdr.addr));

  process_start(&tcpip_process, NULL);

  printf("Tentative link-local IPv6 address ");

  lladdr = uip_ds6_get_link_local(-1);
  for(i = 0; i < 7; ++i) {
    printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
           lladdr->ipaddr.u8[i * 2 + 1]);
  }
  printf("%02x%02x\n", lladdr->ipaddr.u8[14],
         lladdr->ipaddr.u8[15]);

  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
  uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
  uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
  printf("Tentative global IPv6 address ");
  for(i = 0; i < 7; ++i) {
    printf("%02x%02x:",
           ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
  }
  printf("%02x%02x\n",
         ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);

  /* Start serial process */
  serial_line_init();

  /* Start autostart processes (defined in Contiki application) */
  print_processes(autostart_processes);
  autostart_start(autostart_processes);

  /* Start the SLIP */
  printf("Initiating SLIP with IP address is 172.16.0.2.\n");

  uip_ipaddr(&ipv4addr, 172, 16, 0, 2);
  uip_ipaddr(&netmask, 255, 255, 255, 0);
  ip64_set_ipv4_address(&ipv4addr, &netmask);

  rs232_set_input(slip_input_byte);
  log_set_putchar_with_slip(1);

  uip_ip4addr_t ip4addr;
  uip_ip6addr_t ip6addr;

  uip_ipaddr(&ip4addr, 8,8,8,8);
  ip64_addr_4to6(&ip4addr, &ip6addr);

  uip_nameserver_update((uip_ipaddr_t *)&ip6addr, UIP_NAMESERVER_INFINITE_LIFETIME);
}
IOReturn AgereET131x::setHardwareAddress(const IOEthernetAddress * addr)
{
	set_mac_addr(addr->bytes);
	return kIOReturnSuccess;
}