aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c130
-rw-r--r--demos/ARM7-AT91SAM7X-WEB-GCC/Makefile6
-rw-r--r--demos/ARM7-AT91SAM7X-WEB-GCC/board.c6
-rw-r--r--demos/ARM7-AT91SAM7X-WEB-GCC/main.c2
-rw-r--r--demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c32
-rw-r--r--os/io/platforms/AT91SAM7X/mac_lld.c8
6 files changed, 88 insertions, 96 deletions
diff --git a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c
index 5716f6e58..ccd7bd67f 100644
--- a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c
+++ b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/netif/ethernetif.c
@@ -1,55 +1,3 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
-
- This file is part of ChibiOS/RT.
-
- ChibiOS/RT is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/RT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-/*
- **** This file incorporates work covered by the following copyright and ****
- **** permission notice: ****
-
- Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- OF SUCH DAMAGE.
-
- This file is part of the lwIP TCP/IP stack.
-
- Author: Adam Dunkels <adam@sics.se>
-*/
-
/**
* @file
* Ethernet Interface Skeleton
@@ -57,6 +5,38 @@
*/
/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+
+/*
* This file is a skeleton for developing Ethernet network interface
* drivers for lwIP. Add code to the low_level functions and do a
* search-and-replace for the word "ethernetif" to replace it with
@@ -65,7 +45,7 @@
#include "lwip/opt.h"
-#if 1 /* don't build, this is only a skeleton, see previous comment */
+#if 0 /* don't build, this is only a skeleton, see previous comment */
#include "lwip/def.h"
#include "lwip/mem.h"
@@ -105,23 +85,23 @@ static void
low_level_init(struct netif *netif)
{
struct ethernetif *ethernetif = netif->state;
-
+
/* set MAC hardware address length */
netif->hwaddr_len = ETHARP_HWADDR_LEN;
/* set MAC hardware address */
-////////// netif->hwaddr[0] = ;
-////////// ...
-////////// netif->hwaddr[5] = ;
+ netif->hwaddr[0] = ;
+ ...
+ netif->hwaddr[5] = ;
/* maximum transfer unit */
netif->mtu = 1500;
-
+
/* device capabilities */
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
-
- /* Do whatever else is needed to initialize interface. */
+
+ /* Do whatever else is needed to initialize interface. */
}
/**
@@ -146,8 +126,8 @@ low_level_output(struct netif *netif, struct pbuf *p)
struct ethernetif *ethernetif = netif->state;
struct pbuf *q;
-////////// initiate transfer();
-
+ initiate transfer();
+
#if ETH_PAD_SIZE
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
#endif
@@ -156,15 +136,15 @@ low_level_output(struct netif *netif, struct pbuf *p)
/* Send the data from the pbuf to the interface, one pbuf at a
time. The size of the data in each pbuf is kept in the ->len
variable. */
-////////// send data from(q->payload, q->len);
+ send data from(q->payload, q->len);
}
-////////// signal that packet should be sent();
+ signal that packet should be sent();
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
#endif
-
+
LINK_STATS_INC(link.xmit);
return ERR_OK;
@@ -187,7 +167,7 @@ low_level_input(struct netif *netif)
/* Obtain the size of the packet and put it into the "len"
variable. */
-////////// len = ;
+ len = ;
#if ETH_PAD_SIZE
len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
@@ -195,7 +175,7 @@ low_level_input(struct netif *netif)
/* We allocate a pbuf chain of pbufs from the pool. */
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
-
+
if (p != NULL) {
#if ETH_PAD_SIZE
@@ -208,9 +188,9 @@ low_level_input(struct netif *netif)
/* Read enough bytes to fill this pbuf in the chain. The
* available data in the pbuf is given by the q->len
* variable. */
-////////// read data into(q->payload, q->len);
+ read data into(q->payload, q->len);
}
-////////// acknowledge that packet has been read();
+ acknowledge that packet has been read();
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
@@ -218,12 +198,12 @@ low_level_input(struct netif *netif)
LINK_STATS_INC(link.recv);
} else {
-////////// drop packet();
+ drop packet();
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
}
- return p;
+ return p;
}
/**
@@ -293,7 +273,7 @@ ethernetif_init(struct netif *netif)
struct ethernetif *ethernetif;
LWIP_ASSERT("netif != NULL", (netif != NULL));
-
+
ethernetif = mem_malloc(sizeof(struct ethernetif));
if (ethernetif == NULL) {
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n"));
@@ -310,7 +290,7 @@ ethernetif_init(struct netif *netif)
* The last argument should be replaced with your link speed, in units
* of bits per second.
*/
- NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, ???);
+ NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
netif->state = ethernetif;
netif->name[0] = IFNAME0;
@@ -321,9 +301,9 @@ ethernetif_init(struct netif *netif)
* is available...) */
netif->output = etharp_output;
netif->linkoutput = low_level_output;
-
+
ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
-
+
/* initialize the hardware */
low_level_init(netif);
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile
index 9538d20d5..bb4c21c1a 100644
--- a/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile
+++ b/demos/ARM7-AT91SAM7X-WEB-GCC/Makefile
@@ -65,13 +65,17 @@ CSRC = ${PORTSRC} \
${USRC} \
${CHIBIOS}/os/io/pal.c \
${CHIBIOS}/os/io/serial.c \
+ ${CHIBIOS}/os/io/phy.c \
+ ${CHIBIOS}/os/io/mac.c \
${CHIBIOS}/os/io/platforms/AT91SAM7X/pal_lld.c \
${CHIBIOS}/os/io/platforms/AT91SAM7X/serial_lld.c \
- ${CHIBIOS}/os/io/platforms/AT91SAM7X/sam7x_emac.c \
+ ${CHIBIOS}/os/io/platforms/AT91SAM7X/phy_lld.c \
+ ${CHIBIOS}/os/io/platforms/AT91SAM7X/mac_lld.c \
${CHIBIOS}/os/io/platforms/AT91SAM7X/at91lib/aic.c \
${CHIBIOS}/os/various/evtimer.c \
web/webthread.c \
board.c main.c
+# ${CHIBIOS}/os/io/platforms/AT91SAM7X/sam7x_emac.c \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c
index e57f8bcdc..39136b03e 100644
--- a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c
+++ b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c
@@ -20,7 +20,8 @@
#include <ch.h>
#include <pal.h>
#include <serial.h>
-#include <sam7x_emac.h>
+#include <mac.h>
+//#include <sam7x_emac.h>
#include "board.h"
#include "at91lib/aic.h"
@@ -178,7 +179,8 @@ void hwinit1(void) {
/*
* EMAC driver initialization.
*/
- emac_init(AT91C_AIC_PRIOR_HIGHEST - 3);
+// emac_init(AT91C_AIC_PRIOR_HIGHEST - 3);
+ macInit();
/*
* ChibiOS/RT initialization.
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/main.c b/demos/ARM7-AT91SAM7X-WEB-GCC/main.c
index adfba225f..e2d3e8cd8 100644
--- a/demos/ARM7-AT91SAM7X-WEB-GCC/main.c
+++ b/demos/ARM7-AT91SAM7X-WEB-GCC/main.c
@@ -28,7 +28,7 @@
#include "web/webthread.h"
static WORKING_AREA(waWebThread, 512);
-static WORKING_AREA(waThread1, 64);
+static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c b/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c
index d064e1ef3..521a40b04 100644
--- a/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c
+++ b/demos/ARM7-AT91SAM7X-WEB-GCC/web/webthread.c
@@ -21,7 +21,7 @@
#include <ch.h>
#include <evtimer.h>
-#include <sam7x_emac.h>
+#include <mac.h>
#include <uip.h>
#include <uip_arp.h>
@@ -47,11 +47,11 @@ static const struct uip_eth_addr macaddr = {
*/
static void network_device_send(void) {
int i;
- BufDescriptorEntry *bdep;
+ MACTransmitDescriptor *tdp;
for (i = 0; i < SEND_RETRY_MAX; i++) {
- if ((bdep = EMACGetTransmitBuffer()) != NULL) {
- uint8_t *bp = (uint8_t *)bdep->w1;
+ if ((tdp = macWaitTransmitDescriptor(&MAC1, uip_len, TIME_IMMEDIATE)) != NULL) {
+ uint8_t *bp = macGetTransmitBuffer(tdp);
if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN)
memcpy(bp, &uip_buf[0], uip_len);
@@ -61,7 +61,7 @@ static void network_device_send(void) {
uip_appdata,
uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN));
}
- EMACTransmit(bdep, uip_len);
+ macReleaseTransmitDescriptor(&MAC1, tdp);
return;
}
chThdSleep(SEND_RETRY_INTERVAL);
@@ -73,10 +73,16 @@ static void network_device_send(void) {
* uIP receive function wrapping the EMAC function.
*/
static size_t network_device_read(void) {
- size_t size = UIP_CONF_BUFFER_SIZE;
- if (EMACReceive(uip_buf, &size))
- return size;
- return 0;
+ MACReceiveDescriptor *rdp;
+ size_t size;
+ uint8_t *bp;
+
+ if ((rdp = macWaitReceiveDescriptor(&MAC1, &size, TIME_IMMEDIATE)) == NULL)
+ return 0;
+ bp = macGetReceiveBuffer(rdp);
+ memcpy(&uip_buf[0], bp, size);
+ macReleaseReceiveDescriptor(&MAC1, rdp);
+ return size;
}
void clock_init(void) {}
@@ -107,7 +113,7 @@ static void PeriodicTimerHandler(eventid_t id) {
static void ARPTimerHandler(eventid_t id) {
uip_arp_timer();
- (void)EMACGetLinkStatus();
+ (void)macPollLinkStatus(&MAC1);
}
/*
@@ -150,7 +156,7 @@ msg_t WebThread(void *p) {
/*
* Event sources setup.
*/
- chEvtRegister(&EMACFrameReceived, &el0, FRAME_RECEIVED_ID);
+ chEvtRegister(macGetReceiveEventSource(&MAC1), &el0, FRAME_RECEIVED_ID);
chEvtPend(EVENT_MASK(FRAME_RECEIVED_ID)); /* In case some frames are already buffered */
evtInit(&evt1, MS2ST(500));
@@ -164,8 +170,8 @@ msg_t WebThread(void *p) {
/*
* EMAC settings.
*/
- EMACSetAddress(&macaddr.addr[0]);
- (void)EMACGetLinkStatus();
+ macSetAddress(&MAC1, &macaddr.addr[0]);
+ (void)macPollLinkStatus(&MAC1);
/*
* uIP initialization.
diff --git a/os/io/platforms/AT91SAM7X/mac_lld.c b/os/io/platforms/AT91SAM7X/mac_lld.c
index f218af15a..69d45dfbc 100644
--- a/os/io/platforms/AT91SAM7X/mac_lld.c
+++ b/os/io/platforms/AT91SAM7X/mac_lld.c
@@ -84,7 +84,7 @@ static void serve_interrupt(void) {
chSysLockFromIsr();
chSemResetI(&MAC1.md_rdsem, 0);
#if CH_USE_EVENTS
- chEvtBroadcast(&MAC1.md_rdevent);
+ chEvtBroadcastI(&MAC1.md_rdevent);
#endif
chSysUnlockFromIsr();
}
@@ -202,9 +202,9 @@ void mac_lld_init(void) {
*/
void mac_lld_set_address(MACDriver *macp, const uint8_t *p) {
- AT91C_BASE_EMAC->EMAC_SA1L = (AT91_REG)((p[2] << 24) | (p[3] << 16) |
- (p[4] << 8) | p[5]);
- AT91C_BASE_EMAC->EMAC_SA1H = (AT91_REG)((p[0] << 8) | p[1]);
+ AT91C_BASE_EMAC->EMAC_SA1L = (AT91_REG)((p[3] << 24) | (p[2] << 16) |
+ (p[1] << 8) | p[0]);
+ AT91C_BASE_EMAC->EMAC_SA1H = (AT91_REG)((p[5] << 8) | p[4]);
}
/**