History log of /freebsd-10-stable/sys/boot/sparc64/loader/main.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 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

# 251589 09-Jun-2013 marius

- The method introduced as part of r234898 for not altering the boot path
when booting from ZFS turned out to also cause the boot path not being
adjusted if booting from CD-ROM with firmware versions that do not employ
the "cdrom" alias in that case. So shuffle the code around instead in order
to achieve the original intent. Ideally, we shouldn't fiddle with the boot
path when booting from UFS on a disk either; unfortunately, there doesn't
seem to be an universal way of telling disks and CD-ROMs apart, though. [1]
- Use NULL instead of 0 for pointers.

PR: 179289
MFC after: 1 week


# 245697 20-Jan-2013 avg

zfs/sparc64 boot: fix booting after r242230

arch_zfs_probe method is supposed to only probe for ZFS vdevs, but it can
not expect that ZFS data is in a ready state yet.
So, move some code from sparc64_zfs_probe to main to meet the constraints.

Reported by: Chris Ross <cross+freebsd@distal.com>
Tested by: Chris Ross <cross+freebsd@distal.com>
MFC after: 4 days


# 240335 11-Sep-2012 ae

Slightly reduce an overhead for the open() call in the zfsloader.
libstand(3) tries to detect file system in the predefined order,
but zfsloader usually is used for the booting from ZFS, and there is
no need to try detect several file system types for each open() call.


# 238851 27-Jul-2012 marius

Pull the tier-2 card and change the sparc64 ZFS loader to no longer probe
all diskN aliases for providers (which more or less corresponds to how the
x86 version behaves) but instead probe only those listed in the boot-device
OFW environment variable. This has the following advantages:
- avoids otherwise unavoidable OFW warnings about failures to open disks
for which aliases exist but no actual hardware is connected
- avoids issues due to different diskN naming schemes
- aligns us with Solaris

MFC after: 3 days


# 236581 04-Jun-2012 marius

The loaddev environment variable is not modifiable once set, so it is not
update for ZFS. It seems that this does not really affect anything except
the help command. Nevertheless, rearrange things so loaddev is set only
once in all cases in order to get it right.
Pointed out by: avg

MFC after: r235364


# 235364 12-May-2012 avg

sparc64/zfs boot: take advantage of new libzfsboot capabilities

Also drop the now unneeded compatibility shims.

Tested by: marius
MFC after: 1 month


# 235329 12-May-2012 avg

zfsboot/zfsloader: support accessing filesystems within a pool

In zfs loader zfs device name format now is "zfs:pool/fs",
fully qualified file path is "zfs:pool/fs:/path/to/file"
loader allows accessing files from various pools and filesystems as well
as changing currdev to a different pool/filesystem.

zfsboot accepts kernel/loader name in a format pool:fs:path/to/file or,
as before, pool:path/to/file; in the latter case a default filesystem
is used (pool root or bootfs). zfsboot passes guids of the selected
pool and dataset to zfsloader to be used as its defaults.

zfs support should be architecture independent and is provided
in a separate library, but architectures wishing to use this zfs support
still have to provide some glue code and their devdesc should be
compatible with zfs_devdesc.
arch_zfs_probe method is used to discover all disk devices that may
be part of ZFS pool(s).

libi386 unconditionally includes zfs support, but some zfs-specific
functions are stubbed out as weak symbols. The strong definitions
are provided in libzfsboot.
This change mean that the size of i386_devspec becomes larger
to match zfs_devspec.

Backward-compatibility shims are provided for recently added sparc64
zfs boot support. Currently that architecture still works the old
way and does not support the new features.

TODO:
- clear up pool root filesystem vs pool bootfs filesystem distinction
- update sparc64 support
- set vfs.root.mountfrom based on currdev (for zfs)

Mid-future TODO:
- loader sub-menu for selecting alternative boot environment

Distant future TODO:
- support accessing snapshots, using a snapshot as readonly root

Reviewed by: marius (sparc64),
Gavin Mu <gavin.mu@gmail.com> (sparc64)
Tested by: Florian Wagner <florian@wagner-flo.net> (x86),
marius (sparc64)
No objections: fs@, hackers@
MFC after: 1 month


# 235153 09-May-2012 avg

sys/boot: add common CTASSERT definition


# 234898 01-May-2012 marius

Add initial support for booting from ZFS on sparc64. At least on Sun Fire
V100, the firmware is known to be broken and not allowing to simultaneously
open disk devices, causing attempts to boot from a mirror or RAIDZ to cause
a crash. This will be worked around later. The firmwares of newer sun4u models
don't seem to exhibit this problem though.

Steps for ZFS booting:

1. create VTOC8 label
# gpart create -s vtoc8 da0

2. add partitions, f.e.:
# gpart add -t freebsd-zfs -s 60g da0
# gpart add -t freebsd-swap da0
resulting in something like:
# gpart show
=> 0 143331930 da0 VTOC8 (68G)
0 125821080 1 freebsd-zfs (60G)
125821080 17510850 2 freebsd-swap (8.4G)

3. create zpool
# zpool create bunker da0a
or for mirror/RAIDZ (after preparing additional disks as in steps 1. + 2.):
# zpool create bunker mirror da0a da1a
# zpool create bunker raidz da0a da1a da2a ...

4. set bootfs
# zpool set bootfs=bunker bunker

5. install zfsboot
# zpool export bunker
# gpart bootcode -p /boot/zfsboot da0

6. write zfsloader to the ZFS Boot Block (so far, there's no dedicated tool
for this, so dd(1) has to be used for this purpose)
When using mirror/RAIDZ, step 4. and the dd(1) invocation should be repeated
for the additional disks in order to be able to boot from another disk in
case of failure.
# sysctl kern.geom.debugflags=0x10
# dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc
# zpool import bunker

7. install system on ZFS filesystem
Don't forget to set 'zfs_load="YES"' and vfs.root.mountfrom="zfs:bunker" in
loader.conf as well as 'zfs_enable="YES"'in rc.conf.

8. copy zpool.cache to the ZFS filesystem
cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache

9. set mountpoint
# zfs set mountpoint=/ bunker

10. Now, given that aliases for all disks in the zpool exists (check with
the `devalias` command on the boot monitor prompt) and disk0 corresponds
to da0 (likewise for additional disks), the system can be booted from the
ZFS with:
{1} ok boot disk0

PR: 165025
Submitted by: Gavin Mu


# 234897 01-May-2012 marius

Add a command for showing the heap usage.

PR: 165025
Submitted by: Gavin Mu
MFC after: 1 week


# 223719 02-Jul-2011 marius

- For Cheetah- and Zeus-class CPUs don't flush all unlocked entries from
the TLBs in order to get rid of the user mappings but instead traverse
them an flush only the latter like we also do for the Spitfire-class.
Also flushing the unlocked kernel entries can cause instant faults which
when called from within cpu_switch() are handled with the scheduler lock
held which in turn can cause timeouts on the acquisition of the lock by
other CPUs. This was easily seen with a 16-core V890 but occasionally
also happened with 2-way machines.
While at it, move the SPARC64-V support code entirely to zeus.c. This
causes a little bit of duplication but is less confusing than partially
using Cheetah-class bits for these.
- For SPARC64-V ensure that 4-Mbyte page entries are stored in the 1024-
entry, 2-way set associative TLB.
- In {d,i}tlb_get_data_sun4u() turn off the interrupts in order to ensure
that ASI_{D,I}TLB_DATA_ACCESS_REG actually are read twice back-to-back.

Tested by: Peter Jeremy (16-core US-IV), Michael Moll (2-way SPARC64-V)


# 221869 14-May-2011 attilio

Disconnect sun4v architecture from the three.

Some files keep the SUN4V tags as a code reference, for the future,
if any rewamped sun4v support wants to be added again.

Reviewed by: marius
Tested by: sbruno
Approved by: re


# 220290 03-Apr-2011 marcel

Revert rev 165325. The arch_maphint interface hasn't been in use for
more than 4 years.


# 214526 29-Oct-2010 marius

Partially revert r203829; as it turns out what the PowerPC OFW loader did
was incorrect as further down the road cons_probe() calls malloc() so the
former can't be called before init_heap() has succeed. Instead just exit
to the firmware in case init_heap() fails like OF_init() does when hitting
a problem as we're then likely running in a very broken environment where
hardly anything can be trusted to work.


# 207537 02-May-2010 marius

Add support for SPARC64 V (and where it already makes sense for other
HAL/Fujitsu) CPUs. For the most part this consists of fleshing out the
MMU and cache handling, it doesn't add pmap optimizations possible with
these CPU, yet, though.
With these changes FreeBSD runs stable on Fujitsu Siemens PRIMEPOWER 250
and likely also other models based on SPARC64 V like 450, 650 and 850.
Thanks go to Michael Moll for providing access to a PRIMEPOWER 250.


# 204152 20-Feb-2010 marius

Some machines can not only consist of CPUs running at different speeds
but also of different types, f.e. Sun Fire V890 can be equipped with a
mix of UltraSPARC IV and IV+ CPUs, requiring different MMU initialization
and different workarounds for model specific errata. Therefore move the
CPU implementation number from a global variable to the per-CPU data.
Functions which are called before the latter is available are passed the
implementation number as a parameter now.


# 203831 13-Feb-2010 marius

Correct the panic strings introduced in r203830 to match their arguments.


# 203830 13-Feb-2010 marius

Use the SUNW,{d,i}tlb-load methods for entering locked TLB entries like
OpenBSD and OpenSolaris do instead of fiddling with the MMUs ourselves.
Unlike direct access the firmware methods don't automatically use the
next free (?) TLB slot, instead the slot to be used has to be specified.
We allocate the TLB slots for the kernel top-down as OpenSolaris suggests
that the firmware will always allocate the ones for its own use bottom-up.
Besides being simpler, according to OpenBSD using the firmware methods is
required to allow booting on Sun Fire E10K with multi-systemboard domains.


# 203829 13-Feb-2010 marius

- Assert that HEAPSZ is a multiple of PAGE_SIZE as at least the firmware
of Sun Fire V1280 doesn't round up the size itself but instead lets
claiming of non page-sized amounts of memory fail.
- Change parameters and variables related to the TLB slots to unsigned
which is more appropriate.
- Search the whole OFW device tree instead of only the children of the
root nexus device for the BSP as starting with UltraSPARC IV the 'cpu'
nodes hang off of from 'cmp' (chip multi-threading processor) or 'core'
or combinations thereof. Also in large UltraSPARC III based machines
the 'cpu' nodes hang off of 'ssm' (scalable shared memory) nodes which
group snooping-coherency domains together instead of directly from the
nexus.
- Add support for UltraSPARC IV and IV+ BSPs. Due to the fact that these
are multi-core each CPU has two Fireplane config registers and thus the
module/target ID has to be determined differently so the one specific
to a certain core is used. Similarly, starting with UltraSPARC IV the
individual cores use a different property in the OFW device tree to
indicate the CPU/core ID as it no longer is in coincidence with the
shared slot/socket ID.
While at it additionally distinguish between CPUs with Fireplane and
JBus interconnects as these also use slightly different sizes for the
JBus/agent/module/target IDs.
- Check the return value of init_heap(). This requires moving it after
cons_probe() so we can panic when appropriate. This should be fine as
the PowerPC OFW loader uses that order for quite some time now.


# 200946 24-Dec-2009 marius

Execute the cleanup handlers before jumping to the kernel just
like the other architectures do.


# 200944 24-Dec-2009 marius

Revert r183628 as with the current ata(4) ATAPI DMA with AcerLabs
M5229 appears to be once again fixed. If this happens to return
we probably should disable ATAPI DMA in ataacerlabs(4) instead
just like the Linux libATA does.


# 191071 14-Apr-2009 marius

Fix masking of TTE bits; the TD_*_MASK macros need shifting via the
corresponding TD_*_SHIFT.

MFC after: 3 days


# 191012 13-Apr-2009 marius

Fix whitespace.


# 188455 10-Feb-2009 marius

- 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[].


# 183628 05-Oct-2008 marius

Disable ATAPI DMA as it's once again broken in that it causes data
corruption with the on-board AcerLabs M5229 controllers. While at
it, remove the pointless "nothing to autoload yet." message.

MFC after: 3 days


# 182916 10-Sep-2008 marius

Work around Cheetah+ erratum 34 (USIII+ erratum #10) by relocating
the locked entry in it16 slot 0, which typically is occupied by the
PROM, and manually entering locked entries in slots != 0.

Thanks to Hubert Feyrer for donating the Blade 2000 this change was
developed on.


# 182877 08-Sep-2008 marius

USIII and beyond CPUs have stricter requirements when it comes
to synchronization needed after stores to internal ASIs in order
to make side-effects visible. This mainly requires the MEMBAR #Sync
after such stores to be replaced with a FLUSH. We use KERNBASE as
the address to FLUSH as it is guaranteed to not trap. Actually,
the USII synchronization rules also already require a FLUSH in
pretty much all of the cases changed.
We're also hitting an additional USIII synchronization rule which
requires stores to AA_IMMU_SFSR to be immediately followed by a DONE,
FLUSH or RETRY. Doing so triggers a RED state exception though so
leave the MEMBAR #Sync. Linux apparently also has gotten away with
doing the same for quite some time now, apart from the fact that
it's not clear to me why we need to clear the valid bit from the
SFSR in the first place.

Reviewed by: nwhitehorn


# 182766 04-Sep-2008 marius

Ensure interrupts are off while in {d,i}tlb_va_to_pa_sun4u().
I think this is necessary in order to make sure the workarounds
in {d,i}tlb_get_data_sun4u() work correctly.


# 182478 30-Aug-2008 marius

- Read ASI_{D,I}TLB_DATA_ACCESS_REG twice in order to work around
errata of USIII and beyond (USIII erratum #19, USIII+ erratum #1,
USIIIi erratum #1).
- Use the cheetah PA mask in {d,i}tlb_va_to_pa_sun4u() for USIII
and beyond. This is done so that these functions will still mask
the debug bits of spitfire-class CPUs once we increase TD_PA_BITS
to match the number of bits used for the PA by cheetah-class CPUs.
- Change {d,i}tlb_enter_sun4u() to also set TLB_CTX_KERNEL as the
context of the mappings entered. This is more or less cosmetic as
TLB_CTX_KERNEL is 0.
- Now that we have to distinguish between different sun4u CPUs in
the loader anyway, no longer do trial and error when reading the
portid property.


# 182020 22-Aug-2008 marius

cosmetic changes and style fixes


# 181398 07-Aug-2008 marius

- Reimplement {d,i}tlb_enter() and {d,i}tlb_va_to_pa() in C. There's
no particular reason for them to be implemented in assembler and
having them in C allows easier extension as well as using more C
macros and {d,i}tlb_slot_max rather than hard-coding magic (and
actually spitfire-only) values.
- Fix the compilation of pmap_print_tte().
- Change pmap_print_tlb() to use ldxa() rather than re-rolling it
inline as well as TLB_DAR_SLOT and {d,i}tlb_slot_max rather than
hardcoding magic (and actually spitfire-only) values.
- While at it, suffix the above mentioned functions with "_sun4u" to
underline they're architecture-specific.
- Use __FBSDID and macros instead of magic values in locore.S.
- Remove unused includes and smp_stack in locore.S.


# 170854 16-Jun-2007 marius

- Make better use of the global chosen, memory and mmu handles instead
of obtaining them over and over again and pretending we could do
anything useful without them (for chosen this includes adding a
declaration and initializing it in OF_init()).
- In OF_init() if obtaining the memory or mmu handle fails just call
OF_exit() instead of panic() as the loader hasn't initialized the
console at these early stages yet and trying to print out something
causes a hang. With OF_exit() one at least has a change to get back
to the OFW boot monitor and debug the problem.
- Fix OF_call_method() on 64-bit machines (this is a merge of
sys/dev/ofw/openfirm.c rev 1.6).
- Replace OF_alloc_phys(), OF_claim_virt(), OF_map_phys() and
OF_release_phys() in the MI part of the loader with wrappers around
OF_call_method() in the sparc64. Beside the fact that they duplicate
OF_call_method() the formers should never have been in the MI part
of the loader as contrary to the OFW spec they use two-cell physical
addresses.
- Remove unused functions which are also MD dupes of OF_call_method().
- In sys/boot/sparc64/loader/main.c add __func__ to panic strings as
different functions use otherwise identical panic strings and make
some of the panic strings a tad more user-friendly instead of just
mentioning the name of the function that returned an unexpected
result.


# 170839 16-Jun-2007 marius

- Remove dupe and unused declarations and prototypes.
- Add missing prototypes.
- Define global variables not used outside of this module as static.
- Replace some outdated hard-coded functions names in panic strings
with __func__.
- Fix some style(9) bugs.


# 165325 18-Dec-2006 kmacy

add an interface for passing the entire kernel size up front to the
loader so that it can memory can be allocated aligned at the beginning of
the desired large page


# 163893 01-Nov-2006 marcel

Don't unconditionally compile-in the bcache code. It's only used on
i386/amd64 and pc98. Remove useless calls to bcache_init() from the
ia64 and sparc64 loaders, as well as from the OFW common code.


# 163151 09-Oct-2006 kmacy

unbreak sparc64 loader build
re-add accidentally deleted asi value
remove sun4v only header include

Approved by: rwatson (mentor)
Reviewed by: jmg


# 163145 09-Oct-2006 kmacy

add sun4v support to the sparc64 boot loader

Approved by: rwatson (mentor)
Reviewed by: jmg
Tested by: kris, dwhite, and jmg


# 139738 05-Jan-2005 imp

Start each of the license/copyright comments with /*-


# 134944 08-Sep-2004 kensmith

Back out v1.24. v1.40 of sys/sparc64/sparc64/bus_machdep.c fixes the
problem this hack was put in place for.

MFC to be done if the fix to bus_machdep.c is MFC-ed.


# 134039 19-Aug-2004 kensmith

Temporary bandaid to help sparc64 systems with ATA disks boot. Recent
changes to the ATA driver cause a kernel crash, no fault of the ATA
code. Work is in progress to add the necessary feature to the sparc64
kernel and this commit will be backed out when it is complete. This
bandaid is being put in mostly in the interests of getting the first
release snapshot done and out the door.

Tested on: Ultra-10 exhibiting the insta-panic.
MFC: Real Soon


# 133862 16-Aug-2004 marius

Instead of "OpenFirmware", "openfirmware", etc. use the official spelling
"Open Firmware" from IEEE 1275 and OpenFirmware.org (no pun intended).

Ok'ed by: tmm


# 124139 04-Jan-2004 obrien

Convert to __FBSDID.


# 117448 11-Jul-2003 tmm

NFS support should be conditional on LOADER_NFS_SUPPORT, not
LOADER_NET_SUPPORT.


# 116415 15-Jun-2003 jake

Remember to release the loader's heap.

Reviewed by: tmm


# 114386 01-May-2003 peter

Commit a missed change to keep in sync with the MI elf loader.


# 108100 19-Dec-2002 jake

Renamed the loader's zipfs to gzipfs. zipfs.c was repo-copied to gzipfs.c.


# 106738 10-Nov-2002 jake

Change the device path representation in libofw to use the full firmware
path, instead of an internal i386 specific one. Don't try to interpret
a disklabel in ofw_disk.c, open the partition's device node directly and
let the firmware do it. This fixes booting from a partition other than 'a'
on sparc64, which is needed to support more installation methods.

No objection: ppc


# 105065 13-Oct-2002 jake

Compile in support for zipfs and bzipfs so we can load the gzipped mfsroot
that releases use.


# 102226 21-Aug-2002 robert

- Do not pretend to compile a kernel and remove the definition
of the _KERNEL macro.
- Do not include <sys/pcpu.h> for no reason.

Suggested by: jake


# 102219 21-Aug-2002 robert

- Define the macro _KERNEL to pretend we are compiling a kernel.
This is required by recent changes to <sys/pcpu.h>, which uses
the #error preprocessor directive to keep non-kernel
applications from using it.
_KERNEL is defined below the #include <stand.h>, because <stand.h>
removes the definition of _KERNEL.
- Move the inclusion of <sys/queue.h> above the inclusion of
<sys/linker.h> to avoid syntax errors.


# 101287 03-Aug-2002 jake

Print out the strings in vers.o instead of hardcoding the loader banner.


# 97510 29-May-2002 jake

Add needed include of queue.h. Remove unneeded include of smp.h.


# 97445 29-May-2002 jake

Use a contrived 'tlb_entry' structure for passing the mappings for the
kernel text and data from the loader to the kernel, so that the tte format
is not part of the loader->kernel ABI.


# 96755 16-May-2002 trhodes

More s/file system/filesystem/g


# 96428 11-May-2002 jake

Attempt to not crash and burn on UltraSPARC III machines; the cpuid property
is named differently.


# 93678 02-Apr-2002 tmm

Do not use semi-fixed TLB slots for the 4M kernel pages any more.


# 93606 01-Apr-2002 tmm

Add support for booting from CD-ROM. Make it possible to enable UFS
support using make arguments.


# 91519 01-Mar-2002 jake

Catch up to change in tte format.

Forgetten by: jake
Submitted by: tmm


# 91139 23-Feb-2002 jake

Keep track of the ttes used to map the kernel and pass them to it as loader
metadata. Modify tlb handling functions to take a tte, instead of virtual
address, physical address and flags.


# 91110 23-Feb-2002 jake

Fix fs support ifdefs. Add tftp support. Add physical and virtual
watchpoint support for debugging (under LOADER_DEBUG). Claim the
physical and virtual addresses used to map the kernel from the prom;
we map it ourselves behind the scenes though. Add a reboot command.

Submitted by: tmm


# 85719 30-Oct-2001 jake

Add definitions for network support, doesn't work yet.
Pass the right arguments to the kernel.
Replace magic numbers with symbolic constants.
Pass the real openfirmware entry point to OF_init.


# 84997 15-Oct-2001 robert

Fix some warnings.


# 84996 15-Oct-2001 robert

Add the FreeBSD/sparc64 boot loader source files.