tasklet.h revision 1.4 1 1.4 riastrad /* $NetBSD: tasklet.h,v 1.4 2021/12/19 01:17:46 riastradh Exp $ */
2 1.1 riastrad
3 1.1 riastrad /*-
4 1.1 riastrad * Copyright (c) 2018 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.3 riastrad #define tasklet_disable linux_tasklet_disable
37 1.4 riastrad #define tasklet_disable_sync_once linux_tasklet_disable_sync_once
38 1.3 riastrad #define tasklet_enable linux_tasklet_enable
39 1.4 riastrad #define tasklet_enable_sync_once linux_tasklet_enable_sync_once
40 1.3 riastrad #define tasklet_hi_schedule linux_tasklet_hi_schedule
41 1.3 riastrad #define tasklet_init linux_tasklet_init
42 1.4 riastrad #define tasklet_is_enabled linux_tasklet_is_enabled
43 1.3 riastrad #define tasklet_kill linux_tasklet_kill
44 1.3 riastrad #define tasklet_schedule linux_tasklet_schedule
45 1.3 riastrad #define tasklet_struct linux_tasklet_struct
46 1.1 riastrad
47 1.1 riastrad struct tasklet_struct {
48 1.1 riastrad SIMPLEQ_ENTRY(tasklet_struct) tl_entry;
49 1.1 riastrad volatile unsigned tl_state;
50 1.1 riastrad volatile unsigned tl_disablecount;
51 1.1 riastrad /* begin Linux API */
52 1.1 riastrad void (*func)(unsigned long);
53 1.1 riastrad unsigned long data;
54 1.1 riastrad /* end Linux API */
55 1.1 riastrad };
56 1.1 riastrad
57 1.1 riastrad #define DEFINE_TASKLET(name, func, data) \
58 1.1 riastrad struct tasklet_struct name = { \
59 1.1 riastrad .tl_state = 0, \
60 1.1 riastrad .tl_disablecount = 0, \
61 1.1 riastrad .func = (func), \
62 1.1 riastrad .data = (data), \
63 1.1 riastrad }
64 1.1 riastrad
65 1.1 riastrad #define DEFINE_TASKLET_DISABLED(name, func, data) \
66 1.1 riastrad struct tasklet_struct name = { \
67 1.1 riastrad .tl_state = 0, \
68 1.1 riastrad .tl_disablecount = 1, \
69 1.1 riastrad .func = (func), \
70 1.1 riastrad .data = (data), \
71 1.1 riastrad }
72 1.1 riastrad
73 1.1 riastrad int linux_tasklets_init(void);
74 1.1 riastrad void linux_tasklets_fini(void);
75 1.1 riastrad
76 1.1 riastrad void tasklet_init(struct tasklet_struct *, void (*)(unsigned long),
77 1.1 riastrad unsigned long);
78 1.1 riastrad void tasklet_disable(struct tasklet_struct *);
79 1.1 riastrad void tasklet_enable(struct tasklet_struct *);
80 1.1 riastrad void tasklet_schedule(struct tasklet_struct *);
81 1.1 riastrad void tasklet_hi_schedule(struct tasklet_struct *);
82 1.1 riastrad void tasklet_kill(struct tasklet_struct *);
83 1.1 riastrad
84 1.4 riastrad /* i915drmkms hack */
85 1.4 riastrad void tasklet_disable_sync_once(struct tasklet_struct *);
86 1.4 riastrad void tasklet_enable_sync_once(struct tasklet_struct *);
87 1.4 riastrad bool tasklet_is_enabled(const struct tasklet_struct *);
88 1.4 riastrad
89 1.1 riastrad #endif /* _LINUX_TASKLET_H_ */
90