diff mbox series

[U-Boot,1/2] distro_bootcmd: Add command to run FreeBSD

Message ID 20171204190617.13976-1-manu@bidouilliste.com
State Deferred
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/2] distro_bootcmd: Add command to run FreeBSD | expand

Commit Message

Emmanuel Vadot Dec. 4, 2017, 7:06 p.m. UTC
Add commands that scans for the FreeBSD loader and run it if found.
FreeBSD has two loader: ubldr which is an ELF binary and ubldr.bin which
is a PIE binary.

Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
---
 include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

Heinrich Schuchardt Dec. 4, 2017, 7:18 p.m. UTC | #1
On 12/04/2017 08:06 PM, Emmanuel Vadot wrote:
> Add commands that scans for the FreeBSD loader and run it if found.
> FreeBSD has two loader: ubldr which is an ELF binary and ubldr.bin which
> is a PIE binary.
> 
> Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> ---
>  include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> index 5c469a23fa..424d63a355 100644
> --- a/include/config_distro_bootcmd.h
> +++ b/include/config_distro_bootcmd.h
> @@ -158,6 +158,36 @@
>  #define SCAN_DEV_FOR_EFI
>  #endif
>  
> +#ifdef CONFIG_DISTRO_FREEBSD
> +#define BOOTENV_SHARED_FREEBSD                                            \
> +	"boot_freebsd_binary="                                            \
> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> +			"${kernel_addr_r} ubldr.bin; "                    \
> +		"go ${kernel_addr_r}\0"                                   \
> +	\
> +	"boot_freebsd_elf="                                               \
> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> +			"${kernel_addr_r} ubldr; "                        \
> +		"bootelf ${kernel_addr_r}\0"                              \
> +	\
> +	"scan_dev_for_freebsd="                                           \
> +		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
> +					"ubldr.bin; then "                \

Your commit message does not provide any reason why you need this.

Couldn't you simply create a boot.scr that invokes ubldr.bin or ubldr as
other distros do?

E.g. Debian has a package flash-boot which generates a new boot.scr
every time a new kernel is installed.

Best

> +				"echo Found FreeBSD U-Boot Loader (bin);" \
> +				"run boot_freebsd_binary; "               \
> +				"echo FREEBSD FAILED: continuing...; "    \
> +		"elif test -e ${devtype} ${devnum}:${distro_bootpart} "   \
> +					"ubldr; then "                    \
> +				"echo Found FreeBSD U-Boot Loader (elf);" \
> +				"run boot_freebsd_elf; "                  \
> +				"echo FREEBSD FAILED: continuing...; "    \
> +		"fi;\0"
> +#define SCAN_DEV_FOR_FREEBSD "run scan_dev_for_freebsd;"
> +#else
> +#define BOOTENV_SHARED_FREEBSD
> +#define SCAN_DEV_FOR_FREEBSD
> +#endif
> +
>  #ifdef CONFIG_SATA
>  #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
>  #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
> @@ -331,6 +361,7 @@
>  	BOOTENV_SHARED_IDE \
>  	BOOTENV_SHARED_UBIFS \
>  	BOOTENV_SHARED_EFI \
> +	BOOTENV_SHARED_FREEBSD \
>  	"boot_prefixes=/ /boot/\0" \
>  	"boot_scripts=boot.scr.uimg boot.scr\0" \
>  	"boot_script_dhcp=boot.scr.uimg\0" \
> @@ -374,6 +405,7 @@
>  			"run scan_dev_for_scripts; "                      \
>  		"done;"                                                   \
>  		SCAN_DEV_FOR_EFI                                          \
> +		SCAN_DEV_FOR_FREEBSD                                      \
>  		"\0"                                                      \
>  	\
>  	"scan_dev_for_boot_part="                                         \
>
Emmanuel Vadot Dec. 12, 2017, 9:03 a.m. UTC | #2
Hi Heinrich,

On Mon, 4 Dec 2017 20:18:22 +0100
Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:

> On 12/04/2017 08:06 PM, Emmanuel Vadot wrote:
> > Add commands that scans for the FreeBSD loader and run it if found.
> > FreeBSD has two loader: ubldr which is an ELF binary and ubldr.bin which
> > is a PIE binary.
> > 
> > Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> > ---
> >  include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
> >  1 file changed, 32 insertions(+)
> > 
> > diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> > index 5c469a23fa..424d63a355 100644
> > --- a/include/config_distro_bootcmd.h
> > +++ b/include/config_distro_bootcmd.h
> > @@ -158,6 +158,36 @@
> >  #define SCAN_DEV_FOR_EFI
> >  #endif
> >  
> > +#ifdef CONFIG_DISTRO_FREEBSD
> > +#define BOOTENV_SHARED_FREEBSD                                            \
> > +	"boot_freebsd_binary="                                            \
> > +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> > +			"${kernel_addr_r} ubldr.bin; "                    \
> > +		"go ${kernel_addr_r}\0"                                   \
> > +	\
> > +	"boot_freebsd_elf="                                               \
> > +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> > +			"${kernel_addr_r} ubldr; "                        \
> > +		"bootelf ${kernel_addr_r}\0"                              \
> > +	\
> > +	"scan_dev_for_freebsd="                                           \
> > +		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
> > +					"ubldr.bin; then "                \
> 
> Your commit message does not provide any reason why you need this.
> 
> Couldn't you simply create a boot.scr that invokes ubldr.bin or ubldr as
> other distros do?
> 
> E.g. Debian has a package flash-boot which generates a new boot.scr
> every time a new kernel is installed.
> 
> Best

 The answer is really easy, for FreeBSD 11 (our actual stable release)
we still use ubldr.bin/ubldr but for FreeBSD 12 (our current HEAD) we
want to switch to EFI (almost there). Our ports tree/packages are
common to both releases and using boot.scr would mean to re-implement
the distroboot logic in it.

 I'll resend a V2 explaining this better in the commit message.

> > +				"echo Found FreeBSD U-Boot Loader (bin);" \
> > +				"run boot_freebsd_binary; "               \
> > +				"echo FREEBSD FAILED: continuing...; "    \
> > +		"elif test -e ${devtype} ${devnum}:${distro_bootpart} "   \
> > +					"ubldr; then "                    \
> > +				"echo Found FreeBSD U-Boot Loader (elf);" \
> > +				"run boot_freebsd_elf; "                  \
> > +				"echo FREEBSD FAILED: continuing...; "    \
> > +		"fi;\0"
> > +#define SCAN_DEV_FOR_FREEBSD "run scan_dev_for_freebsd;"
> > +#else
> > +#define BOOTENV_SHARED_FREEBSD
> > +#define SCAN_DEV_FOR_FREEBSD
> > +#endif
> > +
> >  #ifdef CONFIG_SATA
> >  #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
> >  #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
> > @@ -331,6 +361,7 @@
> >  	BOOTENV_SHARED_IDE \
> >  	BOOTENV_SHARED_UBIFS \
> >  	BOOTENV_SHARED_EFI \
> > +	BOOTENV_SHARED_FREEBSD \
> >  	"boot_prefixes=/ /boot/\0" \
> >  	"boot_scripts=boot.scr.uimg boot.scr\0" \
> >  	"boot_script_dhcp=boot.scr.uimg\0" \
> > @@ -374,6 +405,7 @@
> >  			"run scan_dev_for_scripts; "                      \
> >  		"done;"                                                   \
> >  		SCAN_DEV_FOR_EFI                                          \
> > +		SCAN_DEV_FOR_FREEBSD                                      \
> >  		"\0"                                                      \
> >  	\
> >  	"scan_dev_for_boot_part="                                         \
> >
Heinrich Schuchardt Dec. 12, 2017, 7:29 p.m. UTC | #3
On 12/12/2017 10:03 AM, Emmanuel Vadot wrote:
> 
>  Hi Heinrich,
> 
> On Mon, 4 Dec 2017 20:18:22 +0100
> Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> 
>> On 12/04/2017 08:06 PM, Emmanuel Vadot wrote:
>>> Add commands that scans for the FreeBSD loader and run it if found.
>>> FreeBSD has two loader: ubldr which is an ELF binary and ubldr.bin which
>>> is a PIE binary.
>>>
>>> Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
>>> ---
>>>  include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
>>>  1 file changed, 32 insertions(+)
>>>
>>> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
>>> index 5c469a23fa..424d63a355 100644
>>> --- a/include/config_distro_bootcmd.h
>>> +++ b/include/config_distro_bootcmd.h
>>> @@ -158,6 +158,36 @@
>>>  #define SCAN_DEV_FOR_EFI
>>>  #endif
>>>  
>>> +#ifdef CONFIG_DISTRO_FREEBSD
>>> +#define BOOTENV_SHARED_FREEBSD                                            \
>>> +	"boot_freebsd_binary="                                            \
>>> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
>>> +			"${kernel_addr_r} ubldr.bin; "                    \
>>> +		"go ${kernel_addr_r}\0"                                   \
>>> +	\
>>> +	"boot_freebsd_elf="                                               \
>>> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
>>> +			"${kernel_addr_r} ubldr; "                        \
>>> +		"bootelf ${kernel_addr_r}\0"                              \
>>> +	\
>>> +	"scan_dev_for_freebsd="                                           \
>>> +		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
>>> +					"ubldr.bin; then "                \
>>
>> Your commit message does not provide any reason why you need this.
>>
>> Couldn't you simply create a boot.scr that invokes ubldr.bin or ubldr as
>> other distros do?
>>
>> E.g. Debian has a package flash-boot which generates a new boot.scr
>> every time a new kernel is installed.
>>
>> Best
> 
>  The answer is really easy, for FreeBSD 11 (our actual stable release)
> we still use ubldr.bin/ubldr but for FreeBSD 12 (our current HEAD) we
> want to switch to EFI (almost there). Our ports tree/packages are
> common to both releases and using boot.scr would mean to re-implement
> the distroboot logic in it.
> 

Why should U-Boot implement any distro specific logic which could be
implemented with in the distro itself?

My feeling is that U-Boot should be distro agnostic. It shall implement
standards and load any conforming distro.

Best regards

Heinrich

>  I'll resend a V2 explaining this better in the commit message.
> 
>>> +				"echo Found FreeBSD U-Boot Loader (bin);" \
>>> +				"run boot_freebsd_binary; "               \
>>> +				"echo FREEBSD FAILED: continuing...; "    \
>>> +		"elif test -e ${devtype} ${devnum}:${distro_bootpart} "   \
>>> +					"ubldr; then "                    \
>>> +				"echo Found FreeBSD U-Boot Loader (elf);" \
>>> +				"run boot_freebsd_elf; "                  \
>>> +				"echo FREEBSD FAILED: continuing...; "    \
>>> +		"fi;\0"
>>> +#define SCAN_DEV_FOR_FREEBSD "run scan_dev_for_freebsd;"
>>> +#else
>>> +#define BOOTENV_SHARED_FREEBSD
>>> +#define SCAN_DEV_FOR_FREEBSD
>>> +#endif
>>> +
>>>  #ifdef CONFIG_SATA
>>>  #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
>>>  #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
>>> @@ -331,6 +361,7 @@
>>>  	BOOTENV_SHARED_IDE \
>>>  	BOOTENV_SHARED_UBIFS \
>>>  	BOOTENV_SHARED_EFI \
>>> +	BOOTENV_SHARED_FREEBSD \
>>>  	"boot_prefixes=/ /boot/\0" \
>>>  	"boot_scripts=boot.scr.uimg boot.scr\0" \
>>>  	"boot_script_dhcp=boot.scr.uimg\0" \
>>> @@ -374,6 +405,7 @@
>>>  			"run scan_dev_for_scripts; "                      \
>>>  		"done;"                                                   \
>>>  		SCAN_DEV_FOR_EFI                                          \
>>> +		SCAN_DEV_FOR_FREEBSD                                      \
>>>  		"\0"                                                      \
>>>  	\
>>>  	"scan_dev_for_boot_part="                                         \
>>>
> 
>
Emmanuel Vadot Dec. 12, 2017, 8 p.m. UTC | #4
On Tue, 12 Dec 2017 20:29:42 +0100
Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:

> On 12/12/2017 10:03 AM, Emmanuel Vadot wrote:
> > 
> >  Hi Heinrich,
> > 
> > On Mon, 4 Dec 2017 20:18:22 +0100
> > Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> > 
> >> On 12/04/2017 08:06 PM, Emmanuel Vadot wrote:
> >>> Add commands that scans for the FreeBSD loader and run it if found.
> >>> FreeBSD has two loader: ubldr which is an ELF binary and ubldr.bin which
> >>> is a PIE binary.
> >>>
> >>> Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
> >>> ---
> >>>  include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
> >>>  1 file changed, 32 insertions(+)
> >>>
> >>> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> >>> index 5c469a23fa..424d63a355 100644
> >>> --- a/include/config_distro_bootcmd.h
> >>> +++ b/include/config_distro_bootcmd.h
> >>> @@ -158,6 +158,36 @@
> >>>  #define SCAN_DEV_FOR_EFI
> >>>  #endif
> >>>  
> >>> +#ifdef CONFIG_DISTRO_FREEBSD
> >>> +#define BOOTENV_SHARED_FREEBSD                                            \
> >>> +	"boot_freebsd_binary="                                            \
> >>> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> >>> +			"${kernel_addr_r} ubldr.bin; "                    \
> >>> +		"go ${kernel_addr_r}\0"                                   \
> >>> +	\
> >>> +	"boot_freebsd_elf="                                               \
> >>> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
> >>> +			"${kernel_addr_r} ubldr; "                        \
> >>> +		"bootelf ${kernel_addr_r}\0"                              \
> >>> +	\
> >>> +	"scan_dev_for_freebsd="                                           \
> >>> +		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
> >>> +					"ubldr.bin; then "                \
> >>
> >> Your commit message does not provide any reason why you need this.
> >>
> >> Couldn't you simply create a boot.scr that invokes ubldr.bin or ubldr as
> >> other distros do?
> >>
> >> E.g. Debian has a package flash-boot which generates a new boot.scr
> >> every time a new kernel is installed.
> >>
> >> Best
> > 
> >  The answer is really easy, for FreeBSD 11 (our actual stable release)
> > we still use ubldr.bin/ubldr but for FreeBSD 12 (our current HEAD) we
> > want to switch to EFI (almost there). Our ports tree/packages are
> > common to both releases and using boot.scr would mean to re-implement
> > the distroboot logic in it.
> > 
> 
> Why should U-Boot implement any distro specific logic which could be
> implemented with in the distro itself?
> 
> My feeling is that U-Boot should be distro agnostic. It shall implement
> standards and load any conforming distro.
> 
> Best regards
> 
> Heinrich

 I was under the impression that u-boot will automatically load a linux
kernel but it seems that I'm wrong. If that's the case yes this patch
can be dropped and I'll deal with the issue locally for FreeBSD.

> >  I'll resend a V2 explaining this better in the commit message.
> > 
> >>> +				"echo Found FreeBSD U-Boot Loader (bin);" \
> >>> +				"run boot_freebsd_binary; "               \
> >>> +				"echo FREEBSD FAILED: continuing...; "    \
> >>> +		"elif test -e ${devtype} ${devnum}:${distro_bootpart} "   \
> >>> +					"ubldr; then "                    \
> >>> +				"echo Found FreeBSD U-Boot Loader (elf);" \
> >>> +				"run boot_freebsd_elf; "                  \
> >>> +				"echo FREEBSD FAILED: continuing...; "    \
> >>> +		"fi;\0"
> >>> +#define SCAN_DEV_FOR_FREEBSD "run scan_dev_for_freebsd;"
> >>> +#else
> >>> +#define BOOTENV_SHARED_FREEBSD
> >>> +#define SCAN_DEV_FOR_FREEBSD
> >>> +#endif
> >>> +
> >>>  #ifdef CONFIG_SATA
> >>>  #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
> >>>  #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
> >>> @@ -331,6 +361,7 @@
> >>>  	BOOTENV_SHARED_IDE \
> >>>  	BOOTENV_SHARED_UBIFS \
> >>>  	BOOTENV_SHARED_EFI \
> >>> +	BOOTENV_SHARED_FREEBSD \
> >>>  	"boot_prefixes=/ /boot/\0" \
> >>>  	"boot_scripts=boot.scr.uimg boot.scr\0" \
> >>>  	"boot_script_dhcp=boot.scr.uimg\0" \
> >>> @@ -374,6 +405,7 @@
> >>>  			"run scan_dev_for_scripts; "                      \
> >>>  		"done;"                                                   \
> >>>  		SCAN_DEV_FOR_EFI                                          \
> >>> +		SCAN_DEV_FOR_FREEBSD                                      \
> >>>  		"\0"                                                      \
> >>>  	\
> >>>  	"scan_dev_for_boot_part="                                         \
> >>>
> > 
> > 
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Heinrich Schuchardt Dec. 12, 2017, 10:53 p.m. UTC | #5
On 12/12/2017 09:00 PM, Emmanuel Vadot wrote:
> On Tue, 12 Dec 2017 20:29:42 +0100
> Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> 
>> On 12/12/2017 10:03 AM, Emmanuel Vadot wrote:
>>>
>>>  Hi Heinrich,
>>>
>>> On Mon, 4 Dec 2017 20:18:22 +0100
>>> Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>>
>>>> On 12/04/2017 08:06 PM, Emmanuel Vadot wrote:
>>>>> Add commands that scans for the FreeBSD loader and run it if found.
>>>>> FreeBSD has two loader: ubldr which is an ELF binary and ubldr.bin which
>>>>> is a PIE binary.
>>>>>
>>>>> Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
>>>>> ---
>>>>>  include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
>>>>>  1 file changed, 32 insertions(+)
>>>>>
>>>>> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
>>>>> index 5c469a23fa..424d63a355 100644
>>>>> --- a/include/config_distro_bootcmd.h
>>>>> +++ b/include/config_distro_bootcmd.h
>>>>> @@ -158,6 +158,36 @@
>>>>>  #define SCAN_DEV_FOR_EFI
>>>>>  #endif
>>>>>  
>>>>> +#ifdef CONFIG_DISTRO_FREEBSD
>>>>> +#define BOOTENV_SHARED_FREEBSD                                            \
>>>>> +	"boot_freebsd_binary="                                            \
>>>>> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
>>>>> +			"${kernel_addr_r} ubldr.bin; "                    \
>>>>> +		"go ${kernel_addr_r}\0"                                   \
>>>>> +	\
>>>>> +	"boot_freebsd_elf="                                               \
>>>>> +		"load ${devtype} ${devnum}:${distro_bootpart} "           \
>>>>> +			"${kernel_addr_r} ubldr; "                        \
>>>>> +		"bootelf ${kernel_addr_r}\0"                              \
>>>>> +	\
>>>>> +	"scan_dev_for_freebsd="                                           \
>>>>> +		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
>>>>> +					"ubldr.bin; then "                \
>>>>
>>>> Your commit message does not provide any reason why you need this.
>>>>
>>>> Couldn't you simply create a boot.scr that invokes ubldr.bin or ubldr as
>>>> other distros do?
>>>>
>>>> E.g. Debian has a package flash-boot which generates a new boot.scr
>>>> every time a new kernel is installed.
>>>>
>>>> Best
>>>
>>>  The answer is really easy, for FreeBSD 11 (our actual stable release)
>>> we still use ubldr.bin/ubldr but for FreeBSD 12 (our current HEAD) we
>>> want to switch to EFI (almost there). Our ports tree/packages are
>>> common to both releases and using boot.scr would mean to re-implement
>>> the distroboot logic in it.
>>>
>>
>> Why should U-Boot implement any distro specific logic which could be
>> implemented with in the distro itself?
>>
>> My feeling is that U-Boot should be distro agnostic. It shall implement
>> standards and load any conforming distro.
>>
>> Best regards
>>
>> Heinrich
> 
>  I was under the impression that u-boot will automatically load a linux
> kernel but it seems that I'm wrong. If that's the case yes this patch
> can be dropped and I'll deal with the issue locally for FreeBSD.

https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ and
U-Boot's /doc/README.distro describe how Linux or any other distro can
be booted.

Unfortunately not all systems supported by U-Boot can be built with
CONFIG_DISTRO_DEFAULTS.

doc/README.efi describes the EFI boot support.

Rob Clark recently contributed
https://lists.denx.de/pipermail/u-boot/2017-September/305211.html

Unfortunately the boot manager is not yet described in a README.
So we only have the online help:

bootmgr [fdt addr]
  - load and boot EFI payload based on BootOrder/BootXXXX variables.

This refers to EFI variable that can be set by an EFI application.
Currently the variables cannot be persisted so bootmgr is not really usable.

Regards

Heinrich

> 
>>>  I'll resend a V2 explaining this better in the commit message.
>>>
>>>>> +				"echo Found FreeBSD U-Boot Loader (bin);" \
>>>>> +				"run boot_freebsd_binary; "               \
>>>>> +				"echo FREEBSD FAILED: continuing...; "    \
>>>>> +		"elif test -e ${devtype} ${devnum}:${distro_bootpart} "   \
>>>>> +					"ubldr; then "                    \
>>>>> +				"echo Found FreeBSD U-Boot Loader (elf);" \
>>>>> +				"run boot_freebsd_elf; "                  \
>>>>> +				"echo FREEBSD FAILED: continuing...; "    \
>>>>> +		"fi;\0"
>>>>> +#define SCAN_DEV_FOR_FREEBSD "run scan_dev_for_freebsd;"
>>>>> +#else
>>>>> +#define BOOTENV_SHARED_FREEBSD
>>>>> +#define SCAN_DEV_FOR_FREEBSD
>>>>> +#endif
>>>>> +
>>>>>  #ifdef CONFIG_SATA
>>>>>  #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
>>>>>  #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
>>>>> @@ -331,6 +361,7 @@
>>>>>  	BOOTENV_SHARED_IDE \
>>>>>  	BOOTENV_SHARED_UBIFS \
>>>>>  	BOOTENV_SHARED_EFI \
>>>>> +	BOOTENV_SHARED_FREEBSD \
>>>>>  	"boot_prefixes=/ /boot/\0" \
>>>>>  	"boot_scripts=boot.scr.uimg boot.scr\0" \
>>>>>  	"boot_script_dhcp=boot.scr.uimg\0" \
>>>>> @@ -374,6 +405,7 @@
>>>>>  			"run scan_dev_for_scripts; "                      \
>>>>>  		"done;"                                                   \
>>>>>  		SCAN_DEV_FOR_EFI                                          \
>>>>> +		SCAN_DEV_FOR_FREEBSD                                      \
>>>>>  		"\0"                                                      \
>>>>>  	\
>>>>>  	"scan_dev_for_boot_part="                                         \
>>>>>
>>>
>>>
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot@lists.denx.de
>> https://lists.denx.de/listinfo/u-boot
> 
>
diff mbox series

Patch

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 5c469a23fa..424d63a355 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -158,6 +158,36 @@ 
 #define SCAN_DEV_FOR_EFI
 #endif
 
+#ifdef CONFIG_DISTRO_FREEBSD
+#define BOOTENV_SHARED_FREEBSD                                            \
+	"boot_freebsd_binary="                                            \
+		"load ${devtype} ${devnum}:${distro_bootpart} "           \
+			"${kernel_addr_r} ubldr.bin; "                    \
+		"go ${kernel_addr_r}\0"                                   \
+	\
+	"boot_freebsd_elf="                                               \
+		"load ${devtype} ${devnum}:${distro_bootpart} "           \
+			"${kernel_addr_r} ubldr; "                        \
+		"bootelf ${kernel_addr_r}\0"                              \
+	\
+	"scan_dev_for_freebsd="                                           \
+		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
+					"ubldr.bin; then "                \
+				"echo Found FreeBSD U-Boot Loader (bin);" \
+				"run boot_freebsd_binary; "               \
+				"echo FREEBSD FAILED: continuing...; "    \
+		"elif test -e ${devtype} ${devnum}:${distro_bootpart} "   \
+					"ubldr; then "                    \
+				"echo Found FreeBSD U-Boot Loader (elf);" \
+				"run boot_freebsd_elf; "                  \
+				"echo FREEBSD FAILED: continuing...; "    \
+		"fi;\0"
+#define SCAN_DEV_FOR_FREEBSD "run scan_dev_for_freebsd;"
+#else
+#define BOOTENV_SHARED_FREEBSD
+#define SCAN_DEV_FOR_FREEBSD
+#endif
+
 #ifdef CONFIG_SATA
 #define BOOTENV_SHARED_SATA	BOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA	BOOTENV_DEV_BLKDEV
@@ -331,6 +361,7 @@ 
 	BOOTENV_SHARED_IDE \
 	BOOTENV_SHARED_UBIFS \
 	BOOTENV_SHARED_EFI \
+	BOOTENV_SHARED_FREEBSD \
 	"boot_prefixes=/ /boot/\0" \
 	"boot_scripts=boot.scr.uimg boot.scr\0" \
 	"boot_script_dhcp=boot.scr.uimg\0" \
@@ -374,6 +405,7 @@ 
 			"run scan_dev_for_scripts; "                      \
 		"done;"                                                   \
 		SCAN_DEV_FOR_EFI                                          \
+		SCAN_DEV_FOR_FREEBSD                                      \
 		"\0"                                                      \
 	\
 	"scan_dev_for_boot_part="                                         \