blob: 32fcefc6e396ebe169ecc9766684f69b493c234f [file] [log] [blame]
/*****************************************************************************
* 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_debug.h
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file would be used as a kal header file for the compilation
* of any module using debug version of kal.
*
* 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!
*------------------------------------------------------------------------------
* 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
*********************************************************************/
#ifndef _KAL_DEBUG_H
#define _KAL_DEBUG_H
#include "kal_internal_def.h"
/*************************************************************************
* Constant definition and check
*************************************************************************/
#if defined(DEBUG_KAL) && defined(RELEASE_KAL)
#error "Only one of DEBUG_KAL and RELEASE_KAL can be defined"
#endif
#if !defined(DEBUG_KAL) && !defined(RELEASE_KAL)
#error "At least one of DEBUG_KAL or RELEASE_KAL should be defined"
#endif
#if !defined(__KAL_ASSERT_LEVEL4__) && !defined(__KAL_ASSERT_LEVEL3__) && !defined(__KAL_ASSERT_LEVEL2__) && !defined(__KAL_ASSERT_LEVEL1__) && !defined(__KAL_ASSERT_LEVEL0__)
#error "At least one of KAL_ASSERT_LEVEL4 or KAL_ASSERT_LEVEL3 or KAL_ASSERT_LEVEL2 or KAL_ASSERT_LEVEL1 or KAL_ASSERT_LEVEL0 should be defined"
#endif
/*************************************************************************
* Include the common header file
*************************************************************************/
#include "kal_public_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { KAL_MUTEX_GIVEN, KAL_MUTEX_TAKEN } kal_mutex_state;
#if defined(DEBUG_KAL) && defined(DEBUG_DEADLOCKS)
typedef struct kal_lock_wait_info_struct {
kal_uint32 *waiting_lock_p;
kal_uint32 waiting_start_time;
void * context;
} kal_lock_wait_info_type;
void kal_set_lock_waiting_info(void *context, kal_uint32 *lock);
void kal_clear_lock_waiting_info(void *context);
kal_lock_wait_info_type *kal_get_lock_waiting_info(void *context);
#endif
#if defined (__MTK_TARGET__)
typedef enum {
KAL_WP_W = 1,
KAL_WP_R,
KAL_WP_RW
} kal_wp_type;
#if defined __MD97__ && !defined MT6297_IA
#define KAL_WP_MASK_CACHE_LINE (0x4) /* Mask bits 4:0 */
#define KAL_WATCHPOINT_7_SET(addr, type, mask) \
do {\
__asm__ __volatile__ (\
".set push;"\
".set noreorder;"\
"mtc0 %0, $18, 7;"\
"sll $t1, %2, 22;"\
"li $t0, 1279;"\
"ins $t1, $t0, 11, 11;"\
"ins $t1, %1, 0, 2;"\
"mtc0 $t1, $19, 7;"\
"ehb;"\
".set pop;"\
: \
: "r"(addr), "r"(type), "r"(mask)\
: "$t0", "$t1"\
);\
} while(0)
#define KAL_STACK_PROTECT(stack_ptr) KAL_WATCHPOINT_7_SET(stack_ptr, KAL_WP_W, KAL_WP_MASK_CACHE_LINE);
#else /* defined __MD97__ && !defined MT6297_IA */
#define KAL_WP_MASK_CACHE_LINE (0x3) /* Mask address bits 4:3, WatchLo already
uses bits 2:0 for I/R/W config -> bits 4:0 are masked */
#ifndef __mips16
#define KAL_WATCHPOINT_3_SET(addr, type, mask) \
do {\
__asm__ __volatile__ (\
".set push;"\
".set noreorder;"\
"move $t0, %0;"\
"ins $t0, %1, 0, 2;"\
"sll $t1, %2, 3;"\
"mtc0 $t0, $18, 3;"\
"mtc0 $t1, $19, 3;"\
"ehb;"\
".set pop;"\
: \
: "r"(addr), "r"(type), "r"(mask)\
: "$t0", "$t1"\
);\
} while(0)
#else
#define KAL_WATCHPOINT_3_SET(addr, type, mask) \
do {\
__asm__ __volatile__ (\
".set push;"\
".set noreorder;"\
"move $2, %0;"\
"ins $2, %1, 0, 2;"\
"sll $3, %2, 3;"\
"mtc0 $2, $18, 3;"\
"mtc0 $3, $19, 3;"\
"ehb;"\
".set pop;"\
: \
: "d"(addr), "d"(type), "d"(mask)\
: "$2", "$3"\
);\
} while(0)
#endif
#define KAL_STACK_PROTECT(stack_ptr) KAL_WATCHPOINT_3_SET(stack_ptr, KAL_WP_W, KAL_WP_MASK_CACHE_LINE);
#endif /* defined __MD97__ && !defined MT6297_IA */
#endif /* defined (__MTK_TARGET__) */
#if defined(DEBUG_KAL)
/*************************************************************************
* Macros Without Parameters
*************************************************************************/
#ifdef DEBUG_BUF1
#define KAL_HEAD_PRINT_SIZE 4
#define KAL_FOOT_PRINT_SIZE 2
#define KAL_FOOT_BUFF_ID_SIZE 2
#define KAL_FOOT2_PRINT_SIZE 4
#define KAL_BUFF_HEADER_SIZE KAL_HEAD_PRINT_SIZE
#define KAL_BUFF_FOOTER_SIZE (KAL_FOOT_PRINT_SIZE + KAL_FOOT_BUFF_ID_SIZE)
#endif
#ifdef DEBUG_BUF2
#define KAL_HEAD_PRINT_SIZE 4
#define KAL_FOOT_PRINT_SIZE 2
#define KAL_FOOT_BUFF_ID_SIZE 2
#define KAL_FOOT2_PRINT_SIZE 4
#define KAL_TASKID_PTR_SIZE 4
#define KAL_BUFF_HEADER_SIZE (KAL_HEAD_PRINT_SIZE + KAL_TASKID_PTR_SIZE)
#define KAL_BUFF_FOOTER_SIZE (KAL_FOOT_PRINT_SIZE + KAL_FOOT_BUFF_ID_SIZE)
#define KAL_GET_TASKID_PTR_IN_BUFF_HEADER(buf_ptr) \
((kal_char *)buf_ptr - KAL_TASKID_PTR_SIZE)
#endif
#if defined(DEBUG_BUF1) || defined(DEBUG_BUF2)
#define KAL_GET_HEADER_PTR_IN_BUFF_HEADER(buf_ptr) \
((kal_char *)buf_ptr - KAL_BUFF_HEADER_SIZE)
#if defined(__MTK_TARGET__)
#define SENSITIVE_BUFF_FLAG (0x1 << 1) /* bit 1 of header is the sensitive flag */
#endif
#endif
/*************************************************************************
* Define exported function prototype
*************************************************************************/
extern void kal_set_free_pattern(void *user_ptr, kal_uint32 buff_size);
extern void *kal_is_freepattern(void *user_ptr, kal_uint32 buff_size);
#if defined(DEBUG_BUF1) || defined(DEBUG_BUF2)
extern void kal_init_buff_header_footer(void *buff_pt, kal_poolid ext_pool_id,
kal_uint16 buff_id);
extern void kal_update_buff_header_footer(kal_poolid pool_id, void *buff_ptr,
kal_taskid ext_task_id,
kal_uint32 buff_size,
kal_uint16 buff_number);
extern void kal_is_valid_buffer(void *buff_ptr, kal_uint16 buff_number);
#endif /* DEBUG_BUF1 ||DEBUG_BUF2 */
#if defined(DEBUG_BUF3)
extern void kal_check_free_pattern(void *user_ptr, kal_uint32 buff_size);
extern void kal_set_alloc_pattern(void *user_ptr, kal_uint32 user_size,
kal_uint32 buff_size);
extern void kal_check_frag_pattern(void *user_ptr, kal_uint32 user_size,
kal_uint32 buff_size);
#endif /* DEBUG_BUF3 */
#endif /* DEBUG_KAL */
/*************************************************************************
* Define Console or Log Print Functions
*************************************************************************/
extern void stack_print(char *string);
#ifdef KAL_ON_OSCAR
#define system_print osc_platform_print_msg
#else
#if !defined(__FUE__)
#define system_print(s) stack_print(s)
#else
#define system_print(s) fue_dbg_print(s)
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _KAL_DEBUG_H */