#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "spebase.h"
#include "lib_builtin.h"
#include "default_c99_handler.h"
#include "default_posix1_handler.h"
#include "default_libea_handler.h"
Go to the source code of this file.
Defines | |
#define | HANDLER_IDX(x) (x & 0xff) |
Functions | |
int | _base_spe_callback_handler_register (void *handler, unsigned int callnum, unsigned int mode) |
int | _base_spe_callback_handler_deregister (unsigned int callnum) |
void * | _base_spe_callback_handler_query (unsigned int callnum) |
int | _base_spe_handle_library_callback (struct spe_context *spe, int callnum, unsigned int npc) |
#define HANDLER_IDX | ( | x | ) | (x & 0xff) |
Definition at line 29 of file lib_builtin.c.
int _base_spe_callback_handler_deregister | ( | unsigned int | callnum | ) |
unregister a handler function for the specified number NOTE: unregistering a handler from call zero and one is ignored.
Definition at line 78 of file lib_builtin.c.
References MAX_CALLNUM, and RESERVED.
00079 { 00080 errno = 0; 00081 if (callnum > MAX_CALLNUM) { 00082 errno = EINVAL; 00083 return -1; 00084 } 00085 if (callnum < RESERVED) { 00086 errno = EACCES; 00087 return -1; 00088 } 00089 if (handlers[callnum] == NULL) { 00090 errno = ESRCH; 00091 return -1; 00092 } 00093 00094 handlers[callnum] = NULL; 00095 return 0; 00096 }
void* _base_spe_callback_handler_query | ( | unsigned int | callnum | ) |
query a handler function for the specified number
Definition at line 98 of file lib_builtin.c.
References MAX_CALLNUM.
00099 { 00100 errno = 0; 00101 00102 if (callnum > MAX_CALLNUM) { 00103 errno = EINVAL; 00104 return NULL; 00105 } 00106 if (handlers[callnum] == NULL) { 00107 errno = ESRCH; 00108 return NULL; 00109 } 00110 return handlers[callnum]; 00111 }
int _base_spe_callback_handler_register | ( | void * | handler, | |
unsigned int | callnum, | |||
unsigned int | mode | |||
) |
register a handler function for the specified number NOTE: registering a handler to call zero and one is ignored.
Definition at line 40 of file lib_builtin.c.
References MAX_CALLNUM, RESERVED, SPE_CALLBACK_NEW, and SPE_CALLBACK_UPDATE.
00041 { 00042 errno = 0; 00043 00044 if (callnum > MAX_CALLNUM) { 00045 errno = EINVAL; 00046 return -1; 00047 } 00048 00049 switch(mode){ 00050 case SPE_CALLBACK_NEW: 00051 if (callnum < RESERVED) { 00052 errno = EACCES; 00053 return -1; 00054 } 00055 if (handlers[callnum] != NULL) { 00056 errno = EACCES; 00057 return -1; 00058 } 00059 handlers[callnum] = handler; 00060 break; 00061 00062 case SPE_CALLBACK_UPDATE: 00063 if (handlers[callnum] == NULL) { 00064 errno = ESRCH; 00065 return -1; 00066 } 00067 handlers[callnum] = handler; 00068 break; 00069 default: 00070 errno = EINVAL; 00071 return -1; 00072 break; 00073 } 00074 return 0; 00075 00076 }
int _base_spe_handle_library_callback | ( | struct spe_context * | spe, | |
int | callnum, | |||
unsigned int | npc | |||
) |
Definition at line 113 of file lib_builtin.c.
References spe_context::base_private, DEBUG_PRINTF, spe_context_base_priv::flags, spe_context_base_priv::mem_mmap_base, SPE_EMULATE_PARAM_BUFFER, and SPE_ISOLATE_EMULATE.
Referenced by _base_spe_context_run().
00115 { 00116 int (*handler)(void *, unsigned int); 00117 int rc; 00118 00119 errno = 0; 00120 if (!handlers[callnum]) { 00121 DEBUG_PRINTF ("No SPE library handler registered for this call.\n"); 00122 errno=ENOSYS; 00123 return -1; 00124 } 00125 00126 handler=handlers[callnum]; 00127 00128 /* For emulated isolation mode, position the 00129 * npc so that the buffer for the PPE-assisted 00130 * library calls can be accessed. */ 00131 if (spe->base_private->flags & SPE_ISOLATE_EMULATE) 00132 npc = SPE_EMULATE_PARAM_BUFFER; 00133 00134 rc = handler(spe->base_private->mem_mmap_base, npc); 00135 if (rc) { 00136 DEBUG_PRINTF ("SPE library call unsupported.\n"); 00137 errno=ENOSYS; 00138 return rc; 00139 } 00140 return 0; 00141 }