1124882Srwatson/*- 2124882Srwatson * Copyright (c) 2000 Doug Rabson 3124882Srwatson * All rights reserved. 4124882Srwatson * 5124882Srwatson * Redistribution and use in source and binary forms, with or without 6124882Srwatson * modification, are permitted provided that the following conditions 7124882Srwatson * are met: 8124882Srwatson * 1. Redistributions of source code must retain the above copyright 9124882Srwatson * notice, this list of conditions and the following disclaimer. 10124882Srwatson * 2. Redistributions in binary form must reproduce the above copyright 11124882Srwatson * notice, this list of conditions and the following disclaimer in the 12124882Srwatson * documentation and/or other materials provided with the distribution. 13124882Srwatson * 14124882Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15124882Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16124882Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17124882Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18124882Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19124882Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20124882Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21124882Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22124882Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23124882Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24124882Srwatson * SUCH DAMAGE. 25124882Srwatson * 26124882Srwatson * $FreeBSD: stable/11/sys/sys/_task.h 333338 2018-05-07 21:42:22Z shurd $ 27124882Srwatson */ 28124882Srwatson 29124882Srwatson#ifndef _SYS__TASK_H_ 30124882Srwatson#define _SYS__TASK_H_ 31124882Srwatson 32124882Srwatson#include <sys/queue.h> 33124882Srwatson 34124882Srwatson/* 35124882Srwatson * Each task includes a function which is called from 36124882Srwatson * taskqueue_run(). The first argument is taken from the 'ta_context' 37124882Srwatson * field of struct task and the second argument is a count of how many 38124882Srwatson * times the task was enqueued before the call to taskqueue_run(). 39210377Smdf * 40210377Smdf * List of locks 41210377Smdf * (c) const after init 42210377Smdf * (q) taskqueue lock 43124882Srwatson */ 44124882Srwatsontypedef void task_fn_t(void *context, int pending); 45304704Sshurdtypedef void gtask_fn_t(void *context); 46124882Srwatson 47124882Srwatsonstruct task { 48210377Smdf STAILQ_ENTRY(task) ta_link; /* (q) link for queue */ 49300372Savg uint16_t ta_pending; /* (q) count times queued */ 50210377Smdf u_short ta_priority; /* (c) Priority */ 51210377Smdf task_fn_t *ta_func; /* (c) task handler */ 52210377Smdf void *ta_context; /* (c) argument for handler */ 53124882Srwatson}; 54124882Srwatson 55304704Sshurdstruct gtask { 56304704Sshurd STAILQ_ENTRY(gtask) ta_link; /* (q) link for queue */ 57304704Sshurd uint16_t ta_flags; /* (q) state flags */ 58304704Sshurd u_short ta_priority; /* (c) Priority */ 59304704Sshurd gtask_fn_t *ta_func; /* (c) task handler */ 60304704Sshurd void *ta_context; /* (c) argument for handler */ 61304704Sshurd}; 62304704Sshurd 63300113Sscottlstruct grouptask { 64304704Sshurd struct gtask gt_task; 65300113Sscottl void *gt_taskqueue; 66300113Sscottl LIST_ENTRY(grouptask) gt_list; 67300113Sscottl void *gt_uniq; 68333338Sshurd#define GROUPTASK_NAMELEN 32 69333338Sshurd char gt_name[GROUPTASK_NAMELEN]; 70300113Sscottl int16_t gt_irq; 71300113Sscottl int16_t gt_cpu; 72300113Sscottl}; 73300113Sscottl 74124882Srwatson#endif /* !_SYS__TASK_H_ */ 75