libspe2  0.9a
spebase.h
Go to the documentation of this file.
1 /*
2  * libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS
3  * Copyright (C) 2005 IBM Corp.
4  *
5  * This library is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation; either version 2.1 of the License,
8  * or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
22 #ifndef _spebase_h_
23 #define _spebase_h_
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
30 #include <pthread.h>
31 
32 #include "libspe2-types.h"
33 
34 #define __PRINTF(fmt, args...) { fprintf(stderr,fmt , ## args); }
35 #ifdef DEBUG
36 #define DEBUG_PRINTF(fmt, args...) __PRINTF(fmt , ## args)
37 #else
38 #define DEBUG_PRINTF(fmt, args...)
39 #endif
40 
42 enum fd_name {
56 };
57 
58 /*
59  * "Private" structure -- do no use, if you want to achieve binary compatibility
60  */
62  /* mutex to protect members which modified in lifetime of the context:
63  spe_fds_array, entry
64  */
65  pthread_mutex_t fd_lock[NUM_MBOX_FDS];
66 
67  /* SPE Group base directory fd */
69 
70  /* SPE SPUFS base dir fd*/
72 
73  /* SPE Program execution and environment flags */
74  unsigned int flags;
75 
76  /* SPE Mailbox and Signal fds */
79 
80  /* event pipes for speevent library */
81  int ev_pipe[2];
82 
83  /* Base Addresses of memory mapped SPE areas */
91 
92  /* SPE program entry point generated by elf_load() */
93  int entry;
94 
95  /* pointer to the program loaded/being loaded to the SPE. We need to
96  * store this to allow deferred updates to gdb, when loading is
97  * asynchronous (ie, isolated load, which is performed by the SPE).
98  */
100 
101  /* We need to keep the entry point for emulated isolated contexts,
102  * and ignore the value provided to spe_context_run */
104 
105  /* This is used to keep track of tags used for proxy DMA operations
106  * so we can use the zero tagmask parameter in the status functions*/
107 
109 };
110 
111 
112 /* spe related sizes
113  */
114 
115 #define LS_SIZE 0x40000 /* 256K (in bytes) */
116 #define PSMAP_SIZE 0x20000 /* 128K (in bytes) */
117 #define MFC_SIZE 0x1000
118 #define MSS_SIZE 0x1000
119 #define CNTL_SIZE 0x1000
120 #define SIGNAL_SIZE 0x1000
121 
122 #define MSSYNC_OFFSET 0x00000
123 #define MFC_OFFSET 0x03000
124 #define CNTL_OFFSET 0x04000
125 #define SIGNAL1_OFFSET 0x14000
126 #define SIGNAL2_OFFSET 0x1c000
127 
132 #define SPE_EMULATE_PARAM_BUFFER 0x3e000
133 
134 /*
135  */
136 #define SPE_PROGRAM_NORMAL_END 0x2000
137 #define SPE_PROGRAM_LIBRARY_CALL 0x2100
138 
142 #define SPE_PROGRAM_ISOLATED_STOP 0x2200
143 #define SPE_PROGRAM_ISO_LOAD_COMPLETE 0x2206
144 
151 {
152  /* SPE Gang execution and environment flags */
153  unsigned int flags;
154 
155  /* SPE Mailbox and Signal fds */
157 
158  char gangname[256];
159 };
160 
161 
162 /* Function Prototypes
163  */
164 
175 
185 extern spe_gang_context_ptr_t _base_spe_gang_context_create(unsigned int flags);
186 
195 
206 
212 
220 
227 
248 extern int _base_spe_context_run(spe_context_ptr_t spe, unsigned int *entry,
249  unsigned int runflags, void *argp, void *envp, spe_stop_info_t *stopinfo);
250 
262 extern int _base_spe_image_close(spe_program_handle_t *handle);
263 
294 extern spe_program_handle_t *_base_spe_image_open(const char *filename);
295 
313 extern int _base_spe_mfcio_put(spe_context_ptr_t spectx,
314  unsigned int ls,
315  void *ea,
316  unsigned int size,
317  unsigned int tag,
318  unsigned int tid,
319  unsigned int rid);
320 
338  unsigned int ls,
339  void *ea,
340  unsigned int size,
341  unsigned int tag,
342  unsigned int tid,
343  unsigned int rid);
344 
361  unsigned int ls,
362  void *ea,
363  unsigned int size,
364  unsigned int tag,
365  unsigned int tid,
366  unsigned int rid);
367 
385  unsigned int ls,
386  void *ea,
387  unsigned int size,
388  unsigned int tag,
389  unsigned int tid,
390  unsigned int rid);
391 
409  unsigned int ls,
410  void *ea,
411  unsigned int size,
412  unsigned int tag,
413  unsigned int tid,
414  unsigned int rid);
415 
432  unsigned int ls,
433  void *ea,
434  unsigned int size,
435  unsigned int tag,
436  unsigned int tid,
437  unsigned int rid);
438 
462  unsigned int mbox_data[],
463  int count);
464 
494  unsigned int mbox_data[],
495  int count,
496  int behavior_flag);
497 
510 
523 
536 
542  unsigned int mbox_data[],
543  int count,
544  int behavior_flag);
545 
561  unsigned int signal_reg,
562  unsigned int data );
563 
568 extern int _base_spe_callback_handler_register(void * handler, unsigned int callnum, unsigned int mode);
569 
574 extern int _base_spe_callback_handler_deregister(unsigned int callnum );
575 
579 extern void * _base_spe_callback_handler_query(unsigned int callnum );
580 
595 
596 
602 int _base_spe_mfcio_tag_status_read(spe_context_ptr_t spectx, unsigned int mask, unsigned int behavior, unsigned int *tag_status);
603 
610 
617 
625 
633 int __base_spe_event_source_acquire(struct spe_context *spectx, enum fd_name fdesc);
634 
642 void __base_spe_event_source_release(struct spe_context *spectx, enum fd_name fdesc);
643 
652 void* _base_spe_ps_area_get(struct spe_context *spectx, enum ps_area area);
653 
659 int __base_spe_spe_dir_get(struct spe_context *spectx);
660 
667 void* _base_spe_ls_area_get(struct spe_context *spectx);
668 
675 
683 
691 
695 int _base_spe_cpu_info_get(int info_requested, int cpu_node);
696 
701 void __spe_context_update_event(void);
702 
709 
716 
717 
718 #ifdef __cplusplus
719 }
720 #endif
721 
722 #endif
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)
Definition: run.c:99
spe_gang_context_ptr_t _base_spe_gang_context_create(unsigned int flags)
Definition: create.c:376
int _base_spe_mssync_status(spe_context_ptr_t spectx)
Definition: dma.c:359
void * signal2_mmap_base
Definition: spebase.h:90
int _base_spe_in_mbox_write(spe_context_ptr_t spectx, unsigned int mbox_data[], int count, int behavior_flag)
int _base_spe_image_close(spe_program_handle_t *handle)
Definition: image.c:96
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)
Definition: dma.c:182
int _base_spe_stop_status_get(spe_context_ptr_t spectx)
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)
Definition: dma.c:126
int _base_spe_out_intr_mbox_status(spe_context_ptr_t spectx)
Definition: mbox.c:238
int _base_spe_cpu_info_get(int info_requested, int cpu_node)
Definition: info.c:105
int _base_spe_stop_reason_get(spe_context_ptr_t spectx)
int __base_spe_stop_event_target_get(spe_context_ptr_t spectx)
Definition: accessors.c:100
int _base_spe_out_mbox_status(spe_context_ptr_t spectx)
Definition: mbox.c:220
void * psmap_mmap_base
Definition: spebase.h:84
spe_program_handle_t * loaded_program
Definition: spebase.h:99
void * mssync_mmap_base
Definition: spebase.h:87
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)
Definition: dma.c:171
void _base_spe_program_load_complete(spe_context_ptr_t spectx)
Definition: load.c:38
int _base_spe_signal_write(spe_context_ptr_t spectx, unsigned int signal_reg, unsigned int data)
Definition: mbox.c:307
void * cntl_mmap_base
Definition: spebase.h:88
void * mfc_mmap_base
Definition: spebase.h:86
int _base_spe_emulated_loader_present(void)
Definition: load.c:159
int _base_spe_mfcio_tag_status_read(spe_context_ptr_t spectx, unsigned int mask, unsigned int behavior, unsigned int *tag_status)
Definition: dma.c:307
void * signal1_mmap_base
Definition: spebase.h:89
void * _base_spe_ps_area_get(struct spe_context *spectx, enum ps_area area)
spe_program_handle_t * _base_spe_image_open(const char *filename)
Definition: image.c:37
void * _base_spe_callback_handler_query(unsigned int callnum)
Definition: lib_builtin.c:98
int spe_fds_array[NUM_MBOX_FDS]
Definition: spebase.h:77
Definition: spebase.h:53
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)
Definition: dma.c:137
int _base_spe_out_mbox_read(spe_context_ptr_t spectx, unsigned int mbox_data[], int count)
Definition: mbox.c:58
int __base_spe_event_source_acquire(struct spe_context *spectx, enum fd_name fdesc)
int _base_spe_context_destroy(spe_context_ptr_t spectx)
Definition: create.c:418
int spe_fds_refcount[NUM_MBOX_FDS]
Definition: spebase.h:78
int _base_spe_mssync_start(spe_context_ptr_t spectx)
Definition: dma.c:335
Definition: spebase.h:54
int _base_spe_out_intr_mbox_read(spe_context_ptr_t spectx, unsigned int mbox_data[], int count, int behavior_flag)
Definition: mbox.c:255
void __spe_context_update_event(void)
int _base_spe_callback_handler_register(void *handler, unsigned int callnum, unsigned int mode)
Definition: lib_builtin.c:40
spe_context_ptr_t _base_spe_context_create(unsigned int flags, spe_gang_context_ptr_t gctx, spe_context_ptr_t aff_spe)
Definition: create.c:183
int _base_spe_program_load(spe_context_ptr_t spectx, spe_program_handle_t *program)
Definition: load.c:203
fd_name
Definition: spebase.h:42
void _base_spe_context_unlock(spe_context_ptr_t spe, enum fd_name fd)
Definition: create.c:96
unsigned int flags
Definition: spebase.h:74
void __base_spe_event_source_release(struct spe_context *spectx, enum fd_name fdesc)
Definition: accessors.c:79
ps_area
void _base_spe_context_lock(spe_context_ptr_t spe, enum fd_name fd)
Definition: create.c:91
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)
Definition: dma.c:160
void * mem_mmap_base
Definition: spebase.h:85
int _base_spe_callback_handler_deregister(unsigned int callnum)
Definition: lib_builtin.c:78
int _base_spe_in_mbox_status(spe_context_ptr_t spectx)
Definition: mbox.c:202
int __base_spe_stop_event_source_get(spe_context_ptr_t spectx)
Definition: accessors.c:92
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)
Definition: dma.c:148
void * _base_spe_ls_area_get(struct spe_context *spectx)
int _base_spe_ls_size_get(spe_context_ptr_t spe)
Definition: accessors.c:105
int __base_spe_spe_dir_get(struct spe_context *spectx)
pthread_mutex_t fd_lock[NUM_MBOX_FDS]
Definition: spebase.h:65
int _base_spe_gang_context_destroy(spe_gang_context_ptr_t gctx)
Definition: create.c:427