| 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 | |
|---|
| 24 | /* local definitions */ |
|---|
| 25 | #define SGL_DEFAULT_CACHE_SIZE 1024 |
|---|
| 26 | /* Debug macros */ |
|---|
| 27 | #ifdef CONFIG_SGL_DEBUG |
|---|
| 28 | #define SGL_TRACE(x) ((bgfx_get_debug_level() > 1) ? (printf x) : (void) 0) |
|---|
| 29 | #define SGL_DEBUG(x) ((bgfx_get_debug_level()) ? (printf x) : (void) 0) |
|---|
| 30 | #else |
|---|
| 31 | #define SGL_TRACE(x) ((void) 0) |
|---|
| 32 | #define SGL_DEBUG(x) ((void) 0) |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | #define SGL_IO_CHECK(x) \ |
|---|
| 36 | err = x; \ |
|---|
| 37 | if (err <= 0) { \ |
|---|
| 38 | SGL_DEBUG(( "IO Failure %s <%d>:\n\t", __FILE__, __LINE__ )); \ |
|---|
| 39 | goto done; \ |
|---|
| 40 | } |
|---|
| 41 | /* Data structures stored little endian, swapping required on big endian systems only */ |
|---|
| 42 | #define SGL_SWAP_INT(x) x |
|---|
| 43 | #define SGL_SWAP_ULONG(x) x |
|---|
| 44 | |
|---|
| 45 | #define SGL_MEMSET memset |
|---|
| 46 | #define SGL_MEMCPY memcpy |
|---|
| 47 | #define SGL_MALLOC(size) malloc(size) |
|---|
| 48 | #define SGL_FREE(ptr) free(ptr) |
|---|
| 49 | |
|---|
| 50 | #ifdef __cplusplus |
|---|
| 51 | extern "C" { |
|---|
| 52 | #endif |
|---|
| 53 | /**************************************************************** |
|---|
| 54 | * Set the current debug message level. |
|---|
| 55 | * When compile time debugging is enabled this function can |
|---|
| 56 | * be used to set the verbosity of the debug messages. |
|---|
| 57 | ****************************************************************/ |
|---|
| 58 | void bgfx_set_debug_level(int level /* debug level selectively enables debugging messages */ |
|---|
| 59 | ); |
|---|
| 60 | |
|---|
| 61 | /**************************************************************** |
|---|
| 62 | * Get the current debug message level. |
|---|
| 63 | * When compile time debugging is enabled this function can |
|---|
| 64 | * be used to get the verbosity of the debug messages. |
|---|
| 65 | ****************************************************************/ |
|---|
| 66 | int bgfx_get_debug_level(); |
|---|
| 67 | |
|---|
| 68 | /**************************************************************** |
|---|
| 69 | * global sgil initialization |
|---|
| 70 | * Initialize global IO and locking support functions. |
|---|
| 71 | * prot_p must be an allocated and initialized bgfx_prot_t structure. |
|---|
| 72 | * It is important that these entities exist for the entire time |
|---|
| 73 | * SGIL is running and initialized. |
|---|
| 74 | ****************************************************************/ |
|---|
| 75 | void bgfx_config(bgfx_io_t *io_p, /* SGIL_RW read callback funtion */ |
|---|
| 76 | bgfx_prot_t *prot_p /* allocated, initialized sgil_prot_t reference */ |
|---|
| 77 | ); |
|---|
| 78 | |
|---|
| 79 | /**************************************************************** |
|---|
| 80 | * lock access to global SGIL resources |
|---|
| 81 | * Used internaly to control access to global data structures |
|---|
| 82 | * |
|---|
| 83 | ****************************************************************/ |
|---|
| 84 | void bgfx_lock(void); |
|---|
| 85 | |
|---|
| 86 | /**************************************************************** |
|---|
| 87 | * unlock access to global SGIL resources |
|---|
| 88 | * Used internaly to unlock access to global data structures |
|---|
| 89 | * |
|---|
| 90 | ****************************************************************/ |
|---|
| 91 | void bgfx_unlock(void); |
|---|
| 92 | |
|---|
| 93 | /**************************************************************** |
|---|
| 94 | * Internal function to read data |
|---|
| 95 | * Used internaly to read data from a stream. |
|---|
| 96 | * |
|---|
| 97 | ****************************************************************/ |
|---|
| 98 | long bgfx_read(void *buffer, long size, long count, void *fp ); |
|---|
| 99 | int bgfx_set( void *fp,int offset, int whence); |
|---|
| 100 | unsigned int bgfx_tell(void *fp ); |
|---|
| 101 | |
|---|
| 102 | /**************************************************************** |
|---|
| 103 | * Flush cache |
|---|
| 104 | * Used internaly perform cache flush. |
|---|
| 105 | * |
|---|
| 106 | ****************************************************************/ |
|---|
| 107 | void bgfx_cacheflush(void *ptr,int nbytes); |
|---|
| 108 | |
|---|
| 109 | #ifdef __cplusplus |
|---|
| 110 | } |
|---|
| 111 | #endif |
|---|
| 112 | |
|---|
| 113 | #endif /* __bgfx_defs_h__ */ |
|---|
| 114 | |
|---|