forked from Dude100/MediaTek-HelioX10-Baseband
/
kal_public_defs.h
962 lines (870 loc) · 31.4 KB
/
kal_public_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* kal_public_defs.h
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file provides public and common types definations.
* Note this file will inhirit RTOS header file
*
* Data type definitions in this file are visible for KAL Public Users.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
****************************************************************************/
#ifndef _KAL_PUBLIC_DEFS_H
#define _KAL_PUBLIC_DEFS_H
#include "kal_general_types.h"
#ifndef _DEBUG_MSG_SAP_
#include "stack_config.h" /* module_type & task_indx_type */
#endif
#include "stack_msgs.h" /* sap_type & msg_type */
/*******************************************************************************
* Type Definitions
*******************************************************************************/
/* opaque type for task identity */
typedef struct
{
kal_uint8 unused;
} kal_taskid_s;
typedef kal_taskid_s* kal_taskid;
/* opaque type for hisr identity */
typedef struct
{
kal_uint8 unused;
} kal_hisrid_s;
typedef kal_hisrid_s* kal_hisrid;
/* opaque type for semaphore identity */
typedef struct
{
kal_uint8 unused;
} kal_semid_s;
typedef kal_semid_s* kal_semid;
/* opaque type for message queue identity */
typedef struct
{
kal_uint8 unused;
} kal_msgqid_s;
typedef kal_msgqid_s* kal_msgqid;
/* contain message queue information */
typedef struct
{
/* current number of pending messages in message queue */
kal_uint32 pending_msgs;
/* maximum number of pending messages in message queue */
kal_uint32 max_msgs;
} kal_msgq_info;
/* opaque type for mutex identity */
typedef struct
{
kal_uint8 unused;
} kal_mutexid_s;
typedef kal_mutexid_s* kal_mutexid;
/* opaque type for event group identity */
typedef struct
{
kal_uint8 unused;
} kal_eventgrpid_s;
typedef kal_eventgrpid_s* kal_eventgrpid;
/* opaque type for partition memory pool identity */
typedef struct
{
kal_uint8 unused;
} kal_poolid_s;
typedef kal_poolid_s* kal_poolid;
/* opaque type for Application Dynamic Memory identity */
typedef struct
{
kal_uint8 unused;
} KAL_ADM_ID_s;
typedef KAL_ADM_ID_s* KAL_ADM_ID;
/* opaque type for Application Fix Memory identity */
typedef struct
{
kal_uint8 unused;
} KAL_AFM_ID_s;
typedef KAL_AFM_ID_s* KAL_AFM_ID;
/* opaque type for First Level Memory Manager identity */
typedef struct
{
kal_uint8 unused;
} KAL_FLMM_ID_s;
typedef KAL_FLMM_ID_s* KAL_FLMM_ID;
/* opaque type for Second Level Memory Manager identity */
typedef struct
{
kal_uint8 unused;
} KAL_SLMM_ID_s;
typedef KAL_SLMM_ID_s* KAL_SLMM_ID;
/* opaque type for enhance mutex identity */
typedef struct
{
kal_uint8 unused;
} kal_enhmutexid_s;
typedef kal_enhmutexid_s* kal_enhmutexid;
/* opaque type for kal timer identity */
typedef struct
{
kal_uint8 unused;
} kal_timerid_s;
typedef kal_timerid_s* kal_timerid;
/* opaque type for event scheduler identity */
typedef struct event_scheduler
{
kal_uint8 unused;
} event_scheduler;
/* opaque type for event identity */
typedef void* eventid;
/* task entry function parameter */
typedef struct task_entry_struct
{
/* paremeter of task main entry*/
kal_uint32 parameter;
} task_entry_struct;
/* general function pointer prototype */
typedef void (*kal_func_ptr)(void);
/* task entry function prototype */
typedef void (*kal_task_func_ptr)(task_entry_struct *task_entry_ptr);
/* hisr entry function prototype */
typedef void (*kal_hisr_func_ptr)(void);
/* timer (kal timer, stack timer, event scheduler) callback function prototype */
typedef void (*kal_timer_func_ptr)(void *param_ptr);
/*************************************************************************
* Type Definitions for ILM communication
*************************************************************************/
/* transfer direction flags for local_para & peer_buff, only TD_RESET is meaningful now */
typedef enum {
TD_UL = 0x01 << 0, /* Uplink Direction, obsolete */
TD_DL = 0x01 << 1, /* Downlink Direction, obsolete */
TD_CTRL = 0x01 << 2, /* Control Plane. Both directions, obsolete */
TD_RESET = 0x01 << 3 /* Reset buffer content to 0 */
} transfer_direction;
#define LOCAL_PARA_HDR \
kal_uint8 ref_count; \
kal_uint8 lp_reserved; \
kal_uint16 msg_len;
/* common local_para header */
typedef struct local_para_struct {
/* ref_count: reference count;
* lp_reserved : reserved for future;
* msg_len : total length including this header.
*/
LOCAL_PARA_HDR
#ifdef __BUILD_DOM__
;
#endif
} local_para_struct;
#define PEER_BUFF_HDR \
kal_uint16 pdu_len; \
kal_uint8 ref_count; \
kal_uint8 pb_resvered; \
kal_uint16 free_header_space; \
kal_uint16 free_tail_space;
/* peer buffer header, user should treat it as opaque type */
typedef struct peer_buff_struct {
PEER_BUFF_HDR
#ifdef __BUILD_DOM__
;
#endif
} peer_buff_struct;
typedef kal_uint16 interrupt_type;
typedef kal_uint16 module_type;
typedef kal_uint16 sap_type;
typedef kal_uint16 msg_type;
/* The Interlayer Message structure, which is exchaged between modules. */
typedef struct ilm_struct {
module_type src_mod_id; /* Source module ID of the message. */
module_type dest_mod_id; /* Destination module ID of the message. */
sap_type sap_id; /* Service Access Pointer Identifier. */
msg_type msg_id; /* Message identifier */
local_para_struct *local_para_ptr; /* local_para pointer */
peer_buff_struct *peer_buff_ptr; /* peer_buff pointer */
} ilm_struct;
/* maximum payload size in an inline-ILM message */
#define MSG_INLINE_ILM_MAX_PAYLOAD (sizeof(local_para_struct *) + sizeof(peer_buff_struct *))
/*************************************************************************
* Type Definitions for stack timer
*************************************************************************/
typedef enum {
STACK_TIMER_INITIALIZED,
STACK_TIMER_NOT_RUNNING = STACK_TIMER_INITIALIZED,
STACK_TIMER_RUNNING,
STACK_TIMER_NOT_TIMED_OUT = STACK_TIMER_RUNNING, /* Backward compatiable */
STACK_TIMER_EXPIRED,
STACK_TIMER_TIMED_OUT = STACK_TIMER_EXPIRED, /* Backward compatiable */
STACK_TIMER_STOPPED
} stack_timer_status_type;
typedef enum {
STACK_TIMER_USER_VIEW_STOPPED,
STACK_TIMER_USER_VIEW_RUNNING
}stack_timer_user_view_status_type;
/* opaque type for stack timer, don't reference its member directly */
typedef struct stack_timer_struct_t {
stack_timer_user_view_status_type timer_user_view_status;
stack_timer_status_type timer_status;
kal_uint8 invalid_time_out_count;
kal_timerid kal_timer_id;
kal_uint16 timer_indx;
module_type dest_mod_id;
#if defined(KAL_ON_OSCAR)
kal_uint8 ut_not_send_msg;
#endif
} stack_timer_struct;
/* DOM-NOT_FOR_SDK-BEGIN */
/*******************************************************************************
* Constant definition
*******************************************************************************/
#if defined(KAL_ON_NUCLEUS)
#define KAL_CONSUME 1 //NU_OR_CONSUME
#define KAL_AND 2 //NU_AND
#define KAL_AND_CONSUME 3 //NU_AND_CONSUME
#define KAL_OR 0 //NU_OR
#define KAL_OR_CONSUME 1 //NU_OR_CONSUME
#define KAL_NO_SUSPEND 0 //NU_NO_SUSPEND
#define KAL_SUSPEND 0xFFFFFFFF //NU_SUSPEND
#elif defined (KAL_ON_OSCAR) /* KAL_ON_NUCLEUS */
#define KAL_CONSUME 0x4 //OSC_ACTION_CLS
#define KAL_AND 0x1 //OSC_ACTION_FULL_SET
#define KAL_AND_CONSUME (KAL_AND | KAL_CONSUME) //OSC_ACTION_FULL_SET | OSC_ACTION_CLS
#define KAL_OR 0x2 //OSC_ACTION_PART_SET
#define KAL_OR_CONSUME (KAL_OR | KAL_CONSUME) //OSC_ACTION_PART_SET | OSC_ACTION_CLS
#define KAL_NO_SUSPEND 0 //OSC_TIMEOUT_NONE
#define KAL_SUSPEND 0xFFFFFFFF //OSC_TIMEOUT_FOREVER
#elif defined(KAL_ON_THREADX) /* KAL_ON_NUCLEUS */
#define KAL_CONSUME 1 //TX_OR_CLEAR
#define KAL_AND 2 //TX_AND
#define KAL_AND_CONSUME 3 //TX_AND_CLEAR
#define KAL_OR 0 //TX_OR
#define KAL_OR_CONSUME 1 //TX_OR_CLEAR
#define KAL_NO_SUSPEND 0 //TX_NO_WAIT
#define KAL_SUSPEND 0xFFFFFFFF //TX_WAIT_FOREVER
#elif defined(KAL_ON_OSABS)
typedef enum
{
KAL_CONSUME,
KAL_AND,
KAL_AND_CONSUME,
KAL_OR,
KAL_OR_CONSUME,
KAL_NO_SUSPEND,
KAL_SUSPEND
};
#endif /* KAL_ON_NUCLEUS */
#define KAL_NILTASK_ID (kal_taskid)NULL
#define KAL_NILHISR_ID (kal_hisrid)NULL
#define KAL_NILTIMER_ID (kal_timerid)NULL
#define KAL_NILPOOL_ID (kal_poolid)NULL
#define KAL_NILMUTEX_ID (kal_mutexid)NULL
#define KAL_NILEVENTGRP_ID (kal_eventgrpid)NULL
#define KAL_NILSEM_ID (kal_semid)NULL
#define KAL_NILQ_ID (kal_msgqid)NULL
#define KAL_NILSEC (kal_uint32)0xffffffff
#define KAL_NILMSEC (kal_uint16)0xffff
#define KAL_NILTICK (kal_uint32)0xffffffff
/* DOM-NOT_FOR_SDK-END */
/*******************************************************************************
* Constant definition Referenced By Public APIs
*******************************************************************************/
/* boot mode enumeration */
typedef enum
{
/* factory mode, system boot up to communicate with factory tools */
FACTORY_BOOT = 0,
/* normal mode */
NORMAL_BOOT = 1,
/* USB mode, system boot up when USB charger connect */
USBMS_BOOT = 2,
/* Firmware Update Engine mode, system run inside FUE */
FUE_BOOT = 3,
/* number of known boot mode */
NUM_OF_BOOT_MODE,
/* unknown mode */
UNKNOWN_BOOT_MODE = 0xff
} boot_mode_type;
/* adm feature option used in kal_adm_create2 */
/* DOM-NOT_FOR_SDK-BEGIN */
#define KAL_ADM_OLD_ISLOGGING_FLAG 0x1
#define KAL_ADM_PROFILE_FLAG 0x2
/* DOM-NOT_FOR_SDK-END */
#define KAL_ADM_GUARDIAN_FLAG 0x4 /* put a guard word before and after each user buffer to detect memory corruption */
#define KAL_ADM_EXTHEADER_FLAG 0x8 /* has an extensible header immediate before each user buffer */
#define KAL_ADM_CLEANDELETE_FLAG 0x10 /* on kal_adm_delete(), if any user buffer is not free yet, system enter fatal error handling */
#define KAL_ADM_REALLOCFAIL_FATAL_FLAG 0x20 /* if kal_adm_realloc() failed, system enter fatal error handling */
#define KAL_ADM_REALLOCFAIL_FREE_FLAG 0x40 /* if kal_adm_realloc() failed, free old user buffer before return NULL */
#define KAL_ADM_LIGHTCHECK_FREEPATTERN_FLAG 0x80
#define KAL_ADM_FREEPATTERN_FLAG 0x100
/* DOM-NOT_FOR_SDK-BEGIN */
#define KAL_ADM_VALID_FLAG 0x1ff /* OR of all KAL_ADM_*_FLAG, should not used by users */
/* DOM-NOT_FOR_SDK-END */
/* DOM-NOT_FOR_SDK-BEGIN */
/* ADM allocation options */
#define ADM_OPT_ALIGN_ALLOC (0x01 << 16)
#define ADM_CACHE_1_CHANNEL_COVER (0x02 << 16)
#define ADM_CACHE_ALL_CHANNEL_COVER (0x04 << 16)
#define ADM_OPT_TOPMOST_ALLOC (0x08 << 16)
#define ADM_OPT_BOTTOMMOST_ALLOC (0x10 << 16) /* allocate from the bottom(lower address)*/
#define ADM_OPT_MASK (0x7fff << 16) /* the highest bit is reserved to avoid signed overflow warning */
/* DOM-NOT_FOR_SDK-END */
/* Calculate how many words needed for an extheader (argument of extheader_size_in_word in kal_adm_create2) */
#define KAL_ADM_EXTHEADER_WORDS(x) (((x) + 3) / sizeof(kal_uint32) * sizeof(kal_uint32))
/* DOM-NOT_FOR_SDK-BEGIN */
/* ADM POOL SIZE CALCULATE MACROS BEGIN */
/* NOTE: */
/* following sizes are hard size for ADM structure, user must not */
/* use it directly. and it must be sync with kal_adm.h when ADM */
/* structure has been changed. */
/* macros internal begin */
#define ADM_CB_SIZE 16
#define ADM_BL_SIZE 16
#define ADM_MB_MINI_HEAD_SIZE 8
#define ADM_MB_HEAD_SIZE 16
#define ADM_MB_HEADGUARD_SIZE 4
#define ADM_MB_FOOTGUARD_SIZE 4
#define ADM_MB_OLDLOGGING_EXTHEADER_SIZE 8
/* macros internal end */
/* macros external begin */
#define ADM_DEFAULT_BL_NUM 7
#define ADM_MB_OVERHEAD(flags, extheader_size_in_word) \
(ADM_MB_MINI_HEAD_SIZE + \
((flags) & KAL_ADM_OLD_ISLOGGING_FLAG ? (ADM_MB_HEADGUARD_SIZE+ADM_MB_FOOTGUARD_SIZE+ADM_MB_OLDLOGGING_EXTHEADER_SIZE):0) + \
((flags) & KAL_ADM_GUARDIAN_FLAG ? (ADM_MB_HEADGUARD_SIZE+ADM_MB_FOOTGUARD_SIZE):0) + \
((flags) & KAL_ADM_EXTHEADER_FLAG ? (extheader_size_in_word)*4:0))
#define ADM_POOLSIZE_CALC(bl_num,user_pool_size) \
(ADM_CB_SIZE + \
ADM_BL_SIZE * (bl_num) + \
ADM_MB_MINI_HEAD_SIZE+ADM_MB_HEADGUARD_SIZE+ADM_MB_FOOTGUARD_SIZE + \
ADM_MB_MINI_HEAD_SIZE+ADM_MB_HEADGUARD_SIZE+ADM_MB_FOOTGUARD_SIZE + \
(user_pool_size))
/* macros external end */
/* ADM POOL SIZE CALCULATE MACROS END */
/* DOM-NOT_FOR_SDK-END */
/* DOM-NOT_FOR_SDK-BEGIN */
/* AFM allocation options */
#define AFM_OPT_NONE 0x0000
#define AFM_OPT_ALIGN_ALLOC 0x0001 /* user buffers in this AFM is aligned to CPU cache line (32 bytes) */
#define AFM_OPT_DBG 0x0002
#define AFM_OPT_CUSLOG 0x0004
#define AFM_OPT_NOFALLBACK_ALLOC 0x0008 /* when search avaiable user buffer, don't try to search subpools bigger than fittest subpool */
#define AFM_OPT_DBG_FREEPATTERN 0x0010
#define AFM_OPT_VALID 0x1F /* OR of all AFM_OPT_*, should not used by users */
#define AFM_LOG_PAUSE 0x01
#define AFM_LOG_CLEAR 0x02
#define AFM_LOG_CLR AFM_LOG_CLEAR /* for compatible only */
#define AFM_LOG_START 0x04
#define AFM_LOG_STR AFM_LOG_START /* for compatible only */
/* DOM-NOT_FOR_SDK-END */
/* DOM-NOT_FOR_SDK-BEGIN */
/* AFM POOL SIZE CALCULATE MACROS BEGIN*/
/* NOTE: */
/* following sizes are hard size for AFM structure, user MUST NOT */
/* use it directly. and it must be sync with kal_afm.h when AFM */
/* structure has been changed. */
/* macros internal begin*/
#define AFM_CB_T_SIZE 16
#define AFM_POOL_CB_T_SIZE 20
#define AFM_POOL_CUSLOG_T_SIZE 4
#define AFM_MB_HEAD_T_SIZE 8
#define AFM_MB_HEADGUD_T_SIZE 16
#define AFM_MB_FOOTGUD_T_SIZE 4
#define ALIGNTO4(sz) (((sz) + 3) & ~3)
#define ALIGNTOCACHELINE(sz) (((sz) + CPU_CACHE_LINE_SIZE-1) & ~(CPU_CACHE_LINE_SIZE-1))
/* macros internal end*/
/* macros external begin*/
#define AFM_MB_OVERHEAD(option) (AFM_MB_HEAD_T_SIZE + (option & AFM_OPT_DBG ? AFM_MB_HEADGUD_T_SIZE + AFM_MB_FOOTGUD_T_SIZE : 0))
#if defined(__MTK_TARGET__) && (defined(__ARM9_MMU__) || defined(__DYNAMIC_SWITCH_CACHEABILITY__))
#define AFM_POOL_OVERHEAD(option, subpool_count) \
(AFM_CB_T_SIZE + AFM_POOL_CB_T_SIZE * subpool_count \
+ (((option) & AFM_OPT_CUSLOG) ? AFM_POOL_CUSLOG_T_SIZE * (subpool_count) : 0) + 4 \
+ (((option) & AFM_OPT_ALIGN_ALLOC) ? CPU_CACHE_LINE_SIZE : 0))
#define AFM_SUBPOOL_OVERHEAD(option, sz, nr) \
(option & AFM_OPT_ALIGN_ALLOC ? \
(nr) * (ALIGNTOCACHELINE(sz) + ALIGNTOCACHELINE(AFM_MB_OVERHEAD(option))) \
: (nr) * (ALIGNTO4(sz) + AFM_MB_OVERHEAD(option)))
#else
#define AFM_POOL_OVERHEAD(option, subpool_count) \
AFM_CB_T_SIZE + AFM_POOL_CB_T_SIZE * (subpool_count) \
+ ((option & AFM_OPT_CUSLOG) ? AFM_POOL_CUSLOG_T_SIZE * subpool_count : 0) + 4
#define AFM_SUBPOOL_OVERHEAD(option, sz, nr) \
(nr) * (ALIGNTO4(sz) + AFM_MB_OVERHEAD(option))
#endif
/* macros external end*/
/* AFM POOL SIZE CALCULATE MACROS END*/
#define AFM_SUBPOOL_END_PATTERN 0xFFFFFFFF
/* DOM-NOT_FOR_SDK-END */
#if defined(__MTK_TARGET__) && defined(__KAL_STACK_ISOLATION__)
#define KAL_VM_PAGESIZE (4096) /* KAL VM page size */
#ifdef __ARM9_MMU__
#define KAL_VM_STACK_PAGESIZE 1024
#else //!__ARM9_MMU__
#define KAL_VM_STACK_PAGESIZE 4096
#endif //__ARM9_MMU__
#define KAL_VM_STACK_UPALIGN(x) ( ((x) + KAL_VM_STACK_PAGESIZE - 1) / KAL_VM_STACK_PAGESIZE * KAL_VM_STACK_PAGESIZE)
#define KAL_VM_STACK_ALIGNED(x) ( (x) & ~(KAL_VM_STACK_PAGESIZE - 1) == 0 )
#define kal_vm_stack_begin() (custom_get_FLMM_STACKSPACE_Base())
#define kal_vm_stack_end() (custom_get_FLMM_STACKSPACE_End())
#define KAL_VM_PAGE_ALIGNED(x) (!( ((kal_uint32)(x)) & (KAL_VM_PAGESIZE - 1))) /* is KAL VM page size aligned */
#define KAL_VM_PAGE_UPALIGN(x) (( ((kal_uint32)(x)) + KAL_VM_PAGESIZE - 1) & ~(KAL_VM_PAGESIZE - 1)) /* align to next KAL VM page size */
#define KAL_VM_PAGE_DOWNALIGN(x) ( ((kal_uint32)(x)) & ~(KAL_VM_PAGESIZE - 1)) /* align to KAL VM page size */
#define KAL_VM_PAGE_MARGIN(x) (KAL_VM_PAGE_UPALIGN(x) - (x)) /* how many bytes needed to align to next KAL VM page size */
#endif /* #if defined(__MTK_TARGET__) && defined(__KAL_STACK_ISOLATION__) */
/* define maximum memory region number can be dump via catcher on EXT_ASSERT_DUMP */
#define ASSERT_DUMP_PARAM_MAX 10
/* memory regions dump via catcher */
typedef struct ASSERT_DUMP_PARAM
{
kal_uint32 addr[ASSERT_DUMP_PARAM_MAX]; /* start address of this memory region */
kal_uint32 len[ASSERT_DUMP_PARAM_MAX]; /* length of this memory region */
} ASSERT_DUMP_PARAM_T;
/* keys of assert specific */
typedef enum
{
ASSERT_NONE,
ASSERT_SPECIFIC_CALLBACK,
ASSERT_SPECIFIC_WITH_LR,
ASSERT_LINE,
ASSERT_EXT,
ASSERT_EXT_DUMP,
ASSERT_NATIVE
} assert_specific_key;
/* callback function of ASSERT_SPECIFIC_CALLBACK */
typedef void (*Assert_Specific_Callback)(void* para_ptr);
/* define wait mode */
typedef enum {
KAL_NO_WAIT, /* don't wait if the condition is not satisfied and return error code */
KAL_INFINITE_WAIT /* wait until the condition is satisfied */
} kal_wait_mode;
/* define kal status */
typedef enum {
KAL_SUCCESS, /* the operation is succeeded */
KAL_ERROR, /* general error */
KAL_Q_FULL, /* queue is full */
KAL_Q_EMPTY, /* queue is empty */
KAL_SEM_NOT_AVAILABLE, /* semaphore is not available at the moment */
KAL_WOULD_BLOCK, /* the operation would block but requester don't want */
KAL_MESSAGE_TOO_BIG, /* message is too big */
KAL_INVALID_ID, /* an invalid identity */
KAL_NOT_INITIALIZED, /* the resource is not initialized */
KAL_INVALID_LENGHT, /* an invalid length */
KAL_NULL_ADDRESS, /* the address is NULL */
KAL_NOT_RECEIVE, /* no receiver want this message */
KAL_NOT_SEND, /* can't send this message out */
KAL_MEMORY_NOT_VALID, /* memory is corrupted */
KAL_NOT_PRESENT, /* the request resource is not present */
KAL_MEMORY_NOT_RELEASE, /* some memory is not released */
KAL_TIMEOUT /* the opearation time out */
} kal_status;
/* define kal task status */
typedef enum {
/*------- error cases -------*/
KAL_ERROR_RESERVE1, /**/
KAL_ERROR_RESERVE2, /**/
KAL_ERROR_RESERVE3, /**/
KAL_ERROR_TCB, /* incorrect task control block */
/*------- running case -------*/
KAL_READY, /* ready to execute */
/*------- suspend cases -------*/
KAL_SLEEP_SUSPEND, /* waiting for sleep timeout */
KAL_SEMA_SUSPEND, /* waiting for semaphore */
KAL_ENHMUTEX_SUSPEND, /* waiting for enhanced mutex */
KAL_OTHER_SUSPEND, /* waiting for other resource */
KAL_EVENT_SUSPEND, /* waiting for event */
KAL_QUEUE_SUSPEND, /* waiting for queue */
KAL_RESERVE1_SUSPEND, /* */
KAL_RESERVE2_SUSPEND, /* */
KAL_RESERVE3_SUSPEND, /* */
/*------- end case -------*/
KAL_TERMINATED, /* task is terminated */
} kal_task_status;
#define KAL_MAX_TICKS (2048*26*51)
#define ALIGNED_TIMER_MAX_DELAY (255)
#ifdef __STACK_ALIGN_MPU__
#define KAL_TASK_STACK_ALIGN (__STACK_ALIGN_MPU__)
#else
#define KAL_TASK_STACK_ALIGN (8U)
#endif
#define KAL_TASK_STACK_ALIGNMASK (KAL_TASK_STACK_ALIGN-1)
#define KAL_STACK_ALIGN(SIZE) (((SIZE + KAL_TASK_STACK_ALIGNMASK) / KAL_TASK_STACK_ALIGN) * KAL_TASK_STACK_ALIGN)
#ifdef KAL_ON_NUCLEUS
/* define how many miliseconds per system tick represent */
#ifdef OS_TICK_PERIOD_US
#define KAL_MICROSECS_PER_TICK OS_TICK_PERIOD_US
#define KAL_MILLISECS_PER_TICK ((float)KAL_MICROSECS_PER_TICK/1000)
/* +(KAL_MICROSECS_PER_TICK/2)/KAL_MICROSECS_PER_TICK:
* round the number to the nearest whole number
*/
#define KAL_TICKS_10_MSEC (( 10000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 10 msec */
#define KAL_TICKS_50_MSEC (( 50000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 50 msec */
#define KAL_TICKS_100_MSEC (( 100000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 100 msec */
#define KAL_TICKS_500_MSEC (( 500000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 500 msec */
#define KAL_TICKS_1024_MSEC (( 1024000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 1024 msec */
#define KAL_TICKS_1_SEC (( 1000000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 1 sec */
#define KAL_TICKS_2_SEC (( 2000000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 2 sec */
#define KAL_TICKS_3_SEC (( 3000000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 3 sec */
#define KAL_TICKS_5_SEC (( 5000000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 5 sec */
#define KAL_TICKS_30_SEC (( 30000000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 30 sec */
#define KAL_TICKS_1_MIN (( 60000000+(KAL_MICROSECS_PER_TICK/2))/KAL_MICROSECS_PER_TICK) /* 1 min */
#define KAL_MSEC_64_TICKS ((KAL_MICROSECS_PER_TICK*64+(1000/2)) /1000) /* 64 ticks */
#define KAL_MSEC_256_TICKS ((KAL_MICROSECS_PER_TICK*256+(1000/2)) /1000) /* 256 ticks */
#else /* else of OS_TICK_PERIOD_US */
#define KAL_MICROSECS_PER_TICK 4615
#define KAL_MILLISECS_PER_TICK 4.615
/* DOM-NOT_FOR_SDK-BEGIN */
/* Following defines are internal to the KAL */
#define KAL_TICKS_10_MSEC (2) /* 10 msec */
#define KAL_TICKS_50_MSEC (10) /* 50 msec */
#define KAL_TICKS_100_MSEC (21) /* 100 msec */
#define KAL_TICKS_500_MSEC (108) /* 500 msec */
#define KAL_TICKS_1024_MSEC (221) /* 1024 msec */
#define KAL_TICKS_1_SEC (216) /* 1 sec */
#define KAL_TICKS_2_SEC (433) /* 2 sec */
#define KAL_TICKS_3_SEC (650) /* 3 sec */
#define KAL_TICKS_5_SEC (1083) /* 5 sec */
#define KAL_TICKS_30_SEC (6500) /* 30 sec */
#define KAL_TICKS_1_MIN (13000) /* 1 min */
#define KAL_MSEC_64_TICKS (295) /* 64 ticks */
#define KAL_MSEC_256_TICKS (1181) /* 256 ticks */
/* DOM-NOT_FOR_SDK-END */
#endif /* end of "else of OS_TICK_PERIOD_US" */
#endif /* KAL_ON_NUCLEUS */
#ifdef KAL_ON_OSCAR
/* define how many miliseconds per system tick represent */
#define KAL_MILLISECS_PER_TICK 5
#define KAL_MICROSECS_PER_TICK 5000
/* DOM-NOT_FOR_SDK-BEGIN */
/* Following defines are internal to the KAL */
#define KAL_SIM_MSECS_PER_TICK KAL_MILLISECS_PER_TICK
#define KAL_TICKS_10_MSEC (10/KAL_SIM_MSECS_PER_TICK) /* 10 msec */
#define KAL_TICKS_50_MSEC (50/KAL_SIM_MSECS_PER_TICK) /* 50 msec */
#define KAL_TICKS_100_MSEC (100/KAL_SIM_MSECS_PER_TICK) /* 100 msec */
#define KAL_TICKS_500_MSEC (500/KAL_SIM_MSECS_PER_TICK) /* 500 msec */
#define KAL_TICKS_1024_MSEC (1024/KAL_SIM_MSECS_PER_TICK) /* 1024 msec */
#define KAL_TICKS_1_SEC (1000/KAL_SIM_MSECS_PER_TICK) /* 1 sec */
#define KAL_TICKS_2_SEC (2000/KAL_SIM_MSECS_PER_TICK) /* 2 sec */
#define KAL_TICKS_3_SEC (3000/KAL_SIM_MSECS_PER_TICK) /* 3 sec */
#define KAL_TICKS_5_SEC (5000/KAL_SIM_MSECS_PER_TICK) /* 5 sec */
#define KAL_TICKS_30_SEC (30000/KAL_SIM_MSECS_PER_TICK)/* 30 sec */
#define KAL_TICKS_1_MIN (60000/KAL_SIM_MSECS_PER_TICK)/* 1 min */
#define KAL_MSEC_64_TICKS (64*KAL_SIM_MSECS_PER_TICK) /* 64 ticks */
#define KAL_MSEC_256_TICKS (256*KAL_SIM_MSECS_PER_TICK) /* 256 ticks */
/* DOM-NOT_FOR_SDK-END */
#endif /* KAL_ON_OSCAR */
#if defined(KAL_ON_OSABS)
#define KAL_TICKS_10_MSEC (2) /* 10 msec */
#define KAL_TICKS_50_MSEC (10) /* 50 msec */
#define KAL_TICKS_100_MSEC (21) /* 100 msec */
#define KAL_TICKS_500_MSEC (108) /* 500 msec */
#define KAL_TICKS_1024_MSEC (221) /* 1024 msec */
#define KAL_TICKS_1_SEC (216) /* 1 sec */
#define KAL_TICKS_5_SEC (1083) /* 5 sec */
#define KAL_TICKS_30_SEC (6500) /* 30 sec */
#define KAL_TICKS_1_MIN (13001) /* 1 min */
#define KAL_MSEC_64_TICKS (295) /* 64 ticks */
#define KAL_MSEC_256_TICKS (1181) /* 256 ticks */
#endif
#if defined(__ARMCC_VERSION)
#define INLINE __inline
#define INLINE_MODIFIER extern
#elif defined (__GNUC__) && !defined(__MINGW32__)
#define INLINE inline
#define INLINE_MODIFIER extern
#elif defined (_MSC_VER) || defined(__MINGW32__)
#define INLINE __inline
#define INLINE_MODIFIER static
#endif /* Cross RVCT/GCC/VC9 Compiler marco definition */
#if defined(__ARMCC_VERSION)
#define GET_RETURN_ADDRESS(a) a=__return_address()
#elif defined (__GNUC__)
#define GET_RETURN_ADDRESS(a) a=(kal_uint32)__builtin_return_address(0)
#elif defined (_MSC_VER)
#define GET_RETURN_ADDRESS(a) a=_ReturnAddress()
#endif /* Cross RVCT/GCC/VC9 Compiler marco definition */
#if defined(__ARMCC_VERSION)
#define GET_STACK_POINTER(a) a= __current_sp()
#elif defined (__GNUC__)
#define GET_STACK_POINTER(a) a= (kal_uint32)__builtin_frame_address(0)
#elif defined (_MSC_VER)
#define GET_STACK_POINTER(a) __asm mov a,ESP
#endif /* Cross RVCT/GCC/VC9 Compiler marco definition */
#if defined(__ARMCC_VERSION) && defined(__MTK_TARGET__)
#define PRAGMA_BEGIN_COMPILER_OPTIMIZE_DISABLE _Pragma("push")\
_Pragma("O0")
#define PRAGMA_END_COMPILER_OPTIMIZE_DISABLE _Pragma("pop")
#define PRAGMA_BEGIN_COMPILER_OPTIMIZE_TIME _Pragma("push")\
_Pragma("Otime")
#define PRAGMA_END_COMPILER_OPTIMIZE_TIME _Pragma("pop")
#elif defined(__GNUC__) && defined(__MTK_TARGET__)
#define PRAGMA_BEGIN_COMPILER_OPTIMIZE_DISABLE _Pragma("GCC push_options")\
_Pragma("GCC optimize(\"-O0\")")
#define PRAGMA_END_COMPILER_OPTIMIZE_DISABLE _Pragma("GCC pop_options")
#define PRAGMA_BEGIN_COMPILER_OPTIMIZE_TIME _Pragma("GCC push_options")\
_Pragma("GCC optimize(\"-O3\")")
#define PRAGMA_END_COMPILER_OPTIMIZE_TIME _Pragma("GCC pop_options")
#else
#define PRAGMA_BEGIN_COMPILER_OPTIMIZE_DISABLE
#define PRAGMA_END_COMPILER_OPTIMIZE_DISABLE
#define PRAGMA_BEGIN_COMPILER_OPTIMIZE_TIME
#define PRAGMA_END_COMPILER_OPTIMIZE_TIME
#endif /* Cross RVCT/GCC/VC9 Compiler marco definition */
#define CBS_SCAN_EVENT_INDEX (1)
/*******************************************************************************
* Defines for ADT
*******************************************************************************/
/* ADT */
struct adt_node;
/* ilm free callback function prototype */
typedef void (*ilm_free_callback_t)(ilm_struct *ilm_ptr);
/* ilm ADT translator callback function prototype */
typedef void (*translator_adt_enc_callback_t)(const ilm_struct *ilm_ptr, struct adt_node **adt);
#endif /* _KAL_PUBLIC_DEFS_H */