| /***************************************************************************** |
| * 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: |
| * --------- |
| * stack_config.c |
| * |
| * Project: |
| * -------- |
| * Maui_Software |
| * |
| * Description: |
| * ------------ |
| * This file provides a template for .c files. This space |
| * should be used to describe the file contents. |
| * |
| * 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! |
| * 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! |
| *------------------------------------------------------------------------------ |
| * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| *============================================================================ |
| ****************************************************************************/ |
| |
| /********************************************************************* |
| (C) _____ (year of first publication) Sasken communication |
| Technologies Limited, All rights reserved. |
| * This file provides a template for .c files. This space |
| * should be used to describe the file contents |
| * Component-specific prefix : xxxx |
| *********************************************************************/ |
| |
| /************************************************************************* |
| * Included header files |
| *************************************************************************/ |
| //#include "kal_release.h" |
| //#include "init_time_cfg.h" |
| |
| //#include "stack_common.h" |
| //#include "stack_msgs.h" |
| //#include "app_ltlcom.h" |
| #include "lcd_ip_cqueue.h" |
| //#include "stack_types.h" |
| #include "task_config.h" |
| |
| #include "stack_buff_pool.h" |
| #include "ctrl_buff_pool.h" |
| |
| #include "sysconf_statistics.h" |
| #include "dspsys_statistics.h" |
| |
| //#if defined(DEBUG_KAL) && ( defined(DEBUG_BUF1) || defined(DEBUG_BUF2) ) |
| //#include "kal_debug.h" |
| //#endif /* DEBUG_KAL && ( DEBUG_BUF1 || DEBUG_BUF2 ) */ |
| /*RHR*/ |
| #include "kal_general_types.h" |
| #include "kal_os.h" |
| #include "kal_buff_mgr.h" |
| #include "kal_internal_api.h" |
| #include "kal_internal_def.h" |
| //#include "kal_common_defs.h" |
| #include "stack_config.h" |
| #include "kal_public_defs.h" |
| #include "stdlib.h" |
| /*RHR*/ |
| #include "event_shed.h" |
| |
| #ifdef __MTK_TARGET__ |
| #include "sys_mem_size.h" |
| #else |
| #include "sys_mem_size_modis.h" |
| #endif /* __MTK_TARGET__*/ |
| |
| #include "cpu.h" |
| #include "cache_sw.h" |
| #include "us_timer.h" |
| |
| #include "SST_intrCtrl.h" |
| |
| /************************************************************************* |
| * Global data definitions |
| *************************************************************************/ |
| stack_statistics_struct sys_stats; |
| |
| /************************************************************************* |
| * Definitions of Imported Globals |
| *************************************************************************/ |
| extern kal_uint32 KALTotalTasks; |
| extern kal_uint32 KALTotalModules; |
| |
| extern kal_uint32 sys_mem_total_size; |
| extern kal_uint32 sys_mem_left_size; |
| |
| #ifdef DEBUG_KAL |
| extern kal_uint32 debug_mem_total_size; |
| extern kal_uint32 debug_mem_left_size; |
| #endif /* DEBUG_KAL */ |
| |
| extern kal_internal_hisrid kal_hisr_ptrs_g[]; |
| extern kal_uint8 num_hisr_created_g; |
| |
| /************************************************************************* |
| * FUNCTION |
| * stack_config |
| * |
| * DESCRIPTION |
| * This function implements to config Protocol Stack's configuration |
| * |
| * PARAMETERS |
| * |
| * RETURNS |
| * |
| * GLOBALS AFFECTED |
| * |
| *************************************************************************/ |
| kal_bool stack_config(void) |
| { |
| #if defined(__TST_MODULE__) && defined(__DSP_FCORE4__) |
| init_dspsys_stat(); |
| #endif |
| return KAL_TRUE; |
| } |
| |
| |
| /************************************************************************* |
| * FUNCTION |
| * stack_get_statistics_struct_size |
| * |
| * DESCRIPTION |
| * This function implements to get stack_statistics_struct size |
| * |
| * PARAMETERS |
| * |
| * RETURNS |
| * |
| * GLOBALS AFFECTED |
| * |
| *************************************************************************/ |
| |
| kal_uint32 stack_get_statistics_struct_size(void) |
| { |
| kal_uint32 nSize = 0; |
| |
| nSize = sizeof(stack_statistics_struct); |
| |
| return nSize; |
| } |
| |
| |
| /************************************************************************* |
| * FUNCTION |
| * stack_update_sys_statistics |
| * |
| * DESCRIPTION |
| * This function implements to compare with statistics saved in FLASH, and |
| * update if necessary. |
| * |
| * PARAMETERS |
| * |
| * RETURNS |
| * |
| * GLOBALS AFFECTED |
| * |
| *************************************************************************/ |
| #ifdef DEBUG_KAL |
| kal_uint32 kal_kal_timer_g; |
| kal_uint32 kal_es_timer_g; |
| kal_uint32 kal_max_event_number; |
| kal_uint32 kal_max_mutex_number; |
| kal_uint32 kal_max_semaphore_number; |
| kal_uint32 kal_max_enhmutex_number; |
| kal_uint32 kal_max_eventgroup_number; |
| kal_uint32 kal_max_spinlock_number; |
| kal_uint32 kal_max_protect_number; |
| #endif |
| |
| #if defined(DEBUG_KAL) && defined(DEBUG_TIMER2) |
| kal_uint16 kal_timer_count_debug[LAST_MOD_ID]; |
| kal_uint16 kal_timer_count_debug_tmp[LAST_MOD_ID]; |
| |
| |
| /*Sort in decresing order*/ |
| static kal_int32 timer_count_cmp(const void *a, const void *b) |
| { |
| kal_uint16 a_int16 = *((kal_uint16 *)a); |
| kal_uint16 b_int16 = *((kal_uint16 *)b); |
| |
| if (a_int16 > b_int16) { |
| return -1; |
| } else if (a_int16 == b_int16) { |
| return 0; |
| } else { |
| return 1; |
| } |
| } |
| #endif |
| |
| kal_bool stack_update_sys_statistics(stack_statistics_struct *prev_stats) |
| { |
| kal_bool f_modified = KAL_FALSE; |
| kal_uint32 i, *stack_start, *stack_ptr, *stack_end; |
| kal_uint32 time_us_high, time_us_low; |
| /* kal_uint32 stack_size; fix compile warning */ |
| #if defined(DEBUG_KAL) && defined(DEBUG_TIMER2) |
| kal_int32 key = 0; |
| kal_int32 count = 0; |
| #endif |
| #if defined(FURTHER_STATISTIC) && defined(__MTK_TARGET__) |
| kal_internal_taskid taskid = NULL; |
| extern kal_uint8 system_resource_amount[]; |
| #endif |
| |
| #if defined(DEBUG_KAL) && (defined(DEBUG_BUF1) || defined(DEBUG_BUF2)) |
| kal_pool_statistics pool_stats; |
| buff_pool_info_struct *pool_info; |
| #endif /* DEBUG_KAL && ( DEBUG_BUF1 || DEBUG_BUF2 ) */ |
| |
| #if defined(FURTHER_STATISTIC) && defined(__MTK_TARGET__) |
| extern ADM_PROFILE top_adm[]; |
| extern ADM_PROFILE top_adm_user[]; |
| extern AFM_PROFILE top_afm[]; |
| extern AFM_PROFILE top_afm_user[]; |
| extern kal_uint32 kicked_out_smallest_adm_user_size[]; |
| extern kal_uint32 kicked_out_adm_user_number; |
| #if defined(__HARD_REAL_TIME_CHECK_LOG_LEVEL__) |
| extern HRTQbitFailLogStruct HRTQbitFailLog_VPE0[HRTQbitFailLogSize]; |
| extern HRTQbitFailLogStruct HRTQbitFailLog_VPE1[HRTQbitFailLogSize]; |
| extern HRTQbitFailLogStruct HRTQbitFailLog_VPE2[HRTQbitFailLogSize]; |
| extern HRTQbitFailLogStruct HRTQbitFailLog_VPE3[HRTQbitFailLogSize]; |
| #endif |
| #endif |
| |
| /* memory management statistics */ |
| |
| sys_stats.memory_pool.max_sys_mem_used = sys_mem_total_size - sys_mem_left_size; |
| if (sys_stats.memory_pool.max_sys_mem_used > |
| prev_stats->memory_pool.max_sys_mem_used) { |
| prev_stats->memory_pool.max_sys_mem_used = |
| sys_stats.memory_pool.max_sys_mem_used; |
| f_modified = KAL_TRUE; |
| } |
| |
| #ifdef DEBUG_KAL |
| sys_stats.memory_pool.max_sysdebug_mem_used = |
| debug_mem_total_size - debug_mem_left_size; |
| |
| if (sys_stats.memory_pool.max_sysdebug_mem_used > |
| prev_stats->memory_pool.max_sysdebug_mem_used) { |
| prev_stats->memory_pool.max_sysdebug_mem_used = |
| sys_stats.memory_pool.max_sysdebug_mem_used; |
| f_modified = KAL_TRUE; |
| } |
| |
| sys_stats.memory_pool.max_event_number_used = kal_max_event_number; |
| if (sys_stats.memory_pool.max_event_number_used > |
| prev_stats->memory_pool.max_event_number_used) { |
| prev_stats->memory_pool.max_event_number_used = |
| sys_stats.memory_pool.max_event_number_used; |
| f_modified = KAL_TRUE; |
| } |
| |
| #endif /* DEBUG_KAL */ |
| |
| /* task stack size statistics */ |
| for (i = 0; i < KALTotalTasks; i++) { |
| |
| if (task_info_g[i].task_id == NULL) |
| continue; |
| |
| #if defined(KAL_ON_OSCAR) |
| sys_stats.runtime_max_amount_task[i].stack = 0; |
| #elif defined(KAL_ON_MERTOS) |
| (void)stack_start; (void)stack_ptr, (void)stack_end; // To make compiler happy |
| (void)time_us_low; (void)time_us_high; |
| #endif |
| |
| if (sys_stats.runtime_max_amount_task[i].stack > |
| prev_stats->runtime_max_amount_task[i].stack) { |
| prev_stats->runtime_max_amount_task[i].stack = |
| sys_stats.runtime_max_amount_task[i].stack; |
| f_modified = KAL_TRUE; |
| } |
| } |
| |
| /* HISR stack size statistics */ |
| for (i = 0; i < KAL_MAX_NUM_HISRS; i++) { |
| |
| #if !defined(KAL_ON_MERTOS) |
| if (kal_hisr_ptrs_g[i] == NULL) |
| continue; |
| #endif |
| |
| #if defined(KAL_ON_OSCAR) |
| sys_stats.runtime_max_amount_hisr[i].stack = 0; |
| #endif |
| |
| if (sys_stats.runtime_max_amount_hisr[i].stack > |
| prev_stats->runtime_max_amount_hisr[i].stack) { |
| prev_stats->runtime_max_amount_hisr[i].stack = |
| sys_stats.runtime_max_amount_hisr[i].stack; |
| f_modified = KAL_TRUE; |
| } |
| } |
| |
| /* Queue management statistics */ |
| #if defined(DEBUG_ITC) && defined(DEBUG_KAL) |
| for (i = 0; i < KALTotalTasks; i++) { |
| if (task_info_g[i].task_ext_qid == NULL) |
| continue; |
| |
| sys_stats.runtime_max_amount_task[i].ext_queue = |
| ((kal_internal_msgqid)task_info_g[i].task_ext_qid) |
| ->q_stat->max_num_msgs_enqued; |
| |
| if (sys_stats.runtime_max_amount_task[i].ext_queue > |
| prev_stats->runtime_max_amount_task[i].ext_queue) { |
| prev_stats->runtime_max_amount_task[i].ext_queue = |
| sys_stats.runtime_max_amount_task[i].ext_queue; |
| f_modified = KAL_TRUE; |
| } |
| } |
| for (i = 0; i < KALTotalTasks; i++) { |
| if (task_info_g[i].task_int_qid_ptr == NULL) { |
| continue; |
| } |
| |
| sys_stats.runtime_max_amount_task[i].int_queue = 0; |
| |
| LCD_IP_CQUEUE_UPDATE_MAX((*(int_q_type *)task_info_g[i].task_int_qid_ptr), |
| sys_stats.runtime_max_amount_task[i].int_queue); |
| |
| if (sys_stats.runtime_max_amount_task[i].int_queue > |
| prev_stats->runtime_max_amount_task[i].int_queue) { |
| prev_stats->runtime_max_amount_task[i].int_queue = |
| sys_stats.runtime_max_amount_task[i].int_queue; |
| f_modified = KAL_TRUE; |
| } |
| } |
| |
| #endif /* DEBUG_ITC && DEBUG_KAL */ |
| |
| /* Buffer management statistics */ |
| #if defined(DEBUG_KAL) && (defined(DEBUG_BUF1) || defined(DEBUG_BUF2)) |
| for (i = 0; i < RPS_CREATED_CTRL_BUFF_POOLS; i++) { |
| pool_info = &ctrl_buff_pool_info_g[i]; |
| if (pool_info->pool_id == NULL) |
| continue; |
| |
| pool_stats = KAL_GET_POOL_STATISTICS_ADDR(pool_info->pool_id); |
| sys_stats.max_ctrl_buff_num_allocated[i] = pool_stats->max_num_allocated; |
| |
| if (sys_stats.max_ctrl_buff_num_allocated[i] > |
| prev_stats->max_ctrl_buff_num_allocated[i]) { |
| prev_stats->max_ctrl_buff_num_allocated[i] = |
| sys_stats.max_ctrl_buff_num_allocated[i]; |
| f_modified = KAL_TRUE; |
| } |
| } |
| |
| #endif /* DEBUG_KAL && ( DEBUG_BUF1 || DEBUG_BUF2 ) */ |
| |
| |
| #ifdef DEBUG_KAL |
| sys_stats.runtime_max_amount_total.kal_timer = kal_kal_timer_g - kal_es_timer_g; |
| if (sys_stats.runtime_max_amount_total.kal_timer > |
| prev_stats->runtime_max_amount_total.kal_timer) { |
| prev_stats->runtime_max_amount_total.kal_timer = |
| sys_stats.runtime_max_amount_total.kal_timer; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_total.event_scheduler = kal_es_timer_g; |
| if (sys_stats.runtime_max_amount_total.event_scheduler > |
| prev_stats->runtime_max_amount_total.event_scheduler) { |
| prev_stats->runtime_max_amount_total.event_scheduler = |
| sys_stats.runtime_max_amount_total.event_scheduler; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_total.mutex = kal_max_mutex_number; |
| if (sys_stats.runtime_max_amount_total.mutex > |
| prev_stats->runtime_max_amount_total.mutex) { |
| prev_stats->runtime_max_amount_total.mutex = |
| sys_stats.runtime_max_amount_total.mutex; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_total.semaphore = kal_max_semaphore_number; |
| if (sys_stats.runtime_max_amount_total.semaphore > |
| prev_stats->runtime_max_amount_total.semaphore) { |
| prev_stats->runtime_max_amount_total.semaphore = |
| sys_stats.runtime_max_amount_total.semaphore; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_total.event_group = kal_max_eventgroup_number; |
| if (sys_stats.runtime_max_amount_total.event_group > |
| prev_stats->runtime_max_amount_total.event_group) { |
| prev_stats->runtime_max_amount_total.event_group = |
| sys_stats.runtime_max_amount_total.event_group; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_total.spinlock = kal_max_spinlock_number; |
| if (sys_stats.runtime_max_amount_total.spinlock > |
| prev_stats->runtime_max_amount_total.spinlock) { |
| prev_stats->runtime_max_amount_total.spinlock = |
| sys_stats.runtime_max_amount_total.spinlock; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_total.protect = kal_max_protect_number; |
| if (sys_stats.runtime_max_amount_total.protect > |
| prev_stats->runtime_max_amount_total.protect) { |
| prev_stats->runtime_max_amount_total.protect = |
| sys_stats.runtime_max_amount_total.protect; |
| f_modified = KAL_TRUE; |
| } |
| #endif |
| |
| |
| /* runtime resource sysmem statistics */ |
| #if defined(FURTHER_STATISTIC) && defined(__MTK_TARGET__) |
| prev_stats->primitive_size.event_scheduler = |
| sys_stats.primitive_size.event_scheduler = KAL_RT_SYSMEM_SIZE_EVSHED; |
| prev_stats->primitive_size.mutex = sys_stats.primitive_size.mutex = |
| KAL_RT_SYSMEM_SIZE_MUTEX; |
| prev_stats->primitive_size.semaphore = sys_stats.primitive_size.semaphore = |
| KAL_RT_SYSMEM_SIZE_SEM; |
| prev_stats->primitive_size.event_group = sys_stats.primitive_size.event_group = |
| KAL_RT_SYSMEM_SIZE_EVENT_GROUP; |
| prev_stats->primitive_size.kal_timer = sys_stats.primitive_size.kal_timer = |
| KAL_RT_SYSMEM_SIZE_KAL_TIMER; |
| prev_stats->primitive_size.spinlock = sys_stats.primitive_size.spinlock = |
| KAL_RT_SYSMEM_SIZE_SPINLOCK; |
| prev_stats->primitive_size.protect = sys_stats.primitive_size.protect = |
| KAL_RT_SYSMEM_SIZE_PROTECT; |
| |
| sys_stats.runtime_max_amount_system.event_scheduler = |
| system_resource_amount[KAL_RT_RESOURCE_EVSHED]; |
| if (sys_stats.runtime_max_amount_system.event_scheduler > |
| prev_stats->runtime_max_amount_system.event_scheduler) { |
| prev_stats->runtime_max_amount_system.event_scheduler = |
| sys_stats.runtime_max_amount_system.event_scheduler; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_system.mutex = |
| system_resource_amount[KAL_RT_RESOURCE_MUTEX]; |
| if (sys_stats.runtime_max_amount_system.mutex > |
| prev_stats->runtime_max_amount_system.mutex) { |
| prev_stats->runtime_max_amount_system.mutex = |
| sys_stats.runtime_max_amount_system.mutex; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_system.semaphore = |
| system_resource_amount[KAL_RT_RESOURCE_SEM]; |
| if (sys_stats.runtime_max_amount_system.semaphore > |
| prev_stats->runtime_max_amount_system.semaphore) { |
| prev_stats->runtime_max_amount_system.semaphore = |
| sys_stats.runtime_max_amount_system.semaphore; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_system.event_group = |
| system_resource_amount[KAL_RT_RESOURCE_EVENT_GROUP]; |
| if (sys_stats.runtime_max_amount_system.event_group > |
| prev_stats->runtime_max_amount_system.event_group) { |
| prev_stats->runtime_max_amount_system.event_group = |
| sys_stats.runtime_max_amount_system.event_group; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_system.kal_timer = |
| system_resource_amount[KAL_RT_RESOURCE_KAL_TIMER] - |
| system_resource_amount[KAL_RT_RESOURCE_EVSHED]; |
| if (sys_stats.runtime_max_amount_system.kal_timer > |
| prev_stats->runtime_max_amount_system.kal_timer) { |
| prev_stats->runtime_max_amount_system.kal_timer = |
| sys_stats.runtime_max_amount_system.kal_timer; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_system.spinlock = |
| system_resource_amount[KAL_RT_RESOURCE_SPINLOCK]; |
| if (sys_stats.runtime_max_amount_system.spinlock > |
| prev_stats->runtime_max_amount_system.spinlock) { |
| prev_stats->runtime_max_amount_system.spinlock = |
| sys_stats.runtime_max_amount_system.spinlock; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_system.protect = |
| system_resource_amount[KAL_RT_RESOURCE_PROTECT]; |
| if (sys_stats.runtime_max_amount_system.protect > |
| prev_stats->runtime_max_amount_system.protect) { |
| prev_stats->runtime_max_amount_system.protect = |
| sys_stats.runtime_max_amount_system.protect; |
| f_modified = KAL_TRUE; |
| } |
| |
| |
| for (i = 0; i < KALTotalTasks; i++) { |
| if (task_info_g[i].task_id == NULL) |
| continue; |
| |
| taskid = (kal_internal_taskid)(task_info_g[i].task_id); |
| |
| memcpy(&(sys_stats.runtime_max_amount_task[i].name), |
| task_info_g[i].task_name_ptr, |
| sizeof(sys_stats.runtime_max_amount_task[i].name)); |
| memcpy(&(prev_stats->runtime_max_amount_task[i].name), |
| task_info_g[i].task_name_ptr, |
| sizeof(prev_stats->runtime_max_amount_task[i].name)); |
| |
| sys_stats.runtime_max_amount_task[i].event_scheduler = |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_EVSHED]; |
| if (sys_stats.runtime_max_amount_task[i].event_scheduler > |
| prev_stats->runtime_max_amount_task[i].event_scheduler) { |
| prev_stats->runtime_max_amount_task[i].event_scheduler = |
| sys_stats.runtime_max_amount_task[i].event_scheduler; |
| f_modified = KAL_TRUE; |
| } |
| |
| sys_stats.runtime_max_amount_task[i].mutex = |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_MUTEX]; |
| if (sys_stats.runtime_max_amount_task[i].mutex > |
| prev_stats->runtime_max_amount_task[i].mutex) { |
| prev_stats->runtime_max_amount_task[i].mutex = |
| sys_stats.runtime_max_amount_task[i].mutex; |
| f_modified = KAL_TRUE; |
| } |
| |
| sys_stats.runtime_max_amount_task[i].semaphore = |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_SEM]; |
| if (sys_stats.runtime_max_amount_task[i].semaphore > |
| prev_stats->runtime_max_amount_task[i].semaphore) { |
| prev_stats->runtime_max_amount_task[i].semaphore = |
| sys_stats.runtime_max_amount_task[i].semaphore; |
| f_modified = KAL_TRUE; |
| } |
| |
| sys_stats.runtime_max_amount_task[i].event_group = |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_EVENT_GROUP]; |
| if (sys_stats.runtime_max_amount_task[i].event_group > |
| prev_stats->runtime_max_amount_task[i].event_group) { |
| prev_stats->runtime_max_amount_task[i].event_group = |
| sys_stats.runtime_max_amount_task[i].event_group; |
| f_modified = KAL_TRUE; |
| } |
| |
| sys_stats.runtime_max_amount_task[i].kal_timer = |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_KAL_TIMER] - |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_EVSHED]; |
| if (sys_stats.runtime_max_amount_task[i].kal_timer > |
| prev_stats->runtime_max_amount_task[i].kal_timer) { |
| prev_stats->runtime_max_amount_task[i].kal_timer = |
| sys_stats.runtime_max_amount_task[i].kal_timer; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_task[i].spinlock = |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_SPINLOCK]; |
| if (sys_stats.runtime_max_amount_task[i].spinlock > |
| prev_stats->runtime_max_amount_task[i].spinlock) { |
| prev_stats->runtime_max_amount_task[i].spinlock = |
| sys_stats.runtime_max_amount_task[i].spinlock; |
| f_modified = KAL_TRUE; |
| } |
| sys_stats.runtime_max_amount_task[i].protect = |
| taskid->task_runtime_resource_amount[KAL_RT_RESOURCE_PROTECT]; |
| if (sys_stats.runtime_max_amount_task[i].protect > |
| prev_stats->runtime_max_amount_task[i].protect) { |
| prev_stats->runtime_max_amount_task[i].protect = |
| sys_stats.runtime_max_amount_task[i].protect; |
| f_modified = KAL_TRUE; |
| } |
| } |
| |
| for (i = 0; i < KAL_MAX_NUM_HISRS; i++) { |
| |
| if (kal_hisr_ptrs_g[i] == NULL) |
| continue; |
| |
| memcpy(&(sys_stats.runtime_max_amount_hisr[i].name), |
| kal_hisr_ptrs_g[i]->hisr_name, |
| sizeof(sys_stats.runtime_max_amount_hisr[i].name)); |
| |
| memcpy(&(prev_stats->runtime_max_amount_hisr[i].name), |
| kal_hisr_ptrs_g[i]->hisr_name, |
| sizeof(prev_stats->runtime_max_amount_hisr[i].name)); |
| } |
| |
| /* ADM runtime statistics */ |
| for (i = 0; i < KAL_ADM_PROFILE_AMOUNT; i++) { |
| memcpy(&prev_stats->top_adm_profile[i], &top_adm[i], sizeof(ADM_PROFILE)); |
| memcpy(&sys_stats.top_adm_profile[i], &top_adm[i], sizeof(ADM_PROFILE)); |
| memcpy(&prev_stats->top_adm_user_profile[i], &top_adm_user[i], |
| sizeof(ADM_PROFILE)); |
| memcpy(&sys_stats.top_adm_user_profile[i], &top_adm_user[i], |
| sizeof(ADM_PROFILE)); |
| } |
| for (i = 0; i < KAL_ADM_PROFILE_AMOUNT_KICKED_OUT; i++) { |
| prev_stats->kicked_out_smallest_adm_user_size[i] = |
| kicked_out_smallest_adm_user_size[i]; |
| sys_stats.kicked_out_smallest_adm_user_size[i] = |
| kicked_out_smallest_adm_user_size[i]; |
| } |
| prev_stats->kicked_out_adm_user_number = kicked_out_adm_user_number; |
| sys_stats.kicked_out_adm_user_number = kicked_out_adm_user_number; |
| |
| for (i = 0; i < KAL_AFM_PROFILE_AMOUNT; i++) { |
| memcpy(&prev_stats->top_afm_profile[i], &top_afm[i], sizeof(AFM_PROFILE)); |
| memcpy(&sys_stats.top_afm_profile[i], &top_afm[i], sizeof(AFM_PROFILE)); |
| memcpy(&prev_stats->top_afm_user_profile[i], &top_afm_user[i], |
| sizeof(AFM_PROFILE)); |
| memcpy(&sys_stats.top_afm_user_profile[i], &top_afm_user[i], |
| sizeof(AFM_PROFILE)); |
| } |
| |
| #if defined(__HARD_REAL_TIME_CHECK_LOG_LEVEL__) |
| |
| for (i = 0; i < HRTQbitFailLogSize && i < HRTQbitProfileSize; i++) { |
| if (prev_stats->NVRAM_HRTQbitFailLog_VPE0_Dur[i] < |
| HRTQbitFailLog_VPE0[i].violationDuration) { |
| prev_stats->NVRAM_HRTQbitFailLog_VPE0_Dur[i] = |
| HRTQbitFailLog_VPE0[i].violationAddress; |
| prev_stats->NVRAM_HRTQbitFailLog_VPE0_Addr[i] = |
| HRTQbitFailLog_VPE0[i].violationDuration; |
| } |
| if (prev_stats->NVRAM_HRTQbitFailLog_VPE1_Dur[i] < |
| HRTQbitFailLog_VPE1[i].violationDuration) { |
| prev_stats->NVRAM_HRTQbitFailLog_VPE1_Dur[i] = |
| HRTQbitFailLog_VPE1[i].violationAddress; |
| prev_stats->NVRAM_HRTQbitFailLog_VPE1_Addr[i] = |
| HRTQbitFailLog_VPE1[i].violationDuration; |
| } |
| if (prev_stats->NVRAM_HRTQbitFailLog_VPE2_Dur[i] < |
| HRTQbitFailLog_VPE2[i].violationDuration) { |
| prev_stats->NVRAM_HRTQbitFailLog_VPE2_Dur[i] = |
| HRTQbitFailLog_VPE2[i].violationAddress; |
| prev_stats->NVRAM_HRTQbitFailLog_VPE2_Addr[i] = |
| HRTQbitFailLog_VPE2[i].violationDuration; |
| } |
| if (prev_stats->NVRAM_HRTQbitFailLog_VPE3_Dur[i] < |
| HRTQbitFailLog_VPE3[i].violationDuration) { |
| prev_stats->NVRAM_HRTQbitFailLog_VPE3_Dur[i] = |
| HRTQbitFailLog_VPE3[i].violationAddress; |
| prev_stats->NVRAM_HRTQbitFailLog_VPE3_Addr[i] = |
| HRTQbitFailLog_VPE3[i].violationDuration; |
| } |
| } |
| |
| |
| #endif |
| |
| #endif |
| |
| if (f_modified == KAL_TRUE) { |
| prev_stats->stack_stats_status = STACK_STATS_UPDATE; |
| prev_stats->total_save_count = prev_stats->total_save_count + 1; |
| } |
| |
| return f_modified; |
| } |
| |
| /************************************************************************* |
| * FUNCTION |
| * stack_query_stat_info |
| * |
| * DESCRIPTION |
| * This function gets system statistics related informations such as |
| * HISR name. |
| * |
| * PARAMETERS |
| * stat - flag to indicate the querying statsitic |
| * buff - user buffer to store informations |
| * buff_size - user buffer's size |
| * |
| * RETURNS |
| * -1 for failure, other nonzero value for success |
| * |
| *************************************************************************/ |
| kal_int32 stack_get_stats_info(kal_uint32 stats, void *buff, kal_uint32 buff_size) |
| { |
| #if !defined(KAL_ON_MERTOS) |
| kal_int32 ret; |
| kal_char * chp; |
| kal_uint32 i, j; |
| |
| |
| ret = -1; |
| |
| switch (stats) { |
| case STACK_STATS_HISR_NAME: |
| /* check buffer size */ |
| if (buff_size < |
| (num_hisr_created_g * STACK_STATS_HISR_MAX_NAME * sizeof(kal_char))) { |
| break; |
| } else { |
| ret = num_hisr_created_g * STACK_STATS_HISR_MAX_NAME * sizeof(kal_char); |
| } |
| |
| /* copy HISR names into the buffer */ |
| chp = (kal_char *)buff; |
| for (i = 0; i < KAL_MAX_NUM_HISRS; i++) { |
| if (kal_hisr_ptrs_g[i] == NULL) |
| continue; |
| |
| for (j = 0; j < STACK_STATS_HISR_MAX_NAME; j++, chp++) { |
| #if defined(KAL_ON_OSCAR) |
| *chp = '0'; |
| #endif |
| } |
| } |
| |
| break; |
| |
| default: |
| /* unknown statistic type */ |
| break; |
| } |
| |
| return ret; |
| #else |
| return 0; |
| #endif |
| } |