Add FreeBSD kconfig options
v4 cover Add FreeBSD kconfig options
This series of patches add the needed bits for booting the FreeBSD loader and kernel.
FreeBSD loader and kernel needs the U-Boot API and dcache/icache flushed for it to run so add this operation in go/bootelf command and when closing the API.
Also add some some boot command that locate and run the FreeBSD loader if found.
Changes in v4:
Convert boards to CONFIG_API
Change commit log for patch 3 to be not FreeBSD specific and add Reviewed-By Change patch order.
Changes in v3:
Always flush icache/dcache if enabled for bootelf/go commands Correct some typos
Point to api/README in the help of Kconfig API
Changes in v2:
Remove SYS_DCACHE_OFF option
Flush dcache/icache in go/boot command
Flush dcache/icache in API closedev
Emmanuel Vadot (4):
kconfig: Add API kconfig file
api: Convert to Kconfig
distro_bootcmd: Add command to run FreeBSD
kconfig: Add a DISTRO_FREEBSD option
Warner Losh (1):
api: bootelf: go: flush cache before starting
Kconfig | 2 ++ api/Kconfig | 9 +++++++++ api/api.c | 5 +++++ cmd/boot.c | 4 ++++ cmd/elf.c | 5 +++++ common/Kconfig | 11 +++++++++++ configs/PMC440_defconfig | 1 + configs/lsxhl_defconfig | 1 + include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++ include/configs/PMC440.h | 2 -- include/configs/lsxl.h | 5 ----- scripts/config_whitelist.txt | 1 - 12 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 api/Kconfig
Signature · 1 line
2.11.0
PATCH v4 1/5 kconfig: Add API kconfig file
Add kconfig file to enable API support
--- Kconfig | 2 ++ api/Kconfig | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 api/Kconfig
Kconfig +2 -0
@@ -308,6 +308,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig" source "cmd/Kconfig"
api/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enables the U-Boot API. See api/README for more information. + +endmenu
Signature · 1 line
2.11.0
PATCH v4 1/5 kconfig: Add API kconfig file
Quoted 3 lines · Emmanuel Vadot
Add kconfig file to enable API support
Signed-off-by Emmanuel Vadot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170205/93dfabc9/attachment.sig>
PATCH v4 1/5 kconfig: Add API kconfig file
In reply to Emmanuel VadotQuoted 8 lines · Emmanuel Vadot
Add kconfig file to enable API support
Signed-off-by Emmanuel Vadot <[email protected]>--- Kconfig | 2 ++ api/Kconfig | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 api/Kconfig
Change log?
PATCH v4 1/5 kconfig: Add API kconfig file
In reply to Emmanuel VadotQuoted 5 lines · Emmanuel Vadot
Add kconfig file to enable API support
Signed-off-by Emmanuel Vadot <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170208/7b1e3842/attachment.sig>
PATCH v4 2/5 api: Convert to Kconfig
In reply to Emmanuel VadotNow that we have a Kconfig for the API, convert the two boards that are using this to Kconfig and remove CONFIG_API from the whitelist.
--- configs/PMC440_defconfig | 1 + configs/lsxhl_defconfig | 1 + include/configs/PMC440.h | 2 -- include/configs/lsxl.h | 5 ----- scripts/config_whitelist.txt | 1 - 5 files changed, 2 insertions(+), 8 deletions(-)
configs/PMC440_defconfig +1 -0
@@ -24,3 +24,4 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_STORAGE=y CONFIG_OF_LIBFDT=y +CONFIG_API=y
configs/lsxhl_defconfig +1 -0
@@ -23,3 +23,4 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_STORAGE=y CONFIG_OF_LIBFDT=y +CONFIG_API=y
include/configs/PMC440.h +0 -2
@@ -385,6 +385,4 @@#define CONFIG_KGDB_BAUDRATE 230400/* speed to run kgdb serial port */ #endif -#define CONFIG_API 1 -#endif /* __CONFIG_H */
include/configs/lsxl.h +0 -5
@@ -38,11 +38,6 @@#define CONFIG_SYS_NO_FLASH /* -* Enable u-boot API for standalone programs. -*/ -#define CONFIG_API - -/* * Commands configuration */ #define CONFIG_CMD_ENV
scripts/config_whitelist.txt +0 -1
@@ -102,7 +102,6 @@ CONFIG_APBH_DMA_BURST8 CONFIG_APER_0_BASE CONFIG_APER_1_BASE CONFIG_APER_SIZE -CONFIG_API CONFIG_APUS_FAST_EXCEPT CONFIG_AP_SH4A_4A CONFIG_ARCH_ADPAG101P
Signature · 1 line
2.11.0
PATCH v4 2/5 api: Convert to Kconfig
Quoted 4 lines · Emmanuel Vadot
Now that we have a
Kconfigfor the API, convert the two boards that are using this toKconfigand removeCONFIG_APIfrom the whitelist.Signed-off-by Emmanuel Vadot <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170205/7b9f47a5/attachment.sig>
PATCH v4 2/5 api: Convert to Kconfig
In reply to Emmanuel VadotQuoted 11 lines · Emmanuel Vadot
Now that we have a
Kconfigfor the API, convert the two boards that are using this toKconfigand removeCONFIG_APIfrom the whitelist.Signed-off-by Emmanuel Vadot <[email protected]>--- configs/PMC440_defconfig | 1 + configs/lsxhl_defconfig | 1 + include/configs/PMC440.h | 2 -- include/configs/lsxl.h | 5 ----- scripts/config_whitelist.txt | 1 - 5 files changed, 2 insertions(+), 8 deletions(-)
PATCH v4 2/5 api: Convert to Kconfig
In reply to Emmanuel VadotQuoted 6 lines · Emmanuel Vadot
Now that we have a
Kconfigfor the API, convert the two boards that are using this toKconfigand removeCONFIG_APIfrom the whitelist.Signed-off-by Emmanuel Vadot <[email protected]>Reviewed-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170208/d7374146/attachment.sig>
PATCH v4 3/5 api: bootelf: go: flush cache before starting
In reply to Emmanuel VadotFrom: Warner Losh <[email protected]>
Some application might load some code at location that contain stale cache entries. Before running a elf or raw binary, flush the caches if they are enabled.
--- api/api.c | 5 +++++ cmd/boot.c | 4 ++++ cmd/elf.c | 5 +++++ 3 files changed, 14 insertions(+)
api/api.c +5 -0
@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +if (dcache_status ()) +flush_dcache_all (); +if (icache_status ()) +invalidate_icache_all (); +return err; }
cmd/boot.c +4 -0
@@ -19,6 +19,10 @@ __attribute__((weak))unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]) { +if (dcache_status ()) +flush_dcache_all (); +if (icache_status ()) +invalidate_icache_all ();return entry (argc, argv); }
cmd/elf.c +5 -0
@@ -109,6 +109,11 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), {unsigned long ret; +if (dcache_status ()) +flush_dcache_all (); +if (icache_status ()) +invalidate_icache_all (); +/* * pass address parameter as argv[0] (aka command name), * and all remaining args
Signature · 1 line
2.11.0
PATCH v4 3/5 api: bootelf: go: flush cache before starting
Quoted 6 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
Some application might load some code at location that contain stale cache entries. Before running a elf or raw binary, flush the caches if they are enabled.
Quoted 7 lines
Reviewed-by Tom Rini <[email protected]>Signed-off-by Emmanuel Vadot <[email protected]>--- api/api.c | 5 +++++ cmd/boot.c | 4 ++++ cmd/elf.c | 5 +++++ 3 files changed, 14 insertions(+)
PATCH v4 3/5 api: bootelf: go: flush cache before starting
In reply to Emmanuel VadotQuoted 20 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
Some application might load some code at location that contain stale cache entries. Before running a elf or raw binary, flush the caches if they are enabled.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Emmanuel Vadot <[email protected]>Reviewed-by Simon Glass <[email protected]>--- api/api.c | 5 +++++ cmd/boot.c | 4 ++++ cmd/elf.c | 5 +++++ 3 files changed, 14 insertions(+)api/api.c +0
-0
api/api.c static int API_dev_close(va_list ap) · line 297
Quoted 8 lines
api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +if (dcache_status ()) +flush_dcache_all (); +if (icache_status ()) +invalidate_icache_all (); +
So this runs into a problem. Building for sandbox, or many many other platforms gives us:
undefined reference to `dcache_status'
undefined reference to `flush_dcache_all'
undefined reference to `icache_status'
undefined reference to `invalidate_icache_all'
At the high level, we have a few problems. We don't have a global "has icache" and "has dcache" support CONFIG symbol. We also have a few instances of weak functions that end up being no-ops in these cases, but it's not quite correct to use them in this case, possibly. For example, PowerPC does have dcache support and functions but no flush_dcache_all (and only sometimes a flush_dcache() that looks like it would be _all()), and same for icache.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170208/f7fe1c05/attachment.sig>
PATCH v4 3/5 api: bootelf: go: flush cache before starting
Quoted 37 lines · Tom Rini
Quoted 20 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
Some application might load some code at location that contain stale cache entries. Before running a elf or raw binary, flush the caches if they are enabled.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Emmanuel Vadot <[email protected]>Reviewed-by Simon Glass <[email protected]>--- api/api.c | 5 +++++ cmd/boot.c | 4 ++++ cmd/elf.c | 5 +++++ 3 files changed, 14 insertions(+)api/api.c +0
-0api/api.c static int API_dev_close(va_list ap) · line 297
Quoted 8 lines
api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +if (dcache_status ()) +flush_dcache_all (); +if (icache_status ()) +invalidate_icache_all (); +So this runs into a problem. Building for sandbox, or many many other platforms gives us:
undefined reference to `dcache_status'
undefined reference to `flush_dcache_all'
undefined reference to `icache_status'
undefined reference to `invalidate_icache_all'
Quoted 7 lines
At the high level, we have a few problems. We don't have a global "has icache" and "has dcache" support CONFIG symbol. We also have a few instances of weak functions that end up being no-ops in these cases, but it's not quite correct to use them in this case, possibly. For example, PowerPC does have dcache support and functions but no
flush_dcache_all(and only sometimes aflush_dcache()that looks like it would be_all()), and same for icache.
Well, if we want to keep the API consistent (which I think we do) we should probably fix that :). It's quite a good chunk of unpleasant work though...
Alex
PATCH v4 3/5 api: bootelf: go: flush cache before starting
In reply to Tom RiniQuoted 38 lines · On Wed, 8 Feb 2017 10:00:54 -0500 Tom Rini <[email protected]> wrote:
Quoted 20 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
Some application might load some code at location that contain stale cache entries. Before running a elf or raw binary, flush the caches if they are enabled.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Emmanuel Vadot <[email protected]>Reviewed-by Simon Glass <[email protected]>--- api/api.c | 5 +++++ cmd/boot.c | 4 ++++ cmd/elf.c | 5 +++++ 3 files changed, 14 insertions(+)api/api.c +0
-0api/api.c static int API_dev_close(va_list ap) · line 297
Quoted 8 lines
api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +if (dcache_status ()) +flush_dcache_all (); +if (icache_status ()) +invalidate_icache_all (); +So this runs into a problem. Building for sandbox, or many many other platforms gives us:
undefined reference to `dcache_status'
undefined reference to `flush_dcache_all'
undefined reference to `icache_status'
undefined reference to `invalidate_icache_all'
Quoted 10 lines
At the high level, we have a few problems. We don't have a global "has icache" and "has dcache" support CONFIG symbol. We also have a few instances of weak functions that end up being no-ops in these cases, but it's not quite correct to use them in this case, possibly. For example, PowerPC does have dcache support and functions but no
flush_dcache_all(and only sometimes aflush_dcache()that looks like it would be_all()), and same for icache.Signature · 1 line
Tom
Hi Tom,
Will depending on CONFIG_CMD_CACHE will be acceptable ? This is the easiest fix that I can think of.
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v4 3/5 api: bootelf: go: flush cache before starting
Quoted 49 lines · Emmanuel Vadot
Quoted 38 lines · On Wed, 8 Feb 2017 10:00:54 -0500 Tom Rini <[email protected]> wrote:
Quoted 20 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
Some application might load some code at location that contain stale cache entries. Before running a elf or raw binary, flush the caches if they are enabled.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Emmanuel Vadot <[email protected]>Reviewed-by Simon Glass <[email protected]>--- api/api.c | 5 +++++ cmd/boot.c | 4 ++++ cmd/elf.c | 5 +++++ 3 files changed, 14 insertions(+)api/api.c +0
-0api/api.c static int API_dev_close(va_list ap) · line 297
Quoted 8 lines
api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +if (dcache_status ()) +flush_dcache_all (); +if (icache_status ()) +invalidate_icache_all (); +So this runs into a problem. Building for sandbox, or many many other platforms gives us:
undefined reference to `dcache_status'
undefined reference to `flush_dcache_all'
undefined reference to `icache_status'
undefined reference to `invalidate_icache_all'Quoted 7 lines
At the high level, we have a few problems. We don't have a global "has icache" and "has dcache" support CONFIG symbol. We also have a few instances of weak functions that end up being no-ops in these cases, but it's not quite correct to use them in this case, possibly. For example, PowerPC does have dcache support and functions but no
flush_dcache_all(and only sometimes aflush_dcache()that looks like it would be_all()), and same for icache.
Quoted 4 lines
Hi Tom,
Will depending on
CONFIG_CMD_CACHEwill be acceptable ? This is the easiest fix that I can think of.
That will continue to bring in the PowerPC side of the problem. I'll see about doing a little research to confirm what I said about the cache functions on PowerPC and we can move from there.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170210/dee20544/attachment.sig>
PATCH v4 4/5 distro_bootcmd: Add command to run FreeBSD
In reply to Emmanuel VadotAdd 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.
--- include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
include/config_distro_bootcmd.h +32 -0
@@ -149,6 +149,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_CMD_SATA #define BOOTENV_SHARED_SATA BOOTENV_SHARED_BLKDEV(sata)#define BOOTENV_DEV_SATA BOOTENV_DEV_BLKDEV
@@ -322,6 +352,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" \
@@ -365,6 +396,7 @@"run scan_dev_for_scripts; " \"done;" \SCAN_DEV_FOR_EFI \ +SCAN_DEV_FOR_FREEBSD \"\0" \ \"scan_dev_for_boot_part=" \
Signature · 1 line
2.11.0
PATCH v4 4/5 distro_bootcmd: Add command to run FreeBSD
Quoted 5 lines · Emmanuel Vadot
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 <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170205/ce369e2b/attachment.sig>
PATCH v4 4/5 distro_bootcmd: Add command to run FreeBSD
In reply to Emmanuel VadotQuoted 8 lines · Emmanuel Vadot
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 <[email protected]>--- include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
PATCH v4 5/5 kconfig: Add a DISTRO_FREEBSD option
In reply to Emmanuel VadotAdd a FreeBSD option that enables the API and the data cache command as both are needed to boot the FreeBSD loader.
--- common/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
common/Kconfig +11 -0
@@ -430,4 +430,15 @@ config BOARD_EARLY_INIT_F endmenu +config DISTRO_FREEBSD + bool "Enable FreeBSD boot" + select API + select CMD_CACHE + default n + help + This options adds boot configuration that can run the FreeBSD + loader. When enabled the distro_bootcmd will be expanded to + include scan_dev_for_freebsd which search for the FreeBSD loader + and if found run it. + source "common/spl/Kconfig"
Signature · 1 line
2.11.0
v4 cover Add FreeBSD kconfig options
In reply to Emmanuel VadotQuoted 7 lines · Emmanuel Vadot
This series of patches add the needed bits for booting the FreeBSD loader and kernel.
FreeBSD loader and kernel needs the U-Boot API and dcache/icache flushed for it to run so add this operation in go/bootelf command and when closing the API.
Also add some some boot command that locate and run the FreeBSD loader if found.
LGTM :)
Alex