| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: module.9,v 1.45 2018/06/03 01:52:47 pgoyette Exp $ | | 1 | .\" $NetBSD: module.9,v 1.46 2018/06/03 10:34:59 pgoyette Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2010 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 2010 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Andrew Doran. | | 7 | .\" by Andrew Doran. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -33,27 +33,31 @@ | | | @@ -33,27 +33,31 @@ |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm module , | | 34 | .Nm module , |
35 | .Nm module_load , | | 35 | .Nm module_load , |
36 | .Nm module_autoload , | | 36 | .Nm module_autoload , |
37 | .Nm module_unload , | | 37 | .Nm module_unload , |
38 | .Nm module_init_class , | | 38 | .Nm module_init_class , |
39 | .Nm module_hold , | | 39 | .Nm module_hold , |
40 | .Nm module_rele , | | 40 | .Nm module_rele , |
41 | .Nm module_find_section , | | 41 | .Nm module_find_section , |
42 | .Nm module_kernel , | | 42 | .Nm module_kernel , |
43 | .Nm module_name , | | 43 | .Nm module_name , |
44 | .Nm module_source , | | 44 | .Nm module_source , |
45 | .Nm module_register_callbacks , | | 45 | .Nm module_register_callbacks , |
46 | .Nm module_unregister_callbacks | | 46 | .Nm module_unregister_callbacks , |
| | | 47 | .Nm module_specific_key_create , |
| | | 48 | .Nm module_specific_key_delete , |
| | | 49 | .Nm module_getspecific , |
| | | 50 | .Nm module_setspecific |
47 | .Nd kernel module loader | | 51 | .Nd kernel module loader |
48 | .Sh SYNOPSIS | | 52 | .Sh SYNOPSIS |
49 | .In sys/module.h | | 53 | .In sys/module.h |
50 | .Fn MODULE "class" "name" "required" | | 54 | .Fn MODULE "class" "name" "required" |
51 | .Ft int | | 55 | .Ft int |
52 | .Fn module_load "const char *name" "int flags" "prop_dictionary_t props" \ | | 56 | .Fn module_load "const char *name" "int flags" "prop_dictionary_t props" \ |
53 | "modclass_t class" | | 57 | "modclass_t class" |
54 | .Ft int | | 58 | .Ft int |
55 | .Fn module_autoload "const char *name" "modclass_t class" | | 59 | .Fn module_autoload "const char *name" "modclass_t class" |
56 | .Ft int | | 60 | .Ft int |
57 | .Fn module_unload "const char *name" | | 61 | .Fn module_unload "const char *name" |
58 | .Ft void | | 62 | .Ft void |
59 | .Fn module_init_class "modclass_t class" | | 63 | .Fn module_init_class "modclass_t class" |
| @@ -72,26 +76,35 @@ | | | @@ -72,26 +76,35 @@ |
72 | .Ft void | | 76 | .Ft void |
73 | .Fn module_init "void" | | 77 | .Fn module_init "void" |
74 | .Ft void | | 78 | .Ft void |
75 | .Fn module_start_unload_thread "void" | | 79 | .Fn module_start_unload_thread "void" |
76 | .Ft void | | 80 | .Ft void |
77 | .Fn module_builtin_require_force "void" | | 81 | .Fn module_builtin_require_force "void" |
78 | .Ft void | | 82 | .Ft void |
79 | .Fn module_load_vfs_init "void" | | 83 | .Fn module_load_vfs_init "void" |
80 | .Ft "void *" | | 84 | .Ft "void *" |
81 | .Fn module_register_callbacks "void (*)(struct module *)" \ | | 85 | .Fn module_register_callbacks "void (*)(struct module *)" \ |
82 | "void (*unload)(struct module *)" | | 86 | "void (*unload)(struct module *)" |
83 | .Ft void | | 87 | .Ft void |
84 | .Fn module_unregister_callbacks "void *" | | 88 | .Fn module_unregister_callbacks "void *" |
| | | 89 | .Ft specificdata_key_t |
| | | 90 | .Fn module_specific_key_create "specificdata_key_t *keyp" \ |
| | | 91 | "specificdata_dtor_t dtor" |
| | | 92 | .Ft void |
| | | 93 | .Fn module_specific_key_delete "specificdata_key_t key" |
| | | 94 | .Ft "void *" |
| | | 95 | .Fn module_getspecific "module_t *mod" "specificdata_key_t key" |
| | | 96 | .Ft "void *" |
| | | 97 | .Fn module_setspecific "module_t *mod" "specificdata_key_t key" "void *data" |
85 | .Sh DESCRIPTION | | 98 | .Sh DESCRIPTION |
86 | Modules are sections of code that can be independently linked and selectively | | 99 | Modules are sections of code that can be independently linked and selectively |
87 | loaded into or unloaded from a running kernel. | | 100 | loaded into or unloaded from a running kernel. |
88 | This provides a mechanism to update the module without having to relink | | 101 | This provides a mechanism to update the module without having to relink |
89 | the kernel and reboot. | | 102 | the kernel and reboot. |
90 | Modules can be loaded from within the kernel image, provided by the boot | | 103 | Modules can be loaded from within the kernel image, provided by the boot |
91 | loader, or loaded from the file system. | | 104 | loader, or loaded from the file system. |
92 | .Pp | | 105 | .Pp |
93 | The | | 106 | The |
94 | .Nm | | 107 | .Nm |
95 | subsystem includes two data types: | | 108 | subsystem includes two data types: |
96 | .Bl -enum -offset indent | | 109 | .Bl -enum -offset indent |
97 | .It | | 110 | .It |
| @@ -469,26 +482,51 @@ successfully loaded; the | | | @@ -469,26 +482,51 @@ successfully loaded; the |
469 | callback is invoked before any module is unloaded. | | 482 | callback is invoked before any module is unloaded. |
470 | Each load or unload event can result in multiple invocations of the | | 483 | Each load or unload event can result in multiple invocations of the |
471 | callback routines. | | 484 | callback routines. |
472 | An opaque cookie is returned which can be passed to | | 485 | An opaque cookie is returned which can be passed to |
473 | .Fn module_unregister_callbacks . | | 486 | .Fn module_unregister_callbacks . |
474 | .It Fn module_unregister_callbacks "void *opaque" | | 487 | .It Fn module_unregister_callbacks "void *opaque" |
475 | Unregister a set of callback routines previously registered with | | 488 | Unregister a set of callback routines previously registered with |
476 | .Fn module_register_callbacks . | | 489 | .Fn module_register_callbacks . |
477 | The | | 490 | The |
478 | .Fa opaque | | 491 | .Fa opaque |
479 | argument should be the return value from the previous | | 492 | argument should be the return value from the previous |
480 | .Fn module_register_callbacks | | 493 | .Fn module_register_callbacks |
481 | call. | | 494 | call. |
| | | 495 | .It module_specific_key_create "specificdata_key_t *keyp" \ |
| | | 496 | "specificdata_dtor_t dtor" |
| | | 497 | Creates a new specificdata_key for use within the |
| | | 498 | .Nm |
| | | 499 | domain. |
| | | 500 | The key identifier is returned in |
| | | 501 | .Fa keyp . |
| | | 502 | .It module_specific_key_delete "specificdata_key_t key" |
| | | 503 | Deletes the specified specificdata_key |
| | | 504 | .Fa key |
| | | 505 | from the |
| | | 506 | .Nm domain. |
| | | 507 | .It module_getspecific "module_t *mod" "specificdata_key_t key" |
| | | 508 | Retrieves the value associated with |
| | | 509 | .Fa key |
| | | 510 | from module |
| | | 511 | .Fa mod . |
| | | 512 | .It module_setspecific "module_t *mod" "specificdata_key_t key" "void *data" |
| | | 513 | Stores |
| | | 514 | .Fa data |
| | | 515 | as the value associated with |
| | | 516 | .Fa key |
| | | 517 | for module |
| | | 518 | .Fa mod . |
| | | 519 | |
482 | .El | | 520 | .El |
483 | .Sh PROGRAMMING CONSIDERATIONS | | 521 | .Sh PROGRAMMING CONSIDERATIONS |
484 | The module subsystem is designed to be called recursively, but only within | | 522 | The module subsystem is designed to be called recursively, but only within |
485 | a single LWP. | | 523 | a single LWP. |
486 | This permits one module's | | 524 | This permits one module's |
487 | .Fn modcmd | | 525 | .Fn modcmd |
488 | routine to load or unload other modules. | | 526 | routine to load or unload other modules. |
489 | .Pp | | 527 | .Pp |
490 | Additional considerations: | | 528 | Additional considerations: |
491 | .Bl -bullet -offset indent | | 529 | .Bl -bullet -offset indent |
492 | .It | | 530 | .It |
493 | A module is not permitted to load or unload itself. | | 531 | A module is not permitted to load or unload itself. |
494 | Attempts to load or unload a module from within its own | | 532 | Attempts to load or unload a module from within its own |