module_khelp.h revision 296373
1169689Skan/*- 290075Sobrien * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> 390075Sobrien * Copyright (c) 2010 The FreeBSD Foundation 490075Sobrien * All rights reserved. 590075Sobrien * 690075Sobrien * This software was developed by Lawrence Stewart while studying at the Centre 790075Sobrien * for Advanced Internet Architectures, Swinburne University of Technology, made 890075Sobrien * possible in part by grants from the FreeBSD Foundation and Cisco University 990075Sobrien * Research Program Fund at Community Foundation Silicon Valley. 1090075Sobrien * 1190075Sobrien * Portions of this software were developed at the Centre for Advanced 1290075Sobrien * Internet Architectures, Swinburne University of Technology, Melbourne, 1390075Sobrien * Australia by Lawrence Stewart under sponsorship from the FreeBSD Foundation. 1490075Sobrien * 1590075Sobrien * Redistribution and use in source and binary forms, with or without 1690075Sobrien * modification, are permitted provided that the following conditions 17132718Skan * are met: 1890075Sobrien * 1. Redistributions of source code must retain the above copyright 1990075Sobrien * notice, this list of conditions and the following disclaimer. 2090075Sobrien * 2. Redistributions in binary form must reproduce the above copyright 2190075Sobrien * notice, this list of conditions and the following disclaimer in the 2290075Sobrien * documentation and/or other materials provided with the distribution. 2390075Sobrien * 2490075Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2590075Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2690075Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2790075Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2890075Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2990075Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3090075Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3190075Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3290075Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3390075Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3490075Sobrien * SUCH DAMAGE. 3590075Sobrien * 3690075Sobrien * $FreeBSD: releng/10.3/sys/sys/module_khelp.h 251789 2013-06-15 10:38:31Z lstewart $ 3790075Sobrien */ 3890075Sobrien 3990075Sobrien#ifndef _SYS_MODULE_KHELP_H_ 4090075Sobrien#define _SYS_MODULE_KHELP_H_ 4190075Sobrien 4290075Sobrien/* XXXLAS: Needed for uma related typedefs. */ 4390075Sobrien#include <vm/uma.h> 4490075Sobrien 4590075Sobrien/* Helper flags. */ 4690075Sobrien#define HELPER_NEEDS_OSD 0x0001 47132718Skan 4890075Sobrienstruct helper { 4990075Sobrien int (*mod_init) (void); 5090075Sobrien int (*mod_destroy) (void); 5190075Sobrien#define HELPER_NAME_MAXLEN 16 5290075Sobrien char h_name[HELPER_NAME_MAXLEN]; 53169689Skan uma_zone_t h_zone; 54169689Skan struct hookinfo *h_hooks; 55169689Skan uint32_t h_nhooks; 56169689Skan uint32_t h_classes; 57169689Skan int32_t h_id; 58169689Skan volatile uint32_t h_refcount; 59169689Skan uint16_t h_flags; 6090075Sobrien TAILQ_ENTRY(helper) h_next; 6190075Sobrien}; 6290075Sobrien 6390075Sobrienstruct khelp_modevent_data { 6490075Sobrien char name[HELPER_NAME_MAXLEN]; 6590075Sobrien struct helper *helper; 6696263Sobrien struct hookinfo *hooks; 6790075Sobrien int nhooks; 6890075Sobrien int uma_zsize; 6990075Sobrien uma_ctor umactor; 7090075Sobrien uma_dtor umadtor; 7190075Sobrien}; 7290075Sobrien 7390075Sobrien#define KHELP_DECLARE_MOD_UMA(hname, hdata, hhooks, version, size, ctor, dtor) \ 74169689Skan static struct khelp_modevent_data kmd_##hname = { \ 75169689Skan .name = #hname, \ 76169689Skan .helper = hdata, \ 77169689Skan .hooks = hhooks, \ 7890075Sobrien .nhooks = sizeof(hhooks) / sizeof(hhooks[0]), \ 7990075Sobrien .uma_zsize = size, \ 8090075Sobrien .umactor = ctor, \ 8190075Sobrien .umadtor = dtor \ 8290075Sobrien }; \ 8390075Sobrien static moduledata_t h_##hname = { \ 8490075Sobrien .name = #hname, \ 8590075Sobrien .evhand = khelp_modevent, \ 8690075Sobrien .priv = &kmd_##hname \ 8790075Sobrien }; \ 8890075Sobrien DECLARE_MODULE(hname, h_##hname, SI_SUB_KLD, SI_ORDER_ANY); \ 8990075Sobrien MODULE_VERSION(hname, version) 9090075Sobrien 9190075Sobrien#define KHELP_DECLARE_MOD(hname, hdata, hhooks, version) \ 9290075Sobrien KHELP_DECLARE_MOD_UMA(hname, hdata, hhooks, version, 0, NULL, NULL) 9390075Sobrien 9490075Sobrienint khelp_modevent(module_t mod, int type, void *data); 9590075Sobrien 9690075Sobrien#endif /* _SYS_MODULE_KHELP_H_ */ 9790075Sobrien