libspe2 0.9a
|
00001 /* handler_utils.h - definitions for assisted SPE library calls. 00002 * 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 __HANDLER_UTILS_H__ 00021 #define __HANDLER_UTILS_H__ 00022 00023 struct spe_reg128 { 00024 unsigned int slot[4]; 00025 }; 00026 00027 #ifndef LS_SIZE 00028 #define LS_SIZE 0x40000 /* 256K (in bytes) */ 00029 #define LS_ADDR_MASK (LS_SIZE - 1) 00030 #endif /* LS_SIZE */ 00031 00032 #define __PRINTF(fmt, args...) { fprintf(stderr,fmt , ## args); } 00033 #ifdef DEBUG 00034 #define DEBUG_PRINTF(fmt, args...) __PRINTF(fmt , ## args) 00035 #else 00036 #define DEBUG_PRINTF(fmt, args...) 00037 #endif 00038 00039 #define LS_ARG_ADDR(_index) \ 00040 (&((struct spe_reg128 *) ((char *) ls + ls_args))[_index]) 00041 00042 #define DECL_RET() \ 00043 struct spe_reg128 *ret = LS_ARG_ADDR(0) 00044 00045 #define GET_LS_PTR(_off) \ 00046 (void *) ((char *) ls + ((_off) & LS_ADDR_MASK)) 00047 00048 #define GET_LS_PTR_NULL(_off) \ 00049 ((_off) ? GET_LS_PTR(_off) : NULL) 00050 00051 #define DECL_0_ARGS() \ 00052 unsigned int ls_args = (opdata & 0xffffff) 00053 00054 #define DECL_1_ARGS() \ 00055 DECL_0_ARGS(); \ 00056 struct spe_reg128 *arg0 = LS_ARG_ADDR(0) 00057 00058 #define DECL_2_ARGS() \ 00059 DECL_1_ARGS(); \ 00060 struct spe_reg128 *arg1 = LS_ARG_ADDR(1) 00061 00062 #define DECL_3_ARGS() \ 00063 DECL_2_ARGS(); \ 00064 struct spe_reg128 *arg2 = LS_ARG_ADDR(2) 00065 00066 #define DECL_4_ARGS() \ 00067 DECL_3_ARGS(); \ 00068 struct spe_reg128 *arg3 = LS_ARG_ADDR(3) 00069 00070 #define DECL_5_ARGS() \ 00071 DECL_4_ARGS(); \ 00072 struct spe_reg128 *arg4 = LS_ARG_ADDR(4) 00073 00074 #define DECL_6_ARGS() \ 00075 DECL_5_ARGS(); \ 00076 struct spe_reg128 *arg5 = LS_ARG_ADDR(5) 00077 00078 #define PUT_LS_RC(_a, _b, _c, _d) \ 00079 ret->slot[0] = (unsigned int) (_a); \ 00080 ret->slot[1] = (unsigned int) (_b); \ 00081 ret->slot[2] = (unsigned int) (_c); \ 00082 ret->slot[3] = (unsigned int) (_d); \ 00083 __asm__ __volatile__ ("sync" : : : "memory") 00084 00085 #endif /* __HANDLER_UTILS_H__ */