1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2007 Semihalf
10 #include <linux/types.h>
11 #include <api_public.h>
17 #define debugf(fmt, args...) do { printf("%s(): ", __func__); printf(fmt, ##args); } while (0)
19 #define debugf(fmt, args...)
22 #define errf(fmt, args...) do { printf("ERROR @ %s(): ", __func__); printf(fmt, ##args); } while (0)
24 #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
26 static int dev_valid_net(void *cookie)
28 return ((void *)eth_get_dev() == cookie) ? 1 : 0;
31 int dev_open_net(void *cookie)
33 if (!dev_valid_net(cookie))
42 int dev_close_net(void *cookie)
44 if (!dev_valid_net(cookie))
52 * There can only be one active eth interface at a time - use what is
53 * currently set to eth_current
55 int dev_enum_net(struct device_info *di)
57 struct eth_device *eth_current = eth_get_dev();
59 di->type = DEV_TYP_NET;
60 di->cookie = (void *)eth_current;
61 if (di->cookie == NULL)
64 memcpy(di->di_net.hwaddr, eth_current->enetaddr, 6);
66 debugf("device found, returning cookie 0x%08x\n",
67 (u_int32_t)di->cookie);
72 int dev_write_net(void *cookie, void *buf, int len)
74 /* XXX verify that cookie points to a valid net device??? */
76 return eth_send(buf, len);
79 int dev_read_net(void *cookie, void *buf, int len)
81 /* XXX verify that cookie points to a valid net device??? */
83 return eth_receive(buf, len);
88 int dev_open_net(void *cookie)
93 int dev_close_net(void *cookie)
98 int dev_enum_net(struct device_info *di)
103 int dev_write_net(void *cookie, void *buf, int len)
108 int dev_read_net(void *cookie, void *buf, int len)