summaryrefslogtreecommitdiffstats
path: root/kiro-trb.c
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2014-04-28 19:24:44 +0200
committerTimo Dritschler <timo.dritschler@kit.edu>2014-04-28 19:28:23 +0200
commit6b28a07e6bba885b3f33e7b81d3e76544f18ce07 (patch)
tree16b114536cd35b79545c098a747700dedcaebe3e /kiro-trb.c
parent3405180e97cd6b4d4bef6fed2a7e666eb8126906 (diff)
downloadkiro-6b28a07e6bba885b3f33e7b81d3e76544f18ce07.tar.gz
kiro-6b28a07e6bba885b3f33e7b81d3e76544f18ce07.tar.bz2
kiro-6b28a07e6bba885b3f33e7b81d3e76544f18ce07.tar.xz
kiro-6b28a07e6bba885b3f33e7b81d3e76544f18ce07.zip
Added new function 'kiro_trb_dma_push' that allows the user to directly
write a new element into the buffers memory Changed the name of 'kiro_trb_ingest' to 'kiro_trb_adopt' Added new function 'kiro_trb_clone' that copies the pointed memory before 'adopting' it. Started to add documentation
Diffstat (limited to 'kiro-trb.c')
-rw-r--r--kiro-trb.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/kiro-trb.c b/kiro-trb.c
index b433e38..ff0291b 100644
--- a/kiro-trb.c
+++ b/kiro-trb.c
@@ -163,6 +163,7 @@ void kiro_trb_flush (KiroTrb *self)
KiroTrbPrivate* priv = KIRO_TRB_GET_PRIVATE(self);
priv->iteration = 0;
priv->current = priv->frame_top;
+ write_header(priv);
}
@@ -182,7 +183,7 @@ int kiro_trb_reshape (KiroTrb *self, uint64_t element_size, uint64_t element_cou
((struct KiroTrbInfo *)newmem)->buffer_size_bytes = new_size;
((struct KiroTrbInfo *)newmem)->element_size = element_size;
((struct KiroTrbInfo *)newmem)->offset = 0;
- kiro_trb_ingest(self, newmem);
+ kiro_trb_adopt(self, newmem);
return 0;
}
@@ -206,6 +207,25 @@ int kiro_trb_push (KiroTrb *self, void *element_in)
}
+void* kiro_trb_dma_push (KiroTrb *self)
+{
+ KiroTrbPrivate* priv = KIRO_TRB_GET_PRIVATE(self);
+ if(priv->initialized != 1)
+ return -1;
+ if((priv->current + priv->element_size) > (priv->mem + priv->buff_size))
+ return -1;
+ void *mem_out = priv->current;
+ priv->current += priv->element_size;
+ if(priv->current >= priv->frame_top + (priv->element_size * priv->max_elements))
+ {
+ priv->current = priv->frame_top;
+ priv->iteration++;
+ }
+ write_header(priv);
+ return mem_out;
+}
+
+
void kiro_trb_refresh (KiroTrb *self)
{
KiroTrbPrivate* priv = KIRO_TRB_GET_PRIVATE(self);
@@ -220,7 +240,7 @@ void kiro_trb_refresh (KiroTrb *self)
}
-void kiro_trb_ingest (KiroTrb *self, void *buff_in)
+void kiro_trb_adopt (KiroTrb *self, void *buff_in)
{
KiroTrbPrivate* priv = KIRO_TRB_GET_PRIVATE(self);
if(priv->mem)
@@ -228,3 +248,19 @@ void kiro_trb_ingest (KiroTrb *self, void *buff_in)
priv->mem = buff_in;
kiro_trb_refresh(self);
}
+
+
+int kiro_trb_clone (KiroTrb *self, void *buff_in)
+{
+ KiroTrbPrivate* priv = KIRO_TRB_GET_PRIVATE(self);
+ struct KiroTrbInfo *header = (struct KiroTrbInfo *)buff_in;
+ void *newmem = malloc(header->buffer_size_bytes);
+ if(!newmem)
+ return -1;
+ memcpy(newmem, buff_in, header->buffer_size_bytes);
+ if(priv->mem)
+ free(priv->mem);
+ priv->mem = newmem;
+ kiro_trb_refresh(self);
+ return 0;
+}