spebase.h
Go to the documentation of this file.
/*
* libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS
* Copyright (C) 2005 IBM Corp.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _spebase_h_
#define _spebase_h_
#ifdef __cplusplus
extern "C"
{
#endif
#include <pthread.h>
#include "libspe2-types.h"
#define __PRINTF(fmt, args...) { fprintf(stderr,fmt , ## args); }
#ifdef DEBUG
#define DEBUG_PRINTF(fmt, args...) __PRINTF(fmt , ## args)
#else
#define DEBUG_PRINTF(fmt, args...)
#endif
enum fd_name {
FD_MBOX,
FD_MBOX_STAT,
FD_IBOX,
FD_IBOX_NB,
FD_IBOX_STAT,
FD_WBOX,
FD_WBOX_NB,
FD_WBOX_STAT,
FD_SIG1,
FD_SIG2,
FD_MFC,
FD_MSS,
NUM_MBOX_FDS
};
/*
* "Private" structure -- do no use, if you want to achieve binary compatibility
*/
struct spe_context_base_priv {
/* mutex to protect members which modified in lifetime of the context:
spe_fds_array, entry
*/
pthread_mutex_t fd_lock[NUM_MBOX_FDS];
/* SPE Group base directory fd */
int fd_grp_dir;
/* SPE SPUFS base dir fd*/
int fd_spe_dir;
/* SPE Program execution and environment flags */
unsigned int flags;
/* SPE Mailbox and Signal fds */
int spe_fds_array[NUM_MBOX_FDS];
int spe_fds_refcount[NUM_MBOX_FDS];
/* event pipes for speevent library */
int ev_pipe[2];
/* Base Addresses of memory mapped SPE areas */
void *psmap_mmap_base;
void *mem_mmap_base;
void *mfc_mmap_base;
void *mssync_mmap_base;
void *cntl_mmap_base;
void *signal1_mmap_base;
void *signal2_mmap_base;
/* SPE program entry point generated by elf_load() */
int entry;
/* pointer to the program loaded/being loaded to the SPE. We need to
* store this to allow deferred updates to gdb, when loading is
* asynchronous (ie, isolated load, which is performed by the SPE).
*/
spe_program_handle_t *loaded_program;
/* We need to keep the entry point for emulated isolated contexts,
* and ignore the value provided to spe_context_run */
int emulated_entry;
/* This is used to keep track of tags used for proxy DMA operations
* so we can use the zero tagmask parameter in the status functions*/
int active_tagmask;
};
/* spe related sizes
*/
#define LS_SIZE 0x40000 /* 256K (in bytes) */
#define PSMAP_SIZE 0x20000 /* 128K (in bytes) */
#define MFC_SIZE 0x1000
#define MSS_SIZE 0x1000
#define CNTL_SIZE 0x1000
#define SIGNAL_SIZE 0x1000
#define MSSYNC_OFFSET 0x00000
#define MFC_OFFSET 0x03000
#define CNTL_OFFSET 0x04000
#define SIGNAL1_OFFSET 0x14000
#define SIGNAL2_OFFSET 0x1c000
#define SPE_EMULATE_PARAM_BUFFER 0x3e000
/*
*/
#define SPE_PROGRAM_NORMAL_END 0x2000
#define SPE_PROGRAM_LIBRARY_CALL 0x2100
#define SPE_PROGRAM_ISOLATED_STOP 0x2200
#define SPE_PROGRAM_ISO_LOAD_COMPLETE 0x2206
struct spe_gang_context_base_priv
{
/* SPE Gang execution and environment flags */
unsigned int flags;
/* SPE Mailbox and Signal fds */
int fd_gang_dir;
char gangname[256];
};
/* Function Prototypes
*/
extern spe_context_ptr_t _base_spe_context_create(unsigned int flags, spe_gang_context_ptr_t gctx, spe_context_ptr_t aff_spe);
extern spe_gang_context_ptr_t _base_spe_gang_context_create(unsigned int flags);
extern int _base_spe_program_load(spe_context_ptr_t spectx, spe_program_handle_t *program);
void _base_spe_program_load_complete(spe_context_ptr_t spectx);
int _base_spe_emulated_loader_present(void);
extern int _base_spe_context_destroy(spe_context_ptr_t spectx);
extern int _base_spe_gang_context_destroy(spe_gang_context_ptr_t gctx);
extern int _base_spe_context_run(spe_context_ptr_t spe, unsigned int *entry,
unsigned int runflags, void *argp, void *envp, spe_stop_info_t *stopinfo);
extern int _base_spe_image_close(spe_program_handle_t *handle);
extern spe_program_handle_t *_base_spe_image_open(const char *filename);
extern int _base_spe_mfcio_put(spe_context_ptr_t spectx,
unsigned int ls,
void *ea,
unsigned int size,
unsigned int tag,
unsigned int tid,
unsigned int rid);
int _base_spe_mfcio_putb(spe_context_ptr_t spectx,
unsigned int ls,
void *ea,
unsigned int size,
unsigned int tag,
unsigned int tid,
unsigned int rid);
int _base_spe_mfcio_putf(spe_context_ptr_t spectx,
unsigned int ls,
void *ea,
unsigned int size,
unsigned int tag,
unsigned int tid,
unsigned int rid);
int _base_spe_mfcio_get(spe_context_ptr_t spectx,
unsigned int ls,
void *ea,
unsigned int size,
unsigned int tag,
unsigned int tid,
unsigned int rid);
int _base_spe_mfcio_getb(spe_context_ptr_t spectx,
unsigned int ls,
void *ea,
unsigned int size,
unsigned int tag,
unsigned int tid,
unsigned int rid);
int _base_spe_mfcio_getf(spe_context_ptr_t spectx,
unsigned int ls,
void *ea,
unsigned int size,
unsigned int tag,
unsigned int tid,
unsigned int rid);
int _base_spe_out_mbox_read(spe_context_ptr_t spectx,
unsigned int mbox_data[],
int count);
int _base_spe_in_mbox_write(spe_context_ptr_t spectx,
unsigned int mbox_data[],
int count,
int behavior_flag);
int _base_spe_in_mbox_status(spe_context_ptr_t spectx);
int _base_spe_out_mbox_status(spe_context_ptr_t spectx);
int _base_spe_out_intr_mbox_status(spe_context_ptr_t spectx);
int _base_spe_out_intr_mbox_read(spe_context_ptr_t spectx,
unsigned int mbox_data[],
int count,
int behavior_flag);
int _base_spe_signal_write(spe_context_ptr_t spectx,
unsigned int signal_reg,
unsigned int data );
extern int _base_spe_callback_handler_register(void * handler, unsigned int callnum, unsigned int mode);
extern int _base_spe_callback_handler_deregister(unsigned int callnum );
extern void * _base_spe_callback_handler_query(unsigned int callnum );
int _base_spe_stop_reason_get(spe_context_ptr_t spectx);
int _base_spe_mfcio_tag_status_read(spe_context_ptr_t spectx, unsigned int mask, unsigned int behavior, unsigned int *tag_status);
int __base_spe_stop_event_source_get(spe_context_ptr_t spectx);
int __base_spe_stop_event_target_get(spe_context_ptr_t spectx);
int _base_spe_stop_status_get(spe_context_ptr_t spectx);
int __base_spe_event_source_acquire(struct spe_context *spectx, enum fd_name fdesc);
void __base_spe_event_source_release(struct spe_context *spectx, enum fd_name fdesc);
void* _base_spe_ps_area_get(struct spe_context *spectx, enum ps_area area);
int __base_spe_spe_dir_get(struct spe_context *spectx);
void* _base_spe_ls_area_get(struct spe_context *spectx);
int _base_spe_ls_size_get(spe_context_ptr_t spe);
void _base_spe_context_lock(spe_context_ptr_t spe, enum fd_name fd);
void _base_spe_context_unlock(spe_context_ptr_t spe, enum fd_name fd);
int _base_spe_cpu_info_get(int info_requested, int cpu_node);
void __spe_context_update_event(void);
int _base_spe_mssync_start(spe_context_ptr_t spectx);
int _base_spe_mssync_status(spe_context_ptr_t spectx);
#ifdef __cplusplus
}
#endif
#endif