1 /*
2 * Copyright 2022, Cypress Semiconductor Corporation (an Infineon company)
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /** @file
19 * Provides generic APSTA functionality that chip specific files use
20 */
21
22 #include "whd_debug.h"
23 #include "whd_int.h"
24 #include "whd_resource_if.h"
25
26 /******************************************************
27 * * @cond Constants
28 * ******************************************************/
29
30 /******************************************************
31 * * Enumerations
32 * ******************************************************/
33
34 /******************************************************
35 * * Function Declarations
36 * ******************************************************/
37
38 /******************************************************
39 * Variables Definitions
40 *****************************************************/
41
42 /******************************************************
43 * Function Definitions
44 ******************************************************/
whd_resource_size(whd_driver_t whd_driver,whd_resource_type_t resource,uint32_t * size_out)45 uint32_t whd_resource_size(whd_driver_t whd_driver, whd_resource_type_t resource, uint32_t *size_out)
46 {
47 if (whd_driver->resource_if->whd_resource_size)
48 {
49 return whd_driver->resource_if->whd_resource_size(whd_driver, resource, size_out);
50 }
51 else
52 {
53 WPRINT_WHD_ERROR( ("Function pointers not provided .\n") );
54 }
55
56 return WHD_WLAN_NOFUNCTION;
57 }
58
whd_get_resource_block_size(whd_driver_t whd_driver,whd_resource_type_t type,uint32_t * size_out)59 uint32_t whd_get_resource_block_size(whd_driver_t whd_driver, whd_resource_type_t type, uint32_t *size_out)
60 {
61
62 if (whd_driver->resource_if->whd_get_resource_block_size)
63 {
64 return whd_driver->resource_if->whd_get_resource_block_size(whd_driver, type, size_out);
65 }
66 else
67 {
68 WPRINT_WHD_ERROR( ("Function pointers not provided .\n") );
69 }
70
71 return WHD_WLAN_NOFUNCTION;
72 }
73
whd_get_resource_no_of_blocks(whd_driver_t whd_driver,whd_resource_type_t type,uint32_t * block_count)74 uint32_t whd_get_resource_no_of_blocks(whd_driver_t whd_driver, whd_resource_type_t type, uint32_t *block_count)
75 {
76 if (whd_driver->resource_if->whd_get_resource_no_of_blocks)
77 {
78 return whd_driver->resource_if->whd_get_resource_no_of_blocks(whd_driver, type, block_count);
79 }
80 else
81 {
82 WPRINT_WHD_ERROR( ("Function pointers not provided .\n") );
83 }
84
85 return WHD_WLAN_NOFUNCTION;
86 }
87
whd_get_resource_block(whd_driver_t whd_driver,whd_resource_type_t type,uint32_t blockno,const uint8_t ** data,uint32_t * size_out)88 uint32_t whd_get_resource_block(whd_driver_t whd_driver, whd_resource_type_t type,
89 uint32_t blockno, const uint8_t **data, uint32_t *size_out)
90 {
91
92 if (whd_driver->resource_if->whd_get_resource_block)
93 {
94 return whd_driver->resource_if->whd_get_resource_block(whd_driver, type, blockno, data, size_out);
95 }
96 else
97 {
98 WPRINT_WHD_ERROR( ("Function pointers not provided .\n") );
99 }
100
101 return WHD_WLAN_NOFUNCTION;
102 }
103
whd_resource_read(whd_driver_t whd_driver,whd_resource_type_t type,uint32_t offset,uint32_t size,uint32_t * size_out,void * buffer)104 uint32_t whd_resource_read(whd_driver_t whd_driver, whd_resource_type_t type, uint32_t offset,
105 uint32_t size, uint32_t *size_out, void *buffer)
106 {
107 if (whd_driver->resource_if->whd_resource_read)
108 {
109 return whd_driver->resource_if->whd_resource_read(whd_driver, type, offset, size, size_out, buffer);
110 }
111 else
112 {
113 WPRINT_WHD_ERROR( ("Function pointers not provided .\n") );
114 }
115
116 return WHD_WLAN_NOFUNCTION;
117 }
118