Move some things around and organize things so that the driver model
implementation will fit in more easily.
Signed-off-by: Joe Hershberger joe.hershber...@ni.com
---
include/net.h | 63 +
net/eth.c | 75 +++
2 files changed, 73 insertions(+), 65 deletions(-)
diff --git a/include/net.h b/include/net.h
index ff8b7af..7eef9cc 100644
--- a/include/net.h
+++ b/include/net.h
@@ -100,10 +100,7 @@ struct eth_device {
int eth_initialize(bd_t *bis); /* Initialize network subsystem */
int eth_register(struct eth_device *dev);/* Register network device */
int eth_unregister(struct eth_device *dev);/* Remove network device */
-void eth_try_another(int first_restart); /* Change the device */
-void eth_set_current(void);/* set nterface to ethcur var */
-/* get the current device MAC */
extern struct eth_device *eth_current;
static inline __attribute__((always_inline))
@@ -112,6 +109,7 @@ struct eth_device *eth_get_dev(void)
return eth_current;
}
+/* get the current device MAC */
static inline unsigned char *eth_get_ethaddr(void)
{
if (eth_current)
@@ -119,6 +117,37 @@ static inline unsigned char *eth_get_ethaddr(void)
return NULL;
}
+/* Set active state */
+static inline __attribute__((always_inline)) int eth_init_state_only(bd_t *bis)
+{
+ eth_get_dev()-state = ETH_STATE_ACTIVE;
+
+ return 0;
+}
+/* Set passive state */
+static inline __attribute__((always_inline)) void eth_halt_state_only(void)
+{
+ eth_get_dev()-state = ETH_STATE_PASSIVE;
+}
+
+/*
+ * Set the hardware address for an ethernet interface based on 'eth%daddr'
+ * environment variable (or just 'ethaddr' if eth_number is 0).
+ * Args:
+ * base_name - base name for device (normally eth)
+ * eth_number - value of %d (0 for first device of this type)
+ * Returns:
+ * 0 is success, non-zero is error status from driver.
+ */
+int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
+int eth_number);
+
+int usb_eth_initialize(bd_t *bi);
+#endif
+
+void eth_try_another(int first_restart); /* Change the device */
+void eth_set_current(void);/* set nterface to ethcur var */
+
struct eth_device *eth_get_dev_by_name(const char *devname);
struct eth_device *eth_get_dev_by_index(int index); /* get dev @ index */
int eth_get_dev_index(void); /* get the device index */
@@ -138,7 +167,6 @@ int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
int eth_getenv_enetaddr_by_index(const char *base_name, int index,
uchar *enetaddr);
-int usb_eth_initialize(bd_t *bi);
int eth_init(bd_t *bis); /* Initialize the device */
int eth_send(void *packet, int length); /* Send a packet */
@@ -148,32 +176,7 @@ void (*push_packet)(void *packet, int length);
#endif
int eth_rx(void); /* Check for received packets */
void eth_halt(void); /* stop SCC */
-char *eth_get_name(void); /* get name of current device */
-
-/* Set active state */
-static inline __attribute__((always_inline)) int eth_init_state_only(bd_t *bis)
-{
- eth_get_dev()-state = ETH_STATE_ACTIVE;
-
- return 0;
-}
-/* Set passive state */
-static inline __attribute__((always_inline)) void eth_halt_state_only(void)
-{
- eth_get_dev()-state = ETH_STATE_PASSIVE;
-}
-
-/*
- * Set the hardware address for an ethernet interface based on 'eth%daddr'
- * environment variable (or just 'ethaddr' if eth_number is 0).
- * Args:
- * base_name - base name for device (normally eth)
- * eth_number - value of %d (0 for first device of this type)
- * Returns:
- * 0 is success, non-zero is error status from driver.
- */
-int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
-int eth_number);
+const char *eth_get_name(void);/* get name of current device */
#ifdef CONFIG_MCAST_TFTP
int eth_mcast_join(IPaddr_t mcast_addr, u8 join);
diff --git a/net/eth.c b/net/eth.c
index 65e8c77..c02548c 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -55,6 +55,14 @@ static inline int eth_setenv_enetaddr_by_index(const char
*base_name, int index,
return eth_setenv_enetaddr(enetvar, enetaddr);
}
+static void eth_env_init(void)
+{
+ const char *s;
+
+ s = getenv(bootfile);
+ if (s != NULL)
+ copy_filename(BootFile, s, sizeof(BootFile));
+}
static int eth_mac_skip(int index)
{
@@ -87,6 +95,11 @@ static unsigned int eth_rcv_current, eth_rcv_last;
static struct eth_device *eth_devices;
struct eth_device *eth_current;
+static void eth_set_current_to_next(void)
+{
+ eth_current = eth_current-next;
+}
+
struct eth_device *eth_get_dev_by_name(const char *devname)
{
struct eth_device *dev, *target_dev;
@@ -137,22 +150,6 @@ int