summaryrefslogtreecommitdiffstats
path: root/arch/m68k/mach-mcfv4e/net/queue.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-04-04 18:16:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2008-04-04 18:16:06 +0200
commitae6cc2d36baec9dee3a82d5542354fcac6b7679c (patch)
tree7078ba7beefa5b61fd9c38f76c8449d4fee1bd67 /arch/m68k/mach-mcfv4e/net/queue.c
parent35497c757ce705f4c2a19662e9b2f130583b673b (diff)
downloadbarebox-ae6cc2d36baec9dee3a82d5542354fcac6b7679c.tar.gz
barebox-ae6cc2d36baec9dee3a82d5542354fcac6b7679c.tar.xz
[m68k] Add Freescale Coldfire V4E Architecture support
- Added m68k vector, exception & interrupt handlers - Added m68k macros to access m68k movec registers - Added Coldfire support code (MultiChannelDMA) - Added board support for phytec phyCore-MCF baseboard - Added board support for konzeptpark MCB2 prototype Signed-off-by: Carsten Schlote <schlote@vahanus.net>
Diffstat (limited to 'arch/m68k/mach-mcfv4e/net/queue.c')
-rw-r--r--arch/m68k/mach-mcfv4e/net/queue.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/arch/m68k/mach-mcfv4e/net/queue.c b/arch/m68k/mach-mcfv4e/net/queue.c
new file mode 100644
index 0000000000..55f938af3e
--- /dev/null
+++ b/arch/m68k/mach-mcfv4e/net/queue.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2008 Carsten Schlote <c.schlote@konzeptpark.de>
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This file is part of U-Boot V2.
+ *
+ * U-Boot V2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * U-Boot V2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with U-Boot V2. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file
+ * Implements a first in, first out linked list
+ *
+ * @note Simple selfcontaining basic code
+ * @todo Replace by u-boot standard list functions
+ */
+#include <linux/types.h>
+#include <asm/proc/net/queue.h>
+
+/** Initialize the specified queue to an empty state
+ *
+ * @param[in]
+ * q Pointer to queue structure
+ */
+void queue_init(QUEUE *q)
+{
+ q->head = NULL;
+}
+
+/**
+ * Check for an empty queue
+ *
+ * @param[in] q Pointer to queue structure
+ * @return
+ * 1 if Queue is empty
+ * 0 otherwise
+ */
+int
+queue_isempty(QUEUE *q)
+{
+ return (q->head == NULL);
+}
+
+/**
+ * Add an item to the end of the queue
+ *
+ * @param[in] q Pointer to queue structure
+ * @param[in] node New node to add to the queue
+ */
+void queue_add(QUEUE *q, QNODE *node)
+{
+ if (queue_isempty(q))
+ {
+ q->head = q->tail = node;
+ }
+ else
+ {
+ q->tail->next = node;
+ q->tail = node;
+ }
+
+ node->next = NULL;
+}
+
+/** Remove and return first (oldest) entry from the specified queue
+ *
+ * @param[in] q Pointer to queue structure
+ * @return
+ * Node at head of queue - NULL if queue is empty
+ */
+QNODE*
+queue_remove(QUEUE *q)
+{
+ QNODE *oldest;
+
+ if (queue_isempty(q))
+ return NULL;
+
+ oldest = q->head;
+ q->head = oldest->next;
+ return oldest;
+}
+
+/** Peek into the queue and return pointer to first (oldest) entry.
+ *
+ * The queue is not modified
+ *
+ * @param[in] q Pointer to queue structure
+ * @return
+ * Node at head of queue - NULL if queue is empty
+ */
+QNODE*
+queue_peek(QUEUE *q)
+{
+ return q->head;
+}
+
+/** Move entire contents of one queue to the other
+ *
+ * @param[in] src Pointer to source queue
+ * @param[in] dst Pointer to destination queue
+ */
+void
+queue_move(QUEUE *dst, QUEUE *src)
+{
+ if (queue_isempty(src))
+ return;
+
+ if (queue_isempty(dst))
+ dst->head = src->head;
+ else
+ dst->tail->next = src->head;
+
+ dst->tail = src->tail;
+ src->head = NULL;
+ return;
+}
+