/****************************************************************************** * (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 #include #include "bapp_task.h" #include "bgfx.h" #ifndef LINUX #define GETTIMEOFDAY(tv) gettimeofday(tv) #else #include #define GETTIMEOFDAY(tv) gettimeofday(tv,NULL) #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 struct bin_read_t { unsigned char *data; unsigned int size; unsigned int cnt; }bin_read_t; /* Summary: Utility IO function. Description: Utility IO function to be used for pseudo IO. */ int bin_read( void *buffer, int size, int count, void *fp ); int bin_set(void *fp, int offset, int whence ); unsigned int bin_tell(void *fp ); /** 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 (struct timeval *result, struct timeval *x, struct 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); struct utc_tm { int tm_sec; /* Seconds. [0-60] (1 leap second) */ int tm_min; /* Minutes. [0-59] */ int tm_hour; /* Hours. [0-23] */ int tm_mday; /* Day. [1-31] */ int tm_mon; /* Month. [0-11] */ int tm_year; /* Year - 1980. */ int tm_wday; /* Day of week. [0-6] */ int tm_yday; /* Days in year.[0-365] */ }; void utctime(unsigned int secs,struct utc_tm *p_tm); #endif /* BAPP_UTIL_H__ */