blob: ca071a9b6ae52ffe8c485317f21fa12357d6d4ff [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**=============================================================================
43 vos_getBin.c
44 \brief
45 Description...
Madan Mohan Koyyalamudia208d102012-10-15 15:18:18 -070046 Copyright (c) 2012 Qualcomm Atheros, Inc.
47 All Rights Reserved.
48 Qualcomm Atheros Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -070049 ==============================================================================*/
50/* $HEADER$ */
51/**-----------------------------------------------------------------------------
52 Include files
53 ----------------------------------------------------------------------------*/
54#include <vos_getBin.h>
55#include <linux/fs.h> // for softmac direct file i/o
56#include <vos_api.h>
57#include <vos_sched.h>
58#include <wlan_hdd_misc.h>
59#include <wlan_hdd_main.h>
60/**-----------------------------------------------------------------------------
61 Preprocessor definitions and constants
62 ----------------------------------------------------------------------------*/
63/**-----------------------------------------------------------------------------
64 Type declarations
65 ----------------------------------------------------------------------------*/
66extern tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void );
67
68/**-----------------------------------------------------------------------------
69 Function declarations and documenation
70 ----------------------------------------------------------------------------*/
71/*----------------------------------------------------------------------------
72 \brief vos_get_binary_blob() - get binary data from platform
73 This API allows components to get binary data from the platform independent
74 of where the data is stored on the device.
75 <ul>
76 <li> Firmware
77 <li> Configuration Data
78 \param binaryId - identifies the binary data to return to the caller.
79 raw binary data and update the *pBufferSize with the exact
80 size of the data that has been retreived.
81 the size of the binary data in *pBufferSize.
82 size of the data buffer available at pBuffer. Upon success, this
83 retreived and written to the buffer at pBuffer.
84 Input value of 0 is valid and will cause the API to return
85 the size of the binary data in *pBufferSize.
86 retreived and written to the buffer.
87 refer to a valid VOS Binary ID.
88 variable that the API can write to.
89 *pBufferSize is not big enough to contain the binary.
90 \sa
91 --------------------------------------------------------------------------*/
92VOS_STATUS vos_get_binary_blob( VOS_BINARY_ID binaryId,
93 v_VOID_t *pBuffer, v_SIZE_t *pBufferSize )
94{
95 VOS_STATUS VosSts = VOS_STATUS_SUCCESS;
96 char *pFileName;
97
98 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
99
100 // get the correct file name from binary Id
101 switch (binaryId)
102 {
103 case VOS_BINARY_ID_CONFIG:
104 pFileName = WLAN_CFG_FILE;
105 break;
106 case VOS_BINARY_ID_COUNTRY_INFO:
107 pFileName = WLAN_COUNTRY_INFO_FILE;
108 break;
109 case VOS_BINARY_ID_HO_CONFIG:
110 pFileName = WLAN_HO_CFG_FILE;
111 break;
112 default:
113 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "Invalid binaryID");
114 return VosSts;
115 }
116 if(0 == *pBufferSize )
117 {
118 /* just a file size request. set the value and return VOS_STATUS_E_NOMEM*/
119 VosSts = hdd_get_cfg_file_size(((VosContextType*)(pVosContext))->pHDDContext,pFileName,pBufferSize);
120
121 if ( !VOS_IS_STATUS_SUCCESS( VosSts ))
122 {
123 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
124 "%s : vos_open failed\n",__func__);
125
126 return VOS_STATUS_E_FAILURE;
127 }
128 VosSts = VOS_STATUS_E_NOMEM;
129 }
130 else
131 {
132 if(NULL != pBuffer) {
133 // read the contents into the buffer
134 VosSts = hdd_read_cfg_file(((VosContextType*)(pVosContext))->pHDDContext,pFileName,pBuffer,pBufferSize);
135 }
136 else {
137 VosSts = VOS_STATUS_E_FAILURE;
138 }
139 }
140
141 return VosSts;
142}
143
144#ifndef FEATURE_WLAN_INTEGRATED_SOC
145VOS_STATUS vos_get_fwbinary( v_VOID_t **ppBinary, v_SIZE_t *pNumBytes )
146{
147 v_CONTEXT_t pVosContext;
148 VOS_STATUS status = VOS_STATUS_SUCCESS;
149
150 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
151
152 if(pVosContext) {
153
154 status = hdd_request_firmware(WLAN_FW_FILE,((VosContextType*)(pVosContext))->pHDDContext,ppBinary,pNumBytes);
155
156 }
157 return status;
158}
159#endif
160
161#ifdef WLAN_SOFTAP_FEATURE
162tVOS_CON_MODE vos_get_conparam( void )
163{
164 tVOS_CON_MODE con_mode;
165 con_mode = hdd_get_conparam ( );
166 return con_mode;
167}
168#endif
169tVOS_CONCURRENCY_MODE vos_get_concurrency_mode( void )
170{
171 tVOS_CONCURRENCY_MODE con_mode;
172 con_mode = hdd_get_concurrency_mode ( );
173 return con_mode;
174}
175
176v_BOOL_t vos_concurrent_sessions_running(void)
177{
178 v_U8_t i=0;
179 v_U8_t j=0;
180 hdd_context_t *pHddCtx;
181 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
182
183 if (NULL != pVosContext)
184 {
185 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
Madan Mohan Koyyalamudia208d102012-10-15 15:18:18 -0700186 if (NULL != pHddCtx)
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 {
Madan Mohan Koyyalamudia208d102012-10-15 15:18:18 -0700188 for (i=0; i < VOS_MAX_NO_OF_MODE; i++)
189 {
190 j += pHddCtx->no_of_sessions[i];
191 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 }
193 }
194
195 return (j>1);
196}
197