libspe2  0.9a
Functions
dma.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/poll.h>
#include "create.h"
#include "dma.h"
Include dependency graph for dma.c:

Go to the source code of this file.

Functions

int _base_spe_mfcio_put (spe_context_ptr_t spectx, unsigned int ls, void *ea, unsigned int size, unsigned int tag, unsigned int tid, unsigned int rid)
 
int _base_spe_mfcio_putb (spe_context_ptr_t spectx, unsigned int ls, void *ea, unsigned int size, unsigned int tag, unsigned int tid, unsigned int rid)
 
int _base_spe_mfcio_putf (spe_context_ptr_t spectx, unsigned int ls, void *ea, unsigned int size, unsigned int tag, unsigned int tid, unsigned int rid)
 
int _base_spe_mfcio_get (spe_context_ptr_t spectx, unsigned int ls, void *ea, unsigned int size, unsigned int tag, unsigned int tid, unsigned int rid)
 
int _base_spe_mfcio_getb (spe_context_ptr_t spectx, unsigned int ls, void *ea, unsigned int size, unsigned int tag, unsigned int tid, unsigned int rid)
 
int _base_spe_mfcio_getf (spe_context_ptr_t spectx, unsigned int ls, void *ea, unsigned int size, unsigned int tag, unsigned int tid, unsigned int rid)
 
int _base_spe_mfcio_tag_status_read (spe_context_ptr_t spectx, unsigned int mask, unsigned int behavior, unsigned int *tag_status)
 
int _base_spe_mssync_start (spe_context_ptr_t spectx)
 
int _base_spe_mssync_status (spe_context_ptr_t spectx)
 

Function Documentation

int _base_spe_mfcio_get ( spe_context_ptr_t  spectx,
unsigned int  ls,
void *  ea,
unsigned int  size,
unsigned int  tag,
unsigned int  tid,
unsigned int  rid 
)

The _base_spe_mfcio_get function places a get DMA command on the proxy command queue of the SPE thread specified by speid. The get command transfers size bytes of data starting at the effective address specified by ea to the local store address specified by ls. The DMA is identified by the tag id specified by tag and performed according to the transfer class and replacement class specified by tid and rid respectively.

Parameters
spectxSpecifies the SPE context
lsSpecifies the starting local store destination address.
eaSpecifies the starting effective address source address.
sizeSpecifies the size, in bytes, to be transferred.
tagSpecifies the tag id used to identify the DMA command.
tidSpecifies the transfer class identifier of the DMA command.
ridSpecifies the replacement class identifier of the DMA command.
Returns
On success, return 0. On failure, -1 is returned.

Definition at line 160 of file dma.c.

References MFC_CMD_GET.

167 {
168  return spe_do_mfc_get(spectx, ls, ea, size, tag, tid, rid, MFC_CMD_GET);
169 }
int _base_spe_mfcio_getb ( spe_context_ptr_t  spectx,
unsigned int  ls,
void *  ea,
unsigned int  size,
unsigned int  tag,
unsigned int  tid,
unsigned int  rid 
)

The _base_spe_mfcio_getb function is identical to _base_spe_mfcio_get except that it places a getb (get with barrier) DMA command on the proxy command queue. The barrier form ensures that this command and all sequence commands with the same tag identifier as this command are locally ordered with respect to all previously issued commands with the same tag group and command queue.

Parameters
spectxSpecifies the SPE context
lsSpecifies the starting local store destination address.
eaSpecifies the starting effective address source address.
sizeSpecifies the size, in bytes, to be transferred.
tagSpecifies the tag id used to identify the DMA command.
tidSpecifies the transfer class identifier of the DMA command.
ridSpecifies the replacement class identifier of the DMA command.
Returns
On success, return 0. On failure, -1 is returned.

Definition at line 171 of file dma.c.

References MFC_CMD_GETB.

178 {
179  return spe_do_mfc_get(spectx, ls, ea, size, tag, rid, rid, MFC_CMD_GETB);
180 }
int _base_spe_mfcio_getf ( spe_context_ptr_t  spectx,
unsigned int  ls,
void *  ea,
unsigned int  size,
unsigned int  tag,
unsigned int  tid,
unsigned int  rid 
)

The _base_spe_mfcio_getf function is identical to _base_spe_mfcio_get except that it places a getf (get with fence) DMA command on the proxy command queue. The fence form ensure that this command is locally ordered with respect to all previously issued commands with the same tag group and command queue.

Parameters
spectxSpecifies the SPE context
lsSpecifies the starting local store destination address.
eaSpecifies the starting effective address source address.
sizeSpecifies the size, in bytes, to be transferred.
tagSpecifies the tag id used to identify the DMA command.
tidSpecifies the transfer class identifier of the DMA command.
ridSpecifies the replacement class identifier of the DMA command.
Returns
On success, return 0. On failure, -1 is returned.

Definition at line 182 of file dma.c.

References MFC_CMD_GETF.

189 {
190  return spe_do_mfc_get(spectx, ls, ea, size, tag, tid, rid, MFC_CMD_GETF);
191 }
int _base_spe_mfcio_put ( spe_context_ptr_t  spectx,
unsigned int  ls,
void *  ea,
unsigned int  size,
unsigned int  tag,
unsigned int  tid,
unsigned int  rid 
)

The _base_spe_mfcio_put function places a put DMA command on the proxy command queue of the SPE thread specified by speid. The put command transfers size bytes of data starting at the local store address specified by ls to the effective address specified by ea. The DMA is identified by the tag id specified by tag and performed according transfer class and replacement class specified by tid and rid respectively.

Parameters
spectxSpecifies the SPE context
lsSpecifies the starting local store destination address.
eaSpecifies the starting effective address source address.
sizeSpecifies the size, in bytes, to be transferred.
tagSpecifies the tag id used to identify the DMA command.
tidSpecifies the transfer class identifier of the DMA command.
ridSpecifies the replacement class identifier of the DMA command.
Returns
On success, return 0. On failure, -1 is returned.

Definition at line 126 of file dma.c.

References MFC_CMD_PUT.

133 {
134  return spe_do_mfc_put(spectx, ls, ea, size, tag, tid, rid, MFC_CMD_PUT);
135 }
int _base_spe_mfcio_putb ( spe_context_ptr_t  spectx,
unsigned int  ls,
void *  ea,
unsigned int  size,
unsigned int  tag,
unsigned int  tid,
unsigned int  rid 
)

The _base_spe_mfcio_putb function is identical to _base_spe_mfcio_put except that it places a putb (put with barrier) DMA command on the proxy command queue. The barrier form ensures that this command and all sequence commands with the same tag identifier as this command are locally ordered with respect to all previously i ssued commands with the same tag group and command queue.

Parameters
spectxSpecifies the SPE context
lsSpecifies the starting local store destination address.
eaSpecifies the starting effective address source address.
sizeSpecifies the size, in bytes, to be transferred.
tagSpecifies the tag id used to identify the DMA command.
tidSpecifies the transfer class identifier of the DMA command.
ridSpecifies the replacement class identifier of the DMA command.
Returns
On success, return 0. On failure, -1 is returned.

Definition at line 137 of file dma.c.

References MFC_CMD_PUTB.

144 {
145  return spe_do_mfc_put(spectx, ls, ea, size, tag, tid, rid, MFC_CMD_PUTB);
146 }
int _base_spe_mfcio_putf ( spe_context_ptr_t  spectx,
unsigned int  ls,
void *  ea,
unsigned int  size,
unsigned int  tag,
unsigned int  tid,
unsigned int  rid 
)

The _base_spe_mfcio_putf function is identical to _base_spe_mfcio_put except that it places a putf (put with fence) DMA command on the proxy command queue. The fence form ensures that this command is locally ordered with respect to all previously issued commands with the same tag group and command queue.

Parameters
spectxSpecifies the SPE context
lsSpecifies the starting local store destination address.
eaSpecifies the starting effective address source address.
sizeSpecifies the size, in bytes, to be transferred.
tagSpecifies the tag id used to identify the DMA command.
tidSpecifies the transfer class identifier of the DMA command.
ridSpecifies the replacement class identifier of the DMA command.
Returns
On success, return 0. On failure, -1 is returned.

Definition at line 148 of file dma.c.

References MFC_CMD_PUTF.

155 {
156  return spe_do_mfc_put(spectx, ls, ea, size, tag, tid, rid, MFC_CMD_PUTF);
157 }
int _base_spe_mfcio_tag_status_read ( spe_context_ptr_t  spectx,
unsigned int  mask,
unsigned int  behavior,
unsigned int *  tag_status 
)

_base_spe_mfcio_tag_status_read

No Idea

Definition at line 307 of file dma.c.

References spe_context_base_priv::active_tagmask, spe_context::base_private, spe_context_base_priv::flags, SPE_MAP_PS, SPE_TAG_ALL, SPE_TAG_ANY, and SPE_TAG_IMMEDIATE.

308 {
309  if ( mask != 0 ) {
310  if (!(spectx->base_private->flags & SPE_MAP_PS))
311  mask = 0;
312  } else {
313  if ((spectx->base_private->flags & SPE_MAP_PS))
314  mask = spectx->base_private->active_tagmask;
315  }
316 
317  if (!tag_status) {
318  errno = EINVAL;
319  return -1;
320  }
321 
322  switch (behavior) {
323  case SPE_TAG_ALL:
324  return spe_mfcio_tag_status_read_all(spectx, mask, tag_status);
325  case SPE_TAG_ANY:
326  return spe_mfcio_tag_status_read_any(spectx, mask, tag_status);
327  case SPE_TAG_IMMEDIATE:
328  return spe_mfcio_tag_status_read_immediate(spectx, mask, tag_status);
329  default:
330  errno = EINVAL;
331  return -1;
332  }
333 }
int _base_spe_mssync_start ( spe_context_ptr_t  spectx)

_base_spe_mssync_start starts Multisource Synchronisation

Parameters
spectxSpecifies the SPE context

Definition at line 335 of file dma.c.

References _base_spe_open_if_closed(), spe_context::base_private, FD_MSS, spe_context_base_priv::flags, spe_mssync_area::MFC_MSSync, spe_context_base_priv::mssync_mmap_base, and SPE_MAP_PS.

336 {
337  int ret, fd;
338  unsigned int data = 1; /* Any value can be written here */
339 
340  volatile struct spe_mssync_area *mss_area =
342 
343  if (spectx->base_private->flags & SPE_MAP_PS) {
344  mss_area->MFC_MSSync = data;
345  return 0;
346  } else {
347  fd = _base_spe_open_if_closed(spectx, FD_MSS, 0);
348  if (fd != -1) {
349  ret = write(fd, &data, sizeof (data));
350  if ((ret < 0) && (errno != EIO)) {
351  perror("spe_mssync_start: internal error");
352  }
353  return ret < 0 ? -1 : 0;
354  } else
355  return -1;
356  }
357 }

Here is the call graph for this function:

int _base_spe_mssync_status ( spe_context_ptr_t  spectx)

_base_spe_mssync_status retrieves status of Multisource Synchronisation

Parameters
spectxSpecifies the SPE context

Definition at line 359 of file dma.c.

References _base_spe_open_if_closed(), spe_context::base_private, FD_MSS, spe_context_base_priv::flags, spe_mssync_area::MFC_MSSync, spe_context_base_priv::mssync_mmap_base, and SPE_MAP_PS.

360 {
361  int ret, fd;
362  unsigned int data;
363 
364  volatile struct spe_mssync_area *mss_area =
366 
367  if (spectx->base_private->flags & SPE_MAP_PS) {
368  return mss_area->MFC_MSSync;
369  } else {
370  fd = _base_spe_open_if_closed(spectx, FD_MSS, 0);
371  if (fd != -1) {
372  ret = read(fd, &data, sizeof (data));
373  if ((ret < 0) && (errno != EIO)) {
374  perror("spe_mssync_start: internal error");
375  }
376  return ret < 0 ? -1 : data;
377  } else
378  return -1;
379  }
380 }

Here is the call graph for this function: