--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(wlandrv-plugin C)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(pkgs REQUIRED
+ glib-2.0
+ dlog
+ vconf
+ )
+
+ADD_SUBDIRECTORY(src)
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+SOFTWARE LICENSE AGREEMENT
+
+The accompanying software in binary code form (“Software”), is licensed to you,
+or, if you are accepting on behalf of an entity, the entity and its affiliates
+exercising rights hereunder (“Licensee”) subject to the terms of this software
+license agreement (“Agreement”), unless Licensee and Broadcom Corporation
+(“Broadcom”) execute a separate written software license agreement governing
+use of the Software. ANY USE, REPRODUCTION, OR DISTRIBUTION OF THE SOFTWARE
+CONSTITUTES LICENSEE’S ACCEPTANCE OF THIS AGREEMENT.
+
+1. License. Subject to the terms and conditions of this Agreement,
+Broadcom hereby grants to Licensee a limited, non-exclusive, non-transferable,
+royalty-free license: (i) to use and integrate the Software with any other
+software; and (ii) to reproduce and distribute the Software complete,
+unmodified, and as provided by Broadcom, solely for use with Broadcom
+proprietary integrated circuit product(s) sold by Broadcom with which the
+Software was designed to be used, or their successors.
+
+2. Restrictions. Licensee shall distribute Software with a copy of this
+Agreement. Licensee shall not remove, efface or obscure any copyright or
+trademark notices from the Software. Reproductions of the Broadcom copyright
+notice shall be included with each copy of the Software, except where such
+Software is embedded in a manner not readily accessible to the end user.
+Licensee shall not: (i) use, license, sell or otherwise distribute the Software
+except as provided in this Agreement; (ii) attempt to modify in any way,
+reverse engineer, decompile or disassemble any portion of the Software; or
+(iii) use the Software or other material in violation of any applicable law or
+regulation, including but not limited to any regulatory agency. This Agreement
+shall automatically terminate upon Licensee’s failure to comply with any of the
+terms of this Agreement. In such event, Licensee will destroy all copies of the
+Software and its component parts.
+
+3. Ownership. The Software is licensed and not sold. Title to and
+ownership of the Software, including all intellectual property rights thereto,
+and any portion thereof remain with Broadcom or its licensors. Licensee hereby
+covenants that it will not assert any claim that the Software created by or for
+Broadcom infringe any intellectual property right owned or controlled by
+Licensee.
+
+4. Disclaimer. THE SOFTWARE IS OFFERED “AS IS,” AND BROADCOM PROVIDES AND
+GRANTS AND LICENSEE RECEIVES NO SUPPORT AND NO WARRANTIES OF ANY KIND, EXPRESS
+OR IMPLIED, BY STATUTE, COMMUNICATION OR CONDUCT WITH LICENSEE, OR OTHERWISE.
+BROADCOM SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A SPECIFIC PURPOSE, OR NONINFRINGEMENT CONCERNING THE SOFTWARE OR
+ANY UPGRADES TO OR DOCUMENTATION FOR THE SOFTWARE. WITHOUT LIMITATION OF THE
+ABOVE, BROADCOM GRANTS NO WARRANTY THAT THE SOFTWARE IS ERROR-FREE OR WILL
+OPERATE WITHOUT INTERRUPTION, AND GRANTS NO WARRANTY REGARDING ITS USE OR THE
+RESULTS THEREFROM INCLUDING, WITHOUT LIMITATION, ITS CORRECTNESS, ACCURACY, OR
+RELIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM
+OR ANY OF ITS LICENSORS HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER FOR BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE) OR
+OTHERWISE, ARISING OUT OF THIS AGREEMENT OR USE, REPRODUCTION, OR DISTRIBUTION
+OF THE SOFTWARE, INCLUDING BUT NOT LIMITED TO LOSS OF DATA AND LOSS OF PROFITS,
+EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE
+LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY
+LIMITED REMEDY.
+
+5. Export Laws. LICENSEE UNDERSTANDS AND AGREES THAT THE SOFTWARE IS
+SUBJECT TO UNITED STATES AND OTHER APPLICABLE EXPORT-RELATED LAWS AND
+REGULATIONS AND THAT LICENSEE MAY NOT EXPORT, RE-EXPORT OR TRANSFER THE
+SOFTWARE OR ANY DIRECT PRODUCT OF THE SOFTWARE EXCEPT AS PERMITTED UNDER THOSE
+LAWS. WITHOUT LIMITING THE FOREGOING, EXPORT, RE-EXPORT, OR TRANSFER OF THE
+SOFTWARE TO CUBA, IRAN, NORTH KOREA, SUDAN, AND SYRIA IS PROHIBITED.
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
+
--- /dev/null
+Name: wlandrv-plugin-tizen
+Summary: Firmware & tools for broadcom
+Version: 1.0.6
+Release: 1
+Group: Netwowrk & Connectivity
+License: Apache-2.0 and Broadcom
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(vconf)
+
+
+%description
+firmware & tools for broadcom
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/
+cp wlandrv-plugin-tizen/files/wifi-ready.service %{buildroot}%{_libdir}/systemd/system/wifi-ready.service
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/
+ln -s ../wifi-ready.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/wifi-ready.service
+
+mkdir -p %{buildroot}/lib/firmware/brcm
+cp -af wlandrv-plugin-tizen/lib/firmware/brcm/* %{buildroot}/lib/firmware/brcm
+mkdir -p %{buildroot}/usr/bin
+cp wlandrv-plugin-tizen/usr/bin/* %{buildroot}/usr/bin/
+
+%files
+%license LICENSE.APLv2 LICENSE.Broadcom
+/lib/firmware/brcm/*
+%{_libdir}/systemd/system/wifi-ready.service
+%{_libdir}/systemd/system/multi-user.target.wants/wifi-ready.service
+%manifest %{name}.manifest
+
+%{_bindir}/wlan.sh
+%{_bindir}/wifi-loader
+%caps(cap_net_admin,cap_dac_override,cap_sys_module,cap_sys_admin,cap_net_raw=eip) %{_bindir}/wifi-loader
+
+%post
+chmod 755 %{_bindir}/wlan.sh
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(wifi-loader C)
+
+SET(SRCS
+ main.c
+ wifi-util.c
+ )
+
+ADD_DEFINITIONS("-DUSE_COB_TYPE")
+SET(SRCS ${SRCS} wifi-loader_bcm.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ glib-2.0
+ dlog
+ vconf
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_EXECUTABLE(wifi-loader ${SRCS})
+TARGET_LINK_LIBRARIES(wifi-loader ${pkgs_LDFLAGS})
+
+#INSTALL(TARGETS wifi-loader RUNTIME DESTINATION /usr/bin)
+INSTALL(TARGETS wifi-loader DESTINATION /usr/bin)
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __WIFI_LOADER_H__
+#define __WIFI_LOADER_H__
+
+#include <stdbool.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define WIFI_MAC_INFO_PATH "/opt/etc/.mac.info"
+#define WIFI_MAC_ADD_PATH "/sys/class/net/wlan0/address"
+#define WIFI_INTERFACE_NAME "wlan0"
+#define MAC_ADDRESS_MAX_LEN 18
+
+#ifndef TEMP_FAILURE_RETRY
+/* Used to retry syscalls that can return EINTR. */
+#define TEMP_FAILURE_RETRY(exp) ({ \
+ typeof (exp) _rc; \
+ do { \
+ _rc = (exp); \
+ } while (_rc == -1 && errno == EINTR); \
+ _rc; })
+#endif
+
+enum wifi_loader_firmware {
+ WIFI_MODE_OFF = 0x00,
+ WIFI_MODE_STA = 0x01,
+ WIFI_MODE_P2P = 0x02,
+ WIFI_MODE_SOFTAP = 0x03,
+ WIFI_MODE_IBSS = 0x04,
+ WIFI_MODE_MFG = 0x05,
+ WIFI_MODE_READY = 0x06,
+};
+
+bool wifi_start(enum wifi_loader_firmware mode);
+int wifi_stop(void);
+int wifi_ready(void);
+
+#endif /* __WIFI_LOADER_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __WIFI_LOG_H__
+#define __WIFI_LOG_H__
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "WIFI_LOADER"
+
+#define WIFI_LOGV(fmt, args...) LOGV(fmt, ##args)
+#define WIFI_LOGD(fmt, args...) LOGD(fmt, ##args)
+#define WIFI_LOGI(fmt, args...) LOGI(fmt, ##args)
+#define WIFI_LOGW(fmt, args...) LOGW(fmt, ##args)
+#define WIFI_LOGE(fmt, args...) LOGE(fmt, ##args)
+#define WIFI_LOGF(fmt, args...) LOGF(fmt, ##args)
+
+#endif /* __WIFI_LOG_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __WIFI_UTIL_H__
+#define __WIFI_UTIL_H__
+
+#include <stdbool.h>
+#include <unistd.h>
+
+#define BUFF_MAX 255
+
+bool wifi_interface_up(const char *ifname);
+bool wifi_interface_down(const char *ifname);
+bool wifi_check_mac_info(void);
+int sys_write_buf(char *file, char *buf, int cnt);
+int sys_read_buf(char *file, char *buf);
+
+#endif /* __WIFI_UTIL_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "wifi-util.h"
+#include "wifi-loader.h"
+#include "wifi-log.h"
+
+int wifi_station()
+{
+ if (wifi_start(WIFI_MODE_STA) == false) {
+ WIFI_LOGE("wifi_start(WIFI_MODE_STA) failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+int wifi_softap()
+{
+ if (wifi_start(WIFI_MODE_SOFTAP) == false) {
+ WIFI_LOGE("wifi_start(WIFI_MODE_SOFTAP) failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+int wifi_rftest()
+{
+ if (wifi_start(WIFI_MODE_MFG) == false) {
+ WIFI_LOGE("wifi_start(WIFI_MODE_MFG) failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ WIFI_LOGE("argc(%d), argv[1] = %s\n", argc, argv[1]);
+
+ if (argc != 2)
+ return 0;
+
+ if (strcmp(argv[1], "ready") == 0) {
+ ret = wifi_ready();
+ if (ret < 0)
+ WIFI_LOGE("Failed to run wifi_check_mac_info and ready, quitting...\n");
+ return ret;
+ }
+ else if ((strcmp(argv[1], "start") == 0 || strcmp(argv[1], "p2p") == 0)) {
+ ret = wifi_station();
+ if (ret < 0)
+ WIFI_LOGE("Failed to run wifi_station, quitting...\n");
+ return ret;
+ }
+ else if (strcmp(argv[1], "softap") == 0) {
+ ret = wifi_softap();
+ if (ret < 0)
+ WIFI_LOGE("Failed to run wifi_softap, quitting...\n");
+ return ret;
+ }
+ else if (strcmp(argv[1], "rftest") == 0) {
+ ret = wifi_rftest();
+ if (ret < 0)
+ WIFI_LOGE("Failed to run wifi_rftest, quitting...\n");
+ return ret;
+ }
+ else if (strcmp(argv[1], "stop") == 0) {
+ ret = wifi_stop();
+ if (ret < 0)
+ WIFI_LOGE("Failed to run wifi_stop, quitting...\n");
+ return ret;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "wifi-loader.h"
+#include "wifi-log.h"
+#include "wifi-util.h"
+
+
+
+void wifi_loader_set_vconf_str(const char * key, const char * value)
+{
+ int ret = 0;
+
+ WIFI_LOGD("[%s: %s]", key, value);
+
+ ret = vconf_set_str(key, value);
+ if (ret != VCONF_OK)
+ WIFI_LOGE("Failed to vconf set");
+}
+
+void wifi_loader_set_mac_address_from_file(void)
+{
+ FILE *file = NULL;
+ char mac_str[MAC_ADDRESS_MAX_LEN];
+ char *mac_lower_str = NULL;
+ int mac_len = 0;
+
+ file = fopen(WIFI_MAC_ADD_PATH, "r");
+ if (file == NULL) {
+ WIFI_LOGE("Fail to open %s", WIFI_MAC_ADD_PATH);
+ return;
+ }
+ if (fgets(mac_str, sizeof(mac_str), file) == NULL) {
+ WIFI_LOGE("Fail to read mac address");
+ fclose(file);
+ return;
+ }
+
+ mac_len = strlen(mac_str);
+ if (mac_len < 17) {
+ WIFI_LOGE("mac.info is empty");
+ fclose(file);
+ return;
+ }
+
+ mac_lower_str = g_ascii_strup(mac_str, (gssize)mac_len);
+ wifi_loader_set_vconf_str(VCONFKEY_WIFI_BSSID_ADDRESS, mac_lower_str);
+
+ g_free(mac_lower_str);
+ fclose(file);
+}
+
+bool wifi_start(enum wifi_loader_firmware mode)
+{
+ WIFI_LOGD("mode = %d", mode);
+ WIFI_LOGD("wifi_start called");
+
+ return true;
+}
+
+int wifi_stop()
+{
+ WIFI_LOGD("wifi_stop called");
+
+ return 0;
+}
+
+int wifi_ready()
+{
+ WIFI_LOGD("wifi_ready called");
+
+ if (wifi_check_mac_info() == false) {
+ WIFI_LOGE("There is broken %s file", WIFI_MAC_INFO_PATH);
+
+ if (wifi_interface_up(WIFI_INTERFACE_NAME) == false) {
+ WIFI_LOGE("wifi_interface_up failed");
+ return -1;
+ }
+
+ wifi_loader_set_mac_address_from_file();
+
+ usleep(200000);
+
+ if (wifi_interface_down(WIFI_INTERFACE_NAME) == false) {
+ WIFI_LOGE("wifi_interface_down failed");
+ return -1;
+ }
+
+ wifi_stop();
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <sys/utsname.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include <net/if.h>
+#include <sys/ioctl.h>
+
+#include "wifi-util.h"
+#include "wifi-loader.h"
+#include "wifi-log.h"
+
+bool wifi_interface_up(const char *ifname)
+{
+ int fd;
+ struct ifreq ifr;
+
+ fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ return false;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
+
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return false;
+ }
+
+ ifr.ifr_flags |= (IFF_UP | IFF_DYNAMIC);
+ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return false;
+ }
+
+ close(fd);
+
+ WIFI_LOGD("Successfully activated wireless interface");
+ return true;
+}
+
+bool wifi_interface_down(const char *ifname)
+{
+ int fd;
+ struct ifreq ifr;
+
+ fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ return false;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
+
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return false;
+ }
+
+ ifr.ifr_flags = (ifr.ifr_flags & ~IFF_UP) | IFF_DYNAMIC;
+ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
+ close(fd);
+ return false;
+ }
+
+ close(fd);
+
+ WIFI_LOGD("Successfully de-activated wireless interface");
+ return true;
+}
+
+bool wifi_check_mac_info()
+{
+ char buf[BUFF_MAX];
+ int ret = 0;
+
+ ret = sys_read_buf(WIFI_MAC_INFO_PATH, buf);
+
+ if(ret < 0) {
+ WIFI_LOGE("Failed to open/read %s err = %d", WIFI_MAC_INFO_PATH, ret);
+ return false;
+ }
+
+ WIFI_LOGE("Successfully read %s", WIFI_MAC_INFO_PATH);
+
+ return true;
+}
+
+int sys_write_buf(char *file, char *buf, int cnt)
+{
+ int fd;
+ int r;
+
+ if (!file || !buf) {
+ WIFI_LOGE("%s: invalid argument\n", __func__);
+ return -1;
+ }
+
+ fd = open(file, O_WRONLY);
+ if (fd == -1) {
+ WIFI_LOGE("%s: file:%s, %s.",
+ __func__, file, strerror(errno));
+ return -1;
+ }
+
+ r = write(fd, buf, cnt);
+ close(fd);
+ if (r < 0)
+ return -1;
+
+ return 0;
+}
+
+int sys_read_buf(char *file, char *buf)
+{
+ int fd;
+ int r;
+
+ fd = open(file, O_RDONLY);
+ if (fd == -1) {
+ WIFI_LOGE("%s: file:%s, %s.",
+ __func__, file, strerror(errno));
+ return -ENOENT;
+ }
+
+ r = read(fd, buf, BUFF_MAX);
+ if ((r > 0) && (r < BUFF_MAX))
+ buf[r] = '\0';
+ else
+ r = -EIO;
+
+ close(fd);
+
+ return r;
+}
+
--- /dev/null
+[Unit]
+Description=Wifi module checking
+Before=net-config.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/wifi-loader ready
+MemoryLimit=10M
+SmackProcessLabel=System
+User=network_fw
+Group=network_fw
+Capabilities=cap_net_admin,cap_dac_override,cap_sys_module,cap_sys_admin,cap_net_raw=i
+SecureBits=keep-caps
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+# NVRAM file for BCM943430WLPTH
+# 2.4 GHz, 20 MHz BW mode
+
+# The following parameter values are just placeholders, need to be updated.
+manfid=0x2d0
+prodid=0x0727
+vendid=0x14e4
+devid=0x43e2
+boardtype=0x0727
+boardrev=0x1101
+boardnum=22
+macaddr=00:90:4c:c5:12:38
+sromrev=11
+boardflags=0x00404201
+boardflags3=0x08000000
+xtalfreq=37400
+nocrc=1
+ag0=255
+aa2g=1
+ccode=ALL
+
+pa0itssit=0x20
+extpagain2g=0
+#PA parameters for 2.4GHz, measured at CHIP OUTPUT
+pa2ga0=-168,7161,-820
+AvVmid_c0=0x0,0xc8
+cckpwroffset0=5
+
+# PPR params
+maxp2ga0=84
+txpwrbckof=6
+cckbw202gpo=0
+legofdmbw202gpo=0x66111111
+mcsbw202gpo=0x77711111
+propbw202gpo=0xdd
+
+# OFDM IIR :
+ofdmdigfilttype=18
+ofdmdigfilttypebe=18
+# PAPD mode:
+papdmode=1
+papdvalidtest=1
+pacalidx2g=42
+papdepsoffset=-22
+papdendidx=58
+
+# LTECX flags
+ltecxmux=0
+ltecxpadnum=0x0102
+ltecxfnsel=0x44
+ltecxgcigpio=0x01
+
+il0macaddr=00:90:4c:c5:12:38
+wl0id=0x431b
+
+deadman_to=0xffffffff
+# muxenab: 0x1 for UART enable, 0x2 for GPIOs, 0x8 for JTAG
+muxenab=0x1
+# CLDO PWM voltage settings - 0x4 - 1.1 volt
+#cldo_pwm=0x4
+
+#VCO freq 326.4MHz
+spurconfig=0x3
+
+edonthd20l=-75
+edoffthd20ul=-80
--- /dev/null
+# Cloned from bcm94345wlpagb_p2xx.txt
+NVRAMRev=$Rev: 498373 $
+sromrev=11
+vendid=0x14e4
+devid=0x43ab
+manfid=0x2d0
+prodid=0x06e4
+#macaddr=00:90:4c:c5:12:38
+macaddr=b8:27:eb:74:f2:6c
+nocrc=1
+boardtype=0x6e4
+boardrev=0x1304
+
+#XTAL 37.4MHz
+xtalfreq=37400
+
+btc_mode=1
+#------------------------------------------------------
+#boardflags: 5GHz eTR switch by default
+# 2.4GHz eTR switch by default
+# bit1 for btcoex
+boardflags=0x00480201
+boardflags2=0x40800000
+boardflags3=0x44200100
+phycal_tempdelta=15
+rxchain=1
+txchain=1
+aa2g=1
+aa5g=1
+tssipos5g=1
+tssipos2g=1
+femctrl=0
+AvVmid_c0=1,165,2,100,2,100,2,100,2,100
+pa2ga0=-129,6525,-718
+pa2ga1=-149,4408,-601
+pa5ga0=-185,6836,-815,-186,6838,-815,-184,6859,-815,-184,6882,-818
+pa5ga1=-202,4285,-574,-201,4312,-578,-196,4391,-586,-201,4294,-575
+itrsw=1
+pdoffsetcckma0=2
+pdoffset2gperchan=0,-2,1,0,1,0,1,1,1,0,0,-1,-1,0
+pdoffset2g40ma0=16
+pdoffset40ma0=0x8888
+pdoffset80ma0=0x8888
+extpagain5g=2
+extpagain2g=2
+tworangetssi2g=1
+tworangetssi5g=1
+# LTECX flags
+# WCI2
+ltecxmux=0
+ltecxpadnum=0x0504
+ltecxfnsel=0x22
+ltecxgcigpio=0x32
+
+maxp2ga0=80
+ofdmlrbw202gpo=0x0022
+dot11agofdmhrbw202gpo=0x4442
+mcsbw202gpo=0x98444422
+mcsbw402gpo=0x98444422
+maxp5ga0=82,82,82,82
+mcsbw205glpo=0xb9555000
+mcsbw205gmpo=0xb9555000
+mcsbw205ghpo=0xb9555000
+mcsbw405glpo=0xb9555000
+mcsbw405gmpo=0xb9555000
+mcsbw405ghpo=0xb9555000
+mcsbw805glpo=0xb9555000
+mcsbw805gmpo=0xb9555000
+mcsbw805ghpo=0xb9555000
+
+swctrlmap_2g=0x00000000,0x00000000,0x00000000,0x010000,0x3ff
+swctrlmap_5g=0x00100010,0x00200020,0x00200020,0x010000,0x3fe
+swctrlmapext_5g=0x00000000,0x00000000,0x00000000,0x000000,0x3
+swctrlmapext_2g=0x00000000,0x00000000,0x00000000,0x000000,0x3
+
+vcodivmode=1
+deadman_to=481500000
+
+ed_thresh2g=-54
+ed_thresh5g=-54
+eu_edthresh2g=-54
+eu_edthresh5g=-54
+ldo1=4
+rawtempsense=0x1ff
+cckPwrIdxCorr=3
+cckTssiDelay=150
+ofdmTssiDelay=150
+txpwr2gAdcScale=1
+txpwr5gAdcScale=1
+dot11b_opts=0x3aa85
+cbfilttype=1
+fdsslevel_ch11=6
+
+# Improved Bluetooth coexistence parameters from Cypress
+btc_mode=1
+btc_params8=0x4e20
+btc_params1=0x7530
--- /dev/null
+#!/bin/sh
+
+WIFI_LOADER=/usr/bin/wifi-loader
+
+start()
+{
+ ${WIFI_LOADER} start
+}
+
+stop()
+{
+ ${WIFI_LOADER} stop
+}
+
+softap()
+{
+ ${WIFI_LOADER} softap
+}
+
+p2p()
+{
+ ${WIFI_LOADER} p2p
+}
+
+rftest()
+{
+ ${WIFI_LOADER} rftest
+}
+
+ready()
+{
+ ${WIFI_LOADER} ready
+}
+
+case $1 in
+"start")
+start
+;;
+"stop")
+stop
+;;
+"softap")
+softap
+;;
+"p2p")
+p2p
+;;
+"rftest")
+rftest
+;;
+"ready")
+ready
+;;
+*)
+echo wlan.sh [ready] [start] [stop] [softap] [p2p] [check_hw] [rftest]
+exit 1
+;;
+esac
+exit 0