blob: af2280b598cb867bf844906225385ac13da4ea53 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/******************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2018
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*******************************************************************************/
35
36#ifndef _PSILIB_API_H
37#define _PSILIB_API_H
38
39// include dependency headers
40
41/********************************************
42 * MACROS *
43 ********************************************/
44#include "kal_general_types.h"
45#include "ps_public_enum_public.h"
46#include "kal_public_defs.h"
47
48/********************************************
49 * TYPE DEFINITIONS & ENUMS *
50 ********************************************/
51#define PSILIB_NULL_PSI L4_PS_NULL_PSI
52#define PSILIB_INVALID_CID L4_PS_NULL_CID
53#define PSILIB_INVALID_APN_IDX -1
54#define PSILIB_INVALID_APN_NAME "#do_not_care"
55
56typedef enum {
57 PSILIB_PSI_OP_RELEASE,
58 PSILIB_PSI_OP_OCCUPY,
59 PSILIB_PSI_OP_QUERY,
60 PSILIB_PSI_OP_INJECT,
61 PSILIB_PSI_OP_REQUIRE,
62 PSILIB_PSI_OP_UT = 254,
63 PSILIB_PSI_OP_MAX,
64} psilib_op_enum;
65
66/********************************************
67 * VARIABLES *
68 ********************************************/
69
70// only extern variables are allowed in header
71
72/********************************************
73 * FUNCTION DECLARATIONS *
74 ********************************************/
75
76/**
77 * @brief Initialize the PSILIB (to be called by module_init())
78 * @param[in] null
79 * @return
80 * - KAL_TRUE, always
81 */
82kal_bool psilib_init(void);
83
84/**
85 * @brief Allocate a psi with the specified apn name, apn_idx and cid
86 * @param[in] apn name (to be associated with psi)
87 * @param[in] apn index(to be associated with psi)
88 * @param[in] cid (to be associated with psi)
89 * @return
90 * - KAL_TRUE if successful;
91 * - KAL_FALSE if failed (ex. all psi are occupied by other cids; the specified cid is used to alloc too many times)
92 */
93kal_bool psilib_alloc_psi_by_apn_idx_cid(kal_uint8 sim_interface, kal_char *apn_name,
94 kal_int8 apn_idx, kal_uint8 cid);
95
96/**
97 * @brief Module IP occupies a psi with the specified apn name, apn_idx and cid. It usually used by EPSI_REQ of ILM
98 * @param[in] apn name (to be associated with psi)
99 * @param[in] apn index(to be associated with psi)
100 * @param[in] module type(to record occupier of associated psi)
101 * @return
102 * - KAL_TRUE if successful;
103 * - KAL_FALSE if failed (ex. all psi are occupied by other cids; the specified cid is used to alloc too many times)
104 */
105kal_bool psilib_alloc_psi_by_apn_idx(kal_uint8 sim_interface, kal_char *apn_name,
106 kal_int8 apn_idx, module_type mod_id);
107
108/**
109 * @brief Allocate a psi with the specified cid
110 * @param[in] cid (to be assoicated with psi)
111 * @return
112 * - KAL_TRUE if successful;
113 * - KAL_FALSE if failed (ex. all psi are occupied by other cids; the specified cid is used to alloc too many times)
114 */
115kal_bool psilib_alloc_psi_by_cid(kal_uint8 sim_interface, kal_uint8 cid);
116
117/**
118 * @brief Allocate a psi with the specified psi, apn name and apn_idx
119 * @param[in] apn name (to be associated with psi)
120 * @param[in] apn index(to be associated with psi)
121 * @param[in] psi (a used/existing psi)
122 * @param[in] module type(to record occupier of associated psi)
123 * @return
124 * - KAL_TRUE if successful;
125 * - KAL_FALSE if failed (ex. all psi are occupied by other cids; the specified cid is used to alloc too many times)
126 */
127kal_bool psilib_require_psi_by_psi_apn_idx(kal_uint8 sim_interface, kal_char *apn_name,
128 kal_int8 apn_idx, kal_int8 psi, module_type mod_id);
129
130/**
131 * @brief Query the associated psi for the specified cid
132 * @param[in] cid (to know its associated psi)
133 * @return
134 * - [psi_val] if successful;
135 * - PSILIB_NULL_PSI if failed (ex. the specified cid does not allocate with any psi)
136 */
137kal_uint8 psilib_query_psi_by_cid(kal_uint8 sim_interface, kal_uint8 cid);
138
139/**
140 * @brief Query the associated psi for the specified apn name and apn index
141 * @param[in] apn_name (to know its associated psi)
142 * @param[in] apn_idx (to know its associated psi)
143 * @param[in] mod_id (to know its occupied psi)
144 * @return
145 * - [psi_val] if successful;
146 * - PSILIB_NULL_PSI if failed (ex. It did not allocate any psi with specified apn name and apn index)
147 */
148kal_uint8 psilib_query_psi_by_apn_idx(kal_uint8 sim_interface, kal_char *apn_name, kal_int8 apn_idx, module_type mod_id);
149
150/**
151 * @brief De-allocate psi with the specified cid
152 * @param[in] cid (it would be de-associated with the psi)
153 * @return
154 * - KAL_TRUE if successful;
155 * - KAL_FALSE if failed (ex. the specified cid is not associated with psi before calling dealloc)
156 */
157kal_bool psilib_dealloc_psi_by_cid(kal_uint8 sim_interface, kal_uint8 cid);
158
159/**
160 * @brief Release psi which occupied by someone module
161 * @param[in] psi (to release specified psi)
162 * @param[in] mod_id (the module wants to release psi (Occupier))
163 * @return
164 * - KAL_TRUE if successful;
165 * - KAL_FALSE if failed (ex. the specified psi's ref_count is already 0)
166 */
167kal_bool psilib_release_psi_by_psi(kal_uint8 sim_interface, kal_uint8 psi, module_type mod_id);
168
169/**
170 * @brief De-allocate psi with the specified apn name and apn index
171 * @param[in] apn_name (it would de-associated with psi)
172 * @param[in] apn_idx (it would de-associated with psi)
173 * @param[in] mod_id (the module wants to release psi (Occupier))
174 * @return
175 * - KAL_TRUE if successful;
176 * - KAL_FALSE if failed (ex. the specified apn name and apn index were not associated with psi before calling dealloc)
177 */
178kal_bool psilib_dealloc_psi_by_apn_idx(kal_uint8 sim_interface, kal_char *apn_name, kal_int8 apn_idx, module_type mod_id);
179
180/**
181 * @brief Update apn and apn index to associated psi with the specified cid
182 * @param[in] cid (to know its associated psi)
183 * @param[in] apn_name (to update apn of associated psi)
184 * @param[in] apn_idx (to update apn_idx of associated psi)
185 * @return
186 * - KAL_TRUE if successful;
187 * - KAL_FALSE if failed (ex. can not find psi according to cid)
188 */
189kal_bool psilib_update_apn_idx_by_cid(kal_uint8 sim_interface, kal_uint8 cid, kal_char *apn_name, kal_int8 apn_idx);
190
191/**
192 * @brief Inject PSI value for testing purpose
193 * @param[in] PSI
194 * @return
195 */
196void psilib_inject_psi(kal_uint8 sim_interface, kal_uint8 psi);
197
198#ifndef __MTK_TARGET__
199/**
200 * @brief Unit test of psilib
201 * @return
202 */
203void psilib_ut_handler(void);
204
205/**
206 * @brief Reset the PSILIB (to be called by module_reset())
207 * @param[in] null
208 * @return
209 * - KAL_TRUE, always
210 */
211kal_bool psilib_reset(void);
212#endif // #ifndef __MTK_TARGET__
213
214#endif /* _PSILIB_API_H */