Commit Graph

1983 Commits

Author SHA1 Message Date
Yoshihiro Takahashi
b5ca553462 Oops, fix the previous change. 2009-03-20 13:03:33 +00:00
Yoshihiro Takahashi
d0680af004 MFi386: r189749
Teach the BIOS CD driver to use bounce buffers when the destination
  address is > 1 MB.
2009-03-20 12:26:42 +00:00
Yoshihiro Takahashi
e4cc6edfc1 Merge the missing changes from i386.
Teach the loader about the FAT partitions.
2009-03-20 05:33:58 +00:00
Yoshihiro Takahashi
43d1b8129c MFi386: the part of r179825 to reduce diffs against i386. 2009-03-20 05:21:29 +00:00
Andrew Thompson
2b78d30630 Remove the uscanner(4) driver, this follows the removal of the kernel scanner
driver in Linux 2.6. uscanner was just a simple wrapper around a fifo and
contained no logic, the default interface is now libusb (supported by sane).

Reviewed by:	HPS
2009-03-19 20:33:26 +00:00
Yoshihiro Takahashi
abadd1494d Reduce diffs against i386. 2009-03-19 13:53:42 +00:00
Yoshihiro Takahashi
1214222676 Use the common PC98_MID_* defines instead of a magic number. 2009-03-19 12:33:37 +00:00
Dmitry Chagin
6465d2d9d2 Chase the k8temp->amdtemp rename in NOTES and loader.conf.
Approved by:	kib (mentor)
2009-03-16 10:36:24 +00:00
John Baldwin
47193e464b The recent change to use memory > 1MB for the heap by default broke CD
booting because the CD driver did not use bounce buffers to ensure
request buffers sent to the BIOS were always in the first 1MB.  Copy over
the bounce buffer logic from the BIOS disk driver (minus the 64k boundary
code for floppies) to fix this.

Reported by:	kensmith
2009-03-12 20:41:52 +00:00
John Baldwin
49e81dc952 - Make it possible to disable GPT support by setting LOADER_NO_GPT_SUPPORT
in make.conf or src.conf.
- When GPT is enabled (which it is by default), use memory above 1 MB and
  leave the memory from the end of the bss to the end of the 640k window
  purely for the stack.  The loader has grown and now it is much more
  common for the heap and stack to grow into each other when both are
  located in the 640k window.

PR:		kern/129526
MFC after:	1 week
2009-03-09 17:16:29 +00:00
Marcel Moolenaar
20b2c39f0c Revert the part of change 107879 that employs the unused bytes after
the disklabel in the 2nd sector for boot code. Even with both UFS1
and UFS2 supported, there's enough bytes left that we don't have to
nibble from the disklabel.
Thus, the entire 2nd sector is now reserved for the disklabel, which
makes the bootcode compatible again with disklabels that have more
than 8 partitions -- such as those created and supported by gpart.

i386: 135 bytes available
amd64: 151 bytes available

Ok'd by: jhb
2009-03-07 22:05:58 +00:00
John Baldwin
2cf997a261 Fix some more issues with the real mode BTX.
The old BTX passed the general purpose registers from the 32-bit client to
the routines called via virtual 86 mode.  The new BTX did the same thing.
However, it turns out that some instructions behave differently in virtual 86
mode and real mode (even though this is under-documented).  For example, the
LEAVE instruction will cause an exception in real mode if any of the upper
16-bits of %ebp are non-zero after it executes.  In virtual 8086 mode the
upper 16-bits are simply ignored.  This could cause faults in hardware
interrupt handlers that inherited an %ebp larger than 0xffff from the 32-bit
client (loader, boot2, etc.) while running in real mode.

To fix, when executing hardware interrupt handlers provide an explicit clean
state where all the general purpose and segment registers are zero upon
entry to the interrupt handler.  While here, I attempted to simplify the
control flow in the 'intusr' code that sets up the various stack frames
and exits protected mode to invoke the requested routine via real mode.

A huge thanks to Tor Egge (tegge@) for debugging this issue.

Submitted by:	tegge
Reviewed by:	tegge
Tested by:	bz
MFC after:	1 week
2009-02-24 23:11:15 +00:00
Ruslan Ermilov
d9ca85fca7 Fix build when WITH_SSP is set explicitly.
Submitted by:	Jeremie Le Hen
2009-02-21 15:04:31 +00:00
Warner Losh
7d11259539 Enable building of ficl on MIPS. It compiles, but needs more testing. 2009-02-19 18:53:08 +00:00
Warner Losh
962cd8ffd7 Add basic mips support. This has been compile tested only. 2009-02-19 18:52:31 +00:00
Andrew Thompson
d842ade9a4 Add a helper function for loading geli keys from the loader. 2009-02-16 02:42:17 +00:00
Marius Strobl
ceab1bee37 - Use the generally more appropriate PROM base rather than the
kernel one as the non-faulting flush address in the loader so
  we can can change KERNBASE and VM_MIN_KERNEL_ADDRESS if we
  ever want to without needing to worry about using a compatible
  loader.
- Correctly check for LOADER_DEBUG.
- Add a missing const for page_sizes[].
2009-02-10 21:48:42 +00:00
Gabor Kovesdan
d3e084d2cf - Remove superfluous comment
PR:		docs/129400
Submitted by:	Gavin Atkinson <gavin@freebsd.org>
2009-01-30 15:27:04 +00:00
Weongyo Jeong
0d5245c817 Add an entry for the urtw(4) module. 2009-01-23 05:56:09 +00:00
Luigi Rizzo
3f2721ea44 remove a file which is, as far as I can tell, totally unused. 2009-01-13 22:15:47 +00:00
Luigi Rizzo
2ca710fbbc comment out some debugging messages that slipped in by mistake.
MFC after:	3 days
2009-01-13 12:28:14 +00:00
Jung-uk Kim
88a82e34f7 Allow VIA Nano processors to boot FreeBSD/amd64.
PR:		amd64/130303
MFC after:	1 week
2009-01-12 16:28:19 +00:00
Luigi Rizzo
065188a630 This patch introduces a number of simplifications to the Forth
functions used in the bootloader. The goal is to make the code more
readable and smaller (especially because we have size issues
in the loader's environment).

High level description of the changes:
+ define some string manipulation functions to improve readability;
+ create functions to manipulate module descriptors, removing some
  duplicated code;
+ rename the error codes to ESOMETHING;
+ consistently use set_environment_variable (which evaluates
  $variables) when interpreting variable=value assignments;

I have tested the code, but there might be code paths that I have
not traversed so please let me know of any issues.

Details of this change:

--- loader.4th ---
+ add some module operators, to remove duplicated code while parsing
  module-related commands:

        set-module-flag
        enable-module
        disable-module
        toggle-module
        show-module

--- pnp.4th ---
+ move here the definition related to the pnp devices list, e.g.
  STAILQ_* , pnpident, pnpinfo

--- support.4th ---
+ rename error codes to capital e.g. ENOMEM EFREE ... and do obvious
  changes related to the renaming;
+ remove unused structures (those relevant to pnp are moved to pnp.4th)
+ various string functions
  - strlen removed (it is an internal function)
  - strchr, defined as the C function
  - strtype -- type a string to output
  - strref -- assign a reference to the string on the stack
  - unquote -- remove quotes from a string

+ remove reset_line_buffer

+ move up the 'set_environment_variable' function (which now
  uses the interpreter, so $variables are evaluated).
  Use the function in various places

+ add a 'test_file function' for debugging purposes

MFC after:	4 weeks
2009-01-05 20:09:54 +00:00
Luigi Rizzo
df52a87993 A number of small changes to make the 'save choice to disk' safer,
and re-enable it as default.

In particular:

+ re-enable the 'update' flag in the Makefile (of course!);

+ commit Warner's patch "orb $NOUPDATE,_FLAGS(%bp)"
  to avoid writing to disk in case of a timeout/default choice;

+ fix an off-by-one count in the partition scan code that would
  print the wrong name for unknown partitions;

+ unconditionally change the boot prompt to 'Boot:' instead of 'Default:'
  to make room for the extra code/checks/messages. Some of the changes
  listed below are also made to save space;

+ rearrange and fix comments for known partition types. Right now we
  explicitly recognise *BSD, Linux, FAT16 (type 6, used on many USB keys),
  NTFS (type 7), FAT32 (type 11).
  Depending on other options we also recognise Extended (type 5),
  FAT12 (type 1) and FAT16 < 32MB (type 4).

+ Add an entry "F6 PXE" when the code is built with -DPXE (which is
  a default now). Technically, F6 boots through INT18, so the prompt 'PXE'
  is a bit misleading. Unfortunately the name INT18
  is too long and does not fit in - we could use ROM perhaps.
  The reason I picked 'PXE' is that on many (I believe) new systems
  INT18 calls PXE.

Apart from the choice of the name for PXE/ROM/INT18, this should close
pending issues on the 1-sector boot0 code and we should be able to
move the code to RELENG_7 when it reopens.

No boot0cfg changes are necessary.

MFC after:	3 weeks
2008-12-30 09:40:50 +00:00
Sam Leffler
41fe50f5de MFH @ 186335 2008-12-20 01:29:19 +00:00
Sam Leffler
656c23db6e add delays around 16-bit enable/disable a la the driver; w/o this
operation on my ixp435 Cambria board is unreliable
2008-12-19 00:56:47 +00:00
Doug Rabson
7b3569ff05 Use full 64bit arithmetic when converting file offsets to block numbers - fixes
booting on filesystems with inode numbers with values above 4194304.

Submitted by:	ps
2008-12-17 18:12:01 +00:00
Rafal Jaworowski
845a6f19d2 Improve style(9) in PowerPC U-Boot support lib. 2008-12-17 15:58:07 +00:00
Yoshihiro Takahashi
aa22b26643 Disconnect the efi from pc98. It's not needed. 2008-12-14 02:57:41 +00:00
Sam Leffler
4173c22644 merge WIP multi-board support; tested on Avila and Cambria, still
needs Proghorn testing
2008-12-13 02:56:08 +00:00
Paul Saab
5ee5aed0a3 Fix a leak introduced in r185902. We should free the devspec if
we've successfully found a zfs pool.
2008-12-11 16:48:35 +00:00
Paul Saab
390edcc5b9 Avoid a double free in devopen by not freeing the device structure
in zfs_dev_open.  This stops a panic in the loader when trying to
read from a zfs device and no zfs devices exist.
2008-12-11 02:23:49 +00:00
Doug Rabson
937a012e5d Don't get confused if we encounter a device which is part of a raidz or raidz2
pool while probing for vdevs.

PR:		129539
Submitted by:	Paul Wootton (paul at fletchermoorland dot co dot uk)
2008-12-10 10:46:34 +00:00
Maxim Sobolev
bce289fa28 Remove now unused label.
Submitted by:	Christoph Mallon
MFC after:	4 weeks
		(along with r185779 and r185780)
2008-12-09 00:25:57 +00:00
Maxim Sobolev
55641d8353 Optimiza assembly in the previous r185779, to save whooping 16 bytes.
Submitted by:	Christoph Mallon
MFC after:	4 weeks
		(including r185779)
2008-12-08 23:45:41 +00:00
Maxim Sobolev
e110108d3e Respect RBX_MUTE flag from boot[012].
MFC after:	4 weeks
2008-12-08 21:52:06 +00:00
Maxim Sobolev
a6d94c502c Fix typo in the comment %is -> %si. 2008-12-08 20:53:27 +00:00
Luigi Rizzo
5e5391084a PROBLEM: putting in a loader config file a line of the form
loader_conf_files="foo bar baz"

should cause loading the files listed, and then resume with the
remaining config files (from previous values of the variable).
Unfortunately, sometimes the line was ignored -- actually even
modifying the line in /boot/default/loader.conf  sometimes doesn't work.

ANALYSIS: After much investigation, turned out to be a bug in the logic.
The existing code detected a new assignment by looking at the address
of the the variable containing the string. This only worked by pure
chance, i.e. if the new string is longer than the previous value
then the memory allocator may return a different address
to store the string hence triggering the detection.

SOLUTION: This commit contains a minimal change to fix the problem,
without altering too much the existing structure of the code.
However, as a step towards improving the quality and reliability of
this code, I have introduced a handful of one-line functions
(strget, strset, strfree, string= ) that could be used in dozens
of places in the existing code.

HOWEVER:
There is a much bigger problem here. Even though I am no Forth
expert (as most fellow src committers) I can tell that much of the
forth code (in support.4th at least) is in severe need of a
review/refactoring:

+ pieces of code are replicated multiple times instead of writing
  functions (see e.g.  set_module_*);

+ a lot of stale code (e.g. "structure" definitions for
  preloaded_files, kernel_module, pnp stuff) which is not used
  or at least belongs elsewhere.
  The code bload is extremely bad as the loader runs with very small
  memory constraints, and we already hit the limit once (see

    http://svn.freebsd.org/viewvc/base?view=revision&revision=185132
  Reducing the footprint of the forth files is critical.

+ two different styles of coding, one using pure stack functions
  (maybe beautiful but surely highly unreadable), one using
  high level mechanisms to give names to arguments and local
  variables (which leads to readable code).

Note that this code is used by default by all FreeBSD installations,
so the fragility and the code bloat are extremely damaging.
I will try to work fixing the three items above, but if others have
time, please have a look at these issues.

MFC after:	4 weeks
2008-12-07 19:42:20 +00:00
Paul Saab
8f6a8ed553 Correct include path for i386 specific includes. This allows zfs
to boot on systems where the loader is built on amd64 systems.
2008-12-06 14:45:03 +00:00
Daniel Gerzo
f1f8583397 - correct variable name
PR:		docs/129448
Submitted by:	Kenyon Ralph <kralph@gmail.com>
MFC after:	Revision 1.91 is merged
2008-12-06 11:21:10 +00:00
Luigi Rizzo
ae3096705c Another, hopefully final set of changes to boot0 and boot0cfg.
boot0.S changes:

+ import a patch from Christoph Mallon to rearrange the various
  print functions and save another couple of bytes;

+ implement the suggestion in PR 70531 to enable booting from
  any valid partition because even the extended partitions that
  were previously in our kill list may contain a valid boot loader.
  This simplifies the code and saves some bytes;

+ followwing up PR 127764, implement conditional code to preserve
  the 'Volume ID' which might be used by other OS (NT, XP, Vista)
  and is located at offset 0x1b8. This requires a relocation of the
  parameter block within the boot sector -- there is no other
  possible workaround.
  To address this, boot0cfg has been updated to handle both
  versions of the boot code;

+ slightly rearrange the strings printed in the menus to make
  the code buildable with all options. Given the tight memory
  budget, this means that with certain options we need to
  shrink or remove certain labels.

and especially:

	make -DVOLUME_LABEL -DPXE the default options.

  This means that the newly built boot0 block will preserve the
  Volume ID, and has the (hidden) option F6 to boot from INT18/PXE.
  I think the extra functionality is well worth the change.

  The most visible difference here is that the 'Default: ' string
  now becomes 'Boot: ' (it can be reverted to the old value
  but then we need to nuke 1/2 partition name or entries to
  make up for the extra room).

boot0cfg changes:

+ modify the code to recognise the new boot0 structure (with the
  relocated options block to make room for the Volume id).

+ add two options, '-i xxxx-xxxx' to set the volume ID, -e c
  to modify the character printed in case of bad input

PR:		127764 70531
Submitted by:	Christoph Mallon (portions)
MFC after:	4 weeks
2008-12-03 14:53:59 +00:00
Luigi Rizzo
4b91bf7948 This commits brings in a lot of documentation and some enhancement
of the boot0.S code, with a number of compile-time selectable options,
the most interesting one being the ability to select PXE booting.

The code is completely compatible with the previous one, and with
the boot0cfg program. Even the actual code is largely unmodified,
with only minor rearrangements or fixes to make room for the new
features.

The behaviour of the standard build differs from the previous
version in the following, minor things:

+ 'noupdate' is the default, which means the code does not
  write back the selection to disk. You can enable the feature
  at runtime with boot0cfg, or changing the flags in the Makefile.

+ a drive number of 0x00 (floppy, or USB in floppy emulation) is
  now accepted as valid. Previously, it was overridden with 0x80,
  meaning that the partition table coming from the media was
  used to access sectors on a possibly different media.
  You can revert to the previous mode building with -DCHECK_DRIVE,
  and you can always use the 'setdrv' option in boot0cfg

+ certain FAT or NTFS partitions are listed as WIN instead of DOS.

+ the 'bel' character on a bad selection is replaced by a '#' to
  make it clear that the system is not hang even if the machine
  does not have a speaker. This can be reverted back at compile
  time, or at runtime with an upcoming boot0cfg option.

Additional features are available as compile time options,
and may be become the default if deemed useful. In particular:

+ INT18/PXE boot (make -DPXE)
  This option enables booting through INT 18h (which on certain
  BIOSes can be hooked to PXE) by pressing F6. There is unfortunately
  no room to print the additional menu option.
  Also, to make room for the code, the 'Default: ' string is
  changed to 'Boot: '

+ print current drive number (make -DTEST)
  Prints a line indicating the current drive number.
  This is useful to figure out what is going on for machines/bioses
  which remap drives in sometimes surprising ways.

+ disable numeric keys in console mode (make -DONLY_F_KEYS)
  Not really a significant option, but it is needed to make
  room for the -DTEST mode.

+ disable floppy support (make -DCHECK_DRIVE)
  Revert to the old behaviour of only accepting 0x80 and above
  as valid drive numbers.

MFC after:	6 weeks
2008-12-02 14:57:48 +00:00
Rafal Jaworowski
8504549387 Let ARM loader(8) build with the man page. 2008-11-27 16:53:01 +00:00
Luigi Rizzo
86d6c2d4b9 Fix a typo in previous commit: must call "putn" to print a crlf,
instead of "puts" which prints whatever is at %si, followed by a CRLF.

It was not noticed during tests because at that point %si points
to a partition entry whose first byte is 0x80, which is both a
terminator for the string and a non printable character.

Submitted by:	Christoph Mallon
2008-11-26 21:38:43 +00:00
Luigi Rizzo
54dd5ca200 Pass the pointer to the selected partition in %si to the next stage
boot code. The bug was introduced in rev.1.13, and went unnoticed
because FreeBSD's boot1 does not use it, but other systems might.

(I have been struggling for almost a full day trying to figure out
why a syslinux'ed partition would not boot when started with the
FreeBSD /boot/boot0, only to realize that the bug was ours!)

The space for the two extra bytes (push %si and pop %si) is reclaimed
by removing an extra CRLF that is printed before booting.

The bug is not a major one but if there is time it might be a good
thing to merge it into the upcoming releases.
2008-11-26 18:01:21 +00:00
Doug Rabson
ebd4055a33 Fix amd64 build and re-enable gptzfsboot. 2008-11-22 14:24:55 +00:00
Dag-Erling Smørgrav
265e36de8c Disconnect gptzfsboot from the build until dfr@ gets his act together. 2008-11-21 08:10:07 +00:00
Luigi Rizzo
ade303f361 As reported in kern/118222, pxeboot in RELENG7 (and presumably
above) exhibits some misbehaviours on machines with AMD64 CPUs,
which at least in some cases I have tracked down to a heap overflow.

It is unclear whether it depends on the CPU or on the pxe bios
itself which may use more memory on AMD machines.

Noticeably a pxeboot compiled from 6.x sources works fine on all
machines I have tried so far, while a pxeboot compiled from 7.x
sources does not.

This patch is a first step in reducing the amount of memory used
while processing the configuration files read by the loader at boot
(some of them are quite large, 1700+ lines), and it does so by:
+ moving a buffer to static memory instead of allocating in the heap;
+ skipping empty lines;
+ reducing the amount of memory used for line descriptors;

Unfortunately there are several changes between 6.x and above,
affecting the compiler, the loader code itself, and libstand,
and it is not so straightforward to
These changes fix the behaviour on one motherboard with a
single-core AMD cpu, but are still not enough e.g on an Asus
M2N-VM (with a dual-core CPU).

I need to investigate the problem a bit more before figuring
out what should be committed to RELENG_7

PR:		kern/118222
2008-11-20 14:57:09 +00:00
Rafal Jaworowski
11cdd0c0c2 Initial storage functionality for U-Boot support library.
- Only non-sliced bsdlabel style partitioning is currently supported (but provisions
  are made towards GPT support, which should follow soon)
- Enable storage support in loader on ARM

Obtained from:	Semihalf
2008-11-19 17:34:28 +00:00
Doug Rabson
0d16312b46 Some zfsboot fixes from Norikatsu Shigemura:
1. zfsboot2 (boot2) doesn't %d (printf), so change %d to %u.
2. chase new zpool versioning as SPA_VERSION.
   Obtained from: sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h

Submitted by:	nork
2008-11-19 16:59:19 +00:00