summaryrefslogtreecommitdiff
path: root/sys/kern/kern_module.c
Commit message (Collapse)AuthorAgeFilesLines
* kern: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-1/+1
| | | | Notes: svn path=/head/; revision=365222
* Use NULL for SYSINIT's last arg, which is a pointer typeEd Maste2018-05-181-1/+1
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=333806
* Move most of the contents of opt_compat.h to opt_global.h.Brooks Davis2018-04-061-2/+0
| | | | | | | | | | | | | | | | | | | | | opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Notes: svn path=/head/; revision=332122
* sys/kern: adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326271
* Provide better debug message on kernel module name clash.Edward Tomasz Napierala2015-10-101-6/+2
| | | | | | | | | Reviewed by: kib@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=289111
* Fix a typo.John Baldwin2012-08-221-1/+1
| | | | Notes: svn path=/head/; revision=239586
* In order to maximize the re-usability of kernel code in user space thisKip Macy2011-09-161-4/+4
| | | | | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz) Notes: svn path=/head/; revision=225617
* Style fix.Attilio Rao2010-11-221-3/+2
| | | | | | | | | | | Sponsored by: Sandvine Incorporated Requested by: jhb Reviewed by: jhb MFC after: 1 week X-MFC: 215544 Notes: svn path=/head/; revision=215683
* Scan the list in reverse order for the shutdown handlers of loaded modules.Attilio Rao2010-11-191-2/+2
| | | | | | | | | | | | | | | This way, when there is a dependency between two modules, the handler of the latter probed runs first. This is a similar approach as the modules are unloaded in the same linkerfile. Sponsored by: Sandvine Incorporated Submitted by: Nima Misaghian <nmisaghian at sandvine dot com> MFC after: 1 week Notes: svn path=/head/; revision=215544
* Use ISO C99 integer types in sys/kern where possible.Ed Schouten2010-06-211-2/+2
| | | | | | | | | There are only about 100 occurences of the BSD-specific u_int*_t datatypes in sys/kern. The ISO C99 integer types are used here more often. Notes: svn path=/head/; revision=209390
* Provide groundwork for 32-bit binary compatibility on non-x86 platforms,Nathan Whitehorn2010-03-111-1/+1
| | | | | | | | | | | | for upcoming 64-bit PowerPC and MIPS support. This renames the COMPAT_IA32 option to COMPAT_FREEBSD32, removes some IA32-specific code from MI parts of the kernel and enhances the freebsd32 compatibility code to support big-endian platforms. Reviewed by: kib, jhb Notes: svn path=/head/; revision=205014
* When the SYSINIT() to load a module invokes the MOD_LOAD event successfully,John Baldwin2008-12-051-0/+15
| | | | | | | | | | | | | | | | move that module to the head of the associated linker file's list of modules. The end result is that once all the modules are loaded, they are sorted in the reverse of their load order. This causes the kernel linker to invoke the MOD_QUIESCE and MOD_UNLOAD events in the reverse of the order that MOD_LOAD was invoked. This means that the ordering of MOD_LOAD events that is set by the SI_* paramters to DECLARE_MODULE() are now honored in the same order they would be for SYSUNINIT() for the MOD_QUIESCE and MOD_UNLOAD events. MFC after: 1 month Notes: svn path=/head/; revision=185642
* - Invoke MOD_QUIESCE on all modules in a linker file (kld) beforeJohn Baldwin2008-12-051-5/+20
| | | | | | | | | | | | | | | | | unloading any modules. As a result, if any module veto's an unload request via MOD_QUIESCE, the entire set of modules for that linker file will remain loaded and active now rather than leaving the kld in a weird state where some modules are loaded and some are unloaded. - This also moves the logic for handling the "forced" unload flag out of kern_module.c and into kern_linker.c which is a bit cleaner. - Add a module_name() routine that returns the name of a module and use that instead of printing pointer values in debug messages when a module fails MOD_QUIESCE or MOD_UNLOAD. MFC after: 1 month Notes: svn path=/head/; revision=185635
* In keeping with style(9)'s recommendations on macros, use a ';'Robert Watson2008-03-161-1/+1
| | | | | | | | | | | | after each SYSINIT() macro invocation. This makes a number of lightweight C parsers much happier with the FreeBSD kernel source, including cflow's prcc and lxr. MFC after: 1 month Discussed with: imp, rink Notes: svn path=/head/; revision=177253
* Add an automatic kernel module version dependency to prevent loadingJohn Baldwin2008-02-131-0/+2
| | | | | | | | | | | | | | | | modules using invalid ABI versions (e.g. a 7.x module with an 8.x kernel) for a given kernel: - Add a 'kernel' module version whose value is __FreeBSD_version. - Add a version dependency on 'kernel' in every module that has an acceptable version range of __FreeBSD_version up to the end of the branch __FreeBSD_version is part of. E.g. a module compiled on 701000 would work on kernels with versions between 701000 and 799999 inclusive. Discussed on: arch@ MFC after: 1 week Notes: svn path=/head/; revision=176252
* Move several data structure definitions out of freebsd32_misc.c and intoJohn Baldwin2007-12-061-0/+1
| | | | | | | | | freebsd32.h instead. MFC after: 1 week Notes: svn path=/head/; revision=174377
* Remove 'MPSAFE' annotations from the comments above most system calls: allRobert Watson2007-03-041-15/+0
| | | | | | | | | | | system calls now enter without Giant held, and then in some cases, acquire Giant explicitly. Remove a number of other MPSAFE annotations in the credential code and tweak one or two other adjacent comments. Notes: svn path=/head/; revision=167211
* Address a problem I missed in removing Giant from the kernel linker. NotJohn Baldwin2006-06-261-3/+9
| | | | | | | | | | all of the module event handlers are MP safe yet, so always acquire Giant for now when invoking module event handlers. Eventually we can add an MPSAFE flag or some such and add appropriate locking to all module event handlers. Notes: svn path=/head/; revision=159957
* o Expand an exclusive lock scope to prevent a race between twoMaxim Konovalov2006-06-151-5/+5
| | | | | | | | | | | simultaneous module_register(). Original work done by: Alex Lyashkov Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=159634
* Add a new module_file() function that returns the linker_file_t associatedJohn Baldwin2006-04-171-0/+7
| | | | | | | | | | | | | with a given module_t. I use this in some the MOD_LOAD event handler for some test kernel modules to ask the kernel linker to look up the linker sets in my test modules. (I use linker sets to generate the list of possible events that I then signal to execute via a sysctl. On non-amd64, ld(8) would resolve the entire linker set, but on amd64 I have to ask the kernel linker to do it for me, and having the kernel linker do it works on all archs.) Notes: svn path=/head/; revision=157818
* Swap the arguments for CP so we copy the correct source andPaul Saab2005-02-181-4/+4
| | | | | | | destination. Notes: svn path=/head/; revision=142067
* Add a 32bit syscall wrapper for modstatPaul Saab2005-01-191-0/+81
| | | | | | | Obtained from: Yahoo! Notes: svn path=/head/; revision=140482
* Don't bother calling the module event handlers from module_shutdown()Don Lewis2004-08-201-0/+3
| | | | | | | | | | | | | | | | | in the shutdown_final state if the RB_NOSYNC flag is set. The specific motivation in this case is that a system panic in an interrupt context results in a call to module_shutdown(), which calls g_modevent(), which calls g_malloc(..., M_WAITOK), which results in a second panic. While g_modevent() could be fixed to not call malloc() for MOD_SHUTDOWN events (which it doesn't handle in any case), it is probably also a good idea to entirely skip the execution of the module shutdown handlers after a panic. This may be a MFC candidate for RELENG_5. Notes: svn path=/head/; revision=134092
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPPoul-Henning Kamp2004-07-151-1/+1
| | | | | | | | | | | for unknown events. A number of modules return EINVAL in this instance, and I have left those alone for now and instead taught MOD_QUIESCE to accept this as "didn't do anything". Notes: svn path=/head/; revision=132199
* A module with no modevent function gets modevent_nop() as default.Poul-Henning Kamp2004-07-141-1/+9
| | | | | | | | | | | | | | | | Until now the function has just returned zero for any event, but that is downright wrong for MOD_UNLOAD and not very useful for any future events we add where it may be crucial to be able to tell if the event was unhandled or successful. Change the function to return as follows: MOD_LOAD -> 0 MOD_UNLOAD -> EBUSY anything else -> EOPNOTSUPP Notes: svn path=/head/; revision=132167
* Give kldunload a -f(orce) argument.Poul-Henning Kamp2004-07-131-1/+7
| | | | | | | | | | | | | | | | | | | | Add a MOD_QUIESCE event for modules. This should return error (EBUSY) of the module is in use. MOD_UNLOAD should now only fail if it is impossible (as opposed to inconvenient) to unload the module. Valid reasons are memory references into the module which cannot be tracked down and eliminated. When kldunloading, we abandon if MOD_UNLOAD fails, and if -force is not given, MOD_QUIESCE failing will also prevent the unload. For backwards compatibility, we treat EOPNOTSUPP from MOD_QUIESCE as success. Document that modules should return EOPNOTSUPP for unknown events. Notes: svn path=/head/; revision=132117
* Use __FBSDID().David E. O'Brien2003-06-111-2/+3
| | | | Notes: svn path=/head/; revision=116182
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-1/+1
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-1/+1
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Move the MOD_SHUTDOWN event from shutdown_post_sync to shutdown_final,Peter Wemm2003-01-071-1/+1
| | | | | | | | | | | | | so that entities that want to use the post_sync hook to write stuff to devices and other tidy-up can do so before the device tree is shot down. eg: da doing a SYNC_CACHE etc. This should get crashdumps working on mpt devices again, and stops the ia64 boxes locking up on regular shutdown when da tries to issue the scsi commands to mpt. Obtained from: njl, gibbs Notes: svn path=/head/; revision=108905
* SCARGS removal take II.Alfred Perlstein2002-12-141-6/+6
| | | | Notes: svn path=/head/; revision=107849
* Backout removal SCARGS, the code freeze is only "selectively" over.Alfred Perlstein2002-12-131-6/+6
| | | | Notes: svn path=/head/; revision=107839
* Remove SCARGS.Alfred Perlstein2002-12-131-6/+6
| | | | | | | Reviewed by: md5 Notes: svn path=/head/; revision=107838
* - Remove Giant acquisition from modevent(), modfnext(), modstat() andAndrew R. Reiter2002-06-261-27/+11
| | | | | | | | | | modfind(). Giant is no longer needed by these functions for safe execution. Reviewed by: jhb Notes: svn path=/head/; revision=98835
* - Lock down the ``module'' structure by adding an SX lock that is used byAndrew R. Reiter2002-03-181-19/+58
| | | | | | | | | | | | all the global bits of ``module'' data. This commit adds a few generic macros, MOD_SLOCK, MOD_XLOCK, etc., that are meant to be used as ways of accessing the SX lock. It is also the first step in helping to lock down the kernel linker and module systems. Reviewed by: jhb, jake, smp@ Notes: svn path=/head/; revision=92547
* Fix a warning. Do not assume pointer == long.Peter Wemm2002-02-261-2/+2
| | | | Notes: svn path=/head/; revision=91261
* - Whitespace fixup left over from previous commit.Andrew R. Reiter2002-02-221-10/+9
| | | | | | | | | - Remove bogus cast. Submitted by: bde Notes: svn path=/head/; revision=91067
* - Fix style further by adding parentheses around return values so thatAndrew R. Reiter2002-02-201-14/+14
| | | | | | | | they look like: return (val); instead of: return val; Notes: svn path=/head/; revision=90980
* - Style.9 formatting fix; this commit is mostly white space related withAndrew R. Reiter2002-02-201-209/+209
| | | | | | | | | | | | | the next commit actually doing the: return val; -> return (val); changes. This commit was done in preparation for getting ``struct modules'' locked down. Reviewed by: bde Approved by: dfr Notes: svn path=/head/; revision=90963
* KSE Milestone 2Julian Elischer2001-09-121-13/+13
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Giant Pushdown. Saved the worst P4 tree breakage for last.Matthew Dillon2001-09-011-19/+52
| | | | | | | | | | | | | | | reboot() getpriority() setpriority() rtprio() osetrlimit() ogetrlimit() setrlimit() getrlimit() getrusage() getpid() getppid() getpgrp() getpgid() getsid() getgid() getegid() getgroups() setsid() setpgid() setuid() seteuid() setgid() setegid() setgroups() setreuid() setregid() setresuid() setresgid() getresuid() getresgid () __setugid() getlogin() setlogin() modnext() modfnext() modstat() modfind() kldload() kldunload() kldfind() kldnext() kldstat() kldfirstmod() kldsym() getdtablesize() dup2() dup() fcntl() close() ofstat() fstat() nfsstat() fpathconf() flock() Notes: svn path=/head/; revision=82749
* Mechanical change to use <sys/queue.h> macro API instead ofPoul-Henning Kamp2001-02-041-3/+3
| | | | | | | | | | fondling implementation details. Created with: sed(1) Reviewed by: md5(1) Notes: svn path=/head/; revision=71999
* Staticize some malloc M_ instances.Poul-Henning Kamp2000-12-081-1/+1
| | | | Notes: svn path=/head/; revision=69774
* Back out the previous change to the queue(3) interface.Jake Burkholder2000-05-261-3/+3
| | | | | | | | | It was not discussed and should probably not happen. Requested by: msmith and others Notes: svn path=/head/; revision=60938
* Change the way that the queue(3) structures are declared; don't assume thatJake Burkholder2000-05-231-3/+3
| | | | | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd Notes: svn path=/head/; revision=60833
* First round implementation of a fine grain enhanced module to modulePeter Wemm2000-04-291-15/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | version dependency system. This isn't quite finished, but it is at a useful stage to do a functional checkpoint. Highlights: - version and dependency metadata is gathered via linker sets, so things are handled the same for static kernels and code built to live in a kld. - The dependencies are at module level (versus at file level). - Dependencies determine kld symbol search order - this means that you cannot link against symbols in another file unless you depend on it. This is so that you cannot accidently unload the target out from underneath the ones referencing it. - It is flexible enough that we can put tags in #include files and macros so that we can get decent hooks for enforcing recompiles on incompatable ABI changes. eg: if we change struct proc, we could force a recompile for all kld's that reference the proc struct. - Tangled dependency references at boot time are sorted. Files are relocated once all their dependencies are already relocated. Caveats: - Loader support is incomplete, but has been worked on seperately. - Actual enforcement of the version number tags is not active yet - just the module dependencies are live. The actual structure of versioning hasn't been agreed on yet. (eg: major.minor, or whatever) - There is some backwards compatability for old modules without metadata but I'm not sure how good it is. This is based on work originally done by Boris Popov (bp@freebsd.org), but I'm not sure he'd recognize much of it now. Don't blame him. :-) Also, ideas have been borrowed from Mike Smith. Notes: svn path=/head/; revision=59751
* A hack basically.. We have a bunch of code that used to callPeter Wemm1999-11-081-1/+8
| | | | | | | | | | | | | | devsw_module_handler() indirectly and not use the chain arguments. To eliminate this indirection via that function (which does nothing now) without duplicating a modevent handler into all the routines that don't presently have one, supply a NOP (do nothing, return OK) routine which is functionally equivalent to what's there now. This is a hack and is still wrong, because there doesn't appear to be anything to reclaim resources on an unload of a module with one of these in it. I'm not sure whether to make the NOP handler refuse a MOD_UNLOAD event or what. Notes: svn path=/head/; revision=52991
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Implement a new generic mechanism for attaching handler functions toMike Smith1999-08-211-4/+6
| | | | | | | | | | | | | | | | events, in order to pave the way for removing a number of the ad-hoc implementations currently in use. Retire the at_shutdown family of functions and replace them with new event handler lists. Rework kern_shutdown.c to take greater advantage of the use of event handlers. Reviewed by: green Notes: svn path=/head/; revision=50107
* Oops, set module->file..Peter Wemm1999-05-201-1/+2
| | | | | | | | PR: 1179 Submitted-by: lha@stacken.kth.se Notes: svn path=/head/; revision=47330