00001 /* 00002 * libspe2 - A wrapper to allow direct execution of SPE binaries 00003 * Copyright (C) 2005 IBM Corp. 00004 * 00005 * This library is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 2.1 of the License, 00008 * or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this library; if not, write to the Free Software Foundation, 00017 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 #ifndef libspe2_types_h 00021 #define libspe2_types_h 00022 00023 #ifdef __cplusplus 00024 extern "C" 00025 { 00026 #endif 00027 00028 #include <limits.h> 00029 #include "cbea_map.h" 00030 00031 /* 00032 * Data structure declarations for 00033 * SPE problem state areas 00034 * (part of public API) 00035 */ 00036 00043 typedef struct spe_program_handle { 00044 /* 00045 * handle_size allows for future extensions of the spe_program_handle 00046 * struct by new fields, without breaking compatibility with existing users. 00047 * Users of the new field would check whether the size is large enough. 00048 */ 00049 unsigned int handle_size; 00050 void *elf_image; 00051 void *toe_shadow; 00052 } spe_program_handle_t; 00053 00054 00064 struct spe_context 00065 { 00066 /* 00067 * Note: The debugger accesses this data structure, and assumes 00068 * it starts out with an spe_program_handle_t identifying the SPE 00069 * executable running within this SPE thread. Everything below 00070 * is private to libspe. 00071 */ 00072 spe_program_handle_t handle; 00073 /* 00074 * PRIVATE TO IMPLEMENTATION - DO NOT USE DIRECTLY 00075 */ 00076 struct spe_context_base_priv * base_private; 00077 struct spe_context_event_priv * event_private; 00078 }; 00083 typedef struct spe_context * spe_context_ptr_t; 00084 00094 struct spe_gang_context 00095 { 00096 /* 00097 * PRIVATE TO IMPLEMENTATION - DO NOT USE DIRECTLY 00098 */ 00099 struct spe_gang_context_base_priv * base_private; 00100 struct spe_gang_context_event_priv * event_private; 00101 }; 00106 typedef struct spe_gang_context * spe_gang_context_ptr_t; 00107 00108 /* 00109 * SPE stop information 00110 * This structure is used to return all information available 00111 * on the reason why an SPE program stopped execution. 00112 * This information is important for some advanced programming 00113 * patterns and/or detailed error reporting. 00114 */ 00115 00118 typedef struct spe_stop_info { 00119 unsigned int stop_reason; 00120 union { 00121 int spe_exit_code; 00122 int spe_signal_code; 00123 int spe_runtime_error; 00124 int spe_runtime_exception; 00125 int spe_runtime_fatal; 00126 int spe_callback_error; 00127 int spe_isolation_error; 00128 /* Reserved fields */ 00129 void *__reserved_ptr; 00130 unsigned long long __reserved_u64; 00131 } result; 00132 int spu_status; 00133 } spe_stop_info_t; 00134 00135 /* 00136 * SPE event structure 00137 * This structure is used for SPE event handling 00138 */ 00139 00143 typedef union spe_event_data 00144 { 00145 void *ptr; 00146 unsigned int u32; 00147 unsigned long long u64; 00148 } spe_event_data_t; 00149 00152 typedef struct spe_event_unit 00153 { 00154 unsigned int events; 00155 spe_context_ptr_t spe; 00156 spe_event_data_t data; 00157 } spe_event_unit_t; 00158 00159 typedef void* spe_event_handler_ptr_t; 00160 typedef int spe_event_handler_t; 00161 00162 00163 /* 00164 *--------------------------------------------------------- 00165 * 00166 * API symbolic constants 00167 * 00168 *--------------------------------------------------------- 00169 */ 00170 00171 enum ps_area { SPE_MSSYNC_AREA, SPE_MFC_COMMAND_AREA, SPE_CONTROL_AREA, SPE_SIG_NOTIFY_1_AREA, SPE_SIG_NOTIFY_2_AREA }; 00172 00176 #define SPE_CFG_SIGNOTIFY1_OR 0x00000010 00177 #define SPE_CFG_SIGNOTIFY2_OR 0x00000020 00178 #define SPE_MAP_PS 0x00000040 00179 #define SPE_ISOLATE 0x00000080 00180 #define SPE_ISOLATE_EMULATE 0x00000100 00181 #define SPE_EVENTS_ENABLE 0x00001000 00182 #define SPE_AFFINITY_MEMORY 0x00002000 00183 00184 00189 #define SPE_EXIT 1 00190 #define SPE_STOP_AND_SIGNAL 2 00191 #define SPE_RUNTIME_ERROR 3 00192 #define SPE_RUNTIME_EXCEPTION 4 00193 #define SPE_RUNTIME_FATAL 5 00194 #define SPE_CALLBACK_ERROR 6 00195 #define SPE_ISOLATION_ERROR 7 00196 00200 #define SPE_SPU_STOPPED_BY_STOP 0x02 /* INTERNAL USE ONLY */ 00201 #define SPE_SPU_HALT 0x04 00202 #define SPE_SPU_WAITING_ON_CHANNEL 0x08 /* INTERNAL USE ONLY */ 00203 #define SPE_SPU_SINGLE_STEP 0x10 00204 #define SPE_SPU_INVALID_INSTR 0x20 00205 #define SPE_SPU_INVALID_CHANNEL 0x40 00206 00210 #define SPE_DMA_ALIGNMENT 0x0008 00211 /* #define SPE_SPE_ERROR 0x0010 */ 00212 #define SPE_DMA_SEGMENTATION 0x0020 00213 #define SPE_DMA_STORAGE 0x0040 00214 #define SPE_INVALID_DMA 0x0800 00215 00219 #define SIGSPE SIGURG 00220 00224 #define SPE_EVENT_OUT_INTR_MBOX 0x00000001 00225 #define SPE_EVENT_IN_MBOX 0x00000002 00226 #define SPE_EVENT_TAG_GROUP 0x00000004 00227 #define SPE_EVENT_SPE_STOPPED 0x00000008 00228 00229 #define SPE_EVENT_ALL_EVENTS SPE_EVENT_OUT_INTR_MBOX | \ 00230 SPE_EVENT_IN_MBOX | \ 00231 SPE_EVENT_TAG_GROUP | \ 00232 SPE_EVENT_SPE_STOPPED 00233 00237 #define SPE_MBOX_ALL_BLOCKING 1 00238 #define SPE_MBOX_ANY_BLOCKING 2 00239 #define SPE_MBOX_ANY_NONBLOCKING 3 00240 00241 00245 #define SPE_TAG_ALL 1 00246 #define SPE_TAG_ANY 2 00247 #define SPE_TAG_IMMEDIATE 3 00248 00249 00253 #define SPE_DEFAULT_ENTRY UINT_MAX 00254 #define SPE_RUN_USER_REGS 0x00000001 /* 128b user data for r3-5. */ 00255 #define SPE_NO_CALLBACKS 0x00000002 00256 00257 /* 00258 * 00259 */ 00260 #define SPE_CALLBACK_NEW 1 00261 #define SPE_CALLBACK_UPDATE 2 00262 00263 00264 00265 #define SPE_COUNT_PHYSICAL_CPU_NODES 1 00266 #define SPE_COUNT_PHYSICAL_SPES 2 00267 #define SPE_COUNT_USABLE_SPES 3 00268 00272 #define SPE_SIG_NOTIFY_REG_1 0x0001 00273 #define SPE_SIG_NOTIFY_REG_2 0x0002 00274 00275 #ifdef __cplusplus 00276 } 00277 #endif 00278 00279 #endif /*libspe2_types_h*/