Add FreeBSD kconfig options
v2 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 v2:
Remove SYS_DCACHE_OFF option
Flush dcache/icache in go/boot command
Flush dcache/icache in API closedev
Emmanuel Vadot (3):
kconfig: Add API kconfig file
kconfig: Add a FREEBSD option
distro_bootcmd: Add command to run FreeBSD
Warner Losh (1):
api: FreeBSD: flush cache before starting loader/kernel
Kconfig | 2 ++ api/Kconfig | 9 +++++++++ api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- common/Kconfig | 9 +++++++++ include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 api/Kconfig
Signature · 1 line
2.11.0
PATCH v2 1/4 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
@@ -306,6 +306,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 enable the U-Boot API. + +endmenu
Signature · 1 line
2.11.0
PATCH v2 1/4 kconfig: Add API kconfig file
Am 17.01.2017 um 16:50 schrieb Emmanuel Vadot:
Quoted 28 lines
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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig" source "cmd/Kconfig"api/Kconfig new file +0
-0
api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API.
"enables"
Should the help say, e.g., "userspace API" for clarity?
api/Kconfig line 9
Quoted 2 lines
api/Kconfig new file +2
-0+ +endmenu
Otherwise looks okay, obviously.
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg)
PATCH v2 1/4 kconfig: Add API kconfig file
Hi Andreas,
Quoted 22 lines · On Tue, 17 Jan 2017 18:16:58 +0100 Andreas F?rber <[email protected]> wrote:
Am 17.01.2017 um 16:50 schrieb Emmanuel Vadot:
Quoted 21 lines
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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig"
Quoted 16 lines
Quoted 7 lines
Kconfig +0
-0source "cmd/Kconfig"api/Kconfig new file +0
-0api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API."enables"
I'll change that, thanks for reviewing.
Quoted 1 line
Should the help say, e.g., "userspace API" for clarity?
I don't know, I'm for whatever is best.
Quoted 13 lines
api/Kconfig line 9
Quoted 3 lines
api/Kconfig new file +2
-0+ +endmenuOtherwise looks okay, obviously.
Regards,
AndreasSignature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg)
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v2 1/4 kconfig: Add API kconfig file
Quoted 45 lines · Emmanuel Vadot
Hi Andreas,
Quoted 22 lines · On Tue, 17 Jan 2017 18:16:58 +0100 Andreas F?rber <[email protected]> wrote:
Am 17.01.2017 um 16:50 schrieb Emmanuel Vadot:
Quoted 21 lines
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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig"Quoted 16 lines
Quoted 7 lines
Kconfig +0
-0source "cmd/Kconfig"api/Kconfig new file +0
-0api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API."enables"
Quoted 5 lines
I'll change that, thanks for reviewing.
Quoted 1 line
Should the help say, e.g., "userspace API" for clarity?
I don't know, I'm for whatever is best.
It isn't a userspace API, per se, since it isn't used after the kernel is loaded and booted. It's likely to lead to confusion if use use that term. The README file calls it "U-Boot machine/arch independent API for external apps" FWIW, so maybe some variation on that might make the help text better.
Warner Losh
<[email protected]>
Quoted 16 lines
Quoted 5 lines
api/Kconfig line 9
Quoted 2 lines
api/Kconfig new file +2
-0+ +endmenuOtherwise looks okay, obviously.
Quoted 7 lines
Regards,
Andreas--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany
GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg)--
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v2 1/4 kconfig: Add API kconfig file
In reply to Emmanuel VadotHi,
Quoted 28 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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig" source "cmd/Kconfig"api/Kconfig new file +0
-0
api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API.
Can you add a little detail about what the API is and what it is for?
Also, are you going to migrate all boards to use Kconfig for this option and drop it from the whitelist?
Quoted 5 lines
api/Kconfig new file +2
-1+ +endmenu --2.11.0
Regards,
Simon
PATCH v2 1/4 kconfig: Add API kconfig file
Quoted 24 lines · Simon Glass
Hi,
Quoted 21 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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig"
Quoted 16 lines
Quoted 7 lines
Kconfig +0
-0source "cmd/Kconfig"api/Kconfig new file +0
-0api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API.Can you add a little detail about what the API is and what it is for?
You can find complete documentation in the api directory. In brief, it allows the loaded binary to call back into the loader to do generic things like send network packets or read blocks from mass storage.
Quoted 2 lines
Also, are you going to migrate all boards to use
Kconfigfor this option and drop it from the whitelist?
I'll leave that to Emmanuel.
Warner
Quoted 8 lines
Quoted 5 lines
api/Kconfig new file +2
-1+ +endmenu --2.11.0
Regards,
Simon
PATCH v2 1/4 kconfig: Add API kconfig file
Quoted 42 lines · Warner Losh
Quoted 24 lines · Simon Glass
Hi,
Quoted 21 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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig"Quoted 16 lines
Quoted 7 lines
Kconfig +0
-0source "cmd/Kconfig"api/Kconfig new file +0
-0api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API.Can you add a little detail about what the API is and what it is for?
Quoted 3 lines
You can find complete documentation in the api directory. In brief, it allows the loaded binary to call back into the loader to do generic things like send network packets or read blocks from mass storage.
Right. Can you re-word the "In brief.." slightly so it reads well under the 'help' section and point to api/README for more details please?
Quoted 4 lines
Quoted 2 lines
Also, are you going to migrate all boards to use
Kconfigfor this option and drop it from the whitelist?I'll leave that to Emmanuel.
There's two boards that enable API today but tools/moveconfig.py may be more overhead than just editing configs/PMC440_defconfig and configs/lsxhl_defconfig (and the respective include/configs/ files).
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/20170123/c8f1541a/attachment.sig>
PATCH v2 1/4 kconfig: Add API kconfig file
Hi Tom,
Quoted 43 lines · On Mon, 23 Jan 2017 09:51:59 -0500 Tom Rini <[email protected]> wrote:
Quoted 42 lines · Warner Losh
Quoted 40 lines · Simon Glass
Hi,
Quoted 28 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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig" source "cmd/Kconfig"api/Kconfig new file +0
-0api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API.Can you add a little detail about what the API is and what it is for?
Quoted 6 lines
Quoted 3 lines
You can find complete documentation in the api directory. In brief, it allows the loaded binary to call back into the loader to do generic things like send network packets or read blocks from mass storage.
Right. Can you re-word the "In brief.." slightly so it reads well under the 'help' section and point to api/README for more details please?
All right, I'll do that for v3.
Quoted 11 lines
Quoted 4 lines
Quoted 2 lines
Also, are you going to migrate all boards to use
Kconfigfor this option and drop it from the whitelist?I'll leave that to Emmanuel.
There's two boards that enable API today but
tools/moveconfig.pymay be more overhead than just editing configs/PMC440_defconfig and configs/lsxhl_defconfig (and the respectiveinclude/configs/files).Signature · 1 line
Tom
Ah, I've missed those. Would it make more sense to submit a patch that
handle adding CONFIG_API into Kconfig (and changing configs for those two board and remove from the whitelist) separate from the FreeBSD config sets of patches ?
Thanks,
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v2 1/4 kconfig: Add API kconfig file
Quoted 63 lines · Emmanuel Vadot
Hi Tom,
Quoted 43 lines · On Mon, 23 Jan 2017 09:51:59 -0500 Tom Rini <[email protected]> wrote:
Quoted 42 lines · Warner Losh
Quoted 40 lines · Simon Glass
Hi,
Quoted 28 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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig" source "cmd/Kconfig"api/Kconfig new file +0
-0api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API.Can you add a little detail about what the API is and what it is for?
Quoted 6 lines
Quoted 3 lines
You can find complete documentation in the api directory. In brief, it allows the loaded binary to call back into the loader to do generic things like send network packets or read blocks from mass storage.
Right. Can you re-word the "In brief.." slightly so it reads well under the 'help' section and point to api/README for more details please?
All right, I'll do that for v3.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Also, are you going to migrate all boards to use
Kconfigfor this option and drop it from the whitelist?I'll leave that to Emmanuel.
Quoted 8 lines
Quoted 3 lines
There's two boards that enable API today but
tools/moveconfig.pymay be more overhead than just editing configs/PMC440_defconfig and configs/lsxhl_defconfig (and the respectiveinclude/configs/files).Ah, I've missed those. Would it make more sense to submit a patch that
handle addingCONFIG_APIintoKconfig(and changing configs for those two board and remove from the whitelist) separate from the FreeBSD config sets of patches ?
It's up to you guys. I want to see this thread sorted out and changes required to support FreeBSD happily, out of the box, in. So API gets converted one way or another :)
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/20170123/e3a7c34c/attachment.sig>
PATCH v2 1/4 kconfig: Add API kconfig file
In reply to Simon GlassQuoted 41 lines · On Fri, 20 Jan 2017 20:51:48 -0700 Simon Glass <[email protected]> wrote:
Hi,
Quoted 28 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/KconfigKconfig +2
-0@@ -306,6 +306,8 @@ config ARCH_FIXUP_FDT_MEMORY endmenu # Boot images +source "api/Kconfig" + source "common/Kconfig" source "cmd/Kconfig"api/Kconfig new file +0
-0api/Kconfig line 7
Quoted 7 lines
api/Kconfig new file +7
-0@@ -0,0 +1,9 @@ +menu "API" + +config API + bool "Enable U-Boot API" + default n + help + This option enable the U-Boot API.Can you add a little detail about what the API is and what it is for?
Quoted 2 lines
Also, are you going to migrate all boards to use
Kconfigfor this option and drop it from the whitelist?
I don't understand your question about migration, currently no board
are using it.
As for the whitelist, if I understand correctly how it works it should
be removed in the same patch.
Quoted 8 lines
Quoted 5 lines
api/Kconfig new file +2
-1+ +endmenu --2.11.0
Regards,
Simon
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v2 2/4 kconfig: Add a FREEBSD option
In reply to Emmanuel VadotAdd a FreeBSD option that enable the API and enable the data cache command as it is needed to boot the FreeBSD loader.
--- common/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+)
common/Kconfig +9 -0
@@ -389,4 +389,13 @@ config DISPLAY_BOARDINFO when U-Boot starts up. The board function checkboard() is called to do this. +config FREEBSD + bool "Enable FreeBSD boot" + select API + select CMD_CACHE + default n + help + This option adds boot configuration that can run the FreeBSD + loader. + source "common/spl/Kconfig"
Signature · 1 line
2.11.0
PATCH v2 2/4 kconfig: Add a FREEBSD option
Hi,
Quoted 14 lines · Emmanuel Vadot
Add a FreeBSD option that enable the API and enable the data cache command as it is needed to boot the FreeBSD loader.
Signed-off-by Emmanuel Vadot <[email protected]>--- common/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+)common/Kconfig +0
-0@@ -389,4 +389,13 @@ config DISPLAY_BOARDINFO when U-Boot starts up. The board function checkboard() is called
common/Kconfig config DISPLAY_BOARDINFO · line 399
Quoted 10 lines
common/Kconfig +8
-0to do this. +config FREEBSD + bool "Enable FreeBSD boot" + select API + select CMD_CACHE + default n + help + This option adds boot configuration that can run the FreeBSD + loader.
What is the FreeBSD loader? Do you mean that U-Boot can boot FreeBSD?
Quoted 5 lines
common/Kconfig +1
-1+ source "common/spl/Kconfig" --2.11.0
Regards,
Simon
PATCH v2 2/4 kconfig: Add a FREEBSD option
Hello Simon,
Quoted 19 lines · Simon Glass
Hi,
Quoted 16 lines · Emmanuel Vadot
Add a FreeBSD option that enable the API and enable the data cache command as it is needed to boot the FreeBSD loader.
Signed-off-by Emmanuel Vadot <[email protected]>--- common/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+)common/Kconfig +0
-0@@ -389,4 +389,13 @@ config DISPLAY_BOARDINFO when U-Boot starts up. The board function checkboard() is called to do this.
Quoted 9 lines
common/Kconfig config DISPLAY_BOARDINFO · line 399
Quoted 8 lines
common/Kconfig +8
-0+config FREEBSD + bool "Enable FreeBSD boot" + select API + select CMD_CACHE + default n + help + This option adds boot configuration that can run the FreeBSD + loader.What is the FreeBSD loader?
see https://www.freebsd.org/cgi/man.cgi?loader(8). Which is rather nice, FreeBSD uses
the same loader independent of arch, so booting the previous kernel / kernel module stuff
and rescue things are roughly the same on i386, amd64 and arm. The loader communicates
with u-boot by its api.
Quoted 2 lines
Do you mean that U-Boot can boot FreeBSD?
Hence he meant what he wrote. Be able to run the FreeBSD _loader_. The FreeBSD loader will take care of booting FreeBSD.
Regards,
Jeroen
PATCH v2 2/4 kconfig: Add a FREEBSD option
In reply to Simon GlassQuoted 19 lines · Simon Glass
Hi,
Quoted 16 lines · Emmanuel Vadot
Add a FreeBSD option that enable the API and enable the data cache command as it is needed to boot the FreeBSD loader.
Signed-off-by Emmanuel Vadot <[email protected]>--- common/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+)common/Kconfig +0
-0@@ -389,4 +389,13 @@ config DISPLAY_BOARDINFO when U-Boot starts up. The board function checkboard() is called to do this.
Quoted 10 lines
common/Kconfig config DISPLAY_BOARDINFO · line 399
Quoted 8 lines
common/Kconfig +8
-0+config FREEBSD + bool "Enable FreeBSD boot" + select API + select CMD_CACHE + default n + help + This option adds boot configuration that can run the FreeBSD + loader.What is the FreeBSD loader? Do you mean that U-Boot can boot FreeBSD?
No. The FreeBSD loader is loaded by u-boot and it loads the kernel, modules and sets up a number of environment variables.
Warner
Quoted 8 lines
Quoted 5 lines
common/Kconfig +1
-1+ source "common/spl/Kconfig" --2.11.0
Regards,
Simon
PATCH v2 3/4 api: FreeBSD: flush cache before starting loader/kernel
In reply to Emmanuel VadotFrom: Warner Losh <[email protected]>
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries.
FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.
--- api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)
api/api.c +5 -0
@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return err; }
cmd/boot.c +5 -0
@@ -19,6 +19,11 @@ __attribute__((weak))unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]) { +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return entry (argc, argv); }
cmd/elf.c +7 -1
@@ -109,6 +109,7 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), {unsigned long ret; +#ifndef CONFIG_FREEBSD /* * QNX images require the data cache is disabled. * Data cache is already flushed, so just turn it off.
@@ -116,15 +117,20 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),int dcache =dcache_status ();if (dcache)dcache_disable (); - +#else +flush_dcache_all (); +invalidate_icache_all (); +#endif /* * pass address parameter as argv[0] (aka command name), * and all remaining args */ ret =entry (argc, argv); +#ifndef CONFIG_FREEBSD if (dcache)dcache_enable (); +#endif return ret; }
Signature · 1 line
2.11.0
PATCH v2 3/4 api: FreeBSD: flush cache before starting loader/kernel
Quoted 8 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries.
FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.Signed-off-by Emmanuel Vadot <[email protected]>
Is there any downside to doing the flush always? I would prefer to not conditionalize it on CONFIG_FREEBSD.
Quoted 51 lines
--- api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return err; }cmd/boot.c +5
-0@@ -19,6 +19,11 @@ __attribute__((weak))unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]) { +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return entry (argc, argv); }cmd/elf.c +1
-0@@ -109,6 +109,7 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), {unsigned long ret; +#ifndef CONFIG_FREEBSD /* * QNX images require the data cache is disabled. * Data cache is already flushed, so just turn it off.
cmd/elf.c static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), · line 119
Quoted 3 lines
cmd/elf.c +0
-0@@ -116,15 +117,20 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),int dcache =dcache_status ();if (dcache)dcache_disable ();
Can FreeBSD boot with dcache disabled? Is there some way we can determine what payload we have from the elf header?
Alex
PATCH v2 3/4 api: FreeBSD: flush cache before starting loader/kernel
Quoted 10 lines · On Tue, 17 Jan 2017 21:13:51 +0100 Alexander Graf <[email protected]> wrote:
Quoted 7 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries.
FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.
Quoted 4 lines
Quoted 1 line
Signed-off-by Emmanuel Vadot <[email protected]>Is there any downside to doing the flush always? I would prefer to not conditionalize it on
CONFIG_FREEBSD.
I don't think there is any downside.
Quoted 59 lines
Quoted 51 lines
--- api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return err; }cmd/boot.c +5
-0@@ -19,6 +19,11 @@ __attribute__((weak))unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]) { +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return entry (argc, argv); }cmd/elf.c +1
-0@@ -109,6 +109,7 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), {unsigned long ret; +#ifndef CONFIG_FREEBSD /* * QNX images require the data cache is disabled. * Data cache is already flushed, so just turn it off. cmd/elf.c static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), · line 119
Quoted 3 lines
cmd/elf.c +0
-0@@ -116,15 +117,20 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),int dcache =dcache_status ();if (dcache)dcache_disable ();Can FreeBSD boot with dcache disabled? Is there some way we can determine what payload we have from the elf header?
Quoted 1 line
Alex
FreeBSD can boot with dcache disabled (our loader and kernel can) I'm not sure I get your other question, sorry.
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v2 3/4 api: FreeBSD: flush cache before starting loader/kernel
Quoted 79 lines · Emmanuel Vadot
Quoted 10 lines · On Tue, 17 Jan 2017 21:13:51 +0100 Alexander Graf <[email protected]> wrote:
Quoted 7 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries.
FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.Quoted 4 lines
Quoted 1 line
Signed-off-by Emmanuel Vadot <[email protected]>Is there any downside to doing the flush always? I would prefer to not conditionalize it on
CONFIG_FREEBSD.I don't think there is any downside.
Quoted 59 lines
Quoted 51 lines
--- api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return err; }cmd/boot.c +5
-0@@ -19,6 +19,11 @@ __attribute__((weak))unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]) { +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return entry (argc, argv); }cmd/elf.c +1
-0@@ -109,6 +109,7 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), {unsigned long ret; +#ifndef CONFIG_FREEBSD /* * QNX images require the data cache is disabled. * Data cache is already flushed, so just turn it off. cmd/elf.c static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), · line 119
Quoted 3 lines
cmd/elf.c +0
-0@@ -116,15 +117,20 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),int dcache =dcache_status ();if (dcache)dcache_disable ();Can FreeBSD boot with dcache disabled? Is there some way we can determine what payload we have from the elf header?
Quoted 4 lines
Quoted 1 line
Alex
FreeBSD can boot with dcache disabled (our loader and kernel can) I'm not sure I get your other question, sorry.
Your patch #ifdefs out the dcache_disable() if CONFIG_FREEBSD is set. So if you can boot just fine with dcache disabled, you can remove this hunk altogether FWIW.
All the other changes in this file are mere cache flushes - and they shouldn't hurt any u-boot api user and thus could be done unconditionally.
Alex
PATCH v2 3/4 api: FreeBSD: flush cache before starting loader/kernel
Quoted 82 lines · On Tue, 17 Jan 2017 21:58:31 +0100 Alexander Graf <[email protected]> wrote:
Quoted 79 lines · Emmanuel Vadot
Quoted 10 lines · On Tue, 17 Jan 2017 21:13:51 +0100 Alexander Graf <[email protected]> wrote:
Quoted 7 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries.
FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.Quoted 4 lines
Quoted 1 line
Signed-off-by Emmanuel Vadot <[email protected]>Is there any downside to doing the flush always? I would prefer to not conditionalize it on
CONFIG_FREEBSD.I don't think there is any downside.
Quoted 59 lines
Quoted 51 lines
--- api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)api/api.c +5
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return err; }cmd/boot.c +5
-0@@ -19,6 +19,11 @@ __attribute__((weak))unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]) { +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return entry (argc, argv); }cmd/elf.c +1
-0@@ -109,6 +109,7 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), {unsigned long ret; +#ifndef CONFIG_FREEBSD /* * QNX images require the data cache is disabled. * Data cache is already flushed, so just turn it off. cmd/elf.c static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), · line 119
Quoted 3 lines
cmd/elf.c +0
-0@@ -116,15 +117,20 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),int dcache =dcache_status ();if (dcache)dcache_disable ();Can FreeBSD boot with dcache disabled? Is there some way we can determine what payload we have from the elf header?
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Alex
FreeBSD can boot with dcache disabled (our loader and kernel can) I'm not sure I get your other question, sorry.
Your patch #ifdefs out the
dcache_disable()ifCONFIG_FREEBSDis set. So if you can boot just fine with dcache disabled, you can remove this hunk altogether FWIW.
Loading the kernel from our loader is much faster with dcache enabled
(1 sec instead of 5/7 sec).
I guess we can always flush the cache and only disable it for QNX,
I'll check if there is a CONFIG_QNX or something like that.
Quoted 2 lines
All the other changes in this file are mere cache flushes - and they shouldn't hurt any u-boot api user and thus could be done unconditionally.
True, I can remove the #ifdefs on CONFIG_FREEBSD here.
Quoted 2 lines
Alex
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v2 3/4 api: FreeBSD: flush cache before starting loader/kernel
In reply to Emmanuel VadotHi,
Quoted 19 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries.
FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.Signed-off-by Emmanuel Vadot <[email protected]>--- api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)api/api.c +0
-0
api/api.c static int API_dev_close(va_list ap) · line 296
Quoted 7 lines
api/api.c +4
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ; +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif
It's not nice IMO to add OS-specific #ifdefs to generic code. Can you instead define a Kconfig option with a sensible name, and have FreeBSD define it?
Quoted 10 lines
api/api.c +1
-0+return err; }cmd/boot.c +0
-0@@ -19,6 +19,11 @@ __attribute__((weak)) unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
cmd/boot.c __attribute__((weak)) · line 29
Quoted 10 lines
cmd/boot.c +5
-0char * const argv[]) { +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return entry (argc, argv); }
Regards,
Simon
PATCH v2 3/4 api: FreeBSD: flush cache before starting loader/kernel
Hi Simon,
Quoted 25 lines · On Fri, 20 Jan 2017 20:51:54 -0700 Simon Glass <[email protected]> wrote:
Hi,
Quoted 22 lines · Emmanuel Vadot
From: Warner Losh <[email protected]>
FreeBSD loader(8) just loaded code to some random location that may contain stale icache entries.
FreeBSD Kernel needs the icache and dcache flushed. Before running either one of them, flush the icache and dcache.Signed-off-by Emmanuel Vadot <[email protected]>--- api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-)api/api.c +0
-0@@ -290,6 +290,11 @@ static int API_dev_close(va_list ap)if (!err) di->state =DEV_STA_CLOSED ;
Quoted 8 lines
api/api.c static int API_dev_close(va_list ap) · line 296
Quoted 4 lines
api/api.c +4
-0+#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif It's not nice IMO to add OS-specific #ifdefs to generic code. Can you instead define a
Kconfigoption with a sensible name, and have FreeBSD define it?
In the same thread, Alexander Graf said that since this are just cache
flush it doesn't even need to be FreeBSD/CONFIG specific so I'll do that on the v3.
Quoted 23 lines
Quoted 10 lines
api/api.c +1
-0+return err; }cmd/boot.c +0
-0@@ -19,6 +19,11 @@ __attribute__((weak)) unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,cmd/boot.c __attribute__((weak)) · line 29
Quoted 10 lines
cmd/boot.c +5
-0char * const argv[]) { +#ifdef CONFIG_FREEBSD +flush_dcache_all (); +invalidate_icache_all (); +#endif +return entry (argc, argv); }Regards,
Simon
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
PATCH v2 4/4 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
@@ -153,6 +153,36 @@#define SCAN_DEV_FOR_EFI #endif +#ifdef CONFIG_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
@@ -326,6 +356,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" \
@@ -369,6 +400,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 v2 4/4 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]>
If we can make the dcache disable part unconditional, I would just fold the CONFIG_FREEBSD part in here and only make the boot script hunk conditional on it.
Alex
v2 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.
Is there any particular reason the EFI boot path doesn't work for you?
Configuring u-boot differently to be able to boot FreeBSD sounds a bit strange to me.
Alex
v2 cover Add FreeBSD kconfig options
Hi Alexander,
Quoted 11 lines · On Tue, 17 Jan 2017 20:36:59 +0100 Alexander Graf <[email protected]> wrote:
Quoted 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.
Quoted 7 lines
Is there any particular reason the EFI boot path doesn't work for you?
Configuring u-boot differently to be able to boot FreeBSD sounds a bit strange to me.
Alex
EFI works fine for us, that's what we use for arm64 (pine64/rpi3 for
example) because we want to only use EFI for arm64.
For armv6/v7 we have legacy devices etc ... and even if EFI works
(well honestly I have to fix our smbios code for it to work properly) we need to be able to boot without EFI support.
With this series of patches is an EFI binary is found this is the one
that would be loaded, so when the times comes we could make our releases with EFI bootloaders for ARM. In the meantimes we still need the U-Boot API for our loader.
Cheers,
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
v2 cover Add FreeBSD kconfig options
Quoted 25 lines · Emmanuel Vadot
Hi Alexander,
Quoted 11 lines · On Tue, 17 Jan 2017 20:36:59 +0100 Alexander Graf <[email protected]> wrote:
Quoted 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.Quoted 7 lines
Is there any particular reason the EFI boot path doesn't work for you?
Configuring u-boot differently to be able to boot FreeBSD sounds a bit strange to me.
Alex
Quoted 9 lines
EFI works fine for us, that's what we use for arm64 (pine64/rpi3 for
example) because we want to only use EFI for arm64.
For armv6/v7 we have legacy devices etc ... and even if EFI works
(well honestly I have to fix our smbios code for it to work properly) we need to be able to boot without EFI support.
With this series of patches is an EFI binary is found this is the one
that would be loaded, so when the times comes we could make our releases with EFI bootloaders for ARM. In the meantimes we still need the U-Boot API for our loader.
In addition, we have a long-term support branch (FreeBSD 11.x) that we need to support with the current setup since we use u-boot to load our tertiary loader which loads the kernel and related files (hence the need for the u-boot app API). It's something that's evolved over a number of years without proper upstreaming in the past. This series of patches lets us continue to use the tried and true paths, as well as setting the stage for a migration to EFI for the next major supported branch of FreeBSD (12.x, not due for a release for about a year or so). FreeBSD 11 support needs to continue past FreeBSD 12's release. Finally, as Emmanuel has said, there's still some rough edges to FreeBSD/arm's EFI support that need to be worked through in parallel before people will switch to the new way.
Warner Losh
<[email protected]>
v2 cover Add FreeBSD kconfig options
Quoted 36 lines · Warner Losh
Quoted 25 lines · Emmanuel Vadot
Hi Alexander,
Quoted 11 lines · On Tue, 17 Jan 2017 20:36:59 +0100 Alexander Graf <[email protected]> wrote:
Quoted 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.Quoted 7 lines
Is there any particular reason the EFI boot path doesn't work for you?
Configuring u-boot differently to be able to boot FreeBSD sounds a bit strange to me.
Alex
Quoted 9 lines
EFI works fine for us, that's what we use for arm64 (pine64/rpi3 for
example) because we want to only use EFI for arm64.
For armv6/v7 we have legacy devices etc ... and even if EFI works
(well honestly I have to fix our smbios code for it to work properly) we need to be able to boot without EFI support.
With this series of patches is an EFI binary is found this is the one
that would be loaded, so when the times comes we could make our releases with EFI bootloaders for ARM. In the meantimes we still need the U-Boot API for our loader.
Quoted 12 lines
In addition, we have a long-term support branch (FreeBSD 11.x) that we need to support with the current setup since we use u-boot to load our tertiary loader which loads the kernel and related files (hence the need for the u-boot app API). It's something that's evolved over a number of years without proper upstreaming in the past. This series of patches lets us continue to use the tried and true paths, as well as setting the stage for a migration to EFI for the next major supported branch of FreeBSD (12.x, not due for a release for about a year or so). FreeBSD 11 support needs to continue past FreeBSD 12's release. Finally, as Emmanuel has said, there's still some rough edges to FreeBSD/arm's EFI support that need to be worked through in parallel before people will switch to the new way.
Thanks a lot to both of you for the detailed description. That indeed makes a lot of sense altogether.
Alex
A message that is not in the archive (sent off-list or not yet received): [email protected]
v2 cover Add FreeBSD kconfig options
Hi Stefan,
Quoted 10 lines · On Tue, 17 Jan 2017 10:08:54 -0800 Stefan Agner <[email protected]> wrote:
Quoted 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.Are FreeBSD's entry conditions documented?
Not really, you can find some stuff in the source code but that's all.
Quoted 30 lines
Linux has some things documented, especially the MMU must be off and also data cache:
https://www.kernel.org/doc/Documentation/arm/Booting--
StefanQuoted 23 lines
Changes in v2:
RemoveSYS_DCACHE_OFFoption
Flush dcache/icache in go/boot command
Flush dcache/icache in API closedevEmmanuel Vadot (3):
kconfig: Add API kconfig file
kconfig: Add a FREEBSD option
distro_bootcmd: Add command to run FreeBSDWarner Losh (1):
api: FreeBSD: flush cache before starting loader/kernelKconfig | 2 ++ api/Kconfig | 9 +++++++++ api/api.c | 5 +++++ cmd/boot.c | 5 +++++ cmd/elf.c | 8 +++++++- common/Kconfig | 9 +++++++++ include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 api/Kconfig
Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>