00001 /* 00002 * libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS 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 #include "spebase.h" 00020 #include "create.h" 00021 00022 #include <fcntl.h> 00023 #include <errno.h> 00024 #include <sys/mman.h> 00025 00026 /* 00027 * accessor functions for private members 00028 */ 00029 00030 void* _base_spe_ps_area_get(spe_context_ptr_t spe, enum ps_area area) 00031 { 00032 void *ptr; 00033 00034 switch (area) { 00035 case SPE_MSSYNC_AREA: 00036 ptr = spe->base_private->mssync_mmap_base; 00037 break; 00038 case SPE_MFC_COMMAND_AREA: 00039 ptr = spe->base_private->mfc_mmap_base; 00040 break; 00041 case SPE_CONTROL_AREA: 00042 ptr = spe->base_private->cntl_mmap_base; 00043 break; 00044 case SPE_SIG_NOTIFY_1_AREA: 00045 ptr = spe->base_private->signal1_mmap_base; 00046 break; 00047 case SPE_SIG_NOTIFY_2_AREA: 00048 ptr = spe->base_private->signal2_mmap_base; 00049 break; 00050 default: 00051 errno = EINVAL; 00052 return NULL; 00053 break; 00054 } 00055 00056 if (ptr == MAP_FAILED) { 00057 errno = EACCES; 00058 return NULL; 00059 } 00060 00061 return ptr; 00062 } 00063 00064 void* _base_spe_ls_area_get(spe_context_ptr_t spe) 00065 { 00066 return spe->base_private->mem_mmap_base; 00067 } 00068 00069 __attribute__ ((noinline)) void __spe_context_update_event(void) 00070 { 00071 return; 00072 } 00073 00074 int __base_spe_event_source_acquire(spe_context_ptr_t spe, enum fd_name fdesc) 00075 { 00076 return _base_spe_open_if_closed(spe, fdesc, 0); 00077 } 00078 00079 void __base_spe_event_source_release(struct spe_context *spe, enum fd_name fdesc) 00080 { 00081 _base_spe_close_if_open(spe, fdesc); 00082 } 00083 00084 int __base_spe_spe_dir_get(spe_context_ptr_t spe) 00085 { 00086 return spe->base_private->fd_spe_dir; 00087 } 00088 00092 int __base_spe_stop_event_source_get(spe_context_ptr_t spe) 00093 { 00094 return spe->base_private->ev_pipe[1]; 00095 } 00096 00100 int __base_spe_stop_event_target_get(spe_context_ptr_t spe) 00101 { 00102 return spe->base_private->ev_pipe[0]; 00103 } 00104 00105 int _base_spe_ls_size_get(spe_context_ptr_t spe) 00106 { 00107 return LS_SIZE; 00108 }