kern_module.c (215544) | kern_module.c (215683) |
---|---|
1/*- 2 * Copyright (c) 1997 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include "opt_compat.h" 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include "opt_compat.h" 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/kern/kern_module.c 215544 2010-11-19 19:43:56Z attilio $"); | 30__FBSDID("$FreeBSD: head/sys/kern/kern_module.c 215683 2010-11-22 15:28:54Z attilio $"); |
31 32#include <sys/param.h> 33#include <sys/kernel.h> 34#include <sys/systm.h> 35#include <sys/eventhandler.h> 36#include <sys/malloc.h> 37#include <sys/sysproto.h> 38#include <sys/sysent.h> 39#include <sys/proc.h> 40#include <sys/lock.h> 41#include <sys/mutex.h> 42#include <sys/reboot.h> 43#include <sys/sx.h> 44#include <sys/module.h> 45#include <sys/linker.h> 46 47static MALLOC_DEFINE(M_MODULE, "module", "module data structures"); 48 | 31 32#include <sys/param.h> 33#include <sys/kernel.h> 34#include <sys/systm.h> 35#include <sys/eventhandler.h> 36#include <sys/malloc.h> 37#include <sys/sysproto.h> 38#include <sys/sysent.h> 39#include <sys/proc.h> 40#include <sys/lock.h> 41#include <sys/mutex.h> 42#include <sys/reboot.h> 43#include <sys/sx.h> 44#include <sys/module.h> 45#include <sys/linker.h> 46 47static MALLOC_DEFINE(M_MODULE, "module", "module data structures"); 48 |
49typedef TAILQ_HEAD(modulelst, module) modulelist_t; | |
50struct module { 51 TAILQ_ENTRY(module) link; /* chain together all modules */ 52 TAILQ_ENTRY(module) flink; /* all modules in a file */ 53 struct linker_file *file; /* file which contains this module */ 54 int refs; /* reference count */ 55 int id; /* unique id number */ 56 char *name; /* module name */ 57 modeventhand_t handler; /* event handler */ 58 void *arg; /* argument for handler */ 59 modspecific_t data; /* module specific data */ 60}; 61 62#define MOD_EVENT(mod, type) (mod)->handler((mod), (type), (mod)->arg) 63 | 49struct module { 50 TAILQ_ENTRY(module) link; /* chain together all modules */ 51 TAILQ_ENTRY(module) flink; /* all modules in a file */ 52 struct linker_file *file; /* file which contains this module */ 53 int refs; /* reference count */ 54 int id; /* unique id number */ 55 char *name; /* module name */ 56 modeventhand_t handler; /* event handler */ 57 void *arg; /* argument for handler */ 58 modspecific_t data; /* module specific data */ 59}; 60 61#define MOD_EVENT(mod, type) (mod)->handler((mod), (type), (mod)->arg) 62 |
64static modulelist_t modules; | 63static TAILQ_HEAD(modulelist, module) modules; |
65struct sx modules_sx; 66static int nextid = 1; 67static void module_shutdown(void *, int); 68 69static int 70modevent_nop(module_t mod, int what, void *arg) 71{ 72 --- 23 unchanged lines hidden (view full) --- 96module_shutdown(void *arg1, int arg2) 97{ 98 module_t mod; 99 100 if (arg2 & RB_NOSYNC) 101 return; 102 mtx_lock(&Giant); 103 MOD_SLOCK; | 64struct sx modules_sx; 65static int nextid = 1; 66static void module_shutdown(void *, int); 67 68static int 69modevent_nop(module_t mod, int what, void *arg) 70{ 71 --- 23 unchanged lines hidden (view full) --- 95module_shutdown(void *arg1, int arg2) 96{ 97 module_t mod; 98 99 if (arg2 & RB_NOSYNC) 100 return; 101 mtx_lock(&Giant); 102 MOD_SLOCK; |
104 TAILQ_FOREACH_REVERSE(mod, &modules, modulelst, link) | 103 TAILQ_FOREACH_REVERSE(mod, &modules, modulelist, link) |
105 MOD_EVENT(mod, MOD_SHUTDOWN); 106 MOD_SUNLOCK; 107 mtx_unlock(&Giant); 108} 109 110void 111module_register_init(const void *arg) 112{ --- 412 unchanged lines hidden --- | 104 MOD_EVENT(mod, MOD_SHUTDOWN); 105 MOD_SUNLOCK; 106 mtx_unlock(&Giant); 107} 108 109void 110module_register_init(const void *arg) 111{ --- 412 unchanged lines hidden --- |