Add riscv tests to cover the base extension specs
Subsystems (2)
v2 cover Add riscv tests to cover the base extension specs
From: Carlos Maiolino <[email protected]>
Hi,
This is a new version of this series to create tests to cover functions of the riscv's SBI base implementation spec. The series also includes a a few helpers to reduce code duplication.
Detailed updates are specified on a patch-basis
Carlos Maiolino (6):
riscv: Add test to probe SBI Extension
riscv: Factor out environment variable check and report generation
riscv: Implement test for architecture ID register
riscv: Enable gen_report() to print the wrong value in case of failure
riscv: Test for specific SBI implementation ID
riscv: Add a wrapper to call sbi_ecall for base extension
riscv/sbi.c | 79 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 12 deletions(-)
Signature · 1 line
2.44.0
PATCH v2 1/6 riscv: Add test to probe SBI Extension
From: Carlos Maiolino <[email protected]>
Factor out vendor id test to a new helper, and add a new test for probing the SBI extension.
Compare the retrieved value against an environment variable, as the implementation can return any non-zero value.
---
V2:
- change sbi_ecall()'s format, to fit a single line.
- Make PROBE_EXT envvar optional, as suggested by Drew. This prevents the test to bail if the envvar is not set.
riscv/sbi.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-)
riscv/sbi.c +32 -11
@@ -14,28 +14,49 @@ static void help(void)puts ("An environ must be provided where expected values are given.\n" ); } -int main (int argc,char **argv) +static void check_base (void ) {struct sbiret ret;long expected; -if (argc >1 && !strcmp (argv[1 ],"-h" )) { -help (); -exit (0 ); - } - -report_prefix_push ("sbi" ); +report_prefix_push ("base" );if (!getenv ("MVENDORID" )) {report_skip ("mvendorid: missing MVENDORID environment variable" ); - goto done; +return ; } + +report_prefix_push ("mvendorid" ); expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); -report (!ret.error,"mvendorid: no error" ); -report (ret.value == expected,"mvendorid" ); -done: +report (!ret.error,"no sbi.error" ); +report (ret.value == expected,"expected sbi.value" ); +report_prefix_pop (); + +report_prefix_push ("probe_ext" ); + expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; + + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); + +report (!ret.error,"no sbi.error" ); +report (ret.value == expected,"expected sbi.value" ); +report_prefix_pop (); + +report_prefix_pop (); +} + +int main (int argc,char **argv) +{ + +if (argc >1 && !strcmp (argv[1 ],"-h" )) { +help (); +exit (0 ); + } + +report_prefix_push ("sbi" ); +check_base (); +return report_summary (); }
Signature · 1 line
2.44.0
PATCH v2 1/6 riscv: Add test to probe SBI Extension
Quoted 86 lines · cem at kernel.org
From: Carlos Maiolino <[email protected]>
Factor out vendor id test to a new helper, and add a new test for probing the SBI extension.
Compare the retrieved value against an environment variable, as the implementation can return any non-zero value.Signed-off-by Carlos Maiolino <[email protected]>---
V2:
- change sbi_ecall()'s format, to fit a single line.
- MakePROBE_EXTenvvar optional, as suggested by Drew. This prevents the test to bail if the envvar is not set.riscv/sbi.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-)riscv/sbi.c +32
-11@@ -14,28 +14,49 @@ static void help(void)puts ("An environ must be provided where expected values are given.\n" ); } -int main (int argc,char **argv) +static void check_base (void ) {struct sbiret ret;long expected; -if (argc >1 && !strcmp (argv[1 ],"-h" )) { -help (); -exit (0 ); - } - -report_prefix_push ("sbi" ); +report_prefix_push ("base" );if (!getenv ("MVENDORID" )) {report_skip ("mvendorid: missing MVENDORID environment variable" ); - goto done; +return ; } + +report_prefix_push ("mvendorid" ); expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); -report (!ret.error,"mvendorid: no error" ); -report (ret.value == expected,"mvendorid" ); -done: +report (!ret.error,"no sbi.error" ); +report (ret.value == expected,"expected sbi.value" ); +report_prefix_pop (); + +report_prefix_push ("probe_ext" ); + expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; + + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); + +report (!ret.error,"no sbi.error" ); +report (ret.value == expected,"expected sbi.value" ); +report_prefix_pop (); + +report_prefix_pop (); +} + +int main (int argc,char **argv) +{ + +if (argc >1 && !strcmp (argv[1 ],"-h" )) { +help (); +exit (0 ); + } + +report_prefix_push ("sbi" ); +check_base (); +return report_summary (); }Signature · 1 line
2.44.0
PATCH v2 2/6 riscv: Factor out environment variable check and report generation
In reply to [email protected]From: Carlos Maiolino <[email protected]>
We do check Environment variables and generate reports all the time, so use a couple of helpers for that
---
V2:
- Rename env_is_defined() to env_or_skip()
- Add information about gen_report() in the commit message
- PROBE_EXT is not mandatory, so we don't need to pass it to env_or_skip().
riscv/sbi.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-)
riscv/sbi.c +23 -15
@@ -14,6 +14,23 @@ static void help(void)puts ("An environ must be provided where expected values are given.\n" ); } +static bool env_or_skip (const char *env) +{ + +if (!getenv (env)) { +report_skip ("missing %s environment variable" , env); +return false; + } + +return true; +} + +static void gen_report (struct sbiret *ret,long expected) +{ +report (!ret->error,"no sbi.error" ); +report (ret->value == expected,"expected sbi.value" ); +} +static void check_base (void ) {struct sbiret ret;
@@ -21,27 +38,18 @@ static void check_base(void)report_prefix_push ("base" ); -if (!getenv ("MVENDORID" )) { -report_skip ("mvendorid: missing MVENDORID environment variable" ); -return ; - } -report_prefix_push ("mvendorid" ); - expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); - - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); - -report (!ret.error,"no sbi.error" ); -report (ret.value == expected,"expected sbi.value" ); +if (env_or_skip ("MVENDORID" )) { + expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); +gen_report (&ret, expected); + }report_prefix_pop ();report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); - -report (!ret.error,"no sbi.error" ); -report (ret.value == expected,"expected sbi.value" ); +gen_report (&ret, expected);report_prefix_pop ();report_prefix_pop ();
Signature · 1 line
2.44.0
PATCH v2 2/6 riscv: Factor out environment variable check and report generation
Quoted 27 lines · cem at kernel.org
From: Carlos Maiolino <[email protected]>
We do check Environment variables and generate reports all the time, so use a couple of helpers for that
Signed-off-by Carlos Maiolino <[email protected]>---
V2:
- Renameenv_is_defined()toenv_or_skip()
- Add information aboutgen_report()in the commit message
-PROBE_EXTis not mandatory, so we don't need to pass it toenv_or_skip().riscv/sbi.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-)riscv/sbi.c +2
-0@@ -14,6 +14,23 @@ static void help(void)puts ("An environ must be provided where expected values are given.\n" ); } +static bool env_or_skip (const char *env) +{
riscv/sbi.c static void help(void) · line 28
Quoted 10 lines
riscv/sbi.c +10
-0+ +if (!getenv (env)) { +report_skip ("missing %s environment variable" , env); +return false; + } + +return true; +} + +static void gen_report (struct sbiret *ret,long expected)
I see you add expected_error in a later patch. I probably would have done that here at function introduction time, but OK.
Quoted 45 lines
riscv/sbi.c +11
-15+{ +report (!ret->error,"no sbi.error" ); +report (ret->value == expected,"expected sbi.value" ); +} +static void check_base (void ) {struct sbiret ret;@@ -21,27 +38,18 @@ static void check_base(void)report_prefix_push ("base" ); -if (!getenv ("MVENDORID" )) { -report_skip ("mvendorid: missing MVENDORID environment variable" ); -return ; - } -report_prefix_push ("mvendorid" ); - expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); - - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); - -report (!ret.error,"no sbi.error" ); -report (ret.value == expected,"expected sbi.value" ); +if (env_or_skip ("MVENDORID" )) { + expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); +gen_report (&ret, expected); + }report_prefix_pop ();report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); - -report (!ret.error,"no sbi.error" ); -report (ret.value == expected,"expected sbi.value" ); +gen_report (&ret, expected);report_prefix_pop ();report_prefix_pop ();Signature · 1 line
2.44.0
PATCH v2 3/6 riscv: Implement test for architecture ID register
In reply to [email protected]From: Carlos Maiolino <[email protected]>
Probe the MARCHID register and compare it to the specified MARCHID environment variable.
---
V2:
- Wrap commit message around 70 chars
- Remove unneeded blank lines
riscv/sbi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
riscv/sbi.c +9 -0
@@ -52,6 +52,15 @@ static void check_base(void)gen_report (&ret, expected);report_prefix_pop (); +report_prefix_push ("marchid" ); +if (env_or_skip ("MARCHID" )) { + expected =strtol (getenv ("MARCHID" ),NULL ,0 ); + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT , +SBI_EXT_BASE_GET_MARCHID ,0 ,0 ,0 ,0 ,0 ); +gen_report (&ret, expected); + } +report_prefix_pop (); +report_prefix_pop (); }
Signature · 1 line
2.44.0
PATCH v2 3/6 riscv: Implement test for architecture ID register
Quoted 20 lines · cem at kernel.org
From: Carlos Maiolino <[email protected]>
Probe the MARCHID register and compare it to the specified MARCHID environment variable.
Signed-off-by Carlos Maiolino <[email protected]>Reviewed-by Andrew Jones <[email protected]>---
V2:
- Wrap commit message around 70 chars
- Remove unneeded blank linesriscv/sbi.c | 9 +++++++++ 1 file changed, 9 insertions(+)riscv/sbi.c +0
-0
riscv/sbi.c static void check_base(void) · line 59
Quoted 8 lines
riscv/sbi.c +5
-0@@ -52,6 +52,15 @@ static void check_base(void)gen_report (&ret, expected);report_prefix_pop (); +report_prefix_push ("marchid" ); +if (env_or_skip ("MARCHID" )) { + expected =strtol (getenv ("MARCHID" ),NULL ,0 ); + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT , +SBI_EXT_BASE_GET_MARCHID ,0 ,0 ,0 ,0 ,0 );
This should be
sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_MARCHID, 0, ...)
Quoted 10 lines
riscv/sbi.c +4
-0+gen_report (&ret, expected); + } +report_prefix_pop (); +report_prefix_pop (); }Signature · 1 line
2.44.0
PATCH v2 4/6 riscv: Enable gen_report() to print the wrong value in case of failure
In reply to [email protected]From: Carlos Maiolino <[email protected]>
If the test fails because the expected value doesn't match, it's useful to know what value was actually printed.
---
V2:
- Reduce subject to fit 70 chars
- Use report_info() to output expected vs received values, leaving only necessary information for parsers on report()
riscv/sbi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
riscv/sbi.c +11 -6
@@ -25,10 +25,15 @@ static bool env_or_skip(const char *env)return true; } -static void gen_report (struct sbiret *ret,long expected) +static void gen_report (struct sbiret *ret, +long expected_error,long expected_value) { -report (!ret->error,"no sbi.error" ); -report (ret->value == expected,"expected sbi.value" ); +if (ret->value != expected_value) +report_info ("expected (error: %ld, value: %ld), received: (error: %ld, value %ld)\n" , + expected_error, expected_value, ret->error, ret->value); + +report (ret->error == expected_error,"expected sbi.error" ); +report (ret->value == expected_value,"expected sbi.value" ); }static void check_base (void )
@@ -42,14 +47,14 @@ static void check_base(void)if (env_or_skip ("MVENDORID" )) { expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); -gen_report (&ret, expected); +gen_report (&ret,0 , expected); }report_prefix_pop ();report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); -gen_report (&ret, expected); +gen_report (&ret,0 , expected);report_prefix_pop ();report_prefix_push ("marchid" );
@@ -57,7 +62,7 @@ static void check_base(void) expected =strtol (getenv ("MARCHID" ),NULL ,0 ); ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE_GET_MARCHID ,0 ,0 ,0 ,0 ,0 ); -gen_report (&ret, expected); +gen_report (&ret,0 , expected); }report_prefix_pop ();
Signature · 1 line
2.44.0
PATCH v2 4/6 riscv: Enable gen_report() to print the wrong value in case of failure
Quoted 20 lines · cem at kernel.org
From: Carlos Maiolino <[email protected]>
If the test fails because the expected value doesn't match, it's useful to know what value was actually printed.
Signed-off-by Carlos Maiolino <[email protected]>---
V2:
- Reduce subject to fit 70 chars
- Usereport_info()to output expected vs received values, leaving only necessary information for parsers onreport()riscv/sbi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)riscv/sbi.c +0
-0
riscv/sbi.c static bool env_or_skip(const char *env) · line 31
Quoted 10 lines
riscv/sbi.c +3
-3@@ -25,10 +25,15 @@ static bool env_or_skip(const char *env)return true; } -static void gen_report (struct sbiret *ret,long expected) +static void gen_report (struct sbiret *ret, +long expected_error,long expected_value) { -report (!ret->error,"no sbi.error" ); -report (ret->value == expected,"expected sbi.value" ); +if (ret->value != expected_value)
This should be
if (ret->error != expected_error || ret->value != expected_value)
riscv/sbi.c static bool env_or_skip(const char *env) · line 36
Quoted 5 lines
riscv/sbi.c +5
-0+report_info ("expected (error: %ld, value: %ld), received: (error: %ld, value %ld)\n" , + expected_error, expected_value, ret->error, ret->value); + +report (ret->error == expected_error,"expected sbi.error" ); +report (ret->value == expected_value,"expected sbi.value" );
nit: We can reduce some code clutter with
bool check_error = ret->error == expected_error;
bool check_value = ret->value == expected_value;
if (!check_error || !check_value)
report_info(...);
report(check_error, ...);
report(check_value, ...);
Quoted 32 lines
riscv/sbi.c +3
-3}static void check_base (void )@@ -42,14 +47,14 @@ static void check_base(void)if (env_or_skip ("MVENDORID" )) { expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); -gen_report (&ret, expected); +gen_report (&ret,0 , expected); }report_prefix_pop ();report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); -gen_report (&ret, expected); +gen_report (&ret,0 , expected);report_prefix_pop ();report_prefix_push ("marchid" );@@ -57,7 +62,7 @@ static void check_base(void) expected =strtol (getenv ("MARCHID" ),NULL ,0 ); ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE_GET_MARCHID ,0 ,0 ,0 ,0 ,0 ); -gen_report (&ret, expected); +gen_report (&ret,0 , expected); }report_prefix_pop ();Signature · 1 line
2.44.0
Thanks,
drew
PATCH v2 5/6 riscv: Test for specific SBI implementation ID
In reply to [email protected]From: Carlos Maiolino <[email protected]>
Retrieve the ID from the SBI, and test it against the SBI_IMPLID enviroment variable.
---
V2:
- Update commit description to fit 70 chars
- Move sbi_ecall() after expected assignment to make consistent with other tests
riscv/sbi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
riscv/sbi.c +9 -0
@@ -51,6 +51,15 @@ static void check_base(void) }report_prefix_pop (); +report_prefix_push ("sbi_impl_id" ); +if (env_or_skip ("SBI_IMPLID" )) { + expected =strtol (getenv ("SBI_IMPLID" ),NULL ,0 ); + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_IMP_ID , +SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); +gen_report (&ret,0 , expected); + } +report_prefix_pop (); +report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 );
Signature · 1 line
2.44.0
PATCH v2 5/6 riscv: Test for specific SBI implementation ID
Quoted 21 lines · cem at kernel.org
From: Carlos Maiolino <[email protected]>
Retrieve the ID from the SBI, and test it against the
SBI_IMPLIDenviroment variable.Signed-off-by Carlos Maiolino <[email protected]>Reviewed-by Andrew Jones <[email protected]>---
V2:
- Update commit description to fit 70 chars
- Movesbi_ecall()after expected assignment to make consistent with other testsriscv/sbi.c | 9 +++++++++ 1 file changed, 9 insertions(+)riscv/sbi.c +0
-0
riscv/sbi.c static void check_base(void) · line 55
Quoted 5 lines
riscv/sbi.c +2
-0@@ -51,6 +51,15 @@ static void check_base(void) }report_prefix_pop (); +report_prefix_push ("sbi_impl_id" ); +if (env_or_skip ("SBI_IMPLID" )) {
Let's spell this SBI_IMPL_ID (just like its report prefix)
riscv/sbi.c static void check_base(void) · line 58
Quoted 3 lines
riscv/sbi.c +3
-0+ expected =strtol (getenv ("SBI_IMPLID" ),NULL ,0 ); + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_IMP_ID , +SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 );
This should be
sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, ...)
Quoted 10 lines
riscv/sbi.c +4
-0+gen_report (&ret,0 , expected); + } +report_prefix_pop (); +report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 );Signature · 1 line
2.44.0
Thanks,
drew
PATCH v2 5/6 riscv: Test for specific SBI implementation ID
Quoted 25 lines · Andrew Jones
Quoted 24 lines · cem at kernel.org
From: Carlos Maiolino <[email protected]>
Retrieve the ID from the SBI, and test it against the
SBI_IMPLIDenviroment variable.Signed-off-by Carlos Maiolino <[email protected]>Reviewed-by Andrew Jones <[email protected]>---
V2:
- Update commit description to fit 70 chars
- Movesbi_ecall()after expected assignment to make consistent with other testsriscv/sbi.c | 9 +++++++++ 1 file changed, 9 insertions(+)riscv/sbi.c +0
-0@@ -51,6 +51,15 @@ static void check_base(void) }report_prefix_pop ();
Quoted 4 lines
riscv/sbi.c static void check_base(void) · line 55
Quoted 2 lines
riscv/sbi.c +2
-0+report_prefix_push ("sbi_impl_id" ); +if (env_or_skip ("SBI_IMPLID" )) {Let's spell this
SBI_IMPL_ID(just like its report prefix)
Actually, let's drop the SBI_ from the name (both report prefix and environment variable) to be consistent with the other tests. Or, only drop sbi_ from the report prefix (since we have the 'sbi' prefix already) and add SBI_ to all the other environment variables.
Quoted 22 lines
riscv/sbi.c static void check_base(void) · line 58
Quoted 4 lines
riscv/sbi.c +3
-0+ expected =strtol (getenv ("SBI_IMPLID" ),NULL ,0 ); + ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_IMP_ID , +SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 );This should be
sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, ...)Quoted 10 lines
riscv/sbi.c +4
-0+gen_report (&ret,0 , expected); + } +report_prefix_pop (); +report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 );Signature · 1 line
2.44.0Thanks,
drew
PATCH v2 6/6 riscv: Add a wrapper to call sbi_ecall for base extension
In reply to [email protected]From: Carlos Maiolino <[email protected]>
All SBI extension functions accepts at most one argument, so create a wrapper around sbi_ecall() to avoid needing to pass in arguments 1 to 5 all the time, also, the wrapper can specify SBI_EXT_BASE directly.
--- riscv/sbi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
riscv/sbi.c +9 -6
@@ -36,6 +36,11 @@ static void gen_report(struct sbiret *ret,report (ret->value == expected_value,"expected sbi.value" ); } +static inline struct sbiret __base_sbi_ecall (int fid,unsigned long arg0) +{ +return sbi_ecall (SBI_EXT_BASE , fid, arg0,0 ,0 ,0 ,0 ,0 ); +} +static void check_base (void ) {struct sbiret ret;
@@ -46,7 +51,7 @@ static void check_base(void)report_prefix_push ("mvendorid" );if (env_or_skip ("MVENDORID" )) { expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_MVENDORID ,0 );gen_report (&ret,0 , expected); }report_prefix_pop ();
@@ -54,23 +59,21 @@ static void check_base(void)report_prefix_push ("sbi_impl_id" );if (env_or_skip ("SBI_IMPLID" )) { expected =strtol (getenv ("SBI_IMPLID" ),NULL ,0 ); - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_IMP_ID , -SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_IMP_ID ,SBI_EXT_BASE );gen_report (&ret,0 , expected); }report_prefix_pop ();report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE );gen_report (&ret,0 , expected);report_prefix_pop ();report_prefix_push ("marchid" );if (env_or_skip ("MARCHID" )) { expected =strtol (getenv ("MARCHID" ),NULL ,0 ); - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT , -SBI_EXT_BASE_GET_MARCHID ,0 ,0 ,0 ,0 ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE_GET_MARCHID );gen_report (&ret,0 , expected); }report_prefix_pop ();
Signature · 1 line
2.44.0
PATCH 6/6 riscv: Add a wrapper to call sbi_ecall for base extension
Quoted 16 lines · cem at kernel.org
From: Carlos Maiolino <[email protected]>
All SBI extension functions accepts at most one argument, so create a wrapper around
sbi_ecall()to avoid needing to pass in arguments 1 to 5 all the time, also, the wrapper can specifySBI_EXT_BASEdirectly.Signed-off-by Carlos Maiolino <[email protected]>--- riscv/sbi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)riscv/sbi.c +0
-0
riscv/sbi.c static void gen_report(struct sbiret *ret, · line 39
Quoted 4 lines
riscv/sbi.c +1
-0@@ -36,6 +36,11 @@ static void gen_report(struct sbiret *ret,report (ret->value == expected_value,"expected sbi.value" ); } +static inline struct sbiret __base_sbi_ecall (int fid,unsigned long arg0)
Drop 'inline'. It's useless for static functions in .c files.
Quoted 17 lines
riscv/sbi.c +5
-1+{ +return sbi_ecall (SBI_EXT_BASE , fid, arg0,0 ,0 ,0 ,0 ,0 ); +} +static void check_base (void ) {struct sbiret ret;@@ -46,7 +51,7 @@ static void check_base(void)report_prefix_push ("mvendorid" );if (env_or_skip ("MVENDORID" )) { expected =strtol (getenv ("MVENDORID" ),NULL ,0 ); - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_MVENDORID ,0 ,0 ,0 ,0 ,0 ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_MVENDORID ,0 );gen_report (&ret,0 , expected); }report_prefix_pop ();
riscv/sbi.c static void check_base(void) · line 62
Quoted 6 lines
riscv/sbi.c +1
-2@@ -54,23 +59,21 @@ static void check_base(void)report_prefix_push ("sbi_impl_id" );if (env_or_skip ("SBI_IMPLID" )) { expected =strtol (getenv ("SBI_IMPLID" ),NULL ,0 ); - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_GET_IMP_ID , -SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_IMP_ID ,SBI_EXT_BASE );
As pointed out in a previous patch the arg should be zero.
Quoted 7 lines
riscv/sbi.c +0
-1gen_report (&ret,0 , expected); }report_prefix_pop ();report_prefix_push ("probe_ext" ); expected =getenv ("PROBE_EXT" ) ?strtol (getenv ("PROBE_EXT" ),NULL ,0 ) :1 ; - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE ,0 ,0 ,0 ,0 ,0 );
riscv/sbi.c static void check_base(void) · line 76
Quoted 10 lines
riscv/sbi.c +2
-2+ ret =__base_sbi_ecall (SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE );gen_report (&ret,0 , expected);report_prefix_pop ();report_prefix_push ("marchid" );if (env_or_skip ("MARCHID" )) { expected =strtol (getenv ("MARCHID" ),NULL ,0 ); - ret =sbi_ecall (SBI_EXT_BASE ,SBI_EXT_BASE_PROBE_EXT , -SBI_EXT_BASE_GET_MARCHID ,0 ,0 ,0 ,0 ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_PROBE_EXT ,SBI_EXT_BASE_GET_MARCHID );
As pointed out in a previous patch the fid should get-marchid and the arg should be zero.
Quoted 6 lines
riscv/sbi.c +0
-0gen_report (&ret,0 , expected); }report_prefix_pop ();Signature · 1 line
2.44.0
The wrapper is good, but this patch should come near the beginning of the series so we're not adding a bunch of code in earlier patches just to modify it later.
Otherwise,