libspe2  0.9a
accessors.c
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  */
19 #include "spebase.h"
20 #include "create.h"
21 
22 #include <fcntl.h>
23 #include <errno.h>
24 #include <sys/mman.h>
25 
26  /*
27  * accessor functions for private members
28  */
29 
31 {
32  void *ptr;
33 
34  switch (area) {
35  case SPE_MSSYNC_AREA:
36  ptr = spe->base_private->mssync_mmap_base;
37  break;
39  ptr = spe->base_private->mfc_mmap_base;
40  break;
41  case SPE_CONTROL_AREA:
42  ptr = spe->base_private->cntl_mmap_base;
43  break;
45  ptr = spe->base_private->signal1_mmap_base;
46  break;
48  ptr = spe->base_private->signal2_mmap_base;
49  break;
50  default:
51  errno = EINVAL;
52  return NULL;
53  break;
54  }
55 
56  if (ptr == MAP_FAILED) {
57  errno = EACCES;
58  return NULL;
59  }
60 
61  return ptr;
62 }
63 
65 {
66  return spe->base_private->mem_mmap_base;
67 }
68 
70 {
71  return;
72 }
73 
75 {
76  return _base_spe_open_if_closed(spe, fdesc, 0);
77 }
78 
80 {
81  _base_spe_close_if_open(spe, fdesc);
82 }
83 
85 {
86  return spe->base_private->fd_spe_dir;
87 }
88 
93 {
94  return spe->base_private->ev_pipe[1];
95 }
96 
101 {
102  return spe->base_private->ev_pipe[0];
103 }
104 
106 {
107  return LS_SIZE;
108 }
void _base_spe_close_if_open(struct spe_context *spe, enum fd_name fdesc)
Definition: create.c:125
void * signal2_mmap_base
Definition: spebase.h:90
void * mssync_mmap_base
Definition: spebase.h:87
void __base_spe_event_source_release(struct spe_context *spe, enum fd_name fdesc)
Definition: accessors.c:79
int __base_spe_stop_event_source_get(spe_context_ptr_t spe)
Definition: accessors.c:92
int _base_spe_open_if_closed(struct spe_context *spe, enum fd_name fdesc, int locked)
Definition: create.c:101
void * cntl_mmap_base
Definition: spebase.h:88
void * mfc_mmap_base
Definition: spebase.h:86
void * signal1_mmap_base
Definition: spebase.h:89
void * _base_spe_ps_area_get(spe_context_ptr_t spe, enum ps_area area)
Definition: accessors.c:30
int __base_spe_stop_event_target_get(spe_context_ptr_t spe)
Definition: accessors.c:100
void __spe_context_update_event(void)
struct spe_context_base_priv * base_private
Definition: libspe2-types.h:76
int __base_spe_spe_dir_get(spe_context_ptr_t spe)
Definition: accessors.c:84
fd_name
Definition: spebase.h:42
ps_area
#define LS_SIZE
Definition: elf_loader.h:23
int __base_spe_event_source_acquire(spe_context_ptr_t spe, enum fd_name fdesc)
Definition: accessors.c:74
void * mem_mmap_base
Definition: spebase.h:85
int _base_spe_ls_size_get(spe_context_ptr_t spe)
Definition: accessors.c:105
__attribute__((noinline))
Definition: accessors.c:69
void * _base_spe_ls_area_get(spe_context_ptr_t spe)
Definition: accessors.c:64