Don't use SBI functions in fdt code
cover Don't use SBI functions in fdt code
My previous solution to build v0.9 in EDK2 wasn't correct:
http://lists.infradead.org/pipermail/opensbi/2021-May/000982.html
Abner reminded me that he had done a similar change before. It was to not use SBI functions in the FDT files but instead call those from libfdt_env.h.
See:2cfd2fc9048806353298a1b967abf985901e36e82845d2d2cf4fb74a89452ba223995aa4a118c07e8e47649eff96c303e02fbd58cdc6c4ed341066ec
Doing the same kinds of changes again, solves the issue.
Daniel Schaefer (3):
lib: utils: Add macro to libfdt_env.h for strncpy
lib: fdt: Don't use sbi_string functions
lib: utils: Replace strcmp with strcmp
lib/utils/fdt/fdt_domain.c | 7 ++++--- lib/utils/libfdt/libfdt_env.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.30.1
PATCH 1/3 lib: utils: Add macro to libfdt_env.h for strncpy
Just like 2845d2d2cf4fb74a89452ba223995aa4a118c07e
--- lib/utils/libfdt/libfdt_env.h | 1 + 1 file changed, 1 insertion(+)
lib/utils/libfdt/libfdt_env.h +1 -0
@@ -31,6 +31,7 @@#define strchr sbi_strchr#define strrchr sbi_strrchr#define strcpy sbi_strcpy +#define strncpy sbi_strncpy#define strcmp sbi_strcmp#define strncmp sbi_strncmp#define strlen sbi_strlen
Signature · 1 line
2.30.1
PATCH 1/3 lib: utils: Add macro to libfdt_env.h for strncpy
? 2021-05-17?? 19:33 +0800?Daniel Schaefer???
Quoted 5 lines
Just like
2845d2d2cf4fb74a89452ba223995aa4a118c07eCc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Signed-off-by Daniel Schaefer <[email protected]>
Look good to me.
This description doesn't look very clear.
I recommend reword:
lib: utils: Add a macro in libfdt_env.h for strncpy
This commit add a macro to replace strncpy with sbi_strncpy.
Regards
Xiang W
Quoted 21 lines
--- lib/utils/libfdt/libfdt_env.h | 1 + 1 file changed, 1 insertion(+)lib/utils/libfdt/libfdt_env.h +1
-0@@ -31,6 +31,7 @@#define strchr sbi_strchr#define strrchr sbi_strrchr#define strcpy sbi_strcpy +#define strncpy sbi_strncpy#define strcmp sbi_strcmp#define strncmp sbi_strncmp#define strlen sbi_strlenSignature · 1 line
2.30.1
Chang
PATCH 1/3 lib: utils: Add macro to libfdt_env.h for strncpy
Quoted 46 lines
-----Original Message-----
From: Xiang W [mailto:wxjstz at 126.com]
Sent: Monday, May 17, 2021 9:48 PM
To: Schaefer, Daniel <[email protected]>; opensbi at lists.infradead.org
Cc: Chang, Abner (HPS SW/FW Technologist) <[email protected]>; Anup Patel <[email protected]>
Subject: Re: [PATCH v1 1/3] lib: utils: Add macro tolibfdt_env.hfor strncpy? 2021-05-17?? 19:33 +0800?Daniel Schaefer???
Quoted 5 lines
Just like
2845d2d2cf4fb74a89452ba223995aa4a118c07eCc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Signed-off-by Daniel Schaefer <[email protected]>Look good to me.
This description doesn't look very clear.I recommend reword:
lib: utils: Add a macro in
libfdt_env.hfor strncpyThis commit add a macro to replace strncpy with
sbi_strncpy.Regards
Xiang WQuoted 21 lines
--- lib/utils/libfdt/libfdt_env.h | 1 + 1 file changed, 1 insertion(+)lib/utils/libfdt/libfdt_env.h +1
-1@@ -31,6 +31,7 @@#define strchr sbi_strchr#define strrchr sbi_strrchr#define strcpy sbi_strcpy +#define strncpy sbi_strncpy#define strcmp sbi_strcmp#define strncmp sbi_strncmp#define strlen sbi_strlen --2.30.1
PATCH 2/3 lib: fdt: Don't use sbi_string functions
In reply to Daniel SchaeferWhen SBI is built by external firmware, we need to use their functions, defined in libfdt_env.h.
Just like 2cfd2fc9048806353298a1b967abf985901e36e8
--- lib/utils/fdt/fdt_domain.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
lib/utils/fdt/fdt_domain.c +4 -3
@@ -9,6 +9,7 @@*/ #include <libfdt.h> +#include <libfdt_env.h> #include <sbi/sbi_domain.h> #include <sbi/sbi_error.h> #include <sbi/sbi_hartmask.h>
@@ -95,7 +96,7 @@ static int __fixup_find_domain_offset(void *fdt, int doff, void *p) {struct __fixup_find_domain_offset_info *fdo = p; -if (!sbi_strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) +if (!strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) *fdo->doffset = doff;return 0 ;
@@ -287,7 +288,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque) regions = &fdt_regions[fdt_domains_count][0 ];/* Read DT node name */ -sbi_strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ), +strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ),sizeof (dom->name)); dom->name[sizeof (dom->name) -1 ] ='\0' ;
@@ -313,7 +314,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)/* Setup memregions from DT */ val32 =0 ; -sbi_memset (regions,0 , +memset (regions,0 ,sizeof (*regions) * (FDT_DOMAIN_REGION_MAX_COUNT +1 )); dom->regions = regions; err = fdt_iterate_each_memregion(fdt, domain_offset, &val32,
Signature · 1 line
2.30.1
PATCH 2/3 lib: fdt: Don't use sbi_string functions
? 2021-05-17?? 19:33 +0800?Daniel Schaefer???
Quoted 8 lines
When SBI is built by external firmware, we need to use their functions,
defined inlibfdt_env.h.
Just like2cfd2fc9048806353298a1b967abf985901e36e8Cc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Signed-off-by Daniel Schaefer <[email protected]>
Look good to me.
but lost sbi_memcpy in line 340.
Regards
Xiang W
Quoted 51 lines
--- lib/utils/fdt/fdt_domain.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)lib/utils/fdt/fdt_domain.c +2
-1@@ -9,6 +9,7 @@*/ #include <libfdt.h> +#include <libfdt_env.h> #include <sbi/sbi_domain.h> #include <sbi/sbi_error.h> #include <sbi/sbi_hartmask.h> @@ -95,7 +96,7 @@ static int __fixup_find_domain_offset(void *fdt, int doff, void *p) { struct __fixup_find_domain_offset_info *fdo = p; -if (!sbi_strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) +if (!strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) *fdo->doffset = doff;lib/utils/fdt/fdt_domain.c +2
-2return 0 ;@@ -287,7 +288,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque) regions = &fdt_regions[fdt_domains_count][0 ];/* Read DT node name */ -sbi_strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ), +strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ),sizeof (dom->name)); dom->name[sizeof (dom->name) -1 ] ='\0' ;@@ -313,7 +314,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)/* Setup memregions from DT */ val32 =0 ; -sbi_memset (regions,0 , +memset (regions,0 ,sizeof (*regions) * (FDT_DOMAIN_REGION_MAX_COUNT +1 ));lib/utils/fdt/fdt_domain.c +0
-0dom->regions = regions; err = fdt_iterate_each_memregion(fdt, domain_offset, &val32,Signature · 1 line
2.30.1
Chang
PATCH 2/3 lib: fdt: Don't use sbi_string functions
After addressing Xiang's comment.
Quoted 74 lines
-----Original Message-----
From: Xiang W [mailto:wxjstz at 126.com]
Sent: Monday, May 17, 2021 9:54 PM
To: Schaefer, Daniel <[email protected]>; opensbi at lists.infradead.org
Cc: Chang, Abner (HPS SW/FW Technologist) <[email protected]>; Anup Patel <[email protected]>
Subject: Re: [PATCH v1 2/3] lib: fdt: Don't usesbi_stringfunctions? 2021-05-17?? 19:33 +0800?Daniel Schaefer???
Quoted 8 lines
When SBI is built by external firmware, we need to use their functions,
defined inlibfdt_env.h.
Just like2cfd2fc9048806353298a1b967abf985901e36e8Cc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Signed-off-by Daniel Schaefer <[email protected]>Look good to me.
but lost
sbi_memcpyin line 340.Regards
Xiang WQuoted 51 lines
--- lib/utils/fdt/fdt_domain.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)lib/utils/fdt/fdt_domain.c +2
-1@@ -9,6 +9,7 @@*/ #include <libfdt.h> +#include <libfdt_env.h> #include <sbi/sbi_domain.h> #include <sbi/sbi_error.h> #include <sbi/sbi_hartmask.h> @@ -95,7 +96,7 @@ static int __fixup_find_domain_offset(void *fdt, int doff, void *p) { struct __fixup_find_domain_offset_info *fdo = p; -if (!sbi_strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) +if (!strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) *fdo->doffset = doff;lib/utils/fdt/fdt_domain.c +2
-2return 0 ;@@ -287,7 +288,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque) regions = &fdt_regions[fdt_domains_count][0 ];/* Read DT node name */ -sbi_strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ), +strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ),sizeof (dom->name)); dom->name[sizeof (dom->name) -1 ] ='\0' ;@@ -313,7 +314,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)/* Setup memregions from DT */ val32 =0 ; -sbi_memset (regions,0 , +memset (regions,0 ,sizeof (*regions) * (FDT_DOMAIN_REGION_MAX_COUNT +1 ));lib/utils/fdt/fdt_domain.c +0
-1dom->regions = regions; err = fdt_iterate_each_memregion(fdt, domain_offset, &val32, --2.30.1
Schaefer
PATCH 2/3 lib: fdt: Don't use sbi_string functions
In reply to Xiang WQuoted 6 lines · Xiang W
? 2021-05-17?? 19:33 +0800?Daniel Schaefer???
Quoted 5 lines
When SBI is built by external firmware, we need to use their functions,
defined inlibfdt_env.h.
Just like2cfd2fc9048806353298a1b967abf985901e36e8
Quoted 6 lines
Quoted 3 lines
Cc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Signed-off-by Daniel Schaefer <[email protected]>Look good to me.
but lost
sbi_memcpyin line 340.
Oh, good catch, thanks! I had made the changes based on v0.9 originally. I'll send out another series.
Quoted 54 lines
Regards
Xiang WQuoted 51 lines
--- lib/utils/fdt/fdt_domain.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)lib/utils/fdt/fdt_domain.c +2
-1@@ -9,6 +9,7 @@*/ #include <libfdt.h> +#include <libfdt_env.h> #include <sbi/sbi_domain.h> #include <sbi/sbi_error.h> #include <sbi/sbi_hartmask.h> @@ -95,7 +96,7 @@ static int __fixup_find_domain_offset(void *fdt, int doff, void *p) { struct __fixup_find_domain_offset_info *fdo = p; -if (!sbi_strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) +if (!strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) *fdo->doffset = doff;lib/utils/fdt/fdt_domain.c +2
-2return 0 ;@@ -287,7 +288,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque) regions = &fdt_regions[fdt_domains_count][0 ];/* Read DT node name */ -sbi_strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ), +strncpy (dom->name,fdt_get_name (fdt, domain_offset,NULL ),sizeof (dom->name)); dom->name[sizeof (dom->name) -1 ] ='\0' ;@@ -313,7 +314,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)/* Setup memregions from DT */ val32 =0 ; -sbi_memset (regions,0 , +memset (regions,0 ,sizeof (*regions) * (FDT_DOMAIN_REGION_MAX_COUNT +1 ));lib/utils/fdt/fdt_domain.c +0
-0dom->regions = regions; err = fdt_iterate_each_memregion(fdt, domain_offset, &val32,Signature · 1 line
2.30.1
PATCH 3/3 lib: utils: Replace strcmp with strcmp
In reply to Daniel Schaefer--- lib/utils/fdt/fdt_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/utils/fdt/fdt_domain.c +1 -1
@@ -96,7 +96,7 @@ static int __fixup_find_domain_offset(void *fdt, int doff, void *p) {struct __fixup_find_domain_offset_info *fdo = p; -if (!strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) +if (!strncmp (fdo->name,fdt_get_name (fdt, doff,NULL ),strlen (fdo->name))) *fdo->doffset = doff;return 0 ;
Signature · 1 line
2.30.1
PATCH 3/3 lib: utils: Replace strcmp with strcmp
s/strcmp with strcmp/strcmp with strncmp/
Andreas.
Signature · 3 lines
Andreas Schwab, schwab at linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
PATCH 3/3 lib: utils: Replace strcmp with strcmp
In reply to Daniel Schaefer? 2021-05-17?? 19:33 +0800?Daniel Schaefer???
Quoted 3 lines
Cc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Signed-off-by Daniel Schaefer <[email protected]>
Look good to me.
Quoted 23 lines
--- lib/utils/fdt/fdt_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/utils/fdt/fdt_domain.c +1
-1@@ -96,7 +96,7 @@ static int __fixup_find_domain_offset(void *fdt, int doff, void *p) { struct __fixup_find_domain_offset_info *fdo = p; -if (!strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) +if (!strncmp (fdo->name,fdt_get_name (fdt, doff,NULL ),strlen (fdo->name))) *fdo->doffset = doff;return 0;
Signature · 1 line
2.30.1
Chang
PATCH 3/3 lib: utils: Replace strcmp with strcmp
Quoted 38 lines
-----Original Message-----
From: Xiang W [mailto:wxjstz at 126.com]
Sent: Monday, May 17, 2021 9:58 PM
To: Schaefer, Daniel <[email protected]>; opensbi at lists.infradead.org
Cc: Chang, Abner (HPS SW/FW Technologist) <[email protected]>; Anup Patel <[email protected]>
Subject: Re: [PATCH v1 3/3] lib: utils: Replace strcmp with strcmp? 2021-05-17?? 19:33 +0800?Daniel Schaefer???
Quoted 3 lines
Cc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Signed-off-by Daniel Schaefer <[email protected]>Look good to me.
Reviewed-by Xiang W <[email protected]>Quoted 23 lines
--- lib/utils/fdt/fdt_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/utils/fdt/fdt_domain.c +1
-1@@ -96,7 +96,7 @@ static int __fixup_find_domain_offset(void *fdt, int doff, void *p) { struct __fixup_find_domain_offset_info *fdo = p; -if (!strcmp (fdo->name,fdt_get_name (fdt, doff,NULL ))) +if (!strncmp (fdo->name,fdt_get_name (fdt, doff,NULL ),strlen (fdo->name))) *fdo->doffset = doff;return 0;
--
2.30.1
cover Don't use SBI functions in fdt code
In reply to Daniel SchaeferHi Daniel,
Quoted 15 lines · Daniel Schaefer
My previous solution to build v0.9 in EDK2 wasn't correct:
http://lists.infradead.org/pipermail/opensbi/2021-May/000982.htmlAbner reminded me that he had done a similar change before. It was to not use SBI functions in the FDT files but instead call those from
libfdt_env.h.See:
2cfd2fc9048806353298a1b967abf985901e36e82845d2d2cf4fb74a89452ba223995aa4a118c07e8e47649eff96c303e02fbd58cdc6c4ed341066ecDoing the same kinds of changes again, solves the issue.
Quoted 7 lines
Cc Abner Chang <[email protected]>Cc Anup Patel <[email protected]>Daniel Schaefer (3):
lib: utils: Add macro tolibfdt_env.hfor strncpy
lib: fdt: Don't usesbi_stringfunctions
lib: utils: Replace strcmp with strcmp
You would be sending a v2 with comments addressed. Right ??
Quoted 5 lines
lib/utils/fdt/fdt_domain.c | 7 ++++--- lib/utils/libfdt/libfdt_env.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-)
Quoted 8 lines
--
2.30.1--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
Regards,
Anup