2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
5 * NBMK Encryption Technologies provides no support of any kind for
6 * this software. Questions or concerns about it may be addressed to
7 * the members of the relevant open-source community at
8 * <tech-crypto@netbsd.org>.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /*****************************************************************************
36 * @(#) helper.h 1.6@(#)
37 *****************************************************************************/
39 /*****************************************************************************/
41 * @brief FreeBSD System Call Abstraction - Header. *
43 * This file provides the FreeBSD implementations of various abstract system *
44 * calls and defined constants. *
45 *****************************************************************************/
47 /*****************************************************************************
49 * 05/12/03 brr Added N8_GET_KERNEL_ID. (Bug 863)
50 * 05/05/03 brr Removed unused #defines.
51 * 04/21/03 brr Added vmalloc/vfree macros for context memory allocation.
52 * 01/06/03 brr/jpw Define N8_GET_SESSION_ID to use process ID, not group.
53 * 10/25/02 brr File created.
54 ****************************************************************************/
55 /** @defgroup NSP2000Driver FreeBSD System Call Abstraction - Header.
67 #include <sys/systm.h>
68 #include <sys/module.h>
73 #include <machine/bus.h>
75 #include <machine/resource.h>
78 #include <sys/ioccom.h>
79 #include <sys/libkern.h>
82 #include <vm/vm_page.h>
83 #include <vm/vm_param.h>
85 #include "n8_enqueue_common.h"
87 #include <sys/param.h>
88 #include <sys/kernel.h>
89 #include <sys/malloc.h>
90 #include <sys/simplelock.h>
91 #include "n8_enqueue_common.h"
93 /* Macros for copying data to and from user space */
94 #define N8_TO_USER(_user,_kernel,_size) copyout((_kernel), (_user), (_size))
95 #define N8_FROM_USER(_kernel,_user,_size) copyin((_user), (_kernel), (_size))
97 #define vmalloc(size) malloc(size, M_DEVBUF, M_WAITOK)
98 #define vfree(ptr) free(ptr, M_DEVBUF)
101 /* ABSTRACT ATOMIC RESOURCE LOCK */
102 /* typedef int ATOMICLOCK_t; */
103 typedef struct simplelock ATOMICLOCK_t
;
104 #define N8_AtomicLock(x) simple_lock(&x)
105 #define N8_AtomicUnlock(x) simple_unlock(&x)
106 #define N8_AtomicLockInit(x) simple_lock_init(&x)
107 #define N8_AtomicLockDel(x)
111 /* ABSTRACT BLOCKING MECHANISM */
112 #define wait_queue_head_t atomic_t
113 #define init_waitqueue_head(A)
114 typedef int n8_WaitQueue_t
;
115 typedef unsigned char wait_queue_head_t
;
116 #define WakeUp(A) wakeup(A);
117 #define N8_InitWaitQueue(q_p)
119 extern int N8_WaitEventInt(n8_WaitQueue_t
*, API_Request_t
*);
120 #define N8_DelWaitQueue(q_p)
123 /* DEBUG MESSAGE DEFINES */
126 #define N8_GET_SESSION_ID curproc->p_pid
127 #define N8_GET_KERNEL_ID 0xdead0000
129 /*****************************************************************************
131 *****************************************************************************/
132 /** @ingroup NSP2000Driver
133 * @brief Convert a physical address to a virtual address.
135 * This routine abstracts the BSDi system call to convert a physical address
136 * to a virtual address.
138 * @param physaddr RO: Specifies the physical address.
144 * Returns the corresponding virtual address.
147 * See return section for error information.
148 *****************************************************************************/
150 extern void *N8_PhysToVirt(unsigned long physaddr
);
154 /*****************************************************************************
156 *****************************************************************************/
157 /** @ingroup NSP2000Driver
158 * @brief Convert a virtual address to a physical address.
160 * This routine abstracts the BSDi system call to convert a virtual address
161 * to a physical address.
163 * @param virtaddr RO: Specifies the physical address.
169 * Returns the corresponding physical address.
172 * See return section for error information.
173 *****************************************************************************/
175 extern unsigned long N8_VirtToPhys(void *virtaddr
);
177 int n8_bounds_check(unsigned long phys
);
180 #endif /* HELPER_H */