Handoff bloblist from previous boot stage
v3 cover Handoff bloblist from previous boot stage
This patch set depends on another series:
"[PATCH v3 00/14] Support Firmware Handoff spec via bloblist".
This patch set implements Qemu-Arm platform custom functions to retrieve the bloblist (aka. Transfer List) from previous loader via boot arguments when CONFIG_OF_BOARD option is enabled and all boot arguments are compliant to the register conventions defined in the Firmware Handoff spec v0.9.
Qemu-Arm platform custom function will load the FDT from the bloblist if it exists.
Otherwise it fallbacks to get the FDT from the specified memory address.
If a platform vendor wish to have different behaviors for loading bloblist or FDT from the previous boot stage, it is required to implement the custom functions board_bloblist_from_boot_arg() and board_fdt_blob_setup().
Raymond Mao (9):
bloblist: add API to check the register conventions
bloblist: check bloblist with specified buffer size
bloblist: refactor of bloblist_reloc()
arm: armv7: save boot arguments
arm: armv8: save boot arguments
qemu-arm: Get bloblist from boot arguments
bloblist: Load the bloblist from the previous loader
fdt: update the document and Kconfig description
qemu-arm: get FDT from bloblist
arch/arm/cpu/armv7/start.S | 13 ++++++ arch/arm/cpu/armv8/start.S | 14 ++++++ board/emulation/qemu-arm/qemu-arm.c | 42 ++++++++++++++++- common/bloblist.c | 72 ++++++++++++++++++++--------- common/board_f.c | 8 +--- configs/qemu_arm64_defconfig | 3 ++ doc/develop/devicetree/control.rst | 6 +-- dts/Kconfig | 7 ++- include/bloblist.h | 36 +++++++++++++-- test/bloblist.c | 8 ++-- 10 files changed, 166 insertions(+), 43 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/9 bloblist: add API to check the register conventions
Add bloblist_check_reg_conv() to check whether the bloblist is compliant to the register conventions defined in Firmware Handoff specification. This API can be used for all Arm platforms.
---
Changes in v2
- Refactor of bloblist_check_reg_conv().
Changes in v3
- bloblist_check_reg_conv() returns -ENOENT if OF_BOARD is disabled.
common/bloblist.c | 13 +++++++++++++ include/bloblist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+)
common/bloblist.c +13 -0
@@ -542,3 +542,16 @@ int bloblist_maybe_init(void)return 0 ; } + +int bloblist_check_reg_conv (ulong rfdt,ulong rzero) +{ +if (!IS_ENABLED (CONFIG_OF_BOARD )) +return -ENOENT ; + +if (rzero || rfdt != (ulong )bloblist_find (BLOBLISTT_CONTROL_FDT ,0 )) { + gd->bloblist =NULL ;/* Reset the gd bloblist pointer */ +return -EIO ; + } + +return 0 ; +}
include/bloblist.h +12 -0
@@ -461,4 +461,16 @@ static inline int bloblist_maybe_init(void) }#endif /* BLOBLIST */ +/** +* bloblist_check_reg_conv() - Check whether the bloblist is compliant to +* the register conventions according to the +* Firmware Handoff spec. +* +* @rfdt: Register that holds the FDT base address. +* @rzero: Register that must be zero. +* Return: 0 if OK, -EIO if the bloblist is not compliant to the register +* conventions, -ENOENT if OF_BOARD is disabled. +*/ +int bloblist_check_reg_conv (ulong rfdt,ulong rzero); +#endif /* __BLOBLIST_H */
Signature · 1 line
2.25.1
Re: [PATCH v3 1/9] bloblist: add API to check the register conventions
Hi Raymond,
Quoted 24 lines · Raymond Mao
Add
bloblist_check_reg_conv()to check whether the bloblist is compliant to the register conventions defined in Firmware Handoff specification. This API can be used for all Arm platforms.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofbloblist_check_reg_conv().
Changes in v3
-bloblist_check_reg_conv()returns-ENOENTifOF_BOARDis disabled.common/bloblist.c | 13 +++++++++++++ include/bloblist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+)common/bloblist.c +0
-0@@ -542,3 +542,16 @@ int bloblist_maybe_init(void)return 0 ; }
common/bloblist.c int bloblist_maybe_init(void) · line 554
Quoted 10 lines
common/bloblist.c +10
-0+ +int bloblist_check_reg_conv (ulong rfdt,ulong rzero) +{ +if (!IS_ENABLED (CONFIG_OF_BOARD )) +return -ENOENT ; + +if (rzero || rfdt != (ulong )bloblist_find (BLOBLISTT_CONTROL_FDT ,0 )) { + gd->bloblist =NULL ;/* Reset the gd bloblist pointer */ +return -EIO ; + }
Where does the magic 4a0fb10b value get checked?
Quoted 25 lines
common/bloblist.c +3
-0+ +return 0 ; +}include/bloblist.h +12
-1@@ -461,4 +461,16 @@ static inline int bloblist_maybe_init(void) }#endif /* BLOBLIST */ +/** +* bloblist_check_reg_conv() - Check whether the bloblist is compliant to +* the register conventions according to the +* Firmware Handoff spec. +* +* @rfdt: Register that holds the FDT base address. +* @rzero: Register that must be zero. +* Return: 0 if OK, -EIO if the bloblist is not compliant to the register +* conventions, -ENOENT if OF_BOARD is disabled. +*/ +int bloblist_check_reg_conv (ulong rfdt,ulong rzero); +#endif /* __BLOBLIST_H */ --
Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH v3 1/9] bloblist: add API to check the register conventions
Hi Simon,
Quoted 36 lines · Simon Glass
Hi Raymond,
Quoted 21 lines · Raymond Mao
Add
bloblist_check_reg_conv()to check whether the bloblist is compliant to the register conventions defined in Firmware Handoff specification. This API can be used for all Arm platforms.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofbloblist_check_reg_conv().
Changes in v3
-bloblist_check_reg_conv()returns-ENOENTifOF_BOARDis disabled.common/bloblist.c | 13 +++++++++++++ include/bloblist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+)common/bloblist.c +0
-0common/bloblist.c int bloblist_maybe_init(void) · line 551
Quoted 10 lines
common/bloblist.c +7
-0@@ -542,3 +542,16 @@ int bloblist_maybe_init(void) return 0; } + +int bloblist_check_reg_conv(ulong rfdt, ulong rzero) +{ + if (!IS_ENABLED(CONFIG_OF_BOARD)) + return -ENOENT; + + if (rzero || rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT,0)) {
Quoted 7 lines
common/bloblist.c int bloblist_maybe_init(void) · line 554
Quoted 3 lines
common/bloblist.c +3
-0+ gd->bloblist =NULL ;/* Reset the gd bloblist pointer */ +return -EIO ; + }Where does the magic
4a0fb10bvalue get checked?The magic and version of register conventions cannot be checked now since
there is
a bug in the spec. PSB:
``` X1[23:0]: set to the TL signature (4a0f_b10b) X1[31:24]: version of the register convention used. Set to 1 for the AArch64 convention specified in this document. ```
Signature (4a0f_b10b) takes all [31:0] and no space for version of the register convention.
This needs to be updated on TF-A and OP-TEE as well after the spec is updated.
For now I will just skip the checking.
[...]
Regards,
Raymond
Re: [PATCH v3 1/9] bloblist: add API to check the register conventions
Hi Raymond,
Quoted 45 lines · Raymond Mao
Hi Simon,
Quoted 26 lines · Simon Glass
Hi Raymond,
Quoted 22 lines · Raymond Mao
Add
bloblist_check_reg_conv()to check whether the bloblist is compliant to the register conventions defined in Firmware Handoff specification. This API can be used for all Arm platforms.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofbloblist_check_reg_conv().
Changes in v3
-bloblist_check_reg_conv()returns-ENOENTifOF_BOARDis disabled.common/bloblist.c | 13 +++++++++++++ include/bloblist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+)common/bloblist.c +0
-0@@ -542,3 +542,16 @@ int bloblist_maybe_init(void)Quoted 15 lines
common/bloblist.c int bloblist_maybe_init(void) · line 554
Quoted 12 lines
common/bloblist.c +10
-0return 0 ; } + +int bloblist_check_reg_conv (ulong rfdt,ulong rzero) +{ +if (!IS_ENABLED (CONFIG_OF_BOARD )) +return -ENOENT ; + +if (rzero || rfdt != (ulong )bloblist_find (BLOBLISTT_CONTROL_FDT ,0 )) { + gd->bloblist =NULL ;/* Reset the gd bloblist pointer */ +return -EIO ; + }Where does the magic
4a0fb10bvalue get checked?
Quoted 4 lines
The magic and version of register conventions cannot be checked now since there is a bug in the spec. PSB:
```
X1[23:0]: set to the TL signature (4a0f_b10b)
That should say 0f_b10b
Quoted 5 lines
X1[31:24]: version of the register convention used. Set to 1 for the AArch64 convention specified in this document. ```
Signature (4a0f_b10b) takes all [31:0] and no space for version of the register convention.
This needs to be updated on TF-A and OP-TEE as well after the spec is updated.
For now I will just skip the checking.
We should fix the spec instead.
Regards,
Simon
Re: [PATCH v3 1/9] bloblist: add API to check the register conventions
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Raymond,
Quoted 8 lines · Raymond Mao
Hi Simon,
Quoted 4 lines · Simon Glass
Hi Raymond,
On Fri, Dec 22, 2023 at 9:31 PM Raymond Mao <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Add
bloblist_check_reg_conv()to check whether the bloblist iscompliant
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
to the register conventions defined in Firmware Handoff specification. This API can be used for all Arm platforms.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofbloblist_check_reg_conv().
Changes in v3
-bloblist_check_reg_conv()returns-ENOENTifOF_BOARDis disabled.common/bloblist.c | 13 +++++++++++++ include/bloblist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+)common/bloblist.c +0
-0@@ -542,3 +542,16 @@ int bloblist_maybe_init(void)Quoted 9 lines
Quoted 9 lines
common/bloblist.c int bloblist_maybe_init(void)
Quoted 9 lines
common/bloblist.c +7
-0return 0 ; } + +int bloblist_check_reg_conv(ulong rfdt, ulong rzero) +{ + if (!IS_ENABLED(CONFIG_OF_BOARD)) + return -ENOENT; + + if (rzero || rfdt !=(ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) {
Quoted 1 line
Quoted 1 line
common/bloblist.c int bloblist_maybe_init(void) · line 552
Quoted 1 line
common/bloblist.c +1
-0+ gd->bloblist =NULL ;/* Reset the gd bloblist pointer */
Quoted 6 lines
Quoted 5 lines
common/bloblist.c int bloblist_maybe_init(void) · line 554
Quoted 2 lines
common/bloblist.c +2
-0+return -EIO ; + }Where does the magic
4a0fb10bvalue get checked?The magic and version of register conventions cannot be checked now
Quoted 8 lines
since there is
Quoted 3 lines
a bug in the spec. PSB:
```
X1[23:0]: set to the TL signature (4a0f_b10b)That should say 0f_b10b
However, currently we have switched to
4a0f_b10bin both TF-A and OP-TEE.
I don't want to break the dataflow that is currently working. I prefer to make patches to TF-A, OP-TEE and U-Boot at the same time when spec v1.0 is ready.
[...]
Thanks and regards,
Raymond
Re: [PATCH v3 1/9] bloblist: add API to check the register conventions
Hi Raymond,
Quoted 58 lines · Raymond Mao
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Raymond,
Quoted 49 lines · Raymond Mao
Hi Simon,
Quoted 26 lines · Simon Glass
Hi Raymond,
Quoted 22 lines · Raymond Mao
Add
bloblist_check_reg_conv()to check whether the bloblist is compliant to the register conventions defined in Firmware Handoff specification. This API can be used for all Arm platforms.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofbloblist_check_reg_conv().
Changes in v3
-bloblist_check_reg_conv()returns-ENOENTifOF_BOARDis disabled.common/bloblist.c | 13 +++++++++++++ include/bloblist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+)common/bloblist.c +0
-0@@ -542,3 +542,16 @@ int bloblist_maybe_init(void)Quoted 15 lines
common/bloblist.c int bloblist_maybe_init(void) · line 554
Quoted 12 lines
common/bloblist.c +10
-0return 0 ; } + +int bloblist_check_reg_conv (ulong rfdt,ulong rzero) +{ +if (!IS_ENABLED (CONFIG_OF_BOARD )) +return -ENOENT ; + +if (rzero || rfdt != (ulong )bloblist_find (BLOBLISTT_CONTROL_FDT ,0 )) { + gd->bloblist =NULL ;/* Reset the gd bloblist pointer */ +return -EIO ; + }Where does the magic
4a0fb10bvalue get checked?The magic and version of register conventions cannot be checked now since there is a bug in the spec. PSB:
```
X1[23:0]: set to the TL signature (4a0f_b10b)
Quoted 5 lines
Quoted 2 lines
That should say 0f_b10b
However, currently we have switched to
4a0f_b10bin both TF-A and OP-TEE.
I don't want to break the dataflow that is currently working.
I prefer to make patches to TF-A, OP-TEE and U-Boot at the same time when spec v1.0 is ready.
Yes, sure, but we should fix them too!
Quoted 5 lines
[...]
Thanks and regards,
Raymond
Regards,
Simon
PATCH v3 2/9 bloblist: check bloblist with specified buffer size
In reply to Raymond MaoInstead of expecting the bloblist total size to be the same as the pre-allocated buffer size, practically we are more interested in whether the pre-allocated buffer size is bigger than the bloblist total size.
---
Changes in v2
- New patch file created for v2.
common/bloblist.c | 2 +- test/bloblist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
common/bloblist.c +1 -1
@@ -384,7 +384,7 @@ int bloblist_check(ulong addr, uint size)return log_msg_ret ("Bad magic" , -ENOENT );if (hdr->version !=BLOBLIST_VERSION )return log_msg_ret ("Bad version" , -EPROTONOSUPPORT ); -if (!hdr->total_size || (size && hdr->total_size != size)) +if (!hdr->total_size || (size && hdr->total_size > size))return log_msg_ret ("Bad total size" , -EFBIG );if (hdr->used_size > hdr->total_size)return log_msg_ret ("Bad used size" , -ENOENT );
test/bloblist.c +1 -1
@@ -207,7 +207,7 @@ static int bloblist_test_checksum(struct unit_test_state *uts) hdr->flags++; hdr->total_size--; -ut_asserteq (-EFBIG ,bloblist_check (TEST_ADDR ,TEST_BLOBLIST_SIZE )); +ut_asserteq (-EIO ,bloblist_check (TEST_ADDR ,TEST_BLOBLIST_SIZE )); hdr->total_size++; hdr->spare++;
Signature · 1 line
2.25.1
Re: [PATCH v3 2/9] bloblist: check bloblist with specified buffer size
Hi Raymond,
common/bloblist.c int bloblist_check(ulong addr, uint size)
Quoted 21 lines · Raymond Mao
Instead of expecting the bloblist total size to be the same as the pre-allocated buffer size, practically we are more interested in whether the pre-allocated buffer size is bigger than the bloblist total size.
Signed-off-by Raymond Mao <[email protected]>Reviewed-by Ilias Apalodimas <[email protected]>---
Changes in v2
- New patch file created for v2.common/bloblist.c | 2 +- test/bloblist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)common/bloblist.c +0
-0@@ -384,7 +384,7 @@ int bloblist_check(ulong addr, uint size)
Can you please also update the function comment for bloblist_check() ?
Quoted 22 lines
common/bloblist.c +1
-1return log_msg_ret ("Bad magic" , -ENOENT );if (hdr->version !=BLOBLIST_VERSION )return log_msg_ret ("Bad version" , -EPROTONOSUPPORT ); -if (!hdr->total_size || (size && hdr->total_size != size)) +if (!hdr->total_size || (size && hdr->total_size > size))return log_msg_ret ("Bad total size" , -EFBIG );if (hdr->used_size > hdr->total_size)return log_msg_ret ("Bad used size" , -ENOENT );test/bloblist.c +1
-2@@ -207,7 +207,7 @@ static int bloblist_test_checksum(struct unit_test_state *uts) hdr->flags++; hdr->total_size--; -ut_asserteq (-EFBIG ,bloblist_check (TEST_ADDR ,TEST_BLOBLIST_SIZE )); +ut_asserteq (-EIO ,bloblist_check (TEST_ADDR ,TEST_BLOBLIST_SIZE )); hdr->total_size++; hdr->spare++; --
Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH v3 2/9] bloblist: check bloblist with specified buffer size
Hi Simon,
Quoted 28 lines · Simon Glass
Hi Raymond,
common/bloblist.c int bloblist_check(ulong addr, uint size)
Quoted 21 lines · Raymond Mao
Instead of expecting the bloblist total size to be the same as the pre-allocated buffer size, practically we are more interested in whether the pre-allocated buffer size is bigger than the bloblist total size.
Signed-off-by Raymond Mao <[email protected]>Reviewed-by Ilias Apalodimas <[email protected]>---
Changes in v2
- New patch file created for v2.common/bloblist.c | 2 +- test/bloblist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)common/bloblist.c +0
-0@@ -384,7 +384,7 @@ int bloblist_check(ulong addr, uint size)Can you please also update the function comment for
bloblist_check()?
Quoted 1 line
Yes. I will update it.
[...]
Regards,
Raymond
PATCH v3 3/9 bloblist: refactor of bloblist_reloc()
In reply to Raymond MaoThe current bloblist pointer and size can be retrieved from global data, so we don't need to pass them from the function arguments. This change also help to remove all external access of gd->bloblist outside of bloblist module.
---
Changes in v2
- New patch file created for v2.
Changes in v3
- Check the space size before copying the bloblist.
- Add return code of bloblist_reloc().
common/bloblist.c | 10 ++++++++-- common/board_f.c | 8 ++------ include/bloblist.h | 8 ++++---- test/bloblist.c | 6 ++---- 4 files changed, 16 insertions(+), 16 deletions(-)
common/bloblist.c +8 -2
@@ -472,13 +472,19 @@ void bloblist_show_list(void) } } -void bloblist_reloc (void *to,uint to_size,void *from,uint from_size) +int bloblist_reloc (void *to,uint to_size) {struct bloblist_hdr *hdr; -memcpy (to, from, from_size); +if (to_size < gd->bloblist->total_size) +return -ENOSPC ; + +memcpy (to, gd->bloblist, gd->bloblist->total_size); hdr = to; hdr->total_size = to_size; + gd->bloblist = to; + +return 0 ; }int bloblist_init (void )
common/board_f.c +2 -6
@@ -676,13 +676,9 @@ static int reloc_bloblist(void) return 0; }if (gd->new_bloblist) { -int size =CONFIG_BLOBLIST_SIZE ; -debug ("Copying bloblist from %p to %p, size %x\n" , - gd->bloblist, gd->new_bloblist, size); -bloblist_reloc (gd->new_bloblist,CONFIG_BLOBLIST_SIZE_RELOC , - gd->bloblist, size); - gd->bloblist = gd->new_bloblist; + gd->bloblist, gd->new_bloblist, gd->bloblist->total_size); +bloblist_reloc (gd->new_bloblist,CONFIG_BLOBLIST_SIZE_RELOC ); }#endif
include/bloblist.h +4 -4
@@ -418,11 +418,11 @@ const char *bloblist_tag_name(enum bloblist_tag_t tag);* bloblist_reloc() - Relocate the bloblist and optionally resize it * * @to: Pointer to new bloblist location (must not overlap old location) -* @to_size: New size for bloblist (must be larger than from_size) -* @from: Pointer to bloblist to relocate -* @from_size: Size of bloblist to relocate +* @to_size: New size for bloblist +* Return: 0 if OK, -ENOSPC if the new size is small than the bloblist total +* size. */ -void bloblist_reloc (void *to,uint to_size,void *from,uint from_size); +int bloblist_reloc (void *to,uint to_size);/** * bloblist_init() - Init the bloblist system with a single bloblist
test/bloblist.c +2 -4
@@ -376,13 +376,12 @@ static int bloblist_test_reloc(struct unit_test_state *uts) {const uint large_size =TEST_BLOBLIST_SIZE ;const uint small_size =0x20 ; -void *old_ptr, *new_ptr; +void *new_ptr;void *blob1, *blob2;ulong new_addr;ulong new_size;ut_assertok (bloblist_new (TEST_ADDR ,TEST_BLOBLIST_SIZE ,0 ,0 )); - old_ptr =map_sysmem (TEST_ADDR ,TEST_BLOBLIST_SIZE );/* Add one blob and then one that won't fit */ blob1 =bloblist_add (TEST_TAG , small_size,0 );
@@ -394,8 +393,7 @@ static int bloblist_test_reloc(struct unit_test_state *uts) new_addr =TEST_ADDR +TEST_BLOBLIST_SIZE ; new_size =TEST_BLOBLIST_SIZE +0x100 ; new_ptr =map_sysmem (new_addr,TEST_BLOBLIST_SIZE ); -bloblist_reloc (new_ptr, new_size, old_ptr,TEST_BLOBLIST_SIZE ); - gd->bloblist = new_ptr; +ut_assertok (bloblist_reloc (new_ptr, new_size));/* Check the old blob is there and that we can now add the bigger one */ ut_assertnonnull (bloblist_find (TEST_TAG , small_size));
Signature · 1 line
2.25.1
Re: [PATCH v3 3/9] bloblist: refactor of bloblist_reloc()
Quoted 14 lines · Raymond Mao
The current bloblist pointer and size can be retrieved from global data, so we don't need to pass them from the function arguments. This change also help to remove all external access of
gd->bloblistoutside of bloblist module.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Check the space size before copying the bloblist.
- Add return code ofbloblist_reloc().
Quoted 5 lines
common/bloblist.c | 10 ++++++++-- common/board_f.c | 8 ++------ include/bloblist.h | 8 ++++---- test/bloblist.c | 6 ++---- 4 files changed, 16 insertions(+), 16 deletions(-)
Re: [PATCH v3 3/9] bloblist: refactor of bloblist_reloc()
In reply to Raymond MaoHi Raymond
Quoted 53 lines · Raymond Mao
The current bloblist pointer and size can be retrieved from global data, so we don't need to pass them from the function arguments. This change also help to remove all external access of
gd->bloblistoutside of bloblist module.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Check the space size before copying the bloblist.
- Add return code ofbloblist_reloc().common/bloblist.c | 10 ++++++++-- common/board_f.c | 8 ++------ include/bloblist.h | 8 ++++---- test/bloblist.c | 6 ++---- 4 files changed, 16 insertions(+), 16 deletions(-)common/bloblist.c +8
-2@@ -472,13 +472,19 @@ void bloblist_show_list(void) } } -void bloblist_reloc (void *to,uint to_size,void *from,uint from_size) +int bloblist_reloc (void *to,uint to_size) {struct bloblist_hdr *hdr; -memcpy (to, from, from_size); +if (to_size < gd->bloblist->total_size) +return -ENOSPC ; + +memcpy (to, gd->bloblist, gd->bloblist->total_size); hdr = to; hdr->total_size = to_size; + gd->bloblist = to; + +return 0 ; }int bloblist_init (void )common/board_f.c +0
-0@@ -676,13 +676,9 @@ static int reloc_bloblist(void)return 0 ; }
common/board_f.c static int reloc_bloblist(void) · line 681
Quoted 10 lines
common/board_f.c +2
-6if (gd->new_bloblist) { -int size =CONFIG_BLOBLIST_SIZE ; -debug ("Copying bloblist from %p to %p, size %x\n" , - gd->bloblist, gd->new_bloblist, size); -bloblist_reloc (gd->new_bloblist,CONFIG_BLOBLIST_SIZE_RELOC , - gd->bloblist, size); - gd->bloblist = gd->new_bloblist; + gd->bloblist, gd->new_bloblist, gd->bloblist->total_size); +bloblist_reloc (gd->new_bloblist,CONFIG_BLOBLIST_SIZE_RELOC );
Why aren't we checking bloblist_reloc() for an error?
common/board_f.c static int reloc_bloblist(void) · line 684
Quoted 3 lines
common/board_f.c +0
-0}#endif
[...]
Thanks
/Ilias
Re: [PATCH v3 3/9] bloblist: refactor of bloblist_reloc()
Hi Ilias,
Quoted 66 lines · Ilias Apalodimas
Hi Raymond
Quoted 51 lines · Raymond Mao
The current bloblist pointer and size can be retrieved from global data, so we don't need to pass them from the function arguments. This change also help to remove all external access of
gd->bloblistoutside of bloblist module.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Check the space size before copying the bloblist.
- Add return code ofbloblist_reloc().common/bloblist.c | 10 ++++++++-- common/board_f.c | 8 ++------ include/bloblist.h | 8 ++++---- test/bloblist.c | 6 ++---- 4 files changed, 16 insertions(+), 16 deletions(-)common/bloblist.c +8
-2@@ -472,13 +472,19 @@ void bloblist_show_list(void) } } -void bloblist_reloc (void *to,uint to_size,void *from,uint from_size) +int bloblist_reloc (void *to,uint to_size) {struct bloblist_hdr *hdr; -memcpy (to, from, from_size); +if (to_size < gd->bloblist->total_size) +return -ENOSPC ; + +memcpy (to, gd->bloblist, gd->bloblist->total_size); hdr = to; hdr->total_size = to_size; + gd->bloblist = to; + +return 0 ; }int bloblist_init (void )common/board_f.c +0
-0common/board_f.c static int reloc_bloblist(void) · line 683
Quoted 8 lines
common/board_f.c +0
-4@@ -676,13 +676,9 @@ static int reloc_bloblist(void)return 0 ; }if (gd->new_bloblist) { -int size =CONFIG_BLOBLIST_SIZE ; - debug("Copying bloblist from %p to %p, size %x\n", - gd->bloblist, gd->new_bloblist, size); - bloblist_reloc(gd->new_bloblist,
CONFIG_BLOBLIST_SIZE_RELOC,common/board_f.c static int reloc_bloblist(void)
Quoted 3 lines
common/board_f.c +1
-2- gd->bloblist, size); - gd->bloblist = gd->new_bloblist; + gd->bloblist, gd->new_bloblist,
Quoted 7 lines
gd->bloblist->total_size);common/board_f.c static int reloc_bloblist(void) · line 681
Quoted 1 line
common/board_f.c +1
-0+ bloblist_reloc(gd->new_bloblist,
CONFIG_BLOBLIST_SIZE_RELOC);Why aren't we checking
bloblist_reloc()for an error?Yes. This should be checked as well here. Will update in v4.
[...]
Regards,
Raymond
PATCH v3 4/9 arm: armv7: save boot arguments
In reply to Raymond MaoSave boot arguments r[0-3] into an array for handover of bloblist from previous boot stage.
---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.
arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm/cpu/armv7/start.S +13 -0
@@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) * *************************************************************************/ WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */ + stm r12, {r2, r1, r0, r3} +#endif b save_boot_params_ret @ back to my caller ENDPROC(save_boot_params) +.section .data +.global saved_args +saved_args: + .rept 4 + .word 0 + .endr +END(saved_args) + #ifdef CONFIG_ARMV7_LPAE WEAK(switch_to_hypervisor) b switch_to_hypervisor_ret
Signature · 1 line
2.25.1
Re: [PATCH v3 4/9] arm: armv7: save boot arguments
Hi Raymond,
Quoted 19 lines · Raymond Mao
Save boot arguments r[0-3] into an array for handover of bloblist from previous boot stage.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)arch/arm/cpu/armv7/start.S +0
-0
arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 158
Quoted 7 lines
arch/arm/cpu/armv7/start.S +4
-0@@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) * *************************************************************************/ WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */ + stm r12, {r2, r1, r0, r3}
I thought the instruction was a bitmap, so what does the 'swapping' actually change?
Quoted 16 lines
arch/arm/cpu/armv7/start.S +9
-1+#endif b save_boot_params_ret @ back to my caller ENDPROC(save_boot_params) +.section .data +.global saved_args +saved_args: + .rept 4 + .word 0 + .endr +END(saved_args) + #ifdef CONFIG_ARMV7_LPAE WEAK(switch_to_hypervisor) b switch_to_hypervisor_ret --
Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH v3 4/9] arm: armv7: save boot arguments
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Raymond,
Quoted 19 lines · Raymond Mao
Save boot arguments r[0-3] into an array for handover of bloblist from previous boot stage.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)arch/arm/cpu/armv7/start.S +0
-0arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 153
Quoted 2 lines
arch/arm/cpu/armv7/start.S +0
-0@@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) **************************************************************************/
arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 158
Quoted 5 lines
arch/arm/cpu/armv7/start.S +4
-0WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */ + stm r12, {r2, r1, r0, r3}
Quoted 4 lines
I thought the instruction was a bitmap, so what does the 'swapping' actually change?
The swapping is due to different register conventions between aarch32 and
aarch64.
Actually swapping here is to avoid the complexity of swapping this in C code.
I will update the comments here.
[...]
Regards,
Raymond
Re: [PATCH v3 4/9] arm: armv7: save boot arguments
Hi Raymond,
Quoted 38 lines · Raymond Mao
Hi Simon,
Quoted 18 lines · Simon Glass
Hi Raymond,
Quoted 14 lines · Raymond Mao
Save boot arguments r[0-3] into an array for handover of bloblist from previous boot stage.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)Quoted 16 lines
arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 158
Quoted 12 lines
arch/arm/cpu/armv7/start.S +4
-0@@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) * *************************************************************************/ WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */ + stm r12, {r2, r1, r0, r3}I thought the instruction was a bitmap, so what does the 'swapping' actually change?
Quoted 5 lines
The swapping is due to different register conventions between aarch32 and aarch64. Actually swapping here is to avoid the complexity of swapping this in C code. I will update the comments here.
[...]
But how does this work? stm does not support changing the ordering...what am I missing?
Regards,
Simon
Re: [PATCH v3 4/9] arm: armv7: save boot arguments
Hi Simon,
Quoted 46 lines · Simon Glass
Hi Raymond,
Quoted 8 lines · Raymond Mao
Hi Simon,
Quoted 4 lines · Simon Glass
Hi Raymond,
On Fri, Dec 22, 2023 at 9:31 PM Raymond Mao <[email protected]>
Quoted 14 lines · wrote:
Quoted 14 lines
Quoted 14 lines
Save boot arguments r[0-3] into an array for handover of bloblist from previous boot stage.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)Quoted 7 lines
Quoted 7 lines
arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 153
Quoted 7 lines
arch/arm/cpu/armv7/start.S +0
-0@@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) **************************************************************************/
Quoted 10 lines
Quoted 9 lines
arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 158
Quoted 5 lines
arch/arm/cpu/armv7/start.S +4
-0WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */ + stm r12, {r2, r1, r0, r3}I thought the instruction was a bitmap, so what does the 'swapping' actually change?
The swapping is due to different register conventions between aarch32
and aarch64.
Quoted 9 lines
Quoted 1 line
Actually swapping here is to avoid the complexity of swapping this in C
code.
Quoted 3 lines
I will update the comments here.
[...]
But how does this work? stm does not support changing the ordering...what am I missing?
Ah, my bad. You are right. I have to use str to store one by one in this case.
[...]
Thanks and regards,
Raymond
Re: [PATCH v3 4/9] arm: armv7: save boot arguments
In reply to Raymond MaoHi Raymond,
Quoted 19 lines · Raymond Mao
Save boot arguments r[0-3] into an array for handover of bloblist from previous boot stage.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)arch/arm/cpu/armv7/start.S +0
-0
arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 157
Quoted 6 lines
arch/arm/cpu/armv7/start.S +3
-0@@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) * *************************************************************************/ WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */
That isn't very helpful. It's obvious what the code does here. Add a comment on *why* (to keep the c function simpler etc)
Thanks
/Ilias
Quoted 19 lines
arch/arm/cpu/armv7/start.S +10
-1+ stm r12, {r2, r1, r0, r3} +#endif b save_boot_params_ret @ back to my caller ENDPROC(save_boot_params) +.section .data +.global saved_args +saved_args: + .rept 4 + .word 0 + .endr +END(saved_args) + #ifdef CONFIG_ARMV7_LPAE WEAK(switch_to_hypervisor) b switch_to_hypervisor_ret --2.25.1
Re: [PATCH v3 4/9] arm: armv7: save boot arguments
Hi Ilias and Simon,
Quoted 30 lines · Ilias Apalodimas
Hi Raymond,
Quoted 19 lines · Raymond Mao
Save boot arguments r[0-3] into an array for handover of bloblist from previous boot stage.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.arch/arm/cpu/armv7/start.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)arch/arm/cpu/armv7/start.S +0
-0arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 153
Quoted 2 lines
arch/arm/cpu/armv7/start.S +0
-0@@ -152,9 +152,22 @@ ENDPROC(c_runtime_cpu_setup) **************************************************************************/
arch/arm/cpu/armv7/start.S ENDPROC(c_runtime_cpu_setup) · line 157
Quoted 4 lines
arch/arm/cpu/armv7/start.S +3
-0WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + ldr r12, =saved_args + /* Intentionally swapping r0 with r2 */
Quoted 4 lines
That isn't very helpful. It's obvious what the code does here. Add a comment on *why* (to keep the c function simpler etc)
Yes. I will update the comment.
[...]
Regards,
Raymond
PATCH v3 5/9 arm: armv8: save boot arguments
In reply to Raymond MaoSave boot arguments x[0-3] into an array for handover of bloblist from previous boot stage.
---
Changes in v2
- New patch file created for v2.
arch/arm/cpu/armv8/start.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/cpu/armv8/start.S +14 -0
@@ -370,5 +370,19 @@ ENTRY(c_runtime_cpu_setup) ENDPROC(c_runtime_cpu_setup) WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + adr x9, saved_args + stp x0, x1, [x9] + /* Increment the address by 16 bytes for the next pair of values */ + stp x2, x3, [x9, #16] +#endif b save_boot_params_ret /* back to my caller */ ENDPROC(save_boot_params) + +.section .data +.global saved_args +saved_args: + .rept 4 + .xword 0 + .endr +END(saved_args)
Signature · 1 line
2.25.1
Re: [PATCH v3 5/9] arm: armv8: save boot arguments
Quoted 4 lines · Raymond Mao
Save boot arguments x[0-3] into an array for handover of bloblist from previous boot stage.
Quoted 8 lines
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.arch/arm/cpu/armv8/start.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/cpu/armv8/start.S ENTRY(c_runtime_cpu_setup) · line 376
Quoted 12 lines
arch/arm/cpu/armv8/start.S +4
-0@@ -370,5 +370,19 @@ ENTRY(c_runtime_cpu_setup) ENDPROC(c_runtime_cpu_setup) WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + adr x9, saved_args + stp x0, x1, [x9] + /* Increment the address by 16 bytes for the next pair of values */
That seems obvious, but I suppose a comment here is fine.
Quoted 13 lines
arch/arm/cpu/armv8/start.S +10
-1+ stp x2, x3, [x9, #16] +#endif b save_boot_params_ret /* back to my caller */ ENDPROC(save_boot_params) + +.section .data +.global saved_args +saved_args: + .rept 4 + .xword 0 + .endr +END(saved_args) --
Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH v3 5/9] arm: armv8: save boot arguments
In reply to Raymond MaoQuoted 37 lines · Raymond Mao
Save boot arguments x[0-3] into an array for handover of bloblist from previous boot stage.
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- New patch file created for v2.arch/arm/cpu/armv8/start.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/arm/cpu/armv8/start.S +14
-1@@ -370,5 +370,19 @@ ENTRY(c_runtime_cpu_setup) ENDPROC(c_runtime_cpu_setup) WEAK(save_boot_params) +#if (IS_ENABLED(CONFIG_OF_BOARD) && IS_ENABLED(CONFIG_BLOBLIST)) + adr x9, saved_args + stp x0, x1, [x9] + /* Increment the address by 16 bytes for the next pair of values */ + stp x2, x3, [x9, #16] +#endif b save_boot_params_ret /* back to my caller */ ENDPROC(save_boot_params) + +.section .data +.global saved_args +saved_args: + .rept 4 + .xword 0 + .endr +END(saved_args) --
Quoted 2 lines
2.25.1
PATCH v3 6/9 qemu-arm: Get bloblist from boot arguments
In reply to Raymond MaoAdd platform custom function to get bloblist from boot arguments. Check whether boot arguments aligns with the register conventions defined in FW Handoff spec v0.9.
Add bloblist related options into qemu default config.
---
Changes in v2
- Remove low level code for copying boot arguments.
- Refactor board_fdt_blob_setup() and remove direct access of gd->bloblist. Changes in v3
- Optimize board_bloblist_from_boot_arg().
board/emulation/qemu-arm/qemu-arm.c | 30 +++++++++++++++++++++++++++++ configs/qemu_arm64_defconfig | 3 +++ 2 files changed, 33 insertions(+)
board/emulation/qemu-arm/qemu-arm.c +30 -0
@@ -4,6 +4,7 @@*/ #include <common.h> +#include <bloblist.h> #include <cpu_func.h> #include <dm.h> #include <efi.h>
@@ -102,6 +103,15 @@ static struct mm_region qemu_arm64_mem_map[] = {struct mm_region *mem_map = qemu_arm64_mem_map;#endif +/* +* Boot parameters saved from start.S +* saved_args[0]: FDT base address +* saved_args[1]: Bloblist signature +* saved_args[2]: must be 0 +* saved_args[3]: Bloblist base address +*/ +extern unsigned long saved_args[]; +int board_init (void ) {return 0 ;
@@ -144,6 +154,26 @@ void *board_fdt_blob_setup(int *err)return (void *)CFG_SYS_SDRAM_BASE ; } +int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size) +{ +int ret = -ENOENT ; + +if (!IS_ENABLED (CONFIG_OF_BOARD ) || !IS_ENABLED (CONFIG_BLOBLIST )) +return -ENOENT ; + + ret =bloblist_check (saved_args[3 ], size); +if (ret) +return ret; + +/* Check the register conventions */ + ret =bloblist_check_reg_conv (saved_args[0 ], saved_args[2 ]); +if (!ret) +/* Relocate the bloblist to the fixed address */ + ret =bloblist_reloc ((void *)addr,CONFIG_BLOBLIST_SIZE ); + +return ret; +} +void enable_caches (void ) {icache_enable ();
configs/qemu_arm64_defconfig +3 -0
@@ -69,3 +69,6 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_PCI=y CONFIG_SEMIHOSTING=y CONFIG_TPM=y +CONFIG_BLOBLIST=y +CONFIG_BLOBLIST_ADDR=0x40004000 +CONFIG_BLOBLIST_SIZE=0x4000
Signature · 1 line
2.25.1
Re: [PATCH v3 6/9] qemu-arm: Get bloblist from boot arguments
Hi Raymond,
Quoted 50 lines · Raymond Mao
Add platform custom function to get bloblist from boot arguments. Check whether boot arguments aligns with the register conventions defined in FW Handoff spec v0.9.
Add bloblist related options into qemu default config.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Remove low level code for copying boot arguments.
- Refactorboard_fdt_blob_setup()and remove direct access ofgd->bloblist. Changes in v3
- Optimizeboard_bloblist_from_boot_arg().board/emulation/qemu-arm/qemu-arm.c | 30 +++++++++++++++++++++++++++++ configs/qemu_arm64_defconfig | 3 +++ 2 files changed, 33 insertions(+)board/emulation/qemu-arm/qemu-arm.c +10
-0@@ -4,6 +4,7 @@*/ #include <common.h> +#include <bloblist.h> #include <cpu_func.h> #include <dm.h> #include <efi.h> @@ -102,6 +103,15 @@ static struct mm_region qemu_arm64_mem_map[] = {struct mm_region *mem_map = qemu_arm64_mem_map;#endif +/* +* Boot parameters saved from start.S +* saved_args[0]: FDT base address +* saved_args[1]: Bloblist signature +* saved_args[2]: must be 0 +* saved_args[3]: Bloblist base address +*/ +extern unsigned long saved_args[]; +int board_init (void ) {return 0 ;@@ -144,6 +154,26 @@ void *board_fdt_blob_setup(int *err)return (void *)CFG_SYS_SDRAM_BASE ; }
board/emulation/qemu-arm/qemu-arm.c void *board_fdt_blob_setup(int *err) · line 166
Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10
-0+int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size) +{ +int ret = -ENOENT ; + +if (!IS_ENABLED (CONFIG_OF_BOARD ) || !IS_ENABLED (CONFIG_BLOBLIST )) +return -ENOENT ; + + ret =bloblist_check (saved_args[3 ], size); +if (ret) +return ret;
What about saved_args[1] ?
board/emulation/qemu-arm/qemu-arm.c void *board_fdt_blob_setup(int *err) · line 176
Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10
-0+ +/* Check the register conventions */ + ret =bloblist_check_reg_conv (saved_args[0 ], saved_args[2 ]); +if (!ret) +/* Relocate the bloblist to the fixed address */ + ret =bloblist_reloc ((void *)addr,CONFIG_BLOBLIST_SIZE ); + +return ret; +} +
This should be a generic function, e.g. in arch/arm
Quoted 15 lines
board/emulation/qemu-arm/qemu-arm.c +0
-0void enable_caches (void ) {icache_enable ();configs/qemu_arm64_defconfig +3
-1@@ -69,3 +69,6 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_PCI=y CONFIG_SEMIHOSTING=y CONFIG_TPM=y +CONFIG_BLOBLIST=y +CONFIG_BLOBLIST_ADDR=0x40004000 +CONFIG_BLOBLIST_SIZE=0x4000 --
Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH v3 6/9] qemu-arm: Get bloblist from boot arguments
Hi Simon,
Quoted 69 lines · Simon Glass
Hi Raymond,
Quoted 11 lines · Raymond Mao
Add platform custom function to get bloblist from boot arguments. Check whether boot arguments aligns with the register conventions defined in FW Handoff spec v0.9.
Add bloblist related options into qemu default config.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Remove low level code for copying boot arguments.
- Refactorboard_fdt_blob_setup()and remove direct access of
gd->bloblist.Review
Quoted 8 lines
Changes in v3
- Optimizeboard_bloblist_from_boot_arg().board/emulation/qemu-arm/qemu-arm.c | 30 +++++++++++++++++++++++++++++ configs/qemu_arm64_defconfig | 3 +++ 2 files changed, 33 insertions(+)(quoted diff) +0
-0
b/board/emulation/qemu-arm/qemu-arm.cQuoted 31 lines
index
942f1fff57..e225011bf0100644board/emulation/qemu-arm/qemu-arm.c +10
-0@@ -4,6 +4,7 @@*/ #include <common.h> +#include <bloblist.h> #include <cpu_func.h> #include <dm.h> #include <efi.h> @@ -102,6 +103,15 @@ static struct mm_region qemu_arm64_mem_map[] = {struct mm_region *mem_map = qemu_arm64_mem_map;#endif +/* +* Boot parameters saved from start.S +* saved_args[0]: FDT base address +* saved_args[1]: Bloblist signature +* saved_args[2]: must be 0 +* saved_args[3]: Bloblist base address +*/ +extern unsigned long saved_args[]; +int board_init (void ) {return 0 ;@@ -144,6 +154,26 @@ void *board_fdt_blob_setup(int *err)return (void *)CFG_SYS_SDRAM_BASE ; }board/emulation/qemu-arm/qemu-arm.c void *board_fdt_blob_setup(int *err) · line 166
Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10
-0+int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size) +{ +int ret = -ENOENT ; + +if (!IS_ENABLED (CONFIG_OF_BOARD ) || !IS_ENABLED (CONFIG_BLOBLIST )) +return -ENOENT ; + + ret =bloblist_check (saved_args[3 ], size); +if (ret) +return ret;What about saved_args[1] ?
Quoted 1 line
The magic and version of register conventions cannot be checked now since
there is
a bug in the spec. PSB:
``` X1[23:0]: set to the TL signature (4a0f_b10b) X1[31:24]: version of the register convention used. Set to 1 for the AArch64 convention specified in this document. ```
Signature (4a0f_b10b) takes all [31:0] and no space for version of the register convention.
This needs to be updated on TF-A and OP-TEE as well after the spec is updated.
For now I will just skip the checking.
Quoted 13 lines
board/emulation/qemu-arm/qemu-arm.c void *board_fdt_blob_setup(int *err) · line 176
Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10
-0+ +/* Check the register conventions */ + ret =bloblist_check_reg_conv (saved_args[0 ], saved_args[2 ]); +if (!ret) +/* Relocate the bloblist to the fixed address */ + ret =bloblist_reloc ((void *)addr,CONFIG_BLOBLIST_SIZE ); + +return ret; +} +This should be a generic function, e.g. in
arch/arm
Quoted 1 line
I didn't find a place under
arch/armthat is good for connect with the
saved boot
args. Do you have any suggestions?
[...]
Regards,
Raymond
Re: [PATCH v3 6/9] qemu-arm: Get bloblist from boot arguments
Hi Raymond,
Quoted 95 lines · Raymond Mao
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Raymond,
Quoted 50 lines · Raymond Mao
Add platform custom function to get bloblist from boot arguments. Check whether boot arguments aligns with the register conventions defined in FW Handoff spec v0.9.
Add bloblist related options into qemu default config.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Remove low level code for copying boot arguments.
- Refactorboard_fdt_blob_setup()and remove direct access ofgd->bloblist. Changes in v3
- Optimizeboard_bloblist_from_boot_arg().board/emulation/qemu-arm/qemu-arm.c | 30 +++++++++++++++++++++++++++++ configs/qemu_arm64_defconfig | 3 +++ 2 files changed, 33 insertions(+)board/emulation/qemu-arm/qemu-arm.c +10
-0@@ -4,6 +4,7 @@*/ #include <common.h> +#include <bloblist.h> #include <cpu_func.h> #include <dm.h> #include <efi.h> @@ -102,6 +103,15 @@ static struct mm_region qemu_arm64_mem_map[] = {struct mm_region *mem_map = qemu_arm64_mem_map;#endif +/* +* Boot parameters saved from start.S +* saved_args[0]: FDT base address +* saved_args[1]: Bloblist signature +* saved_args[2]: must be 0 +* saved_args[3]: Bloblist base address +*/ +extern unsigned long saved_args[]; +int board_init (void ) {return 0 ;@@ -144,6 +154,26 @@ void *board_fdt_blob_setup(int *err)return (void *)CFG_SYS_SDRAM_BASE ; }Quoted 13 lines
board/emulation/qemu-arm/qemu-arm.c void *board_fdt_blob_setup(int *err) · line 166
Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10
-0+int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size) +{ +int ret = -ENOENT ; + +if (!IS_ENABLED (CONFIG_OF_BOARD ) || !IS_ENABLED (CONFIG_BLOBLIST )) +return -ENOENT ; + + ret =bloblist_check (saved_args[3 ], size); +if (ret) +return ret;What about saved_args[1] ?
The magic and version of register conventions cannot be checked now since there is a bug in the spec. PSB:
``` X1[23:0]: set to the TL signature (4a0f_b10b) X1[31:24]: version of the register convention used. Set to 1 for the AArch64 convention specified in this document. ```Signature (4a0f_b10b) takes all [31:0] and no space for version of the register convention. This needs to be updated on TF-A and OP-TEE as well after the spec is updated. For now I will just skip the checking.
Quoted 14 lines
board/emulation/qemu-arm/qemu-arm.c void *board_fdt_blob_setup(int *err) · line 176
Quoted 11 lines
board/emulation/qemu-arm/qemu-arm.c +10
-0+ +/* Check the register conventions */ + ret =bloblist_check_reg_conv (saved_args[0 ], saved_args[2 ]); +if (!ret) +/* Relocate the bloblist to the fixed address */ + ret =bloblist_reloc ((void *)addr,CONFIG_BLOBLIST_SIZE ); + +return ret; +} +This should be a generic function, e.g. in
arch/arm
Quoted 2 lines
I didn't find a place under
arch/armthat is good for connect with the saved boot args. Do you have any suggestions?
How about arch/arm/lib/bloblist.c ?
Quoted 2 lines
[...]
Regards,
Simon
PATCH v3 7/9 bloblist: Load the bloblist from the previous loader
In reply to Raymond MaoDuring bloblist initialization, when CONFIG_OF_BOARD is defined, invoke the platform custom function to load the bloblist via boot arguments from the previous loader.
If the bloblist exists, copy it into the fixed bloblist memory region.
--- common/bloblist.c | 47 ++++++++++++++++++++++++++++------------------ include/bloblist.h | 16 ++++++++++++++++ 2 files changed, 45 insertions(+), 18 deletions(-)
common/bloblist.c +29 -18
@@ -492,31 +492,38 @@ int bloblist_init(void)bool fixed =IS_ENABLED (CONFIG_BLOBLIST_FIXED );int ret = -ENOENT ;ulong addr, size; -bool expected; - -/** -* We don't expect to find an existing bloblist in the first phase of -* U-Boot that runs. Also we have no way to receive the address of an -* allocated bloblist from a previous stage, so it must be at a fixed +/* +* If U-Boot is not in the first phase, an existing bloblist must be +* at a fixed address. +*/ +bool from_addr = fixed && !u_boot_first_phase (); +/* +* If U-Boot is in the first phase that a board specific routine should +* install the bloblist passed from previous loader to this fixed * address. */ - expected = fixed && !u_boot_first_phase (); +bool from_board = fixed &&IS_ENABLED (CONFIG_OF_BOARD ) && +u_boot_first_phase (); +if (spl_prev_phase () ==PHASE_TPL && !IS_ENABLED (CONFIG_TPL_BLOBLIST )) - expected = false; + from_addr = false;if (fixed) addr =IF_ENABLED_INT (CONFIG_BLOBLIST_FIXED ,CONFIG_BLOBLIST_ADDR ); size =CONFIG_BLOBLIST_SIZE ; -if (expected) { + +if (from_board) + ret =board_bloblist_from_boot_arg (addr, size); +else if (from_addr) ret =bloblist_check (addr, size); -if (ret) { -log_warning ("Expected bloblist at %lx not found (err=%d)\n" , - addr, ret); - }else { -/* Get the real size, if it is not what we expected */ - size = gd->bloblist->total_size; - } - } + +if (ret) +log_warning ("Bloblist at %lx not found (err=%d)\n" , + addr, ret); +else +/* Get the real size */ + size = gd->bloblist->total_size; +if (ret) {if (CONFIG_IS_ENABLED (BLOBLIST_ALLOC )) {void *ptr =memalign (BLOBLIST_ALIGN , size);
@@ -525,7 +532,8 @@ int bloblist_init(void)return log_msg_ret ("alloc" , -ENOMEM ); addr =map_to_sysmem (ptr); }else if (!fixed) { -return log_msg_ret ("!fixed" , ret); +return log_msg_ret ("BLOBLIST_FIXED is not enabled" , + ret); }log_debug ("Creating new bloblist size %lx at %lx\n" , size, addr);
@@ -538,6 +546,9 @@ int bloblist_init(void)return log_msg_ret ("ini" , ret); gd->flags |=GD_FLG_BLOBLIST_READY ; +bloblist_show_stats (); +bloblist_show_list (); +return 0 ; }
include/bloblist.h +16 -0
@@ -445,6 +445,22 @@ int bloblist_reloc(void *to, uint to_size);*/ int bloblist_init (void ); +#if (IS_ENABLED (CONFIG_ARCH_QEMU ) &&IS_ENABLED (CONFIG_ARM )) +/* Board custom function for qemu-arm */ +int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size); +#else +/* +* A board need to implement this custom function if it needs to retrieve +* bloblist from a previous loader +*/ +static inline +int board_bloblist_from_boot_arg (unsigned long __always_unused addr, +unsigned long __always_unused size) +{ +return -1 ; +} +#endif +#if CONFIG_IS_ENABLED (BLOBLIST )/** * bloblist_maybe_init() - Init the bloblist system if not already done
Signature · 1 line
2.25.1
Re: [PATCH v3 7/9] bloblist: Load the bloblist from the previous loader
Hi Raymond,
Quoted 6 lines · Raymond Mao
During bloblist initialization, when
CONFIG_OF_BOARDis defined, invoke the platform custom function to load the bloblist via boot arguments from the previous loader.
If the bloblist exists, copy it into the fixed bloblist memory region.
Quoted 6 lines
Signed-off-by Raymond Mao <[email protected]>--- common/bloblist.c | 47 ++++++++++++++++++++++++++++------------------ include/bloblist.h | 16 ++++++++++++++++ 2 files changed, 45 insertions(+), 18 deletions(-)
We should not be using OF_BOARD for this...particularly as I understood our intent was to make it go away.
For now I would like to have OF_BLOBLIST, with OF_BOARD being the fallback for when we need board-specific things. See [1]. It is also very important that U-Boot reports that the DT came from a bloblist.
Perhaps I should send just that patch so that Ilias and I can figure it out.
Quoted 7 lines
common/bloblist.c +0
-0@@ -492,31 +492,38 @@ int bloblist_init(void)bool fixed =IS_ENABLED (CONFIG_BLOBLIST_FIXED );int ret = -ENOENT ;
common/bloblist.c int bloblist_init(void) · line 497
Quoted 10 lines
common/bloblist.c +3
-6ulong addr, size; -bool expected; - -/** -* We don't expect to find an existing bloblist in the first phase of -* U-Boot that runs. Also we have no way to receive the address of an -* allocated bloblist from a previous stage, so it must be at a fixed +/* +* If U-Boot is not in the first phase, an existing bloblist must be +* at a fixed address.
BTW there is now BLOBLIST_ALLOC
Quoted 54 lines
common/bloblist.c +23
-12+*/ +bool from_addr = fixed && !u_boot_first_phase (); +/* +* If U-Boot is in the first phase that a board specific routine should +* install the bloblist passed from previous loader to this fixed * address. */ - expected = fixed && !u_boot_first_phase (); +bool from_board = fixed &&IS_ENABLED (CONFIG_OF_BOARD ) && +u_boot_first_phase (); +if (spl_prev_phase () ==PHASE_TPL && !IS_ENABLED (CONFIG_TPL_BLOBLIST )) - expected = false; + from_addr = false;if (fixed) addr =IF_ENABLED_INT (CONFIG_BLOBLIST_FIXED ,CONFIG_BLOBLIST_ADDR ); size =CONFIG_BLOBLIST_SIZE ; -if (expected) { + +if (from_board) + ret =board_bloblist_from_boot_arg (addr, size); +else if (from_addr) ret =bloblist_check (addr, size); -if (ret) { -log_warning ("Expected bloblist at %lx not found (err=%d)\n" , - addr, ret); - }else { -/* Get the real size, if it is not what we expected */ - size = gd->bloblist->total_size; - } - } + +if (ret) +log_warning ("Bloblist at %lx not found (err=%d)\n" , + addr, ret); +else +/* Get the real size */ + size = gd->bloblist->total_size; +if (ret) {if (CONFIG_IS_ENABLED (BLOBLIST_ALLOC )) {void *ptr =memalign (BLOBLIST_ALIGN , size);@@ -525,7 +532,8 @@ int bloblist_init(void)return log_msg_ret ("alloc" , -ENOMEM ); addr =map_to_sysmem (ptr); }else if (!fixed) { -return log_msg_ret ("!fixed" , ret); +return log_msg_ret ("BLOBLIST_FIXED is not enabled" , + ret); }log_debug ("Creating new bloblist size %lx at %lx\n" , size, addr);
common/bloblist.c int bloblist_init(void) · line 550
Quoted 5 lines
common/bloblist.c +2
-0@@ -538,6 +546,9 @@ int bloblist_init(void)return log_msg_ret ("ini" , ret); gd->flags |=GD_FLG_BLOBLIST_READY ; +bloblist_show_stats (); +bloblist_show_list ();
Can you put those two lines behind a BLOBLIST_DEBUG option, perhaps?
Quoted 32 lines
common/bloblist.c +1
-0+return 0 ; }include/bloblist.h +16
-1@@ -445,6 +445,22 @@ int bloblist_reloc(void *to, uint to_size);*/ int bloblist_init (void ); +#if (IS_ENABLED (CONFIG_ARCH_QEMU ) &&IS_ENABLED (CONFIG_ARM )) +/* Board custom function for qemu-arm */ +int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size); +#else +/* +* A board need to implement this custom function if it needs to retrieve +* bloblist from a previous loader +*/ +static inline +int board_bloblist_from_boot_arg (unsigned long __always_unused addr, +unsigned long __always_unused size) +{ +return -1 ; +} +#endif +#if CONFIG_IS_ENABLED (BLOBLIST )/** * bloblist_maybe_init() - Init the bloblist system if not already done --
Quoted 2 lines
2.25.1
Regards,
Simon
[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
PATCH v3 8/9 fdt: update the document and Kconfig description
In reply to Raymond MaoUpdate the document and Kconfig to describe the behavior of board specific custom functions when CONFIG_OF_BOARD is defined.
--- doc/develop/devicetree/control.rst | 6 +++--- dts/Kconfig | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-)
doc/develop/devicetree/control.rst +3 -3
@@ -104,9 +104,9 @@ in u-boot.bin so you can still just flash u-boot.bin onto your board. If you are using CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to include the device tree binary. -If CONFIG_OF_BOARD is defined, a board-specific routine will provide the -devicetree at runtime, for example if an earlier bootloader stage creates -it and passes it to U-Boot. +If CONFIG_OF_BOARD is defined, board-specific routines will provide the +bloblist and devicetree at runtime, for example if an earlier bootloader stage +creates it and passes it to U-Boot. If CONFIG_SANDBOX is defined, then it will be read from a file on startup. Use the -d flag to U-Boot to specify the file to read, -D for the
dts/Kconfig +5 -2
@@ -110,8 +110,11 @@ config OF_BOARD default y if SANDBOX || OF_HAS_PRIOR_STAGE help If this option is enabled, the device tree is provided at runtime by - a custom function called board_fdt_blob_setup(). The board must - implement this function if it wishes to provide special behaviour. + a custom function called board_fdt_blob_setup(). + If this option is enabled, bloblist is provided at runtime by a + custom function called board_bloblist_from_boot_arg(). + The board must implement these functions if it wishes to provide + special behaviour. With this option, the device tree build by U-Boot may be overridden or ignored. See OF_HAS_PRIOR_STAGE.
Signature · 1 line
2.25.1
Re: [PATCH v3 8/9] fdt: update the document and Kconfig description
Hi Raymond,
Quoted 32 lines · Raymond Mao
Update the document and
Kconfigto describe the behavior of board specific custom functions whenCONFIG_OF_BOARDis defined.Signed-off-by Raymond Mao <[email protected]>--- doc/develop/devicetree/control.rst | 6 +++--- dts/Kconfig | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-)doc/develop/devicetree/control.rst +3
-3@@ -104,9 +104,9 @@ in u-boot.bin so you can still just flash u-boot.bin onto your board. If you are using CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to include the device tree binary. -If CONFIG_OF_BOARD is defined, a board-specific routine will provide the -devicetree at runtime, for example if an earlier bootloader stage creates -it and passes it to U-Boot. +If CONFIG_OF_BOARD is defined, board-specific routines will provide the +bloblist and devicetree at runtime, for example if an earlier bootloader stage +creates it and passes it to U-Boot. If CONFIG_SANDBOX is defined, then it will be read from a file on startup. Use the -d flag to U-Boot to specify the file to read, -D for thedts/Kconfig +0
-0
dts/Kconfig config OF_BOARD · line 117
Quoted 10 lines
dts/Kconfig +5
-2@@ -110,8 +110,11 @@ config OF_BOARD default y if SANDBOX || OF_HAS_PRIOR_STAGE help If this option is enabled, the device tree is provided at runtime by - a custom function called board_fdt_blob_setup(). The board must - implement this function if it wishes to provide special behaviour. + a custom function called board_fdt_blob_setup(). + If this option is enabled, bloblist is provided at runtime by a + custom function called board_bloblist_from_boot_arg(). + The board must implement these functions if it wishes to provide + special behaviour.
Again, this spec is not board-specific, so it should work on any ARM board, without board-specific code, just by enabling the feature.
Quoted 6 lines
dts/Kconfig +0
-1With this option, the device tree build by U-Boot may be overridden or ignored. See OF_HAS_PRIOR_STAGE. --2.25.1
Regards,
SImon
Re: [PATCH v3 8/9] fdt: update the document and Kconfig description
Hi Simon,
Quoted 53 lines · Simon Glass
Hi Raymond,
Review
Quoted 11 lines · Raymond Mao
Update the document and
Kconfigto describe the behavior of board specific custom functions whenCONFIG_OF_BOARDis defined.Signed-off-by Raymond Mao <[email protected]>--- doc/develop/devicetree/control.rst | 6 +++--- dts/Kconfig | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/doc/develop/devicetree/control.rstdoc/develop/devicetree/control.rst in u-boot.bin so you can still just flash u-boot.bin
Quoted 4 lines
index
cbb65c9b17..e061f4e812100644doc/develop/devicetree/control.rst +0
-0@@ -104,9 +104,9 @@ in u-boot.bin so you can still just flash u-boot.binonto your board. If you are
doc/develop/devicetree/control.rst in u-boot.bin so you can still just flash u-boot.bin · line 104
Quoted 1 line
doc/develop/devicetree/control.rst +0
-0using CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to includethe device
doc/develop/devicetree/control.rst in u-boot.bin so you can still just flash u-boot.bin onto your board. If you are
Quoted 4 lines
doc/develop/devicetree/control.rst +0
-2tree binary. -If CONFIG_OF_BOARD is defined, a board-specific routine will provide the -devicetree at runtime, for example if an earlier bootloader stagecreates
doc/develop/devicetree/control.rst in u-boot.bin so you can still just flash u-boot.bin onto your board. If you are
Quoted 3 lines
doc/develop/devicetree/control.rst +2
-1-it and passes it to U-Boot. +If CONFIG_OF_BOARD is defined, board-specific routines will provide the +bloblist and devicetree at runtime, for example if an earlierbootloader stage
doc/develop/devicetree/control.rst in u-boot.bin so you can still just flash u-boot.bin onto your board. If you are
Quoted 4 lines
doc/develop/devicetree/control.rst +1
-0+creates it and passes it to U-Boot. If CONFIG_SANDBOX is defined, then it will be read from a file on startup. Use the -d flag to U-Boot to specify the file to read, -D forthe
dts/Kconfig config OF_BOARD · line 112
Quoted 8 lines
dts/Kconfig +0
-0@@ -110,8 +110,11 @@ config OF_BOARD default y if SANDBOX || OF_HAS_PRIOR_STAGE help If this option is enabled, the device tree is provided atruntime by
dts/Kconfig config OF_BOARD · line 114
Quoted 2 lines
dts/Kconfig +0
-2- a custom function called board_fdt_blob_setup(). The board must - implement this function if it wishes to provide specialbehaviour.
dts/Kconfig config OF_BOARD
Quoted 4 lines
dts/Kconfig +4
-0+ a custom function called board_fdt_blob_setup(). + If this option is enabled, bloblist is provided at runtime by a + custom function called board_bloblist_from_boot_arg(). + The board must implement these functions if it wishes to
Quoted 7 lines
provide
dts/Kconfig config OF_BOARD · line 117
Quoted 1 line
dts/Kconfig +1
-0+ special behaviour.Again, this spec is not board-specific, so it should work on any ARM board, without board-specific code, just by enabling the feature.
dts/Kconfig is for all platforms. And from the view of a non-ARM platform,
this is
still platform-specific.
[...]
Regards,
Raymond
PATCH v3 9/9 qemu-arm: get FDT from bloblist
In reply to Raymond MaoGet devicetree from a bloblist if it exists.
If not, fallback to get FDT from the specified memory address.
---
Changes in v2
- Refactor of board_fdt_blob_setup().
board/emulation/qemu-arm/qemu-arm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
board/emulation/qemu-arm/qemu-arm.c +10 -2
@@ -149,9 +149,17 @@ int dram_init_banksize(void)void *board_fdt_blob_setup (int *err) { +void *fdt =NULL ; *err =0 ; -/* QEMU loads a generated DTB for us at the start of RAM. */ -return (void *)CFG_SYS_SDRAM_BASE ; + +/* Check if a DTB exists in bloblist */ +if (IS_ENABLED (CONFIG_BLOBLIST ) && !bloblist_maybe_init ()) + fdt =bloblist_find (BLOBLISTT_CONTROL_FDT ,0 ); +if (!fdt) +/* QEMU loads a generated DTB for us at the start of RAM. */ +return (void *)CFG_SYS_SDRAM_BASE ; + +return fdt; }int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size)
Signature · 1 line
2.25.1
Re: [PATCH v3 9/9] qemu-arm: get FDT from bloblist
Hi,
Quoted 4 lines · Raymond Mao
Get devicetree from a bloblist if it exists.
If not, fallback to get FDT from the specified memory address.
Quoted 8 lines
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofboard_fdt_blob_setup().board/emulation/qemu-arm/qemu-arm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
I believe this patch will not be needed, since we have fdtdec_setup() to do this.
Quoted 25 lines
board/emulation/qemu-arm/qemu-arm.c +10
-3@@ -149,9 +149,17 @@ int dram_init_banksize(void)void *board_fdt_blob_setup (int *err) { +void *fdt =NULL ; *err =0 ; -/* QEMU loads a generated DTB for us at the start of RAM. */ -return (void *)CFG_SYS_SDRAM_BASE ; + +/* Check if a DTB exists in bloblist */ +if (IS_ENABLED (CONFIG_BLOBLIST ) && !bloblist_maybe_init ()) + fdt =bloblist_find (BLOBLISTT_CONTROL_FDT ,0 ); +if (!fdt) +/* QEMU loads a generated DTB for us at the start of RAM. */ +return (void *)CFG_SYS_SDRAM_BASE ; + +return fdt; }int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size) --
Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH v3 9/9] qemu-arm: get FDT from bloblist
Quoted 13 lines · Simon Glass
Hi,
Quoted 9 lines · Raymond Mao
Get devicetree from a bloblist if it exists.
If not, fallback to get FDT from the specified memory address.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofboard_fdt_blob_setup().
Quoted 6 lines
Quoted 3 lines
board/emulation/qemu-arm/qemu-arm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)I believe this patch will not be needed, since we have
fdtdec_setup()to do this.
Yep, it's not. The board-specific portion should be limited to what happens if the bloblist is *not* detected by fdtdec_setup() (assuming the user wants to allow a fallback)
Quoted 31 lines
Quoted 26 lines
board/emulation/qemu-arm/qemu-arm.c +10
-3@@ -149,9 +149,17 @@ int dram_init_banksize(void)void *board_fdt_blob_setup (int *err) { +void *fdt =NULL ; *err =0 ; -/* QEMU loads a generated DTB for us at the start of RAM. */ -return (void *)CFG_SYS_SDRAM_BASE ; + +/* Check if a DTB exists in bloblist */ +if (IS_ENABLED (CONFIG_BLOBLIST ) && !bloblist_maybe_init ()) + fdt =bloblist_find (BLOBLISTT_CONTROL_FDT ,0 ); +if (!fdt) +/* QEMU loads a generated DTB for us at the start of RAM. */ +return (void *)CFG_SYS_SDRAM_BASE ; + +return fdt; }int board_bloblist_from_boot_arg (unsigned long addr,unsigned long size) --Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH v3 9/9] qemu-arm: get FDT from bloblist
Hi Ilias and Simon,
Quoted 19 lines · Ilias Apalodimas
Quoted 4 lines · Simon Glass
Hi,
On Fri, Dec 22, 2023 at 9:32 PM Raymond Mao <[email protected]>
Quoted 13 lines · wrote:
Quoted 12 lines
Get devicetree from a bloblist if it exists.
If not, fallback to get FDT from the specified memory address.Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofboard_fdt_blob_setup().board/emulation/qemu-arm/qemu-arm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
Quoted 8 lines
Quoted 2 lines
I believe this patch will not be needed, since we have
fdtdec_setup()to do this.Yep, it's not. The board-specific portion should be limited to what happens if the bloblist is *not* detected by
fdtdec_setup()(assuming the user wants to allow a fallback)But I think whether we allow a fallback or not is really something that
should be
considered by a board vendor other than a common logic in fdtdec_setup(). And a board vendor can also decide whether to allow a FDT that comes from bloblist
by this custom function.
[...]
Regards,
Raymond
Re: [PATCH v3 9/9] qemu-arm: get FDT from bloblist
Quoted 26 lines · Raymond Mao
Hi Ilias and Simon,
Quoted 22 lines · Ilias Apalodimas
Quoted 19 lines · Simon Glass
Hi,
Quoted 4 lines · Raymond Mao
Get devicetree from a bloblist if it exists.
If not, fallback to get FDT from the specified memory address.Quoted 8 lines
Signed-off-by Raymond Mao <[email protected]>---
Changes in v2
- Refactor ofboard_fdt_blob_setup().board/emulation/qemu-arm/qemu-arm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)I believe this patch will not be needed, since we have
fdtdec_setup()to do this.
Quoted 6 lines
Quoted 4 lines
Yep, it's not. The board-specific portion should be limited to what happens if the bloblist is *not* detected by
fdtdec_setup()(assuming the user wants to allow a fallback)But I think whether we allow a fallback or not is really something that should be considered by a board vendor other than a common logic in
fdtdec_setup().
It's not. The bloblist is coming from the standard register calling convention. Doesn't it make more sense to have the code
- Scan for a bloblist if BLOBLIST is enabled
- Fallback to board-specific methods if that register does not contain a bloblist, or contains one without a DT entry
Quoted 2 lines
And a board vendor can also decide whether to allow a FDT that comes from bloblist by this custom function.
I am not sure I understand this one. That decision should be in u-boot proper, the vendor should only be allowed to provide his special DT if we dont find it in a transfer list
Thanks
/Ilias
Quoted 5 lines
[...]
Regards,
Raymond