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