[haiku-commits] r34391 - in haiku/trunk/src/libs/compat/freebsd_network/compat: machine sys

  • From: coling@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 30 Nov 2009 22:19:30 +0100 (CET)

Author: colin
Date: 2009-11-30 22:19:30 +0100 (Mon, 30 Nov 2009)
New Revision: 34391
Changeset: http://dev.haiku-os.org/changeset/34391/haiku

Added:
   haiku/trunk/src/libs/compat/freebsd_network/compat/machine/cpufunc.h
Modified:
   haiku/trunk/src/libs/compat/freebsd_network/compat/machine/bus.h
   haiku/trunk/src/libs/compat/freebsd_network/compat/sys/mutex.h
   haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h
Log:
Enhancing freebsd network compat layer with linkage support of the iprowifi2100
driver in mind.


Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/machine/bus.h
===================================================================
--- haiku/trunk/src/libs/compat/freebsd_network/compat/machine/bus.h    
2009-11-30 21:12:29 UTC (rev 34390)
+++ haiku/trunk/src/libs/compat/freebsd_network/compat/machine/bus.h    
2009-11-30 21:19:30 UTC (rev 34391)
@@ -3,11 +3,116 @@
  * Copyright 2007, Hugo Santos. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  */
+
+
+/*-
+ * Copyright (c) KATO Takenori, 1999.
+ *
+ * All rights reserved.  Unpublished rights reserved under the copyright
+ * laws of Japan.
+ *
+ * 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 as
+ *    the first lines of this file unmodified.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ *
+ * $FreeBSD$
+ */
+
+/*     $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $    */
+
+/*-
+ * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*-
+ * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
+ * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Christopher G. Demetriou
+ *     for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
 #ifndef _FBSD_COMPAT_MACHINE_BUS_H_
 #define _FBSD_COMPAT_MACHINE_BUS_H_
 
 
 #include <machine/_bus.h>
+#include <machine/cpufunc.h>
 
 
 // TODO: x86 specific!
@@ -39,26 +144,22 @@
 void bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t handle,
        bus_size_t offset, uint32_t value);
 
-void bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
-       bus_size_t offset, const u_int8_t *addr, size_t count);
 
-
-static __inline void
+static inline void
 bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
        bus_size_t offset, u_int32_t *addr, size_t count)
 {
-
        if (tag == I386_BUS_SPACE_IO) {
                int _port_ = bsh + offset;
-               __asm __volatile("                              \n\
-                       cld                                     \n\
-               1:      inl %w2,%%eax                           \n\
-                       stosl                                   \n\
-                       addl $4,%2                              \n\
-                       loop 1b"                                :
-                   "=D" (addr), "=c" (count), "=d" (_port_)    :
-                   "0" (addr), "1" (count), "2" (_port_)       :
-                   "%eax", "memory", "cc");
+               __asm __volatile("                                              
        \n\
+                       cld                                                     
                        \n\
+               1:      inl %w2,%%eax                                           
        \n\
+                       stosl                                                   
                \n\
+                       addl $4,%2                                              
                \n\
+                       loop 1b"                                                
                :
+                       "=D" (addr), "=c" (count), "=d" (_port_):
+                       "0" (addr), "1" (count), "2" (_port_)   :
+                       "%eax", "memory", "cc");
        } else {
                void* _port_ = (void*) (bsh + offset);
                memcpy(addr, _port_, count);
@@ -66,21 +167,21 @@
 }
 
 
-static __inline void
+static inline void
 bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
        bus_size_t offset, const u_int8_t *addr, size_t count)
 {
        if (tag == I386_BUS_SPACE_IO) {
                int _port_ = bsh + offset;
-               __asm __volatile("                              \n\
-                       cld                                     \n\
-               1:      lodsb                                   \n\
-                       outb %%al,%w0                           \n\
-                       incl %0                                 \n\
-                       loop 1b"                                :
-                   "=d" (_port_), "=S" (addr), "=c" (count)    :
-                   "0" (_port_), "1" (addr), "2" (count)       :
-                   "%eax", "memory", "cc");
+               __asm __volatile("                                              
        \n\
+                       cld                                                     
                        \n\
+               1:      lodsb                                                   
                \n\
+                       outb %%al,%w0                                           
        \n\
+                       incl %0                                                 
                \n\
+                       loop 1b"                                                
                :
+                       "=d" (_port_), "=S" (addr), "=c" (count):
+                       "0" (_port_), "1" (addr), "2" (count)   :
+                       "%eax", "memory", "cc");
        } else {
                void* _port_ = (void*) (bsh + offset);
                memcpy(_port_, addr, count);
@@ -99,6 +200,26 @@
 }
 
 
+static inline void
+bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
+       bus_size_t offset, const u_int8_t *addr, size_t count)
+{
+
+       if (tag == I386_BUS_SPACE_IO)
+               outsb(bsh + offset, addr, count);
+       else {
+               __asm __volatile("                                              
                \n\
+                       cld                                                     
                                \n\
+               1:      lodsb                                                   
                        \n\
+                       movb %%al,(%2)                                          
                \n\
+                       loop 1b"                                                
                        :
+                       "=S" (addr), "=c" (count)                               
        :
+                       "r" (bsh + offset), "0" (addr), "1" (count)     :
+                       "%eax", "memory", "cc");
+       }
+}
+
+
 #include <machine/bus_dma.h>
 
 

Added: haiku/trunk/src/libs/compat/freebsd_network/compat/machine/cpufunc.h
===================================================================
--- haiku/trunk/src/libs/compat/freebsd_network/compat/machine/cpufunc.h        
                        (rev 0)
+++ haiku/trunk/src/libs/compat/freebsd_network/compat/machine/cpufunc.h        
2009-11-30 21:19:30 UTC (rev 34391)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1993 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * $FreeBSD$
+ */
+#ifndef _FBSD_COMPAT_MACHINE_CPUFUNC_H_
+#define _FBSD_COMPAT_MACHINE_CPUFUNC_H_
+
+
+static __inline void
+outsb(u_int port, const void *addr, size_t cnt)
+{
+       __asm __volatile("cld; rep; outsb"
+                        : "+S" (addr), "+c" (cnt)
+                        : "d" (port));
+}
+
+#endif /* _FBSD_COMPAT_MACHINE_CPUFUNC_H_ */

Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/mutex.h
===================================================================
--- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/mutex.h      
2009-11-30 21:12:29 UTC (rev 34390)
+++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/mutex.h      
2009-11-30 21:19:30 UTC (rev 34391)
@@ -13,6 +13,7 @@
 #include <sys/_mutex.h>
 #include <sys/pcpu.h>
 #include <machine/atomic.h>
+#include <machine/cpufunc.h>
 
 
 #define MA_OWNED               0x1

Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h
===================================================================
--- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h      
2009-11-30 21:12:29 UTC (rev 34390)
+++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/systm.h      
2009-11-30 21:19:30 UTC (rev 34391)
@@ -11,6 +11,7 @@
 #include <string.h>
 
 #include <machine/atomic.h>
+#include <machine/cpufunc.h>
 
 #include <sys/callout.h>
 #include <sys/cdefs.h>
@@ -75,21 +76,19 @@
 extern void driver_vprintf(const char *format, va_list vl);
 #define        vprintf(fmt, vl) driver_vprintf(fmt, vl)
 
-extern int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 
0);
+extern int vsnprintf(char *, size_t, const char *, __va_list)
+       __printflike(3, 0);
 
-int    msleep(void* chan, struct mtx* mutex, int pri, const char* wmesg, int 
timo);
+int msleep(void *, struct mtx *, int, const char *, int);
+int _pause(const char *, int);
+#define pause(waitMessage, timeout) _pause((waitMessage), (timeout))
+#define tsleep(channel, priority, waitMessage, timeout)                        
                \
+       msleep((channel), NULL, (priority), (waitMessage), (timeout))
 
-#define        tsleep(chan, pri, wmesg, timo)                                  
\
-       msleep((chan), NULL, (pri), (wmesg), (timo))
-
-// TODO call tsleep with an identifier != NULL
-#define pause(wmesg, timo) tsleep(NULL, 0, wmesg, timo)
-
-
 struct unrhdr;
 struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
-void delete_unrhdr(struct unrhdr *uh);
-int alloc_unr(struct unrhdr *uh);
-void free_unr(struct unrhdr *uh, u_int item);
+void delete_unrhdr(struct unrhdr *);
+int alloc_unr(struct unrhdr *);
+void free_unr(struct unrhdr *, u_int);
 
 #endif /* _FBSD_COMPAT_SYS_SYSTM_H_ */


Other related posts:

  • » [haiku-commits] r34391 - in haiku/trunk/src/libs/compat/freebsd_network/compat: machine sys - coling