diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2008-04-30 07:38:45 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-04-30 07:38:47 -0400 |
commit | 2e5061e40af88070984e3769eafb5a06022375fd (patch) | |
tree | 2964cc88a68f826fc8e025d145f692e1e78740e0 /include/asm-s390 | |
parent | 8fc63658681f32e6e29f6d1138de933d7272e0ec (diff) |
[S390] Convert machine feature detection code to C.
From: Heiko Carstens <heiko.carstens@de.ibm.com>
From: Carsten Otte <cotte@de.ibm.com>
This lets us use defines for the magic bits in machine flags instead
of using plain numbers all over the place.
In addition on newer machines features/facilities are indicated by the
result of the stfl instruction. So we use these bits instead of trying
to execute new instructions and check wether we get an exception or
not.
Also the mvpg instruction is always available when in zArch mode,
whereas the idte instruction is only available in zArch mode. This
results in some minor optimizations.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'include/asm-s390')
-rw-r--r-- | include/asm-s390/setup.h | 33 | ||||
-rw-r--r-- | include/asm-s390/smp.h | 6 | ||||
-rw-r--r-- | include/asm-s390/system.h | 8 |
3 files changed, 33 insertions, 14 deletions
diff --git a/include/asm-s390/setup.h b/include/asm-s390/setup.h index aaf4b518b940..3a9e458fd8c3 100644 --- a/include/asm-s390/setup.h +++ b/include/asm-s390/setup.h | |||
@@ -59,23 +59,36 @@ extern unsigned int s390_noexec; | |||
59 | */ | 59 | */ |
60 | extern unsigned long machine_flags; | 60 | extern unsigned long machine_flags; |
61 | 61 | ||
62 | #define MACHINE_IS_VM (machine_flags & 1) | 62 | #define MACHINE_FLAG_VM (1UL << 0) |
63 | #define MACHINE_IS_P390 (machine_flags & 4) | 63 | #define MACHINE_FLAG_IEEE (1UL << 1) |
64 | #define MACHINE_HAS_MVPG (machine_flags & 16) | 64 | #define MACHINE_FLAG_P390 (1UL << 2) |
65 | #define MACHINE_IS_KVM (machine_flags & 64) | 65 | #define MACHINE_FLAG_CSP (1UL << 3) |
66 | #define MACHINE_HAS_IDTE (machine_flags & 128) | 66 | #define MACHINE_FLAG_MVPG (1UL << 4) |
67 | #define MACHINE_HAS_DIAG9C (machine_flags & 256) | 67 | #define MACHINE_FLAG_DIAG44 (1UL << 5) |
68 | #define MACHINE_FLAG_IDTE (1UL << 6) | ||
69 | #define MACHINE_FLAG_DIAG9C (1UL << 7) | ||
70 | #define MACHINE_FLAG_MVCOS (1UL << 8) | ||
71 | #define MACHINE_FLAG_KVM (1UL << 9) | ||
72 | |||
73 | #define MACHINE_IS_VM (machine_flags & MACHINE_FLAG_VM) | ||
74 | #define MACHINE_IS_KVM (machine_flags & MACHINE_FLAG_KVM) | ||
75 | #define MACHINE_IS_P390 (machine_flags & MACHINE_FLAG_P390) | ||
76 | #define MACHINE_HAS_DIAG9C (machine_flags & MACHINE_FLAG_DIAG9C) | ||
68 | 77 | ||
69 | #ifndef __s390x__ | 78 | #ifndef __s390x__ |
70 | #define MACHINE_HAS_IEEE (machine_flags & 2) | 79 | #define MACHINE_HAS_IEEE (machine_flags & MACHINE_FLAG_IEEE) |
71 | #define MACHINE_HAS_CSP (machine_flags & 8) | 80 | #define MACHINE_HAS_CSP (machine_flags & MACHINE_FLAG_CSP) |
81 | #define MACHINE_HAS_IDTE (0) | ||
72 | #define MACHINE_HAS_DIAG44 (1) | 82 | #define MACHINE_HAS_DIAG44 (1) |
83 | #define MACHINE_HAS_MVPG (machine_flags & MACHINE_FLAG_MVPG) | ||
73 | #define MACHINE_HAS_MVCOS (0) | 84 | #define MACHINE_HAS_MVCOS (0) |
74 | #else /* __s390x__ */ | 85 | #else /* __s390x__ */ |
75 | #define MACHINE_HAS_IEEE (1) | 86 | #define MACHINE_HAS_IEEE (1) |
76 | #define MACHINE_HAS_CSP (1) | 87 | #define MACHINE_HAS_CSP (1) |
77 | #define MACHINE_HAS_DIAG44 (machine_flags & 32) | 88 | #define MACHINE_HAS_IDTE (machine_flags & MACHINE_FLAG_IDTE) |
78 | #define MACHINE_HAS_MVCOS (machine_flags & 512) | 89 | #define MACHINE_HAS_DIAG44 (machine_flags & MACHINE_FLAG_DIAG44) |
90 | #define MACHINE_HAS_MVPG (1) | ||
91 | #define MACHINE_HAS_MVCOS (machine_flags & MACHINE_FLAG_MVCOS) | ||
79 | #endif /* __s390x__ */ | 92 | #endif /* __s390x__ */ |
80 | 93 | ||
81 | #define MACHINE_HAS_SCLP (!MACHINE_IS_P390) | 94 | #define MACHINE_HAS_SCLP (!MACHINE_IS_P390) |
diff --git a/include/asm-s390/smp.h b/include/asm-s390/smp.h index 8376b195a1b6..ae89cf2478fc 100644 --- a/include/asm-s390/smp.h +++ b/include/asm-s390/smp.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <asm/lowcore.h> | 19 | #include <asm/lowcore.h> |
20 | #include <asm/sigp.h> | 20 | #include <asm/sigp.h> |
21 | #include <asm/ptrace.h> | 21 | #include <asm/ptrace.h> |
22 | #include <asm/system.h> | ||
22 | 23 | ||
23 | /* | 24 | /* |
24 | s390 specific smp.c headers | 25 | s390 specific smp.c headers |
@@ -53,10 +54,7 @@ extern void machine_power_off_smp(void); | |||
53 | 54 | ||
54 | static inline __u16 hard_smp_processor_id(void) | 55 | static inline __u16 hard_smp_processor_id(void) |
55 | { | 56 | { |
56 | __u16 cpu_address; | 57 | return stap(); |
57 | |||
58 | asm volatile("stap %0" : "=m" (cpu_address)); | ||
59 | return cpu_address; | ||
60 | } | 58 | } |
61 | 59 | ||
62 | /* | 60 | /* |
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h index 79bdbf4b33a7..c819ae25a842 100644 --- a/include/asm-s390/system.h +++ b/include/asm-s390/system.h | |||
@@ -432,6 +432,14 @@ static inline unsigned int stfl(void) | |||
432 | return S390_lowcore.stfl_fac_list; | 432 | return S390_lowcore.stfl_fac_list; |
433 | } | 433 | } |
434 | 434 | ||
435 | static inline unsigned short stap(void) | ||
436 | { | ||
437 | unsigned short cpu_address; | ||
438 | |||
439 | asm volatile("stap %0" : "=m" (cpu_address)); | ||
440 | return cpu_address; | ||
441 | } | ||
442 | |||
435 | extern void (*_machine_restart)(char *command); | 443 | extern void (*_machine_restart)(char *command); |
436 | extern void (*_machine_halt)(void); | 444 | extern void (*_machine_halt)(void); |
437 | extern void (*_machine_power_off)(void); | 445 | extern void (*_machine_power_off)(void); |