static err_t low_level_init(struct netif *netif) { struct xemac_s *xemac; XEmacLite_Config *config; XEmacLite *xemaclitep; struct xtopology_t *xtopologyp; xemacliteif_s *xemacliteif; unsigned link_speed = 1000; xemaclitep = mem_malloc(sizeof *xemaclitep); #ifndef XLWIP_CONFIG_INCLUDE_EMACLITE_ON_ZYNQ #if XPAR_INTC_0_HAS_FAST == 1 xemaclitep_fast = xemaclitep; #endif #endif if (xemaclitep == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xemacliteif_init: out of memory\r\n")); return ERR_MEM; } xemac = mem_malloc(sizeof *xemac); if (xemac == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xemacliteif_init: out of memory\r\n")); return ERR_MEM; } xemacliteif = mem_malloc(sizeof *xemacliteif); if (xemacliteif == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xemacliteif_init: out of memory\r\n")); return ERR_MEM; } /* obtain pointer to topology structure for this emac */ xemac->topology_index = xtopology_find_index((unsigned)(netif->state)); xtopologyp = &xtopology[xemac->topology_index]; /* obtain config of this emaclite */ config = xemaclite_lookup_config((unsigned)(netif->state)); /* maximum transfer unit */ netif->mtu = XEL_MTU_SIZE; /* broadcast capability */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; /* initialize the mac */ XEmacLite_Initialize(xemaclitep, config->DeviceId); xemaclitep->NextRxBufferToUse = 0; #if XLWIP_CONFIG_INCLUDE_EMACLITE_ON_ZYNQ == 1 XScuGic_RegisterHandler(xtopologyp->scugic_baseaddr, xtopologyp->intc_emac_intr, (Xil_ExceptionHandler)XEmacLite_InterruptHandler, xemaclitep); XScuGic_SetPriTrigTypeByDistAddr(INTC_DIST_BASE_ADDR, xtopologyp->intc_emac_intr, EMACLITE_INTR_PRIORITY_SET_IN_GIC, TRIG_TYPE_RISING_EDGE_SENSITIVE); XScuGic_EnableIntr(INTC_DIST_BASE_ADDR, xtopologyp->intc_emac_intr); #else #if NO_SYS #if XPAR_INTC_0_HAS_FAST == 1 XIntc_RegisterFastHandler(xtopologyp->intc_baseaddr, xtopologyp->intc_emac_intr, (XFastInterruptHandler)XEmacLite_FastInterruptHandler); #else XIntc_RegisterHandler(xtopologyp->intc_baseaddr, xtopologyp->intc_emac_intr, (XInterruptHandler)XEmacLite_InterruptHandler, xemaclitep); #endif #else xPortInstallInterruptHandler( XPAR_INTC_0_EMACLITE_0_VEC_ID, ( XInterruptHandler ) XEmacLite_InterruptWrapper, xemaclitep ); vPortEnableInterrupt( XPAR_INTC_0_EMACLITE_0_VEC_ID ); #endif #endif /* set mac address */ XEmacLite_SetMacAddress(xemaclitep, (unsigned char*)(netif->hwaddr)); /* flush any frames already received */ XEmacLite_FlushReceive(xemaclitep); /* set Rx, Tx interrupt handlers */ XEmacLite_SetRecvHandler(xemaclitep, (void *)(xemac), xemacif_recv_handler); XEmacLite_SetSendHandler(xemaclitep, (void *)(xemac), xemacif_send_handler); /* enable Rx, Tx interrupts */ XEmacLite_EnableInterrupts(xemaclitep); #if !NO_SYS sys_sem_new(&xemac->sem_rx_data_available, 0); #endif /* replace the state in netif (currently the base address of emaclite) * with the xemacliteif instance pointer. * this contains a pointer to the config table entry */ xemac->type = xemac_type_xps_emaclite; xemac->state = (void *)xemacliteif; netif->state = (void *)xemac; xemacliteif->instance = xemaclitep; xemacliteif->recv_q = pq_create_queue(); if (!xemacliteif->recv_q) return ERR_MEM; xemacliteif->send_q = pq_create_queue(); if (!xemacliteif->send_q) return ERR_MEM; /* Initialize PHY */ /* set PHY <--> MAC data clock */ #ifdef CONFIG_LINKSPEED_AUTODETECT link_speed = get_IEEE_phy_speed_emaclite(xemaclitep); xil_printf("auto-negotiated link speed: %d\r\n", link_speed); #elif defined(CONFIG_LINKSPEED1000) xil_printf("Link speed of 1000 Mbps not possible\r\n"); #elif defined(CONFIG_LINKSPEED100) link_speed = 100; configure_IEEE_phy_speed_emaclite(xemaclitep, link_speed); xil_printf("link speed: %d\r\n", link_speed); #elif defined(CONFIG_LINKSPEED10) link_speed = 10; configure_IEEE_phy_speed_emaclite(xemaclitep, link_speed); xil_printf("link speed: %d\r\n", link_speed); #endif return ERR_OK; }
static err_t low_level_init(struct netif *netif) { unsigned mac_address = (unsigned)(netif->state); struct xemac_s *xemac; xaxiemacif_s *xaxiemacif; XAxiEthernet_Config *mac_config; xaxiemacif = mem_malloc(sizeof *xaxiemacif); if (xaxiemacif == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xaxiemacif_init: out of memory\r\n")); return ERR_MEM; } xemac = mem_malloc(sizeof *xemac); if (xemac == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xaxiemacif_init: out of memory\r\n")); return ERR_MEM; } xemac->state = (void *)xaxiemacif; xemac->topology_index = xtopology_find_index(mac_address); xemac->type = xemac_type_axi_ethernet; xaxiemacif->send_q = NULL; xaxiemacif->recv_q = pq_create_queue(); if (!xaxiemacif->recv_q) return ERR_MEM; /* maximum transfer unit */ #ifdef USE_JUMBO_FRAMES netif->mtu = XAE_JUMBO_MTU - XAE_HDR_SIZE; #else netif->mtu = XAE_MTU - XAE_HDR_SIZE; #endif #if LWIP_IGMP netif->igmp_mac_filter = xaxiemacif_mac_filter_update; #endif netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; #if LWIP_IGMP netif->flags |= NETIF_FLAG_IGMP; #endif #if !NO_SYS sys_sem_new(&xemac->sem_rx_data_available, 0); #endif /* obtain config of this emac */ mac_config = lookup_config((unsigned)netif->state); XAxiEthernet_CfgInitialize(&xaxiemacif->axi_ethernet, mac_config, mac_config->BaseAddress); /* figure out if the system has DMA */ if (XAxiEthernet_IsDma(&xaxiemacif->axi_ethernet)) { #ifndef XLWIP_CONFIG_INCLUDE_AXI_ETHERNET_FIFO /* initialize the DMA engine */ init_axi_dma(xemac); #endif } else if (XAxiEthernet_IsFifo(&xaxiemacif->axi_ethernet)) { #ifdef XLWIP_CONFIG_INCLUDE_AXI_ETHERNET_FIFO /* initialize the locallink FIFOs */ init_axi_fifo(xemac); #endif } else { /* should not occur */ LWIP_DEBUGF(NETIF_DEBUG, ("xaxiemacif_init: mac is not configured with DMA or FIFO\r\n")); return ERR_IF; } /* initialize the mac */ init_axiemac(xaxiemacif, netif); /* replace the state in netif (currently the emac baseaddress) * with the mac instance pointer. */ netif->state = (void *)xemac; return ERR_OK; }
static err_t low_level_init(struct netif *netif) { unsigned mac_address = (unsigned)(netif->state); struct xemac_s *xemac; xlltemacif_s *xlltemacif; xlltemacif = mem_malloc(sizeof *xlltemacif); if (xlltemacif == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xlltemacif_init: out of memory\r\n")); return ERR_MEM; } xemac = mem_malloc(sizeof *xemac); if (xemac == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xlltemacif_init: out of memory\r\n")); return ERR_MEM; } xemac->state = (void *)xlltemacif; xemac->topology_index = xtopology_find_index(mac_address); xemac->type = xemac_type_xps_ll_temac; xlltemacif->send_q = NULL; xlltemacif->recv_q = pq_create_queue(); if (!xlltemacif->recv_q) return ERR_MEM; /* maximum transfer unit */ #ifdef USE_JUMBO_FRAMES netif->mtu = XTE_JUMBO_MTU - XTE_HDR_SIZE; #else netif->mtu = XTE_MTU - XTE_HDR_SIZE; #endif #if LWIP_IGMP netif->igmp_mac_filter = xlltemacif_mac_filter_update; #endif /* broadcast capability */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; #if LWIP_IGMP netif->flags |= NETIF_FLAG_IGMP; #endif #if !NO_SYS sys_sem_new(&xemac->sem_rx_data_available, 0); #endif /* initialize the mac */ init_lltemac(xlltemacif, netif); /* figure out if the system has DMA */ if (XLlTemac_IsDma(&xlltemacif->lltemac)) { /* initialize the DMA engine */ init_sdma(xemac); } else if (XLlTemac_IsFifo(&xlltemacif->lltemac)) { /* initialize the locallink FIFOs */ init_ll_fifo(xemac); } else { /* should not occur */ LWIP_DEBUGF(NETIF_DEBUG, ("xlltemacif_init: lltemac is not configured with DMA or FIFO\r\n")); return ERR_IF; } /* replace the state in netif (currently the emac baseaddress) * with the xlltemac instance pointer. */ netif->state = (void *)xemac; return ERR_OK; }
static err_t low_level_init(struct netif *netif) { struct xemac_s *xemac; XEmacLite_Config *config; XEmacLite *xemaclitep; struct xtopology_t *xtopologyp; xemacliteif_s *xemacliteif; xemaclitep = mem_malloc(sizeof *xemaclitep); if (xemaclitep == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xemacliteif_init: out of memory\r\n")); return ERR_MEM; } xemac = mem_malloc(sizeof *xemac); if (xemac == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xemacliteif_init: out of memory\r\n")); return ERR_MEM; } xemacliteif = mem_malloc(sizeof *xemacliteif); if (xemac == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("xemacliteif_init: out of memory\r\n")); return ERR_MEM; } /* obtain pointer to topology structure for this emac */ xemac->topology_index = xtopology_find_index((unsigned)(netif->state)); xtopologyp = &xtopology[xemac->topology_index]; /* obtain config of this emaclite */ config = xemaclite_lookup_config((unsigned)(netif->state)); /* maximum transfer unit */ netif->mtu = XEL_MTU_SIZE; /* broadcast capability */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; /* initialize the mac */ XEmacLite_Initialize(xemaclitep, config->DeviceId); xemaclitep->NextRxBufferToUse = 0; #if NO_SYS XIntc_RegisterHandler(xtopologyp->intc_baseaddr, xtopologyp->intc_emac_intr, (XInterruptHandler)XEmacLite_InterruptHandler, xemaclitep); #else #include "xmk.h" register_int_handler(xtopologyp->intc_emac_intr, (XInterruptHandler)XEmacLite_InterruptHandler, xemaclitep); enable_interrupt(xtopologyp->intc_emac_intr); #endif /* set mac address */ XEmacLite_SetMacAddress(xemaclitep, (Xuint8*)(netif->hwaddr)); /* flush any frames already received */ XEmacLite_FlushReceive(xemaclitep); /* set Rx, Tx interrupt handlers */ XEmacLite_SetRecvHandler(xemaclitep, (void *)(xemac), xemacif_recv_handler); XEmacLite_SetSendHandler(xemaclitep, (void *)(xemac), xemacif_send_handler); /* enable Rx, Tx interrupts */ XEmacLite_EnableInterrupts(xemaclitep); #if !NO_SYS xemac->sem_rx_data_available = sys_sem_new(0); #endif /* replace the state in netif (currently the base address of emaclite) * with the xemacliteif instance pointer. * this contains a pointer to the config table entry */ xemac->type = xemac_type_xps_emaclite; xemac->state = (void *)xemacliteif; netif->state = (void *)xemac; xemacliteif->instance = xemaclitep; xemacliteif->recv_q = pq_create_queue(); if (!xemacliteif->recv_q) return ERR_MEM; xemacliteif->send_q = pq_create_queue(); if (!xemacliteif->send_q) return ERR_MEM; return ERR_OK; }