summaryrefslogtreecommitdiffstats
path: root/sys/boot/common/module.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r316754: loader/multiboot: fix multiboot loadingroyger2017-05-091-0/+16
| | | | Sponsored by: Citrix Systems R&D
* Fix several instances where the boot loader ignored pager_outputimp2016-05-181-4/+7
| | | | | | | return value when it could return 1 (indicating we should stop). Fix a few instances of pager_open() / pager_close() not being called. Actually use these routines for the environment variable printing code I just committed.
* sys/boot/common: use of spaces vs. TAB.pfg2016-05-121-8/+8
| | | | No functional change.
* sys: use our roundup2/rounddown2() macros when param.h is available.pfg2016-04-211-1/+1
| | | | | | | | | | rounddown2 tends to produce longer lines than the original code and when the code has a high indentation level it was not really advantageous to do the replacement. This tries to strike a balance between readability using the macros and flexibility of having the expressions, so not everything is converted.
* A new implementation of the loader block cacheallanjude2016-04-181-3/+3
| | | | | | | | | | | | | | | | | The block cache implementation in loader has proven to be almost useless, and in worst case even slowing down the disk reads due to insufficient cache size and extra memory copy. Also the current cache implementation does not cache reads from CDs, or work with zfs built on top of multiple disks. Instead of an LRU, this code uses a simple hash (O(1) read from cache), and instead of a single global cache, a separate cache per block device. The cache also implements limited read-ahead to increase performance. To simplify read ahead management, the read ahead will not wrap over bcache end, so in worst case, single block physical read will be performed to fill the last block in bcache. Booting from a virtual CD over IPMI: 0ms latency, before: 27 second, after: 7 seconds 60ms latency, before: over 12 minutes, after: under 5 minutes. Submitted by: Toomas Soome <tsoome@me.com> Reviewed by: delphij (previous version), emaste (previous version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D4713
* Make common boot file_loadraw name parameter constsmh2016-01-151-7/+6
| | | | | | | | | | Fix compiler warnings about dropping const qualifier by changing file_loadraw name param to const, and updating method to make that the case (it was abusing the variable). MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay
* Improve non-interactive forth cmd error reportingsmh2016-01-131-9/+22
| | | | | | | | | | | | | | | | | | | Non-interactive forth command errors where silent even for critical issues e.g. failing to load a required kernel module or mfs_root. This resulted in later unexplained and hard to trace errors such as mount root failures. This introduces additional command return codes that are treated appropriately by the non-interactive command processor (bf_command). * CMD_CRIT = print error * CMD_FATAL = panic Also fix minor style(9) issues with command_load return codes. MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay
* Enable warnings in EFI boot codesmh2016-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Set WARNS if not set for EFI boot code and fix the issues highlighted by setting it. Most components are set to WARNS level 6 with few being left at lower levels due to the amount of changes needed to fix at higher levels. Error types fixed: * Missing / invalid casts * Missing inner structs * Unused vars * Missing static for internal only funcs * Missing prototypes * Alignment changes * Use of uninitialised vars * Unknown pragma (intrinsic) * Missing types etc due to missing includes * printf formatting types Reviewed by: emaste (in part) MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay Differential Revision: https://reviews.freebsd.org/D4839
* Fix a problem which made loader(8) load non-kld files twice.trasz2015-08-031-0/+8
| | | | | | | | | | | | | | | For example, without this patch, the following three lines in /boot/loader.conf would result in /boot/root.img being preloaded twice, and two md(4) devices - md0 and md1 - being created. initmd_load="YES" initmd_type="md_image" initmd_name="/boot/root.img" Reviewed by: marcel@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3204
* loader: implement multiboot support for Xen Dom0royger2015-01-151-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement a subset of the multiboot specification in order to boot Xen and a FreeBSD Dom0 from the FreeBSD bootloader. This multiboot implementation is tailored to boot Xen and FreeBSD Dom0, and it will most surely fail to boot any other multiboot compilant kernel. In order to detect and boot the Xen microkernel, two new file formats are added to the bootloader, multiboot and multiboot_obj. Multiboot support must be tested before regular ELF support, since Xen is a multiboot kernel that also uses ELF. After a multiboot kernel is detected, all the other loaded kernels/modules are parsed by the multiboot_obj format. The layout of the loaded objects in memory is the following; first the Xen kernel is loaded as a 32bit ELF into memory (Xen will switch to long mode by itself), after that the FreeBSD kernel is loaded as a RAW file (Xen will parse and load it using it's internal ELF loader), and finally the metadata and the modules are loaded using the native FreeBSD way. After everything is loaded we jump into Xen's entry point using a small trampoline. The order of the multiboot modules passed to Xen is the following, the first module is the RAW FreeBSD kernel, and the second module is the metadata and the FreeBSD modules. Since Xen will relocate the memory position of the second multiboot module (the one that contains the metadata and native FreeBSD modules), we need to stash the original modulep address inside of the metadata itself in order to recalculate its position once booted. This also means the metadata must come before the loaded modules, so after loading the FreeBSD kernel a portion of memory is reserved in order to place the metadata before booting. In order to tell the loader to boot Xen and then the FreeBSD kernel the following has to be added to the /boot/loader.conf file: xen_cmdline="dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga" xen_kernel="/boot/xen" The first argument contains the command line that will be passed to the Xen kernel, while the second argument is the path to the Xen kernel itself. This can also be done manually from the loader command line, by for example typing the following set of commands: OK unload OK load /boot/xen dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga OK load kernel OK load zfs OK load if_tap OK load ... OK boot Sponsored by: Citrix Systems R&D Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D517 For the Forth bits: Submitted by: Julien Grall <julien.grall AT citrix.com>
* The current limit of 100k for the linker hints file is getting a bitimp2014-11-291-1/+1
| | | | | | | | crowded as we now are at about 70k. Bump the limit to 1MB instead which is still quite a reasonable limit and allows for future growth of this file and possible future expansion to additional data. MFC After: 2 weeks
* When built with FDT support, add /boot/dtb to the list of search directories.ian2014-09-031-0/+5
|
* Rename command_unload() to unload() and re-implement command_unload()marcel2014-08-061-6/+12
| | | | | | | in terms of unload() This allows unloading all files by the loader itself. Obtained from: Juniper Networks, Inc.
* In command_lsmod() prevent overrunning lbuf due to long pathmarcel2014-08-051-2/+4
| | | | | | names. Call pager_output() separately for the module name. Obtained from: Juniper Networks, Inc.
* In file_loadraw() print the name of the file as well as its sizemarcel2014-08-051-1/+6
| | | | | | so that we know what file is being loaded and how big the file is once complete. This has ELF modules and disk images emit the same output.
* Change file_loadraw() from static to public. Change the order of itsian2014-02-221-10/+9
| | | | | | arguments from type,filename to filename,type to be consistant with other public file_whatever() functions, and change it to return a pointer to the preloaded_file struct describing the file. Adjust existing callers.
* Since we didn't break the loop, we should set i to -1 to start from theae2013-04-211-1/+2
| | | | | | | beginning. Submitted by: Steven Hartland MFC after: 1 week
* Fix the bug I introduced in r247045.kientzle2013-02-251-36/+0
| | | | | | | | | | | | | | | | After digging through more carefully, it looks like there's no real need to have the DTB in the module directory. So we can simplify a lot: Just copy DTB into local heap for "fdt addr" and U-Boot integration, drop all the extra COPYIN() calls. I've left one final COPYIN() to update the in-kernel DTB for consistency with how this code used to work, but I'm no longer convinced it's appropriate here. I've also remove the mem_load_raw() utility that I added to boot/common/module.c with r247045 since it's no longer necessary.
* Add mem_load_raw() for loading data from another location in memory.kientzle2013-02-181-0/+37
| | | | | | This will be used by some upcoming changes to loader(8) FDT handling to allow it to use an FDT provided by an earlier boot stage the same as an FDT loaded from disk.
* Fix the style.ae2012-09-301-4/+4
|
* Remember the file format of the last loaded module and try to use it forae2012-09-301-2/+9
| | | | next files.
* boot: file_loadraw should strdup name argumentavg2012-09-111-1/+1
| | | | | | ... the same way it's done for type argument. MFC after: 2 weeks
* Fix a long standing bug where file_load() passes down the global loadaddrmarcel2011-04-041-1/+1
| | | | | | | | to the l_load() method in the file_formats structure, while being passed an address as an argument (dest). With file_load() calling arch_loadaddr() now, this bug is a little bit more significant. Spotted by: nyan@ (nice catch!)
* Add 2 new archsw interfaces:marcel2011-04-031-19/+6
| | | | | | | | | | | | | | 1. arch_loadaddr - used by platform code to adjust the address at which the object gets loaded. Implement PC98 using this new interface instead of using conditional compilation. For ELF objects the ELF header is passed as the data pointer. For raw files it's the filename. Note that ELF objects are first considered as raw files. 2. arch_loadseg - used by platform code to keep track of actual segments, so that (instruction) caches can be flushed or translations can be created. Both the ELF header as well as the program header are passed to allow platform code to treat the kernel proper differently from any additional modules and to have all the relevant details of the loaded segment (e.g. protection).
* Formatting nitimp2010-05-101-1/+2
|
* Don't use 15M-16M area on pc98. It's reserved for some devices.nyan2009-12-311-0/+19
| | | | MFC after: 2 week
* Add a helper function for loading geli keys from the loader.thompsa2009-02-161-0/+38
|
* Also boot *.debug if everything else fails.obrien2007-10-041-0/+1
| | | | Approved by: re(gnn)
* In moduledir_readhints() cast the value returned by sizeof() to ssize_tmarius2006-01-121-1/+2
| | | | | | | | | | | when checking whether it's greater than a struct stat st_size in order to also catch the case when st_size is -1. Previously this check didn't trigger on sparc64 when st_size is -1 (as it's the case for a file on a bzipfs, TFTP server etc.), causing the content of the linker hints file to be copied to memory referenced by a null-pointer. PR: 91231 MFC after: 1 week
* Use __FBSDID().obrien2003-08-251-2/+3
| | | | Also some minor style cleanups.
* FreeBSD 5.0 has stopped shipping /modules 2.5 years ago. Catchru2003-03-031-1/+1
| | | | | up with this further by excluding /modules from the (default) kern.module_path.
* Bandaid for a buffer overrun in the module searching code. When breakingpeter2002-04-111-0/+2
| | | | | | | | up the module_path string, we would walk one past the end of the buffer. This hurting ia64 originally, but it was probably also happening on i386 occasionally as well. The effects were usually harmless, it would add bogus "binary" search directories to the places it actually looked for files.
* Fix a number of misspellings of "dependency" and "dependencies" iniedowse2001-11-161-3/+3
| | | | | | | comments and function names. PR: kern/8589 Submitted by: Rajesh Vaidheeswarran <rv@fore.com>
* Implement the long-awaited module->file cache database. A userlandpeter2001-09-111-84/+399
| | | | | | | tool (kldxref(8)) keeps a cache of what modules and versions are inside what .ko files. I have tested this on both Alpha and i386. Submitted by: bp
* Fix a minor style bug in the last commit.jesper2001-06-101-1/+1
| | | | | Submitted by: Adrian Steinmann <ast@marabu.ch> MFC after: 2 days
* In sys/boot/common/module.c, near line 105 a request for a rawjesper2001-05-271-1/+1
| | | | | | | | | | | | | | | | | file is processed by passing its name in argv[1]: return(mod_loadobj(typestr, argv[1])); however, it is not tested to see if argv[1] actually is defined. At best, mod_loadobj() near line 244 returns an error like "can't find 'garbage'" but if the "filename" entered is sufficiently long, some buffer gets overrun. Of course, "load -t filename" is actually a typo because we meant to type "load -t mfs_root filename"; nevertheless, a hung machine seems like too harsh a punishment for such a small typo... PR: i386/27693 Submitted by: Adrian Steinmann <ast@marabu.ch> MFC after: 1 week
* The default search path for kernel and modules was bogus. It makes nodcs2000-09-161-1/+1
| | | | sense for /boot/kernel to come last.
* Fix autoboot. Now autoboot *always* show the correct kernel name. Itdcs2000-09-081-0/+1
| | | | | | | | | | | | | | | | | | gets the name from the environment variable kernelname, which is set when a kernel is loaded. For this reason, autoboot will _first_ try to load a kernel, and only proceed with the wait prompt after that succeeds. If it fails, it will abort immediately. While I understand some may think this behavior undesirable, I think it is, overall, the best thing to do, even if we do not consider the aesthetic issue. Notice that anyone using the default loader.rc already has the kernel loaded before autoboot. On unload, unset kernelname. Separate the code that tries to load a kernel from the list of options to the function loadakernel(). It is used by both boot() and autoboot().
* The kernel is now known as `kernel.ko' and it and its matching modulesobrien2000-09-051-1/+1
| | | | live in ``/boot/kernel/''.
* Cleanup warnings. Most of these are signed/unsigned warnings, as well asjhb2000-08-031-2/+2
| | | | some added const's.
* Update loader logic to distinguish modules vs. files.bp2000-05-011-202/+261
| | | | | | | Add support for module metadata. The old way of dependancy handling will be supported for a while. Reviewed by: peter
* Fix the loader to handle module dependencies properly. More fixesbp2000-02-251-70/+74
| | | | | | | will be provided after modmetadata appears in the kernel. Reviewed by: msmith Approved by: jkh
* Close a file descriptor leak in the code which loads file objects.msmith2000-02-171-0/+2
| | | | | Submitted by: Paul Saab <paul@mu.org> Approved by: jkh
* Add fairings. Do not depend on user actually supplying the argumentsdcs1999-12-011-0/+4
| | | | he is supposed to supply.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Fix a number of memory leaks and other memory-related disorders.dcs1999-03-081-4/+6
| | | | | | | | | | | | | | | Also, unbreak the breakage introduced at the last revision of module.c. This changes the semantics of mod_searchfile() (and mod_searchmodule()) to make the caller's responsibility freeing the buffer returned. This is different from other functions in loader's code, and was done as a fix for kern/9631. If someone wants to revert this to the original behavior, don't forget to fix kern/9631 in another way. This should also fix bin/10462, which was introduced as a result of the first try at kern/9631 (module.c last revision). PR: bin/10462 Submitted by: Takanori Saneto <sanewo@ba2.so-net.ne.jp>
* Fix assorted memory leak/buffer reuse problems.dcs1999-02-221-4/+8
| | | | | | | Not restricted to, but including: PR: kern/9631 Submitted by: Bill Fenner <fenner@parc.xerox.com>
* No builtin command resets getopt before using it, causingmsmith1999-01-111-1/+3
| | | | | | | | problems in case a wrong option was given previously, and no option is given to the next command. PR: kern/9371 Submitted by: "Daniel C. Sobral" <dcs@newsguy.com>
* Use a consistant module search path (same as kernel will be).peter1998-10-091-26/+17
| | | | Use new dependency mechanism.
* * Add old UFS compatibility code to alpha/boot1.dfr1998-09-261-7/+7
| | | | | | * Fix a raft of warnings, printf and otherwise. * Allocate the correct amount in mod_searchmodule to prevent an overflow. * Fix the makefiles so they work outside my home directory (oops).
OpenPOWER on IntegriCloud