]>
git.ipfire.org Git - people/ms/u-boot.git/blob - api/api_net.c
2 * (C) Copyright 2007 Semihalf
4 * Written by: Rafal Jaworowski <raj@semihalf.com>
6 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/types.h>
13 #include <api_public.h>
15 DECLARE_GLOBAL_DATA_PTR
;
21 #define debugf(fmt, args...) do { printf("%s(): ", __func__); printf(fmt, ##args); } while (0)
23 #define debugf(fmt, args...)
26 #define errf(fmt, args...) do { printf("ERROR @ %s(): ", __func__); printf(fmt, ##args); } while (0)
30 static int dev_valid_net(void *cookie
)
32 return ((void *)eth_get_dev() == cookie
) ? 1 : 0;
35 int dev_open_net(void *cookie
)
37 if (!dev_valid_net(cookie
))
46 int dev_close_net(void *cookie
)
48 if (!dev_valid_net(cookie
))
56 * There can only be one active eth interface at a time - use what is
57 * currently set to eth_current
59 int dev_enum_net(struct device_info
*di
)
61 struct eth_device
*eth_current
= eth_get_dev();
63 di
->type
= DEV_TYP_NET
;
64 di
->cookie
= (void *)eth_current
;
65 if (di
->cookie
== NULL
)
68 memcpy(di
->di_net
.hwaddr
, eth_current
->enetaddr
, 6);
70 debugf("device found, returning cookie 0x%08x\n",
71 (u_int32_t
)di
->cookie
);
76 int dev_write_net(void *cookie
, void *buf
, int len
)
78 /* XXX verify that cookie points to a valid net device??? */
80 return eth_send(buf
, len
);
83 int dev_read_net(void *cookie
, void *buf
, int len
)
85 /* XXX verify that cookie points to a valid net device??? */
87 return eth_receive(buf
, len
);
92 int dev_open_net(void *cookie
)
97 int dev_close_net(void *cookie
)
102 int dev_enum_net(struct device_info
*di
)
107 int dev_write_net(void *cookie
, void *buf
, int len
)
112 int dev_read_net(void *cookie
, void *buf
, int len
)