]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - net/net.c
Merge branch 'master' of git://git.denx.de/u-boot-usb
[karo-tx-uboot.git] / net / net.c
index d0fe1c4960a2fb024dc5cb704712fb0e61ab785e..e9536b36ef43929229ad739dddc90261392f8023 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -77,6 +77,7 @@
 #include <common.h>
 #include <watchdog.h>
 #include <command.h>
+#include <linux/compiler.h>
 #include <net.h>
 #include "bootp.h"
 #include "tftp.h"
@@ -152,7 +153,7 @@ IPaddr_t    NetOurIP;
 /* Server IP addr (0 = unknown) */
 IPaddr_t       NetServerIP;
 /* Current receive packet */
-volatile uchar *NetRxPacket;
+uchar *NetRxPacket;
 /* Current rx packet length */
 int            NetRxPacketLen;
 /* IP packet ID */
@@ -161,7 +162,7 @@ unsigned    NetIPID;
 uchar          NetBcastAddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 uchar          NetEtherNullAddr[6];
 #ifdef CONFIG_API
-void           (*push_packet)(volatile void *, int len) = 0;
+void           (*push_packet)(void *, int len) = 0;
 #endif
 #if defined(CONFIG_CMD_CDP)
 /* Ethernet bcast address */
@@ -203,15 +204,10 @@ IPaddr_t  NetNtpServerIP;
 int            NetTimeOffset;
 #endif
 
-#ifdef CONFIG_NETCONSOLE
-void NcStart(void);
-int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len);
-#endif
-
-volatile uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
+uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
 
 /* Receive packet */
-volatile uchar *NetRxPackets[PKTBUFSRX];
+uchar *NetRxPackets[PKTBUFSRX];
 
 /* Current RX packet handler */
 static rxhand_f *packetHandler;
@@ -225,7 +221,7 @@ static ulong        timeStart;
 /* Current timeout value */
 static ulong   timeDelta;
 /* THE transmit packet */
-volatile uchar *NetTxPacket;
+uchar *NetTxPacket;
 
 static int net_check_prereq(enum proto_t protocol);
 
@@ -246,7 +242,7 @@ int         NetArpWaitTry;
 
 void ArpRequest(void)
 {
-       volatile uchar *pkt;
+       uchar *pkt;
        ARP_t *arp;
 
        debug("ARP broadcast %d\n", NetArpWaitTry);
@@ -342,13 +338,11 @@ void net_auto_load(void)
 static void NetInitLoop(enum proto_t protocol)
 {
        static int env_changed_id;
-       bd_t *bd = gd->bd;
        int env_id = get_env_id();
 
        /* update only when the environment has changed */
        if (env_changed_id != env_id) {
                NetOurIP = getenv_IPaddr("ipaddr");
-               NetCopyIP(&bd->bi_ip_addr, &NetOurIP);
                NetOurGatewayIP = getenv_IPaddr("gatewayip");
                NetOurSubnetMask = getenv_IPaddr("netmask");
                NetServerIP = getenv_IPaddr("serverip");
@@ -402,6 +396,7 @@ int NetLoop(enum proto_t protocol)
                NetArpWaitTxPacketSize = 0;
        }
 
+       bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start");
        eth_halt();
        eth_set_current();
        if (eth_init(bd) < 0) {
@@ -526,10 +521,7 @@ restart:
        for (;;) {
                WATCHDOG_RESET();
 #ifdef CONFIG_SHOW_ACTIVITY
-               {
-                       extern void show_activity(int arg);
-                       show_activity(1);
-               }
+               show_activity(1);
 #endif
                /*
                 *      Check the ethernet for a new packet.  The ethernet
@@ -704,7 +696,7 @@ NetSetTimeout(ulong iv, thand_f *f)
 
 
 void
-NetSendPacket(volatile uchar *pkt, int len)
+NetSendPacket(uchar *pkt, int len)
 {
        (void) eth_send(pkt, len);
 }
@@ -728,7 +720,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
         */
        if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
 
-               debug("sending ARP for %08lx\n", dest);
+               debug("sending ARP for %08x\n", dest);
 
                NetArpWaitPacketIP = dest;
                NetArpWaitPacketMAC = ether;
@@ -751,7 +743,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
                return 1;       /* waiting */
        }
 
-       debug("sending UDP to %08lx/%pM\n", dest, ether);
+       debug("sending UDP to %08x/%pM\n", dest, ether);
 
        pkt = (uchar *)NetTxPacket;
        pkt += NetSetEther(pkt, ether, PROT_IP);
@@ -767,15 +759,15 @@ static ushort PingSeqNo;
 int PingSend(void)
 {
        static uchar mac[6];
-       volatile IP_t *ip;
-       volatile ushort *s;
+       IP_t *ip;
+       ushort *s;
        uchar *pkt;
 
        /* XXX always send arp request */
 
        memcpy(mac, NetEtherNullAddr, 6);
 
-       debug("sending ARP for %08lx\n", NetPingIP);
+       debug("sending ARP for %08x\n", NetPingIP);
 
        NetArpWaitPacketIP = NetPingIP;
        NetArpWaitPacketMAC = mac;
@@ -783,7 +775,7 @@ int PingSend(void)
        pkt = NetArpWaitTxPacket;
        pkt += NetSetEther(pkt, mac, PROT_IP);
 
-       ip = (volatile IP_t *)pkt;
+       ip = (IP_t *)pkt;
 
        /*
         * Construct an IP and ICMP header.
@@ -935,9 +927,9 @@ static ushort CDP_compute_csum(const uchar *buff, ushort len)
 
 int CDPSendTrigger(void)
 {
-       volatile uchar *pkt;
-       volatile ushort *s;
-       volatile ushort *cp;
+       uchar *pkt;
+       ushort *s;
+       ushort *cp;
        Ethernet_t *et;
        int len;
        ushort chksum;
@@ -964,7 +956,7 @@ int CDPSendTrigger(void)
        /* CDP header */
        *pkt++ = 0x02;                          /* CDP version 2 */
        *pkt++ = 180;                           /* TTL */
-       s = (volatile ushort *)pkt;
+       s = (ushort *)pkt;
        cp = s;
        /* checksum (0 for later calculation) */
        *s++ = htons(0);
@@ -1102,8 +1094,8 @@ CDPHandler(const uchar *pkt, unsigned len)
         * output a warning
         */
        if (pkt[0] != 0x02)
-               printf("** WARNING: CDP packet received with a protocol version %d > 2\n",
-                               pkt[0] & 0xff);
+               printf("**WARNING: CDP packet received with a protocol version "
+                               "%d > 2\n", pkt[0] & 0xff);
 
        if (CDP_compute_csum(pkt, len) != 0)
                return;
@@ -1238,7 +1230,7 @@ struct hole {
 
 static IP_t *__NetDefragment(IP_t *ip, int *lenp)
 {
-       static uchar pkt_buff[IP_PKTSIZE] __attribute__((aligned(PKTALIGN)));
+       static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN);
        static u16 first_hole, total_len;
        struct hole *payload, *thisfrag, *h, *newh;
        IP_t *localip = (IP_t *)pkt_buff;
@@ -1438,7 +1430,7 @@ static void receive_icmp(IP_t *ip, int len, IPaddr_t src_ip, Ethernet_t *et)
 }
 
 void
-NetReceive(volatile uchar *inpkt, int len)
+NetReceive(uchar *inpkt, int len)
 {
        Ethernet_t *et;
        IP_t    *ip;
@@ -1610,6 +1602,7 @@ NetReceive(volatile uchar *inpkt, int len)
                        /* matched waiting packet's address */
                        if (tmp == NetArpWaitReplyIP) {
                                debug("Got it\n");
+
                                /* save address for later use */
                                memcpy(NetArpWaitPacketMAC,
                                       &arp->ar_data[0], 6);
@@ -1618,7 +1611,8 @@ NetReceive(volatile uchar *inpkt, int len)
                                (*packetHandler)(0, 0, 0, 0, 0);
 #endif
                                /* modify header, and transmit it */
-                               memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6);
+                               memcpy(((Ethernet_t *)NetArpWaitTxPacket)->
+                                       et_dest, NetArpWaitPacketMAC, 6);
                                (void) eth_send(NetArpWaitTxPacket,
                                                NetArpWaitTxPacketSize);
 
@@ -1855,7 +1849,6 @@ common:
        case CDP:
        case DHCP:
                if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
-                       extern int eth_get_dev_index(void);
                        int num = eth_get_dev_index();
 
                        switch (num) {
@@ -1917,7 +1910,7 @@ NetEthHdrSize(void)
 }
 
 int
-NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
+NetSetEther(uchar *xet, uchar * addr, uint prot)
 {
        Ethernet_t *et = (Ethernet_t *)xet;
        ushort myvlanid;
@@ -1942,7 +1935,7 @@ NetSetEther(volatile uchar *xet, uchar * addr, uint prot)
 }
 
 void
-NetSetIP(volatile uchar *xip, IPaddr_t dest, int dport, int sport, int len)
+NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
 {
        IP_t *ip = (IP_t *)xip;