Skip to content

Commit

Permalink
Disintegrate asm/system.h for S390
Browse files Browse the repository at this point in the history
Disintegrate asm/system.h for S390.

Signed-off-by: David Howells <[email protected]>
cc: [email protected]
  • Loading branch information
dhowells committed Mar 28, 2012
1 parent ae3a197 commit a0616cd
Show file tree
Hide file tree
Showing 39 changed files with 369 additions and 335 deletions.
1 change: 1 addition & 0 deletions arch/s390/crypto/crypt_s390.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define _CRYPTO_ARCH_S390_CRYPT_S390_H

#include <asm/errno.h>
#include <asm/facility.h>

#define CRYPT_S390_OP_MASK 0xFF00
#define CRYPT_S390_FUNC_MASK 0x00FF
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/system.h>
#include <asm/cmpxchg.h>

#define ATOMIC_INIT(i) { (i) }

Expand Down
35 changes: 35 additions & 0 deletions arch/s390/include/asm/barrier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright IBM Corp. 1999, 2009
*
* Author(s): Martin Schwidefsky <[email protected]>
*/

#ifndef __ASM_BARRIER_H
#define __ASM_BARRIER_H

/*
* Force strict CPU ordering.
* And yes, this is required on UP too when we're talking
* to devices.
*
* This is very similar to the ppc eieio/sync instruction in that is
* does a checkpoint syncronisation & makes sure that
* all memory ops have completed wrt other CPU's ( see 7-15 POP DJB ).
*/

#define eieio() asm volatile("bcr 15,0" : : : "memory")
#define SYNC_OTHER_CORES(x) eieio()
#define mb() eieio()
#define rmb() eieio()
#define wmb() eieio()
#define read_barrier_depends() do { } while(0)
#define smp_mb() mb()
#define smp_rmb() rmb()
#define smp_wmb() wmb()
#define smp_read_barrier_depends() read_barrier_depends()
#define smp_mb__before_clear_bit() smp_mb()
#define smp_mb__after_clear_bit() smp_mb()

#define set_mb(var, value) do { var = value; mb(); } while (0)

#endif /* __ASM_BARRIER_H */
76 changes: 76 additions & 0 deletions arch/s390/include/asm/ctl_reg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright IBM Corp. 1999, 2009
*
* Author(s): Martin Schwidefsky <[email protected]>
*/

#ifndef __ASM_CTL_REG_H
#define __ASM_CTL_REG_H

#ifdef __s390x__

#define __ctl_load(array, low, high) ({ \
typedef struct { char _[sizeof(array)]; } addrtype; \
asm volatile( \
" lctlg %1,%2,%0\n" \
: : "Q" (*(addrtype *)(&array)), \
"i" (low), "i" (high)); \
})

#define __ctl_store(array, low, high) ({ \
typedef struct { char _[sizeof(array)]; } addrtype; \
asm volatile( \
" stctg %1,%2,%0\n" \
: "=Q" (*(addrtype *)(&array)) \
: "i" (low), "i" (high)); \
})

#else /* __s390x__ */

#define __ctl_load(array, low, high) ({ \
typedef struct { char _[sizeof(array)]; } addrtype; \
asm volatile( \
" lctl %1,%2,%0\n" \
: : "Q" (*(addrtype *)(&array)), \
"i" (low), "i" (high)); \
})

#define __ctl_store(array, low, high) ({ \
typedef struct { char _[sizeof(array)]; } addrtype; \
asm volatile( \
" stctl %1,%2,%0\n" \
: "=Q" (*(addrtype *)(&array)) \
: "i" (low), "i" (high)); \
})

#endif /* __s390x__ */

#define __ctl_set_bit(cr, bit) ({ \
unsigned long __dummy; \
__ctl_store(__dummy, cr, cr); \
__dummy |= 1UL << (bit); \
__ctl_load(__dummy, cr, cr); \
})

#define __ctl_clear_bit(cr, bit) ({ \
unsigned long __dummy; \
__ctl_store(__dummy, cr, cr); \
__dummy &= ~(1UL << (bit)); \
__ctl_load(__dummy, cr, cr); \
})

#ifdef CONFIG_SMP

extern void smp_ctl_set_bit(int cr, int bit);
extern void smp_ctl_clear_bit(int cr, int bit);
#define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
#define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)

#else

#define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
#define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)

#endif /* CONFIG_SMP */

#endif /* __ASM_CTL_REG_H */
1 change: 0 additions & 1 deletion arch/s390/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ typedef s390_fp_regs compat_elf_fpregset_t;
typedef s390_compat_regs compat_elf_gregset_t;

#include <linux/sched.h> /* for task_struct */
#include <asm/system.h> /* for save_access_regs */
#include <asm/mmu_context.h>

#include <asm/vdso.h>
Expand Down
12 changes: 12 additions & 0 deletions arch/s390/include/asm/exec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright IBM Corp. 1999, 2009
*
* Author(s): Martin Schwidefsky <[email protected]>
*/

#ifndef __ASM_EXEC_H
#define __ASM_EXEC_H

extern unsigned long arch_align_stack(unsigned long sp);

#endif /* __ASM_EXEC_H */
63 changes: 63 additions & 0 deletions arch/s390/include/asm/facility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright IBM Corp. 1999, 2009
*
* Author(s): Martin Schwidefsky <[email protected]>
*/

#ifndef __ASM_FACILITY_H
#define __ASM_FACILITY_H

#include <linux/string.h>
#include <linux/preempt.h>
#include <asm/lowcore.h>

#define MAX_FACILITY_BIT (256*8) /* stfle_fac_list has 256 bytes */

/*
* The test_facility function uses the bit odering where the MSB is bit 0.
* That makes it easier to query facility bits with the bit number as
* documented in the Principles of Operation.
*/
static inline int test_facility(unsigned long nr)
{
unsigned char *ptr;

if (nr >= MAX_FACILITY_BIT)
return 0;
ptr = (unsigned char *) &S390_lowcore.stfle_fac_list + (nr >> 3);
return (*ptr & (0x80 >> (nr & 7))) != 0;
}

/**
* stfle - Store facility list extended
* @stfle_fac_list: array where facility list can be stored
* @size: size of passed in array in double words
*/
static inline void stfle(u64 *stfle_fac_list, int size)
{
unsigned long nr;

preempt_disable();
S390_lowcore.stfl_fac_list = 0;
asm volatile(
" .insn s,0xb2b10000,0(0)\n" /* stfl */
"0:\n"
EX_TABLE(0b, 0b)
: "=m" (S390_lowcore.stfl_fac_list));
nr = 4; /* bytes stored by stfl */
memcpy(stfle_fac_list, &S390_lowcore.stfl_fac_list, 4);
if (S390_lowcore.stfl_fac_list & 0x01000000) {
/* More facility bits available with stfle */
register unsigned long reg0 asm("0") = size - 1;

asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
: "+d" (reg0)
: "a" (stfle_fac_list)
: "memory", "cc");
nr = (reg0 + 1) * 8; /* # bytes stored by stfle */
}
memset((char *) stfle_fac_list + nr, 0, size * 8 - nr);
preempt_enable();
}

#endif /* __ASM_FACILITY_H */
14 changes: 14 additions & 0 deletions arch/s390/include/asm/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@ typedef struct {
.context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list), \
.context.gmap_list = LIST_HEAD_INIT(name.context.gmap_list),

static inline int tprot(unsigned long addr)
{
int rc = -EFAULT;

asm volatile(
" tprot 0(%1),0\n"
"0: ipm %0\n"
" srl %0,28\n"
"1:\n"
EX_TABLE(0b,1b)
: "+d" (rc) : "a" (addr) : "cc");
return rc;
}

#endif
1 change: 1 addition & 0 deletions arch/s390/include/asm/mmu_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <asm/pgalloc.h>
#include <asm/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/ctl_reg.h>
#include <asm-generic/mm_hooks.h>

static inline int init_new_context(struct task_struct *tsk,
Expand Down
24 changes: 24 additions & 0 deletions arch/s390/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define __ASM_S390_PROCESSOR_H

#include <linux/linkage.h>
#include <linux/irqflags.h>
#include <asm/cpu.h>
#include <asm/page.h>
#include <asm/ptrace.h>
Expand Down Expand Up @@ -156,6 +157,14 @@ unsigned long get_wchan(struct task_struct *p);
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->psw.addr)
#define KSTK_ESP(tsk) (task_pt_regs(tsk)->gprs[15])

static inline unsigned short stap(void)
{
unsigned short cpu_address;

asm volatile("stap %0" : "=m" (cpu_address));
return cpu_address;
}

/*
* Give up the time slice of the virtual PU.
*/
Expand Down Expand Up @@ -303,6 +312,21 @@ static inline void __noreturn disabled_wait(unsigned long code)
while (1);
}

/*
* Use to set psw mask except for the first byte which
* won't be changed by this function.
*/
static inline void
__set_psw_mask(unsigned long mask)
{
__load_psw_mask(mask | (arch_local_save_flags() & ~(-1UL >> 8)));
}

#define local_mcck_enable() \
__set_psw_mask(psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK)
#define local_mcck_disable() \
__set_psw_mask(psw_kernel_bits | PSW_MASK_DAT)

/*
* Basic Machine Check/Program Check Handler.
*/
Expand Down
14 changes: 14 additions & 0 deletions arch/s390/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ extern char vmpoff_cmd[];
#define NSS_NAME_SIZE 8
extern char kernel_nss_name[];

#ifdef CONFIG_PFAULT
extern int pfault_init(void);
extern void pfault_fini(void);
#else /* CONFIG_PFAULT */
#define pfault_init() ({-1;})
#define pfault_fini() do { } while (0)
#endif /* CONFIG_PFAULT */

extern void cmma_init(void);

extern void (*_machine_restart)(char *command);
extern void (*_machine_halt)(void);
extern void (*_machine_power_off)(void);

#else /* __ASSEMBLY__ */

#ifndef __s390x__
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#ifdef CONFIG_SMP

#include <asm/system.h>
#include <asm/lowcore.h>

#define raw_smp_processor_id() (S390_lowcore.cpu_nr)

Expand Down
Loading

0 comments on commit a0616cd

Please sign in to comment.