rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #ifndef _KAL_INLINE_API_H |
| 2 | #define _KAL_INLINE_API_H |
| 3 | |
| 4 | #include "kal_general_types.h" |
| 5 | #include "mips_ia_utils_public.h" |
| 6 | |
| 7 | /******************************************************************************* |
| 8 | * <GROUP Functions> |
| 9 | * |
| 10 | * FUNCTION |
| 11 | * kal_query_boot_mode |
| 12 | * DESCRIPTION |
| 13 | * query system boot mode. |
| 14 | * PARAMETERS |
| 15 | * N/A |
| 16 | * SEE ALSO |
| 17 | * boot_mode_type |
| 18 | ******************************************************************************/ |
| 19 | INLINE_MODIFIER INLINE INLINE_ALWAYS boot_mode_type kal_query_boot_mode(void) |
| 20 | { |
| 21 | extern boot_mode_type system_boot_mode; |
| 22 | return system_boot_mode; |
| 23 | } |
| 24 | |
| 25 | /******************************************************************************* |
| 26 | * <GROUP Functions> |
| 27 | * |
| 28 | * FUNCTION |
| 29 | * kal_set_boot_mode |
| 30 | * DESCRIPTION |
| 31 | * set system boot mode (for Seamless META Switch) |
| 32 | * PARAMETERS |
| 33 | * boot_mode_type |
| 34 | * SEE ALSO |
| 35 | * boot_mode_type |
| 36 | ******************************************************************************/ |
| 37 | INLINE_MODIFIER INLINE INLINE_ALWAYS void kal_set_boot_mode(boot_mode_type boot_mode) |
| 38 | { |
| 39 | extern boot_mode_type system_boot_mode; |
| 40 | system_boot_mode = boot_mode; |
| 41 | } |
| 42 | |
| 43 | /******************************************************************************* |
| 44 | * <GROUP Functions> |
| 45 | * |
| 46 | * FUNCTION |
| 47 | * kal_get_current_core_id |
| 48 | * DESCRIPTION |
| 49 | * get current executed CORE ID |
| 50 | * PARAMETERS |
| 51 | * N/A |
| 52 | * RETURNS |
| 53 | * current executed CORE ID: 0 ~ 3. |
| 54 | ******************************************************************************/ |
| 55 | INLINE INLINE_ALWAYS static kal_uint32 kal_get_current_core_id(void) |
| 56 | { |
| 57 | #if defined(__MTK_TARGET__) |
| 58 | kal_uint32 cpu_id = 0; |
| 59 | |
| 60 | cpu_id = miu_get_current_core_id(); |
| 61 | |
| 62 | return cpu_id; |
| 63 | #else |
| 64 | return 0; |
| 65 | #endif |
| 66 | } |
| 67 | |
| 68 | /******************************************************************************* |
| 69 | * <GROUP Functions> |
| 70 | * |
| 71 | * FUNCTION |
| 72 | * kal_get_current_vpe_id |
| 73 | * DESCRIPTION |
| 74 | * get current executed VPE ID |
| 75 | * PARAMETERS |
| 76 | * N/A |
| 77 | * RETURNS |
| 78 | * current executed VPE ID: 0 ~ 7. |
| 79 | ******************************************************************************/ |
| 80 | INLINE INLINE_ALWAYS static kal_uint32 kal_get_current_vpe_id(void) |
| 81 | { |
| 82 | |
| 83 | #if defined(__MTK_TARGET__) |
| 84 | kal_uint32 cpu_id = 0; |
| 85 | |
| 86 | cpu_id = miu_get_current_vpe_id(); |
| 87 | |
| 88 | return cpu_id; |
| 89 | #else |
| 90 | return 0; |
| 91 | #endif |
| 92 | } |
| 93 | |
| 94 | /******************************************************************************* |
| 95 | * <GROUP Functions> |
| 96 | * |
| 97 | * FUNCTION |
| 98 | * kal_get_current_tc_id |
| 99 | * DESCRIPTION |
| 100 | * get current executed TC ID |
| 101 | * PARAMETERS |
| 102 | * N/A |
| 103 | * RETURNS |
| 104 | * current executed TC ID: 0 ~ 3. |
| 105 | ******************************************************************************/ |
| 106 | INLINE INLINE_ALWAYS static kal_uint32 kal_get_current_tc_id(void) |
| 107 | { |
| 108 | #if defined(__MTK_TARGET__) |
| 109 | kal_uint32 tc_id = 0; |
| 110 | |
| 111 | tc_id = miu_get_current_tc_id(); |
| 112 | |
| 113 | return tc_id; |
| 114 | #else |
| 115 | return 0; |
| 116 | #endif |
| 117 | } |
| 118 | |
| 119 | /******************************************************************************* |
| 120 | * Category 1 : StdLib-like Function |
| 121 | *******************************************************************************/ |
| 122 | INLINE_MODIFIER INLINE INLINE_ALWAYS void *kal_mem_cpy(void *dest, const void *src, |
| 123 | kal_uint32 size) |
| 124 | { |
| 125 | return memcpy(dest, src, size); |
| 126 | } |
| 127 | |
| 128 | INLINE_MODIFIER INLINE INLINE_ALWAYS void *kal_mem_set(void *dest, kal_int32 value, |
| 129 | kal_uint32 size) |
| 130 | { |
| 131 | return memset(dest, value, size); |
| 132 | } |
| 133 | |
| 134 | INLINE_MODIFIER INLINE INLINE_ALWAYS kal_int32 kal_mem_cmp(const void *src1, const void *src2, |
| 135 | kal_uint32 size) |
| 136 | { |
| 137 | return memcmp(src1, src2, size); |
| 138 | } |
| 139 | |
| 140 | INLINE_MODIFIER INLINE INLINE_ALWAYS void *kal_mem_bwcpy(void *dest, const void *src, |
| 141 | kal_uint32 size) |
| 142 | { |
| 143 | char * destaddr = (char *)dest + (size - 1); |
| 144 | char const *srcaddr = (char *)src + (size - 1); |
| 145 | while (size-- > 0) |
| 146 | *destaddr-- = *srcaddr--; |
| 147 | return destaddr; |
| 148 | } |
| 149 | |
| 150 | #endif |