blob: 1197c299644b102fd2656ce1fc467fa0db7af2bd [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
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) 2005
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/*******************************************************************************
37 *
38 * Filename:
39 * ---------
40 * meta_customize.c
41 *
42 * Project:
43 * --------
44 * Maui
45 *
46 * Description:
47 * ------------
48 * This file contains ft task customized bt funcitons in META mode.
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *==============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 * removed!
60 * removed!
61 *
62 * removed!
63 * removed!
64 * removed!
65 * removed!
66 *
67 * removed!
68 * removed!
69 * removed!
70 * removed!
71 *
72 * removed!
73 * removed!
74 * removed!
75 * removed!
76 *
77 * removed!
78 * removed!
79 * removed!
80 *
81 * removed!
82 * removed!
83 * removed!
84 * removed!
85 *
86 * removed!
87 * removed!
88 *
89 * removed!
90 * removed!
91 *
92 * removed!
93 * removed!
94 *
95 * removed!
96 * removed!
97 *
98 * removed!
99 * removed!
100 * removed!
101 *
102 * removed!
103 * removed!
104 * removed!
105 *
106 * removed!
107 * removed!
108 * removed!
109 *
110 * removed!
111 * removed!
112 * removed!
113 * removed!
114 * removed!
115 * removed!
116 * removed!
117 *
118 * removed!
119 * removed!
120 * removed!
121 *
122 * removed!
123 * removed!
124 * removed!
125 *
126 * removed!
127 * removed!
128 * removed!
129 *
130 * removed!
131 * removed!
132 * removed!
133 *
134 * removed!
135 * removed!
136 * removed!
137 *
138 * removed!
139 * removed!
140 * removed!
141 *
142 * removed!
143 * removed!
144 * removed!
145 *
146 * removed!
147 * removed!
148 * removed!
149 *
150 * removed!
151 * removed!
152 * removed!
153 *
154 * removed!
155 * removed!
156 * removed!
157 *
158 * removed!
159 * removed!
160 * removed!
161 *
162 * removed!
163 * removed!
164 * removed!
165 *
166 * removed!
167 * removed!
168 * removed!
169 *
170 * removed!
171 * removed!
172 * removed!
173 *
174 * removed!
175 * removed!
176 * removed!
177 *
178 * removed!
179 * removed!
180 * removed!
181 *
182 * removed!
183 * removed!
184 * removed!
185 *
186 * removed!
187 * removed!
188 * removed!
189 *
190 * removed!
191 * removed!
192 * removed!
193 *
194 * removed!
195 * removed!
196 * removed!
197 *
198 * removed!
199 * removed!
200 * removed!
201 *
202 * removed!
203 * removed!
204 * removed!
205 *
206 * removed!
207 * removed!
208 * removed!
209 *
210 * removed!
211 * removed!
212 * removed!
213 *
214 * removed!
215 * removed!
216 * removed!
217 *
218 * removed!
219 * removed!
220 * removed!
221 *
222 * removed!
223 * removed!
224 * removed!
225 *
226 * removed!
227 * removed!
228 * removed!
229 *
230 * removed!
231 * removed!
232 * removed!
233 *
234 * removed!
235 * removed!
236 * removed!
237 *
238 * removed!
239 * removed!
240 * removed!
241 *
242 * removed!
243 * removed!
244 * removed!
245 *
246 * removed!
247 * removed!
248 * removed!
249 *
250 * removed!
251 * removed!
252 * removed!
253 *
254 * removed!
255 * removed!
256 * removed!
257 * removed!
258 * removed!
259 * removed!
260 * removed!
261 * removed!
262 *
263 * removed!
264 * removed!
265 * removed!
266 *
267 * removed!
268 * removed!
269 * removed!
270 *
271 * removed!
272 * removed!
273 * removed!
274 *
275 * removed!
276 * removed!
277 * removed!
278 *
279 * removed!
280 * removed!
281 * removed!
282 *
283 * removed!
284 * removed!
285 * removed!
286 *
287 * removed!
288 * removed!
289 * removed!
290 *
291 * removed!
292 * removed!
293 * removed!
294 *
295 * removed!
296 * removed!
297 * removed!
298 *
299 * removed!
300 * removed!
301 * removed!
302 *
303 * removed!
304 * removed!
305 * removed!
306 *
307 * removed!
308 * removed!
309 * removed!
310 *
311 * removed!
312 * removed!
313 * removed!
314 *
315 * removed!
316 * removed!
317 * removed!
318 *
319 * removed!
320 * removed!
321 * removed!
322 *
323 * removed!
324 * removed!
325 * removed!
326 *
327 * removed!
328 * removed!
329 * removed!
330 *
331 * removed!
332 * removed!
333 * removed!
334 *
335 * removed!
336 * removed!
337 * removed!
338 *
339 * removed!
340 * removed!
341 * removed!
342 *
343 * removed!
344 * removed!
345 * removed!
346 *
347 *
348 *
349 *
350 *
351 *------------------------------------------------------------------------------
352 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
353 *==============================================================================
354 *******************************************************************************/
355#if defined(__MTK_TARGET__)
356#if !defined(__MAUI_BASIC__)
357/****************************************************************************
358 * KAL
359 ***************************************************************************/
360#include "kal_general_types.h"
361#include "kal_public_api.h"
362#include "init.h"
363/****************************************************************************
364 * NVRAM
365 ***************************************************************************/
366#include "nvram_enums.h"
367#include "nvram_data_items.h"
368#include "ft_nvram_def.h"
369#include "nvram_interface.h"
370#include "adc_nvram_def.h"
371#include "ul1_nvram_def.h"
372#include "l4_nvram_def.h"
373extern kal_bool Custom_META_IsSecureLid(kal_uint16 lid);
374/****************************************************************************
375 * MODEM BSP
376 ***************************************************************************/
377#include "ft_msg.h"
378//#include "l1audio.h"
379#include "meta_customize.h"
380/****************************************************************************
381 * Non MODEM BSP
382 ***************************************************************************/
383nvram_lid_enum meta_must_backup_lid_array[ ] =
384{
385#ifndef __MAUI_BASIC__
386#else
387 0 // at least one element
388#endif //#ifndef __MAUI_BASIC__
389};
390
391kal_uint16 custom_meta_check_must_backup_lid_array(kal_bool bCheckImeiFlag)
392{
393#ifndef __MAUI_BASIC__
394 kal_uint16 i;
395 kal_char *pcStrPrefix;
396 kal_char *pcStrVerNo;
397 kal_uint16 lid_num = custom_meta_get_check_lid_num();//sizeof(meta_must_backup_lid_array)/ sizeof(nvram_lid_enum);
398 kal_bool error_flag = KAL_FALSE;
399 kal_uint16 stop_index = 0;
400
401#ifndef __TC01__
402 for(i=0; i<lid_num-1; i++) // imei exclusively
403#else
404 for(i=0; i<lid_num; i++) // only focus calibration data.
405#endif
406 {
407 if(NVRAM_IO_ERRNO_OK != nvram_check_backup(meta_must_backup_lid_array[i], &pcStrPrefix, &pcStrVerNo))
408 {
409 error_flag = KAL_TRUE;
410 stop_index = i;
411 break;
412 }
413
414 }
415#ifndef __TC01__
416 if(i==lid_num-1) // pass the all check except IMEI
417 {
418 if(bCheckImeiFlag) // need to check imei
419 {
420 if(NVRAM_IO_ERRNO_OK != nvram_check_backup(meta_must_backup_lid_array[i], &pcStrPrefix, &pcStrVerNo))
421 error_flag =KAL_TRUE;
422 }
423 stop_index = i;
424 }
425#endif
426
427 if(error_flag == KAL_TRUE)
428 {
429 return stop_index;
430 }
431 else
432 {
433 return lid_num; // means success!
434 }
435#else
436 return 0;
437#endif // #ifndef __MAUI_BASIC__
438
439}
440
441kal_uint16 custom_meta_get_check_lid_num(void)
442{
443 return sizeof(meta_must_backup_lid_array)/sizeof(nvram_lid_enum);
444}
445
446kal_uint16 custom_meta_get_enum_by_index(kal_uint16 index)
447{
448 if(index < custom_meta_get_check_lid_num())
449 return (kal_uint16)meta_must_backup_lid_array[index];
450 else
451 return custom_meta_get_check_lid_num();
452}
453
454
455kal_bool custom_ft_util_check_if_isp_support()
456{
457 //#if defined(ISP_SUPPORT) && !defined(YUV_SENSOR_SUPPORT)
458 #if defined(ISP_SUPPORT)
459 return KAL_TRUE;
460 #else
461 return KAL_FALSE;
462 #endif
463}
464
465kal_bool custom_ft_util_check_if_usb_enable_support()
466{
467 return KAL_FALSE;
468}
469kal_uint16 custom_ft_get_calflag_enum(void)
470{
471#if !defined (NVRAM_NOT_PRESENT)
472 return NVRAM_EF_CAL_FLAG_LID;
473#else
474 return 0;
475#endif
476}
477/*******************************************************************************
478 * FUNCTION
479 * Custom_META_IsAllowedLimitedStateOperation
480 *
481 * DESCRIPTION
482 * Customizable limited state META mode operation check function
483 *
484 * CALLS
485 * INT_GetMetaModeSrc
486 *
487 * PARAMETERS
488 * ptrMsg the ilm_struct of the request message
489 *
490 * RETURNS
491 * The indicator of the operation is allowed or denied
492 *
493 *******************************************************************************/
494kal_bool Custom_META_IsAllowedLimitedStateOperation(ilm_struct* ptrMsg)
495{
496 return KAL_TRUE;
497}
498
499kal_bool Custom_META_IsSecureOperation(ilm_struct* ptrMsg)
500{
501 kal_bool isSecureOp = KAL_FALSE;
502 FT_H *ft_header = NULL;
503
504 ft_header = (FT_H *)(ptrMsg->local_para_ptr);
505
506 /*******************************************************
507 * Add more secured operations below
508 * message type id defined in interface\meta\ft_msg.h
509 * enum type FT_MESSAGE_ID
510 *******************************************************/
511 if (FT_NVRAM_READ_REQ_ID == ft_header->ft_msg_id)
512 {
513 ft_nvram_read_req_struct_T *ptr_loc_para = (ft_nvram_read_req_struct_T*) ptrMsg->local_para_ptr;
514 if (Custom_META_IsSecureLid(ptr_loc_para->file_idx))
515 {
516 isSecureOp = KAL_TRUE;
517 FT_SendDeniedMsgIdCnf(ft_header->ft_msg_id, FT_CNF_NOT_ALLOWED);
518 }
519 }
520
521 else if (FT_NVRAM_WRITE_REQ_ID == ft_header->ft_msg_id)
522 {
523 ft_nvram_write_req_struct_T *ptr_loc_para = (ft_nvram_write_req_struct_T*) ptrMsg->local_para_ptr;
524 if (Custom_META_IsSecureLid(ptr_loc_para->file_idx))
525 {
526 isSecureOp = KAL_TRUE;
527 FT_SendDeniedMsgIdCnf(ft_header->ft_msg_id, FT_CNF_NOT_ALLOWED);
528 }
529 }
530
531 else
532 {
533 isSecureOp = KAL_FALSE;
534 }
535
536 return isSecureOp;
537}
538
539
540kal_bool Custom_META_GetSlaPara(kal_uint8* para, kal_uint32 para_len)
541{
542 return true;
543}
544
545kal_uint16 Custom_META_CheckSlaVer(kal_uint32 sla_ver_from_pc)
546{
547 return 0;
548}
549
550kal_uint16 custom_ft_get_rf_cal_env_enum(void)
551{
552#ifdef __TC01_CALIBRATION__
553 return NVRAM_EF_RF_CAL_ENV_LID;
554#else
555 return 0;
556#endif
557}
558kal_uint16 custom_ft_get_rf_loss_setting_enum(void)
559{
560#ifdef __TC01_CALIBRATION__
561 return NVRAM_EF_RF_CAL_LOSS_SETTING_LID;
562#else
563 return 0;
564#endif
565}
566kal_uint16 custom_ft_get_rf_test_power_result_enum(void)
567{
568#ifdef __TC01_CALIBRATION__
569 return NVRAM_EF_RF_TEST_POWER_RESULT_LID;
570#else
571 return 0;
572#endif
573}
574void Custom_META_USBVirtualComDisconnect(void)
575{
576}
577/**
578 * This function will return the result of SDS support.
579 *
580 * usage: Custom_META_SdsSupported();
581 * @return KAL_TRUE, support SDS; KAL_FALSE, does not support SDS
582 */
583kal_bool Custom_META_SdsSupported(void)
584{
585#if defined(__SECURE_DATA_STORAGE__)
586 return KAL_TRUE;
587#else // #if defined(__SECURE_DATA_STORAGE__)
588 return KAL_FALSE;
589#endif // #if !defined(__SECURE_DATA_STORAGE__)
590}
591/**
592 * This function is used for customization
593 * The return value will be used as the maximum size of
594 * control buffer used between META and target
595 *
596 * FT task will truncate the value to the actual
597 * maximum value if the return value is over the actual
598 * maximum value
599 * (eg. system maximum value is 8K and the custom parameter
600 * asks for 16K, the result is 8K)
601 *
602 * on the other hand, if the custom parameter asks fewer
603 * than 2K, the FT task will override the value to 2K to
604 * keep the legacy command compatible.
605 * (eg. custom parameter is 1K, the FT task will override
606 * the setting to 2K for backward compatible)
607 */
608kal_uint32 Custom_META_ControlBufferSize(void)
609{
610 return 8192;
611}
612/**
613 * This function query the FT custom memory pool size
614 * @return pool size
615 */
616#define META_CUSTOM_MEM_POOL_SIZE 16384
617#if defined(__MTK_TARGET__)
618__attribute__((aligned(4)))
619#endif
620 kal_uint8 ft_ext_mem[META_CUSTOM_MEM_POOL_SIZE];
621kal_uint32 Custom_META_GetCustomMemoryPoolSize(void)
622{
623 return META_CUSTOM_MEM_POOL_SIZE;
624}
625/**
626 * This function return the pool arrangement
627 */
628static const kal_uint32 ft_subpool_size[8] = { 16384, 32768, 65536, 131072, 262144, 524288, 0xffffffff, 0 };
629void* Custom_META_GetCustomMemoryPoolArrangement(void)
630{
631 if(Custom_META_GetCustomMemoryPoolSize() > 4096)
632 {
633 return (void*)ft_subpool_size;
634 }
635 else
636 {
637 return NULL;
638 }
639}
640/**
641 * This function get the custom memory pool address
642 */
643kal_uint8* Custom_META_GetCustomMemoryPool(void)
644{
645 return ft_ext_mem;
646}
647#endif // #if !defined(__MAUI_BASIC__)
648#endif // #if defined(__MTK_TARGET__)