1 /*
2  * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #include "Driver_WiFi.h"
20 
21 #define ARM_WIFI_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0)        // Driver version
22 
23 // Driver Version
24 static const ARM_DRIVER_VERSION driver_version = {
25   ARM_WIFI_API_VERSION,
26   ARM_WIFI_DRV_VERSION
27 };
28 
29 // Driver Capabilities
30 static const ARM_WIFI_CAPABILITIES driver_capabilities = {
31   0U,                                   // Station supported
32   0U,                                   // Access Point supported
33   0U,                                   // Concurrent Station and Access Point not supported
34   0U,                                   // WiFi Protected Setup (WPS) for Station supported
35   0U,                                   // WiFi Protected Setup (WPS) for Access Point not supported
36   0U,                                   // Access Point: event generated on Station connect
37   0U,                                   // Access Point: event not generated on Station disconnect
38   0U,                                   // Event not generated on Ethernet frame reception in bypass mode
39   0U,                                   // Bypass or pass-through mode (Ethernet interface) not supported
40   0U,                                   // IP (UDP/TCP) (Socket interface) supported
41   0U,                                   // IPv6 (Socket interface) not supported
42   0U,                                   // Ping (ICMP) supported
43   0U                                    // Reserved (must be zero)
44 };
ARM_WiFi_GetVersion(void)45 static ARM_DRIVER_VERSION ARM_WiFi_GetVersion (void) {
46   return driver_version;
47 }
48 
ARM_WiFi_GetCapabilities(void)49 static ARM_WIFI_CAPABILITIES ARM_WiFi_GetCapabilities (void) {
50   return driver_capabilities;
51 }
52 
ARM_WiFi_Initialize(ARM_WIFI_SignalEvent_t cb_event)53 static int32_t ARM_WiFi_Initialize (ARM_WIFI_SignalEvent_t cb_event) {
54   return ARM_DRIVER_ERROR_UNSUPPORTED;
55 }
56 
ARM_WiFi_Uninitialize(void)57 static int32_t ARM_WiFi_Uninitialize (void) {
58   return ARM_DRIVER_ERROR_UNSUPPORTED;
59 }
60 
ARM_WiFi_PowerControl(ARM_POWER_STATE state)61 static int32_t ARM_WiFi_PowerControl (ARM_POWER_STATE state) {
62   return ARM_DRIVER_ERROR_UNSUPPORTED;
63 }
64 
ARM_WiFi_GetModuleInfo(char * module_info,uint32_t max_len)65 static int32_t ARM_WiFi_GetModuleInfo (char *module_info, uint32_t max_len) {
66   return ARM_DRIVER_ERROR_UNSUPPORTED;
67 }
68 
ARM_WiFi_SetOption(uint32_t interface,uint32_t option,const void * data,uint32_t len)69 static int32_t ARM_WiFi_SetOption (uint32_t interface, uint32_t option, const void *data, uint32_t len) {
70   return ARM_DRIVER_ERROR_UNSUPPORTED;
71 }
72 
ARM_WiFi_GetOption(uint32_t interface,uint32_t option,void * data,uint32_t * len)73 static int32_t ARM_WiFi_GetOption (uint32_t interface, uint32_t option, void *data, uint32_t *len) {
74   return ARM_DRIVER_ERROR_UNSUPPORTED;
75 }
ARM_WiFi_Scan(ARM_WIFI_SCAN_INFO_t scan_info[],uint32_t max_num)76 static int32_t ARM_WiFi_Scan (ARM_WIFI_SCAN_INFO_t scan_info[], uint32_t max_num) {
77   return ARM_DRIVER_ERROR_UNSUPPORTED;
78 }
79 
ARM_WiFi_Activate(uint32_t interface,const ARM_WIFI_CONFIG_t * config)80 static int32_t ARM_WiFi_Activate (uint32_t interface, const ARM_WIFI_CONFIG_t *config) {
81   return ARM_DRIVER_ERROR_UNSUPPORTED;
82 }
83 
ARM_WiFi_Deactivate(uint32_t interface)84 static int32_t ARM_WiFi_Deactivate (uint32_t interface) {
85   return ARM_DRIVER_ERROR_UNSUPPORTED;
86 }
87 
ARM_WiFi_IsConnected(void)88 static uint32_t ARM_WiFi_IsConnected (void) {
89   return 0U;
90 }
91 
ARM_WiFi_GetNetInfo(ARM_WIFI_NET_INFO_t * net_info)92 static int32_t ARM_WiFi_GetNetInfo (ARM_WIFI_NET_INFO_t *net_info) {
93   return ARM_DRIVER_ERROR_UNSUPPORTED;
94 }
95 
ARM_WiFi_BypassControl(uint32_t interface,uint32_t mode)96 static int32_t ARM_WiFi_BypassControl (uint32_t interface, uint32_t mode) {
97   return ARM_DRIVER_ERROR_UNSUPPORTED;
98 }
99 
ARM_WiFi_EthSendFrame(uint32_t interface,const uint8_t * frame,uint32_t len)100 static int32_t ARM_WiFi_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len){
101   return ARM_DRIVER_ERROR_UNSUPPORTED;
102 }
103 
ARM_WiFi_EthReadFrame(uint32_t interface,uint8_t * frame,uint32_t len)104 static int32_t ARM_WiFi_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len){
105   return ARM_DRIVER_ERROR_UNSUPPORTED;
106 }
107 
ARM_WiFi_EthGetRxFrameSize(uint32_t interface)108 static uint32_t ARM_WiFi_EthGetRxFrameSize (uint32_t interface){
109   return 0U;
110 }
111 
ARM_WiFi_SocketCreate(int32_t af,int32_t type,int32_t protocol)112 static int32_t ARM_WiFi_SocketCreate (int32_t af, int32_t type, int32_t protocol) {
113   return ARM_DRIVER_ERROR_UNSUPPORTED;
114 }
115 
ARM_WiFi_SocketBind(int32_t socket,const uint8_t * ip,uint32_t ip_len,uint16_t port)116 static int32_t ARM_WiFi_SocketBind (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
117   return ARM_DRIVER_ERROR_UNSUPPORTED;
118 }
119 
ARM_WiFi_SocketListen(int32_t socket,int32_t backlog)120 static int32_t ARM_WiFi_SocketListen (int32_t socket, int32_t backlog) {
121   return ARM_DRIVER_ERROR_UNSUPPORTED;
122 }
123 
ARM_WiFi_SocketAccept(int32_t socket,uint8_t * ip,uint32_t * ip_len,uint16_t * port)124 static int32_t ARM_WiFi_SocketAccept (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
125   return ARM_DRIVER_ERROR_UNSUPPORTED;
126 }
127 
ARM_WiFi_SocketConnect(int32_t socket,const uint8_t * ip,uint32_t ip_len,uint16_t port)128 static int32_t ARM_WiFi_SocketConnect (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
129   return ARM_DRIVER_ERROR_UNSUPPORTED;
130 }
131 
ARM_WiFi_SocketRecv(int32_t socket,void * buf,uint32_t len)132 static int32_t ARM_WiFi_SocketRecv (int32_t socket, void *buf, uint32_t len) {
133   return ARM_DRIVER_ERROR_UNSUPPORTED;
134 }
135 
ARM_WiFi_SocketRecvFrom(int32_t socket,void * buf,uint32_t len,uint8_t * ip,uint32_t * ip_len,uint16_t * port)136 static int32_t ARM_WiFi_SocketRecvFrom (int32_t socket, void *buf, uint32_t len, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
137   return ARM_DRIVER_ERROR_UNSUPPORTED;
138 }
139 
ARM_WiFi_SocketSend(int32_t socket,const void * buf,uint32_t len)140 static int32_t ARM_WiFi_SocketSend (int32_t socket, const void *buf, uint32_t len) {
141   return ARM_DRIVER_ERROR_UNSUPPORTED;
142 }
143 
ARM_WiFi_SocketSendTo(int32_t socket,const void * buf,uint32_t len,const uint8_t * ip,uint32_t ip_len,uint16_t port)144 static int32_t ARM_WiFi_SocketSendTo (int32_t socket, const void *buf, uint32_t len, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
145   return ARM_DRIVER_ERROR_UNSUPPORTED;
146 }
147 
ARM_WiFi_SocketGetSockName(int32_t socket,uint8_t * ip,uint32_t * ip_len,uint16_t * port)148 static int32_t ARM_WiFi_SocketGetSockName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
149   return ARM_DRIVER_ERROR_UNSUPPORTED;
150 }
151 
ARM_WiFi_SocketGetPeerName(int32_t socket,uint8_t * ip,uint32_t * ip_len,uint16_t * port)152 static int32_t ARM_WiFi_SocketGetPeerName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
153   return ARM_DRIVER_ERROR_UNSUPPORTED;
154 }
155 
ARM_WiFi_SocketGetOpt(int32_t socket,int32_t opt_id,void * opt_val,uint32_t * opt_len)156 static int32_t ARM_WiFi_SocketGetOpt (int32_t socket, int32_t opt_id, void *opt_val, uint32_t *opt_len) {
157   return ARM_DRIVER_ERROR_UNSUPPORTED;
158 }
159 
ARM_WiFi_SocketSetOpt(int32_t socket,int32_t opt_id,const void * opt_val,uint32_t opt_len)160 static int32_t ARM_WiFi_SocketSetOpt (int32_t socket, int32_t opt_id, const void *opt_val, uint32_t opt_len) {
161   return ARM_DRIVER_ERROR_UNSUPPORTED;
162 }
163 
ARM_WiFi_SocketClose(int32_t socket)164 static int32_t ARM_WiFi_SocketClose (int32_t socket) {
165   return ARM_DRIVER_ERROR_UNSUPPORTED;
166 }
167 
ARM_WiFi_SocketGetHostByName(const char * name,int32_t af,uint8_t * ip,uint32_t * ip_len)168 static int32_t ARM_WiFi_SocketGetHostByName (const char *name, int32_t af, uint8_t *ip, uint32_t *ip_len) {
169   return ARM_DRIVER_ERROR_UNSUPPORTED;
170 }
171 
ARM_WiFi_Ping(const uint8_t * ip,uint32_t ip_len)172 static int32_t ARM_WiFi_Ping (const uint8_t *ip, uint32_t ip_len) {
173   return ARM_DRIVER_ERROR_UNSUPPORTED;
174 }
175 
176 /* WiFi Driver Control Block */
177 extern \
178 ARM_DRIVER_WIFI Driver_WiFi0;
179 ARM_DRIVER_WIFI Driver_WiFi0 = {
180   ARM_WiFi_GetVersion,
181   ARM_WiFi_GetCapabilities,
182   ARM_WiFi_Initialize,
183   ARM_WiFi_Uninitialize,
184   ARM_WiFi_PowerControl,
185   ARM_WiFi_GetModuleInfo,
186   ARM_WiFi_SetOption,
187   ARM_WiFi_GetOption,
188   ARM_WiFi_Scan,
189   ARM_WiFi_Activate,
190   ARM_WiFi_Deactivate,
191   ARM_WiFi_IsConnected,
192   ARM_WiFi_GetNetInfo,
193   ARM_WiFi_BypassControl,
194   ARM_WiFi_EthSendFrame,
195   ARM_WiFi_EthReadFrame,
196   ARM_WiFi_EthGetRxFrameSize,
197   ARM_WiFi_SocketCreate,
198   ARM_WiFi_SocketBind,
199   ARM_WiFi_SocketListen,
200   ARM_WiFi_SocketAccept,
201   ARM_WiFi_SocketConnect,
202   ARM_WiFi_SocketRecv,
203   ARM_WiFi_SocketRecvFrom,
204   ARM_WiFi_SocketSend,
205   ARM_WiFi_SocketSendTo,
206   ARM_WiFi_SocketGetSockName,
207   ARM_WiFi_SocketGetPeerName,
208   ARM_WiFi_SocketGetOpt,
209   ARM_WiFi_SocketSetOpt,
210   ARM_WiFi_SocketClose,
211   ARM_WiFi_SocketGetHostByName,
212   ARM_WiFi_Ping
213 };
214