1 /*
2  * Copyright (c) 2006-2022, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2017-08-24     chinesebear  first version
9  */
10 
11 
12 #ifndef SYNOP_GMAC_NETWORK_INTERFACE_H
13 #define SYNOP_GMAC_NETWORK_INTERFACE_H 1
14 
15 
16 #include <lwip/sys.h>
17 #include <netif/ethernetif.h>
18 #include "synopGMAC_plat.h"
19 #include "synopGMAC_Host.h"
20 #include "synopGMAC_Dev.h"
21 
22 //#include <common.h>
23 //#include <net.h>
24 //#include <linux/stddef.h>
25 
26 
27 #define NET_IF_TIMEOUT (10*HZ)
28 #define CHECK_TIME (HZ)
29 
30 s32  synopGMAC_init_network_interface(char* xname,u64 synopGMACMappedAddr);
31 void  synopGMAC_exit_network_interface(void);
32 
33 s32 synopGMAC_linux_open(struct eth_device *);
34 s32 synopGMAC_linux_close(struct eth_device *);
35 //s32 synopGMAC_linux_xmit_frames(struct ifnet *);
36 struct net_device_stats * synopGMAC_linux_get_stats(struct synopGMACNetworkAdapter *);
37 //void synopGMAC_linux_set_multicast_list(struct net_device *);
38 //s32 synopGMAC_linux_set_mac_address(struct synopGMACNetwokrAdapter*,void *);
39 //s32 synopGMAC_linux_change_mtu(struct net_device *,s32);
40 //s32 synopGMAC_linux_do_ioctl(struct ifnet *,struct ifreq *,s32);
41 //void synopGMAC_linux_tx_timeout(struct net_device *);
42 
43 s32 synopGMAC_test(synopGMACdevice * gmacdev_0,synopGMACdevice * gmacdev_1);
44 
45 void dumpreg(u64 );
46 void dumpphyreg();
47 
48 /*
49  *  gethex(vp,p,n)
50  *      convert n hex digits from p to binary, result in vp,
51  *      rtn 1 on success
52  */
gethex(u8 * vp,char * p,int n)53 static int gethex(u8 *vp, char *p, int n)
54 {
55         u8 v;
56         int digit;
57 
58         for (v = 0; n > 0; n--) {
59                 if (*p == 0)
60                         return (0);
61                 if (*p >= '0' && *p <= '9')
62                         digit = *p - '0';
63                 else if (*p >= 'a' && *p <= 'f')
64                         digit = *p - 'a' + 10;
65                 else if (*p >= 'A' && *p <= 'F')
66                         digit = *p - 'A' + 10;
67                 else
68                         return (0);
69 
70                 v <<= 4;
71                 v |= digit;
72                 p++;
73         }
74         *vp = v;
75         return (1);
76 }
77 
78 #endif /* End of file */
79