Annotation of src/sys/compat/ndis/nbcompat.c, Revision 1.5.16.1
1.1 rittera 1: /* nbcompat.c
2: * Implementations of some FreeBSD functions on NetBSD to make things
3: * a bit smoother.
4: */
5: #include <sys/param.h>
6: #include <sys/systm.h>
7: #include <sys/kernel.h>
8: #include <sys/kthread.h>
9: #include <sys/proc.h>
10: #include <sys/wait.h>
11: #include <sys/unistd.h>
12: #include <sys/types.h>
13: #include <sys/errno.h>
14: #include <sys/lock.h>
1.5.16.1! joerg 15: #include <sys/bus.h>
1.1 rittera 16:
17: #include <machine/stdarg.h>
18:
19: #include "nbcompat.h"
20:
21: /* note: this is also defined in ntoskrnl_var.h, but I didn't want to include
22: * the whole file here
23: */
24: #define NDIS_KSTACK_PAGES 8
25:
26: struct ndis_resource{
27: bus_space_handle_t res_handle;
28: bus_space_tag_t res_tag;
29: bus_addr_t res_base;
30: bus_size_t res_size;
31: };
32:
1.3 christos 33: int
1.4 christos 34: bus_release_resource(device_t dev, int type, int rid,
1.3 christos 35: struct ndis_resource *r)
1.1 rittera 36: {
37: switch(type) {
38: case SYS_RES_IOPORT:
39: bus_space_unmap(r->res_tag, r->res_handle, r->res_size);
40: break;
41: case SYS_RES_MEMORY:
42: bus_space_unmap(r->res_tag, r->res_handle, r->res_size);
43: break;
44: default:
45: printf("error: bus_release_resource()");
46: }
47:
48: return 0;
49: }
50:
1.3 christos 51: void
1.4 christos 52: mtx_lock(struct mtx *mutex)
1.1 rittera 53: {
54: /* I'm not sure if this is needed or not. NetBSD kernel
55: * threads aren't preempted, but there still may be a need
56: * for lockmgr locks.
57: */
58: //lockmgr(mutex, LK_EXCLUSIVE, NULL);
59: }
60:
1.3 christos 61: void
1.4 christos 62: mtx_unlock(struct mtx *mutex)
1.1 rittera 63: {
64: //lockmgr(mutex, LK_RELEASE, NULL);
65: }
66:
1.3 christos 67: int
1.4 christos 68: device_is_attached(device_t dev)
1.1 rittera 69: {
70: /* Sure, it's attached? */
71: return TRUE;
72: }
73:
74: /* I took this from sys/kern/kern_kthread.c (in the NetBSD source tree).
75: * The only difference is the kernel stack size
76: */
77:
78: /*
79: * Fork a kernel thread. Any process can request this to be done.
80: * The VM space and limits, etc. will be shared with proc0.
81: */
82: int
83: ndis_kthread_create(void (*func)(void *), void *arg,
84: struct proc **newpp, void *stack, size_t stacksize, const char *fmt, ...)
85: {
86: struct proc *p2;
87: int error;
88: va_list ap;
89:
90: /* First, create the new process. */
91: error = fork1(&lwp0, FORK_SHAREVM | FORK_SHARECWD | FORK_SHAREFILES |
92: FORK_SHARESIGS, SIGCHLD, stack, stacksize, func, arg, NULL, &p2);
93: if (__predict_false(error != 0))
94: return (error);
95:
96: /*
97: * Mark it as a system process and not a candidate for
98: * swapping. Set P_NOCLDWAIT so that children are reparented
99: * to init(8) when they exit. init(8) can easily wait them
100: * out for us.
101: */
1.5 pavel 102: p2->p_flag |= PK_SYSTEM | PK_NOCLDWAIT;
103: LIST_FIRST(&p2->p_lwps)->l_flag |= LW_INMEM;
1.1 rittera 104:
105: /* Name it as specified. */
106: va_start(ap, fmt);
107: vsnprintf(p2->p_comm, MAXCOMLEN, fmt, ap);
108: va_end(ap);
109:
110: /* All done! */
111: if (newpp != NULL)
112: *newpp = p2;
113: return (0);
114: }
CVSweb <webmaster@jp.NetBSD.org>