History log of /freebsd-10.0-release/sys/boot/i386/gptboot/Makefile
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 252492 01-Jul-2013 wblock

Add a new gptboot(8) man page. Factor out the redundant information
in gpart(8) and boot(8), adding references to gptboot(8) in both.

Reviewed by: jhb, ae, pjd, Paul Schenkeveld <bsdcan@psconsult.nl>, david_a_bright@dell.com (portions), gjb
MFC after: 1 week


# 232263 28-Feb-2012 dim

Define several extra macros in bsd.sys.mk and sys/conf/kern.pre.mk, to
get rid of testing explicitly for clang (using ${CC:T:Mclang}) in
individual Makefiles.

Instead, use the following extra macros, for use with clang:
- NO_WERROR.clang (disables -Werror)
- NO_WCAST_ALIGN.clang (disables -Wcast-align)
- NO_WFORMAT.clang (disables -Wformat and friends)
- CLANG_NO_IAS (disables integrated assembler)
- CLANG_OPT_SMALL (adds flags for extra small size optimizations)

As a side effect, this enables setting CC/CXX/CPP in src.conf instead of
make.conf! For clang, use the following:

CC=clang
CXX=clang++
CPP=clang-cpp

MFC after: 2 weeks


# 225530 13-Sep-2011 avg

gpt/zfs boot blocks: reduce optimizing CFLAGS to -O1

gpt and zfs boot blocks are not nearly as size-constrained as boot2
from which they inherited their current optimization and anti-optimization
options. As such the current options do not provide any benefit, but
make debugging of the code much harder.
Also, it has been demonstrated that combination of -mrtd and
-fno-unit-at-a-time may result in mis-compilation of the boot code
with the current base gcc.

Additionally, intermediate assembly file filtering is removed for
zfsboot.

The new boot blocks are all compile- and boot- tested using qemu.
gptzfsboot is tested with real hardware.

Reported by: Peter Jeremy <peterjeremy@acm.org> [miscompilation]
Discussed with: bde, jhb
Tested by: Sebastian Chmielewski <chmielsster@gmail.com> [gptzfsboot]
Approved by: re (kib)
MFC after: 3 weeks


# 219483 11-Mar-2011 jhb

Remove all object files during 'make clean'.

PR: kern/154888
Submitted by: arundel
MFC after: 1 week


# 219079 27-Feb-2011 dim

Clang's integrated assembler can now handle sys/boot/i386/boot2/sio.S.
It used to choke on the notation "inb (%dx),%al" for "inb %dx,%al"; GNU
as accepts both forms. Which notation is more 'correct' is an open
question. :)


# 218893 20-Feb-2011 dim

Upgrade our copy of llvm/clang to r126079, from upstream's trunk.

This contains many improvements, primarily better C++ support, an
integrated assembler for x86 and support for -pg.


# 217028 05-Jan-2011 dim

Remove superfluous -mno-(mmx|3dnow|sse|sse2|sse3) flags in Makefiles
under sys/boot/{i386,pc98}, since these are already added via
sys/boot/{i386,pc98}/Makefile.inc.

Submitted by: arundel


# 213568 08-Oct-2010 pho

Ensure that a make from sys/boot does not pick up include files from
/usr/include.

Discussed with: kib


# 213136 24-Sep-2010 pjd

- Split code shared by almost any boot loader into separate files and
clean up most layering violations:

sys/boot/i386/common/rbx.h:

RBX_* defines
OPT_SET()
OPT_CHECK()

sys/boot/common/util.[ch]:

memcpy()
memset()
memcmp()
bcpy()
bzero()
bcmp()
strcmp()
strncmp() [new]
strcpy()
strcat()
strchr()
strlen()
printf()

sys/boot/i386/common/cons.[ch]:

ioctrl
putc()
xputc()
putchar()
getc()
xgetc()
keyhit() [now takes number of seconds as an argument]
getstr()

sys/boot/i386/common/drv.[ch]:

struct dsk
drvread()
drvwrite() [new]
drvsize() [new]

sys/boot/common/crc32.[ch] [new]

sys/boot/common/gpt.[ch] [new]

- Teach gptboot and gptzfsboot about new files. I haven't touched the
rest, but there is still a lot of code duplication to be removed.

- Implement full GPT support. Currently we just read primary header and
partition table and don't care about checksums, etc. After this change we
verify checksums of primary header and primary partition table and if
there is a problem we fall back to backup header and backup partition
table.

- Clean up most messages to use prefix of boot program, so in case of an
error we know where the error comes from, eg.:

gptboot: unable to read primary GPT header

- If we can't boot, print boot prompt only once and not every five
seconds.

- Honour newly added GPT attributes:

bootme - this is bootable partition
bootonce - try to boot from this partition only once
bootfailed - we failed to boot from this partition

- Change boot order of gptboot to the following:

1. Try to boot from all the partitions that have both 'bootme'
and 'bootonce' attributes one by one.
2. Try to boot from all the partitions that have only 'bootme'
attribute one by one.
3. If there are no partitions with 'bootme' attribute, boot from
the first UFS partition.

- The 'bootonce' functionality is implemented in the following way:

1. Walk through all the partitions and when 'bootonce'
attribute is found without 'bootme' attribute, remove
'bootonce' attribute and set 'bootfailed' attribute.
'bootonce' attribute alone means that we tried to boot from
this partition, but boot failed after leaving gptboot and
machine was restarted.
2. Find partition with both 'bootme' and 'bootonce' attributes.
3. Remove 'bootme' attribute.
4. Try to execute /boot/loader or /boot/kernel/kernel from that
partition. If succeeded we stop here.
5. If execution failed, remove 'bootonce' and set 'bootfailed'.
6. Go to 2.

If whole boot succeeded there is new /etc/rc.d/gptboot script coming
that will log all partitions that we failed to boot from (the ones with
'bootfailed' attribute) and will remove this attribute. It will also
find partition with 'bootonce' attribute - this is the partition we
booted from successfully. The script will log success and remove the
attribute.

All the GPT updates we do here goes to both primary and backup GPT if
they are valid. We don't touch headers or partition tables when
checksum doesn't match.

Reviewed by: arch (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>)
Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
MFC after: 2 weeks


# 211677 22-Aug-2010 imp

MF tbemd: Minor tweaks, prefer MACHINE_CPUARCH generally to MACHINE_ARCH


# 173026 26-Oct-2007 jhb

Add . to the include path so that we follow the 'machine' symlink we create
during depend on amd64.

Reported by: rwatson


# 172940 24-Oct-2007 jhb

First cut at support for booting a GPT labeled disk via the BIOS bootstrap
on i386 and amd64 machines. The overall process is that /boot/pmbr lives
in the PMBR (similar to /boot/mbr for MBR disks) and is responsible for
locating and loading /boot/gptboot. /boot/gptboot is similar to /boot/boot
except that it groks GPT rather than MBR + bsdlabel. Unlike /boot/boot,
/boot/gptboot lives in its own dedicated GPT partition with a new
"FreeBSD boot" type. This partition does not have a fixed size in that
/boot/pmbr will load the entire partition into the lower 640k. However,
it is limited in that it can only be 545k. That's still a lot better than
the current 7.5k limit for boot2 on MBR. gptboot mostly acts just like
boot2 in that it reads /boot.config and loads up /boot/loader. Some more
details:
- Include uuid_equal() and uuid_is_nil() in libstand.
- Add a new 'boot' command to gpt(8) which makes a GPT disk bootable using
/boot/pmbr and /boot/gptboot. Note that the disk must have some free
space for the boot partition.
- This required exposing the backend of the 'add' function as a
gpt_add_part() function to the rest of gpt(8). 'boot' uses this to
create a boot partition if needed.
- Don't cripple cgbase() in the UFS boot code for /boot/gptboot so that
it can handle a filesystem > 1.5 TB.
- /boot/gptboot has a simple loader (gptldr) that doesn't do any I/O
unlike boot1 since /boot/pmbr loads all of gptboot up front. The
C portion of gptboot (gptboot.c) has been repocopied from boot2.c.
The primary changes are to parse the GPT to find a root filesystem
and to use 64-bit disk addresses. Currently gptboot assumes that the
first UFS partition on the disk is the / filesystem, but this algorithm
will likely be improved in the future.
- Teach the biosdisk driver in /boot/loader to understand GPT tables.
GPT partitions are identified as 'disk0pX:' (e.g. disk0p2:) which is
similar to the /dev names the kernel uses (e.g. /dev/ad0p2).
- Add a new "freebsd-boot" alias to g_part() for the new boot UUID.

MFC after: 1 month
Discussed with: marcel (some things might still change, but am committing
what I have so far)


# 169732 19-May-2007 kan

Tweak inlining parameters a little. Add warning to tell us if function
we declared as inline can not be inlined.


# 148046 15-Jul-2005 ache

Add -mno-sse3 for prescott/nocona


# 143661 15-Mar-2005 obrien

Ensure GCC does not use FP registers in integer code.
I think all we really need is -fno-sse2.
I really don't like cluttering up the compiler invocation,
but this bigger hammer will fix reported problems for now.


# 134382 27-Aug-2004 yar

B1FLAGS -> BOOT_BOOT1_FLAGS, which is consistent with
naming of other boot-related make vars.


# 132870 30-Jul-2004 kan

Compile boot2 with -fno-unit-at-a-time. GCCs aggressive optimization
breaks boot in spectacular ways otherwise.


# 125932 17-Feb-2004 ru

Re-add sio.S, and properly deal with assembler files.

Repocopied by: joe


# 125621 09-Feb-2004 ru

- Factor out -nostdlib to an upper level Makefile.inc.

- Now that bsd.prog.mk deals with programs linked with -nostdlib
better, and has a notion of an "internal" program, use PROG
where possible. This has a good impact on the contents of
.depend files and causes programs to be linked with cc(1).

XXX: boot2 couldn't be converted as it's actually two programs.

Tested on: i386, amd64


# 125581 07-Feb-2004 ru

Argh, unbreak "make depend" for AMD64.

Reported by: kris


# 125566 07-Feb-2004 ru

- Removed -elf which is not a valid gcc(1) option anymore.
- Removed -ffreestanding; it's enforced by ../Makefile.inc.


# 125564 07-Feb-2004 ru

Generate .depend file.


# 125556 07-Feb-2004 ru

Untangle building of AMD64 boot code.

Tested on: amd64 (sledge)


# 125537 06-Feb-2004 ru

First round of cleanups to sys/boot/ makefiles:

- do not use PROG for what's not a real C program,
- use sys.mk transformation rules where possible,
- only create the "machine" symlink on AMD64,
- removed MAINTAINER lines in individual makefiles,
- added the LIBSTAND defitinion to <bsd.libnames.mk>,
- somewhat better contents in .depend files.

Tested on: i386, amd64
Prodded by: bde


# 125517 06-Feb-2004 ru

Inherit BINDIR from a parent Makefile.inc.


# 116864 26-Jun-2003 peter

Build on amd64. Yes, I know this isn't particularly nice.


# 111490 25-Feb-2003 ru

Fixed CLEANFILES.

Submitted by: cron


# 109886 26-Jan-2003 phk

Build a file "boot" which consists of boot1 and boot2 concatenated.

There is little if any reason to treat the two components separately
and it will simplify disklabel(8) and libdisk if we didn't.


# 108149 21-Dec-2002 obrien

-mno-align-long-strings can make things smaller, so lets use it in hopes
that it does here.


# 108016 18-Dec-2002 imp

I didn't intend to delete this rm from the Makefile. It snuck in at
the last second before the commit.

# likely we can remove this hack now that gcc generates better aligned code
# in the align to word case.

Noticed by: bde


# 108000 17-Dec-2002 imp

Make both UFS1 and UFS2 fit on the same boot blocks. These are a
subset of Peter's patchs that are believed to be safe.

Makefile tweaks:
o -fomit-frame-pointer
o Change default to building both UFS1 and UFS2 bootblocks.

Lots of boot2 tweaks:
o lookup is only ever called with kname, so use it directly.
o inline memsize
o getstr are only ever called with cmd, so hardware that.
o tweaks to the parsing code to test after the conversion rather than
before since we tested after anyways.
o eliminate support for %x in printf.
o eliminate a few bytes in printfs.
o Tweak the boot banner.
o eliminate support for wd and " " devices (I might add wd back to
keep bde happy).
o eliminate support for a few arguments.

This takes us from -162 bytes free to 67 bytes free.

I've tested this only on a few systems, so be careful when updating to
this change.

Submitted by: peter, imp, ian


# 107879 14-Dec-2002 phk

Employ the unused bytes after the disklabel in the second sector. This makes
it possible to make UFS1_ONLY and UFS2_ONLY versions which fit inside the
traditional 16 sectors.

Remove assorted now unneeded hackery.

UFS1_AND_UFS2 still needs another 150 bytes to work, and that is probably
not within our reach, ever.


# 104683 08-Oct-2002 jhb

Revert MEM_USR back to 0xa000 for BTX clients. Instead, adjust boot2
to run at 0xc000 by changing its virtual start address from 0x1000 to
0x2000.

Tested by: phk


# 104680 08-Oct-2002 phk

Now that ufsread.c doesn't do 64bit divide remainder operations,
don't bother with libkern.

Sponsored by: DARPA & NAI Labs.


# 104673 08-Oct-2002 green

Reinstate rev 1.36 with an important line that got missed. Note this
also improves the "random undocumented offsets into various memory
spaces" a little bit.


# 104668 08-Oct-2002 phk

Unbreak boot2 by backing out rev 1.36 to Makefile, which does not
work as advertised:

bang# pwd
/bang/src/sys/boot/i386/boot2
bang# make clean >& /dev/null
bang# cvs -q update -r 1.35 Makefile >& /dev/null
bang# make >& /dev/null
bang# cat /usr/obj/`pwd`/boot2.h
#define XREADORG 0x725
bang# cvs -q update -r 1.36 Makefile > & /dev/null
bang# make clean > & /dev/null
bang# make > & /dev/null
bang# cat /usr/obj/`pwd`/boot2.h
#define XREADORG 0x25
bang#


# 104636 07-Oct-2002 green

Correct a bug in adding 0x700 to a number.


# 104635 07-Oct-2002 phk

Conditionalize the number of sectors loaded by boot1.s on UFS1/UFS12.

Conditionalize the "XX bytes left" checks reference on UFS1/UFS12.

Conditionally build the necessary 64bit math for boot2 if UFS12.

Sponsored by: DARPA & NAI Labs.


# 104632 07-Oct-2002 phk

Change the comment character from # to // in boot1.s and run
it through CPP so we can conditionalized things.

Sponsored by: DARPA & NAI Labs


# 104612 07-Oct-2002 phk

Move the definition of UFS1_ONLY into the Makefiles where it belongs.

Sponsored by: DARPA & NAI Labs.


# 100872 29-Jul-2002 ru

Drop support for COPY, -c has been the default mode of install(1)
for a long time now.

Approved by: bde


# 98556 21-Jun-2002 phk

Revert the part of Kirks UFS2 commit which added divdi3.c and moddi3.c
to libi386, this issue was resolved already in a cleaner way.


# 98542 21-Jun-2002 mckusick

This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by: Poul-Henning Kamp <phk@freebsd.org>


# 97867 05-Jun-2002 phk

Add explicit dependency on ufsread.c


# 97860 05-Jun-2002 phk

Preparation for UFS2 commit:

Factor the ufs reading code out of the i386/boot2 loader so it can
be reused by for instance sparc64.

Sponsored by: DARPA and NAI Labs.


# 96533 13-May-2002 ru

Align CLEANFILES with revision 1.25 changes.


# 96460 12-May-2002 bde

Saved 176 bytes by compiling with -fno-guess-branch-probability. The
default of -fguess-branch-probablility causes time optimizations (?)
like rewriting `if (foo) x++;' as
`if (!foo) goto forth; back: ; ...; forth: x++; goto back;". This is
pessimizes space especially well on i386's because one short branch
gets converted to 2 long ones.

Removed -fno-align-foo since it is implied by -Os. Previous commit
messages seem to have overstated the new alignment bugs in gcc. The
only case that affects boot2 is that -fno-align-functions (or
equivalently -falign-functions=1) actually gives -falign-functions=2.
This is caused by FUNCTION_BOUNDARY being 2 (bytes) instead of 1.
The default case where the optimization level is 1 and no alignment
options are given is more broken. All alignments are minimal, modulo
the bug in FUNCTION_BOUNDARY. This is caused by toplev.c setting
defaults too early.

Some hacks in previous commits ar not needed now, but may as well be
kept until gcc is fixed. The previous on in the Makefile saved 96
bytes of text due to the wrong FUNCTION_BOUNDARY and 32 bytes of data
due to unrelated bloat in the alignment of large objects. There aren't
even any options to control alignment of data.


# 96424 11-May-2002 peter

Use a crowbar and duct-tape to make boot2 fit again. This gets it down
to 4 bytes free. I removed a printf (the Keyboard yes/no) since it is of
marginal value and sed'ed the generated asm output to remove the unwanted
aligns. There's probably a better way to gain a few extra bytes than
losing the printf. Shortening strings is probably a better option but this
should get us over the hurdle.


# 96327 10-May-2002 jhb

- Axe -mpreferred-stack-boundary=2 as -Os turns this on by default.
- Axe -fdata-sections as turning it on or off makes no difference. If
it did make a difference it would serve to bloat boot2 even further with
extra padding.
- Axe -fforce-addr. This gets us 32 bytes so we are down to only being
64-bytes over.

We still can't compile this with gcc 3.1. The problem seems to be that
the -fno-align-foo options don't actually work. Comparing the new and
old output it turns out that gcc is 4-byte padding all the functions and
labels and what not despite the passed in arguments thus adding the
unfortunate bloat to boot2.


# 96306 09-May-2002 obrien

-ffreestanding is the word for /sys.


# 80751 31-Jul-2001 jhb

Add in a hack to support IBM "El Torito" CD-ROM booting BIOS's which expect
the first sector of the emulated floppy to contain a valid MS-DOS BPB that
it can modify. Since boot1 is the first sector of boot.flp, this resulted
in the BIOS overwriting part of boot1: specifically the function used to
read in sectors from the disk.

Submitted by: Mark Peek <mark@whistle.com>
Submitted by: Doug Ambrisko <ambrisko@ambrisko.com>
PR: i386/26382
Obtained from: NetBSD, OpenBSD (the example BPB)
MFC after: 1 month


# 80084 21-Jul-2001 rnordier

Unset MAINTAINER.


# 66555 02-Oct-2000 rnordier

Set MAINTAINER.


# 62138 26-Jun-2000 jhb

Add in support for EDD to support large disks via LBA. This uses a
method similar to that of the loader to avoid potentially breaking older
drives in that we only use EDD if the desired cylinder is > 1023.


# 60821 23-May-2000 jhb

Clean up all of the 16-bit assembly code in the x86 bootstrap to work
with the new binutils. Now that we have a decent assembler, all the old
m4 macros are no longer needed. Instead, straight assembly can be used
since as(1) now understands 16-bit addressing, branches, etc. Also,
several bugs have been fixed in as(1), allowing boot0.s to be further
cleaned up.


# 59150 11-Apr-2000 jhb

Add a missing dependency: boot2 depends on the BTX kernel.


# 53174 15-Nov-1999 obrien

Add -fdata-sections, which is a new GCC 2.95 optimization. Remove
-fschedule-insns as it wasn't such a big win with 2.95 after all.

Add the *BIG* win "-mpreferred-stack-boundary=2" optimiztion submitted by
Dima. GCC 2.95 ensures the stack frame is always properly [opitimally]
aligned by surrounding every function call by code simular to
"addl $-12, %esp" / "addl $12, %esp". Here we need the reduction in space,
with speed not an issue.


# 53134 13-Nov-1999 obrien

Turn on the -fforce-addr and -fschedule-insns optimizations. Adding
either one gives us an additional 32 bytes of additional space available
when using EGCS 1.1.2. With GCC 2.95.2 -fforce-addr gives us 12 more bytes,
and adding -fschedule-insns gives us an additional 4 bytes.


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 48919 19-Jul-1999 rnordier

Reintroduce LBA (cyl > 1023) support in the bootblocks, enabled by
means of a build option.


# 45334 05-Apr-1999 rnordier

Optimize better for space.
Thanks to: jdp


# 42480 10-Jan-1999 rnordier

Use etc/make.conf settings for serial port and speed.

Submitted by: rvb
Reviewed by: bde


# 41008 08-Nov-1998 rnordier

boot1: Eliminate EDD detection and optional use of disk packet
interface. Do some general consistency fixes and space optimizations.
Use of some freed-up space to defend against possible BIOS misfeatures.

boot2: Revise disk read interface to provide for boot1 changes. Free
up space for this.


# 40940 05-Nov-1998 rnordier

Make use of BIOS int 0x13 extensions configurable, and disabled
by default.


# 40541 20-Oct-1998 rnordier

Make serial port, data format, and bps configurable.


# 40416 15-Oct-1998 rnordier

Fix path to sio.s


# 40404 15-Oct-1998 rnordier

Add serial, dual, and probe-keyboard support.


# 40330 13-Oct-1998 rnordier

Fix btx include path.


# 40326 13-Oct-1998 rnordier

Include <bsd.prog.mk>. Add install target (to /boot for now).


# 40314 13-Oct-1998 rnordier

Change to a 15-sector boot2.
Refine slice-handling.


# 40308 13-Oct-1998 rnordier

Don't use an absolute path to objcopy.
Noticed by: Scott Mace <smace@intt.org>


# 40269 12-Oct-1998 rnordier

New boot blocks: support for /boot/loader; a.out & ELF; cyl > 1023;
multiple 0xa5 slices; etc.