Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/vchiq BCM2835 VCHIQ device driver
details: https://anonhg.NetBSD.org/src/rev/d8f8bc1cef69
branches: trunk
changeset: 785321:d8f8bc1cef69
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Mar 08 12:32:29 2013 +0000
description:
BCM2835 VCHIQ device driver
diffstat:
sys/external/bsd/vchiq/conf/files.vchiq | 20 +
sys/external/bsd/vchiq/dist/interface/compat/list.h | 32 +
sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c | 462 +
sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h | 420 +
sys/external/bsd/vchiq/dist/interface/vchi/connections/connection.h | 324 +
sys/external/bsd/vchiq/dist/interface/vchi/message_drivers/message.h | 200 +
sys/external/bsd/vchiq/dist/interface/vchi/vchi.h | 373 +
sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg.h | 225 +
sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg_internal.h | 71 +
sys/external/bsd/vchiq/dist/interface/vchi/vchi_common.h | 163 +
sys/external/bsd/vchiq/dist/interface/vchi/vchi_mh.h | 42 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq.h | 41 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835.h | 42 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c | 723 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c | 2747 +++++++
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.h | 200 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_build_info.h | 37 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_cfg.h | 60 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_connected.c | 117 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_connected.h | 51 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c | 3830 ++++++++++
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h | 707 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_genversion | 89 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_if.h | 185 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_ioctl.h | 128 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c | 451 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_freebsd.c | 205 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c | 175 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_memdrv.h | 71 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h | 39 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_pagelist.h | 59 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_proc.c | 240 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c | 815 ++
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.c | 120 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h | 64 +
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_version.c | 59 +
36 files changed, 13587 insertions(+), 0 deletions(-)
diffs (truncated from 13731 to 300 lines):
diff -r ec962ac5d03d -r d8f8bc1cef69 sys/external/bsd/vchiq/conf/files.vchiq
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/vchiq/conf/files.vchiq Fri Mar 08 12:32:29 2013 +0000
@@ -0,0 +1,20 @@
+# $NetBSD: files.vchiq,v 1.1 2013/03/08 12:32:29 jmcneill Exp $
+#
+# Broadcom VideoCore IV
+#
+
+define vchiqbus { }
+
+device vchiq: vchiqbus
+attach vchiq at obio
+file external/bsd/vchiq/dist/interface/compat/vchi_bsd.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_connected.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c vchiq
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c vchiq
+
+makeoptions vchiq CPPFLAGS+="-I$S/external/bsd/vchiq/dist -DVCOS_VERIFY_BKPTS=1 -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -DVCHIQ_ENABLE_DEBUG=1 -DVCHIQ_LOG_DEFAULT=5"
diff -r ec962ac5d03d -r d8f8bc1cef69 sys/external/bsd/vchiq/dist/interface/compat/list.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/compat/list.h Fri Mar 08 12:32:29 2013 +0000
@@ -0,0 +1,32 @@
+#ifndef __COMPAT_LIST__
+#define __COMPAT_LIST__
+
+struct list_head {
+ struct list_head *next;
+ struct list_head *prev;
+};
+
+#define INIT_LIST_HEAD(ptr) do { \
+ (ptr)->prev = (ptr); \
+ (ptr)->next = (ptr); \
+} while(0)
+
+#define list_for_each_safe(pos, next, head) \
+ for ((pos) = (head)->next, (next) = (pos)->next->next; (pos) != (head); (pos) = (next), (next) = (next)->next)
+#define list_for_each(pos, head) \
+ for ((pos) = (head)->next; (pos) != (head); (pos) = (pos)->next)
+#define list_entry(pos, type, head) ((type*)((intptr_t)(pos) - offsetof(type, head)))
+
+#define list_del(pos) do { \
+ (pos)->prev->next = (pos)->next; \
+ (pos)->next->prev = (pos)->prev; \
+ (pos)->next = (pos)->prev = (pos); \
+} while(0)
+
+#define list_add(pos, head) do { \
+ (pos)->prev = (head)->prev; \
+ (pos)->next = (head); \
+ (head)->prev = (pos); \
+} while (0)
+
+#endif
diff -r ec962ac5d03d -r d8f8bc1cef69 sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c Fri Mar 08 12:32:29 2013 +0000
@@ -0,0 +1,462 @@
+/*-
+ * Copyright (c) 2010 Max Khon <fjoe%freebsd.org@localhost>
+ * All rights reserved.
+ *
+ * This software was developed by Max Khon under sponsorship from
+ * the FreeBSD Foundation and Ethon Technologies GmbH.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: vchi_bsd.c,v 1.1 2013/03/08 12:32:30 jmcneill Exp $
+ */
+
+#include <sys/types.h>
+#include <sys/bus.h>
+#include <sys/callout.h>
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+
+#include <interface/compat/vchi_bsd.h>
+
+MALLOC_DEFINE(M_VCHI, "VCHI", "VCHI");
+
+/*
+ * Timer API
+ */
+static void
+run_timer(void *arg)
+{
+ struct timer_list *t = (struct timer_list *) arg;
+ void (*function)(unsigned long);
+
+ spin_lock(&t->mtx);
+ if (callout_pending(&t->callout)) {
+ /* callout was reset */
+ spin_unlock(&t->mtx);
+ return;
+ }
+ if (!callout_active(&t->callout)) {
+ /* callout was stopped */
+ spin_unlock(&t->mtx);
+ return;
+ }
+ callout_ack(&t->callout);
+
+ function = t->function;
+ spin_unlock(&t->mtx);
+
+ function(t->data);
+}
+
+void
+init_timer(struct timer_list *t)
+{
+ spin_lock_init(&t->mtx);
+ callout_init(&t->callout, CALLOUT_MPSAFE);
+ t->expires = 0;
+ /*
+ * function and data are not initialized intentionally:
+ * they are not initialized by Linux implementation too
+ */
+}
+
+void
+setup_timer(struct timer_list *t, void (*function)(unsigned long), unsigned long data)
+{
+ t->function = function;
+ t->data = data;
+ init_timer(t);
+}
+
+void
+mod_timer(struct timer_list *t, unsigned long expires)
+{
+ spin_lock(&t->mtx);
+ callout_reset(&t->callout, expires - jiffies, run_timer, t);
+ spin_unlock(&t->mtx);
+}
+
+void
+add_timer(struct timer_list *t)
+{
+ mod_timer(t, t->expires);
+}
+
+int
+del_timer_sync(struct timer_list *t)
+{
+ spin_lock(&t->mtx);
+ callout_stop(&t->callout);
+ spin_unlock(&t->mtx);
+
+ spin_lock_destroy(&t->mtx);
+ return 0;
+}
+
+int
+del_timer(struct timer_list *t)
+{
+ del_timer_sync(t);
+ return 0;
+}
+
+/*
+ * Completion API
+ */
+void
+init_completion(struct completion *c)
+{
+ cv_init(&c->cv, "VCHI completion cv");
+ mutex_init(&c->lock, MUTEX_DEFAULT, IPL_NONE);
+ c->done = 0;
+}
+
+void
+destroy_completion(struct completion *c)
+{
+ cv_destroy(&c->cv);
+ mutex_destroy(&c->lock);
+}
+
+void
+wait_for_completion(struct completion *c)
+{
+ mutex_enter(&c->lock);
+ if (!c->done)
+ cv_wait(&c->cv, &c->lock);
+ c->done--;
+ mutex_exit(&c->lock);
+}
+
+int
+try_wait_for_completion(struct completion *c)
+{
+ int res = 0;
+
+ mutex_enter(&c->lock);
+ if (!c->done)
+ c->done--;
+ else
+ res = 1;
+ mutex_exit(&c->lock);
+ return res != 0;
+}
+
+int
+wait_for_completion_timeout(struct completion *c, unsigned long timeout)
+{
+ int res = 0;
+
+ mutex_enter(&c->lock);
+ if (!c->done)
+ res = cv_timedwait(&c->cv, &c->lock, timeout);
+ if (res == 0)
+ c->done--;
+ mutex_exit(&c->lock);
+ return res != 0;
+}
+
+int
+wait_for_completion_interruptible_timeout(struct completion *c, unsigned long timeout)
+{
+ int res = 0;
+
+ mutex_enter(&c->lock);
+ if (!c->done)
+ res = cv_timedwait_sig(&c->cv, &c->lock, timeout);
+ if (res == 0)
+ c->done--;
+ mutex_exit(&c->lock);
+ return res != 0;
+}
+
+int
+wait_for_completion_interruptible(struct completion *c)
+{
+ int res = 0;
+
+ mutex_enter(&c->lock);
+ if (!c->done)
+ res = cv_wait_sig(&c->cv, &c->lock);
+ if (res == 0)
+ c->done--;
+ mutex_exit(&c->lock);
+ return res != 0;
+}
+
+int
+wait_for_completion_killable(struct completion *c)
+{
+ int res = 0;
+
+ mutex_enter(&c->lock);
+ if (!c->done)
+ res = cv_wait_sig(&c->cv, &c->lock);
+ /* TODO: check actual signals here ? */
+ if (res == 0)
+ c->done--;
+ mutex_exit(&c->lock);
+ return res != 0;
+}
+
+void
+complete(struct completion *c)
+{
+ mutex_enter(&c->lock);
+ c->done++;
+ cv_signal(&c->cv);
+ mutex_exit(&c->lock);
+}
+
+void
+complete_all(struct completion *c)
+{
+ mutex_enter(&c->lock);
+ c->done++;
+ cv_broadcast(&c->cv);
Home |
Main Index |
Thread Index |
Old Index