| 1 | /*************************************************************** |
|---|
| 2 | ** |
|---|
| 3 | ** Broadcom Corp. Confidential |
|---|
| 4 | ** Copyright 2002 Broadcom Corp. All Rights Reserved. |
|---|
| 5 | ** |
|---|
| 6 | ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED |
|---|
| 7 | ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. |
|---|
| 8 | ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT |
|---|
| 9 | ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 10 | ** |
|---|
| 11 | ** Description: SGIL platform definitions |
|---|
| 12 | ** |
|---|
| 13 | ** Created: 8/22/2002 by Jeffrey P. Fisher |
|---|
| 14 | ** |
|---|
| 15 | ** |
|---|
| 16 | ** |
|---|
| 17 | ****************************************************************/ |
|---|
| 18 | |
|---|
| 19 | #ifndef __bgfx_defs_h__ |
|---|
| 20 | #define __bgfx_defs_h__ |
|---|
| 21 | |
|---|
| 22 | #include "bgfx_types.h" |
|---|
| 23 | #include "bapp_util.h" |
|---|
| 24 | |
|---|
| 25 | /* local definitions */ |
|---|
| 26 | #define BGFX_DEFAULT_CACHE_SIZE 1024 |
|---|
| 27 | /* Debug macros */ |
|---|
| 28 | #ifdef CONFIG_BGFX_DEBUG |
|---|
| 29 | #define BGFX_TRACE(x) ((bgfx_get_debug_level() > 1) ? (printf x) : (void) 0) |
|---|
| 30 | #define BGFX_DEBUG(x) ((bgfx_get_debug_level()) ? (printf x) : (void) 0) |
|---|
| 31 | #else |
|---|
| 32 | #define BGFX_TRACE(x) ((void) 0) |
|---|
| 33 | #define BGFX_DEBUG(x) ((void) 0) |
|---|
| 34 | #endif |
|---|
| 35 | |
|---|
| 36 | #define BGFX_IO_CHECK(x) \ |
|---|
| 37 | err = x; \ |
|---|
| 38 | if (err <= 0) { \ |
|---|
| 39 | BGFX_DEBUG(( "IO Failure %s <%d>:\n\t", __FILE__, __LINE__ )); \ |
|---|
| 40 | goto done; \ |
|---|
| 41 | } |
|---|
| 42 | /* Data structures stored little endian, swapping required on big endian systems only */ |
|---|
| 43 | #define BGFX_SWAP_INT(x) x |
|---|
| 44 | #define BGFX_SWAP_ULONG(x) x |
|---|
| 45 | |
|---|
| 46 | #define BGFX_MEMSET bapp_util_memset |
|---|
| 47 | #define BGFX_MEMCPY bapp_util_memcpy |
|---|
| 48 | #define BGFX_MALLOC(size) bapp_util_malloc(size) |
|---|
| 49 | #define BGFX_FREE(ptr) bapp_util_free(ptr) |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | #ifdef __GNUC__ |
|---|
| 53 | #define inline __inline__ |
|---|
| 54 | #endif |
|---|
| 55 | |
|---|
| 56 | #ifdef __cplusplus |
|---|
| 57 | extern "C" { |
|---|
| 58 | #endif |
|---|
| 59 | /**************************************************************** |
|---|
| 60 | * Set the current debug message level. |
|---|
| 61 | * When compile time debugging is enabled this function can |
|---|
| 62 | * be used to set the verbosity of the debug messages. |
|---|
| 63 | ****************************************************************/ |
|---|
| 64 | void bgfx_set_debug_level(int level /* debug level selectively enables debugging messages */ |
|---|
| 65 | ); |
|---|
| 66 | |
|---|
| 67 | /**************************************************************** |
|---|
| 68 | * Get the current debug message level. |
|---|
| 69 | * When compile time debugging is enabled this function can |
|---|
| 70 | * be used to get the verbosity of the debug messages. |
|---|
| 71 | ****************************************************************/ |
|---|
| 72 | int bgfx_get_debug_level(void); |
|---|
| 73 | |
|---|
| 74 | /**************************************************************** |
|---|
| 75 | * global sgil initialization |
|---|
| 76 | * Initialize global IO and locking support functions. |
|---|
| 77 | * prot_p must be an allocated and initialized bgfx_prot_t structure. |
|---|
| 78 | * It is important that these entities exist for the entire time |
|---|
| 79 | * SGIL is running and initialized. |
|---|
| 80 | ****************************************************************/ |
|---|
| 81 | void bgfx_config(bgfx_io_t *io_p, /* SGIL_RW read callback funtion */ |
|---|
| 82 | bgfx_prot_t *prot_p /* allocated, initialized sgil_prot_t reference */ |
|---|
| 83 | ); |
|---|
| 84 | |
|---|
| 85 | /**************************************************************** |
|---|
| 86 | * lock access to global SGIL resources |
|---|
| 87 | * Used internaly to control access to global data structures |
|---|
| 88 | * |
|---|
| 89 | ****************************************************************/ |
|---|
| 90 | void bgfx_lock(void); |
|---|
| 91 | |
|---|
| 92 | /**************************************************************** |
|---|
| 93 | * unlock access to global SGIL resources |
|---|
| 94 | * Used internaly to unlock access to global data structures |
|---|
| 95 | * |
|---|
| 96 | ****************************************************************/ |
|---|
| 97 | void bgfx_unlock(void); |
|---|
| 98 | |
|---|
| 99 | /**************************************************************** |
|---|
| 100 | * Internal function to read data |
|---|
| 101 | * Used internaly to read data from a stream. |
|---|
| 102 | * |
|---|
| 103 | ****************************************************************/ |
|---|
| 104 | long bgfx_read(void *buffer, long size, long count, void *fp ); |
|---|
| 105 | int bgfx_set( void *fp,int offset, int whence); |
|---|
| 106 | unsigned int bgfx_tell(void *fp ); |
|---|
| 107 | |
|---|
| 108 | /**************************************************************** |
|---|
| 109 | * Flush cache |
|---|
| 110 | * Used internaly perform cache flush. |
|---|
| 111 | * |
|---|
| 112 | ****************************************************************/ |
|---|
| 113 | void bgfx_cacheflush(void *ptr,int nbytes); |
|---|
| 114 | |
|---|
| 115 | #ifdef __cplusplus |
|---|
| 116 | } |
|---|
| 117 | #endif |
|---|
| 118 | |
|---|
| 119 | #endif /* __bgfx_defs_h__ */ |
|---|
| 120 | |
|---|