| 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 | /** include files **/ |
|---|
| 20 | #include "bgfx_defs.h" |
|---|
| 21 | |
|---|
| 22 | /** local types, definitions and data **/ |
|---|
| 23 | static int g_bgfx_debug_level = 1; |
|---|
| 24 | static bgfx_io_t *g_p_io = NULL; |
|---|
| 25 | static bgfx_prot_t *g_prot_t = NULL; |
|---|
| 26 | |
|---|
| 27 | /****************************************************************} |
|---|
| 28 | * INPUTS: none |
|---|
| 29 | * OUTPUTS: none |
|---|
| 30 | * RETURNS: debug level |
|---|
| 31 | * FUNCTION: get the debug level |
|---|
| 32 | * |
|---|
| 33 | ****************************************************************/ |
|---|
| 34 | |
|---|
| 35 | int bgfx_get_debug_level() |
|---|
| 36 | { |
|---|
| 37 | return g_bgfx_debug_level; |
|---|
| 38 | } |
|---|
| 39 | /****************************************************************} |
|---|
| 40 | * INPUTS: debug level |
|---|
| 41 | * OUTPUTS: none |
|---|
| 42 | * RETURNS: none |
|---|
| 43 | * FUNCTION: set the debug level |
|---|
| 44 | * |
|---|
| 45 | ****************************************************************/ |
|---|
| 46 | void bgfx_set_debug_level(int level) |
|---|
| 47 | { |
|---|
| 48 | g_bgfx_debug_level = level; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | /**************************************************************** |
|---|
| 53 | * INPUTS: none |
|---|
| 54 | * OUTPUTS: none |
|---|
| 55 | * RETURNS: none |
|---|
| 56 | * FUNCTION: Called to protect internal global structures. Supplied |
|---|
| 57 | * callback function should function as a mutual exclusion |
|---|
| 58 | * semaphore. |
|---|
| 59 | ****************************************************************/ |
|---|
| 60 | void bgfx_lock(void) |
|---|
| 61 | { |
|---|
| 62 | g_prot_t->lock(); |
|---|
| 63 | } |
|---|
| 64 | /**************************************************************** |
|---|
| 65 | * INPUTS: none |
|---|
| 66 | * OUTPUTS: none |
|---|
| 67 | * RETURNS: none |
|---|
| 68 | * FUNCTION: Called to release protection of internal global structures. |
|---|
| 69 | * Supplied callback function should release mutual exclusion |
|---|
| 70 | * semaphore. |
|---|
| 71 | ****************************************************************/ |
|---|
| 72 | void bgfx_unlock(void) |
|---|
| 73 | { |
|---|
| 74 | g_prot_t->unlock(); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | /**************************************************************** |
|---|
| 78 | * INPUTS: same as standard file IO (see fread) |
|---|
| 79 | * OUTPUTS: none |
|---|
| 80 | * RETURNS: none |
|---|
| 81 | * FUNCTION: Read data from the file stream. Supplied callback function |
|---|
| 82 | * should load count elements of size bytes into the supplied |
|---|
| 83 | * buffer and return the number of bytes actualy loaded or |
|---|
| 84 | * value < 0 when an error occurs. |
|---|
| 85 | * |
|---|
| 86 | * |
|---|
| 87 | ****************************************************************/ |
|---|
| 88 | long bgfx_read(void *buffer, long size, long count, void *fp ) |
|---|
| 89 | { |
|---|
| 90 | return g_p_io->read(buffer,size,count,fp); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | /**************************************************************** |
|---|
| 94 | * INPUTS: same as standard file IO (see fread) |
|---|
| 95 | * OUTPUTS: none |
|---|
| 96 | * RETURNS: none |
|---|
| 97 | * FUNCTION: Read data from the file stream. Supplied callback function |
|---|
| 98 | * should load count elements of size bytes into the supplied |
|---|
| 99 | * buffer and return the number of bytes actualy loaded or |
|---|
| 100 | * value < 0 when an error occurs. |
|---|
| 101 | * |
|---|
| 102 | * |
|---|
| 103 | ****************************************************************/ |
|---|
| 104 | unsigned int bgfx_tell(void *fp ) |
|---|
| 105 | { |
|---|
| 106 | return g_p_io->tell(fp); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | /**************************************************************** |
|---|
| 110 | * INPUTS: same as standard file IO (see fseek) |
|---|
| 111 | * OUTPUTS: none |
|---|
| 112 | * RETURNS: none |
|---|
| 113 | * FUNCTION: Set the current file pointer. (only uses SEEK_SET = 0) |
|---|
| 114 | * |
|---|
| 115 | * |
|---|
| 116 | ****************************************************************/ |
|---|
| 117 | int bgfx_set( void *fp,int offset, int whence) |
|---|
| 118 | { |
|---|
| 119 | return g_p_io->set(fp, offset, whence); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | /****************************************************************} |
|---|
| 123 | * INPUTS: io and protection function structures |
|---|
| 124 | * OUTPUTS: none |
|---|
| 125 | * RETURNS: non-zero on failure |
|---|
| 126 | * FUNCTION: initialize sgl, primarily for protection of freetype global |
|---|
| 127 | * structures. |
|---|
| 128 | * |
|---|
| 129 | ****************************************************************/ |
|---|
| 130 | void bgfx_config(bgfx_io_t *io_p,bgfx_prot_t *prot_p) |
|---|
| 131 | { |
|---|
| 132 | g_p_io = io_p; |
|---|
| 133 | g_prot_t = prot_p; |
|---|
| 134 | } |
|---|
| 135 | /****************************************************************} |
|---|
| 136 | * INPUTS: ptr - address to flush |
|---|
| 137 | * nbytes - number of bytes |
|---|
| 138 | * OUTPUTS: none |
|---|
| 139 | * RETURNS: none |
|---|
| 140 | * FUNCTION: Perform a cache flush for the address and size specified. |
|---|
| 141 | * |
|---|
| 142 | ****************************************************************/ |
|---|
| 143 | void bgfx_cacheflush(void *ptr,int nbytes) |
|---|
| 144 | { |
|---|
| 145 | /* not implemented in uclibc cacheflush(ptr,nbytes,DCACHE); |
|---|
| 146 | BROKEN syscall(__NR_cacheflush,ptr,nbytes,DCACHE); |
|---|
| 147 | */ |
|---|
| 148 | } |
|---|
| 149 | |
|---|