Skip to contentSkip to conversation

Add FreeBSD kconfig options

PATCH Superseded Emmanuel Vadot 4 participants 15 messages Jan 26, 2017 – Jan 28, 2017

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 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 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 (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

 Kconfig                         |  2 ++
 api/Kconfig                     |  9 +++++++++
 api/api.c                       |  5 +++++
 cmd/boot.c                      |  4 ++++
 cmd/elf.c                       |  5 +++++
 common/Kconfig                  |  9 +++++++++
 include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
 7 files changed, 66 insertions(+)
 create mode 100644 api/Kconfig
Signature · 1 line
2.11.0
#1 lore raw

PATCH v3 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
index cb19ce6f87..2073d933d9 100644
@@ -307,6 +307,8 @@ config ARCH_FIXUP_FDT_MEMORY
 
 endmenu		# Boot images
 
+source "api/Kconfig"
+
 source "common/Kconfig"
 
 source "cmd/Kconfig"
api/Kconfig new file +9 -0
new file mode 100644
index 0000000000..16731d3b4b
@@ -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
#2 lore raw

PATCH v3 1/4 kconfig: Add API kconfig file

Am 26.01.2017 um 17:46 schrieb Emmanuel Vadot:

Quoted 8 lines

Add kconfig file to enable API support

---
 Kconfig     | 2 ++
 api/Kconfig | 9 +++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 api/Kconfig

No patch in this series updates the two boards Tom pointed out.

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)
#3 lore raw

PATCH v3 1/4 kconfig: Add API kconfig file

Quoted 10 lines · On Thu, 26 Jan 2017 18:17:47 +0100 Andreas F?rber <[email protected]> wrote:

Am 26.01.2017 um 17:46 schrieb Emmanuel Vadot:

Quoted 8 lines

Add kconfig file to enable API support

---
 Kconfig     | 2 ++
 api/Kconfig | 9 +++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 api/Kconfig
Quoted 4 lines

No patch in this series updates the two boards Tom pointed out.

Regards,
Andreas

Once CONFIG_API is available I'll update the two boards. I don't think it make sense to convert them in the same patch series
for FreeBSD.

Cheers,

Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
#4 lore raw

PATCH v3 1/4 kconfig: Add API kconfig file

Am 26.01.2017 um 18:45 schrieb Emmanuel Vadot:

Quoted 13 lines
Quoted 10 lines · On Thu, 26 Jan 2017 18:17:47 +0100 Andreas F?rber <[email protected]> wrote:

Am 26.01.2017 um 17:46 schrieb Emmanuel Vadot:

Quoted 8 lines

Add kconfig file to enable API support

---
 Kconfig     | 2 ++
 api/Kconfig | 9 +++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 api/Kconfig
Quoted 3 lines
Quoted 1 line

No patch in this series updates the two boards Tom pointed out.

Once CONFIG_API is available I'll update the two boards.

Unless I'm misreading something, it is available since this patch.

Quoted 2 lines

I don't think it make sense to convert them in the same patch series
for FreeBSD.

Personally I would expect this to be done in this patch that converts the pre-existing option. It's really small as is and so are the requested cleanups. (This patch/commit does not mention FreeBSD once, and, once merged, Git history will not tell what patchset it came from.)

Cheers,
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)
#5 lore raw

PATCH v3 1/4 kconfig: Add API kconfig file

Quoted 20 lines · Andreas F?rber

Am 26.01.2017 um 18:45 schrieb Emmanuel Vadot:

Quoted 13 lines
Quoted 10 lines · On Thu, 26 Jan 2017 18:17:47 +0100 Andreas F?rber <[email protected]> wrote:

Am 26.01.2017 um 17:46 schrieb Emmanuel Vadot:

Quoted 8 lines

Add kconfig file to enable API support

---
 Kconfig     | 2 ++
 api/Kconfig | 9 +++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 api/Kconfig
Quoted 3 lines
Quoted 1 line

No patch in this series updates the two boards Tom pointed out.

Once CONFIG_API is available I'll update the two boards.

Unless I'm misreading something, it is available since this patch.

Quoted 7 lines
Quoted 2 lines

I don't think it make sense to convert them in the same patch series
for FreeBSD.

Personally I would expect this to be done in this patch that converts the pre-existing option. It's really small as is and so are the requested cleanups. (This patch/commit does not mention FreeBSD once, and, once merged, Git history will not tell what patchset it came from.)

Right. The expectation would be that since this patch introduces API into Kconfig, and it's a really easy conversion, we convert the two boards in question as well. If it doesn't apply cleanly when I'm applying it's easy enough that I'll just fix it. 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/20170126/0ba5c4b0/attachment.sig>
#6 lore raw

PATCH v3 2/4 kconfig: Add a FREEBSD option

In reply to Emmanuel Vadot

Add a FreeBSD option that enables the API and the data cache command as both are needed to boot the FreeBSD loader.

---
 common/Kconfig | 9 +++++++++
 1 file changed, 9 insertions(+)
common/Kconfig +9 -0
index 9067d1e277..2fe19d354b 100644
@@ -430,4 +430,13 @@ config BOARD_EARLY_INIT_F
 
 endmenu
 
+config FREEBSD
+	bool "Enable FreeBSD boot"
+	select API
+	select CMD_CACHE
+	default n
+	help
+	  This options adds boot configuration that can run the FreeBSD
+	  loader.
+
 source "common/spl/Kconfig"
Signature · 1 line
2.11.0
#7 lore raw

PATCH v3 2/4 kconfig: Add a FREEBSD option

Quoted 13 lines · Emmanuel Vadot

Add a FreeBSD option that enables the API and the data cache command as both are needed to boot the FreeBSD loader.

---
  common/Kconfig | 9 +++++++++
  1 file changed, 9 insertions(+)
common/Kconfig +0 -0
index 9067d1e277..2fe19d354b 100644

common/Kconfig config BOARD_EARLY_INIT_F · line 439

Quoted 10 lines
common/Kconfig +7 -0
@@ -430,4 +430,13 @@ config BOARD_EARLY_INIT_F
 
  endmenu
 
+config FREEBSD
+	bool "Enable FreeBSD boot"
+	select API
+	select CMD_CACHE
+	default n
+	help
+	  This options adds boot configuration that can run the FreeBSD

The help text should be more descriptive and actually tell users what the option really does. Since the only thing CONFIG_FREEBSD does now is to enable distro boot support for it, maybe even rename the the option into CONFIG_DISTRO_FREEBSD.

Alex

#8 lore raw

PATCH v3 2/4 kconfig: Add a FREEBSD option

Quoted 17 lines · On Thu, 26 Jan 2017 18:08:49 +0100 Alexander Graf <[email protected]> wrote:
Quoted 16 lines · Emmanuel Vadot

Add a FreeBSD option that enables the API and the data cache command as both are needed to boot the FreeBSD loader.

---
  common/Kconfig | 9 +++++++++
  1 file changed, 9 insertions(+)
common/Kconfig +0 -0
index 9067d1e277..2fe19d354b 100644
@@ -430,4 +430,13 @@ config BOARD_EARLY_INIT_F
 
  endmenu
 
Quoted 10 lines

common/Kconfig config BOARD_EARLY_INIT_F · line 439

Quoted 7 lines
common/Kconfig +7 -0
+config FREEBSD
+	bool "Enable FreeBSD boot"
+	select API
+	select CMD_CACHE
+	default n
+	help
+	  This options adds boot configuration that can run the FreeBSD

The help text should be more descriptive and actually tell users what the option really does.

Ok will do that.

Quoted 3 lines

Since the only thing CONFIG_FREEBSD does now is
to enable distro boot support for it, maybe even rename the the option into CONFIG_DISTRO_FREEBSD.

We might want to support uImage/FIT at one point (I'm currently
looking at this) so CONFIG_FREEBSD will make more sense. But we can rename the option later if needed, I don't know which way is better.

Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
#9 lore raw

PATCH v3 2/4 kconfig: Add a FREEBSD option

Quoted 29 lines · Emmanuel Vadot
Quoted 17 lines · On Thu, 26 Jan 2017 18:08:49 +0100 Alexander Graf <[email protected]> wrote:
Quoted 16 lines · Emmanuel Vadot

Add a FreeBSD option that enables the API and the data cache command as both are needed to boot the FreeBSD loader.

---
   common/Kconfig | 9 +++++++++
   1 file changed, 9 insertions(+)
common/Kconfig +0 -0
index 9067d1e277..2fe19d354b 100644
@@ -430,4 +430,13 @@ config BOARD_EARLY_INIT_F
 
   endmenu
 
Quoted 9 lines

common/Kconfig config BOARD_EARLY_INIT_F · line 439

Quoted 7 lines
common/Kconfig +7 -0
+config FREEBSD
+	bool "Enable FreeBSD boot"
+	select API
+	select CMD_CACHE
+	default n
+	help
+	  This options adds boot configuration that can run the FreeBSD

The help text should be more descriptive and actually tell users what the option really does.

Quoted 8 lines

Ok will do that.

Quoted 3 lines

Since the only thing CONFIG_FREEBSD does now is
to enable distro boot support for it, maybe even rename the the option into CONFIG_DISTRO_FREEBSD.

We might want to support uImage/FIT at one point (I'm currently
looking at this) so CONFIG_FREEBSD will make more sense. But we can rename the option later if needed, I don't know which way is better.

What do you need to change for uImage / FIT support? Does that have to be conditionalized?

Alex

#10 lore raw

PATCH v3 2/4 kconfig: Add a FREEBSD option

Am 26.01.2017 um 18:53 schrieb Alexander Graf:

Quoted 33 lines · Emmanuel Vadot
Quoted 32 lines
Quoted 9 lines · On Thu, 26 Jan 2017 18:08:49 +0100 Alexander Graf <[email protected]> wrote:
Quoted 8 lines · Emmanuel Vadot

Add a FreeBSD option that enables the API and the data cache command as both are needed to boot the FreeBSD loader.

---
   common/Kconfig | 9 +++++++++
   1 file changed, 9 insertions(+)
Quoted 15 lines

common/Kconfig config BOARD_EARLY_INIT_F · line 437

Quoted 13 lines
common/Kconfig +6 -0
index 9067d1e277..2fe19d354b 100644
@@ -430,4 +430,13 @@ config BOARD_EARLY_INIT_F
      endmenu
   +config FREEBSD
+    bool "Enable FreeBSD boot"
+    select API
+    select CMD_CACHE
+    default n
+    help
+      This options adds boot configuration that can run the FreeBSD

The help text should be more descriptive and actually tell users what the option really does.

Ok will do that.

Quoted 3 lines

Since the only thing CONFIG_FREEBSD does now is
to enable distro boot support for it, maybe even rename the the option into CONFIG_DISTRO_FREEBSD.

Quoted 6 lines
Quoted 3 lines

We might want to support uImage/FIT at one point (I'm currently
looking at this) so CONFIG_FREEBSD will make more sense. But we can rename the option later if needed, I don't know which way is better.

What do you need to change for uImage / FIT support? Does that have to be conditionalized?

Or going further, is there a strict reason the distro changes need to be conditionalized at all? As long as they're properly guarded with checks for file existence it would only cost little boot time on a Linux system.

If you think of systems where you place U-Boot onto the SD card along your OS code then for sure it's possible for FreeBSD to enable this CONFIG_FREEBSD option during its build; but if you think of devices where U-Boot is in flash then it seems weird to flash different U-Boot variants dependent on what operating system you plan to run.

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)
#12 lore raw

PATCH v3 3/4 api: FreeBSD: flush cache before starting

In reply to 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.

---
 api/api.c  | 5 +++++
 cmd/boot.c | 4 ++++
 cmd/elf.c  | 5 +++++
 3 files changed, 14 insertions(+)
api/api.c +5 -0
index c368511704..88b5df77c0 100644
@@ -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
index 72f2cf362d..b66ae67fcb 100644
@@ -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
index e4c6535111..e98a798203 100644
@@ -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
#13 lore raw

PATCH v3 3/4 api: FreeBSD: flush cache before starting

Quoted 6 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.

This could probably be expanded to note that in general it's just always a good idea to flush icache/dcache prior to running whatever we're about to run. This isn't so much a FreeBSD thing as a generic thing.

Quoted 1 line
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/20170128/8d7e2301/attachment.sig>
#14 lore raw

PATCH v3 4/4 distro_bootcmd: Add command to run FreeBSD

In reply to 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.

---
 include/config_distro_bootcmd.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
include/config_distro_bootcmd.h +32 -0
index 9ecaf38a33..0f5d38534a 100644
@@ -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