blob: 8cc55c34c22f97ceba055851d55634fdb9763ed3 [file] [log] [blame]
Vadim Iosevichd50ea462017-03-30 16:19:08 +03001/*
2 * Copyright (c) 2017, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef _DEFINITIONS_H_
31#define _DEFINITIONS_H_
32
Vadim Ioseviche76832c2017-11-05 09:09:14 +020033#include <map>
Vadim Iosevichd50ea462017-03-30 16:19:08 +030034#include <string>
35#include <cstdint>
Vadim Iosevich20d50d82017-09-19 11:38:15 +030036#include <tuple>
Vadim Iosevichd50ea462017-03-30 16:19:08 +030037#include "Utils.h"
38
Vadim Ioseviche76832c2017-11-05 09:09:14 +020039// FW Defines
40#define MAX_RF_NUMBER 8
41
42
43#define FW_ASSERT_REG 0x91F020
44#define UCODE_ASSERT_REG 0x91F028
45#define FW_ASSOCIATION_REG 0x880A44
46#define FW_ASSOCIATED_VALUE 0x6
47#define MCS_REG 0x880A60
48#define DEVICE_TYPE_REG 0x880A8C
49#define FW_MODE_REG 0x880A34
50#define BOOT_LOADER_VERSION_REG 0x880A0C
51#define CHANNEL_REG 0x883020
52#define BOARDFILE_REG 0x880014
53
54#define UCODE_RX_ON_REG 0x9405BE
55#define BF_SEQ_REG 0x941374
56#define BF_TRIG_REG 0x941380
57#define NAV_REG 0x940490
58#define TX_GP_REG 0x880A58
59#define RX_GP_REG 0x880A5C
60
61#define RF_CONNECTED_REG 0x889488
62#define RF_ENABLED_REG 0x889488
63
64#define BASEBAND_TEMPERATURE_REG 0x91c808
65#define RF_TEMPERATURE_REG 0x91c80c
Vadim Iosevichd50ea462017-03-30 16:19:08 +030066
67// *************************************************************************************************
68/*
Vadim Iosevich40679a12017-06-06 14:24:07 +030069 * The reply data may be generated in several ways, the data is expected to be obtained according to this type
70 */
Vadim Iosevichd50ea462017-03-30 16:19:08 +030071enum REPLY_TYPE
72{
73 REPLY_TYPE_NONE,
74 REPLY_TYPE_BUFFER,
Vadim Iosevich40679a12017-06-06 14:24:07 +030075 REPLY_TYPE_FILE,
76 REPLY_TYPE_WAIT_BINARY,
77 REPLY_TYPE_BINARY
Vadim Iosevichd50ea462017-03-30 16:19:08 +030078};
79
80// *************************************************************************************************
81/*
Vadim Iosevich40679a12017-06-06 14:24:07 +030082 * A response to the client, through the servers
83 */
Vadim Iosevich20d50d82017-09-19 11:38:15 +030084struct ResponseMessage
Vadim Iosevichd50ea462017-03-30 16:19:08 +030085{
Vadim Iosevich20d50d82017-09-19 11:38:15 +030086 ResponseMessage() :
87 type(REPLY_TYPE_NONE),
88 length(0U),
89 binaryMessage(nullptr),
90 inputBufSize(0U)
91 {}
92
Vadim Iosevichd50ea462017-03-30 16:19:08 +030093 std::string message;
94 REPLY_TYPE type;
Vadim Iosevich20d50d82017-09-19 11:38:15 +030095 size_t length;
Vadim Iosevich40679a12017-06-06 14:24:07 +030096 uint8_t* binaryMessage;
97 vector<string> internalParsedMessage;
Vadim Iosevich20d50d82017-09-19 11:38:15 +030098 unsigned inputBufSize;
99};
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300100
Vadim Ioseviche76832c2017-11-05 09:09:14 +0200101// *************************************************************************************************
102/* A response to the user in CLI mode
103*/
104struct Status
105{
106 Status() :
107 m_success(true),
108 m_message("") {}
109
110 Status(bool success, std::string message) :
111 m_success(success),
112 m_message(message) {}
113
114 bool m_success;
115 std::string m_message;
116};
Vadim Iosevich40679a12017-06-06 14:24:07 +0300117
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300118// *************************************************************************************************
119/*
Vadim Iosevich40679a12017-06-06 14:24:07 +0300120 * ConnectionStatus indicates whether to close a connection with a client or not.
121 */
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300122enum ConnectionStatus
123{
124 CLOSE_CONNECTION,
125 KEEP_CONNECTION_ALIVE
126};
127
128// **************************** Events Structures and Enum Types **************************************
129/*
Vadim Iosevich20d50d82017-09-19 11:38:15 +0300130 * Define an event struct which would be sent as Json string.
Vadim Iosevich40679a12017-06-06 14:24:07 +0300131 * NOTE that the __exactly__ same struct is defined in the side that gets this struct.
Vadim Iosevich40679a12017-06-06 14:24:07 +0300132 */
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300133
Vadim Iosevich20d50d82017-09-19 11:38:15 +0300134struct FwVersion
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300135{
Vadim Iosevich20d50d82017-09-19 11:38:15 +0300136 DWORD m_major;
137 DWORD m_minor;
138 DWORD m_subMinor;
139 DWORD m_build;
140
141 FwVersion() :
142 m_major(0), m_minor(0), m_subMinor(0), m_build(0)
143 {}
144
145 bool operator==(const FwVersion& rhs) const
146 {
147 return std::tie(m_major, m_minor, m_subMinor, m_build) == std::tie(rhs.m_major, rhs.m_minor, rhs.m_subMinor, rhs.m_build);
148 }
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300149};
150
Vadim Iosevich20d50d82017-09-19 11:38:15 +0300151struct FwTimestamp
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300152{
Vadim Iosevich20d50d82017-09-19 11:38:15 +0300153 FwTimestamp() :
154 m_hour(0), m_min(0), m_sec(0), m_day(0), m_month(0), m_year(0)
155 {}
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300156
Vadim Iosevich20d50d82017-09-19 11:38:15 +0300157 DWORD m_hour;
158 DWORD m_min;
159 DWORD m_sec;
160 DWORD m_day;
161 DWORD m_month;
162 DWORD m_year;
163
164 bool operator==(const FwTimestamp& rhs) const
165 {
166 return std::tie(m_hour, m_min, m_sec, m_day, m_month, m_year) == std::tie(rhs.m_hour, rhs.m_min, rhs.m_sec, rhs.m_day, rhs.m_month, rhs.m_year);
167 }
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300168};
169
Vadim Ioseviche76832c2017-11-05 09:09:14 +0200170//enum DRIVER_MODE
171//{
172// IOCTL_WBE_MODE,
173// IOCTL_WIFI_STA_MODE,
174// IOCTL_WIFI_SOFTAP_MODE,
175// IOCTL_CONCURRENT_MODE, // This mode is for a full concurrent implementation (not required mode switch between WBE/WIFI/SOFTAP)
176// IOCTL_SAFE_MODE, // A safe mode required for driver for protected flows like upgrade and crash dump...
177//};
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300178
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300179// *************************************************************************************************
180
181#define MAX_REGS_LEN (256* 1024) // Max registers to read/write at once //TODO - is it needed? maybe read until line terminator?
182
183// Max buffer size for a command and a reply. We should consider the longest command/data sequence to fit in a buffer.
184// rb reading 1024 (MAX_REGS_LEN) registers: rb HHHHHHHH HHHH 1024*(0xHHHHHHHH) = 17 + 1024*10 = 10257 bytes
185// wb writing 1024 (MAX_REGS_LEN) hex values: wb HHHHHHHH "1024*HH" = 14+1024*2 = 2062 bytes
186#define MAX_INPUT_BUF (11*MAX_REGS_LEN) //TODO - is it needed? maybe read until line terminator?
187
188// *************************************************************************************************
189
190struct HostIps
191{
192 HostIps() :
193 m_ip(""),
194 m_broadcastIp("")
195 {}
196
197 std::string m_ip; // host's IP address
198 std::string m_broadcastIp; // host's broadcast IP address (derivated by subnet mask)
199};
200
201// *************************************************************************************************
202
203enum ServerType
204{
205 stTcp,
206 stUdp
207};
208
Vadim Ioseviche76832c2017-11-05 09:09:14 +0200209const int SECOND_IN_MILLISECONDS = 1000;
210
Vadim Iosevichd50ea462017-03-30 16:19:08 +0300211#endif // !_DEFINITIONS_H_