diff mbox series

[6/7] pc-bios: s390x: Use PSW constants in start.S

Message ID 20200715094045.381984-7-frankja@linux.ibm.com
State New
Headers show
Series pc-bios: s390x: Cleanup part 2 | expand

Commit Message

Janosch Frank July 15, 2020, 9:40 a.m. UTC
Let's decrease the number of magic numbers.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
---
 pc-bios/s390-ccw/s390-arch.h | 25 +++++++++++++++----------
 pc-bios/s390-ccw/start.S     |  9 +++++----
 2 files changed, 20 insertions(+), 14 deletions(-)

Comments

Thomas Huth July 21, 2020, 7:05 a.m. UTC | #1
On 15/07/2020 11.40, Janosch Frank wrote:
> Let's decrease the number of magic numbers.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  pc-bios/s390-ccw/s390-arch.h | 25 +++++++++++++++----------
>  pc-bios/s390-ccw/start.S     |  9 +++++----
>  2 files changed, 20 insertions(+), 14 deletions(-)
> 
> diff --git a/pc-bios/s390-ccw/s390-arch.h b/pc-bios/s390-ccw/s390-arch.h
> index 6da44d4436..d450c096d0 100644
> --- a/pc-bios/s390-ccw/s390-arch.h
> +++ b/pc-bios/s390-ccw/s390-arch.h
> @@ -11,6 +11,20 @@
>  #ifndef S390_ARCH_H
>  #define S390_ARCH_H
>  
> +/* s390 psw bit masks */
> +#define PSW_MASK_EXT        0x0100000000000000UL
> +#define PSW_MASK_IOINT      0x0200000000000000ULL
> +#define PSW_MASK_SHORTPSW   0x0008000000000000ULL
> +#define PSW_MASK_WAIT       0x0002000000000000ULL
> +#define PSW_MASK_EAMODE     0x0000000100000000ULL
> +#define PSW_MASK_BAMODE     0x0000000080000000ULL
> +#define PSW_MASK_SHORT_ADDR 0x000000007fffffffULL
> +#define PSW_MASK_64         (PSW_MASK_EAMODE | PSW_MASK_BAMODE)
> +#define PSW_MASK_DWAIT      (PSW_MASK_64 | PSW_MASK_WAIT)
> +#define PSW_MASK_EWAIT      (PSW_MASK_DWAIT | PSW_MASK_IOINT | PSW_MASK_EXT)
> +
> +#ifndef __ASSEMBLER__
> +
>  typedef struct PSW {
>      uint64_t mask;
>      uint64_t addr;
> @@ -24,15 +38,6 @@ typedef struct PSWLegacy {
>  } __attribute__ ((aligned(8))) PSWLegacy;
>  _Static_assert(sizeof(struct PSWLegacy) == 8, "PSWLegacy size incorrect");
>  
> -/* s390 psw bit masks */
> -#define PSW_MASK_IOINT      0x0200000000000000ULL
> -#define PSW_MASK_SHORTPSW   0x0008000000000000ULL
> -#define PSW_MASK_WAIT       0x0002000000000000ULL
> -#define PSW_MASK_EAMODE     0x0000000100000000ULL
> -#define PSW_MASK_BAMODE     0x0000000080000000ULL
> -#define PSW_MASK_SHORT_ADDR 0x000000007fffffffULL
> -#define PSW_MASK_64         (PSW_MASK_EAMODE | PSW_MASK_BAMODE)
> -
>  /* Low core mapping */
>  typedef struct LowCore {
>      /* prefix area: defined by architecture */
> @@ -107,5 +112,5 @@ static inline uint32_t store_prefix(void)
>      asm volatile("stpx %0" : "=m" (address));
>      return address;
>  }
> -
> +#endif /* !__ASSEMBLER__ */
>  #endif
> diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
> index ce519300a1..01c4c21b26 100644
> --- a/pc-bios/s390-ccw/start.S
> +++ b/pc-bios/s390-ccw/start.S
> @@ -9,6 +9,7 @@
>   * your option) any later version. See the COPYING file in the top-level
>   * directory.
>   */
> +#include "s390-arch.h"
>  
>          .globl _start
>  _start:
> @@ -108,10 +109,10 @@ io_new_code:
>  
>          .align  8
>  disabled_wait_psw:
> -        .quad   0x0002000180000000,0x0000000000000000
> +        .quad   PSW_MASK_DWAIT, 0x0000000000000000
>  enabled_wait_psw:
> -        .quad   0x0302000180000000,0x0000000000000000
> +        .quad   PSW_MASK_EWAIT, 0x0000000000000000
>  external_new_mask:
> -        .quad   0x0000000180000000
> +        .quad   PSW_MASK_64
>  io_new_mask:
> -        .quad   0x0000000180000000
> +        .quad   PSW_MASK_64
> 

This fails to compile with older versions of binutils (e.g. the ones in
RHEL7):

pc-bios/s390-ccw/start.S: Assembler messages:
pc-bios/s390-ccw/start.S:108: Error: found 'L', expected: ')'
pc-bios/s390-ccw/start.S:108: Error: found 'L', expected: ')'
pc-bios/s390-ccw/start.S:108: Error: junk at end of line, first
unrecognized character is `L'
pc-bios/s390-ccw/start.S:110: Error: found 'L', expected: ')'
pc-bios/s390-ccw/start.S:110: Error: found 'L', expected: ')'
pc-bios/s390-ccw/start.S:110: Error: found 'L', expected: ')'
pc-bios/s390-ccw/start.S:110: Error: junk at end of line, first
unrecognized character is `L'
pc-bios/s390-ccw/start.S:112: Error: found 'L', expected: ')'
pc-bios/s390-ccw/start.S:112: Error: junk at end of line, first
unrecognized character is `L'
pc-bios/s390-ccw/start.S:114: Error: found 'L', expected: ')'
pc-bios/s390-ccw/start.S:114: Error: junk at end of line, first
unrecognized character is `L'

You either need some macro-magic for this, or simply drop the patch.

 Thomas
Christian Borntraeger July 22, 2020, 6:47 a.m. UTC | #2
On 21.07.20 09:05, Thomas Huth wrote:
> On 15/07/2020 11.40, Janosch Frank wrote:
[..]
>>  #ifndef S390_ARCH_H
>>  #define S390_ARCH_H
>>  
>> +/* s390 psw bit masks */
>> +#define PSW_MASK_EXT        0x0100000000000000UL
>> +#define PSW_MASK_IOINT      0x0200000000000000ULL
>> +#define PSW_MASK_SHORTPSW   0x0008000000000000ULL
>> +#define PSW_MASK_WAIT       0x0002000000000000ULL
>> +#define PSW_MASK_EAMODE     0x0000000100000000ULL
>> +#define PSW_MASK_BAMODE     0x0000000080000000ULL
>> +#define PSW_MASK_SHORT_ADDR 0x000000007fffffffULL
>> +#define PSW_MASK_64         (PSW_MASK_EAMODE | PSW_MASK_BAMODE)
>> +#define PSW_MASK_DWAIT      (PSW_MASK_64 | PSW_MASK_WAIT)
>> +#define PSW_MASK_EWAIT      (PSW_MASK_DWAIT | PSW_MASK_IOINT | PSW_MASK_EXT)
>> +
>> +#ifndef __ASSEMBLER__
>> +
>>  typedef struct PSW {
>>      uint64_t mask;
>>      uint64_t addr;
>> @@ -24,15 +38,6 @@ typedef struct PSWLegacy {
>>  } __attribute__ ((aligned(8))) PSWLegacy;
>>  _Static_assert(sizeof(struct PSWLegacy) == 8, "PSWLegacy size incorrect");
>>  
>> -/* s390 psw bit masks */
>> -#define PSW_MASK_IOINT      0x0200000000000000ULL
>> -#define PSW_MASK_SHORTPSW   0x0008000000000000ULL
>> -#define PSW_MASK_WAIT       0x0002000000000000ULL
>> -#define PSW_MASK_EAMODE     0x0000000100000000ULL
>> -#define PSW_MASK_BAMODE     0x0000000080000000ULL
>> -#define PSW_MASK_SHORT_ADDR 0x000000007fffffffULL
>> -#define PSW_MASK_64         (PSW_MASK_EAMODE | PSW_MASK_BAMODE)
>> -
>>  /* Low core mapping */
>>  typedef struct LowCore {
>>      /* prefix area: defined by architecture */
>> @@ -107,5 +112,5 @@ static inline uint32_t store_prefix(void)
>>      asm volatile("stpx %0" : "=m" (address));
>>      return address;
>>  }
>> -
>> +#endif /* !__ASSEMBLER__ */
>>  #endif
>> diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
>> index ce519300a1..01c4c21b26 100644
>> --- a/pc-bios/s390-ccw/start.S
>> +++ b/pc-bios/s390-ccw/start.S
>> @@ -9,6 +9,7 @@
>>   * your option) any later version. See the COPYING file in the top-level
>>   * directory.
>>   */
>> +#include "s390-arch.h"
>>  
>>          .globl _start
>>  _start:
>> @@ -108,10 +109,10 @@ io_new_code:
>>  
>>          .align  8
>>  disabled_wait_psw:
>> -        .quad   0x0002000180000000,0x0000000000000000
>> +        .quad   PSW_MASK_DWAIT, 0x0000000000000000
>>  enabled_wait_psw:
>> -        .quad   0x0302000180000000,0x0000000000000000
>> +        .quad   PSW_MASK_EWAIT, 0x0000000000000000
>>  external_new_mask:
>> -        .quad   0x0000000180000000
>> +        .quad   PSW_MASK_64

I find the old numbers EASIER to parse (as I know how a PSW looks like) than a
macro that I first have to look up.

>>  io_new_mask:
>> -        .quad   0x0000000180000000
>> +        .quad   PSW_MASK_64
>>
> 
> This fails to compile with older versions of binutils (e.g. the ones in
> RHEL7):
> 
> pc-bios/s390-ccw/start.S: Assembler messages:
> pc-bios/s390-ccw/start.S:108: Error: found 'L', expected: ')'
> pc-bios/s390-ccw/start.S:108: Error: found 'L', expected: ')'
> pc-bios/s390-ccw/start.S:108: Error: junk at end of line, first
> unrecognized character is `L'
> pc-bios/s390-ccw/start.S:110: Error: found 'L', expected: ')'
> pc-bios/s390-ccw/start.S:110: Error: found 'L', expected: ')'
> pc-bios/s390-ccw/start.S:110: Error: found 'L', expected: ')'
> pc-bios/s390-ccw/start.S:110: Error: junk at end of line, first
> unrecognized character is `L'
> pc-bios/s390-ccw/start.S:112: Error: found 'L', expected: ')'
> pc-bios/s390-ccw/start.S:112: Error: junk at end of line, first
> unrecognized character is `L'
> pc-bios/s390-ccw/start.S:114: Error: found 'L', expected: ')'
> pc-bios/s390-ccw/start.S:114: Error: junk at end of line, first
> unrecognized character is `L'
> 
> You either need some macro-magic for this, or simply drop the patch.

So I suggest to drop this patch.
diff mbox series

Patch

diff --git a/pc-bios/s390-ccw/s390-arch.h b/pc-bios/s390-ccw/s390-arch.h
index 6da44d4436..d450c096d0 100644
--- a/pc-bios/s390-ccw/s390-arch.h
+++ b/pc-bios/s390-ccw/s390-arch.h
@@ -11,6 +11,20 @@ 
 #ifndef S390_ARCH_H
 #define S390_ARCH_H
 
+/* s390 psw bit masks */
+#define PSW_MASK_EXT        0x0100000000000000UL
+#define PSW_MASK_IOINT      0x0200000000000000ULL
+#define PSW_MASK_SHORTPSW   0x0008000000000000ULL
+#define PSW_MASK_WAIT       0x0002000000000000ULL
+#define PSW_MASK_EAMODE     0x0000000100000000ULL
+#define PSW_MASK_BAMODE     0x0000000080000000ULL
+#define PSW_MASK_SHORT_ADDR 0x000000007fffffffULL
+#define PSW_MASK_64         (PSW_MASK_EAMODE | PSW_MASK_BAMODE)
+#define PSW_MASK_DWAIT      (PSW_MASK_64 | PSW_MASK_WAIT)
+#define PSW_MASK_EWAIT      (PSW_MASK_DWAIT | PSW_MASK_IOINT | PSW_MASK_EXT)
+
+#ifndef __ASSEMBLER__
+
 typedef struct PSW {
     uint64_t mask;
     uint64_t addr;
@@ -24,15 +38,6 @@  typedef struct PSWLegacy {
 } __attribute__ ((aligned(8))) PSWLegacy;
 _Static_assert(sizeof(struct PSWLegacy) == 8, "PSWLegacy size incorrect");
 
-/* s390 psw bit masks */
-#define PSW_MASK_IOINT      0x0200000000000000ULL
-#define PSW_MASK_SHORTPSW   0x0008000000000000ULL
-#define PSW_MASK_WAIT       0x0002000000000000ULL
-#define PSW_MASK_EAMODE     0x0000000100000000ULL
-#define PSW_MASK_BAMODE     0x0000000080000000ULL
-#define PSW_MASK_SHORT_ADDR 0x000000007fffffffULL
-#define PSW_MASK_64         (PSW_MASK_EAMODE | PSW_MASK_BAMODE)
-
 /* Low core mapping */
 typedef struct LowCore {
     /* prefix area: defined by architecture */
@@ -107,5 +112,5 @@  static inline uint32_t store_prefix(void)
     asm volatile("stpx %0" : "=m" (address));
     return address;
 }
-
+#endif /* !__ASSEMBLER__ */
 #endif
diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
index ce519300a1..01c4c21b26 100644
--- a/pc-bios/s390-ccw/start.S
+++ b/pc-bios/s390-ccw/start.S
@@ -9,6 +9,7 @@ 
  * your option) any later version. See the COPYING file in the top-level
  * directory.
  */
+#include "s390-arch.h"
 
         .globl _start
 _start:
@@ -108,10 +109,10 @@  io_new_code:
 
         .align  8
 disabled_wait_psw:
-        .quad   0x0002000180000000,0x0000000000000000
+        .quad   PSW_MASK_DWAIT, 0x0000000000000000
 enabled_wait_psw:
-        .quad   0x0302000180000000,0x0000000000000000
+        .quad   PSW_MASK_EWAIT, 0x0000000000000000
 external_new_mask:
-        .quad   0x0000000180000000
+        .quad   PSW_MASK_64
 io_new_mask:
-        .quad   0x0000000180000000
+        .quad   PSW_MASK_64