aboutsummaryrefslogtreecommitdiff
path: root/stand/i386/loader
Commit message (Collapse)AuthorAgeFilesLines
* Pass severity to vectx_open() rather than vectx_close()Simon J. Gerraty2026-04-101-2/+2
| | | | | | | | | | | | | | | | file_loadraw() can have a need to load unverified files like "dtrace_dof". Allow severity_guess() to look at the filename but if it returns less than VE_MUST check that the type is not one we insist on verifying. In vectx_open if severity < VE_MUST we can allow it to be unverified. If passed VE_GUESS we call severity_guess(). Regardless, we record severity in ctx so it is available to vectx_close(). Sponsored by: Hewlett Packard Enterprise Development LP Reviewed by: khng Differential Revision: https://reviews.freebsd.org/D56297
* loader: Prefer comma-separated list of values for "console"Michael Osipov2026-01-291-2/+2
| | | | | | | PR: 292595 Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54923
* zfsboot: Remove zfsboot(8) program used to boot ZFS from MBR + BIOSJohn Baldwin2025-07-281-1/+1
| | | | | | | | | | | | | This has not worked since the import of OpenZFS in FreeBSD 13.0. Trying to fix it at this point would probably entail rearchitecting how it works (e.g. using a dedicated freebsd-boot slice to hold zfsboot). However, it's not really worth doing that at this point. PR: 271262 Reported by: Henryk Paluch <hpaluch@seznam.cz> Reviewed by: imp, emaste Relnotes: yes Differential Revision: https://reviews.freebsd.org/D51545
* biosboot: Detect memory disks from PXERichard Russo2025-07-231-0/+3
| | | | | | | | | | | | | | | | | | | Walk through the disk driver entries chained off of INT13. MEMDISK is part of the Syslinux project; it loads disk images into memory, sets an int 13h hook and then does a BIOS boot from the image; this can be used as part of a PXE boot environment to load installer disks, however the disks are not accessible from inside the FreeBSD kernel because it doesn't access disks through BIOS APIs. This patch detects the disk images in the loader, and passes their address and length as a driver hint. When the md driver sees the hint, it maps the image, and presents it to the system. (rebased and reworked from https://reviews.freebsd.org/D27349) Feedback from: kib, bapt, olce Differential Revision: https://reviews.freebsd.org/D45404
* stand/i386: Initialize archsw at compile timeWarner Losh2025-05-261-17/+21
| | | | | | | No need to initialize this at runtime. This trades .bss space + code in .text for just .data and is net smaller by 4 bytes. Sponsored by: Netflix
* stand allow for local.defs.mkSimon J. Gerraty2025-05-221-1/+1
| | | | | | | | | | | This allows us to change the VERSION_FILE used for loaders as well as set NEWVERS_DATE and BUILD_UTC to reflect the publish date of loaders for secure-boot. Sponsored by: Juniper Networks, Inc. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D50478
* loader: i386: use -z nostart-stop-gc for bfd as wellKyle Evans2025-05-081-1/+2
| | | | | | | | | | | | binutils 2.37 seems to have added the knob, so let's just use that version here (it's not clear if GC'ing start/stop symbols was actually made the default at the time, and it didn't seem worth it to dig much further). This fixes misbehavior when built with more recent binutils, as we do rely on linker sets for loader commands that we use. Reported by: sjg Reviewed by: dim, sjg Differential Revision: https://reviews.freebsd.org/D50252
* i386/loader: force 4k linker max page sizeChuck Silvers2025-03-191-0/+4
| | | | | | | | | Force the BIOS loaders to use the standard 4k linker max page size so that they fit in the limited space even if someone has set a larger default linker max page size via /etc/src.conf. Reviewed by: imp Sponsored by: Netflix
* stand: Ugly hack due to default changeWarner Losh2024-10-282-2/+2
| | | | | | | | | | | So this is a gross hack to fix the 'noclean' build since we changed to text-only loader. We have to fix it in a better way, but for the moment, this will fix non-meta no-clean builds. A better hack is to fix this so we build either vidconsole.c or textvidc.c, but some minor refactoring and variable renaming is needed. Fixes: 23dee252daf2 Sponsored by: Netflix
* loader: Change this BIOS tradeoff: Add back zip and use text onlyWarner Losh2024-10-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | After talking with a number of people about the removal of some things to make the loader fit, readjust things a little. Add back GZIP and BZIP2 compression support. Many of the downstream MFC packaging systems depend on this. This adds back 20k to the size of the loader. Make the boot loader text-only by default. This saves 40k in size. Net, we're 20k smaller. The graphics loader for BIOS is less useful than the zip functionality: You can still boot w/a text only one it and you can build a custom one if you really want it. It's also the default we use for dual console. This should be merged back into stable/14 and stable/13 so it's in the next release for each of these. That way we have only one release (13.4) with the other defaults. MFC After: 3 days Sponsored by: Netflix Reviewed by: olce, rgrimes, emaste Differential Revision: https://reviews.freebsd.org/D47203
* loader: Minor comentary tweakWarner Losh2024-08-021-2/+2
| | | | | | Reword slightly to cleanup awkward constructs. Sponsored by: Netflix
* stand: Reduce limit to 500k for x86 loaderWarner Losh2024-08-011-1/+6
| | | | | | | | | | | | | | | | | The largest loader that works for PXE boot is about 500k. PXE needs low memory for packets and other driver state, so the largest safe size for the loader is about 500k. Reduce the size from 560k to 500k so we don't accidentally break PXE in the future. Add a comment for people with special needs. If you control the hardware, it can be safe to have boot loaders as large as 580k or 600k in some cases. Since the BIOS loader is becoming more and more of a legacy item, the build variable LOADERSIZE isn't documented. This change doesn't change that: there's been little demand for this documentation and in general, users shouldn't change it lightly. PR: 257018 Sponsored by: Netflix
* loader: Bump all versions to 3.0Warner Losh2024-07-291-0/+1
| | | | | | | | | | | | | Each incompatible change we make, we bump the major version. We've not done the bump in a while, so sync everybody to 3.0. Anything older than 3.0 will be given a warning that their boot loader is too old. We check only the major version, though, so minor versions can still be bumped for individual loaders (though I honestly doubt we'll ever need to do that again). Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D45888
* stand: Remove obsolete junkWarner Losh2024-07-291-4/+0
| | | | | | | | | | We long ago changed newvers.sh to make these comments bogus. Remove them since every single one of them is broken after the $FreeBSD$ removal. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D45879
* stand: Stop building in fat, ext2fs, gzip and bzip to BIOS /boot/loaderWarner Losh2024-07-251-4/+4
| | | | | | | | | | | | | | | | | This saves space to allow pxeboot to work again. Users desiring these features can turn them on for their custom build. While these are useful for some specialized applications, they aren't needed to boot the typical system, and we're low on space. text data bss dec hex filename Before: 465866 20740 31612 518218 0x7e84a loader_lua.bin After: 441535 17484 31092 490111 0x77a7f loader_lua.bin Savings: 28,107 bytes Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D42416
* libsa: Remove redundant sys/cdefs.hWarner Losh2024-02-223-3/+0
| | | | Sponsored by: Netflix
* loader: Retire CTASSERTWarner Losh2024-02-211-5/+4
| | | | | | | | | The project is moving away from CTASSERT in favor of _Static_assert. Cleanup the few instances in the loader proactively. Sponsored by: Netflix Reviewed by: manu, tsoome Differential Revision: https://reviews.freebsd.org/D44006
* loader: Make MK_LOADER_BIOS_TEXTONLY workWarner Losh2024-02-183-1/+88
| | | | | | | | | | | | | | | | | | | Select between text-only and graphical frame buffer consoles for the BIOS boot loader. Pull one or the other in with #ifdef in conf.c. Add gfx_bios.c for the few routines that are needed for the BIOS support of gfx. These are stubbed out for text-only mode. Move bi_load_vbe_data here since it's only used for the graphical frame buffer. Note: This setup also allows us to build multiple BIOS loaders if we have to, some with text-only and some graphical. We don't do this today. We may be forced to turn this on in the future if ZFS keeps growing. The size savings is 41k, which helps a lot with some of our users that want to enable more options in the BIOS boot loader than are normally safe to do, and they don't need graphics. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43917
* loader: Bump the limit to 560,000 bytes for BIOS loaderWarner Losh2024-02-161-3/+2
| | | | | | | Further experience suggests we do not need as much margin. This was mistakenly bumped to 570,000 in a prior commit, so this undoes that. Sponsored by: Netflix
* kboot: Add our own lua bindingsWarner Losh2024-02-161-1/+1
| | | | | | | | Create a small wrapper around the new flua hash module so we can use it here too. There's no 4th bindings, nor will they be created. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43874
* loader: add target for dirdeps buildStephen J. Kiernan2023-11-022-1/+10
| | | | | | | | Update dependencies for the loader variations used for each architecture. Reviewed by: sjg Differential Revision: https://reviews.freebsd.org/D39741
* Remove $FreeBSD$: one-line forth tagWarner Losh2023-08-161-1/+0
| | | | Remove /^\\[\s*]*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line bare tagWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-163-6/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-4/+4
|
* loader: always install help filesMitchell Horne2023-02-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address two issues with current help file logic: The existing condition prevents the common help file from being installed when there are no additional help files defined. This results in no loader.help on EFI platforms, for example. Second, due to the fact that we build and install multiple loader types, each successive install will clobber the previous loader.help. The result is that we could lose type-specific commands, or possibly list them in loaders that do not have such commands. Instead, give each loader type a uniquely named help file. The EFI loader will look for /boot/loader.help.efi, userboot will look for /boot/loader.help.userboot, etc. The interpreter variant has no effect on which help file is loaded. This leaves the old /boot/loader.help unused. Some credit for the final approach goes to Mathieu <sigsys@gmail.com> for their version of the fix in https://reviews.freebsd.org/D22951. PR: 267134 Reported by: Daniel O'Connor <darius@dons.net.au> Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28591
* stand: create common set_currdevWarner Losh2023-01-111-4/+1
| | | | | | | | | | | | Pull together the nearly identical copies of set_currdev in i386, userboot and efi. Other boot loaders have variances that might be fine to use the common routine, or not. Since they are harder to test for me, and ofw and uboot do handle these setting differently, leave them be for now. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D38005
* stand: Create common gen_setcurrdev and replace codeWarner Losh2023-01-111-2/+2
| | | | | | | | | | Replace 4 identical copies of *_setcurrdev with gen_setcurrdev to avoid having to create a 5th copy. uboot_setcurrdev is actually different and needs to remain separate (even though it's quite similar). Sponsored by: Netflix Reviewed by: fuz@fuz.su, kevans Differential Revision: https://reviews.freebsd.org/D38003
* stand/zfs: Add a third argument to zfs_probe_dev: part_tooWarner Losh2023-01-081-1/+1
| | | | | | | | | Pass in 'true' if you'd like to search this device's partitions or 'false' if you should just search the device. EFI and (in the future) kboot have discrete partitions that aren't accessed via the full disk device. Weird things happen if you try to search in these cases. Sponsored by: Netflix
* stand: create devinitWarner Losh2022-11-301-8/+1
| | | | | | | | devinit() marches through all the devices, calling the inint routines if any exist. Replace all the identical copies of this code. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37349
* stand: Remove i386-only support fire firewireWarner Losh2022-11-183-20/+3
| | | | | | | | | | | | Remove support for booting off of firewire, and for having dcons via firewire in the loader. Kernel support for these things is unchanged. Discussed on arch@ and the current state is not working (and the build was wrong to boot). Sponsored by: Netflix Discussed: https://lists.freebsd.org/archives/freebsd-arch/2022-November/000267.html Reviewed by: kevans, melifaro, emaste Differential Revision: https://reviews.freebsd.org/D37334
* stand: Fix a couple of comment typos in f8a199f28f9dJessica Clarke2022-08-131-2/+2
| | | | | | | The commit message documented it as /etc/src.conf but the comment in the source mentioned the non-existent /etc/loader.conf. Fixes: f8a199f28f9d ("stand: Raise limit to 550,000 bytes for loader")
* stand: Raise limit to 550,000 bytes for loaderWarner Losh2022-08-131-2/+16
| | | | | | | | | | | | | | | | | | | | | | Raise the limit for /boot/loader to be 550k. The IBM PC imposes a limit of 640k of RAM below 1MB, which is needed for real mode calls. BTX takes 40k of that. The BIOS takes some amount (25k seems a good "99% take less than or equal to this" estimate for that, though some systems consume more). Most typical setups need 25k of stack. This leaves 550k for code. We set the limit to 550,000 which gives about an extra 13,000 bytes of buffer for machines that whose setups use a little more stack or whose BIOS reserves a bit more... Add this derivation in the Makefile. Also recommend setting LOADERSIZE lower in /etc/src.conf when the loader has to run on a system whose BIOS takes up more space, or for a complex setup. Add a recipe for how to find how much RAM your BIOS uses as well (thanks to jhb@ for the trick). Network cards that boot via PXE and HBAs with their BIOS enabled are known to be large consumers of lomem space. Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D36152
* stand: Go back to a.out format for /boot/loaderWarner Losh2022-08-111-6/+6
| | | | | | | | | | | | | | | | | | | Turns out there's two hidden a.out dependencies. pxeldr.S assumes it has access to the a.out header from /boot/loader and cdboot.S assumes that /boot/loader is also a.out and doesn't use boot2. So, go back to making a.out files for these and adjust the size checks to use ls, but we only need to check loader.bin. Trim the size we check against by 2,000. The difference in size between loader and loader.bin is about 3000 bytes, but clang15 produces binaries that are a smidge bigger so we need to relax the check just a little and accept some additional risk for the moment. Add some comments to loader's Makefile about this. Sponsored by: Netflix Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D36142
* stand: Make BIOS loader size limits settableWarner Losh2022-08-111-1/+1
| | | | | | | | | It's sometimes desirable to override the size limit: It's a soft limit and there are times we exceed the limit by just a little bit and don't want the build to fail (or we are hitting runtime failures below the 510,000 byte limit). Sponsored by: Netflix
* stand: i386_fmtdev can be reduced to devformatWarner Losh2022-08-111-2/+2
| | | | | | | | | devformat produces the same output as i386_fmtdev, so just use it to reduce on the dependencies. Sponsored by: Netflix Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D35927
* stand: Replace zfs_fmtdev with generic devformat()Warner Losh2022-08-111-1/+1
| | | | | Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D35973
* stand: Change zfs_fmtdev to take a struct devdesc *Warner Losh2022-08-111-1/+1
| | | | | Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D35974
* stand: Move i386_devdesc to a unionWarner Losh2022-08-111-12/+10
| | | | | | | | | | | Rather than have the magic, hand-crafted fields that have to align with fields in other structures at the end of i386_devdesc, make it into anonymous union and adjust the code accordingly. This is safer and similar to what CAM does. Sponsored by: Netflix Reviewed by: kevans, tsoome (prior version) Differential Revision: https://reviews.freebsd.org/D35965
* stand: impose 510,000 byte limit for /boot/loader and /boot/pxeldrWarner Losh2022-08-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BIOS method of booting imposes an absolute limit of 640k for the size of the program being run due to btx. In practice, this means that programs larger than about 500kiB will fail in odd ways as the stack / heap will overflow. Pick 510,000 as the cutoff line semi-arbitrarily. loader_lua is now almost too big and we want to break the build when it crosses this threshold. In my experience, below 500,000 always works, above 520,000 always seems to fail with things getting bad somewhere between 512,000 to 515,000. 510,000 is as close to the line as I think we can go, though experience may dictate we need to lower this in the future. This is at-best a stop-breakage until we have a better way to subset the boot loader for BIOS booting to allow better, more fined-tuned /boot/loaders for the many different environments they have to run in. This likely means we'll have a graphical loader than understands a few filesystmes for installation, and a non-graphical loader that understands the most filesystems possible for everything else in the future. Our build infrastructure needs some work before we can do that, however. At this late date, it likely isn't worth the efforts to move parts of the loader into high memory. There's a number of assumptions about where the stack is, where buffers reside, etc that are fulfilled when it lives in the first 640k that would need bounce buffers and/or other counter measures if we were to split it up. All BIOS calls are done in 16-bit mode with SEG:OFF addresses, requiring them to be in the first 640k of RAM. And nearly all machines in the last decade can boot with UEFI (though there's some exceptions, so it isn't worth killing outright yet). Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D36129
* stand: i386/amd64: Always use elf format for /boot/loader and pxeldrWarner Losh2022-08-111-1/+1
| | | | | | | | | | | | | | | | The first level boot blocks have understood how to load ELF code since 1999. Switch /boot/loader and /boot/pxeldr over to being ELF format so that in-tree tools can examine them more closely. In addition, one could, in theory, now have a 'lo-mem' and a 'hi-mem' segment (though a lot of work would need to be done with bounce buffers, btx, code segment marking, etc for an arrangement like that to work). As far as I can tell, this is the last a.out binary in the tree. There are several raw binaries left, but everything else is ELF. Reviewed by: emaste, kevans Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36130
* stand: s/libstand/libsa/g to catch up with renameWarner Losh2022-04-301-1/+1
| | | | | | | We renamed libstand to libsa years ago with the move from sys/boot to stand. Catch up in the comments. Sponsored by: Netflix
* loader: implement mount/unmount rootfsToomas Soome2021-09-081-0/+4
| | | | | | | | | We want to keep our root file system open to preserve bcache segment between file accesses, thus reducing physical disk IO. Reviewed by: imp, allanjude, kevans (previous version) Differential Revision: https://reviews.freebsd.org/D30848 MFC after: 1 month
* i386 loaders: avoid lld 13 garbage collecting linker setsDimitry Andric2021-09-081-0/+6
| | | | | | | | | | | | Because lld 13 and higher default to garbage collecting start/stop symbols when using --gc-sections, the linker sets used in the i386 boot loaders will disappear. This leads to the loaders not recognizing any commands, and failure to boot. Until we have a good set of linker scripts for the loaders, work around it by disabling the start-stop-gc feature. MFC after: 1 week
* type: becauce -> becauseWarner Losh2021-07-221-1/+1
| | | | | Noticed by: Piotr P. Stefaniak Sponsored by: Netflix
* i386/loader: Call tslog_initColin Percival2021-06-211-0/+6
| | | | | | This allows the i386 loader to start recording timestamps. Reviewed by: kevans
* boot: fix OBJS to not include BTX's crt0.oWarner Losh2021-05-061-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | According to comments in the Makefile, to make pxeboot work we need to have crt0.o first. This is needed because the simplified loader in pxeboot assumes that the startup code is at offset 0 in this binary. In normal booting, the start address can be obtained from headers of the binary, but since pxeboot encodes this as a pure binary, it has no way of knowing where that is and assumes 0. Added comments to that effect in the Makefile. We've done this by adding it to OBJS before all the other .o's are added. However, there's a problem. This also adds it to the CLEANFILES variable, which causes it to be removed from multiple places. The dependencies may also cause it to be re-built at a time that's after boot2 is built. This causes installs to fail because at install time boot2 is considered to be out of date and the programs to rebuild it are no longer in the path. Cope with this problem by just adding it to LDFLAGS instead. Glanced at by: kevans ("I thought that went in ages ago") Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28876
* loader: create built in font from bold font faceToomas Soome2021-01-231-1/+1
| | | | | We did replace full version of default font 8x16v with bold, also use bold version for built in font.
* loader: implement framebuffer consoleToomas Soome2021-01-022-5/+18
| | | | | | | | | | | | | | | | | | | | | | | Draw console on efi. Add vbe framebuffer for BIOS loader (vbe off, vbe on, vbe list, vbe set xxx). autoload font (/boot/fonts) based on resolution and font size. Add command loadfont (set font by file) and variable screen.font (set font by size). Pass loaded font to kernel. Export variables: screen.height screen.width screen.depth Add gfx primitives to draw the screen and put png image on the screen. Rework menu draw to iterate list of consoles to enamble device specific output. Probably something else I forgot... Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27420