| 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 BGFX_DEFAULT_CACHE_SIZE 1024 |
|---|
| 26 | /* Debug macros */ |
|---|
| 27 | #ifdef CONFIG_BGFX_DEBUG |
|---|
| 28 | #define BGFX_TRACE(x) ((bgfx_get_debug_level() > 1) ? (printf x) : (void) 0) |
|---|
| 29 | #define BGFX_DEBUG(x) ((bgfx_get_debug_level()) ? (printf x) : (void) 0) |
|---|
| 30 | #else |
|---|
| 31 | #define BGFX_TRACE(x) ((void) 0) |
|---|
| 32 | #define BGFX_DEBUG(x) ((void) 0) |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | #define BGFX_IO_CHECK(x) \ |
|---|
| 36 | err = x; \ |
|---|
| 37 | if (err <= 0) { \ |
|---|
| 38 | BGFX_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 BGFX_SWAP_INT(x) x |
|---|
| 43 | #define BGFX_SWAP_ULONG(x) x |
|---|
| 44 | |
|---|
| 45 | #define BGFX_MEMSET BKNI_Memset |
|---|
| 46 | #define BGFX_MEMCPY BKNI_Memcpy |
|---|
| 47 | #define BGFX_MALLOC(size) BKNI_Malloc(size) |
|---|
| 48 | #define BGFX_FREE(ptr) BKNI_Free(ptr) |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | typedef struct bin_read_t |
|---|
| 52 | { |
|---|
| 53 | unsigned char *data; |
|---|
| 54 | unsigned int size; |
|---|
| 55 | unsigned int cnt; |
|---|
| 56 | }bin_read_t; |
|---|
| 57 | |
|---|
| 58 | #ifdef __GNUC__ |
|---|
| 59 | #define inline __inline__ |
|---|
| 60 | #endif |
|---|
| 61 | |
|---|
| 62 | #ifdef __cplusplus |
|---|
| 63 | extern "C" { |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|
| 66 | /* |
|---|
| 67 | Summary: |
|---|
| 68 | Utility IO function. |
|---|
| 69 | Description: |
|---|
| 70 | Utility IO function to be used for pseudo IO. |
|---|
| 71 | */ |
|---|
| 72 | |
|---|
| 73 | int bin_read( void *buffer, int size, int count, void *fp ); |
|---|
| 74 | int bin_set(void *fp, int offset, int whence ); |
|---|
| 75 | unsigned int bin_tell(void *fp ); |
|---|
| 76 | /**************************************************************** |
|---|
| 77 | * Set the current debug message level. |
|---|
| 78 | * When compile time debugging is enabled this function can |
|---|
| 79 | * be used to set the verbosity of the debug messages. |
|---|
| 80 | ****************************************************************/ |
|---|
| 81 | void bgfx_set_debug_level(int level /* debug level selectively enables debugging messages */ |
|---|
| 82 | ); |
|---|
| 83 | |
|---|
| 84 | /**************************************************************** |
|---|
| 85 | * Get the current debug message level. |
|---|
| 86 | * When compile time debugging is enabled this function can |
|---|
| 87 | * be used to get the verbosity of the debug messages. |
|---|
| 88 | ****************************************************************/ |
|---|
| 89 | int bgfx_get_debug_level(void); |
|---|
| 90 | |
|---|
| 91 | /**************************************************************** |
|---|
| 92 | * global sgil initialization |
|---|
| 93 | * Initialize global IO and locking support functions. |
|---|
| 94 | * prot_p must be an allocated and initialized bgfx_prot_t structure. |
|---|
| 95 | * It is important that these entities exist for the entire time |
|---|
| 96 | * SGIL is running and initialized. |
|---|
| 97 | ****************************************************************/ |
|---|
| 98 | void bgfx_config(bgfx_io_t *io_p, /* io callback functions */ |
|---|
| 99 | bgfx_prot_t *prot_p, /* allocated, initialized sgil_prot_t */ |
|---|
| 100 | bgfx_hw_t *hw_p /* hw acceleration callbacks */ |
|---|
| 101 | ); |
|---|
| 102 | |
|---|
| 103 | /**************************************************************** |
|---|
| 104 | * lock access to global SGIL resources |
|---|
| 105 | * Used internaly to control access to global data structures |
|---|
| 106 | * |
|---|
| 107 | ****************************************************************/ |
|---|
| 108 | void bgfx_lock(void); |
|---|
| 109 | |
|---|
| 110 | /**************************************************************** |
|---|
| 111 | * unlock access to global SGIL resources |
|---|
| 112 | * Used internaly to unlock access to global data structures |
|---|
| 113 | * |
|---|
| 114 | ****************************************************************/ |
|---|
| 115 | void bgfx_unlock(void); |
|---|
| 116 | |
|---|
| 117 | /**************************************************************** |
|---|
| 118 | * Internal function to read data |
|---|
| 119 | * Used internaly to read data from a stream. |
|---|
| 120 | * |
|---|
| 121 | ****************************************************************/ |
|---|
| 122 | long bgfx_read(void *buffer, long size, long count, void *fp ); |
|---|
| 123 | int bgfx_set( void *fp,int offset, int whence); |
|---|
| 124 | unsigned int bgfx_tell(void *fp ); |
|---|
| 125 | |
|---|
| 126 | /**************************************************************** |
|---|
| 127 | * Flush cache |
|---|
| 128 | * Used internaly perform cache flush. |
|---|
| 129 | * |
|---|
| 130 | ****************************************************************/ |
|---|
| 131 | void bgfx_cacheflush(void *ptr,int nbytes); |
|---|
| 132 | |
|---|
| 133 | /**************************************************************** |
|---|
| 134 | * HW acceleration functions. |
|---|
| 135 | * |
|---|
| 136 | ****************************************************************/ |
|---|
| 137 | int bgfx_hw_fill( void *surf, bgfx_rect *r, uint32_t pixel ); |
|---|
| 138 | int bgfx_hw_blit( void *src_surf, bgfx_rect *src_r, |
|---|
| 139 | void *dst_surf, bgfx_rect *dst_r, |
|---|
| 140 | void *out_surf, bgfx_rect *out_r ); |
|---|
| 141 | bgfx_hw_t *bgfx_hw_get_fcn(void); |
|---|
| 142 | int bgfx_hw_surf_create(uint32_t width, |
|---|
| 143 | uint32_t height, |
|---|
| 144 | int format, |
|---|
| 145 | uint8_t **mem, |
|---|
| 146 | uint32_t *pitch, |
|---|
| 147 | void **p_settop_surf ); |
|---|
| 148 | void bgfx_hw_surf_destroy(void *p_settop_surf ); |
|---|
| 149 | |
|---|
| 150 | #ifdef __cplusplus |
|---|
| 151 | } |
|---|
| 152 | #endif |
|---|
| 153 | |
|---|
| 154 | #endif /* __bgfx_defs_h__ */ |
|---|
| 155 | |
|---|