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