Enhancing freebsd network compat layer with linkage support of the iprowifi2100
driver in mind. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34391 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3,11 +3,116 @@
|
|||||||
* Copyright 2007, Hugo Santos. All Rights Reserved.
|
* Copyright 2007, Hugo Santos. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* 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_
|
#ifndef _FBSD_COMPAT_MACHINE_BUS_H_
|
||||||
#define _FBSD_COMPAT_MACHINE_BUS_H_
|
#define _FBSD_COMPAT_MACHINE_BUS_H_
|
||||||
|
|
||||||
|
|
||||||
#include <machine/_bus.h>
|
#include <machine/_bus.h>
|
||||||
|
#include <machine/cpufunc.h>
|
||||||
|
|
||||||
|
|
||||||
// TODO: x86 specific!
|
// TODO: x86 specific!
|
||||||
@@ -39,15 +144,11 @@ void bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t handle,
|
|||||||
void bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t handle,
|
void bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t handle,
|
||||||
bus_size_t offset, uint32_t value);
|
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_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)
|
bus_size_t offset, u_int32_t *addr, size_t count)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (tag == I386_BUS_SPACE_IO) {
|
if (tag == I386_BUS_SPACE_IO) {
|
||||||
int _port_ = bsh + offset;
|
int _port_ = bsh + offset;
|
||||||
__asm __volatile(" \n\
|
__asm __volatile(" \n\
|
||||||
@@ -66,7 +167,7 @@ bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static __inline void
|
static inline void
|
||||||
bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
|
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)
|
bus_size_t offset, const u_int8_t *addr, size_t count)
|
||||||
{
|
{
|
||||||
@@ -99,6 +200,26 @@ bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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>
|
#include <machine/bus_dma.h>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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_ */
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <sys/_mutex.h>
|
#include <sys/_mutex.h>
|
||||||
#include <sys/pcpu.h>
|
#include <sys/pcpu.h>
|
||||||
#include <machine/atomic.h>
|
#include <machine/atomic.h>
|
||||||
|
#include <machine/cpufunc.h>
|
||||||
|
|
||||||
|
|
||||||
#define MA_OWNED 0x1
|
#define MA_OWNED 0x1
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <machine/atomic.h>
|
#include <machine/atomic.h>
|
||||||
|
#include <machine/cpufunc.h>
|
||||||
|
|
||||||
#include <sys/callout.h>
|
#include <sys/callout.h>
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
@@ -75,21 +76,19 @@ extern int sprintf(char *buf, const char *, ...);
|
|||||||
extern void driver_vprintf(const char *format, va_list vl);
|
extern void driver_vprintf(const char *format, va_list vl);
|
||||||
#define vprintf(fmt, vl) driver_vprintf(fmt, 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);
|
|
||||||
|
|
||||||
#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)
|
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
struct unrhdr;
|
struct unrhdr;
|
||||||
struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
|
struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
|
||||||
void delete_unrhdr(struct unrhdr *uh);
|
void delete_unrhdr(struct unrhdr *);
|
||||||
int alloc_unr(struct unrhdr *uh);
|
int alloc_unr(struct unrhdr *);
|
||||||
void free_unr(struct unrhdr *uh, u_int item);
|
void free_unr(struct unrhdr *, u_int);
|
||||||
|
|
||||||
#endif /* _FBSD_COMPAT_SYS_SYSTM_H_ */
|
#endif /* _FBSD_COMPAT_SYS_SYSTM_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user