module.h revision 290335
11556Srgrimes/*- 21556Srgrimes * Copyright (c) 2010 Isilon Systems, Inc. 31556Srgrimes * Copyright (c) 2010 iX Systems, Inc. 41556Srgrimes * Copyright (c) 2010 Panasas, Inc. 51556Srgrimes * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 61556Srgrimes * All rights reserved. 71556Srgrimes * 81556Srgrimes * Redistribution and use in source and binary forms, with or without 91556Srgrimes * modification, are permitted provided that the following conditions 101556Srgrimes * are met: 111556Srgrimes * 1. Redistributions of source code must retain the above copyright 121556Srgrimes * notice unmodified, this list of conditions, and the following 131556Srgrimes * disclaimer. 141556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151556Srgrimes * notice, this list of conditions and the following disclaimer in the 161556Srgrimes * documentation and/or other materials provided with the distribution. 171556Srgrimes * 181556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 191556Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 201556Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 211556Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 221556Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 231556Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 241556Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 251556Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 261556Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 271556Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 281556Srgrimes * 291556Srgrimes * $FreeBSD: head/sys/compat/linuxkpi/common/include/linux/module.h 290335 2015-11-03 12:37:55Z hselasky $ 301556Srgrimes */ 311556Srgrimes#ifndef _LINUX_MODULE_H_ 321556Srgrimes#define _LINUX_MODULE_H_ 331556Srgrimes 341556Srgrimes#include <sys/cdefs.h> 351556Srgrimes#include <sys/types.h> 361556Srgrimes#include <sys/module.h> 371556Srgrimes 3836150Scharnier#include <linux/list.h> 3936150Scharnier#include <linux/compiler.h> 4036150Scharnier#include <linux/kobject.h> 4136150Scharnier#include <linux/sysfs.h> 4236150Scharnier#include <linux/moduleparam.h> 431556Srgrimes#include <linux/slab.h> 441556Srgrimes 4517987Speter#define MODULE_AUTHOR(name) 4617987Speter#define MODULE_DESCRIPTION(name) 4717987Speter#define MODULE_LICENSE(name) 4817987Speter 4917987Speter#define THIS_MODULE ((struct module *)0) 5017987Speter 5117987Speter#define EXPORT_SYMBOL(name) 5217987Speter#define EXPORT_SYMBOL_GPL(name) 5319281Sache 5417987Speter/* OFED pre-module initialization */ 551556Srgrimes#define SI_SUB_OFED_PREINIT (SI_SUB_ROOT_CONF - 2) 561556Srgrimes/* OFED default module initialization */ 571556Srgrimes#define SI_SUB_OFED_MODINIT (SI_SUB_ROOT_CONF - 1) 581556Srgrimes 591556Srgrimes#include <sys/linker.h> 601556Srgrimes 611556Srgrimesstatic inline void 621556Srgrimes_module_run(void *arg) 631556Srgrimes{ 641556Srgrimes void (*fn)(void); 651556Srgrimes#ifdef OFED_DEBUG_INIT 661556Srgrimes char name[1024]; 671556Srgrimes caddr_t pc; 681556Srgrimes long offset; 691556Srgrimes 701556Srgrimes pc = (caddr_t)arg; 711556Srgrimes if (linker_search_symbol_name(pc, name, sizeof(name), &offset) != 0) 721556Srgrimes printf("Running ??? (%p)\n", pc); 731556Srgrimes else 741556Srgrimes printf("Running %s (%p)\n", name, pc); 7517987Speter#endif 7617987Speter fn = arg; 771556Srgrimes DROP_GIANT(); 781556Srgrimes fn(); 791556Srgrimes PICKUP_GIANT(); 801556Srgrimes} 811556Srgrimes 821556Srgrimes#define module_init(fn) \ 831556Srgrimes SYSINIT(fn, SI_SUB_OFED_MODINIT, SI_ORDER_FIRST, _module_run, (fn)) 841556Srgrimes 851556Srgrimes#define module_exit(fn) \ 861556Srgrimes SYSUNINIT(fn, SI_SUB_OFED_MODINIT, SI_ORDER_SECOND, _module_run, (fn)) 871556Srgrimes 881556Srgrimes/* 891556Srgrimes * The following two macros are a workaround for not having a module 901556Srgrimes * load and unload order resolver: 911556Srgrimes */ 921556Srgrimes#define module_init_order(fn, order) \ 931556Srgrimes SYSINIT(fn, SI_SUB_OFED_MODINIT, (order), _module_run, (fn)) 941556Srgrimes 951556Srgrimes#define module_exit_order(fn, order) \ 961556Srgrimes SYSUNINIT(fn, SI_SUB_OFED_MODINIT, (order), _module_run, (fn)) 9717987Speter 9817987Speter#define module_get(module) 9917987Speter#define module_put(module) 10020425Ssteve#define try_module_get(module) 1 10117987Speter 10225233Ssteve#endif /* _LINUX_MODULE_H_ */ 10318202Speter