libspe2 0.9a
|
#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.
{ errno = 0; if (callnum > MAX_CALLNUM) { errno = EINVAL; return -1; } if (callnum < RESERVED) { errno = EACCES; return -1; } if (handlers[callnum] == NULL) { errno = ESRCH; return -1; } handlers[callnum] = NULL; return 0; }
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.
{ errno = 0; if (callnum > MAX_CALLNUM) { errno = EINVAL; return NULL; } if (handlers[callnum] == NULL) { errno = ESRCH; return NULL; } return handlers[callnum]; }
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.
{ errno = 0; if (callnum > MAX_CALLNUM) { errno = EINVAL; return -1; } switch(mode){ case SPE_CALLBACK_NEW: if (callnum < RESERVED) { errno = EACCES; return -1; } if (handlers[callnum] != NULL) { errno = EACCES; return -1; } handlers[callnum] = handler; break; case SPE_CALLBACK_UPDATE: if (handlers[callnum] == NULL) { errno = ESRCH; return -1; } handlers[callnum] = handler; break; default: errno = EINVAL; return -1; break; } return 0; }
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().
{ int (*handler)(void *, unsigned int); int rc; errno = 0; if (!handlers[callnum]) { DEBUG_PRINTF ("No SPE library handler registered for this call.\n"); errno=ENOSYS; return -1; } handler=handlers[callnum]; /* For emulated isolation mode, position the * npc so that the buffer for the PPE-assisted * library calls can be accessed. */ if (spe->base_private->flags & SPE_ISOLATE_EMULATE) npc = SPE_EMULATE_PARAM_BUFFER; rc = handler(spe->base_private->mem_mmap_base, npc); if (rc) { DEBUG_PRINTF ("SPE library call unsupported.\n"); errno=ENOSYS; return rc; } return 0; }