[BACK]Return to nbcompat.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / compat / ndis

Annotation of src/sys/compat/ndis/nbcompat.c, Revision 1.2.10.2

1.2.10.2! rpaulo      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>
        !            15: #include <machine/bus.h>
        !            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:
        !            33: int bus_release_resource(dev, type, rid, r)
        !            34:        device_t                 dev;
        !            35:        int                      type;
        !            36:        int                      rid;
        !            37:        struct ndis_resource    *r;
        !            38: {
        !            39:        switch(type) {
        !            40:        case SYS_RES_IOPORT:
        !            41:                bus_space_unmap(r->res_tag, r->res_handle, r->res_size);
        !            42:                break;
        !            43:        case SYS_RES_MEMORY:
        !            44:                bus_space_unmap(r->res_tag, r->res_handle, r->res_size);
        !            45:                break;
        !            46:        default:
        !            47:                printf("error: bus_release_resource()");
        !            48:        }
        !            49:
        !            50:        return 0;
        !            51: }
        !            52:
        !            53: void mtx_lock(struct mtx *mutex)
        !            54: {
        !            55:        /* I'm not sure if this is needed or not.  NetBSD kernel
        !            56:         * threads aren't preempted, but there still may be a need
        !            57:         * for lockmgr locks.
        !            58:         */
        !            59:        //lockmgr(mutex, LK_EXCLUSIVE, NULL);
        !            60: }
        !            61:
        !            62: void mtx_unlock(struct mtx *mutex)
        !            63: {
        !            64:        //lockmgr(mutex, LK_RELEASE, NULL);
        !            65: }
        !            66:
        !            67: int device_is_attached(dev)
        !            68:        device_t dev;
        !            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:          */
        !           102:         p2->p_flag |= P_SYSTEM | P_NOCLDWAIT;
        !           103:         LIST_FIRST(&p2->p_lwps)->l_flag |= L_INMEM;
        !           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>