1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "wifi_vendor_hal_stubs.h"
17 
18 namespace OHOS {
19 namespace HDI {
20 namespace Wlan {
21 namespace Chip {
22 namespace V1_0 {
23 
24 template <typename>
25 struct StubFunction;
26 
27 template <typename R, typename... Args>
28 struct StubFunction<R (*)(Args...)> {
InvokeOHOS::HDI::Wlan::Chip::V1_0::StubFunction29     static constexpr R Invoke(Args...) { return HAL_NOT_SUPPORTED; }
30 };
31 template <typename... Args>
32 struct StubFunction<void (*)(Args...)> {
InvokeOHOS::HDI::Wlan::Chip::V1_0::StubFunction33     static constexpr void Invoke(Args...) {}
34 };
35 
36 template <typename T>
PopulateStubFor(T * val)37 void PopulateStubFor(T* val)
38 {
39     *val = &StubFunction<T>::Invoke;
40 }
41 
InitHalFuncTableWithStubs(WifiHalFn * halFn)42 bool InitHalFuncTableWithStubs(WifiHalFn* halFn)
43 {
44     if (halFn == nullptr) {
45         return false;
46     }
47     PopulateStubFor(&halFn->vendorHalInit);
48     PopulateStubFor(&halFn->waitDriverStart);
49     PopulateStubFor(&halFn->vendorHalExit);
50     PopulateStubFor(&halFn->startHalLoop);
51     PopulateStubFor(&halFn->wifiGetSupportedFeatureSet);
52     PopulateStubFor(&halFn->wifiGetChipFeatureSet);
53     PopulateStubFor(&halFn->vendorHalGetIfaces);
54     PopulateStubFor(&halFn->vendorHalGetIfName);
55     PopulateStubFor(&halFn->vendorHalGetChannelsInBand);
56     PopulateStubFor(&halFn->vendorHalCreateIface);
57     PopulateStubFor(&halFn->vendorHalDeleteIface);
58     PopulateStubFor(&halFn->vendorHalSetRestartHandler);
59     PopulateStubFor(&halFn->vendorHalPreInit);
60     PopulateStubFor(&halFn->triggerVendorHalRestart);
61     PopulateStubFor(&halFn->wifiSetCountryCode);
62     PopulateStubFor(&halFn->getChipCaps);
63     PopulateStubFor(&halFn->getPowerMode);
64     PopulateStubFor(&halFn->setPowerMode);
65     PopulateStubFor(&halFn->wifiStartScan);
66     PopulateStubFor(&halFn->wifiStartPnoScan);
67     PopulateStubFor(&halFn->wifiStopPnoScan);
68     PopulateStubFor(&halFn->getScanResults);
69     PopulateStubFor(&halFn->enablePowerMode);
70     PopulateStubFor(&halFn->getSignalPollInfo);
71     PopulateStubFor(&halFn->setDpiMarkRule);
72     PopulateStubFor(&halFn->registerIfaceCallBack);
73     PopulateStubFor(&halFn->setTxPower);
74     return true;
75 }
76 
77 } // namespace v1_0
78 } // namespace Chip
79 } // namespace Wlan
80 } // namespace HDI
81 } // namespace OHOS