mirror of https://github.com/m-labs/artiq.git
runtime: link against lwip, cleanups
This commit is contained in:
parent
91cd79a8a3
commit
4c6387929b
|
@ -40,7 +40,8 @@ runtime.elf: $(OBJECTS) libs
|
||||||
$(OBJECTS) \
|
$(OBJECTS) \
|
||||||
-L$(MSCDIR)/software/libbase \
|
-L$(MSCDIR)/software/libbase \
|
||||||
-L$(MSCDIR)/software/libcompiler-rt \
|
-L$(MSCDIR)/software/libcompiler-rt \
|
||||||
-lbase -lcompiler-rt
|
-Lliblwip \
|
||||||
|
-lbase -lcompiler-rt -llwip
|
||||||
@chmod -x $@
|
@chmod -x $@
|
||||||
|
|
||||||
ksupport.elf: $(OBJECTS_KSUPPORT)
|
ksupport.elf: $(OBJECTS_KSUPPORT)
|
||||||
|
@ -71,8 +72,10 @@ main.o: main.c
|
||||||
libs:
|
libs:
|
||||||
$(MAKE) -C $(MSCDIR)/software/libcompiler-rt
|
$(MAKE) -C $(MSCDIR)/software/libcompiler-rt
|
||||||
$(MAKE) -C $(MSCDIR)/software/libbase
|
$(MAKE) -C $(MSCDIR)/software/libbase
|
||||||
|
$(MAKE) -C liblwip
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
$(MAKE) -C liblwip clean
|
||||||
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) $(OBJECTS_KSUPPORT) $(OBJECTS_KSUPPORT:.o=.d)
|
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) $(OBJECTS_KSUPPORT) $(OBJECTS_KSUPPORT:.o=.d)
|
||||||
$(RM) runtime.elf runtime.bin runtime.fbi .*~ *~
|
$(RM) runtime.elf runtime.bin runtime.fbi .*~ *~
|
||||||
$(RM) service_table.h ksupport.elf ksupport.bin
|
$(RM) service_table.h ksupport.elf ksupport.bin
|
||||||
|
|
|
@ -32,7 +32,7 @@ CORE4OBJS=$(LWIPDIR)/core/ipv4/icmp.o \
|
||||||
NETIFOBJS=$(LWIPDIR)/netif/etharp.o \
|
NETIFOBJS=$(LWIPDIR)/netif/etharp.o \
|
||||||
netif/liteethif.o
|
netif/liteethif.o
|
||||||
|
|
||||||
# NETIFOBJS: All the above.
|
# LWIPOBJS: All the above.
|
||||||
LWIPOBJS=$(COREOBJS) $(CORE4OBJS) $(NETIFOBJS)
|
LWIPOBJS=$(COREOBJS) $(CORE4OBJS) $(NETIFOBJS)
|
||||||
OBJS_LIB+=$(LWIPOBJS)
|
OBJS_LIB+=$(LWIPOBJS)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <hw/ethmac_mem.h>
|
#include <hw/ethmac_mem.h>
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
unsigned char raw[1514];
|
unsigned char raw[1514];
|
||||||
} ethernet_buffer;
|
} ethernet_buffer;
|
||||||
|
|
||||||
static unsigned int rxslot;
|
static unsigned int rxslot;
|
||||||
|
@ -32,106 +32,103 @@ static ethernet_buffer *txbuffer1;
|
||||||
|
|
||||||
static void liteeth_low_level_init(struct netif *netif)
|
static void liteeth_low_level_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
netif->hwaddr_len = 6;
|
netif->hwaddr_len = 6;
|
||||||
for(i=0;i<netif->hwaddr_len;i++)
|
for(i=0;i<netif->hwaddr_len;i++)
|
||||||
netif->hwaddr[i] = macadr[i];
|
netif->hwaddr[i] = macadr[i];
|
||||||
netif->mtu = 1514;
|
netif->mtu = 1514;
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
||||||
|
|
||||||
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
||||||
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
||||||
|
|
||||||
rxbuffer0 = (ethernet_buffer *)ETHMAC_RX0_BASE;
|
rxbuffer0 = (ethernet_buffer *)ETHMAC_RX0_BASE;
|
||||||
rxbuffer1 = (ethernet_buffer *)ETHMAC_RX1_BASE;
|
rxbuffer1 = (ethernet_buffer *)ETHMAC_RX1_BASE;
|
||||||
txbuffer0 = (ethernet_buffer *)ETHMAC_TX0_BASE;
|
txbuffer0 = (ethernet_buffer *)ETHMAC_TX0_BASE;
|
||||||
txbuffer1 = (ethernet_buffer *)ETHMAC_TX1_BASE;
|
txbuffer1 = (ethernet_buffer *)ETHMAC_TX1_BASE;
|
||||||
|
|
||||||
rxslot = 0;
|
rxslot = 0;
|
||||||
txslot = 0;
|
txslot = 0;
|
||||||
|
|
||||||
rxbuffer = rxbuffer0;
|
rxbuffer = rxbuffer0;
|
||||||
txbuffer = txbuffer0;
|
txbuffer = txbuffer0;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)
|
static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
{
|
{
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
|
|
||||||
txlen = 0;
|
txlen = 0;
|
||||||
for(q = p; q != NULL; q = q->next) {
|
for(q = p; q != NULL; q = q->next) {
|
||||||
memcpy(txbuffer->raw, q->payload, q->len);
|
memcpy(txbuffer->raw, q->payload, q->len);
|
||||||
txbuffer += q->len;
|
txbuffer += q->len;
|
||||||
txlen += q->len;
|
txlen += q->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
ethmac_sram_reader_slot_write(txslot);
|
ethmac_sram_reader_slot_write(txslot);
|
||||||
ethmac_sram_reader_length_write(txlen);
|
ethmac_sram_reader_length_write(txlen);
|
||||||
while(!(ethmac_sram_reader_ready_read()));
|
while(!ethmac_sram_reader_ready_read());
|
||||||
ethmac_sram_reader_start_write(1);
|
ethmac_sram_reader_start_write(1);
|
||||||
|
|
||||||
txslot = (txslot+1)%2;
|
txslot = (txslot + 1) % 2;
|
||||||
if (txslot)
|
if(txslot)
|
||||||
txbuffer = txbuffer1;
|
txbuffer = txbuffer1;
|
||||||
else
|
else
|
||||||
txbuffer = txbuffer0;
|
txbuffer = txbuffer0;
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pbuf * liteeth_low_level_input(struct netif *netif)
|
static struct pbuf *liteeth_low_level_input(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct pbuf *p, *q;
|
struct pbuf *p, *q;
|
||||||
|
|
||||||
rxslot = ethmac_sram_writer_slot_read();
|
rxslot = ethmac_sram_writer_slot_read();
|
||||||
rxlen = ethmac_sram_writer_length_read();
|
rxlen = ethmac_sram_writer_length_read();
|
||||||
if (rxslot)
|
if(rxslot)
|
||||||
rxbuffer = rxbuffer1;
|
rxbuffer = rxbuffer1;
|
||||||
else
|
else
|
||||||
rxbuffer = rxbuffer0;
|
rxbuffer = rxbuffer0;
|
||||||
|
|
||||||
p = pbuf_alloc(PBUF_RAW, rxlen, PBUF_POOL);
|
p = pbuf_alloc(PBUF_RAW, rxlen, PBUF_POOL);
|
||||||
if (p != NULL) {
|
if(p != NULL) {
|
||||||
for(q = p; q != NULL; q = q->next) {
|
for(q = p; q != NULL; q = q->next) {
|
||||||
memcpy(q->payload, rxbuffer->raw, q->len);
|
memcpy(q->payload, rxbuffer->raw, q->len);
|
||||||
rxbuffer += q->len;
|
rxbuffer += q->len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void liteeth_input(struct netif *netif)
|
void liteeth_input(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
p = liteeth_low_level_input(netif);
|
p = liteeth_low_level_input(netif);
|
||||||
if (p != NULL) {
|
if(p != NULL)
|
||||||
netif->input(p, netif);
|
netif->input(p, netif);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err_t liteeth_init(struct netif *netif)
|
err_t liteeth_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct liteethif *liteethif;
|
struct liteethif *liteethif;
|
||||||
|
|
||||||
liteethif = mem_malloc(sizeof(struct liteethif));
|
liteethif = mem_malloc(sizeof(struct liteethif));
|
||||||
if (liteethif == NULL)
|
if(liteethif == NULL)
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
netif->state = liteethif;
|
netif->state = liteethif;
|
||||||
|
|
||||||
netif->hwaddr_len = 6;
|
netif->hwaddr_len = 6;
|
||||||
netif->name[0] = IFNAME0;
|
netif->name[0] = IFNAME0;
|
||||||
netif->name[1] = IFNAME1;
|
netif->name[1] = IFNAME1;
|
||||||
netif->output = etharp_output;
|
netif->output = etharp_output;
|
||||||
netif->linkoutput = liteeth_low_level_output;
|
netif->linkoutput = liteeth_low_level_output;
|
||||||
netif->mtu = 1514;
|
netif->mtu = 1514;
|
||||||
|
|
||||||
liteethif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
liteethif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
||||||
|
|
||||||
liteeth_low_level_init(netif);
|
liteeth_low_level_init(netif);
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue