summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/src/bridge_dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/sar/src/bridge_dma.c')
-rw-r--r--cesar/mac/sar/src/bridge_dma.c155
1 files changed, 155 insertions, 0 deletions
diff --git a/cesar/mac/sar/src/bridge_dma.c b/cesar/mac/sar/src/bridge_dma.c
new file mode 100644
index 0000000000..5ceee75be9
--- /dev/null
+++ b/cesar/mac/sar/src/bridge_dma.c
@@ -0,0 +1,155 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/src/bridge_dma.c
+ * \brief header for the bridge dma launch.
+ * \ingroup mac_sar
+ */
+
+#include "common/std.h"
+#include "mac/sar/inc/bridge_dma.h"
+
+/**
+ * Initialize the list of jobs for the bridge DMA.
+ */
+void bridge_dma_list_init (sar_bridge_dma_list_t *list)
+{
+ list->head = NULL;
+ list->tail = NULL;
+}
+
+/**
+ * Return the head of the list and remove it from the list
+ *
+ * \param list the list to get the head
+ * \return the head of the lsit
+ */
+sar_job_mfs_t * bridge_dma_get_head (sar_bridge_dma_list_t *list)
+{
+ dbg_assert (list);
+ sar_job_mfs_t *job = NULL;
+
+ dbg_assert (list);
+
+ if (list->head == list->tail)
+ {
+ job = list->head;
+ list->head = NULL;
+ list->tail = NULL;
+ }
+ else if (list->head != NULL)
+ {
+ job = list->head;
+ list->head = list->head->next;
+ }
+
+ return job;
+}
+
+/**
+ * Add a job to the bridge dma list
+ *
+ * \param bridge_list the list in which the job must be added
+ * \param head the head chain list
+ * \param last the tail of the chain list.
+ */
+void bridge_dma_add_jobs (sar_bridge_dma_list_t *bridge_list,
+ sar_job_mfs_t *head, sar_job_mfs_t *last)
+{
+ dbg_assert (bridge_list);
+ dbg_assert (head);
+ dbg_assert (last);
+
+ if (bridge_list->tail == NULL)
+ {
+ bridge_list->head = head;
+ bridge_list->tail = last;
+ last->job.last = true;
+ }
+ else
+ {
+ bridge_list->tail->job.last = false;
+ bridge_list->tail->next = head;
+ bridge_list->tail = last;
+ last->job.last = true;
+ }
+}
+
+/**
+ * Add a job to the tx/rx pending job list
+ *
+ * \param list the bridge dma list to add the job
+ * \param head the job mfs to add to the list
+ */
+void bridge_dma_add_pending_job (sar_bridge_dma_list_t *list,
+ sar_job_mfs_t *head)
+{
+ dbg_assert (list);
+ dbg_assert (head);
+
+ if (list->head == NULL)
+ {
+ list->head = head;
+ list->tail = head;
+ }
+ else
+ {
+ list->tail->next = head;
+ list->tail = head;
+ }
+
+ head->next = NULL;
+}
+
+/**
+ * Verify the if a list is empty.
+ *
+ * \return boolean indicating is the state of the list
+ */
+bool bridge_dma_list_is_empty (sar_bridge_dma_list_t *list)
+{
+ dbg_assert (list);
+
+ if (list->head == NULL)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Remove all the jobs in the list and release the mfs and PBs in it.
+ *
+ * \param list the list to uninit.
+ */
+void bridge_dma_uninit_list (sar_bridge_dma_list_t *list)
+{
+ dbg_assert (list);
+
+ sar_job_mfs_t *job_mfs;
+ pb_t *pb_curr;
+
+ //release all pending jobs.
+ while ( (job_mfs = bridge_dma_get_head (list))!= NULL)
+ {
+ // release the PB in the job
+ while (job_mfs->job.first_pb_desc)
+ {
+ pb_curr = (pb_t *) job_mfs->job.first_pb_desc;
+ job_mfs->job.first_pb_desc = job_mfs->job.first_pb_desc->next;
+ blk_release_desc ((blk_t *) pb_curr);
+ }
+
+ blk_release ((blk_t *) job_mfs->mfs);
+ blk_release ((blk_t *) job_mfs);
+ }
+
+ list->head = NULL;
+ list->tail = NULL;
+}