[haiku-commits] haiku: hrev51994 - in src/libs/compat/freebsd11_network: . compat/sys

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 8 Jun 2018 21:03:35 -0400 (EDT)

hrev51994 adds 1 changeset to branch 'master'
old head: e1c961d028af9e7d5684e55eb2c143167f90fd01
new head: 800e9d6652407c04cae748f0d346ee5ba47578a5
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=800e9d665240+%5Ee1c961d028af

----------------------------------------------------------------------------

800e9d665240: freebsd11_network: More changes for freebsd11_wlan.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev51994
Commit:      800e9d6652407c04cae748f0d346ee5ba47578a5
URL:         https://git.haiku-os.org/haiku/commit/?id=800e9d665240
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Wed Jun  6 03:17:43 2018 UTC

----------------------------------------------------------------------------

11 files changed, 122 insertions(+), 18 deletions(-)
src/libs/compat/freebsd11_network/Jamfile        |  1 +
.../compat/freebsd11_network/compat/sys/cdefs.h  |  6 +++-
.../freebsd11_network/compat/sys/haiku-module.h  | 11 ++++---
.../compat/freebsd11_network/compat/sys/kernel.h | 28 ++++++++++-------
.../compat/freebsd11_network/compat/sys/mutex.h  | 19 ++++++++++++
.../compat/freebsd11_network/compat/sys/sysctl.h |  9 +++++-
.../freebsd11_network/compat/sys/taskqueue.h     |  1 +
src/libs/compat/freebsd11_network/device.c       |  2 +-
src/libs/compat/freebsd11_network/mutex.c        | 10 ++++++
.../compat/freebsd11_network/subr_autoconf.cpp   | 32 ++++++++++++++++++++
src/libs/compat/freebsd11_network/taskqueue.c    | 21 +++++++++++++

----------------------------------------------------------------------------

diff --git a/src/libs/compat/freebsd11_network/Jamfile 
b/src/libs/compat/freebsd11_network/Jamfile
index eb57203809..d1b5219d8f 100644
--- a/src/libs/compat/freebsd11_network/Jamfile
+++ b/src/libs/compat/freebsd11_network/Jamfile
@@ -41,6 +41,7 @@ KernelStaticLibrary libfreebsd11_network.a :
        mutex.c
        priv.cpp
        smp.c
+       subr_autoconf.cpp
        synch.c
        systm.c
        taskqueue.c
diff --git a/src/libs/compat/freebsd11_network/compat/sys/cdefs.h 
b/src/libs/compat/freebsd11_network/compat/sys/cdefs.h
index 70a8fb40ac..accce562a3 100644
--- a/src/libs/compat/freebsd11_network/compat/sys/cdefs.h
+++ b/src/libs/compat/freebsd11_network/compat/sys/cdefs.h
@@ -160,7 +160,7 @@
 #define        __offsetof(type, field) ((size_t)(&((type *)0)->field))
 #else
 #define __offsetof(type, field)                                        \
-  (__offsetof__ (reinterpret_cast <size_t>                     \
+  ((reinterpret_cast <size_t>                  \
                  (&reinterpret_cast <const volatile char &>    \
                   (static_cast<type *> (0)->field))))
 #endif
@@ -307,6 +307,10 @@
 #define        __UNCONST(var)  ((void*)(uintptr_t)(const void *)(var))
 #endif
 
+#ifndef        __DEVOLATILE
+#define        __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void 
*)(var))
+#endif
+
 #if __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
 /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
 #elif defined(__COUNTER__)
diff --git a/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h 
b/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h
index 427e071ff4..126ba8ccfa 100644
--- a/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h
+++ b/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h
@@ -205,10 +205,13 @@ extern void __haiku_reenable_interrupts(device_t dev);
 extern int __haiku_driver_requirements;
 
 enum {
-       FBSD_TASKQUEUES         = 1 << 0,
-       FBSD_FAST_TASKQUEUE     = 1 << 1,
-       FBSD_SWI_TASKQUEUE      = 1 << 2,
-       FBSD_WLAN                       = 1 << 3,
+       FBSD_TASKQUEUES                 = 1 << 0,
+       FBSD_FAST_TASKQUEUE             = 1 << 1,
+       FBSD_SWI_TASKQUEUE              = 1 << 2,
+       FBSD_THREAD_TASKQUEUE   = 1 << 3,
+       FBSD_WLAN_FEATURE               = 1 << 4,
+       FBSD_WLAN                               = FBSD_WLAN_FEATURE | 
FBSD_TASKQUEUES
+                                                               | 
FBSD_THREAD_TASKQUEUE,
 };
 
 #define HAIKU_DRIVER_REQUIREMENTS(flags) \
diff --git a/src/libs/compat/freebsd11_network/compat/sys/kernel.h 
b/src/libs/compat/freebsd11_network/compat/sys/kernel.h
index bad39de2e2..8a5f26b702 100644
--- a/src/libs/compat/freebsd11_network/compat/sys/kernel.h
+++ b/src/libs/compat/freebsd11_network/compat/sys/kernel.h
@@ -29,21 +29,15 @@
 
 #define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz)
 
-typedef void (*system_init_func_t)(void *);
+extern int32 ticks;
+
 
+typedef void (*system_init_func_t)(void *);
 
 struct __system_init {
        system_init_func_t func;
 };
 
-typedef void (*ich_func_t)(void *_arg);
-
-struct intr_config_hook {
-       TAILQ_ENTRY(intr_config_hook) ich_links;
-       ich_func_t      ich_func;
-       void            *ich_arg;
-};
-
 /* TODO implement SYSINIT/SYSUNINIT subsystem */
 #define SYSINIT(uniquifier, subsystem, order, func, ident) \
        struct __system_init __init_##uniquifier = { (system_init_func_t) func }
@@ -51,9 +45,21 @@ struct intr_config_hook {
 #define SYSUNINIT(uniquifier, subsystem, order, func, ident) \
        struct __system_init __uninit_##uniquifier = { (system_init_func_t) 
func }
 
+
 #define TUNABLE_INT(path, var)
 #define TUNABLE_INT_FETCH(path, var)
 
-extern int32 ticks;
 
-#endif
+typedef void (*ich_func_t)(void *_arg);
+
+struct intr_config_hook {
+       TAILQ_ENTRY(intr_config_hook) ich_links;
+       ich_func_t      ich_func;
+       void            *ich_arg;
+};
+
+int config_intrhook_establish(struct intr_config_hook *hook);
+void config_intrhook_disestablish(struct intr_config_hook *hook);
+
+
+#endif // _FBSD_COMPAT_SYS_KERNEL_H_
diff --git a/src/libs/compat/freebsd11_network/compat/sys/mutex.h 
b/src/libs/compat/freebsd11_network/compat/sys/mutex.h
index 18b2838557..2666030fc8 100644
--- a/src/libs/compat/freebsd11_network/compat/sys/mutex.h
+++ b/src/libs/compat/freebsd11_network/compat/sys/mutex.h
@@ -39,6 +39,7 @@ extern struct mtx Giant;
 
 
 void mtx_init(struct mtx*, const char*, const char*, int);
+void mtx_sysinit(void *arg);
 void mtx_destroy(struct mtx*);
 
 
@@ -89,4 +90,22 @@ mtx_owned(struct mtx* mutex)
 }
 
 
+struct mtx_args {
+       void            *ma_mtx;
+       const char      *ma_desc;
+       int              ma_opts;
+};
+
+#define        MTX_SYSINIT(name, mtx, desc, opts)                              
\
+       static struct mtx_args name##_args = {                          \
+               (mtx),                                                  \
+               (desc),                                                 \
+               (opts)                                                  \
+       };                                                              \
+       SYSINIT(name##_mtx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE,       \
+           mtx_sysinit, &name##_args);                                 \
+       SYSUNINIT(name##_mtx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE,   \
+           mtx_destroy, __DEVOLATILE(void *, &(mtx)->mtx_lock))
+
+
 #endif /* _FBSD_COMPAT_SYS_MUTEX_H_ */
diff --git a/src/libs/compat/freebsd11_network/compat/sys/sysctl.h 
b/src/libs/compat/freebsd11_network/compat/sys/sysctl.h
index bfe3dd267f..3be80f6e84 100644
--- a/src/libs/compat/freebsd11_network/compat/sys/sysctl.h
+++ b/src/libs/compat/freebsd11_network/compat/sys/sysctl.h
@@ -76,8 +76,15 @@ sysctl_ctx_free(struct sysctl_ctx_list *clist)
 }
 
 
+static inline int
+sysctl_wire_old_buffer(struct sysctl_req *req, size_t len)
+{
+       return -1;
+}
+
+
 static inline void *
-sysctl_add_oid(struct sysctl_ctx_list *clist, void *parent, int nbr, 
+sysctl_add_oid(struct sysctl_ctx_list *clist, void *parent, int nbr,
        const char *name, int kind, void *arg1, int arg2,
        int (*handler) (SYSCTL_HANDLER_ARGS), const char *fmt, const char 
*descr)
 {
diff --git a/src/libs/compat/freebsd11_network/compat/sys/taskqueue.h 
b/src/libs/compat/freebsd11_network/compat/sys/taskqueue.h
index 77fa6a0604..64b2e5a8bb 100644
--- a/src/libs/compat/freebsd11_network/compat/sys/taskqueue.h
+++ b/src/libs/compat/freebsd11_network/compat/sys/taskqueue.h
@@ -33,6 +33,7 @@ void taskqueue_thread_enqueue(void *context);
 
 extern struct taskqueue *taskqueue_fast;
 extern struct taskqueue *taskqueue_swi;
+extern struct taskqueue *taskqueue_thread;
 
 int taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task);
 struct taskqueue *taskqueue_create_fast(const char *name, int mflags,
diff --git a/src/libs/compat/freebsd11_network/device.c 
b/src/libs/compat/freebsd11_network/device.c
index da9964752f..dfb4cdb862 100644
--- a/src/libs/compat/freebsd11_network/device.c
+++ b/src/libs/compat/freebsd11_network/device.c
@@ -51,7 +51,7 @@ compat_open(const char *name, uint32 flags, void **cookie)
 
        ifp->if_init(ifp->if_softc);
 
-       if (!HAIKU_DRIVER_REQUIRES(FBSD_WLAN)) {
+       if (!HAIKU_DRIVER_REQUIRES(FBSD_WLAN_FEATURE)) {
                ifp->if_flags &= ~IFF_UP;
                ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL);
 
diff --git a/src/libs/compat/freebsd11_network/mutex.c 
b/src/libs/compat/freebsd11_network/mutex.c
index d7589a8cbe..b9edac17e9 100644
--- a/src/libs/compat/freebsd11_network/mutex.c
+++ b/src/libs/compat/freebsd11_network/mutex.c
@@ -33,6 +33,16 @@ mtx_init(struct mtx *mutex, const char *name, const char 
*type,
 }
 
 
+void
+mtx_sysinit(void *arg)
+{
+       struct mtx_args *margs = arg;
+
+       mtx_init((struct mtx *)margs->ma_mtx, margs->ma_desc, NULL,
+           margs->ma_opts);
+}
+
+
 void
 mtx_destroy(struct mtx *mutex)
 {
diff --git a/src/libs/compat/freebsd11_network/subr_autoconf.cpp 
b/src/libs/compat/freebsd11_network/subr_autoconf.cpp
new file mode 100644
index 0000000000..60acdaa69b
--- /dev/null
+++ b/src/libs/compat/freebsd11_network/subr_autoconf.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Augustin Cavalier <waddlesplash>
+ */
+
+
+extern "C" {
+#      include <sys/kernel.h>
+}
+
+
+int
+config_intrhook_establish(struct intr_config_hook *hook)
+{
+       // By the time we get here, interrupts have already been set up, so
+       // unlike FreeBSD we do not need to store the hooks in a queue for 
later,
+       // but we can call them immediately. This is the same behavior that
+       // FreeBSD has as of 11.1 (however, they have a comment stating that
+       // it should probably not happen this way...)
+       (*hook->ich_func)(hook->ich_arg);
+       return 0;
+}
+
+
+void
+config_intrhook_disestablish(struct intr_config_hook *hook)
+{
+       // We don't store the hooks, so we don't need to do anything here.
+}
diff --git a/src/libs/compat/freebsd11_network/taskqueue.c 
b/src/libs/compat/freebsd11_network/taskqueue.c
index b4cf6d1c35..423ebaf98c 100644
--- a/src/libs/compat/freebsd11_network/taskqueue.c
+++ b/src/libs/compat/freebsd11_network/taskqueue.c
@@ -336,8 +336,26 @@ init_taskqueues()
                        goto err_2;
        }
 
+       if (HAIKU_DRIVER_REQUIRES(FBSD_THREAD_TASKQUEUE)) {
+               taskqueue_thread = taskqueue_create_fast("thread taskq", 0,
+                       taskqueue_thread_enqueue, &taskqueue_thread);
+               if (taskqueue_thread == NULL) {
+                       status = B_NO_MEMORY;
+                       goto err_2;
+               }
+
+               status = taskqueue_start_threads(&taskqueue_thread, 1,
+                       B_REAL_TIME_PRIORITY, "swi taskq");
+               if (status < B_OK)
+                       goto err_3;
+       }
+
        return B_OK;
 
+err_3:
+       if (taskqueue_thread)
+               taskqueue_free(taskqueue_thread);
+
 err_2:
        if (taskqueue_swi)
                taskqueue_free(taskqueue_swi);
@@ -353,6 +371,9 @@ err_1:
 void
 uninit_taskqueues()
 {
+       if (HAIKU_DRIVER_REQUIRES(FBSD_THREAD_TASKQUEUE))
+               taskqueue_free(taskqueue_thread);
+
        if (HAIKU_DRIVER_REQUIRES(FBSD_SWI_TASKQUEUE))
                taskqueue_free(taskqueue_swi);
 


Other related posts:

  • » [haiku-commits] haiku: hrev51994 - in src/libs/compat/freebsd11_network: . compat/sys - waddlesplash