| 1 | /*************************************************************** |
|---|
| 2 | ** (c)2009 Broadcom Corporation |
|---|
| 3 | ** |
|---|
| 4 | ** This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | ** and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | ** conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | ** (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | ** no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | ** Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | ** intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | ** HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | ** NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | ** |
|---|
| 14 | ** Except as expressly set forth in the Authorized License, |
|---|
| 15 | ** |
|---|
| 16 | ** 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | ** secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | ** and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | ** |
|---|
| 20 | ** 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | ** AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | ** WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | ** THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | ** OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | ** LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | ** OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | ** USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | ** |
|---|
| 29 | ** 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | ** LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | ** EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | ** USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | ** THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | ** ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | ** LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | ** ANY LIMITED REMEDY. |
|---|
| 37 | ** |
|---|
| 38 | ** Created: 8/22/2002 by Jeffrey P. Fisher |
|---|
| 39 | ** |
|---|
| 40 | ** $brcm_Workfile: bgfx_defs.c $ |
|---|
| 41 | ** $brcm_Revision: Refsw_7550/3 $ |
|---|
| 42 | ** $brcm_Date: 11/26/09 11:27a $ |
|---|
| 43 | ** |
|---|
| 44 | ** Revision History: |
|---|
| 45 | ** |
|---|
| 46 | ** $brcm_Log: /nexus/lib/softgfx/src/bgfx_defs.c $ |
|---|
| 47 | ** |
|---|
| 48 | ** Refsw_7550/3 11/26/09 11:27a kagrawal |
|---|
| 49 | ** SW7550-77: Fixed compile time warning |
|---|
| 50 | ** |
|---|
| 51 | ** Refsw_7550/2 9/25/09 12:54p kagrawal |
|---|
| 52 | ** SW7550-50: Performance optimized gfx from 7003 latest |
|---|
| 53 | ** |
|---|
| 54 | ** Refsw_7550/1 9/7/09 5:04p kagrawal |
|---|
| 55 | ** SW7550-3: Initial check-in for Soft Graphics |
|---|
| 56 | ** |
|---|
| 57 | ****************************************************************/ |
|---|
| 58 | |
|---|
| 59 | /** include files **/ |
|---|
| 60 | #include "bgfx_defs.h" |
|---|
| 61 | |
|---|
| 62 | /** local types, definitions and data **/ |
|---|
| 63 | static int g_bgfx_debug_level = 1; |
|---|
| 64 | static bgfx_io_t *g_p_io = NULL; |
|---|
| 65 | static bgfx_prot_t *g_prot_t = NULL; |
|---|
| 66 | |
|---|
| 67 | /****************************************************************} |
|---|
| 68 | * INPUTS: none |
|---|
| 69 | * OUTPUTS: none |
|---|
| 70 | * RETURNS: debug level |
|---|
| 71 | * FUNCTION: get the debug level |
|---|
| 72 | * |
|---|
| 73 | ****************************************************************/ |
|---|
| 74 | |
|---|
| 75 | int bgfx_get_debug_level() |
|---|
| 76 | { |
|---|
| 77 | return g_bgfx_debug_level; |
|---|
| 78 | } |
|---|
| 79 | /****************************************************************} |
|---|
| 80 | * INPUTS: debug level |
|---|
| 81 | * OUTPUTS: none |
|---|
| 82 | * RETURNS: none |
|---|
| 83 | * FUNCTION: set the debug level |
|---|
| 84 | * |
|---|
| 85 | ****************************************************************/ |
|---|
| 86 | void bgfx_set_debug_level(int level) |
|---|
| 87 | { |
|---|
| 88 | g_bgfx_debug_level = level; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | /**************************************************************** |
|---|
| 93 | * INPUTS: none |
|---|
| 94 | * OUTPUTS: none |
|---|
| 95 | * RETURNS: none |
|---|
| 96 | * FUNCTION: Called to protect internal global structures. Supplied |
|---|
| 97 | * callback function should function as a mutual exclusion |
|---|
| 98 | * semaphore. |
|---|
| 99 | ****************************************************************/ |
|---|
| 100 | void bgfx_lock(void) |
|---|
| 101 | { |
|---|
| 102 | g_prot_t->lock(); |
|---|
| 103 | } |
|---|
| 104 | /**************************************************************** |
|---|
| 105 | * INPUTS: none |
|---|
| 106 | * OUTPUTS: none |
|---|
| 107 | * RETURNS: none |
|---|
| 108 | * FUNCTION: Called to release protection of internal global structures. |
|---|
| 109 | * Supplied callback function should release mutual exclusion |
|---|
| 110 | * semaphore. |
|---|
| 111 | ****************************************************************/ |
|---|
| 112 | void bgfx_unlock(void) |
|---|
| 113 | { |
|---|
| 114 | g_prot_t->unlock(); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | /**************************************************************** |
|---|
| 118 | * INPUTS: same as standard file IO (see fread) |
|---|
| 119 | * OUTPUTS: none |
|---|
| 120 | * RETURNS: none |
|---|
| 121 | * FUNCTION: Read data from the file stream. Supplied callback function |
|---|
| 122 | * should load count elements of size bytes into the supplied |
|---|
| 123 | * buffer and return the number of bytes actualy loaded or |
|---|
| 124 | * value < 0 when an error occurs. |
|---|
| 125 | * |
|---|
| 126 | * |
|---|
| 127 | ****************************************************************/ |
|---|
| 128 | long bgfx_read(void *buffer, long size, long count, void *fp ) |
|---|
| 129 | { |
|---|
| 130 | return g_p_io->read(buffer,size,count,fp); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | /**************************************************************** |
|---|
| 134 | * INPUTS: same as standard file IO (see fread) |
|---|
| 135 | * OUTPUTS: none |
|---|
| 136 | * RETURNS: none |
|---|
| 137 | * FUNCTION: Read data from the file stream. Supplied callback function |
|---|
| 138 | * should load count elements of size bytes into the supplied |
|---|
| 139 | * buffer and return the number of bytes actualy loaded or |
|---|
| 140 | * value < 0 when an error occurs. |
|---|
| 141 | * |
|---|
| 142 | * |
|---|
| 143 | ****************************************************************/ |
|---|
| 144 | unsigned int bgfx_tell(void *fp ) |
|---|
| 145 | { |
|---|
| 146 | return g_p_io->tell(fp); |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | /**************************************************************** |
|---|
| 150 | * INPUTS: same as standard file IO (see fseek) |
|---|
| 151 | * OUTPUTS: none |
|---|
| 152 | * RETURNS: none |
|---|
| 153 | * FUNCTION: Set the current file pointer. (only uses SEEK_SET = 0) |
|---|
| 154 | * |
|---|
| 155 | * |
|---|
| 156 | ****************************************************************/ |
|---|
| 157 | int bgfx_set( void *fp,int offset, int whence) |
|---|
| 158 | { |
|---|
| 159 | return g_p_io->set(fp, offset, whence); |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | /****************************************************************} |
|---|
| 163 | * INPUTS: io and protection function structures |
|---|
| 164 | * OUTPUTS: none |
|---|
| 165 | * RETURNS: non-zero on failure |
|---|
| 166 | * FUNCTION: initialize sgl, primarily for protection of freetype global |
|---|
| 167 | * structures. |
|---|
| 168 | * |
|---|
| 169 | ****************************************************************/ |
|---|
| 170 | void bgfx_config(bgfx_io_t *io_p,bgfx_prot_t *prot_p) |
|---|
| 171 | { |
|---|
| 172 | g_p_io = io_p; |
|---|
| 173 | g_prot_t = prot_p; |
|---|
| 174 | } |
|---|
| 175 | /****************************************************************} |
|---|
| 176 | * INPUTS: ptr - address to flush |
|---|
| 177 | * nbytes - number of bytes |
|---|
| 178 | * OUTPUTS: none |
|---|
| 179 | * RETURNS: none |
|---|
| 180 | * FUNCTION: Perform a cache flush for the address and size specified. |
|---|
| 181 | * |
|---|
| 182 | ****************************************************************/ |
|---|
| 183 | void bgfx_cacheflush(void *ptr,int nbytes) |
|---|
| 184 | { |
|---|
| 185 | /* not implemented in uclibc cacheflush(ptr,nbytes,DCACHE); |
|---|
| 186 | BROKEN syscall(__NR_cacheflush,ptr,nbytes,DCACHE); |
|---|
| 187 | */ |
|---|
| 188 | BSTD_UNUSED(ptr); |
|---|
| 189 | BSTD_UNUSED(nbytes); |
|---|
| 190 | } |
|---|
| 191 | |
|---|