/****************************************************************************** * (c)2008-2009 Broadcom Corporation * * This program is the proprietary software of Broadcom Corporation and/or its licensors, * and may only be used, duplicated, modified or distributed pursuant to the terms and * conditions of a separate, written license agreement executed between you and Broadcom * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants * no license (express or implied), right to use, or waiver of any kind with respect to the * Software, and Broadcom expressly reserves all rights in and to the Software and all * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. * * Except as expressly set forth in the Authorized License, * * 1. This program, including its structure, sequence and organization, constitutes the valuable trade * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, * and to use this information only in connection with your use of Broadcom integrated circuit products. * * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF * USE OR PERFORMANCE OF THE SOFTWARE. * * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF * ANY LIMITED REMEDY. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * Created: 09/28/2009 by Jeff Fisher * * $brcm_Log: $ * * *****************************************************************************/ #ifndef BAPP_UTIL_H__ #define BAPP_UTIL_H__ #include "bstd.h" #include "bkni.h" #include "bgfx.h" #include "bos.h" #include "ministd.h" #ifdef BCM_DEBUG #define BAPP_ASSERT(expr) { \ if (!expr) \ printf("%s failed at %s:%d\n",#expr, __FILE__, __LINE__); \ } #else #define BAPP_ASSERT(expr) if (!(expr)) ; #endif #define bapp_util_malloc BKNI_Malloc #define bapp_util_free BKNI_Free #define bapp_util_memset BKNI_Memset #define bapp_util_memcpy BKNI_Memcpy #define bapp_util_strlen(x) strlen((const char*)x) #define bapp_util_strcpy(dst,src) strcpy((char*)dst,(const char*)src) #define bapp_util_strcmp(str1,str2) strcmp((const char*)str1,(const char*)str2) #define bapp_util_sleep BKNI_Sleep #define BAPP_UNUSED(x) ((void)x) #define BAPP_TICKS_PER_SECOND g_ticks_per_second typedef void (*get_str_t)(void *p_app, void *p_screen, int text_id, /* Text id */ unsigned int *p_uni_str, /* Buffer to put UNI string into */ unsigned int *str_len, /* On input the max length in words on output the actual size in characters. */ void *data /* User data */ ); /** Summary: Get ticks used to establish time deltas in the applicaiton. **/ #define bapp_util_get_ticks bapp_task_getticks #define bapp_util_getticks bapp_task_getticks /** Summary: Convert string to int value **/ int bapp_util_atoi(unsigned char *str_p, int bytes); int timeval_subtract (b_timeval *result, b_timeval *x, b_timeval *y); bool get_utc_time(unsigned int *time); bool get_local_time(unsigned int *utc_secs); bool get_mac_address(unsigned char *hw_address); bool get_hw_address(unsigned char *hw_address); char *get_unit_address_str(void); #define text_box(surf,font,x,y,w,h,msg,len,c,lspace) \ bgfx_draw_text_box(surf,x,y,w,h,(const unsigned long*)msg,len,font,c,lspace) /* Summary: Same as text box but with shadow. Description: Same as text box but with shadow. */ int text_box_shadow(bgfx_surf_t *p_surf, /* bgfx surface */ bgfx_font_t *font, /* bgfx font */ uint16_t x, /* x location in pixels */ uint16_t y, /* y location in pixels */ uint16_t width, /* width in pixels */ uint16_t height, /* height in pixels */ unsigned int *msg, /* UNI string */ unsigned int msg_len, /* Number of characters in the msg */ bgfx_pixel c_f, /* palette index for forground text*/ bgfx_pixel c_b, /* palette index for background text */ int shadow_offset, /* offset from xy to place shaddow (can be negative) */ int line_spacing /* number of vertical pixels between lines */ ); /* Summary: Draw a button. Description: Draw a button. */ void draw_button(bgfx_surf_t *p_surf, /* bgfx surface */ bgfx_font_t *font, /* bgfx font */ uint16_t x, /* x location in pixels */ uint16_t y, /* y location in pixels */ uint16_t width, /* width in pixels */ uint16_t height, /* height in pixels */ unsigned int *msg, /* UNI string */ unsigned int msg_len, /* Number of characters in the msg */ int state, /* button state, 1 - on, 0 - off */ int type /* button type, 1 - check box, 0 - menu */ ); /* Summary: Perform a "hard" chip reset if possible. */ void chip_reset(void); /** Summary: parse the mso string looking for a delimiter and return true if successful */ void parse_mso_str(char *pMSO, /* MSO string from EMM phone # field */ char *pServiceInterrupted, /* allocated buffer to return service interrupted string in */ char *pActivationSupport, /* allocated buffer to return activation support string in */ int max_len /* size of each buffer */ ); typedef struct timing_profile_t { uint32_t min; /* minimal */ uint32_t ave; /* average */ uint32_t max; /* maximum */ uint32_t diff; /* last time */ uint32_t total; /* total */ uint32_t cnt; /* cnt */ bool in_use; /* in use flag */ char name[8]; /* name */ uint32_t cur_ticks; /* current ticks */ } timing_profile_t, *p_timing_profile_t; /** Summary: initialize timing structure to use true if OK false otherwise */ bool timing_profile_init(void); /** Summary: uninitialize timing structure used true if OK false otherwise */ bool timing_profile_uninit(void); /** Summary: get timing profile object return NULL if all timing profile resources are used pointer to a timing profile resource to use */ p_timing_profile_t timing_profile_get(char *name); /** Summary: reset timing profile object true if OK false otherwise */ bool timing_profile_reset(p_timing_profile_t ptp); /** Summary: start timing profile true if OK false otherwise */ bool timing_profile_start(p_timing_profile_t ptp); /** Summary: stop timing profiling true if OK false otherwise */ bool timing_profile_stop(p_timing_profile_t ptp); /** Summary: print timing profile information true if OK false otherwise */ bool timing_profile_print(p_timing_profile_t ptp); /* Summary: Profiling utility start profiling. */ void bapp_util_start_profiling(void); /* Summary: Profiling utility stop profiling. */ void bapp_util_stop_profiling(void); #endif /* BAPP_UTIL_H__ */