Home | History | Annotate | Line # | Download | only in linux
tasklet.h revision 1.2
      1 /*	$NetBSD: tasklet.h,v 1.2 2021/12/19 01:17:23 riastradh Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2018 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Taylor R. Campbell.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef	_LINUX_TASKLET_H_
     33 #define	_LINUX_TASKLET_H_
     34 
     35 /* namespace */
     36 #define	tasklet_disable		linux_tasklet_disable
     37 #define	tasklet_enable		linux_tasklet_enable
     38 #define	tasklet_hi_schedule	linux_tasklet_hi_schedule
     39 #define	tasklet_init		linux_tasklet_init
     40 #define	tasklet_kill		linux_tasklet_kill
     41 #define	tasklet_schedule	linux_tasklet_schedule
     42 #define	tasklet_struct		linux_tasklet_struct
     43 
     44 struct tasklet_struct {
     45 	SIMPLEQ_ENTRY(tasklet_struct)	tl_entry;
     46 	volatile unsigned		tl_state;
     47 	volatile unsigned		tl_disablecount;
     48 	/* begin Linux API */
     49 	void				(*func)(unsigned long);
     50 	unsigned long			data;
     51 	/* end Linux API */
     52 };
     53 
     54 #define	DEFINE_TASKLET(name, func, data)				      \
     55 	struct tasklet_struct name = {					      \
     56 	    .tl_state = 0,						      \
     57 	    .tl_disablecount = 0,					      \
     58 	    .func = (func),						      \
     59 	    .data = (data),						      \
     60 	}
     61 
     62 #define	DEFINE_TASKLET_DISABLED(name, func, data)			      \
     63 	struct tasklet_struct name = {					      \
     64 	    .tl_state = 0,						      \
     65 	    .tl_disablecount = 1,					      \
     66 	    .func = (func),						      \
     67 	    .data = (data),						      \
     68 	}
     69 
     70 int	linux_tasklets_init(void);
     71 void	linux_tasklets_fini(void);
     72 
     73 void	tasklet_init(struct tasklet_struct *, void (*)(unsigned long),
     74 	    unsigned long);
     75 void	tasklet_disable(struct tasklet_struct *);
     76 void	tasklet_enable(struct tasklet_struct *);
     77 void	tasklet_schedule(struct tasklet_struct *);
     78 void	tasklet_hi_schedule(struct tasklet_struct *);
     79 void	tasklet_kill(struct tasklet_struct *);
     80 
     81 #endif	/* _LINUX_TASKLET_H_ */
     82