1 /*
2  * Copyright (c) 2006-2018, 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 #ifndef SYNOP_GMAC_NETWORK_INTERFACE_H
12 #define SYNOP_GMAC_NETWORK_INTERFACE_H 1
13 
14 #include <lwip/sys.h>
15 #include <netif/ethernetif.h>
16 #include "synopGMAC_plat.h"
17 #include "synopGMAC_Host.h"
18 #include "synopGMAC_Dev.h"
19 
20 #define NET_IF_TIMEOUT (10*HZ)
21 #define CHECK_TIME (HZ)
22 
23 s32  synopGMAC_init_network_interface(char* xname,u64 synopGMACMappedAddr);
24 void  synopGMAC_exit_network_interface(void);
25 
26 s32 synopGMAC_linux_open(struct eth_device *);
27 s32 synopGMAC_linux_close(struct eth_device *);
28 struct net_device_stats * synopGMAC_linux_get_stats(struct synopGMACNetworkAdapter *);
29 
30 s32 synopGMAC_test(synopGMACdevice * gmacdev_0,synopGMACdevice * gmacdev_1);
31 
32 void dumpreg(u64 );
33 void dumpphyreg();
34 
35 /*
36  *  gethex(vp,p,n)
37  *      convert n hex digits from p to binary, result in vp,
38  *      rtn 1 on success
39  */
gethex(u8 * vp,char * p,int n)40 static int gethex(u8 *vp, char *p, int n)
41 {
42         u8 v;
43         int digit;
44 
45         for (v = 0; n > 0; n--) {
46                 if (*p == 0)
47                         return (0);
48                 if (*p >= '0' && *p <= '9')
49                         digit = *p - '0';
50                 else if (*p >= 'a' && *p <= 'f')
51                         digit = *p - 'a' + 10;
52                 else if (*p >= 'A' && *p <= 'F')
53                         digit = *p - 'A' + 10;
54                 else
55                         return (0);
56 
57                 v <<= 4;
58                 v |= digit;
59                 p++;
60         }
61         *vp = v;
62         return (1);
63 }
64 
65 #endif /* End of file */
66