summaryrefslogtreecommitdiffstats
path: root/include/asm-s390x
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2001-03-09 20:33:35 +0000
committerRalf Baechle <ralf@linux-mips.org>2001-03-09 20:33:35 +0000
commit116674acc97ba75a720329996877077d988443a2 (patch)
tree6a3f2ff0b612ae2ee8a3f3509370c9e6333a53b3 /include/asm-s390x
parent71118c319fcae4a138f16e35b4f7e0a6d53ce2ca (diff)
Merge with Linux 2.4.2.
Diffstat (limited to 'include/asm-s390x')
-rw-r--r--include/asm-s390x/a.out.h38
-rw-r--r--include/asm-s390x/atomic.h236
-rw-r--r--include/asm-s390x/bitops.h884
-rw-r--r--include/asm-s390x/bugs.h22
-rw-r--r--include/asm-s390x/byteorder.h113
-rw-r--r--include/asm-s390x/cache.h16
-rw-r--r--include/asm-s390x/ccwcache.h84
-rw-r--r--include/asm-s390x/chandev.h151
-rw-r--r--include/asm-s390x/checksum.h188
-rw-r--r--include/asm-s390x/current.h31
-rw-r--r--include/asm-s390x/dasd.h339
-rw-r--r--include/asm-s390x/debug.h210
-rw-r--r--include/asm-s390x/delay.h22
-rw-r--r--include/asm-s390x/div64.h10
-rw-r--r--include/asm-s390x/dma.h16
-rw-r--r--include/asm-s390x/ebcdic.h55
-rw-r--r--include/asm-s390x/elf.h82
-rw-r--r--include/asm-s390x/errno.h140
-rw-r--r--include/asm-s390x/fcntl.h85
-rw-r--r--include/asm-s390x/gdb-stub.h18
-rw-r--r--include/asm-s390x/hardirq.h108
-rw-r--r--include/asm-s390x/hdreg.h13
-rw-r--r--include/asm-s390x/idals.h57
-rw-r--r--include/asm-s390x/ide.h54
-rw-r--r--include/asm-s390x/init.h29
-rw-r--r--include/asm-s390x/io.h94
-rw-r--r--include/asm-s390x/ioctl.h78
-rw-r--r--include/asm-s390x/ioctls.h89
-rw-r--r--include/asm-s390x/ipc.h39
-rw-r--r--include/asm-s390x/ipcbuf.h28
-rw-r--r--include/asm-s390x/irq.h962
-rw-r--r--include/asm-s390x/irqextras390.h151
-rw-r--r--include/asm-s390x/lowcore.h196
-rw-r--r--include/asm-s390x/major.h150
-rw-r--r--include/asm-s390x/mathemu.h48
-rw-r--r--include/asm-s390x/misc390.h15
-rw-r--r--include/asm-s390x/mman.h46
-rw-r--r--include/asm-s390x/mmu.h7
-rw-r--r--include/asm-s390x/mmu_context.h45
-rw-r--r--include/asm-s390x/module.h11
-rw-r--r--include/asm-s390x/msgbuf.h27
-rw-r--r--include/asm-s390x/namei.h21
-rw-r--r--include/asm-s390x/page.h94
-rw-r--r--include/asm-s390x/param.h32
-rw-r--r--include/asm-s390x/pgalloc.h315
-rw-r--r--include/asm-s390x/pgtable.h486
-rw-r--r--include/asm-s390x/poll.h33
-rw-r--r--include/asm-s390x/posix_types.h74
-rw-r--r--include/asm-s390x/processor.h227
-rw-r--r--include/asm-s390x/ptrace.h326
-rw-r--r--include/asm-s390x/queue.h170
-rw-r--r--include/asm-s390x/resource.h56
-rw-r--r--include/asm-s390x/s390-gdbregs.h89
-rw-r--r--include/asm-s390x/s390-regs-common.h115
-rw-r--r--include/asm-s390x/s390_ext.h30
-rw-r--r--include/asm-s390x/s390dyn.h50
-rw-r--r--include/asm-s390x/s390io.h95
-rw-r--r--include/asm-s390x/s390mach.h106
-rw-r--r--include/asm-s390x/scatterlist.h13
-rw-r--r--include/asm-s390x/segment.h4
-rw-r--r--include/asm-s390x/semaphore-helper.h100
-rw-r--r--include/asm-s390x/semaphore.h191
-rw-r--r--include/asm-s390x/sembuf.h22
-rw-r--r--include/asm-s390x/setup.h52
-rw-r--r--include/asm-s390x/shmbuf.h38
-rw-r--r--include/asm-s390x/shmparam.h13
-rw-r--r--include/asm-s390x/sigcontext.h56
-rw-r--r--include/asm-s390x/siginfo.h240
-rw-r--r--include/asm-s390x/signal.h185
-rw-r--r--include/asm-s390x/sigp.h159
-rw-r--r--include/asm-s390x/smp.h78
-rw-r--r--include/asm-s390x/smplock.h62
-rw-r--r--include/asm-s390x/socket.h69
-rw-r--r--include/asm-s390x/sockios.h20
-rw-r--r--include/asm-s390x/softirq.h35
-rw-r--r--include/asm-s390x/spinlock.h119
-rw-r--r--include/asm-s390x/stat.h33
-rw-r--r--include/asm-s390x/statfs.h33
-rw-r--r--include/asm-s390x/string.h121
-rw-r--r--include/asm-s390x/system.h264
-rw-r--r--include/asm-s390x/termbits.h180
-rw-r--r--include/asm-s390x/termios.h114
-rw-r--r--include/asm-s390x/timex.h29
-rw-r--r--include/asm-s390x/todclk.h19
-rw-r--r--include/asm-s390x/types.h69
-rw-r--r--include/asm-s390x/uaccess.h559
-rw-r--r--include/asm-s390x/ucontext.h22
-rw-r--r--include/asm-s390x/unaligned.h24
-rw-r--r--include/asm-s390x/unistd.h346
-rw-r--r--include/asm-s390x/user.h77
-rw-r--r--include/asm-s390x/xor.h1
91 files changed, 10653 insertions, 0 deletions
diff --git a/include/asm-s390x/a.out.h b/include/asm-s390x/a.out.h
new file mode 100644
index 000000000..72adee6ef
--- /dev/null
+++ b/include/asm-s390x/a.out.h
@@ -0,0 +1,38 @@
+/*
+ * include/asm-s390/a.out.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *
+ * Derived from "include/asm-i386/a.out.h"
+ * Copyright (C) 1992, Linus Torvalds
+ *
+ * I don't think we'll ever need a.out ...
+ */
+
+#ifndef __S390_A_OUT_H__
+#define __S390_A_OUT_H__
+
+struct exec
+{
+ unsigned long a_info; /* Use macros N_MAGIC, etc for access */
+ unsigned a_text; /* length of text, in bytes */
+ unsigned a_data; /* length of data, in bytes */
+ unsigned a_bss; /* length of uninitialized data area for file, in bytes */
+ unsigned a_syms; /* length of symbol table data in file, in bytes */
+ unsigned a_entry; /* start address */
+ unsigned a_trsize; /* length of relocation info for text, in bytes */
+ unsigned a_drsize; /* length of relocation info for data, in bytes */
+};
+
+#define N_TRSIZE(a) ((a).a_trsize)
+#define N_DRSIZE(a) ((a).a_drsize)
+#define N_SYMSIZE(a) ((a).a_syms)
+
+#ifdef __KERNEL__
+
+#define STACK_TOP TASK_SIZE
+
+#endif
+
+#endif /* __A_OUT_GNU_H__ */
diff --git a/include/asm-s390x/atomic.h b/include/asm-s390x/atomic.h
new file mode 100644
index 000000000..29e40413c
--- /dev/null
+++ b/include/asm-s390x/atomic.h
@@ -0,0 +1,236 @@
+#ifndef __ARCH_S390_ATOMIC__
+#define __ARCH_S390_ATOMIC__
+
+/*
+ * include/asm-s390x/atomic.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
+ * Denis Joseph Barrow
+ *
+ * Derived from "include/asm-i386/bitops.h"
+ * Copyright (C) 1992, Linus Torvalds
+ *
+ */
+
+/*
+ * Atomic operations that C can't guarantee us. Useful for
+ * resource counting etc..
+ * S390 uses 'Compare And Swap' for atomicity in SMP enviroment
+ */
+
+typedef struct { volatile int counter; } atomic_t __attribute__ ((aligned (4)));
+#define ATOMIC_INIT(i) { (i) }
+
+#define atomic_eieio() __asm__ __volatile__ ("BCR 15,0")
+
+static __inline__ int atomic_read(atomic_t *v)
+{
+ int retval;
+ __asm__ __volatile__("bcr 15,0\n\t"
+ "l %0,%1"
+ : "=d" (retval) : "m" (*v) );
+ return retval;
+}
+
+static __inline__ void atomic_set(atomic_t *v, int i)
+{
+ __asm__ __volatile__("st %1,%0\n\t"
+ "bcr 15,0"
+ : "=m" (*v) : "d" (i) );
+}
+
+static __inline__ void atomic_add(int i, atomic_t *v)
+{
+ __asm__ __volatile__(" la 2,%0\n"
+ " l 0,0(2)\n"
+ "0: lr 1,0\n"
+ " ar 1,%1\n"
+ " cs 0,1,0(2)\n"
+ " jl 0b"
+ : "+m" (*v) : "d" (i) : "0", "1", "2", "cc" );
+}
+
+static __inline__ int atomic_add_return (int i, atomic_t *v)
+{
+ int newval;
+ __asm__ __volatile__(" la 1,%0\n"
+ " l 0,0(1)\n"
+ "0: lr %1,0\n"
+ " ar %1,%2\n"
+ " cs 0,%1,0(1)\n"
+ " jl 0b"
+ : "+m" (*v), "=&d" (newval)
+ : "d" (i) : "0", "1", "cc" );
+ return newval;
+}
+
+static __inline__ int atomic_inc_and_test(volatile atomic_t *v)
+{
+ int i;
+
+ __asm__ __volatile__(" l 0,%0\n"
+ "0: lr %1,0\n"
+ " ahi %1,1\n"
+ " cs 0,%1,%0\n"
+ " jl 0b"
+ : "+m" (*v), "=&d" (i) : : "0", "cc" );
+ return i != 0;
+}
+
+static __inline__ int atomic_add_negative(int i, atomic_t *v)
+{
+ int newval;
+ __asm__ __volatile__(" la 1,%0\n"
+ " l 0,0(1)\n"
+ "0: lr %1,0\n"
+ " ar %1,%2\n"
+ " cs 0,%1,0(1)\n"
+ " jl 0b\n"
+ : "+m" (*v), "=&d" (newval)
+ : "d" (i) : "0", "1", "cc" );
+ return newval < 0;
+}
+
+static __inline__ void atomic_sub(int i, atomic_t *v)
+{
+ __asm__ __volatile__(" la 2,%0\n"
+ " l 0,0(2)\n"
+ "0: lr 1,0\n"
+ " sr 1,%1\n"
+ " cs 0,1,0(2)\n"
+ " jl 0b"
+ : "+m" (*v) : "d" (i) : "0", "1", "2", "cc" );
+}
+
+static __inline__ void atomic_inc(volatile atomic_t *v)
+{
+ __asm__ __volatile__(" la 2,%0\n"
+ " l 0,0(2)\n"
+ "0: lr 1,0\n"
+ " ahi 1,1\n"
+ " cs 0,1,0(2)\n"
+ " jl 0b"
+ : "+m" (*v) : : "0", "1", "2", "cc" );
+}
+
+static __inline__ int atomic_inc_return(volatile atomic_t *v)
+{
+ int i;
+ __asm__ __volatile__(" la 1,%0\n"
+ " l 0,0(1)\n"
+ "0: lr %1,0\n"
+ " ahi %1,1\n"
+ " cs 0,%1,0(1)\n"
+ " jl 0b"
+ : "+m" (*v), "=&d" (i) : : "0", "1", "cc" );
+ return i;
+}
+
+static __inline__ void atomic_dec(volatile atomic_t *v)
+{
+ __asm__ __volatile__(" la 2,%0\n"
+ " l 0,0(2)\n"
+ "0: lr 1,0\n"
+ " ahi 1,-1\n"
+ " cs 0,1,0(2)\n"
+ " jl 0b"
+ : "+m" (*v) : : "0", "1", "2", "cc" );
+}
+
+static __inline__ int atomic_dec_return(volatile atomic_t *v)
+{
+ int i;
+ __asm__ __volatile__(" la 1,%0\n"
+ " l 0,0(1)\n"
+ "0: lr %1,0\n"
+ " ahi %1,-1\n"
+ " cs 0,%1,0(1)\n"
+ " jl 0b"
+ : "+m" (*v), "=&d" (i) : : "0", "1", "cc" );
+ return i;
+}
+
+static __inline__ int atomic_dec_and_test(volatile atomic_t *v)
+{
+ int i;
+ __asm__ __volatile__(" la 1,%0\n"
+ " l 0,0(1)\n"
+ "0: lr %1,0\n"
+ " ahi %1,-1\n"
+ " cs 0,%1,0(1)\n"
+ " jl 0b"
+ : "+m" (*v), "=&d" (i) : : "0", "1", "cc");
+ return i == 0;
+}
+
+static __inline__ void atomic_clear_mask(unsigned long mask, atomic_t *v)
+{
+ __asm__ __volatile__(" la 2,%0\n"
+ " l 0,0(2)\n"
+ "0: lr 1,0\n"
+ " nr 1,%1\n"
+ " cs 0,1,0(2)\n"
+ " jl 0b"
+ : "+m" (*v) : "d" (~(mask))
+ : "0", "1", "2", "cc" );
+}
+
+static __inline__ void atomic_set_mask(unsigned long mask, atomic_t *v)
+{
+ __asm__ __volatile__(" la 2,%0\n"
+ " l 0,0(2)\n"
+ "0: lr 1,0\n"
+ " or 1,%1\n"
+ " cs 0,1,0(2)\n"
+ " jl 0b"
+ : "+m" (*v) : "d" (mask) : "0", "1", "2", "cc" );
+}
+
+/*
+ returns 0 if expected_oldval==value in *v ( swap was successful )
+ returns 1 if unsuccessful.
+*/
+static __inline__ int
+atomic_compare_and_swap(int expected_oldval,int new_val,atomic_t *v)
+{
+ int retval;
+
+ __asm__ __volatile__(
+ " la 1,%1\n"
+ " lr 0,%2\n"
+ " cs 0,%3,0(1)\n"
+ " ipm %0\n"
+ " srl %0,28"
+ : "=&r" (retval), "+m" (*v)
+ : "d" (expected_oldval) , "d" (new_val)
+ : "0", "1", "cc");
+ return retval;
+}
+
+/*
+ Spin till *v = expected_oldval then swap with newval.
+ */
+static __inline__ void
+atomic_compare_and_swap_spin(int expected_oldval,int new_val,atomic_t *v)
+{
+ __asm__ __volatile__(
+ " la 1,%0\n"
+ "0: lr 0,%1\n"
+ " cs 0,%2,0(1)\n"
+ " jl 0b\n"
+ : "+m" (*v)
+ : "d" (expected_oldval) , "d" (new_val)
+ : "cc", "0", "1");
+}
+
+#define atomic_compare_and_swap_debug(where,from,to) \
+if (atomic_compare_and_swap ((from), (to), (where))) {\
+ printk (KERN_WARNING"%s/%d atomic counter:%s couldn't be changed from %d(%s) to %d(%s), was %d\n",\
+ __FILE__,__LINE__,#where,(from),#from,(to),#to,atomic_read (where));\
+ atomic_set(where,(to));\
+}
+
+#endif /* __ARCH_S390_ATOMIC __ */
+
diff --git a/include/asm-s390x/bitops.h b/include/asm-s390x/bitops.h
new file mode 100644
index 000000000..6f4204e72
--- /dev/null
+++ b/include/asm-s390x/bitops.h
@@ -0,0 +1,884 @@
+/*
+ * include/asm-s390/bitops.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/bitops.h"
+ * Copyright (C) 1992, Linus Torvalds
+ *
+ */
+
+#ifndef _S390_BITOPS_H
+#define _S390_BITOPS_H
+
+/*
+ * bit 0 is the LSB of *addr; bit 63 is the MSB of *addr;
+ * bit 64 is the LSB of *(addr+8). That combined with the
+ * big endian byte order on S390 give the following bit
+ * order in memory:
+ * 3f 3e 3d 3c 3b 3a 39 38 37 36 35 34 33 32 31 30
+ * 2f 2e 2d 2c 2b 2a 29 28 27 26 25 24 23 22 21 20
+ * 1f 1e 1d 1c 1b 1a 19 18 17 16 15 14 13 12 11 10
+ * 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00
+ * after that follows the next long with bit numbers
+ * 7f 7e 7d 7c 7b 7a 79 78 77 76 75 74 73 72 71 70
+ * 6f 6e 6d 6c 6b 6a 69 68 67 66 65 64 63 62 61 60
+ * 5f 5e 5d 5c 5b 5a 59 58 57 56 55 54 53 52 51 50
+ * 4f 4e 4d 4c 4b 4a 49 48 47 46 45 44 43 42 41 40
+ * The reason for this bit ordering is the fact that
+ * in the architecture independent code bits operations
+ * of the form "flags |= (1 << bitnr)" are used INTERMIXED
+ * with operation of the form "set_bit(bitnr, flags)".
+ */
+#include <linux/config.h>
+
+/* set ALIGN_CS to 1 if the SMP safe bit operations should
+ * align the address to 4 byte boundary. It seems to work
+ * without the alignment.
+ */
+#define ALIGN_CS 0
+
+/* bitmap tables from arch/S390/kernel/bitmap.S */
+extern const char _oi_bitmap[];
+extern const char _ni_bitmap[];
+extern const char _zb_findmap[];
+
+#ifdef CONFIG_SMP
+/*
+ * SMP save set_bit routine based on compare and swap (CS)
+ */
+static __inline__ void set_bit_cs(unsigned long nr, volatile void * addr)
+{
+ unsigned long bits, mask;
+ __asm__ __volatile__(
+#if ALIGN_CS == 1
+ " lghi %2,3\n" /* CS must be aligned on 4 byte b. */
+ " ngr %2,%1\n" /* isolate last 2 bits of address */
+ " xgr %1,%2\n" /* make addr % 4 == 0 */
+ " sllg %2,%2,3\n"
+ " agr %0,%2\n" /* add alignement to bitnr */
+#endif
+ " lghi %2,63\n"
+ " nr %2,%0\n" /* make shift value */
+ " xr %0,%2\n"
+ " srlg %0,%0,3\n"
+ " lghi %3,1\n"
+ " la %1,0(%0,%1)\n" /* calc. address for CS */
+ " sllg %3,%3,0(%2)\n" /* make OR mask */
+ " lg %0,0(%1)\n"
+ "0: lgr %2,%0\n" /* CS loop starts here */
+ " ogr %2,%3\n" /* set bit */
+ " csg %0,%2,0(%1)\n"
+ " jl 0b"
+ : "+a" (nr), "+a" (addr), "=a" (bits), "=d" (mask) :
+ : "cc", "memory" );
+}
+
+/*
+ * SMP save clear_bit routine based on compare and swap (CS)
+ */
+static __inline__ void clear_bit_cs(unsigned long nr, volatile void * addr)
+{
+ unsigned long bits, mask;
+ __asm__ __volatile__(
+#if ALIGN_CS == 1
+ " lghi %2,3\n" /* CS must be aligned on 4 byte b. */
+ " ngr %2,%1\n" /* isolate last 2 bits of address */
+ " xgr %1,%2\n" /* make addr % 4 == 0 */
+ " sllg %2,%2,3\n"
+ " agr %0,%2\n" /* add alignement to bitnr */
+#endif
+ " lghi %2,63\n"
+ " nr %2,%0\n" /* make shift value */
+ " xr %0,%2\n"
+ " srlg %0,%0,3\n"
+ " lghi %3,-2\n"
+ " la %1,0(%0,%1)\n" /* calc. address for CS */
+ " lghi %3,-2\n"
+ " rllg %3,%3,0(%2)\n" /* make AND mask */
+ " lg %0,0(%1)\n"
+ "0: lgr %2,%0\n" /* CS loop starts here */
+ " ngr %2,%3\n" /* clear bit */
+ " csg %0,%2,0(%1)\n"
+ " jl 0b"
+ : "+a" (nr), "+a" (addr), "=a" (bits), "=d" (mask) :
+ : "cc", "memory" );
+}
+
+/*
+ * SMP save change_bit routine based on compare and swap (CS)
+ */
+static __inline__ void change_bit_cs(unsigned long nr, volatile void * addr)
+{
+ unsigned long bits, mask;
+ __asm__ __volatile__(
+#if ALIGN_CS == 1
+ " lghi %2,3\n" /* CS must be aligned on 4 byte b. */
+ " ngr %2,%1\n" /* isolate last 2 bits of address */
+ " xgr %1,%2\n" /* make addr % 4 == 0 */
+ " sllg %2,%2,3\n"
+ " agr %0,%2\n" /* add alignement to bitnr */
+#endif
+ " lghi %2,63\n"
+ " nr %2,%0\n" /* make shift value */
+ " xr %0,%2\n"
+ " srlg %0,%0,3\n"
+ " lghi %3,1\n"
+ " la %1,0(%0,%1)\n" /* calc. address for CS */
+ " sllg %3,%3,0(%2)\n" /* make XR mask */
+ " lg %0,0(%1)\n"
+ "0: lgr %2,%0\n" /* CS loop starts here */
+ " xgr %2,%3\n" /* change bit */
+ " csg %0,%2,0(%1)\n"
+ " jl 0b"
+ : "+a" (nr), "+a" (addr), "=a" (bits), "=d" (mask) :
+ : "cc", "memory" );
+}
+
+/*
+ * SMP save test_and_set_bit routine based on compare and swap (CS)
+ */
+static __inline__ int
+test_and_set_bit_cs(unsigned long nr, volatile void * addr)
+{
+ unsigned long bits, mask;
+ __asm__ __volatile__(
+#if ALIGN_CS == 1
+ " lghi %2,3\n" /* CS must be aligned on 4 byte b. */
+ " ngr %2,%1\n" /* isolate last 2 bits of address */
+ " xgr %1,%2\n" /* make addr % 4 == 0 */
+ " sllg %2,%2,3\n"
+ " agr %0,%2\n" /* add alignement to bitnr */
+#endif
+ " lghi %2,63\n"
+ " nr %2,%0\n" /* make shift value */
+ " xr %0,%2\n"
+ " srlg %0,%0,3\n"
+ " lghi %3,1\n"
+ " la %1,0(%0,%1)\n" /* calc. address for CS */
+ " sllg %3,%3,0(%2)\n" /* make OR mask */
+ " lg %0,0(%1)\n"
+ "0: lgr %2,%0\n" /* CS loop starts here */
+ " ogr %2,%3\n" /* set bit */
+ " csg %0,%2,0(%1)\n"
+ " jl 0b\n"
+ " ngr %0,%3\n" /* isolate old bit */
+ : "+a" (nr), "+a" (addr), "=a" (bits), "=d" (mask) :
+ : "cc", "memory" );
+ return nr != 0;
+}
+
+/*
+ * SMP save test_and_clear_bit routine based on compare and swap (CS)
+ */
+static __inline__ int
+test_and_clear_bit_cs(unsigned long nr, volatile void * addr)
+{
+ unsigned long bits, mask;
+ __asm__ __volatile__(
+#if ALIGN_CS == 1
+ " lghi %2,3\n" /* CS must be aligned on 4 byte b. */
+ " ngr %2,%1\n" /* isolate last 2 bits of address */
+ " xgr %1,%2\n" /* make addr % 4 == 0 */
+ " sllg %2,%2,3\n"
+ " agr %0,%2\n" /* add alignement to bitnr */
+#endif
+ " lghi %2,63\n"
+ " nr %2,%0\n" /* make shift value */
+ " xr %0,%2\n"
+ " srlg %0,%0,3\n"
+ " lghi %3,-2\n"
+ " la %1,0(%0,%1)\n" /* calc. address for CS */
+ " rllg %3,%3,0(%2)\n" /* make AND mask */
+ " lg %0,0(%1)\n"
+ "0: lgr %2,%0\n" /* CS loop starts here */
+ " ngr %2,%3\n" /* clear bit */
+ " csg %0,%2,0(%1)\n"
+ " jl 0b\n"
+ " xgr %0,%2\n" /* isolate old bit */
+ : "+a" (nr), "+a" (addr), "=a" (bits), "=d" (mask) :
+ : "cc", "memory" );
+ return nr != 0;
+}
+
+/*
+ * SMP save test_and_change_bit routine based on compare and swap (CS)
+ */
+static __inline__ int
+test_and_change_bit_cs(unsigned long nr, volatile void * addr)
+{
+ unsigned long bits, mask;
+ __asm__ __volatile__(
+#if ALIGN_CS == 1
+ " lghi %2,3\n" /* CS must be aligned on 4 byte b. */
+ " ngr %2,%1\n" /* isolate last 2 bits of address */
+ " xgr %1,%2\n" /* make addr % 4 == 0 */
+ " sllg %2,%2,3\n"
+ " agr %0,%2\n" /* add alignement to bitnr */
+#endif
+ " lghi %2,63\n"
+ " nr %2,%0\n" /* make shift value */
+ " xr %0,%2\n"
+ " srlg %0,%0,3\n"
+ " lghi %3,1\n"
+ " la %1,0(%0,%1)\n" /* calc. address for CS */
+ " sllg %3,%3,0(%2)\n" /* make OR mask */
+ " lg %0,0(%1)\n"
+ "0: lgr %2,%0\n" /* CS loop starts here */
+ " xgr %2,%3\n" /* change bit */
+ " csg %0,%2,0(%1)\n"
+ " jl 0b\n"
+ " ngr %0,%3\n" /* isolate old bit */
+ : "+a" (nr), "+a" (addr), "=a" (bits), "=d" (mask) :
+ : "cc", "memory" );
+ return nr != 0;
+}
+#endif /* CONFIG_SMP */
+
+/*
+ * fast, non-SMP set_bit routine
+ */
+static __inline__ void __set_bit(unsigned long nr, volatile void * addr)
+{
+ __asm__ __volatile__(
+ " lghi 2,56\n"
+ " lghi 1,7\n"
+ " xgr 2,%0\n"
+ " nr 1,%0\n"
+ " srlg 2,2,3\n"
+ " la 2,0(2,%1)\n"
+ " la 1,0(1,%2)\n"
+ " oc 0(1,2),0(1)"
+ : : "a" (nr), "a" (addr), "a" (&_oi_bitmap)
+ : "cc", "memory", "1", "2" );
+}
+
+static __inline__ void
+__constant_set_bit(const unsigned long nr, volatile void * addr)
+{
+ switch (nr&7) {
+ case 0:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x01"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory");
+ break;
+ case 1:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x02"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 2:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x04"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 3:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x08"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 4:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x10"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 5:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x20"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 6:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x40"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 7:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "oi 0(1),0x80"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ }
+}
+
+#define set_bit_simple(nr,addr) \
+(__builtin_constant_p((nr)) ? \
+ __constant_set_bit((nr),(addr)) : \
+ __set_bit((nr),(addr)) )
+
+/*
+ * fast, non-SMP clear_bit routine
+ */
+static __inline__ void
+__clear_bit(unsigned long nr, volatile void * addr)
+{
+ __asm__ __volatile__(
+ " lghi 2,56\n"
+ " lghi 1,7\n"
+ " xgr 2,%0\n"
+ " nr 1,%0\n"
+ " srlg 2,2,3\n"
+ " la 2,0(2,%1)\n"
+ " la 1,0(1,%2)\n"
+ " nc 0(1,2),0(1)"
+ : : "d" (nr), "a" (addr), "a" (&_ni_bitmap)
+ : "cc", "memory", "1", "2" );
+}
+
+static __inline__ void
+__constant_clear_bit(const unsigned long nr, volatile void * addr)
+{
+ switch (nr&7) {
+ case 0:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0xFE"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 1:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0xFD"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 2:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0xFB"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 3:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0xF7"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 4:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0xEF"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "cc", "memory" );
+ break;
+ case 5:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0xDF"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 6:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0xBF"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 7:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "ni 0(1),0x7F"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ }
+}
+
+#define clear_bit_simple(nr,addr) \
+(__builtin_constant_p((nr)) ? \
+ __constant_clear_bit((nr),(addr)) : \
+ __clear_bit((nr),(addr)) )
+
+/*
+ * fast, non-SMP change_bit routine
+ */
+static __inline__ void __change_bit(unsigned long nr, volatile void * addr)
+{
+ __asm__ __volatile__(
+ " lghi 2,56\n"
+ " lghi 1,7\n"
+ " xgr 2,%0\n"
+ " nr 1,%0\n"
+ " srlg 2,2,3\n"
+ " la 2,0(2,%1)\n"
+ " la 1,0(1,%2)\n"
+ " xc 0(1,2),0(1)"
+ : : "d" (nr), "a" (addr), "a" (&_oi_bitmap)
+ : "cc", "memory", "1", "2" );
+}
+
+static __inline__ void
+__constant_change_bit(const unsigned long nr, volatile void * addr)
+{
+ switch (nr&7) {
+ case 0:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x01"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "cc", "memory" );
+ break;
+ case 1:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x02"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "cc", "memory" );
+ break;
+ case 2:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x04"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "cc", "memory" );
+ break;
+ case 3:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x08"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "cc", "memory" );
+ break;
+ case 4:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x10"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "cc", "memory" );
+ break;
+ case 5:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x20"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 6:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x40"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ case 7:
+ __asm__ __volatile__ ("la 1,%0\n\t"
+ "xi 0(1),0x80"
+ : "=m" (*((volatile char *) addr + ((nr>>3)^7)))
+ : : "1", "cc", "memory" );
+ break;
+ }
+}
+
+#define change_bit_simple(nr,addr) \
+(__builtin_constant_p((nr)) ? \
+ __constant_change_bit((nr),(addr)) : \
+ __change_bit((nr),(addr)) )
+
+/*
+ * fast, non-SMP test_and_set_bit routine
+ */
+static __inline__ int
+test_and_set_bit_simple(unsigned long nr, volatile void * addr)
+{
+ int oldbit;
+ __asm__ __volatile__(
+ " lghi 1,56\n"
+ " lghi 2,7\n"
+ " xgr 1,%1\n"
+ " nr 2,%1\n"
+ " srlg 1,1,3\n"
+ " la 1,0(1,%2)\n"
+ " ic %0,0(1)\n"
+ " srl %0,0(2)\n"
+ " la 2,0(2,%3)\n"
+ " oc 0(1,1),0(2)"
+ : "=&d" (oldbit) : "d" (nr), "a" (addr), "a" (&_oi_bitmap)
+ : "cc", "memory", "1", "2" );
+ return oldbit & 1;
+}
+
+/*
+ * fast, non-SMP test_and_clear_bit routine
+ */
+static __inline__ int
+test_and_clear_bit_simple(unsigned long nr, volatile void * addr)
+{
+ int oldbit;
+
+ __asm__ __volatile__(
+ " lghi 1,56\n"
+ " lghi 2,7\n"
+ " xgr 1,%1\n"
+ " nr 2,%1\n"
+ " srlg 1,1,3\n"
+ " la 1,0(1,%2)\n"
+ " ic %0,0(1)\n"
+ " srl %0,0(2)\n"
+ " la 2,0(2,%3)\n"
+ " nc 0(1,1),0(2)"
+ : "=&d" (oldbit) : "d" (nr), "a" (addr), "a" (&_ni_bitmap)
+ : "cc", "memory", "1", "2" );
+ return oldbit & 1;
+}
+
+/*
+ * fast, non-SMP test_and_change_bit routine
+ */
+static __inline__ int
+test_and_change_bit_simple(unsigned long nr, volatile void * addr)
+{
+ int oldbit;
+
+ __asm__ __volatile__(
+ " lghi 1,56\n"
+ " lghi 2,7\n"
+ " xgr 1,%1\n"
+ " nr 2,%1\n"
+ " srlg 1,1,3\n"
+ " la 1,0(1,%2)\n"
+ " ic %0,0(1)\n"
+ " srl %0,0(2)\n"
+ " la 2,0(2,%3)\n"
+ " xc 0(1,1),0(2)"
+ : "=&d" (oldbit) : "d" (nr), "a" (addr), "a" (&_oi_bitmap)
+ : "cc", "memory", "1", "2" );
+ return oldbit & 1;
+}
+
+#ifdef CONFIG_SMP
+#define set_bit set_bit_cs
+#define clear_bit clear_bit_cs
+#define change_bit change_bit_cs
+#define test_and_set_bit test_and_set_bit_cs
+#define test_and_clear_bit test_and_clear_bit_cs
+#define test_and_change_bit test_and_change_bit_cs
+#else
+#define set_bit set_bit_simple
+#define clear_bit clear_bit_simple
+#define change_bit change_bit_simple
+#define test_and_set_bit test_and_set_bit_simple
+#define test_and_clear_bit test_and_clear_bit_simple
+#define test_and_change_bit test_and_change_bit_simple
+#endif
+
+
+/*
+ * This routine doesn't need to be atomic.
+ */
+
+static __inline__ int __test_bit(unsigned long nr, volatile void * addr)
+{
+ int oldbit;
+
+ __asm__ __volatile__(
+ " lghi 2,56\n"
+ " lghi 1,7\n"
+ " xgr 2,%1\n"
+ " nr 1,%1\n"
+ " srlg 2,2,3\n"
+ " ic %0,0(2,%2)\n"
+ " srl %0,0(1)\n"
+ : "=&d" (oldbit) : "d" (nr), "a" (addr)
+ : "cc", "1", "2" );
+ return oldbit & 1;
+}
+
+static __inline__ int
+__constant_test_bit(unsigned long nr, volatile void * addr) {
+ return (((volatile char *) addr)[(nr>>3)^7] & (1<<(nr&7))) != 0;
+}
+
+#define test_bit(nr,addr) \
+(__builtin_constant_p((nr)) ? \
+ __constant_test_bit((nr),(addr)) : \
+ __test_bit((nr),(addr)) )
+
+/*
+ * Find-bit routines..
+ */
+static __inline__ unsigned long
+find_first_zero_bit(void * addr, unsigned long size)
+{
+ unsigned long res;
+
+ if (!size)
+ return 0;
+ __asm__(" lghi 0,-1\n"
+ " lgr 1,%1\n"
+ " slgr %0,%0\n"
+ " aghi 1,63\n"
+ " srlg 1,1,6\n"
+ "0: cg 0,0(%0,%2)\n"
+ " jne 1f\n"
+ " aghi %0,8\n"
+ " brct 1,0b\n"
+ " lgr %0,%1\n"
+ " j 5f\n"
+ "1: lg 1,0(%0,%2)\n"
+ " sllg %0,%0,3\n"
+ " clr 1,0\n"
+ " jne 2f\n"
+ " aghi %0,32\n"
+ " srlg 1,1,32\n"
+ "2: lghi 0,0xff\n"
+ " tmll 1,0xffff\n"
+ " jno 3f\n"
+ " aghi %0,16\n"
+ " srl 1,16\n"
+ "3: tmll 1,0x00ff\n"
+ " jno 4f\n"
+ " aghi %0,8\n"
+ " srl 1,8\n"
+ "4: ngr 1,0\n"
+ " ic 1,0(1,%3)\n"
+ " algr %0,1\n"
+ "5:"
+ : "=&a" (res) : "a" (size), "a" (addr), "a" (&_zb_findmap)
+ : "cc", "0", "1" );
+ return (res < size) ? res : size;
+}
+
+static __inline__ unsigned long
+find_next_zero_bit (void * addr, unsigned long size, unsigned long offset)
+{
+ unsigned long * p = ((unsigned long *) addr) + (offset >> 6);
+ unsigned long bitvec;
+ unsigned long set, bit = offset & 63, res;
+
+ if (bit) {
+ /*
+ * Look for zero in first word
+ */
+ bitvec = (*p) >> bit;
+ __asm__(" lhi 0,-1\n"
+ " lgr 1,%1\n"
+ " slgr %0,%0\n"
+ " clr 1,0\n"
+ " jne 0f\n"
+ " aghi %0,32\n"
+ " srlg 1,1,32\n"
+ "0: lghi 0,0xff\n"
+ " tmll 1,0xffff\n"
+ " jno 1f\n"
+ " aghi %0,16\n"
+ " srlg 1,1,16\n"
+ "1: tmll 1,0x00ff\n"
+ " jno 2f\n"
+ " aghi %0,8\n"
+ " srlg 1,1,8\n"
+ "2: ngr 1,0\n"
+ " ic 1,0(1,%2)\n"
+ " algr %0,1"
+ : "=&d" (set)
+ : "d" (bitvec), "a" (&_zb_findmap)
+ : "cc", "0", "1" );
+ if (set < (64 - bit))
+ return set + offset;
+ offset += 64 - bit;
+ p++;
+ }
+ /*
+ * No zero yet, search remaining full words for a zero
+ */
+ res = find_first_zero_bit (p, size - 64 * (p - (unsigned long *) addr));
+ return (offset + res);
+}
+
+/*
+ * ffz = Find First Zero in word. Undefined if no zero exists,
+ * so code should check against ~0UL first..
+ */
+static __inline__ unsigned long ffz(unsigned long word)
+{
+ int result;
+
+ __asm__(" lhi 0,-1\n"
+ " lgr 1,%1\n"
+ " slgr %0,%0\n"
+ " clr 1,0\n"
+ " jne 0f\n"
+ " aghi %0,32\n"
+ " srlg 1,1,32\n"
+ "0: lghi 0,0xff\n"
+ " tmll 1,0xffff\n"
+ " jno 1f\n"
+ " aghi %0,16\n"
+ " srlg 1,1,16\n"
+ "1: tmll 1,0x00ff\n"
+ " jno 2f\n"
+ " aghi %0,8\n"
+ " srlg 1,1,8\n"
+ "2: ngr 1,0\n"
+ " ic 1,0(1,%2)\n"
+ " algr %0,1"
+ : "=&d" (result)
+ : "d" (word), "a" (&_zb_findmap)
+ : "cc", "0", "1" );
+
+ return result;
+}
+
+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern int __inline__ ffs (int x)
+{
+ int r;
+
+ if (x == 0)
+ return 0;
+ __asm__(" lr 1,%1\n"
+ " slr %0,%0\n"
+ " tml 1,0xFFFF\n"
+ " jnz 0f\n"
+ " ahi %0,16\n"
+ " srl 1,16\n"
+ "0: tml 1,0x00FF\n"
+ " jnz 1f\n"
+ " ahi %0,8\n"
+ " srl 1,8\n"
+ "1: tml 1,0x000F\n"
+ " jnz 2f\n"
+ " ahi %0,4\n"
+ " srl 1,4\n"
+ "2: tml 1,0x0003\n"
+ " jnz 3f\n"
+ " ahi %0,2\n"
+ " srl 1,2\n"
+ "3: tml 1,0x0001\n"
+ " jnz 4f\n"
+ " ahi %0,1\n"
+ "4:"
+ : "=&d" (r) : "d" (x) : "cc", "1" );
+ return r+1;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+#define hweight32(x) generic_hweight32(x)
+#define hweight16(x) generic_hweight16(x)
+#define hweight8(x) generic_hweight8(x)
+
+
+#ifdef __KERNEL__
+
+/*
+ * ATTENTION: intel byte ordering convention for ext2 and minix !!
+ * bit 0 is the LSB of addr; bit 31 is the MSB of addr;
+ * bit 32 is the LSB of (addr+4).
+ * That combined with the little endian byte order of Intel gives the
+ * following bit order in memory:
+ * 07 06 05 04 03 02 01 00 15 14 13 12 11 10 09 08 \
+ * 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24
+ */
+
+#define ext2_set_bit(nr, addr) test_and_set_bit((nr)^56, addr)
+#define ext2_clear_bit(nr, addr) test_and_clear_bit((nr)^56, addr)
+#define ext2_test_bit(nr, addr) test_bit((nr)^56, addr)
+static __inline__ unsigned long
+ext2_find_first_zero_bit(void *vaddr, unsigned long size)
+{
+ unsigned long res;
+
+ if (!size)
+ return 0;
+ __asm__(" lghi 0,-1\n"
+ " lgr 1,%1\n"
+ " aghi 1,63\n"
+ " srlg 1,1,6\n"
+ " slgr %0,%0\n"
+ "0: clg 0,0(%0,%2)\n"
+ " jne 1f\n"
+ " aghi %0,8\n"
+ " brct 1,0b\n"
+ " lgr %0,%1\n"
+ " j 5f\n"
+ "1: cl 0,0(%0,%2)\n"
+ " jne 2f\n"
+ " aghi %0,4\n"
+ "2: l 1,0(%0,%2)\n"
+ " sllg %0,%0,3\n"
+ " aghi %0,24\n"
+ " lghi 0,0xff\n"
+ " tmlh 1,0xffff\n"
+ " jo 3f\n"
+ " aghi %0,-16\n"
+ " srl 1,16\n"
+ "3: tmll 1,0xff00\n"
+ " jo 4f\n"
+ " aghi %0,-8\n"
+ " srl 1,8\n"
+ "4: ngr 1,0\n"
+ " ic 1,0(1,%3)\n"
+ " algr %0,1\n"
+ "5:"
+ : "=&a" (res) : "a" (size), "a" (vaddr), "a" (&_zb_findmap)
+ : "cc", "0", "1" );
+ return (res < size) ? res : size;
+}
+
+static __inline__ unsigned long
+ext2_find_next_zero_bit(void *vaddr, unsigned long size, unsigned long offset)
+{
+ unsigned long *addr = vaddr;
+ unsigned long *p = addr + (offset >> 6);
+ unsigned long word;
+ unsigned long bit = offset & 63UL, res;
+
+ if (offset >= size)
+ return size;
+
+ if (bit) {
+ __asm__(" lrvg %0,%1" /* load reversed, neat instruction */
+ : "=a" (word) : "m" (*p) );
+ word >>= bit;
+ res = bit;
+ /* Look for zero in first 8 byte word */
+ __asm__(" lgr 1,%1\n"
+ " lghi 0,0xff\n"
+ " tmll 1,0xffff\n"
+ " jno 2f\n"
+ " ahi %0,16\n"
+ " srlg 1,1,16\n"
+ "0: tmll 1,0xffff\n"
+ " jno 2f\n"
+ " ahi %0,16\n"
+ " srlg 1,1,16\n"
+ "1: tmll 1,0xffff\n"
+ " jno 2f\n"
+ " ahi %0,16\n"
+ " srl 1,16\n"
+ "2: tmll 1,0x00ff\n"
+ " jno 3f\n"
+ " ahi %0,8\n"
+ " srl 1,8\n"
+ "3: ngr 1,0\n"
+ " ic 1,0(1,%2)\n"
+ " alr %0,1"
+ : "+&d" (res)
+ : "d" (word), "a" (&_zb_findmap)
+ : "cc", "0", "1" );
+ if (res < 64)
+ return (p - addr)*64 + res;
+ p++;
+ }
+ /* No zero yet, search remaining full bytes for a zero */
+ res = ext2_find_first_zero_bit (p, size - 64 * (p - addr));
+ return (p - addr) * 64 + res;
+}
+
+/* Bitmap functions for the minix filesystem. */
+/* FIXME !!! */
+#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr)
+#define minix_set_bit(nr,addr) set_bit(nr,addr)
+#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr)
+#define minix_test_bit(nr,addr) test_bit(nr,addr)
+#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
+
+#endif /* __KERNEL__ */
+
+#endif /* _S390_BITOPS_H */
diff --git a/include/asm-s390x/bugs.h b/include/asm-s390x/bugs.h
new file mode 100644
index 000000000..2c3659621
--- /dev/null
+++ b/include/asm-s390x/bugs.h
@@ -0,0 +1,22 @@
+/*
+ * include/asm-s390/bugs.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/bugs.h"
+ * Copyright (C) 1994 Linus Torvalds
+ */
+
+/*
+ * This is included by init/main.c to check for architecture-dependent bugs.
+ *
+ * Needs:
+ * void check_bugs(void);
+ */
+
+static void __init check_bugs(void)
+{
+ /* s390 has no bugs ... */
+}
diff --git a/include/asm-s390x/byteorder.h b/include/asm-s390x/byteorder.h
new file mode 100644
index 000000000..15bb43ff4
--- /dev/null
+++ b/include/asm-s390x/byteorder.h
@@ -0,0 +1,113 @@
+#ifndef _S390_BYTEORDER_H
+#define _S390_BYTEORDER_H
+
+/*
+ * include/asm-s390/byteorder.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ */
+
+#include <asm/types.h>
+
+#ifdef __GNUC__
+
+static __inline__ __const__ __u64 ___arch__swab64(__u64 x)
+{
+ __u64 result;
+
+ __asm__ __volatile__ (
+ " lrvg %0,%1"
+ : "=&d" (result) : "m" (x) );
+ return result;
+}
+
+static __inline__ __const__ __u64 ___arch__swab64p(__u64 *x)
+{
+ __u64 result;
+
+ __asm__ __volatile__ (
+ " lrvg %0,%1"
+ : "=d" (result) : "m" (*x) );
+ return result;
+}
+
+static __inline__ void ___arch__swab64s(__u64 *x)
+{
+ __asm__ __volatile__ (
+ " lrvg %0,%1\n"
+ " stg %0,%1"
+ : : "m" (*x) : "memory");
+}
+
+static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+{
+ __u32 result;
+
+ __asm__ __volatile__ (
+ " lrv %0,%1"
+ : "=&d" (result) : "m" (x) );
+ return result;
+}
+
+static __inline__ __const__ __u32 ___arch__swab32p(__u32 *x)
+{
+ __u32 result;
+
+ __asm__ __volatile__ (
+ " lrv %0,%1"
+ : "=d" (result) : "m" (*x) );
+ return result;
+}
+
+static __inline__ void ___arch__swab32s(__u32 *x)
+{
+ __asm__ __volatile__ (
+ " lrv %0,%1\n"
+ " st %0,%1"
+ : : "m" (*x) : "memory");
+}
+
+static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
+{
+ __u16 result;
+
+ __asm__ __volatile__ (
+ " lrvh %0,%1"
+ : "=d" (result) : "m" (x) );
+ return result;
+}
+
+static __inline__ __const__ __u16 ___arch__swab16p(__u16 *x)
+{
+ __u16 result;
+
+ __asm__ __volatile__ (
+ " lrvh %0,%1"
+ : "=d" (result) : "m" (*x) );
+ return result;
+}
+
+static __inline__ void ___arch__swab16s(__u16 *x)
+{
+ __asm__ __volatile__ (
+ " lrvh %0,%1\n"
+ " sth %0,%1"
+ : : "m" (*x) : "memory");
+}
+
+#define __arch__swab32(x) ___arch__swab32(x)
+#define __arch__swab16(x) ___arch__swab16(x)
+#define __arch__swab32p(x) ___arch__swab32p(x)
+#define __arch__swab16p(x) ___arch__swab16p(x)
+#define __arch__swab32s(x) ___arch__swab32s(x)
+#define __arch__swab16s(x) ___arch__swab16s(x)
+
+#define __BYTEORDER_HAS_U64__
+
+#endif /* __GNUC__ */
+
+#include <linux/byteorder/big_endian.h>
+
+#endif /* _S390_BYTEORDER_H */
diff --git a/include/asm-s390x/cache.h b/include/asm-s390x/cache.h
new file mode 100644
index 000000000..ad82cf8e0
--- /dev/null
+++ b/include/asm-s390x/cache.h
@@ -0,0 +1,16 @@
+/*
+ * include/asm-s390/cache.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *
+ * Derived from "include/asm-i386/cache.h"
+ * Copyright (C) 1992, Linus Torvalds
+ */
+
+#ifndef __ARCH_S390_CACHE_H
+#define __ARCH_S390_CACHE_H
+
+#define L1_CACHE_BYTES 16
+
+#endif
diff --git a/include/asm-s390x/ccwcache.h b/include/asm-s390x/ccwcache.h
new file mode 100644
index 000000000..cfbb03bf2
--- /dev/null
+++ b/include/asm-s390x/ccwcache.h
@@ -0,0 +1,84 @@
+/*
+ * File...........: linux/include/asm-s390/ccwcache.h
+ * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
+ * Bugreports.to..: <Linux390@de.ibm.com>
+ * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
+ */
+#ifndef CCWCACHE_H
+#define CCWCACHE_H
+#include <linux/slab.h>
+#include <asm/irq.h>
+
+#ifndef __KERNEL__
+#define kmem_cache_t void
+#endif /* __KERNEL__ */
+
+typedef struct ccw_req_t {
+ /* eye catcher plus queueing information */
+ unsigned int magic;
+ struct ccw_req_t *next; /* pointer to next ccw_req_t in queue */
+ struct ccw_req_t *int_next; /* for internal queueing */
+ struct ccw_req_t *int_prev; /* for internal queueing */
+
+ /* Where to execute what... */
+ void *device; /* index of the device the req is for */
+ void *req; /* pointer to originating request */
+ ccw1_t *cpaddr; /* address of channel program */
+ char status; /* reflecting the status of this request */
+ char flags; /* see below */
+ short retries; /* A retry counter to be set when filling */
+
+ /* ... and how */
+ int options; /* options for execution */
+ char lpm; /* logical path mask */
+ void *data; /* pointer to data area */
+ devstat_t *dstat; /* The device status in case of an error */
+
+ /* these are important for recovering erroneous requests */
+ struct ccw_req_t *refers; /* Does this request refer to another one? */
+ void *function; /* refers to the originating ERP action */ ;
+
+ unsigned long long expires; /* expiratioj period */
+ /* these are for profiling purposes */
+ unsigned long long buildclk; /* TOD-clock of request generation */
+ unsigned long long startclk; /* TOD-clock of request start */
+ unsigned long long stopclk; /* TOD-clock of request interrupt */
+ unsigned long long endclk; /* TOD-clock of request termination */
+
+ /* these are for internal use */
+ int cplength; /* length of the channel program in CCWs */
+ int datasize; /* amount of additional data in bytes */
+ kmem_cache_t *cache; /* the cache this data comes from */
+
+} __attribute__ ((aligned(4))) ccw_req_t;
+
+/*
+ * ccw_req_t -> status can be:
+ */
+#define CQR_STATUS_EMPTY 0x00 /* request is empty */
+#define CQR_STATUS_FILLED 0x01 /* request is ready to be preocessed */
+#define CQR_STATUS_QUEUED 0x02 /* request is queued to be processed */
+#define CQR_STATUS_IN_IO 0x03 /* request is currently in IO */
+#define CQR_STATUS_DONE 0x04 /* request is completed sucessfully */
+#define CQR_STATUS_ERROR 0x05 /* request is completed with error */
+#define CQR_STATUS_FAILED 0x06 /* request is finally failed */
+
+#define CQR_FLAGS_CHAINED 0x01 /* request is chained by another (last CCW is TIC) */
+
+#ifdef __KERNEL__
+#define SMALLEST_SLAB (sizeof(struct ccw_req_t) <= 128 ? 128 :\
+ sizeof(struct ccw_req_t) <= 256 ? 256 : 512 )
+
+/* SMALLEST_SLAB(1),... PAGE_SIZE(CCW_NUMBER_CACHES) */
+#define CCW_NUMBER_CACHES (sizeof(struct ccw_req_t) <= 128 ? 6 :\
+ sizeof(struct ccw_req_t) <= 256 ? 5 : 4 )
+
+int ccwcache_init (void);
+
+ccw_req_t *ccw_alloc_request (char *magic, int cplength, int additional_data);
+void ccw_free_request (ccw_req_t * request);
+#endif /* __KERNEL__ */
+#endif /* CCWCACHE_H */
+
+
+
diff --git a/include/asm-s390x/chandev.h b/include/asm-s390x/chandev.h
new file mode 100644
index 000000000..9efb6fea3
--- /dev/null
+++ b/include/asm-s390x/chandev.h
@@ -0,0 +1,151 @@
+/*
+ * include/asm-s390/chandev.h
+ *
+ * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ *
+ * Generic channel device initialisation support.
+ */
+#include <linux/version.h>
+#include <asm/types.h>
+#include <linux/netdevice.h>
+
+/* chandev_type is a bitmask for registering & describing device types. */
+typedef enum
+{
+ none=0x0,
+ ctc=0x1,
+ escon=0x2,
+ lcs=0x4,
+ osad=0x8,
+ qeth=0x10,
+ claw=0x20,
+} chandev_type;
+
+typedef enum
+{
+ no_category,
+ network_device,
+ serial_device,
+} chandev_category;
+
+/*
+ * The chandev_probeinfo structure is passed to the device driver with configuration
+ * info for which irq's & ports to use when attempting to probe the device.
+ */
+typedef struct
+{
+ int read_irq;
+ int write_irq;
+ u16 read_devno;
+ u16 write_devno;
+ s16 port_protocol_no; /* -1 don't care */
+ u8 hint_port_no; /* lcs specific */
+ u8 max_port_no; /* lcs specific */
+ chandev_type chan_type;
+ u8 checksum_received_ip_pkts;
+ u8 use_hw_stats; /* where available e.g. lcs */
+ u16 cu_type; /* control unit type */
+ u8 cu_model; /* control unit model */
+ u16 dev_type; /* device type */
+ u8 dev_model; /* device model */
+ char *parmstr; /* driver specific parameters added by add_parms keyword */
+ /* newdevice used internally by chandev.c */
+ struct chandev_activelist *newdevice;
+ s32 devif_num;
+/* devif_num=-1 implies don't care,0 implies tr0, info used by chandev_initnetdevice */
+} chandev_probeinfo;
+
+/*
+ * This is a wrapper to the machine check handler & should be used
+ * instead of reqest_irq or s390_request_irq_special for anything
+ * using the channel device layer.
+ */
+int chandev_request_irq(unsigned int irq,
+ void (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id);
+
+typedef enum
+{
+ good=0,
+ not_oper,
+ first_msck=not_oper,
+ no_path,
+ revalidate,
+ gone,
+ last_msck,
+} chandev_msck_status;
+
+typedef int (*chandev_probefunc)(chandev_probeinfo *probeinfo);
+typedef void (*chandev_shutdownfunc)(void *device);
+typedef void (*chandev_unregfunc)(void *device);
+typedef void (*chandev_reoperfunc)(void *device,int msck_for_read_chan,chandev_msck_status prevstatus);
+
+
+
+/* A driver should call chandev_register_and_probe when ready to be probed,
+ * after registeration the drivers probefunction will be called asynchronously
+ * when more devices become available at normal task time.
+ * The shutdownfunc parameter is used so that the channel layer
+ * can request a driver to close unregister itself & release its interrupts.
+ * repoper func is used when a device becomes operational again after being temporarily
+ * not operational the previous status is sent in the prevstatus variable.
+ * This can be used in cases when the default handling isn't quite adequete
+ * e.g. if a ssch is needed to reinitialize long running channel programs.
+ */
+int chandev_register_and_probe(chandev_probefunc probefunc,
+ chandev_shutdownfunc shutdownfunc,
+ chandev_reoperfunc reoperfunc,
+ chandev_type chan_type);
+
+/* The chandev_unregister function is typically called when a module is being removed
+ * from the system. The shutdown parameter if TRUE calls shutdownfunc for each
+ * device instance so the driver writer doesn't have to.
+ */
+void chandev_unregister(chandev_probefunc probefunc,int call_shutdown);
+
+/* chandev_initdevice should be called immeadiately before returning after */
+/* a successful probe. */
+int chandev_initdevice(chandev_probeinfo *probeinfo,void *dev_ptr,u8 port_no,char *devname,
+chandev_category category,chandev_unregfunc unreg_dev);
+
+/* chandev_initnetdevice registers a network device with the channel layer.
+ * It returns the device structure if successful,if dev=NULL it kmallocs it,
+ * On device initialisation failure it will kfree it under ALL curcumstances
+ * i.e. if dev is not NULL on entering this routine it MUST be malloced with kmalloc.
+ * The base name is tr ( e.g. tr0 without the 0 ), for token ring eth for ethernet,
+ * ctc or escon for ctc device drivers.
+ * If valid function pointers are given they will be called to setup,
+ * register & unregister the device.
+ * An example of setup is eth_setup in drivers/net/net_init.c.
+ * An example of init_dev is init_trdev(struct net_device *dev)
+ * & an example of unregister is unregister_trdev,
+ * unregister_netdev should be used for escon & ctc
+ * as there is no network unregister_ctcdev in the kernel.
+*/
+
+#if LINUX_VERSION_CODE>=KERNEL_VERSION(2,3,0)
+struct net_device *chandev_initnetdevice(chandev_probeinfo *probeinfo,u8 port_no,
+ struct net_device *dev,int sizeof_priv,
+ char *basename,
+ struct net_device *(*init_netdevfunc)
+ (struct net_device *dev, int sizeof_priv),
+ void (*unreg_netdevfunc)(struct net_device *dev));
+#else
+struct device *chandev_initnetdevice(chandev_probeinfo *probeinfo,u8 port_no,
+ struct device *dev,int sizeof_priv,
+ char *basename,
+ struct device *(*init_netdevfunc)
+ (struct device *dev, int sizeof_priv),
+ void (*unreg_netdevfunc)(struct device *dev));
+#endif
+
+
+
+
+
+
+
+
diff --git a/include/asm-s390x/checksum.h b/include/asm-s390x/checksum.h
new file mode 100644
index 000000000..bb825c546
--- /dev/null
+++ b/include/asm-s390x/checksum.h
@@ -0,0 +1,188 @@
+#ifndef _S390_CHECKSUM_H
+#define _S390_CHECKSUM_H
+
+/*
+ * include/asm-s390/checksum.h
+ * S390 fast network checksum routines
+ * see also arch/S390/lib/checksum.c
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Ulrich Hild (first version)
+ * Martin Schwidefsky (heavily optimized CKSM version)
+ * D.J. Barrow (third attempt)
+ */
+
+#include <asm/uaccess.h>
+
+/*
+ * computes the checksum of a memory block at buff, length len,
+ * and adds in "sum" (32-bit)
+ *
+ * returns a 32-bit number suitable for feeding into itself
+ * or csum_tcpudp_magic
+ *
+ * this function must be called with even lengths, except
+ * for the last fragment, which may be odd
+ *
+ * it's best to have buff aligned on a 32-bit boundary
+ */
+unsigned int
+csum_partial(const unsigned char * buff, int len, unsigned int sum);
+
+/*
+ * csum_partial as an inline function
+ */
+extern inline unsigned int
+csum_partial_inline(const unsigned char * buff, int len, unsigned int sum)
+{
+ __asm__ __volatile__ (
+ " lgr 2,%1\n" /* address in gpr 2 */
+ " lgfr 3,%2\n" /* length in gpr 3 */
+ "0: cksm %0,2\n" /* do checksum on longs */
+ " jo 0b\n"
+ : "+&d" (sum)
+ : "d" (buff), "d" (len)
+ : "cc", "2", "3" );
+ return sum;
+}
+
+/*
+ * the same as csum_partial, but copies from src while it
+ * checksums
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+
+extern inline unsigned int
+csum_partial_copy(const char *src, char *dst, int len,unsigned int sum)
+{
+ memcpy(dst,src,len);
+ return csum_partial_inline(dst, len, sum);
+}
+
+/*
+ * the same as csum_partial_copy, but copies from user space.
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+
+extern inline unsigned int
+csum_partial_copy_from_user(const char *src, char *dst,
+ int len, unsigned int sum, int *errp)
+{
+ if (copy_from_user(dst, src, len)) {
+ *errp = -EFAULT;
+ memset(dst, 0, len);
+ return sum;
+ }
+ return csum_partial_inline(dst, len, sum);
+}
+
+extern inline unsigned int
+csum_partial_copy_nocheck (const char *src, char *dst, int len, unsigned int sum)
+{
+ memcpy(dst,src,len);
+ return csum_partial_inline(dst, len, sum);
+}
+
+/*
+ * Fold a partial checksum without adding pseudo headers
+ */
+extern inline unsigned short
+csum_fold(unsigned int sum)
+{
+ __asm__ __volatile__ (
+ " sr 3,3\n" /* %0 = H*65536 + L */
+ " lr 2,%0\n" /* %0 = H L, R2/R3 = H L / 0 0 */
+ " srdl 2,16\n" /* %0 = H L, R2/R3 = 0 H / L 0 */
+ " alr 2,3\n" /* %0 = H L, R2/R3 = L H / L 0 */
+ " alr %0,2\n" /* %0 = H+L+C L+H */
+ " srl %0,16\n" /* %0 = H+L+C */
+ : "+&d" (sum) : : "cc", "2", "3");
+ return ((unsigned short) ~sum);
+}
+
+/*
+ * This is a version of ip_compute_csum() optimized for IP headers,
+ * which always checksum on 4 octet boundaries.
+ *
+ */
+extern inline unsigned short
+ip_fast_csum(unsigned char *iph, unsigned int ihl)
+{
+ unsigned long sum;
+
+ __asm__ __volatile__ (
+ " slgr %0,%0\n" /* set sum to zero */
+ " lgr 2,%1\n" /* address in gpr 2 */
+ " lgfr 3,%2\n" /* length in gpr 3 */
+ "0: cksm %0,2\n" /* do checksum on ints */
+ " jo 0b\n"
+ : "=&d" (sum)
+ : "d" (iph), "d" (ihl*4)
+ : "cc", "2", "3" );
+ return csum_fold(sum);
+}
+
+/*
+ * computes the checksum of the TCP/UDP pseudo-header
+ * returns a 32-bit checksum
+ */
+extern inline unsigned int
+csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
+ unsigned short len, unsigned short proto,
+ unsigned int sum)
+{
+ __asm__ __volatile__ (
+ " lgfr %0,%0\n"
+ " algr %0,%1\n" /* sum += saddr */
+ " brc 12,0f\n"
+ " aghi %0,1\n" /* add carry */
+ "0: algr %0,%2\n" /* sum += daddr */
+ " brc 12,1f\n"
+ " aghi %0,1\n" /* add carry */
+ "1: algfr %0,%3\n" /* sum += (len<<16) + proto */
+ " brc 12,2f\n"
+ " aghi %0,1\n" /* add carry */
+ "2: srlg 0,%0,32\n"
+ " alr %0,0\n" /* fold to 32 bits */
+ " brc 12,3f\n"
+ " ahi %0,1\n" /* add carry */
+ "3: llgfr %0,%0"
+ : "+&d" (sum)
+ : "d" (saddr), "d" (daddr),
+ "d" (((unsigned int) len<<16) + (unsigned int) proto)
+ : "cc", "0" );
+ return sum;
+}
+
+/*
+ * computes the checksum of the TCP/UDP pseudo-header
+ * returns a 16-bit checksum, already complemented
+ */
+
+extern inline unsigned short int
+csum_tcpudp_magic(unsigned long saddr, unsigned long daddr,
+ unsigned short len, unsigned short proto,
+ unsigned int sum)
+{
+ return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
+}
+
+/*
+ * this routine is used for miscellaneous IP-like checksums, mainly
+ * in icmp.c
+ */
+
+extern inline unsigned short
+ip_compute_csum(unsigned char * buff, int len)
+{
+ return csum_fold(csum_partial_inline(buff, len, 0));
+}
+
+#endif /* _S390_CHECKSUM_H */
+
+
diff --git a/include/asm-s390x/current.h b/include/asm-s390x/current.h
new file mode 100644
index 000000000..617c758bd
--- /dev/null
+++ b/include/asm-s390x/current.h
@@ -0,0 +1,31 @@
+/*
+ * include/asm-s390/current.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/current.h"
+ */
+
+#ifndef _S390_CURRENT_H
+#define _S390_CURRENT_H
+
+#ifdef __KERNEL__
+
+struct task_struct;
+
+static inline struct task_struct * get_current(void)
+{
+ struct task_struct *current;
+ __asm__("lghi %0,-16384\n\t"
+ "ngr %0,15"
+ : "=&r" (current) );
+ return current;
+ }
+
+#define current get_current()
+
+#endif
+
+#endif /* !(_S390_CURRENT_H) */
diff --git a/include/asm-s390x/dasd.h b/include/asm-s390x/dasd.h
new file mode 100644
index 000000000..d9e4a8363
--- /dev/null
+++ b/include/asm-s390x/dasd.h
@@ -0,0 +1,339 @@
+/*
+ * File...........: linux/drivers/s390/block/dasd.c
+ * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
+ * Bugreports.to..: <Linux390@de.ibm.com>
+ * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
+ *
+ * History of changes (starts July 2000)
+ */
+
+#ifndef DASD_H
+#define DASD_H
+
+#include <linux/ioctl.h>
+#include <asm/irq.h>
+
+#define IOCTL_LETTER 'D'
+/* Disable the volume (for Linux) */
+#define BIODASDDISABLE _IO(IOCTL_LETTER,0)
+/* Enable the volume (for Linux) */
+#define BIODASDENABLE _IO(IOCTL_LETTER,1)
+/* Issue a reserve/release command, rsp. */
+#define BIODASDRSRV _IO(IOCTL_LETTER,2) /* reserve */
+#define BIODASDRLSE _IO(IOCTL_LETTER,3) /* release */
+#define BIODASDSLCK _IO(IOCTL_LETTER,4) /* steal lock */
+/* Read sense ID infpormation */
+#define BIODASDRSID _IOR(IOCTL_LETTER,0,senseid_t)
+/* Format the volume or an extent */
+#define BIODASDFORMAT _IOW(IOCTL_LETTER,0,format_data_t)
+/* translate blocknumber of partition to absolute */
+#define BIODASDRWTB _IOWR(IOCTL_LETTER,0,int)
+
+#define DASD_NAME "dasd"
+#define DASD_PARTN_BITS 2
+#define DASD_PER_MAJOR ( 1U<<(MINORBITS-DASD_PARTN_BITS))
+
+/*
+ * struct format_data_t
+ * represents all data necessary to format a dasd
+ */
+typedef struct format_data_t {
+ int start_unit; /* from track */
+ int stop_unit; /* to track */
+ int blksize; /* sectorsize */
+ int intensity; /* 0: normal, 1:record zero, 3:home address, 4 invalidate tracks */
+} __attribute__ ((packed)) format_data_t;
+
+#define DASD_FORMAT_DEFAULT_START_UNIT 0
+#define DASD_FORMAT_DEFAULT_STOP_UNIT -1
+#define DASD_FORMAT_DEFAULT_BLOCKSIZE -1
+#define DASD_FORMAT_DEFAULT_INTENSITY -1
+
+#ifdef __KERNEL__
+#include <linux/version.h>
+#include <linux/major.h>
+#include <linux/wait.h>
+#include <asm/ccwcache.h>
+#include <linux/blk.h>
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
+#include <linux/blkdev.h>
+#include <linux/devfs_fs_kernel.h>
+#endif
+#include <linux/genhd.h>
+#include <linux/hdreg.h>
+#include <linux/compatmac.h>
+
+#include <asm/s390dyn.h>
+#include <asm/todclk.h>
+#include <asm/debug.h>
+
+/* Kernel Version Compatibility section */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,98))
+typedef struct request *request_queue_t;
+#define block_device_operations file_operations
+#define __setup(x,y) struct dasd_device_t
+#define devfs_register_blkdev(major,name,ops) register_blkdev(major,name,ops)
+#define register_disk(dd,dev,partn,ops,size) \
+do { \
+ dd->sizes[MINOR(dev)] = size >> 1; \
+ resetup_one_dev(dd,MINOR(dev)>>DASD_PARTN_BITS); \
+} while(0)
+#define init_waitqueue_head(x) do { *x = NULL; } while(0)
+#define blk_cleanup_queue(x) do {} while(0)
+#define blk_init_queue(x...) do {} while(0)
+#define blk_queue_headactive(x...) do {} while(0)
+#define blk_queue_make_request(x) do {} while(0)
+#define list_empty(x) (0)
+#define INIT_BLK_DEV(d_major,d_request_fn,d_queue_fn,d_current) \
+do { \
+ blk_dev[d_major].request_fn = d_request_fn; \
+ blk_dev[d_major].queue = d_queue_fn; \
+ blk_dev[d_major].current_request = d_current; \
+} while(0)
+#define INIT_GENDISK(D_MAJOR,D_NAME,D_PARTN_BITS,D_PER_MAJOR) \
+ major:D_MAJOR, \
+ major_name:D_NAME, \
+ minor_shift:D_PARTN_BITS, \
+ max_p:1 << D_PARTN_BITS, \
+ max_nr:D_PER_MAJOR, \
+ nr_real:D_PER_MAJOR,
+static inline struct request *
+dasd_next_request( request_queue_t *queue )
+{
+ return *queue;
+}
+static inline void
+dasd_dequeue_request( request_queue_t * q, struct request *req )
+{
+ *q = req->next;
+ req->next = NULL;
+}
+#else
+#define INIT_BLK_DEV(d_major,d_request_fn,d_queue_fn,d_current) \
+do { \
+ blk_dev[d_major].queue = d_queue_fn; \
+} while(0)
+#define INIT_GENDISK(D_MAJOR,D_NAME,D_PARTN_BITS,D_PER_MAJOR) \
+ major:D_MAJOR, \
+ major_name:D_NAME, \
+ minor_shift:D_PARTN_BITS, \
+ max_p:1 << D_PARTN_BITS, \
+ nr_real:D_PER_MAJOR,
+static inline struct request *
+dasd_next_request( request_queue_t *queue )
+{
+ return blkdev_entry_next_request(&queue->queue_head);
+}
+static inline void
+dasd_dequeue_request( request_queue_t * q, struct request *req )
+{
+ blkdev_dequeue_request (req);
+}
+#endif
+
+/* dasd_range_t are used for dynamic device att-/detachment */
+typedef struct dasd_devreg_t {
+ devreg_t devreg; /* the devreg itself */
+ /* build a linked list of devregs, needed for cleanup */
+ struct dasd_devreg_t *next;
+} dasd_devreg_t;
+
+typedef enum {
+ dasd_era_fatal = -1, /* no chance to recover */
+ dasd_era_none = 0, /* don't recover, everything alright */
+ dasd_era_msg = 1, /* don't recover, just report... */
+ dasd_era_recover = 2 /* recovery action recommended */
+} dasd_era_t;
+
+/* BIT DEFINITIONS FOR SENSE DATA */
+#define DASD_SENSE_BIT_0 0x80
+#define DASD_SENSE_BIT_1 0x40
+#define DASD_SENSE_BIT_2 0x20
+#define DASD_SENSE_BIT_3 0x10
+
+#define check_then_set(where,from,to) \
+do { \
+ if ((*(where)) != (from) ) { \
+ printk (KERN_ERR PRINTK_HEADER "was %d\n", *(where)); \
+ BUG(); \
+ } \
+ (*(where)) = (to); \
+} while (0)
+
+#define DASD_MESSAGE(d_loglevel,d_device,d_string,d_args...)\
+do { \
+ int d_devno = d_device->devinfo.devno; \
+ int d_irq = d_device->devinfo.irq; \
+ char *d_name = d_device->name; \
+ int d_major = MAJOR(d_device->kdev); \
+ int d_minor = MINOR(d_device->kdev); \
+ printk(d_loglevel PRINTK_HEADER \
+ "/dev/%s(%d:%d), 0x%04X on SCH 0x%x:" \
+ d_string "\n",d_name,d_major,d_minor,d_devno,d_irq,d_args ); \
+} while(0)
+
+/*
+ * struct dasd_sizes_t
+ * represents all data needed to access dasd with properly set up sectors
+ */
+typedef
+struct dasd_sizes_t {
+ unsigned long blocks; /* size of volume in blocks */
+ unsigned int bp_block; /* bytes per block */
+ unsigned int s2b_shift; /* log2 (bp_block/512) */
+} dasd_sizes_t;
+
+/*
+ * struct dasd_chanq_t
+ * represents a queue of channel programs related to a single device
+ */
+typedef
+struct dasd_chanq_t {
+ ccw_req_t *head;
+ ccw_req_t *tail;
+} dasd_chanq_t;
+
+struct dasd_device_t;
+struct request;
+
+/*
+ * signatures for the functions of dasd_discipline_t
+ * make typecasts much easier
+ */
+typedef ccw_req_t *(*dasd_erp_action_fn_t) (ccw_req_t * cqr);
+typedef ccw_req_t *(*dasd_erp_postaction_fn_t) (ccw_req_t * cqr);
+
+typedef int (*dasd_ck_id_fn_t) (dev_info_t *);
+typedef int (*dasd_ck_characteristics_fn_t) (struct dasd_device_t *);
+typedef int (*dasd_fill_geometry_fn_t) (struct dasd_device_t *, struct hd_geometry *);
+typedef ccw_req_t *(*dasd_format_fn_t) (struct dasd_device_t *, struct format_data_t *);
+typedef ccw_req_t *(*dasd_init_analysis_fn_t) (struct dasd_device_t *);
+typedef int (*dasd_do_analysis_fn_t) (struct dasd_device_t *);
+typedef int (*dasd_io_starter_fn_t) (ccw_req_t *);
+typedef void (*dasd_int_handler_fn_t)(int irq, void *, struct pt_regs *);
+typedef dasd_era_t (*dasd_error_examine_fn_t) (ccw_req_t *, devstat_t * stat);
+typedef dasd_erp_action_fn_t (*dasd_error_analyse_fn_t) (ccw_req_t *);
+typedef dasd_erp_postaction_fn_t (*dasd_erp_analyse_fn_t) (ccw_req_t *);
+typedef ccw_req_t *(*dasd_cp_builder_fn_t)(struct dasd_device_t *,struct request *);
+typedef char *(*dasd_dump_sense_fn_t)(struct dasd_device_t *,ccw_req_t *);
+typedef ccw_req_t *(*dasd_reserve_fn_t)(struct dasd_device_t *);
+typedef ccw_req_t *(*dasd_release_fn_t)(struct dasd_device_t *);
+typedef ccw_req_t *(*dasd_merge_cp_fn_t)(struct dasd_device_t *);
+
+
+/*
+ * the dasd_discipline_t is
+ * sth like a table of virtual functions, if you think of dasd_eckd
+ * inheriting dasd...
+ * no, currently we are not planning to reimplement the driver in C++
+ */
+typedef struct dasd_discipline_t {
+ char ebcname[8]; /* a name used for tagging and printks */
+ char name[8]; /* a name used for tagging and printks */
+
+ dasd_ck_id_fn_t id_check; /* to check sense data */
+ dasd_ck_characteristics_fn_t check_characteristics; /* to check the characteristics */
+ dasd_init_analysis_fn_t init_analysis; /* to start the analysis of the volume */
+ dasd_do_analysis_fn_t do_analysis; /* to complete the analysis of the volume */
+ dasd_fill_geometry_fn_t fill_geometry; /* to set up hd_geometry */
+ dasd_io_starter_fn_t start_IO;
+ dasd_format_fn_t format_device; /* to format the device */
+ dasd_error_examine_fn_t examine_error;
+ dasd_error_analyse_fn_t erp_action;
+ dasd_erp_analyse_fn_t erp_postaction;
+ dasd_cp_builder_fn_t build_cp_from_req;
+ dasd_dump_sense_fn_t dump_sense;
+ dasd_int_handler_fn_t int_handler;
+ dasd_reserve_fn_t reserve;
+ dasd_release_fn_t release;
+ dasd_merge_cp_fn_t merge_cp;
+
+ struct dasd_discipline_t *next; /* used for list of disciplines */
+} dasd_discipline_t;
+
+typedef struct major_info_t {
+ struct major_info_t *next;
+ struct dasd_device_t **dasd_device;
+ struct gendisk gendisk; /* actually contains the major number */
+} __attribute__ ((packed)) major_info_t;
+
+typedef struct dasd_profile_info_t {
+ unsigned long dasd_io_reqs; /* number of requests processed at all */
+ unsigned long dasd_io_secs[32]; /* histogram of request's sizes */
+ unsigned long dasd_io_times[32]; /* histogram of requests's times */
+ unsigned long dasd_io_timps[32]; /* histogram of requests's times per sector */
+ unsigned long dasd_io_time1[32]; /* histogram of time from build to start */
+ unsigned long dasd_io_time2[32]; /* histogram of time from start to irq */
+ unsigned long dasd_io_time2ps[32]; /* histogram of time from start to irq */
+ unsigned long dasd_io_time3[32]; /* histogram of time from irq to end */
+} dasd_profile_info_t;
+
+typedef struct dasd_device_t {
+ dev_info_t devinfo;
+ dasd_discipline_t *discipline;
+ int level;
+ int open_count;
+ kdev_t kdev;
+ major_info_t *major_info;
+ struct dasd_chanq_t queue;
+ wait_queue_head_t wait_q;
+ request_queue_t request_queue;
+ devstat_t dev_status; /* needed ONLY!! for request_irq */
+ dasd_sizes_t sizes;
+ char name[16]; /* The name of the device in /dev */
+ char *private; /* to be used by the discipline internally */
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,3,98))
+ devfs_handle_t devfs_entry;
+#endif /* LINUX_IS_24 */
+ struct tq_struct bh_tq;
+ atomic_t bh_scheduled;
+ debug_info_t *debug_area;
+ dasd_profile_info_t profile;
+ struct proc_dir_entry *proc_dir; /* directory node */
+ struct proc_dir_entry *proc_info; /* information from dasd_device_t */
+ struct proc_dir_entry *proc_stats; /* statictics information */
+} dasd_device_t;
+
+/* dasd_device_t.level can be: */
+#define DASD_DEVICE_LEVEL_UNKNOWN 0x00
+#define DASD_DEVICE_LEVEL_RECOGNIZED 0x01
+#define DASD_DEVICE_LEVEL_ANALYSIS_PENDING 0x02
+#define DASD_DEVICE_LEVEL_ANALYSIS_PREPARED 0x04
+#define DASD_DEVICE_LEVEL_ANALYSED 0x08
+#define DASD_DEVICE_LEVEL_PARTITIONED 0x10
+
+int dasd_init (void);
+void dasd_discipline_enq (dasd_discipline_t *);
+int dasd_discipline_deq(dasd_discipline_t *);
+int dasd_start_IO (ccw_req_t *);
+void dasd_int_handler (int , void *, struct pt_regs *);
+ccw_req_t *default_erp_action (ccw_req_t *);
+ccw_req_t *default_erp_postaction (ccw_req_t *);
+int dasd_chanq_deq (dasd_chanq_t *, ccw_req_t *);
+ccw_req_t *dasd_alloc_request (char *, int, int);
+void dasd_free_request (ccw_req_t *);
+int (*genhd_dasd_name) (char *, int, int, struct gendisk *);
+int dasd_oper_handler (int irq, devreg_t * devreg);
+
+#endif /* __KERNEL__ */
+
+#endif /* DASD_H */
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only. This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-indent-level: 4
+ * c-brace-imaginary-offset: 0
+ * c-brace-offset: -4
+ * c-argdecl-indent: 4
+ * c-label-offset: -4
+ * c-continued-statement-offset: 4
+ * c-continued-brace-offset: 0
+ * indent-tabs-mode: nil
+ * tab-width: 8
+ * End:
+ */
diff --git a/include/asm-s390x/debug.h b/include/asm-s390x/debug.h
new file mode 100644
index 000000000..fdcc56008
--- /dev/null
+++ b/include/asm-s390x/debug.h
@@ -0,0 +1,210 @@
+/*
+ * include/asm-s390/debug.h
+ * S/390 debug facility
+ *
+ * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH,
+ * IBM Corporation
+ */
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+/* Note:
+ * struct __debug_entry must be defined outside of #ifdef __KERNEL__
+ * in order to allow a user program to analyze the 'raw'-view.
+ */
+
+struct __debug_entry{
+ union {
+ struct {
+ unsigned long long clock:52;
+ unsigned long long exception:1;
+ unsigned long long used:1;
+ unsigned long long unused:1;
+ unsigned long long cpuid:9;
+ } fields;
+
+ unsigned long long stck;
+ } id;
+ void* caller;
+} __attribute__((packed));
+
+#ifdef __KERNEL__
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
+ #include <asm/spinlock.h>
+#else
+ #include <linux/spinlock.h>
+#endif /* LINUX_VERSION_CODE */
+#include <linux/kernel.h>
+#include <linux/time.h>
+#include <linux/proc_fs.h>
+
+#define DEBUG_MAX_LEVEL 6 /* debug levels range from 0 to 6 */
+#define DEBUG_OFF_LEVEL -1 /* level where debug is switched off */
+#define DEBUG_MAX_VIEWS 10 /* max number of views in proc fs */
+#define DEBUG_MAX_PROCF_LEN 16 /* max length for a proc file name */
+#define DEBUG_DEFAULT_LEVEL 3 /* initial debug level */
+#define DEBUG_FEATURE_VERSION 1 /* version of debug feature */
+
+#define DEBUG_DIR_ROOT "s390dbf" /* name of debug root directory in proc fs */
+
+#define DEBUG_DATA(entry) (char*)(entry + 1) /* data is stored behind */
+ /* the entry information */
+
+#define STCK(x) asm volatile ("STCK %0":"=m" (x))
+
+typedef struct __debug_entry debug_entry_t;
+
+struct debug_view;
+
+typedef struct debug_info {
+ struct debug_info* next;
+ struct debug_info* prev;
+ atomic_t ref_count;
+ spinlock_t lock;
+ int level;
+ int nr_areas;
+ int page_order;
+ int buf_size;
+ int entry_size;
+ debug_entry_t** areas;
+ int active_area;
+ int *active_entry;
+ struct proc_dir_entry* proc_root_entry;
+ struct proc_dir_entry* proc_entries[DEBUG_MAX_VIEWS];
+ struct debug_view* views[DEBUG_MAX_VIEWS];
+ char name[DEBUG_MAX_PROCF_LEN];
+} debug_info_t;
+
+typedef int (debug_header_proc_t) (debug_info_t* id,
+ struct debug_view* view,
+ int area,
+ debug_entry_t* entry,
+ char* out_buf);
+
+typedef int (debug_format_proc_t) (debug_info_t* id,
+ struct debug_view* view, char* out_buf,
+ const char* in_buf);
+typedef int (debug_prolog_proc_t) (debug_info_t* id,
+ struct debug_view* view,
+ char* out_buf);
+typedef int (debug_input_proc_t) (debug_info_t* id,
+ struct debug_view* view,
+ struct file* file, const char* user_buf,
+ size_t in_buf_size, loff_t* offset);
+
+int debug_dflt_header_fn(debug_info_t* id, struct debug_view* view,
+ int area, debug_entry_t* entry, char* out_buf);
+
+struct debug_view {
+ char name[DEBUG_MAX_PROCF_LEN];
+ debug_prolog_proc_t* prolog_proc;
+ debug_header_proc_t* header_proc;
+ debug_format_proc_t* format_proc;
+ debug_input_proc_t* input_proc;
+};
+
+extern struct debug_view debug_hex_ascii_view;
+extern struct debug_view debug_raw_view;
+
+debug_info_t* debug_register(char* name, int pages_index, int nr_areas,
+ int buf_size);
+void debug_unregister(debug_info_t* id);
+
+void debug_set_level(debug_info_t* id, int new_level);
+
+debug_entry_t* debug_event(debug_info_t* id, int level, void* data,
+ int length);
+debug_entry_t* debug_int_event(debug_info_t* id, int level,
+ unsigned int tag);
+debug_entry_t* debug_text_event(debug_info_t* id, int level,
+ const char* txt);
+
+debug_entry_t* debug_exception(debug_info_t* id, int level, void* data,
+ int length);
+debug_entry_t* debug_int_exception(debug_info_t* id, int level,
+ unsigned int tag);
+debug_entry_t* debug_text_exception(debug_info_t* id, int level,
+ const char* txt);
+
+static inline debug_entry_t *
+debug_long_event (debug_info_t* id, int level, unsigned long tag)
+{
+ unsigned long t=tag;
+ return debug_event(id,level,&t,sizeof(unsigned long));
+}
+static inline debug_entry_t *
+debug_long_exception (debug_info_t* id, int level, unsigned long tag)
+{
+ unsigned long t=tag;
+ return debug_exception(id,level,&t,sizeof(unsigned long));
+}
+int debug_register_view(debug_info_t* id, struct debug_view* view);
+int debug_unregister_view(debug_info_t* id, struct debug_view* view);
+
+/*
+ define the debug levels:
+ - 0 No debugging output to console or syslog
+ - 1 Log internal errors to syslog, ignore check conditions
+ - 2 Log internal errors and check conditions to syslog
+ - 3 Log internal errors to console, log check conditions to syslog
+ - 4 Log internal errors and check conditions to console
+ - 5 panic on internal errors, log check conditions to console
+ - 6 panic on both, internal errors and check conditions
+ */
+
+#ifndef DEBUG_LEVEL
+#define DEBUG_LEVEL 4
+#endif
+
+#define INTERNAL_ERRMSG(x,y...) "E" __FILE__ "%d: " x, __LINE__, y
+#define INTERNAL_WRNMSG(x,y...) "W" __FILE__ "%d: " x, __LINE__, y
+#define INTERNAL_INFMSG(x,y...) "I" __FILE__ "%d: " x, __LINE__, y
+#define INTERNAL_DEBMSG(x,y...) "D" __FILE__ "%d: " x, __LINE__, y
+
+#if DEBUG_LEVEL > 0
+#define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
+#define PRINT_INFO(x...) printk ( KERN_INFO PRINTK_HEADER x )
+#define PRINT_WARN(x...) printk ( KERN_WARNING PRINTK_HEADER x )
+#define PRINT_ERR(x...) printk ( KERN_ERR PRINTK_HEADER x )
+#define PRINT_FATAL(x...) panic ( PRINTK_HEADER x )
+#else
+#define PRINT_DEBUG(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
+#define PRINT_INFO(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
+#define PRINT_WARN(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
+#define PRINT_ERR(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
+#define PRINT_FATAL(x...) printk ( KERN_DEBUG PRINTK_HEADER x )
+#endif /* DASD_DEBUG */
+
+#if DASD_DEBUG > 4
+#define INTERNAL_ERROR(x...) PRINT_FATAL ( INTERNAL_ERRMSG ( x ) )
+#elif DASD_DEBUG > 2
+#define INTERNAL_ERROR(x...) PRINT_ERR ( INTERNAL_ERRMSG ( x ) )
+#elif DASD_DEBUG > 0
+#define INTERNAL_ERROR(x...) PRINT_WARN ( INTERNAL_ERRMSG ( x ) )
+#else
+#define INTERNAL_ERROR(x...)
+#endif /* DASD_DEBUG */
+
+#if DASD_DEBUG > 5
+#define INTERNAL_CHECK(x...) PRINT_FATAL ( INTERNAL_CHKMSG ( x ) )
+#elif DASD_DEBUG > 3
+#define INTERNAL_CHECK(x...) PRINT_ERR ( INTERNAL_CHKMSG ( x ) )
+#elif DASD_DEBUG > 1
+#define INTERNAL_CHECK(x...) PRINT_WARN ( INTERNAL_CHKMSG ( x ) )
+#else
+#define INTERNAL_CHECK(x...)
+#endif /* DASD_DEBUG */
+
+#undef DEBUG_MALLOC
+#ifdef DEBUG_MALLOC
+void *b;
+#define kmalloc(x...) (PRINT_INFO(" kmalloc %p\n",b=kmalloc(x)),b)
+#define kfree(x) PRINT_INFO(" kfree %p\n",x);kfree(x)
+#define get_free_page(x...) (PRINT_INFO(" gfp %p\n",b=get_free_page(x)),b)
+#define __get_free_pages(x...) (PRINT_INFO(" gfps %p\n",b=__get_free_pages(x)),b)
+#endif /* DEBUG_MALLOC */
+
+#endif /* __KERNEL__ */
+#endif /* DEBUG_H */
diff --git a/include/asm-s390x/delay.h b/include/asm-s390x/delay.h
new file mode 100644
index 000000000..357fdb835
--- /dev/null
+++ b/include/asm-s390x/delay.h
@@ -0,0 +1,22 @@
+/*
+ * include/asm-s390/delay.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/delay.h"
+ * Copyright (C) 1993 Linus Torvalds
+ *
+ * Delay routines calling functions in arch/i386/lib/delay.c
+ */
+
+#ifndef _S390_DELAY_H
+#define _S390_DELAY_H
+
+extern void __udelay(unsigned long usecs);
+extern void __delay(unsigned long loops);
+
+#define udelay(n) __udelay(n)
+
+#endif /* defined(_S390_DELAY_H) */
diff --git a/include/asm-s390x/div64.h b/include/asm-s390x/div64.h
new file mode 100644
index 000000000..17824b1a2
--- /dev/null
+++ b/include/asm-s390x/div64.h
@@ -0,0 +1,10 @@
+#ifndef __S390_DIV64
+#define __S390_DIV64
+
+#define do_div(n,base) ({ \
+int __res; \
+__res = ((unsigned long) n) % (unsigned) base; \
+n = ((unsigned long) n) / (unsigned) base; \
+__res; })
+
+#endif
diff --git a/include/asm-s390x/dma.h b/include/asm-s390x/dma.h
new file mode 100644
index 000000000..2a19a6184
--- /dev/null
+++ b/include/asm-s390x/dma.h
@@ -0,0 +1,16 @@
+/*
+ * include/asm-s390x/dma.h
+ *
+ * S390 version
+ */
+
+#ifndef _ASM_DMA_H
+#define _ASM_DMA_H
+
+#include <asm/io.h> /* need byte IO */
+
+/* The I/O subsystem can access only memory below 2GB.
+ We use the existing DMA zone mechanism to handle this. */
+#define MAX_DMA_ADDRESS 0x80000000
+
+#endif /* _ASM_DMA_H */
diff --git a/include/asm-s390x/ebcdic.h b/include/asm-s390x/ebcdic.h
new file mode 100644
index 000000000..086a09eb8
--- /dev/null
+++ b/include/asm-s390x/ebcdic.h
@@ -0,0 +1,55 @@
+/*
+ * include/asm-s390/ebcdic.h
+ * EBCDIC -> ASCII, ASCII -> EBCDIC conversion routines.
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
+ */
+
+#ifndef _EBCDIC_H
+#define _EBCDIC_H
+
+#ifndef _S390_TYPES_H
+#include <types.h>
+#endif
+
+extern __u8 _ascebc_500[]; /* ASCII -> EBCDIC 500 conversion table */
+extern __u8 _ebcasc_500[]; /* EBCDIC 500 -> ASCII conversion table */
+extern __u8 _ascebc[]; /* ASCII -> EBCDIC conversion table */
+extern __u8 _ebcasc[]; /* EBCDIC -> ASCII conversion table */
+extern __u8 _ebc_tolower[]; /* EBCDIC -> lowercase */
+extern __u8 _ebc_toupper[]; /* EBCDIC -> uppercase */
+
+extern __inline__ void
+codepage_convert(const __u8 *codepage, volatile __u8 * addr, unsigned long nr)
+{
+ static const __u16 tr_op[] = { 0xDC00, 0x1000,0x3000 };
+ __asm__ __volatile__(
+ " lgr 1,%0\n"
+ " lgr 2,%1\n"
+ " lgr 3,%2\n"
+ " aghi 2,-256\n"
+ " jm 1f\n"
+ "0: tr 0(256,1),0(3)\n"
+ " aghi 1,256\n"
+ " aghi 2,-256\n"
+ " jp 0b\n"
+ "1: aghi 2,255\n"
+ " jm 2f\n"
+ " ex 2,%3\n"
+ "2:"
+ : /* no output */
+ : "a" (addr), "d" (nr), "a" (codepage), "m" (tr_op[0])
+ : "cc", "memory", "1", "2", "3" );
+}
+
+#define ASCEBC(addr,nr) codepage_convert(_ascebc, addr, nr)
+#define EBCASC(addr,nr) codepage_convert(_ebcasc, addr, nr)
+#define ASCEBC_500(addr,nr) codepage_convert(_ascebc_500, addr, nr)
+#define EBCASC_500(addr,nr) codepage_convert(_ebcasc_500, addr, nr)
+#define EBC_TOLOWER(addr,nr) codepage_convert(_ebc_tolower, addr, nr)
+#define EBC_TOUPPER(addr,nr) codepage_convert(_ebc_toupper, addr, nr)
+
+#endif
+
diff --git a/include/asm-s390x/elf.h b/include/asm-s390x/elf.h
new file mode 100644
index 000000000..3c0989b8d
--- /dev/null
+++ b/include/asm-s390x/elf.h
@@ -0,0 +1,82 @@
+/*
+ * include/asm-s390/elf.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/elf.h"
+ */
+
+#ifndef __ASMS390_ELF_H
+#define __ASMS390_ELF_H
+
+/*
+ * ELF register definitions..
+ */
+
+#include <asm/ptrace.h>
+#include <asm/user.h>
+
+
+typedef s390_fp_regs elf_fpregset_t;
+typedef s390_regs elf_gregset_t;
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS ELFCLASS64
+#define ELF_DATA ELFDATA2MSB
+#define ELF_ARCH EM_S390
+
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+#define elf_check_arch(x) \
+ ((x)->e_machine == ELF_ARCH && (x)->e_ident[EI_CLASS] == ELF_CLASS)
+
+/* For SVR4/S390 the function pointer to be registered with `atexit` is
+ passed in R14. */
+#define ELF_PLAT_INIT(_r) \
+ do { \
+ _r->gprs[14] = 0; \
+ current->thread.flags = 0; \
+ } while(0)
+
+#define USE_ELF_CORE_DUMP
+#define ELF_EXEC_PAGESIZE 4096
+
+/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
+ use of this is to invoke "./ld.so someprog" to test out a new version of
+ the loader. We need to make sure that it is out of the way of the program
+ that it will "exec", and that there is sufficient room for the brk. */
+
+#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
+
+/* Wow, the "main" arch needs arch dependent functions too.. :) */
+
+/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
+ now struct_user_regs, they are different) */
+
+#define ELF_CORE_COPY_REGS(pr_reg, regs) \
+ memcpy(&pr_reg,regs,sizeof(elf_gregset_t)); \
+
+
+
+/* This yields a mask that user programs can use to figure out what
+ instruction set this CPU supports. */
+
+#define ELF_HWCAP (0)
+
+/* This yields a string that ld.so will use to load implementation
+ specific libraries for optimization. This is more specific in
+ intent than poking at uname or /proc/cpuinfo.
+
+ For the moment, we have only optimizations for the Intel generations,
+ but that could change... */
+
+#define ELF_PLATFORM (NULL)
+
+#ifdef __KERNEL__
+#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
+#endif
+
+#endif
diff --git a/include/asm-s390x/errno.h b/include/asm-s390x/errno.h
new file mode 100644
index 000000000..37d3f24c0
--- /dev/null
+++ b/include/asm-s390x/errno.h
@@ -0,0 +1,140 @@
+/*
+ * include/asm-s390/errno.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/errno.h"
+ */
+
+#ifndef _S390_ERRNO_H
+#define _S390_ERRNO_H
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Arg list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No child processes */
+#define EAGAIN 11 /* Try again */
+#define ENOMEM 12 /* Out of memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device or resource busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math argument out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+#define EDEADLK 35 /* Resource deadlock would occur */
+#define ENAMETOOLONG 36 /* File name too long */
+#define ENOLCK 37 /* No record locks available */
+#define ENOSYS 38 /* Function not implemented */
+#define ENOTEMPTY 39 /* Directory not empty */
+#define ELOOP 40 /* Too many symbolic links encountered */
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define ENOMSG 42 /* No message of desired type */
+#define EIDRM 43 /* Identifier removed */
+#define ECHRNG 44 /* Channel number out of range */
+#define EL2NSYNC 45 /* Level 2 not synchronized */
+#define EL3HLT 46 /* Level 3 halted */
+#define EL3RST 47 /* Level 3 reset */
+#define ELNRNG 48 /* Link number out of range */
+#define EUNATCH 49 /* Protocol driver not attached */
+#define ENOCSI 50 /* No CSI structure available */
+#define EL2HLT 51 /* Level 2 halted */
+#define EBADE 52 /* Invalid exchange */
+#define EBADR 53 /* Invalid request descriptor */
+#define EXFULL 54 /* Exchange full */
+#define ENOANO 55 /* No anode */
+#define EBADRQC 56 /* Invalid request code */
+#define EBADSLT 57 /* Invalid slot */
+
+#define EDEADLOCK EDEADLK
+
+#define EBFONT 59 /* Bad font file format */
+#define ENOSTR 60 /* Device not a stream */
+#define ENODATA 61 /* No data available */
+#define ETIME 62 /* Timer expired */
+#define ENOSR 63 /* Out of streams resources */
+#define ENONET 64 /* Machine is not on the network */
+#define ENOPKG 65 /* Package not installed */
+#define EREMOTE 66 /* Object is remote */
+#define ENOLINK 67 /* Link has been severed */
+#define EADV 68 /* Advertise error */
+#define ESRMNT 69 /* Srmount error */
+#define ECOMM 70 /* Communication error on send */
+#define EPROTO 71 /* Protocol error */
+#define EMULTIHOP 72 /* Multihop attempted */
+#define EDOTDOT 73 /* RFS specific error */
+#define EBADMSG 74 /* Not a data message */
+#define EOVERFLOW 75 /* Value too large for defined data type */
+#define ENOTUNIQ 76 /* Name not unique on network */
+#define EBADFD 77 /* File descriptor in bad state */
+#define EREMCHG 78 /* Remote address changed */
+#define ELIBACC 79 /* Can not access a needed shared library */
+#define ELIBBAD 80 /* Accessing a corrupted shared library */
+#define ELIBSCN 81 /* .lib section in a.out corrupted */
+#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
+#define ELIBEXEC 83 /* Cannot exec a shared library directly */
+#define EILSEQ 84 /* Illegal byte sequence */
+#define ERESTART 85 /* Interrupted system call should be restarted */
+#define ESTRPIPE 86 /* Streams pipe error */
+#define EUSERS 87 /* Too many users */
+#define ENOTSOCK 88 /* Socket operation on non-socket */
+#define EDESTADDRREQ 89 /* Destination address required */
+#define EMSGSIZE 90 /* Message too long */
+#define EPROTOTYPE 91 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 92 /* Protocol not available */
+#define EPROTONOSUPPORT 93 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
+#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
+#define EPFNOSUPPORT 96 /* Protocol family not supported */
+#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
+#define EADDRINUSE 98 /* Address already in use */
+#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
+#define ENETDOWN 100 /* Network is down */
+#define ENETUNREACH 101 /* Network is unreachable */
+#define ENETRESET 102 /* Network dropped connection because of reset */
+#define ECONNABORTED 103 /* Software caused connection abort */
+#define ECONNRESET 104 /* Connection reset by peer */
+#define ENOBUFS 105 /* No buffer space available */
+#define EISCONN 106 /* Transport endpoint is already connected */
+#define ENOTCONN 107 /* Transport endpoint is not connected */
+#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
+#define ETOOMANYREFS 109 /* Too many references: cannot splice */
+#define ETIMEDOUT 110 /* Connection timed out */
+#define ECONNREFUSED 111 /* Connection refused */
+#define EHOSTDOWN 112 /* Host is down */
+#define EHOSTUNREACH 113 /* No route to host */
+#define EALREADY 114 /* Operation already in progress */
+#define EINPROGRESS 115 /* Operation now in progress */
+#define ESTALE 116 /* Stale NFS file handle */
+#define EUCLEAN 117 /* Structure needs cleaning */
+#define ENOTNAM 118 /* Not a XENIX named type file */
+#define ENAVAIL 119 /* No XENIX semaphores available */
+#define EISNAM 120 /* Is a named type file */
+#define EREMOTEIO 121 /* Remote I/O error */
+#define EDQUOT 122 /* Quota exceeded */
+
+#define ENOMEDIUM 123 /* No medium found */
+#define EMEDIUMTYPE 124 /* Wrong medium type */
+
+#endif
diff --git a/include/asm-s390x/fcntl.h b/include/asm-s390x/fcntl.h
new file mode 100644
index 000000000..63c92ded4
--- /dev/null
+++ b/include/asm-s390x/fcntl.h
@@ -0,0 +1,85 @@
+/*
+ * include/asm-s390/fcntl.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/fcntl.h"
+ */
+#ifndef _S390_FCNTL_H
+#define _S390_FCNTL_H
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define FASYNC 020000 /* fcntl, for BSD compatibility */
+#define O_DIRECT 040000 /* direct disk access hint - currently ignored */
+#define O_LARGEFILE 0100000
+#define O_DIRECTORY 0200000 /* must be a directory */
+#define O_NOFOLLOW 0400000 /* don't follow links */
+
+#define F_DUPFD 0 /* dup */
+#define F_GETFD 1 /* get close_on_exec */
+#define F_SETFD 2 /* set/clear close_on_exec */
+#define F_GETFL 3 /* get file->f_flags */
+#define F_SETFL 4 /* set file->f_flags */
+#define F_GETLK 5
+#define F_SETLK 6
+#define F_SETLKW 7
+
+#define F_SETOWN 8 /* for sockets. */
+#define F_GETOWN 9 /* for sockets. */
+#define F_SETSIG 10 /* for sockets. */
+#define F_GETSIG 11 /* for sockets. */
+
+/* for F_[GET|SET]FL */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* for posix fcntl() and lockf() */
+#define F_RDLCK 0
+#define F_WRLCK 1
+#define F_UNLCK 2
+
+/* for old implementation of bsd flock () */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+/* for leases */
+#define F_INPROGRESS 16
+
+/* operations for bsd flock(), also used by the kernel implementation */
+#define LOCK_SH 1 /* shared lock */
+#define LOCK_EX 2 /* exclusive lock */
+#define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+#define LOCK_UN 8 /* remove lock */
+
+#define LOCK_MAND 32 /* This is a mandatory flock */
+#define LOCK_READ 64 /* ... Which allows concurrent read operations */
+#define LOCK_WRITE 128 /* ... Which allows concurrent write operations
+*/
+#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
+
+struct flock {
+ short l_type;
+ short l_whence;
+ __kernel_off_t l_start;
+ __kernel_off_t l_len;
+ __kernel_pid_t l_pid;
+};
+
+#define F_LINUX_SPECIFIC_BASE 1024
+
+#define flock64 flock
+
+#endif
diff --git a/include/asm-s390x/gdb-stub.h b/include/asm-s390x/gdb-stub.h
new file mode 100644
index 000000000..fa68800f4
--- /dev/null
+++ b/include/asm-s390x/gdb-stub.h
@@ -0,0 +1,18 @@
+/*
+ * include/asm-s390/gdb-stub.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ */
+
+#ifndef __S390_GDB_STUB__
+#define __S390_GDB_STUB__
+#include <linux/config.h>
+#if CONFIG_REMOTE_DEBUG
+#include <asm/s390-gdbregs.h>
+#include <asm/ptrace.h>
+extern int gdb_stub_initialised;
+extern void gdb_stub_handle_exception(gdb_pt_regs *regs,int sigval);
+#endif
+#endif
diff --git a/include/asm-s390x/hardirq.h b/include/asm-s390x/hardirq.h
new file mode 100644
index 000000000..d5ec49dde
--- /dev/null
+++ b/include/asm-s390x/hardirq.h
@@ -0,0 +1,108 @@
+/*
+ * include/asm-s390/hardirq.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
+ * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ *
+ * Derived from "include/asm-i386/hardirq.h"
+ */
+
+#ifndef __ASM_HARDIRQ_H
+#define __ASM_HARDIRQ_H
+
+#include <linux/config.h>
+#include <linux/threads.h>
+#include <asm/lowcore.h>
+#include <linux/sched.h>
+
+/* No irq_cpustat_t for s390, the data is held directly in S390_lowcore */
+
+/*
+ * Simple wrappers reducing source bloat. S390 specific because each
+ * cpu stores its data in S390_lowcore (PSA) instead of using a cache
+ * aligned array element like most architectures.
+ */
+
+#ifdef CONFIG_SMP
+
+#define softirq_active(cpu) (safe_get_cpu_lowcore(cpu).__softirq_active)
+#define softirq_mask(cpu) (safe_get_cpu_lowcore(cpu).__softirq_mask)
+#define local_irq_count(cpu) (safe_get_cpu_lowcore(cpu).__local_irq_count)
+#define local_bh_count(cpu) (safe_get_cpu_lowcore(cpu).__local_bh_count)
+#define syscall_count(cpu) (safe_get_cpu_lowcore(cpu).__syscall_count)
+
+#else /* CONFIG_SMP */
+
+/* Optimize away the cpu calculation, it is always current PSA */
+#define softirq_active(cpu) ((void)(cpu), S390_lowcore.__softirq_active)
+#define softirq_mask(cpu) ((void)(cpu), S390_lowcore.__softirq_mask)
+#define local_irq_count(cpu) ((void)(cpu), S390_lowcore.__local_irq_count)
+#define local_bh_count(cpu) ((void)(cpu), S390_lowcore.__local_bh_count)
+#define syscall_count(cpu) ((void)(cpu), S390_lowcore.__syscall_count)
+
+#endif /* CONFIG_SMP */
+
+/*
+ * Are we in an interrupt context? Either doing bottom half
+ * or hardware interrupt processing?
+ * Special definitions for s390, always access current PSA.
+ */
+#define in_interrupt() ((S390_lowcore.__local_irq_count + S390_lowcore.__local_bh_count) != 0)
+
+#define in_irq() (S390_lowcore.__local_irq_count != 0)
+
+#ifndef CONFIG_SMP
+
+#define hardirq_trylock(cpu) (local_irq_count(cpu) == 0)
+#define hardirq_endlock(cpu) do { } while (0)
+
+#define hardirq_enter(cpu) (local_irq_count(cpu)++)
+#define hardirq_exit(cpu) (local_irq_count(cpu)--)
+
+#define synchronize_irq() do { } while (0)
+
+#else
+
+#include <asm/atomic.h>
+#include <asm/smp.h>
+
+extern atomic_t global_irq_holder;
+extern atomic_t global_irq_lock;
+extern atomic_t global_irq_count;
+
+static inline void release_irqlock(int cpu)
+{
+ /* if we didn't own the irq lock, just ignore.. */
+ if (atomic_read(&global_irq_holder) == cpu) {
+ atomic_set(&global_irq_holder,NO_PROC_ID);
+ atomic_set(&global_irq_lock,0);
+ }
+}
+
+static inline void hardirq_enter(int cpu)
+{
+ ++local_irq_count(cpu);
+ atomic_inc(&global_irq_count);
+}
+
+static inline void hardirq_exit(int cpu)
+{
+ atomic_dec(&global_irq_count);
+ --local_irq_count(cpu);
+}
+
+static inline int hardirq_trylock(int cpu)
+{
+ return !atomic_read(&global_irq_count) &&
+ !atomic_read(&global_irq_lock);
+}
+
+#define hardirq_endlock(cpu) do { } while (0)
+
+extern void synchronize_irq(void);
+
+#endif /* CONFIG_SMP */
+
+#endif /* __ASM_HARDIRQ_H */
diff --git a/include/asm-s390x/hdreg.h b/include/asm-s390x/hdreg.h
new file mode 100644
index 000000000..20061819d
--- /dev/null
+++ b/include/asm-s390x/hdreg.h
@@ -0,0 +1,13 @@
+/*
+ * linux/include/asm-arm/hdreg.h
+ *
+ * Copyright (C) 1994-1996 Linus Torvalds & authors
+ */
+
+#ifndef __ASMS390_HDREG_H
+#define __ASMS390_HDREG_H
+
+typedef unsigned long ide_ioreg_t;
+
+#endif /* __ASMS390_HDREG_H */
+
diff --git a/include/asm-s390x/idals.h b/include/asm-s390x/idals.h
new file mode 100644
index 000000000..277489692
--- /dev/null
+++ b/include/asm-s390x/idals.h
@@ -0,0 +1,57 @@
+/*
+ * File...........: linux/include/asm-s390x/idals.h
+ * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
+ * Bugreports.to..: <Linux390@de.ibm.com>
+ * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000a
+
+ * History of changes
+ * 07/24/00 new file
+ */
+#include <linux/config.h>
+#include <asm/irq.h>
+
+typedef unsigned long idaw_t;
+
+static inline idaw_t *
+idal_alloc ( int nridaws )
+{
+ if ( nridaws > 33 )
+ BUG();
+ return kmalloc(nridaws * sizeof(idaw_t), GFP_ATOMIC | GFP_DMA );
+}
+
+static inline void
+idal_free ( idaw_t *idal )
+{
+ kfree (idal);
+}
+
+/*
+ * Function: set_normalized_cda
+ * sets the address of the data in CCW
+ * if necessary it allocates an IDAL and sets sthe appropriate flags
+ */
+#if defined (CONFIG_ARCH_S390X)
+extern void set_normalized_cda(ccw1_t * ccw, unsigned long address);
+#else
+static inline void
+set_normalized_cda(ccw1_t * ccw, unsigned long address)
+{
+ ccw->cda = address;
+}
+#endif
+
+/*
+ * Function: clear_normalized_cda
+ * releases any allocated IDAL related to the CCW
+ */
+static inline void
+clear_normalized_cda ( ccw1_t * ccw )
+{
+ if ( ccw -> flags & CCW_FLAG_IDA ) {
+ idal_free ( (idaw_t *)(unsigned long) (ccw -> cda ));
+ ccw -> flags &= ~CCW_FLAG_IDA;
+ }
+ ccw -> cda = 0;
+}
+
diff --git a/include/asm-s390x/ide.h b/include/asm-s390x/ide.h
new file mode 100644
index 000000000..eb47027ff
--- /dev/null
+++ b/include/asm-s390x/ide.h
@@ -0,0 +1,54 @@
+/*
+ * linux/include/asm-arm/ide.h
+ *
+ * Copyright (C) 1994-1996 Linus Torvalds & authors
+ */
+
+/* s390 does not have IDE */
+
+#ifndef __ASMS390_IDE_H
+#define __ASMS390_IDE_H
+
+#ifdef __KERNEL__
+
+#ifndef MAX_HWIFS
+#define MAX_HWIFS 0
+#endif
+
+#define ide__sti() do {} while (0)
+
+typedef union {
+ unsigned all : 8; /* all of the bits together */
+ struct {
+ unsigned head : 4; /* always zeros here */
+ unsigned unit : 1; /* drive select number, 0 or 1 */
+ unsigned bit5 : 1; /* always 1 */
+ unsigned lba : 1; /* using LBA instead of CHS */
+ unsigned bit7 : 1; /* always 1 */
+ } b;
+ } select_t;
+
+#define ide_request_irq(irq,hand,flg,dev,id) do {} while (0)
+#define ide_free_irq(irq,dev_id) do {} while (0)
+#define ide_check_region(from,extent) do {} while (0)
+#define ide_request_region(from,extent,name) do {} while (0)
+#define ide_release_region(from,extent) do {} while (0)
+
+/*
+ * The following are not needed for the non-m68k ports
+ */
+#define ide_ack_intr(hwif) (1)
+#define ide_fix_driveid(id) do {} while (0)
+#define ide_release_lock(lock) do {} while (0)
+#define ide_get_lock(lock, hdlr, data) do {} while (0)
+
+/*
+ * We always use the new IDE port registering,
+ * so these are fixed here.
+ */
+#define ide_default_io_base(i) ((ide_ioreg_t)0)
+#define ide_default_irq(b) (0)
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASMARM_IDE_H */
diff --git a/include/asm-s390x/init.h b/include/asm-s390x/init.h
new file mode 100644
index 000000000..715485b72
--- /dev/null
+++ b/include/asm-s390x/init.h
@@ -0,0 +1,29 @@
+/*
+ * include/asm-s390/init.h
+ *
+ * S390 version
+ */
+
+#ifndef _S390_INIT_H
+#define _S390_INIT_H
+
+#define __init __attribute__ ((constructor))
+
+/* don't know, if need on S390 */
+#define __initdata
+#define __initfunc(__arginit) \
+ __arginit __init; \
+ __arginit
+/* For assembly routines
+ * need to define ?
+ */
+/*
+#define __INIT .section ".text.init",#alloc,#execinstr
+#define __FINIT .previous
+#define __INITDATA .section ".data.init",#alloc,#write
+*/
+
+#define __cacheline_aligned __attribute__ ((__aligned__(16)))
+
+#endif
+
diff --git a/include/asm-s390x/io.h b/include/asm-s390x/io.h
new file mode 100644
index 000000000..9a4aabd6f
--- /dev/null
+++ b/include/asm-s390x/io.h
@@ -0,0 +1,94 @@
+/*
+ * include/asm-s390/io.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/io.h"
+ */
+
+#ifndef _S390_IO_H
+#define _S390_IO_H
+
+#ifdef __KERNEL__
+
+#include <linux/vmalloc.h>
+#include <asm/page.h>
+
+#define IO_SPACE_LIMIT 0xffffffff
+
+#define __io_virt(x) ((void *)(PAGE_OFFSET | (unsigned long)(x)))
+#define __io_phys(x) ((unsigned long)(x) & ~PAGE_OFFSET)
+/*
+ * Change virtual addresses to physical addresses and vv.
+ * These are pretty trivial
+ */
+extern inline unsigned long virt_to_phys(volatile void * address)
+{
+ unsigned long real_address;
+ __asm__ (" lrag %0,0(%1)\n"
+ " jz 0f\n"
+ " slgr %0,%0\n"
+ "0:"
+ : "=a" (real_address) : "a" (address) );
+ return real_address;
+}
+
+extern inline void * phys_to_virt(unsigned long address)
+{
+ return __io_virt(address);
+}
+
+extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
+
+extern inline void * ioremap (unsigned long offset, unsigned long size)
+{
+ return __ioremap(offset, size, 0);
+}
+
+/*
+ * This one maps high address device memory and turns off caching for that area.
+ * it's useful if some control registers are in such an area and write combining
+ * or read caching is not desirable:
+ */
+extern inline void * ioremap_nocache (unsigned long offset, unsigned long size)
+{
+ return __ioremap(offset, size, 0);
+}
+
+extern void iounmap(void *addr);
+
+/*
+ * IO bus memory addresses are also 1:1 with the physical address
+ */
+#define virt_to_bus virt_to_phys
+#define bus_to_virt phys_to_virt
+
+/*
+ * readX/writeX() are used to access memory mapped devices. On some
+ * architectures the memory mapped IO stuff needs to be accessed
+ * differently.
+ */
+
+#define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
+#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
+#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
+
+#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
+#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
+#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
+
+#define memset_io(a,b,c) memset(__io_virt(a),(b),(c))
+#define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c))
+#define memcpy_toio(a,b,c) memcpy(__io_virt(a),(b),(c))
+
+#define inb_p(addr) readb(addr)
+#define inb(addr) readb(addr)
+
+#define outb(x,addr) ((void) writeb(x,addr))
+#define outb_p(x,addr) outb(x,addr)
+
+#endif /* __KERNEL__ */
+
+#endif
diff --git a/include/asm-s390x/ioctl.h b/include/asm-s390x/ioctl.h
new file mode 100644
index 000000000..35b4821e8
--- /dev/null
+++ b/include/asm-s390x/ioctl.h
@@ -0,0 +1,78 @@
+/*
+ * include/asm-s390/ioctl.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/ioctl.h"
+ */
+
+#ifndef _S390_IOCTL_H
+#define _S390_IOCTL_H
+
+/* ioctl command encoding: 32 bits total, command in lower 16 bits,
+ * size of the parameter structure in the lower 14 bits of the
+ * upper 16 bits.
+ * Encoding the size of the parameter structure in the ioctl request
+ * is useful for catching programs compiled with old versions
+ * and to avoid overwriting user space outside the user buffer area.
+ * The highest 2 bits are reserved for indicating the ``access mode''.
+ * NOTE: This limits the max parameter size to 16kB -1 !
+ */
+
+/*
+ * The following is for compatibility across the various Linux
+ * platforms. The i386 ioctl numbering scheme doesn't really enforce
+ * a type field. De facto, however, the top 8 bits of the lower 16
+ * bits are indeed used as a type field, so we might just as well make
+ * this explicit here. Please be sure to use the decoding macros
+ * below from now on.
+ */
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits.
+ */
+#define _IOC_NONE 0U
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode ioctl numbers.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+#endif /* _S390_IOCTL_H */
diff --git a/include/asm-s390x/ioctls.h b/include/asm-s390x/ioctls.h
new file mode 100644
index 000000000..db7b0a0c3
--- /dev/null
+++ b/include/asm-s390x/ioctls.h
@@ -0,0 +1,89 @@
+/*
+ * include/asm-s390/ioctls.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/ioctls.h"
+ */
+
+#ifndef __ARCH_S390_IOCTLS_H__
+#define __ARCH_S390_IOCTLS_H__
+
+#include <asm/ioctl.h>
+
+/* 0x54 is just a magic number to make these relatively unique ('T') */
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+#define TCGETA 0x5405
+#define TCSETA 0x5406
+#define TCSETAW 0x5407
+#define TCSETAF 0x5408
+#define TCSBRK 0x5409
+#define TCXONC 0x540A
+#define TCFLSH 0x540B
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+#define FIOQSIZE 0x545E
+
+/* Used for packet mode */
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+
+#endif
diff --git a/include/asm-s390x/ipc.h b/include/asm-s390x/ipc.h
new file mode 100644
index 000000000..66d2b53de
--- /dev/null
+++ b/include/asm-s390x/ipc.h
@@ -0,0 +1,39 @@
+/*
+ * include/asm-s390/ipc.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/ipc.h"
+ */
+
+#ifndef __s390_IPC_H__
+#define __s390_IPC_H__
+
+/*
+ * These are used to wrap system calls on S390.
+ *
+ * See arch/s390/kernel/sys_s390.c for ugly details..
+ */
+struct ipc_kludge {
+ struct msgbuf *msgp;
+ long msgtyp;
+};
+
+#define SEMOP 1
+#define SEMGET 2
+#define SEMCTL 3
+#define MSGSND 11
+#define MSGRCV 12
+#define MSGGET 13
+#define MSGCTL 14
+#define SHMAT 21
+#define SHMDT 22
+#define SHMGET 23
+#define SHMCTL 24
+
+/* Used by the DIPC package, try and avoid reusing it */
+#define DIPC 25
+
+#define IPCCALL(version,op) ((version)<<16 | (op))
+
+#endif
diff --git a/include/asm-s390x/ipcbuf.h b/include/asm-s390x/ipcbuf.h
new file mode 100644
index 000000000..d007272a8
--- /dev/null
+++ b/include/asm-s390x/ipcbuf.h
@@ -0,0 +1,28 @@
+#ifndef __S390_IPCBUF_H__
+#define __S390_IPCBUF_H__
+
+/*
+ * The user_ipc_perm structure for S/390 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 32-bit mode_t and seq
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct ipc64_perm
+{
+ __kernel_key_t key;
+ __kernel_uid32_t uid;
+ __kernel_gid32_t gid;
+ __kernel_uid32_t cuid;
+ __kernel_gid32_t cgid;
+ __kernel_mode_t mode;
+ unsigned short __pad1;
+ unsigned short seq;
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif /* __S390_IPCBUF_H__ */
diff --git a/include/asm-s390x/irq.h b/include/asm-s390x/irq.h
new file mode 100644
index 000000000..9849d6fdc
--- /dev/null
+++ b/include/asm-s390x/irq.h
@@ -0,0 +1,962 @@
+#ifndef __irq_h
+#define __irq_h
+
+#include <linux/config.h>
+#ifdef __KERNEL__
+#include <asm/hardirq.h>
+
+/*
+ * How many IRQ's for S390 ?!?
+ */
+#define __MAX_SUBCHANNELS 65536
+#define NR_IRQS __MAX_SUBCHANNELS
+
+#define LPM_ANYPATH 0xff /* doesn't really belong here, Ingo? */
+
+#define INVALID_STORAGE_AREA ((void *)(-1 - 0x3FFF ))
+
+extern int disable_irq(unsigned int);
+extern int enable_irq(unsigned int);
+
+/*
+ * Interrupt controller descriptor. This is all we need
+ * to describe about the low-level hardware.
+ */
+struct hw_interrupt_type {
+ const __u8 *typename;
+ int (*handle)(unsigned int irq,
+ int cpu,
+ struct pt_regs * regs);
+ int (*enable) (unsigned int irq);
+ int (*disable)(unsigned int irq);
+};
+
+/*
+ * Status: reason for being disabled: somebody has
+ * done a "disable_irq()" or we must not re-enter the
+ * already executing irq..
+ */
+#define IRQ_INPROGRESS 1
+#define IRQ_DISABLED 2
+#define IRQ_PENDING 4
+
+/*
+ * path management control word
+ */
+typedef struct {
+ __u32 intparm; /* interruption parameter */
+ __u32 qf : 1; /* qdio facility */
+ __u32 res0 : 1; /* reserved zeros */
+ __u32 isc : 3; /* interruption sublass */
+ __u32 res5 : 3; /* reserved zeros */
+ __u32 ena : 1; /* enabled */
+ __u32 lm : 2; /* limit mode */
+ __u32 mme : 2; /* measurement-mode enable */
+ __u32 mp : 1; /* multipath mode */
+ __u32 tf : 1; /* timing facility */
+ __u32 dnv : 1; /* device number valid */
+ __u32 dev : 16; /* device number */
+ __u8 lpm; /* logical path mask */
+ __u8 pnom; /* path not operational mask */
+ __u8 lpum; /* last path used mask */
+ __u8 pim; /* path installed mask */
+ __u16 mbi; /* measurement-block index */
+ __u8 pom; /* path operational mask */
+ __u8 pam; /* path available mask */
+ __u8 chpid[8]; /* CHPID 0-7 (if available) */
+ __u32 unused1 : 8; /* reserved zeros */
+ __u32 st : 3; /* subchannel type */
+ __u32 unused2 : 20; /* reserved zeros */
+ __u32 csense : 1; /* concurrent sense; can be enabled ...*/
+ /* ... per MSCH, however, if facility */
+ /* ... is not installed, this results */
+ /* ... in an operand exception. */
+ } __attribute__ ((packed)) pmcw_t;
+
+#endif /* __KERNEL__ */
+/*
+ * subchannel status word
+ */
+typedef struct {
+ __u32 key : 4; /* subchannel key */
+ __u32 sctl : 1; /* suspend control */
+ __u32 eswf : 1; /* ESW format */
+ __u32 cc : 2; /* deferred condition code */
+ __u32 fmt : 1; /* format */
+ __u32 pfch : 1; /* prefetch */
+ __u32 isic : 1; /* initial-status interruption control */
+ __u32 alcc : 1; /* address-limit checking control */
+ __u32 ssi : 1; /* suppress-suspended interruption */
+ __u32 zcc : 1; /* zero condition code */
+ __u32 ectl : 1; /* extended control */
+ __u32 pno : 1; /* path not operational */
+ __u32 res : 1; /* reserved */
+ __u32 fctl : 3; /* function control */
+ __u32 actl : 7; /* activity control */
+ __u32 stctl : 5; /* status control */
+ __u32 cpa; /* channel program address */
+ __u32 dstat : 8; /* device status */
+ __u32 cstat : 8; /* subchannel status */
+ __u32 count : 16; /* residual count */
+ } __attribute__ ((packed)) scsw_t;
+
+#define SCSW_FCTL_CLEAR_FUNC 0x1
+#define SCSW_FCTL_HALT_FUNC 0x2
+#define SCSW_FCTL_START_FUNC 0x4
+
+#define SCSW_ACTL_SUSPENDED 0x1
+#define SCSW_ACTL_DEVACT 0x2
+#define SCSW_ACTL_SCHACT 0x4
+#define SCSW_ACTL_CLEAR_PEND 0x8
+#define SCSW_ACTL_HALT_PEND 0x10
+#define SCSW_ACTL_START_PEND 0x20
+#define SCSW_ACTL_RESUME_PEND 0x40
+
+#define SCSW_STCTL_STATUS_PEND 0x1
+#define SCSW_STCTL_SEC_STATUS 0x2
+#define SCSW_STCTL_PRIM_STATUS 0x4
+#define SCSW_STCTL_INTER_STATUS 0x8
+#define SCSW_STCTL_ALERT_STATUS 0x10
+
+#define DEV_STAT_ATTENTION 0x80
+#define DEV_STAT_STAT_MOD 0x40
+#define DEV_STAT_CU_END 0x20
+#define DEV_STAT_BUSY 0x10
+#define DEV_STAT_CHN_END 0x08
+#define DEV_STAT_DEV_END 0x04
+#define DEV_STAT_UNIT_CHECK 0x02
+#define DEV_STAT_UNIT_EXCEP 0x01
+
+#define SCHN_STAT_PCI 0x80
+#define SCHN_STAT_INCORR_LEN 0x40
+#define SCHN_STAT_PROG_CHECK 0x20
+#define SCHN_STAT_PROT_CHECK 0x10
+#define SCHN_STAT_CHN_DATA_CHK 0x08
+#define SCHN_STAT_CHN_CTRL_CHK 0x04
+#define SCHN_STAT_INTF_CTRL_CHK 0x02
+#define SCHN_STAT_CHAIN_CHECK 0x01
+
+/*
+ * architectured values for first sense byte
+ */
+#define SNS0_CMD_REJECT 0x80
+#define SNS_CMD_REJECT SNS0_CMD_REJECT
+#define SNS0_INTERVENTION_REQ 0x40
+#define SNS0_BUS_OUT_CHECK 0x20
+#define SNS0_EQUIPMENT_CHECK 0x10
+#define SNS0_DATA_CHECK 0x08
+#define SNS0_OVERRUN 0x04
+/* 0x02 reserved */
+#define SNS0_INCOMPL_DOMAIN 0x01
+
+/*
+ * architectured values for second sense byte
+ */
+#define SNS1_PERM_ERR 0x80
+#define SNS1_INV_TRACK_FORMAT 0x40
+#define SNS1_EOC 0x20
+#define SNS1_MESSAGE_TO_OPER 0x10
+#define SNS1_NO_REC_FOUND 0x08
+#define SNS1_FILE_PROTECTED 0x04
+#define SNS1_WRITE_INHIBITED 0x02
+#define SNS1_INPRECISE_END 0x01
+
+/*
+ * architectured values for third sense byte
+ */
+#define SNS2_REQ_INH_WRITE 0x80
+#define SNS2_CORRECTABLE 0x40
+#define SNS2_FIRST_LOG_ERR 0x20
+#define SNS2_ENV_DATA_PRESENT 0x10
+/* 0x08 reserved */
+#define SNS2_INPRECISE_END 0x04
+/* 0x02 reserved */
+/* 0x01 reserved */
+
+#ifdef __KERNEL__
+/*
+ * subchannel information block
+ */
+typedef struct {
+ pmcw_t pmcw; /* path management control word */
+ scsw_t scsw; /* subchannel status word */
+ __u8 mda[12]; /* model dependent area */
+ } __attribute__ ((packed,aligned(4))) schib_t;
+#endif /* __KERNEL__ */
+
+typedef struct {
+ __u8 cmd_code;/* command code */
+ __u8 flags; /* flags, like IDA addressing, etc. */
+ __u16 count; /* byte count */
+ __u32 cda; /* data address */
+ } __attribute__ ((packed,aligned(8))) ccw1_t;
+
+#define CCW_FLAG_DC 0x80
+#define CCW_FLAG_CC 0x40
+#define CCW_FLAG_SLI 0x20
+#define CCW_FLAG_SKIP 0x10
+#define CCW_FLAG_PCI 0x08
+#define CCW_FLAG_IDA 0x04
+#define CCW_FLAG_SUSPEND 0x02
+
+#define CCW_CMD_READ_IPL 0x02
+#define CCW_CMD_NOOP 0x03
+#define CCW_CMD_BASIC_SENSE 0x04
+#define CCW_CMD_TIC 0x08
+#define CCW_CMD_SENSE_PGID 0x34
+#define CCW_CMD_SUSPEND_RECONN 0x5B
+#define CCW_CMD_RDC 0x64
+#define CCW_CMD_SET_PGID 0xAF
+#define CCW_CMD_SENSE_ID 0xE4
+#define CCW_CMD_DCTL 0xF3
+
+#ifdef __KERNEL__
+#define SENSE_MAX_COUNT 0x20
+
+/*
+ * architectured values for first sense byte
+ */
+#define SNS0_CMD_REJECT 0x80
+#define SNS_CMD_REJECT SNS0_CMD_REJECT
+#define SNS0_INTERVENTION_REQ 0x40
+#define SNS0_BUS_OUT_CHECK 0x20
+#define SNS0_EQUIPMENT_CHECK 0x10
+#define SNS0_DATA_CHECK 0x08
+#define SNS0_OVERRUN 0x04
+
+/*
+ * operation request block
+ */
+typedef struct {
+ __u32 intparm; /* interruption parameter */
+ __u32 key : 4; /* flags, like key, suspend control, etc. */
+ __u32 spnd : 1; /* suspend control */
+ __u32 res1 : 1; /* reserved */
+ __u32 mod : 1; /* modification control */
+ __u32 sync : 1; /* synchronize control */
+ __u32 fmt : 1; /* format control */
+ __u32 pfch : 1; /* prefetch control */
+ __u32 isic : 1; /* initial-status-interruption control */
+ __u32 alcc : 1; /* address-limit-checking control */
+ __u32 ssic : 1; /* suppress-suspended-interr. control */
+ __u32 res2 : 1; /* reserved */
+ __u32 c64 : 1; /* IDAW/QDIO 64 bit control */
+ __u32 i2k : 1; /* IDAW 2/4kB block size control */
+ __u32 lpm : 8; /* logical path mask */
+ __u32 ils : 1; /* incorrect length */
+ __u32 zero : 6; /* reserved zeros */
+ __u32 orbx : 1; /* ORB extension control */
+ __u32 cpa; /* channel program address */
+ } __attribute__ ((packed,aligned(4))) orb_t;
+
+#endif /* __KERNEL__ */
+typedef struct {
+ __u32 res0 : 4; /* reserved */
+ __u32 pvrf : 1; /* path-verification-required flag */
+ __u32 cpt : 1; /* channel-path timeout */
+ __u32 fsavf : 1; /* Failing storage address validity flag */
+ __u32 cons : 1; /* concurrent-sense */
+ __u32 res8 : 2; /* reserved */
+ __u32 scnt : 6; /* sense count if cons == 1 */
+ __u32 res16 : 16; /* reserved */
+ } __attribute__ ((packed)) erw_t;
+
+/*
+ * subchannel logout area
+ */
+typedef struct {
+ __u32 res0 : 1; /* reserved */
+ __u32 esf : 7; /* extended status flags */
+ __u32 lpum : 8; /* last path used mask */
+ __u32 res16 : 1; /* reserved */
+ __u32 fvf : 5; /* field-validity flags */
+ __u32 sacc : 2; /* storage access code */
+ __u32 termc : 2; /* termination code */
+ __u32 devsc : 1; /* device-status check */
+ __u32 serr : 1; /* secondary error */
+ __u32 ioerr : 1; /* i/o-error alert */
+ __u32 seqc : 3; /* sequence code */
+ } __attribute__ ((packed)) sublog_t ;
+
+/*
+ * Format 0 Extended Status Word (ESW)
+ */
+typedef struct {
+ sublog_t sublog; /* subchannel logout */
+ erw_t erw; /* extended report word */
+ __u32 faddr; /* failing address */
+ __u32 zeros[2]; /* 2 fullwords of zeros */
+ } __attribute__ ((packed)) esw0_t;
+
+/*
+ * Format 1 Extended Status Word (ESW)
+ */
+typedef struct {
+ __u8 zero0; /* reserved zeros */
+ __u8 lpum; /* last path used mask */
+ __u16 zero16; /* reserved zeros */
+ erw_t erw; /* extended report word */
+ __u32 zeros[3]; /* 2 fullwords of zeros */
+ } __attribute__ ((packed)) esw1_t;
+
+/*
+ * Format 2 Extended Status Word (ESW)
+ */
+typedef struct {
+ __u8 zero0; /* reserved zeros */
+ __u8 lpum; /* last path used mask */
+ __u16 dcti; /* device-connect-time interval */
+ erw_t erw; /* extended report word */
+ __u32 zeros[3]; /* 2 fullwords of zeros */
+ } __attribute__ ((packed)) esw2_t;
+
+/*
+ * Format 3 Extended Status Word (ESW)
+ */
+typedef struct {
+ __u8 zero0; /* reserved zeros */
+ __u8 lpum; /* last path used mask */
+ __u16 res; /* reserved */
+ erw_t erw; /* extended report word */
+ __u32 zeros[3]; /* 2 fullwords of zeros */
+ } __attribute__ ((packed)) esw3_t;
+
+typedef union {
+ esw0_t esw0;
+ esw1_t esw1;
+ esw2_t esw2;
+ esw3_t esw3;
+ } __attribute__ ((packed)) esw_t;
+
+/*
+ * interruption response block
+ */
+typedef struct {
+ scsw_t scsw; /* subchannel status word */
+ esw_t esw; /* extended status word */
+ __u8 ecw[32]; /* extended control word */
+ } irb_t __attribute__ ((packed,aligned(4)));
+#ifdef __KERNEL__
+
+/*
+ * TPI info structure
+ */
+typedef struct {
+ __u32 reserved1 : 16; /* reserved 0x00000001 */
+ __u32 irq : 16; /* aka. subchannel number */
+ __u32 intparm; /* interruption parameter */
+ __u32 adapter_IO : 1;
+ __u32 reserved2 : 1;
+ __u32 isc : 3;
+ __u32 reserved3 : 12;
+ __u32 int_type : 3;
+ __u32 reserved4 : 12;
+ } __attribute__ ((packed)) tpi_info_t;
+
+
+//
+// command information word (CIW) layout
+//
+typedef struct _ciw {
+ __u32 et : 2; // entry type
+ __u32 reserved : 2; // reserved
+ __u32 ct : 4; // command type
+ __u32 cmd : 8; // command
+ __u32 count : 16; // count
+ } __attribute__ ((packed)) ciw_t;
+
+#define CIW_TYPE_RCD 0x0 // read configuration data
+#define CIW_TYPE_SII 0x1 // set interface identifier
+#define CIW_TYPE_RNI 0x2 // read node identifier
+
+#define MAX_CIWS 8
+//
+// sense-id response buffer layout
+//
+typedef struct {
+ /* common part */
+ __u8 reserved; /* always 0x'FF' */
+ __u16 cu_type; /* control unit type */
+ __u8 cu_model; /* control unit model */
+ __u16 dev_type; /* device type */
+ __u8 dev_model; /* device model */
+ __u8 unused; /* padding byte */
+ /* extended part */
+ ciw_t ciw[MAX_CIWS]; /* variable # of CIWs */
+ } __attribute__ ((packed,aligned(4))) senseid_t;
+
+#endif /* __KERNEL__ */
+/*
+ * sense data
+ */
+typedef struct {
+ __u8 res[32]; /* reserved */
+ __u8 data[32]; /* sense data */
+ } __attribute__ ((packed)) sense_t;
+
+/*
+ * device status area, to be provided by the device driver
+ * when calling request_irq() as parameter "dev_id", later
+ * tied to the "action" control block.
+ *
+ * Note : No data area must be added after union ii or the
+ * effective devstat size calculation will fail !
+ */
+typedef struct {
+ __u16 devno; /* device number, aka. "cuu" from irb */
+ unsigned long intparm; /* interrupt parameter */
+ __u8 cstat; /* channel status - accumulated */
+ __u8 dstat; /* device status - accumulated */
+ __u8 lpum; /* last path used mask from irb */
+ __u8 unused; /* not used - reserved */
+ unsigned int flag; /* flag : see below */
+ __u32 cpa; /* CCW address from irb at primary status */
+ __u32 rescnt; /* res. count from irb at primary status */
+ __u32 scnt; /* sense count, if DEVSTAT_FLAG_SENSE_AVAIL */
+ union {
+ irb_t irb; /* interruption response block */
+ sense_t sense; /* sense information */
+ } ii; /* interrupt information */
+ } devstat_t;
+
+#define DEVSTAT_FLAG_SENSE_AVAIL 0x00000001
+#define DEVSTAT_NOT_OPER 0x00000002
+#define DEVSTAT_START_FUNCTION 0x00000004
+#define DEVSTAT_HALT_FUNCTION 0x00000008
+#define DEVSTAT_STATUS_PENDING 0x00000010
+#define DEVSTAT_REVALIDATE 0x00000020
+#define DEVSTAT_DEVICE_GONE 0x00000040
+#define DEVSTAT_DEVICE_OWNED 0x00000080
+#define DEVSTAT_CLEAR_FUNCTION 0x00000100
+#define DEVSTAT_PCI 0x00000200
+#define DEVSTAT_SUSPENDED 0x00000400
+#define DEVSTAT_UNKNOWN_DEV 0x00000800
+#define DEVSTAT_FINAL_STATUS 0x80000000
+
+#define DEVINFO_NOT_OPER DEVSTAT_NOT_OPER
+#define DEVINFO_UNKNOWN_DEV DEVSTAT_UNKNOWN_DEV
+#define DEVINFO_DEVICE_OWNED DEVSTAT_DEVICE_OWNED
+#define DEVINFO_QDIO_CAPABLE 0x40000000
+
+#define INTPARM_STATUS_PENDING 0xFFFFFFFF
+#ifdef __KERNEL__
+
+#define IO_INTERRUPT_TYPE 0 /* I/O interrupt type */
+
+typedef void (* io_handler_func1_t) ( int irq,
+ devstat_t *devstat,
+ struct pt_regs *rgs);
+
+typedef void (* io_handler_func_t) ( int irq,
+ void *devstat,
+ struct pt_regs *rgs);
+
+typedef void ( * not_oper_handler_func_t)( int irq,
+ int status );
+
+typedef int (* adapter_int_handler_t)( __u32 intparm );
+
+struct s390_irqaction {
+ io_handler_func_t handler;
+ unsigned long flags;
+ const char *name;
+ devstat_t *dev_id;
+};
+
+/*
+ * This is the "IRQ descriptor", which contains various information
+ * about the irq, including what kind of hardware handling it has,
+ * whether it is disabled etc etc.
+ *
+ * Pad this out to 32 bytes for cache and indexing reasons.
+ */
+typedef struct {
+ unsigned int status; /* IRQ status - IRQ_INPROGRESS, IRQ_DISABLED */
+ struct hw_interrupt_type *handler; /* handle/enable/disable functions */
+ struct s390_irqaction *action; /* IRQ action list */
+ } irq_desc_t;
+
+typedef struct {
+ __u8 state1 : 2; /* path state value 1 */
+ __u8 state2 : 2; /* path state value 2 */
+ __u8 state3 : 1; /* path state value 3 */
+ __u8 resvd : 3; /* reserved */
+ } __attribute__ ((packed)) path_state_t;
+
+typedef struct {
+ union {
+ __u8 fc; /* SPID function code */
+ path_state_t ps; /* SNID path state */
+ } inf;
+ __u32 cpu_addr : 16; /* CPU address */
+ __u32 cpu_id : 24; /* CPU identification */
+ __u32 cpu_model : 16; /* CPU model */
+ __u32 tod_high; /* high word TOD clock */
+ } __attribute__ ((packed)) pgid_t;
+
+#define SPID_FUNC_SINGLE_PATH 0x00
+#define SPID_FUNC_MULTI_PATH 0x80
+#define SPID_FUNC_ESTABLISH 0x00
+#define SPID_FUNC_RESIGN 0x40
+#define SPID_FUNC_DISBAND 0x20
+
+#define SNID_STATE1_RESET 0
+#define SNID_STATE1_UNGROUPED 2
+#define SNID_STATE1_GROUPED 3
+
+#define SNID_STATE2_NOT_RESVD 0
+#define SNID_STATE2_RESVD_ELSE 2
+#define SNID_STATE2_RESVD_SELF 3
+
+#define SNID_STATE3_MULTI_PATH 1
+#define SNID_STATE3_SINGLE_PATH 0
+
+/*
+ * Flags used as input parameters for do_IO()
+ */
+#define DOIO_EARLY_NOTIFICATION 0x0001 /* allow for I/O completion ... */
+ /* ... notification after ... */
+ /* ... primary interrupt status */
+#define DOIO_RETURN_CHAN_END DOIO_EARLY_NOTIFICATION
+#define DOIO_VALID_LPM 0x0002 /* LPM input parameter is valid */
+#define DOIO_WAIT_FOR_INTERRUPT 0x0004 /* wait synchronously for interrupt */
+#define DOIO_REPORT_ALL 0x0008 /* report all interrupt conditions */
+#define DOIO_ALLOW_SUSPEND 0x0010 /* allow for channel prog. suspend */
+#define DOIO_DENY_PREFETCH 0x0020 /* don't allow for CCW prefetch */
+#define DOIO_SUPPRESS_INTER 0x0040 /* suppress intermediate inter. */
+ /* ... for suspended CCWs */
+#define DOIO_TIMEOUT 0x0080 /* 3 secs. timeout for sync. I/O */
+#define DOIO_DONT_CALL_INTHDLR 0x0100 /* don't call interrupt handler */
+
+/*
+ * do_IO()
+ *
+ * Start a S/390 channel program. When the interrupt arrives
+ * handle_IRQ_event() is called, which eventually calls the
+ * IRQ handler, either immediately, delayed (dev-end missing,
+ * or sense required) or never (no IRQ handler registered -
+ * should never occur, as the IRQ (subchannel ID) should be
+ * disabled if no handler is present. Depending on the action
+ * taken, do_IO() returns : 0 - Success
+ * -EIO - Status pending
+ * see : action->dev_id->cstat
+ * action->dev_id->dstat
+ * -EBUSY - Device busy
+ * -ENODEV - Device not operational
+ */
+int do_IO( int irq, /* IRQ aka. subchannel number */
+ ccw1_t *cpa, /* logical channel program address */
+ unsigned long intparm, /* interruption parameter */
+ __u8 lpm, /* logical path mask */
+ unsigned long flag); /* flags : see above */
+
+int start_IO( int irq, /* IRQ aka. subchannel number */
+ ccw1_t *cpa, /* logical channel program address */
+ unsigned long intparm, /* interruption parameter */
+ __u8 lpm, /* logical path mask */
+ unsigned int flag); /* flags : see above */
+
+void do_crw_pending( void ); /* CRW handler */
+
+int resume_IO( int irq); /* IRQ aka. subchannel number */
+
+int halt_IO( int irq, /* IRQ aka. subchannel number */
+ unsigned long intparm, /* dummy intparm */
+ unsigned long flag); /* possible DOIO_WAIT_FOR_INTERRUPT */
+
+int clear_IO( int irq, /* IRQ aka. subchannel number */
+ unsigned long intparm, /* dummy intparm */
+ unsigned long flag); /* possible DOIO_WAIT_FOR_INTERRUPT */
+
+int process_IRQ( struct pt_regs regs,
+ unsigned int irq,
+ unsigned int intparm);
+
+
+int enable_cpu_sync_isc ( int irq );
+int disable_cpu_sync_isc( int irq );
+
+typedef struct {
+ int irq; /* irq, aka. subchannel */
+ __u16 devno; /* device number */
+ unsigned int status; /* device status */
+ senseid_t sid_data; /* senseID data */
+ } s390_dev_info_t;
+
+int get_dev_info( int irq, s390_dev_info_t *); /* to be eliminated - don't use */
+
+int get_dev_info_by_irq ( int irq, s390_dev_info_t *pdi);
+int get_dev_info_by_devno( __u16 devno, s390_dev_info_t *pdi);
+
+int get_irq_by_devno( __u16 devno );
+unsigned int get_devno_by_irq( int irq );
+
+int get_irq_first( void );
+int get_irq_next ( int irq );
+
+int read_dev_chars( int irq, void **buffer, int length );
+int read_conf_data( int irq, void **buffer, int *length, __u8 lpm );
+
+int s390_DevicePathVerification( int irq, __u8 domask );
+
+int s390_request_irq_special( int irq,
+ io_handler_func_t io_handler,
+ not_oper_handler_func_t not_oper_handler,
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id);
+
+extern int handle_IRQ_event( unsigned int irq, int cpu, struct pt_regs *);
+
+extern int set_cons_dev(int irq);
+extern int reset_cons_dev(int irq);
+extern int wait_cons_dev(int irq);
+
+/*
+ * Some S390 specific IO instructions as inline
+ */
+
+extern __inline__ int stsch(int irq, volatile schib_t *addr)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "STSCH 0(%2)\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (irq | 0x10000L), "a" (addr)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int msch(int irq, volatile schib_t *addr)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "MSCH 0(%2)\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (irq | 0x10000L), "a" (addr)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int msch_err(int irq, volatile schib_t *addr)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ " lgr 1,%1\n"
+ " msch 0(%2)\n"
+ "0: ipm %0\n"
+ " srl %0,28\n"
+ "1:\n"
+ ".section .fixup,\"ax\"\n"
+ "2: l %0,%3\n"
+ " jg 1b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,2b\n"
+ ".previous"
+#else
+ " lr 1,%1\n"
+ " msch 0(%2)\n"
+ "0: ipm %0\n"
+ " srl %0,28\n"
+ "1:\n"
+ ".section .fixup,\"ax\"\n"
+ "2: l %0,%3\n"
+ " bras 1,3f\n"
+ " .long 1b\n"
+ "3: l 1,0(1)\n"
+ " br 1\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 4\n"
+ " .long 0b,2b\n"
+ ".previous"
+#endif
+ : "=d" (ccode)
+ : "r" (irq | 0x10000L), "a" (addr), "i" (__LC_PGM_ILC)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int tsch(int irq, volatile irb_t *addr)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "TSCH 0(%2)\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (irq | 0x10000L), "a" (addr)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int tpi( volatile tpi_info_t *addr)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+ "TPI 0(%1)\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "a" (addr)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int ssch(int irq, volatile orb_t *addr)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "SSCH 0(%2)\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (irq | 0x10000L), "a" (addr)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int rsch(int irq)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "RSCH\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (irq | 0x10000L)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int csch(int irq)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "CSCH\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (irq | 0x10000L)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int hsch(int irq)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "HSCH\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (irq | 0x10000L)
+ : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int iac( void)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+ "IAC 1\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : : "cc", "1" );
+ return ccode;
+}
+
+extern __inline__ int rchp(int chpid)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "LGR 1,%1\n\t"
+#else
+ "LR 1,%1\n\t"
+#endif
+ "RCHP\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "r" (chpid)
+ : "cc", "1" );
+ return ccode;
+}
+
+typedef struct {
+ __u16 vrdcdvno : 16; /* device number (input) */
+ __u16 vrdclen : 16; /* data block length (input) */
+ __u32 vrdcvcla : 8; /* virtual device class (output) */
+ __u32 vrdcvtyp : 8; /* virtual device type (output) */
+ __u32 vrdcvsta : 8; /* virtual device status (output) */
+ __u32 vrdcvfla : 8; /* virtual device flags (output) */
+ __u32 vrdcrccl : 8; /* real device class (output) */
+ __u32 vrdccrty : 8; /* real device type (output) */
+ __u32 vrdccrmd : 8; /* real device model (output) */
+ __u32 vrdccrft : 8; /* real device feature (output) */
+ } __attribute__ ((packed,aligned(4))) diag210_t;
+
+void VM_virtual_device_info( __u16 devno, /* device number */
+ senseid_t *ps ); /* ptr to senseID data */
+
+extern __inline__ int diag210( diag210_t * addr)
+{
+ int ccode;
+
+ __asm__ __volatile__(
+#ifdef CONFIG_ARCH_S390X
+ "SAM31\n\t"
+ "DIAG %1,0,0x210\n\t"
+ "SAM64\n\t"
+#else
+ "LR 1,%1\n\t"
+ ".long 0x83110210\n\t"
+#endif
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "a" (addr)
+ : "cc" );
+ return ccode;
+}
+
+/*
+ * Various low-level irq details needed by irq.c, process.c,
+ * time.c, io_apic.c and smp.c
+ *
+ * Interrupt entry/exit code at both C and assembly level
+ */
+
+void mask_irq(unsigned int irq);
+void unmask_irq(unsigned int irq);
+
+#define MAX_IRQ_SOURCES 128
+
+extern spinlock_t irq_controller_lock;
+
+#ifdef CONFIG_SMP
+
+#include <asm/atomic.h>
+
+static inline void irq_enter(int cpu, unsigned int irq)
+{
+ hardirq_enter(cpu);
+#ifdef CONFIG_ARCH_S390X
+ while (atomic_read(&global_irq_lock) != 0) {
+ eieio();
+ }
+#else
+ while (test_bit(0,&global_irq_lock)) {
+ eieio();
+ }
+#endif
+}
+
+static inline void irq_exit(int cpu, unsigned int irq)
+{
+ hardirq_exit(cpu);
+ release_irqlock(cpu);
+}
+
+
+#else
+
+#define irq_enter(cpu, irq) (++local_irq_count(cpu))
+#define irq_exit(cpu, irq) (--local_irq_count(cpu))
+
+#endif
+
+#define __STR(x) #x
+#define STR(x) __STR(x)
+
+#ifdef CONFIG_SMP
+
+/*
+ * SMP has a few special interrupts for IPI messages
+ */
+
+#endif /* CONFIG_SMP */
+
+/*
+ * x86 profiling function, SMP safe. We might want to do this in
+ * assembly totally?
+ */
+extern char _stext;
+static inline void s390_do_profile (unsigned long addr)
+{
+ if (prof_buffer && current->pid) {
+#ifndef CONFIG_ARCH_S390X
+ addr &= 0x7fffffff;
+#endif
+ addr -= (unsigned long) &_stext;
+ addr >>= prof_shift;
+ /*
+ * Don't ignore out-of-bounds EIP values silently,
+ * put them into the last histogram slot, so if
+ * present, they will show up as a sharp peak.
+ */
+ if (addr > prof_len-1)
+ addr = prof_len-1;
+ atomic_inc((atomic_t *)&prof_buffer[addr]);
+ }
+}
+
+#include <asm/s390io.h>
+
+#define s390irq_spin_lock(irq) \
+ spin_lock(&(ioinfo[irq]->irq_lock))
+
+#define s390irq_spin_unlock(irq) \
+ spin_unlock(&(ioinfo[irq]->irq_lock))
+
+#define s390irq_spin_lock_irqsave(irq,flags) \
+ spin_lock_irqsave(&(ioinfo[irq]->irq_lock), flags)
+#define s390irq_spin_unlock_irqrestore(irq,flags) \
+ spin_unlock_irqrestore(&(ioinfo[irq]->irq_lock), flags)
+#endif /* __KERNEL__ */
+#endif
+
diff --git a/include/asm-s390x/irqextras390.h b/include/asm-s390x/irqextras390.h
new file mode 100644
index 000000000..70bac7f44
--- /dev/null
+++ b/include/asm-s390x/irqextras390.h
@@ -0,0 +1,151 @@
+/*
+ * include/asm-s390/irqextras390.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ */
+
+#ifndef __irqextras390_h
+#define __irqextras390_h
+
+/*
+ irqextras390.h by D.J. Barrow
+ if you are a bitfield fan & are paranoid that ansi dosen't
+ give hard definitions about the size of an int or long you might
+ prefer these definitions as an alternative.
+
+*/
+
+#include <linux/types.h>
+
+typedef struct
+{
+ unsigned key:4;
+ unsigned s:1;
+ unsigned l:1;
+ unsigned cc:2;
+ unsigned f:1;
+ unsigned p:1;
+ unsigned i:1;
+ unsigned a:1;
+ unsigned u:1;
+ unsigned z:1;
+ unsigned e:1;
+ unsigned n:1;
+ unsigned zero:1;
+
+ unsigned fc_start:1;
+ unsigned fc_halt:1;
+ unsigned fc_clear:1;
+
+ unsigned ac_resume_pending:1;
+ unsigned ac_start_pending:1;
+ unsigned ac_halt_pending:1;
+ unsigned ac_clear_pending:1;
+ unsigned ac_subchannel_active:1;
+ unsigned ac_device_active:1;
+ unsigned ac_suspended:1;
+
+ unsigned sc_alert:1;
+ unsigned sc_intermediate:1;
+ unsigned sc_primary:1;
+ unsigned sc_seconary:1;
+ unsigned sc_status_pending:1;
+
+ __u32 ccw_address;
+
+ unsigned dev_status_attention:1;
+ unsigned dev_status_modifier:1;
+ unsigned dev_status_control_unit_end:1;
+ unsigned dev_status_busy:1;
+ unsigned dev_status_channel_end:1;
+ unsigned dev_status_device_end:1;
+ unsigned dev_status_unit_check:1;
+ unsigned dev_status_unit_exception:1;
+
+ unsigned sch_status_program_cont_int:1;
+ unsigned sch_status_incorrect_length:1;
+ unsigned sch_status_program_check:1;
+ unsigned sch_status_protection_check:1;
+ unsigned sch_status_channel_data_check:1;
+ unsigned sch_status_channel_control_check:1;
+ unsigned sch_status_interface_control_check:1;
+ unsigned sch_status_chaining_check:1;
+
+ __u16 byte_count;
+} scsw_bits_t __attribute__((packed));
+
+typedef struct
+{
+ __u32 flags;
+ __u32 ccw_address;
+ __u8 dev_status;
+ __u8 sch_status;
+ __u16 byte_count;
+} scsw_words_t __attribute__((packed));
+
+typedef struct
+{
+ __u8 cmd_code;
+
+ unsigned cd:1;
+ unsigned cc:1;
+ unsigned sli:1;
+ unsigned skip:1;
+ unsigned pci:1;
+ unsigned ida:1;
+ unsigned s:1;
+ unsigned res1:1;
+
+ __u16 count;
+
+ __u32 ccw_data_address;
+} ccw1_bits_t __attribute__((packed,aligned(8)));
+
+typedef struct
+{
+ __u32 interruption_parm;
+ unsigned key:4;
+ unsigned s:1;
+ unsigned res1:3;
+ unsigned f:1;
+ unsigned p:1;
+ unsigned i:1;
+ unsigned a:1;
+ unsigned u:1;
+ __u8 lpm;
+ unsigned l:1;
+ unsigned res2:7;
+ ccw1_bits_t *ccw_program_address;
+} orb_bits_t __attribute__((packed));
+
+void fixchannelprogram(orb_bits_t *orbptr);
+void fixccws(ccw1_bits_t *ccwptr);
+enum
+{
+ ccw_write=0x1,
+ ccw_read=0x2,
+ ccw_read_backward=0xc,
+ ccw_control=0x3,
+ ccw_sense=0x4,
+ ccw_sense_id=0xe4,
+ ccw_transfer_in_channel0=0x8,
+ ccw_transfer_in_channel1=0x8,
+ ccw_set_x_mode=0xc3, // according to uli's lan notes
+ ccw_nop=0x3 // according to uli's notes again
+ // n.b. ccw_control clashes with this
+ // so I presume its a special case of
+ // control
+};
+
+
+
+#endif
+
+
+
+
+
+
+
diff --git a/include/asm-s390x/lowcore.h b/include/asm-s390x/lowcore.h
new file mode 100644
index 000000000..215b8b8e0
--- /dev/null
+++ b/include/asm-s390x/lowcore.h
@@ -0,0 +1,196 @@
+/*
+ * include/asm-s390/lowcore.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Hartmut Penner (hpenner@de.ibm.com),
+ * Martin Schwidefsky (schwidefsky@de.ibm.com),
+ * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ */
+
+#ifndef _ASM_S390_LOWCORE_H
+#define _ASM_S390_LOWCORE_H
+
+#define __LC_EXT_OLD_PSW 0x0130
+#define __LC_SVC_OLD_PSW 0x0140
+#define __LC_PGM_OLD_PSW 0x0150
+#define __LC_MCK_OLD_PSW 0x0160
+#define __LC_IO_OLD_PSW 0x0170
+#define __LC_EXT_NEW_PSW 0x01b0
+#define __LC_SVC_NEW_PSW 0x01c0
+#define __LC_PGM_NEW_PSW 0x01d0
+#define __LC_MCK_NEW_PSW 0x01e0
+#define __LC_IO_NEW_PSW 0x01f0
+#define __LC_RETURN_PSW 0x0200
+#define __LC_SYNC_IO_WORD 0x0210
+#define __LC_EXT_PARAMS 0x080
+#define __LC_CPU_ADDRESS 0x084
+#define __LC_EXT_INT_CODE 0x086
+#define __LC_SVC_ILC 0x088
+#define __LC_SVC_INT_CODE 0x08A
+#define __LC_PGM_ILC 0x08C
+#define __LC_PGM_INT_CODE 0x08E
+#define __LC_TRANS_EXC_ADDR 0x0a8
+#define __LC_SUBCHANNEL_ID 0x0B8
+#define __LC_SUBCHANNEL_NR 0x0BA
+#define __LC_IO_INT_PARM 0x0BC
+#define __LC_IO_INT_WORD 0x0C0
+#define __LC_MCCK_CODE 0x0E8
+
+#define __LC_SAVE_AREA 0xC00
+#define __LC_CREGS_SAVE_AREA 0xC80
+#define __LC_AREGS_SAVE_AREA 0xD00
+#define __LC_KERNEL_STACK 0xD40
+#define __LC_KERNEL_LEVEL 0xD48
+#define __LC_IRQ_STAT 0xD50
+#define __LC_CPUID 0xD90
+#define __LC_CPUADDR 0xD98
+#define __LC_IPLDEV 0xDB8
+
+#define __LC_PANIC_MAGIC 0xE00
+
+
+/* interrupt handler start with all io, external and mcck interrupt disabled */
+
+#define _RESTART_PSW_MASK 0x0000000180000000
+#define _EXT_PSW_MASK 0x0400000180000000
+#define _PGM_PSW_MASK 0x0400000180000000
+#define _SVC_PSW_MASK 0x0400000180000000
+#define _MCCK_PSW_MASK 0x0400000180000000
+#define _IO_PSW_MASK 0x0400000180000000
+#define _USER_PSW_MASK 0x0701C00180000000
+#define _WAIT_PSW_MASK 0x0706000180000000
+#define _DW_PSW_MASK 0x0002000180000000
+
+#define _PRIMARY_MASK 0x0000 /* MASK for SACF */
+#define _SECONDARY_MASK 0x0100 /* MASK for SACF */
+#define _ACCESS_MASK 0x0200 /* MASK for SACF */
+#define _HOME_MASK 0x0300 /* MASK for SACF */
+
+#define _PSW_PRIM_SPACE_MODE 0x0000000000000000
+#define _PSW_SEC_SPACE_MODE 0x0000800000000000
+#define _PSW_ACC_REG_MODE 0x0000400000000000
+#define _PSW_HOME_SPACE_MODE 0x0000C00000000000
+
+#define _PSW_WAIT_MASK_BIT 0x0002000000000000
+#define _PSW_IO_MASK_BIT 0x0200000000000000
+#define _PSW_IO_WAIT 0x0202000000000000
+
+#ifndef __ASSEMBLY__
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <linux/types.h>
+#include <asm/atomic.h>
+#include <asm/sigp.h>
+
+
+struct _lowcore
+{
+ /* prefix area: defined by architecture */
+ __u32 ccw1[2]; /* 0x000 */
+ __u32 ccw2[4]; /* 0x008 */
+ __u8 pad1[0x80-0x18]; /* 0x018 */
+ __u32 ext_params; /* 0x080 */
+ __u16 cpu_addr; /* 0x084 */
+ __u16 ext_int_code; /* 0x086 */
+ __u16 svc_ilc; /* 0x088 */
+ __u16 scv_code; /* 0x08a */
+ __u16 pgm_ilc; /* 0x08c */
+ __u16 pgm_code; /* 0x08e */
+ __u32 data_exc_code; /* 0x090 */
+ __u16 mon_class_num; /* 0x094 */
+ __u16 per_perc_atmid; /* 0x096 */
+ addr_t per_address; /* 0x098 */
+ __u8 exc_access_id; /* 0x0a0 */
+ __u8 per_access_id; /* 0x0a1 */
+ __u8 op_access_id; /* 0x0a2 */
+ __u8 ar_access_id; /* 0x0a3 */
+ __u8 pad2[0xA8-0xA4]; /* 0x0a4 */
+ addr_t trans_exc_code; /* 0x0A0 */
+ addr_t monitor_code; /* 0x09c */
+ __u16 subchannel_id; /* 0x0b8 */
+ __u16 subchannel_nr; /* 0x0ba */
+ __u32 io_int_parm; /* 0x0bc */
+ __u32 io_int_word; /* 0x0c0 */
+ __u8 pad3[0xc8-0xc4]; /* 0x0c4 */
+ __u32 stfl_fac_list; /* 0x0c8 */
+ __u8 pad4[0xe8-0xcc]; /* 0x0cc */
+ __u32 mcck_interuption_code[2]; /* 0x0e8 */
+ __u8 pad5[0xf4-0xf0]; /* 0x0f0 */
+ __u32 external_damage_code; /* 0x0f4 */
+ addr_t failing_storage_address; /* 0x0f8 */
+ __u8 pad6[0x120-0x100]; /* 0x100 */
+ psw_t restart_old_psw; /* 0x120 */
+ psw_t external_old_psw; /* 0x130 */
+ psw_t svc_old_psw; /* 0x140 */
+ psw_t program_old_psw; /* 0x150 */
+ psw_t mcck_old_psw; /* 0x160 */
+ psw_t io_old_psw; /* 0x170 */
+ __u8 pad7[0x1a0-0x180]; /* 0x180 */
+ psw_t restart_psw; /* 0x1a0 */
+ psw_t external_new_psw; /* 0x1b0 */
+ psw_t svc_new_psw; /* 0x1c0 */
+ psw_t program_new_psw; /* 0x1d0 */
+ psw_t mcck_new_psw; /* 0x1e0 */
+ psw_t io_new_psw; /* 0x1f0 */
+ psw_t return_psw; /* 0x200 */
+ __u32 sync_io_word; /* 0x210 */
+ __u8 pad8[0xc00-0x214]; /* 0x214 */
+ /* System info area */
+ __u64 save_area[16]; /* 0xc00 */
+ __u64 cregs_save_area[16]; /* 0xc80 */
+ __u32 access_regs_save_area[16];/* 0xd00 */
+ __u64 kernel_stack; /* 0xd40 */
+ __u64 kernel_level; /* 0xd48 */
+ /* entry.S sensitive area start */
+ /* Next 6 words are the s390 equivalent of irq_stat */
+ __u32 __softirq_active; /* 0xd50 */
+ __u32 __softirq_mask; /* 0xd54 */
+ __u32 __local_irq_count; /* 0xd58 */
+ __u32 __local_bh_count; /* 0xd5c */
+ __u32 __syscall_count; /* 0xd60 */
+ __u8 pad10[0xd80-0xd64]; /* 0xd64 */
+ struct cpuinfo_S390 cpu_data; /* 0xd80 */
+ __u32 ipl_device; /* 0xdb8 */
+ __u32 pad13; /* 0xdbc was lsw word of ipl_device until a bug was found DJB */
+ /* entry.S sensitive area end */
+
+ /* SMP info area: defined by DJB */
+ __u64 jiffy_timer_cc; /* 0xdc0 */
+ __u64 ext_call_fast; /* 0xdc8 */
+ __u64 ext_call_queue; /* 0xdd0 */
+ __u64 ext_call_count; /* 0xdd8 */
+
+ __u8 pad11[0xe00-0xde0]; /* 0xde0 */
+
+ /* 0xe00 is used as indicator for dump tools */
+ /* whether the kernel died with panic() or not */
+ __u32 panic_magic; /* 0xe00 */
+
+ /* Align to the top 1k of prefix area */
+ __u8 pad12[0x1000-0xe04]; /* 0xe04 */
+} __attribute__((packed)); /* End structure*/
+
+extern __inline__ void set_prefix(__u32 address)
+{
+ __asm__ __volatile__ ("spx %0" : : "m" (address) : "memory" );
+}
+
+#define S390_lowcore (*((struct _lowcore *) 0))
+extern struct _lowcore *lowcore_ptr[];
+
+#ifndef CONFIG_SMP
+#define get_cpu_lowcore(cpu) S390_lowcore
+#define safe_get_cpu_lowcore(cpu) S390_lowcore
+#else
+#define get_cpu_lowcore(cpu) (*lowcore_ptr[cpu])
+#define safe_get_cpu_lowcore(cpu) \
+ ((cpu)==smp_processor_id() ? S390_lowcore:(*lowcore_ptr[(cpu)]))
+#endif
+#endif /* __ASSEMBLY__ */
+
+#define __PANIC_MAGIC 0xDEADC0DE
+
+#endif
+
diff --git a/include/asm-s390x/major.h b/include/asm-s390x/major.h
new file mode 100644
index 000000000..f07022803
--- /dev/null
+++ b/include/asm-s390x/major.h
@@ -0,0 +1,150 @@
+#ifndef _LINUX_MAJOR_H
+#define _LINUX_MAJOR_H
+
+/*
+ * This file has definitions for major device numbers.
+ * For the device number assignments, see Documentation/devices.txt.
+ */
+
+/* limits */
+
+/*
+ * Important: Don't change this to 256. Major number 255 is and must be
+ * reserved for future expansion into a larger dev_t space.
+ */
+#define MAX_CHRDEV 255
+#define MAX_BLKDEV 255
+
+#define UNNAMED_MAJOR 0
+#define MEM_MAJOR 1
+#define RAMDISK_MAJOR 1
+#define FLOPPY_MAJOR 2
+#define PTY_MASTER_MAJOR 2
+#define IDE0_MAJOR 3
+#define PTY_SLAVE_MAJOR 3
+#define HD_MAJOR IDE0_MAJOR
+#define TTY_MAJOR 4
+#define TTYAUX_MAJOR 5
+#define LP_MAJOR 6
+#define VCS_MAJOR 7
+#define LOOP_MAJOR 7
+#define SCSI_DISK0_MAJOR 8
+#define SCSI_TAPE_MAJOR 9
+#define MD_MAJOR 9
+#define MISC_MAJOR 10
+#define SCSI_CDROM_MAJOR 11
+#define QIC02_TAPE_MAJOR 12
+#define XT_DISK_MAJOR 13
+#define SOUND_MAJOR 14
+#define CDU31A_CDROM_MAJOR 15
+#define JOYSTICK_MAJOR 15
+#define GOLDSTAR_CDROM_MAJOR 16
+#define OPTICS_CDROM_MAJOR 17
+#define SANYO_CDROM_MAJOR 18
+#define CYCLADES_MAJOR 19
+#define CYCLADESAUX_MAJOR 20
+#define MITSUMI_X_CDROM_MAJOR 20
+#define MFM_ACORN_MAJOR 21 /* ARM Linux /dev/mfm */
+#define SCSI_GENERIC_MAJOR 21
+#define Z8530_MAJOR 34
+#define DIGI_MAJOR 23
+#define IDE1_MAJOR 22
+#define DIGICU_MAJOR 22
+#define MITSUMI_CDROM_MAJOR 23
+#define CDU535_CDROM_MAJOR 24
+#define STL_SERIALMAJOR 24
+#define MATSUSHITA_CDROM_MAJOR 25
+#define STL_CALLOUTMAJOR 25
+#define MATSUSHITA_CDROM2_MAJOR 26
+#define QIC117_TAPE_MAJOR 27
+#define MATSUSHITA_CDROM3_MAJOR 27
+#define MATSUSHITA_CDROM4_MAJOR 28
+#define STL_SIOMEMMAJOR 28
+#define ACSI_MAJOR 28
+#define AZTECH_CDROM_MAJOR 29
+#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */
+#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */
+#define CM206_CDROM_MAJOR 32
+#define IDE2_MAJOR 33
+#define IDE3_MAJOR 34
+#define NETLINK_MAJOR 36
+#define PS2ESDI_MAJOR 36
+#define IDETAPE_MAJOR 37
+#define Z2RAM_MAJOR 37
+#define APBLOCK_MAJOR 38 /* AP1000 Block device */
+#define DDV_MAJOR 39 /* AP1000 DDV block device */
+#define NBD_MAJOR 43 /* Network block device */
+#define RISCOM8_NORMAL_MAJOR 48
+#define DAC960_MAJOR 48 /* 48..55 */
+#define RISCOM8_CALLOUT_MAJOR 49
+#define MKISS_MAJOR 55
+#define DSP56K_MAJOR 55 /* DSP56001 processor device */
+
+#define IDE4_MAJOR 56
+#define IDE5_MAJOR 57
+
+#define SCSI_DISK1_MAJOR 65
+#define SCSI_DISK2_MAJOR 66
+#define SCSI_DISK3_MAJOR 67
+#define SCSI_DISK4_MAJOR 68
+#define SCSI_DISK5_MAJOR 69
+#define SCSI_DISK6_MAJOR 70
+#define SCSI_DISK7_MAJOR 71
+
+
+#define LVM_BLK_MAJOR 58 /* Logical Volume Manager */
+
+#define COMPAQ_SMART2_MAJOR 72
+#define COMPAQ_SMART2_MAJOR1 73
+#define COMPAQ_SMART2_MAJOR2 74
+#define COMPAQ_SMART2_MAJOR3 75
+#define COMPAQ_SMART2_MAJOR4 76
+#define COMPAQ_SMART2_MAJOR5 77
+#define COMPAQ_SMART2_MAJOR6 78
+#define COMPAQ_SMART2_MAJOR7 79
+
+#define SPECIALIX_NORMAL_MAJOR 75
+#define SPECIALIX_CALLOUT_MAJOR 76
+
+#define DASD_MAJOR 94
+
+#define LVM_CHAR_MAJOR 109 /* Logical Volume Manager */
+
+#define MDISK_MAJOR 64
+
+#define I2O_MAJOR 80 /* 80->87 */
+
+#define IDE6_MAJOR 88
+#define IDE7_MAJOR 89
+#define IDE8_MAJOR 90
+#define IDE9_MAJOR 91
+
+#define AURORA_MAJOR 79
+
+#define RTF_MAJOR 150
+#define RAW_MAJOR 162
+
+#define USB_ACM_MAJOR 166
+#define USB_ACM_AUX_MAJOR 167
+#define USB_CHAR_MAJOR 180
+
+#define UNIX98_PTY_MASTER_MAJOR 128
+#define UNIX98_PTY_MAJOR_COUNT 8
+#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT)
+
+/*
+ * Tests for SCSI devices.
+ */
+
+#define SCSI_DISK_MAJOR(M) ((M) == SCSI_DISK0_MAJOR || \
+ ((M) >= SCSI_DISK1_MAJOR && (M) <= SCSI_DISK7_MAJOR))
+
+#define SCSI_BLK_MAJOR(M) \
+ (SCSI_DISK_MAJOR(M) \
+ || (M) == SCSI_CDROM_MAJOR)
+
+static __inline__ int scsi_blk_major(int m) {
+ return SCSI_BLK_MAJOR(m);
+}
+
+#endif
diff --git a/include/asm-s390x/mathemu.h b/include/asm-s390x/mathemu.h
new file mode 100644
index 000000000..c78d97b43
--- /dev/null
+++ b/include/asm-s390x/mathemu.h
@@ -0,0 +1,48 @@
+/*
+ * arch/s390/kernel/mathemu.h
+ * IEEE floating point emulation.
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ */
+
+#ifndef __MATHEMU__
+#define __MATHEMU__
+
+extern int math_emu_b3(__u8 *, struct pt_regs *);
+extern int math_emu_ed(__u8 *, struct pt_regs *);
+extern void math_emu_ldr(__u8 *);
+extern void math_emu_ler(__u8 *);
+extern void math_emu_std(__u8 *, struct pt_regs *);
+extern void math_emu_ld(__u8 *, struct pt_regs *);
+extern void math_emu_ste(__u8 *, struct pt_regs *);
+extern void math_emu_le(__u8 *, struct pt_regs *);
+extern int math_emu_lfpc(__u8 *, struct pt_regs *);
+extern int math_emu_stfpc(__u8 *, struct pt_regs *);
+extern int math_emu_srnm(__u8 *, struct pt_regs *);
+
+
+extern __u64 __adddf3(__u64,__u64);
+extern __u64 __subdf3(__u64,__u64);
+extern __u64 __muldf3(__u64,__u64);
+extern __u64 __divdf3(__u64,__u64);
+extern long __cmpdf2(__u64,__u64);
+extern __u64 __negdf2(__u64);
+extern __u64 __absdf2(__u64);
+extern __u32 __addsf3(__u32,__u32);
+extern __u32 __subsf3(__u32,__u32);
+extern __u32 __mulsf3(__u32,__u32);
+extern __u32 __divsf3(__u32,__u32);
+extern __u32 __negsf2(__u32);
+extern __u32 __abssf2(__u32);
+extern long __cmpsf2(__u32,__u32);
+extern __u32 __truncdfsf2(__u64);
+extern __u32 __fixsfsi(__u32);
+extern __u32 __fixdfsi(__u64);
+extern __u64 __floatsidf(__u32);
+extern __u32 __floatsisf(__u32);
+extern __u64 __extendsfdf2(__u32);
+
+#endif /* __MATHEMU__ */
+
diff --git a/include/asm-s390x/misc390.h b/include/asm-s390x/misc390.h
new file mode 100644
index 000000000..3a48a7385
--- /dev/null
+++ b/include/asm-s390x/misc390.h
@@ -0,0 +1,15 @@
+/*
+ * include/asm-s390/misc390.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ */
+
+#define allocaligned2(type,name,number,align) \
+ __u8 name##buff[(sizeof(type)*(number+1))-1]; \
+ type *name=(type *)(((__u32)(&name##buff[align-1]))&(-align))
+
+#define allocaligned(type,name,number) allocaligned2(type,name,number,__alignof__(type))
+
+extern void s390_daemonize(char *name,unsigned long mask,int use_init_fs);
diff --git a/include/asm-s390x/mman.h b/include/asm-s390x/mman.h
new file mode 100644
index 000000000..8fbe65fd5
--- /dev/null
+++ b/include/asm-s390x/mman.h
@@ -0,0 +1,46 @@
+/*
+ * include/asm-s390/mman.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/mman.h"
+ */
+
+#ifndef __S390_MMAN_H__
+#define __S390_MMAN_H__
+
+#define PROT_READ 0x1 /* page can be read */
+#define PROT_WRITE 0x2 /* page can be written */
+#define PROT_EXEC 0x4 /* page can be executed */
+#define PROT_NONE 0x0 /* page can not be accessed */
+
+#define MAP_SHARED 0x01 /* Share changes */
+#define MAP_PRIVATE 0x02 /* Changes are private */
+#define MAP_TYPE 0x0f /* Mask for type of mapping */
+#define MAP_FIXED 0x10 /* Interpret addr exactly */
+#define MAP_ANONYMOUS 0x20 /* don't use a file */
+
+#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
+#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
+#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
+#define MAP_LOCKED 0x2000 /* pages are locked */
+#define MAP_NORESERVE 0x4000 /* don't check for reservations */
+
+#define MS_ASYNC 1 /* sync memory asynchronously */
+#define MS_INVALIDATE 2 /* invalidate the caches */
+#define MS_SYNC 4 /* synchronous memory sync */
+
+#define MCL_CURRENT 1 /* lock all current mappings */
+#define MCL_FUTURE 2 /* lock all future mappings */
+
+#define MADV_NORMAL 0x0 /* default page-in behavior */
+#define MADV_RANDOM 0x1 /* page-in minimum required */
+#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
+#define MADV_WILLNEED 0x3 /* pre-fault pages */
+#define MADV_DONTNEED 0x4 /* discard these pages */
+
+/* compatibility flags */
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FILE 0
+
+#endif /* __S390_MMAN_H__ */
diff --git a/include/asm-s390x/mmu.h b/include/asm-s390x/mmu.h
new file mode 100644
index 000000000..ccd36d266
--- /dev/null
+++ b/include/asm-s390x/mmu.h
@@ -0,0 +1,7 @@
+#ifndef __MMU_H
+#define __MMU_H
+
+/* Default "unsigned long" context */
+typedef unsigned long mm_context_t;
+
+#endif
diff --git a/include/asm-s390x/mmu_context.h b/include/asm-s390x/mmu_context.h
new file mode 100644
index 000000000..2af3f46da
--- /dev/null
+++ b/include/asm-s390x/mmu_context.h
@@ -0,0 +1,45 @@
+/*
+ * include/asm-s390/mmu_context.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/mmu_context.h"
+ */
+
+#ifndef __S390_MMU_CONTEXT_H
+#define __S390_MMU_CONTEXT_H
+
+/*
+ * get a new mmu context.. S390 don't know about contexts.
+ */
+#define init_new_context(tsk,mm) 0
+
+#define destroy_context(mm) flush_tlb_mm(mm)
+
+static inline void enter_lazy_tlb(struct mm_struct *mm,
+ struct task_struct *tsk, unsigned cpu)
+{
+}
+
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
+ struct task_struct *tsk, unsigned cpu)
+{
+ unsigned long pgd;
+
+ if (prev != next) {
+ pgd = (__pa(next->pgd)&PAGE_MASK) | (_REGION_TABLE|USER_STD_MASK);
+ /* Load page tables */
+ asm volatile(" lctlg 7,7,%0\n" /* secondary space */
+ " lctlg 13,13,%0\n" /* home space */
+ : : "m" (pgd) );
+ }
+ set_bit(cpu, &next->cpu_vm_mask);
+}
+
+extern inline void activate_mm(struct mm_struct *prev,
+ struct mm_struct *next)
+{
+ switch_mm(prev, next, current, smp_processor_id());
+}
+
+#endif
diff --git a/include/asm-s390x/module.h b/include/asm-s390x/module.h
new file mode 100644
index 000000000..173869666
--- /dev/null
+++ b/include/asm-s390x/module.h
@@ -0,0 +1,11 @@
+#ifndef _ASM_S390_MODULE_H
+#define _ASM_S390_MODULE_H
+/*
+ * This file contains the s390 architecture specific module code.
+ */
+
+#define module_map(x) vmalloc(x)
+#define module_unmap(x) vfree(x)
+#define module_arch_init(x) (0)
+
+#endif /* _ASM_S390_MODULE_H */
diff --git a/include/asm-s390x/msgbuf.h b/include/asm-s390x/msgbuf.h
new file mode 100644
index 000000000..a131dec56
--- /dev/null
+++ b/include/asm-s390x/msgbuf.h
@@ -0,0 +1,27 @@
+#ifndef _S390_MSGBUF_H
+#define _S390_MSGBUF_H
+
+/*
+ * The msqid64_ds structure for S/390 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 64-bit values
+ */
+
+struct msqid64_ds {
+ struct ipc64_perm msg_perm;
+ __kernel_time_t msg_stime; /* last msgsnd time */
+ __kernel_time_t msg_rtime; /* last msgrcv time */
+ __kernel_time_t msg_ctime; /* last change time */
+ unsigned long msg_cbytes; /* current number of bytes on queue */
+ unsigned long msg_qnum; /* number of messages in queue */
+ unsigned long msg_qbytes; /* max number of bytes on queue */
+ __kernel_pid_t msg_lspid; /* pid of last msgsnd */
+ __kernel_pid_t msg_lrpid; /* last receive pid */
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif /* _S390_MSGBUF_H */
diff --git a/include/asm-s390x/namei.h b/include/asm-s390x/namei.h
new file mode 100644
index 000000000..3e286bdde
--- /dev/null
+++ b/include/asm-s390x/namei.h
@@ -0,0 +1,21 @@
+/*
+ * include/asm-s390/namei.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/namei.h"
+ *
+ * Included from linux/fs/namei.c
+ */
+
+#ifndef __S390_NAMEI_H
+#define __S390_NAMEI_H
+
+/* This dummy routine maybe changed to something useful
+ * for /usr/gnemul/ emulation stuff.
+ * Look at asm-sparc/namei.h for details.
+ */
+
+#define __emul_prefix() NULL
+
+#endif /* __S390_NAMEI_H */
diff --git a/include/asm-s390x/page.h b/include/asm-s390x/page.h
new file mode 100644
index 000000000..9a41c8261
--- /dev/null
+++ b/include/asm-s390x/page.h
@@ -0,0 +1,94 @@
+/*
+ * include/asm-s390/page.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Hartmut Penner (hpenner@de.ibm.com)
+ */
+
+#ifndef _S390_PAGE_H
+#define _S390_PAGE_H
+
+/* PAGE_SHIFT determines the page size */
+#define PAGE_SHIFT 12
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+#ifdef __KERNEL__
+#ifndef __ASSEMBLY__
+
+/*
+ * gcc uses builtin, i.e. MVCLE for both operations
+ */
+
+#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
+#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
+
+#define clear_user_page(page, vaddr) clear_page(page)
+#define copy_user_page(to, from, vaddr) copy_page(to, from)
+
+#define BUG() do { \
+ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
+ __asm__ __volatile__(".long 0"); \
+} while (0)
+
+#define PAGE_BUG(page) do { \
+ BUG(); \
+} while (0)
+
+/* Pure 2^n version of get_order */
+extern __inline__ int get_order(unsigned long size)
+{
+ int order;
+
+ size = (size-1) >> (PAGE_SHIFT-1);
+ order = -1;
+ do {
+ size >>= 1;
+ order++;
+ } while (size);
+ return order;
+}
+
+/*
+ * These are used to make use of C type-checking..
+ */
+typedef struct { unsigned long pte; } pte_t;
+typedef struct {
+ unsigned long pmd0;
+ unsigned long pmd1;
+ } pmd_t;
+typedef struct { unsigned long pgd; } pgd_t;
+typedef struct { unsigned long pgprot; } pgprot_t;
+
+#define pte_val(x) ((x).pte)
+#define pmd_val(x) ((x).pmd0)
+#define pmd_val1(x) ((x).pmd1)
+#define pgd_val(x) ((x).pgd)
+#define pgprot_val(x) ((x).pgprot)
+
+#define __pte(x) ((pte_t) { (x) } )
+#define __pmd(x) ((pmd_t) { (x) } )
+#define __pgd(x) ((pgd_t) { (x) } )
+#define __pgprot(x) ((pgprot_t) { (x) } )
+
+#endif /* !__ASSEMBLY__ */
+
+/* to align the pointer to the (next) page boundary */
+#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
+
+/*
+ *
+ *
+ */
+
+#define __PAGE_OFFSET 0x0UL
+#define PAGE_OFFSET 0x0UL
+#define __pa(x) (unsigned long)(x)
+#define __va(x) (void *)(x)
+#define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
+#define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
+
+#endif /* __KERNEL__ */
+
+#endif /* _S390_PAGE_H */
diff --git a/include/asm-s390x/param.h b/include/asm-s390x/param.h
new file mode 100644
index 000000000..fc5aec78c
--- /dev/null
+++ b/include/asm-s390x/param.h
@@ -0,0 +1,32 @@
+/*
+ * include/asm-s390/param.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/param.h"
+ */
+
+#ifndef _ASMS390_PARAM_H
+#define _ASMS390_PARAM_H
+
+#ifndef HZ
+#define HZ 100
+#endif
+
+#define EXEC_PAGESIZE 4096
+
+#ifndef NGROUPS
+#define NGROUPS 32
+#endif
+
+#ifndef NOGROUP
+#define NOGROUP (-1)
+#endif
+
+#define MAXHOSTNAMELEN 64 /* max length of hostname */
+
+#ifdef __KERNEL__
+# define CLOCKS_PER_SEC HZ /* frequency at which times() counts */
+#endif
+
+#endif
diff --git a/include/asm-s390x/pgalloc.h b/include/asm-s390x/pgalloc.h
new file mode 100644
index 000000000..adcaa1467
--- /dev/null
+++ b/include/asm-s390x/pgalloc.h
@@ -0,0 +1,315 @@
+/*
+ * include/asm-s390/pgalloc.h
+ *
+ * S390 version
+ * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Hartmut Penner (hpenner@de.ibm.com)
+ * Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/pgalloc.h"
+ * Copyright (C) 1994 Linus Torvalds
+ */
+
+#ifndef _S390_PGALLOC_H
+#define _S390_PGALLOC_H
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <linux/threads.h>
+
+#define pgd_quicklist (S390_lowcore.cpu_data.pgd_quick)
+#define pmd_quicklist (S390_lowcore.cpu_data.pmd_quick)
+#define pte_quicklist (S390_lowcore.cpu_data.pte_quick)
+#define pgtable_cache_size (S390_lowcore.cpu_data.pgtable_cache_sz)
+
+/*
+ * Allocate and free page tables. The xxx_kernel() versions are
+ * used to allocate a kernel page table - this turns on ASN bits
+ * if any.
+ */
+
+/*
+ * page directory allocation/free routines.
+ */
+extern __inline__ pgd_t *get_pgd_slow (void)
+{
+ int i;
+ pgd_t *ret = (pgd_t *)__get_free_pages(GFP_KERNEL,2);
+ if (ret)
+ for (i = 0; i < PTRS_PER_PGD; i++)
+ pgd_clear(ret + i);
+ return ret;
+}
+
+extern __inline__ pgd_t *get_pgd_fast (void)
+{
+ unsigned long *ret = pgd_quicklist;
+
+ if (ret != NULL) {
+ pgd_quicklist = (unsigned long *)(*ret);
+ ret[0] = ret[1];
+ pgtable_cache_size -= 4;
+ }
+ return (pgd_t *) ret;
+}
+
+extern __inline__ pgd_t *pgd_alloc (void)
+{
+ pgd_t *pgd;
+
+ pgd = get_pgd_fast();
+ if (!pgd)
+ pgd = get_pgd_slow();
+ return pgd;
+}
+
+extern __inline__ void free_pgd_fast (pgd_t *pgd)
+{
+ *(unsigned long *) pgd = (unsigned long) pgd_quicklist;
+ pgd_quicklist = (unsigned long *) pgd;
+ pgtable_cache_size += 4;
+}
+
+extern __inline__ void free_pgd_slow (pgd_t *pgd)
+{
+ free_pages((unsigned long) pgd, 2);
+}
+
+#define pgd_free(pgd) free_pgd_fast(pgd)
+
+/*
+ * page middle directory allocation/free routines.
+ */
+extern pmd_t empty_bad_pmd_table[];
+extern pmd_t *get_pmd_slow(pgd_t *pgd, unsigned long address);
+
+extern __inline__ pmd_t *get_pmd_fast (void)
+{
+ unsigned long *ret = (unsigned long *) pmd_quicklist;
+ if (ret != NULL) {
+ pmd_quicklist = (unsigned long *)(*ret);
+ ret[0] = ret[1];
+ pgtable_cache_size -= 4;
+ }
+ return (pmd_t *) ret;
+}
+
+extern __inline__ void free_pmd_fast (pmd_t *pmd)
+{
+ if (pmd == empty_bad_pmd_table)
+ return;
+ *(unsigned long *) pmd = (unsigned long) pmd_quicklist;
+ pmd_quicklist = (unsigned long *) pmd;
+ pgtable_cache_size += 4;
+}
+
+extern __inline__ void free_pmd_slow (pmd_t *pmd)
+{
+ free_pages((unsigned long) pmd, 2);
+}
+
+extern __inline__ pmd_t *pmd_alloc (pgd_t *pgd, unsigned long vmaddr)
+{
+ unsigned long offset;
+
+ offset = (vmaddr >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
+ if (pgd_none(*pgd)) {
+ pmd_t *pmd_page = get_pmd_fast();
+
+ if (!pmd_page)
+ return get_pmd_slow(pgd, offset);
+ pgd_set(pgd, pmd_page);
+ return pmd_page + offset;
+ }
+ if (pgd_bad(*pgd))
+ BUG();
+ return (pmd_t *) pgd_page(*pgd) + offset;
+}
+
+#define pmd_alloc_kernel(pgd, addr) pmd_alloc(pgd, addr)
+#define pmd_free_kernel(pmd) free_pmd_fast(pmd)
+#define pmd_free(pmd) free_pmd_fast(pmd)
+
+/*
+ * page table entry allocation/free routines.
+ */
+extern pte_t empty_bad_pte_table[];
+extern pte_t *get_pte_slow (pmd_t *pmd, unsigned long address_preadjusted);
+
+extern __inline__ pte_t *get_pte_fast (void)
+{
+ unsigned long *ret = (unsigned long *) pte_quicklist;
+
+ if (ret != NULL) {
+ pte_quicklist = (unsigned long *)(*ret);
+ ret[0] = ret[1];
+ pgtable_cache_size--;
+ }
+ return (pte_t *) ret;
+}
+
+extern __inline__ void free_pte_fast (pte_t *pte)
+{
+ if (pte == empty_bad_pte_table)
+ return;
+ *(unsigned long *) pte = (unsigned long) pte_quicklist;
+ pte_quicklist = (unsigned long *) pte;
+ pgtable_cache_size++;
+}
+
+extern __inline__ void free_pte_slow (pte_t *pte)
+{
+ free_page((unsigned long) pte);
+}
+
+extern __inline__ pte_t *pte_alloc (pmd_t *pmd, unsigned long vmaddr)
+{
+ unsigned long offset;
+
+ offset = (vmaddr >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
+ if (pmd_none(*pmd)) {
+ pte_t *pte_page = get_pte_fast();
+
+ if (!pte_page)
+ return get_pte_slow(pmd, offset);
+ pmd_set(pmd, pte_page);
+ return pte_page + offset;
+ }
+ if (pmd_bad(*pmd))
+ BUG();
+ return (pte_t *) pmd_page(*pmd) + offset;
+}
+
+#define pte_alloc_kernel(pmd, addr) pte_alloc(pmd, addr)
+#define pte_free_kernel(pte) free_pte_fast(pte)
+#define pte_free(pte) free_pte_fast(pte)
+
+extern int do_check_pgt_cache (int, int);
+
+/*
+ * This establishes kernel virtual mappings (e.g., as a result of a
+ * vmalloc call). Since s390-esame uses a separate kernel page table,
+ * there is nothing to do here... :)
+ */
+#define set_pgdir(vmaddr, entry) do { } while(0)
+
+/*
+ * TLB flushing:
+ *
+ * - flush_tlb() flushes the current mm struct TLBs
+ * - flush_tlb_all() flushes all processes TLBs
+ * called only from vmalloc/vfree
+ * - flush_tlb_mm(mm) flushes the specified mm context TLB's
+ * - flush_tlb_page(vma, vmaddr) flushes one page
+ * - flush_tlb_range(mm, start, end) flushes a range of pages
+ * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
+ */
+
+/*
+ * S/390 has three ways of flushing TLBs
+ * 'ptlb' does a flush of the local processor
+ * 'csp' flushes the TLBs on all PUs of a SMP
+ * 'ipte' invalidates a pte in a page table and flushes that out of
+ * the TLBs of all PUs of a SMP
+ */
+
+#define local_flush_tlb() \
+do { __asm__ __volatile__("ptlb": : :"memory"); } while (0)
+
+
+#ifndef CONFIG_SMP
+
+/*
+ * We always need to flush, since s390 does not flush tlb
+ * on each context switch
+ */
+
+#define flush_tlb() local_flush_tlb()
+#define flush_tlb_all() local_flush_tlb()
+#define flush_tlb_mm(mm) local_flush_tlb()
+#define flush_tlb_page(vma, va) local_flush_tlb()
+#define flush_tlb_range(mm, start, end) local_flush_tlb()
+
+#else
+
+#include <asm/smp.h>
+
+static inline void global_flush_tlb(void)
+{
+ long dummy = 0;
+
+ __asm__ __volatile__ (
+ " la 4,3(%0)\n"
+ " nill 4,0xfffc\n"
+ " la 4,1(4)\n"
+ " slr 2,2\n"
+ " slr 3,3\n"
+ " csp 2,4"
+ : : "a" (&dummy) : "2", "3", "4" );
+}
+
+/*
+ * We only have to do global flush of tlb if process run since last
+ * flush on any other pu than current.
+ * If we have threads (mm->count > 1) we always do a global flush,
+ * since the process runs on more than one processor at the same time.
+ */
+static inline void __flush_tlb_mm(struct mm_struct * mm)
+{
+ if ((smp_num_cpus > 1) &&
+ ((atomic_read(&mm->mm_count) != 1) ||
+ (mm->cpu_vm_mask != (1UL << smp_processor_id())))) {
+ mm->cpu_vm_mask = (1UL << smp_processor_id());
+ global_flush_tlb();
+ } else {
+ local_flush_tlb();
+ }
+}
+
+#define flush_tlb() __flush_tlb_mm(current->mm)
+#define flush_tlb_all() global_flush_tlb()
+#define flush_tlb_mm(mm) __flush_tlb_mm(mm)
+#define flush_tlb_page(vma, va) __flush_tlb_mm((vma)->vm_mm)
+#define flush_tlb_range(mm, start, end) __flush_tlb_mm(mm)
+
+#endif
+
+extern inline void flush_tlb_pgtables(struct mm_struct *mm,
+ unsigned long start, unsigned long end)
+{
+ /* S/390 does not keep any page table caches in TLB */
+}
+
+
+static inline int ptep_test_and_clear_and_flush_young(struct vm_area_struct *vma,
+ unsigned long address, pte_t *ptep)
+{
+ /* No need to flush TLB; bits are in storage key */
+ return ptep_test_and_clear_young(ptep);
+}
+
+static inline int ptep_test_and_clear_and_flush_dirty(struct vm_area_struct *vma,
+ unsigned long address, pte_t *ptep)
+{
+ /* No need to flush TLB; bits are in storage key */
+ return ptep_test_and_clear_dirty(ptep);
+}
+
+static inline pte_t ptep_invalidate(struct vm_area_struct *vma,
+ unsigned long address, pte_t *ptep)
+{
+ pte_t pte = *ptep;
+ if (!(pte_val(pte) & _PAGE_INVALID))
+ __asm__ __volatile__ ("ipte %0,%1" : : "a" (ptep), "a" (address));
+ pte_clear(ptep);
+ return pte;
+}
+
+static inline void ptep_establish(struct vm_area_struct *vma,
+ unsigned long address, pte_t *ptep, pte_t entry)
+{
+ ptep_invalidate(vma, address, ptep);
+ set_pte(ptep, entry);
+}
+
+#endif /* _S390_PGALLOC_H */
diff --git a/include/asm-s390x/pgtable.h b/include/asm-s390x/pgtable.h
new file mode 100644
index 000000000..f73fc215c
--- /dev/null
+++ b/include/asm-s390x/pgtable.h
@@ -0,0 +1,486 @@
+/*
+ * include/asm-s390/pgtable.h
+ *
+ * S390 64bit version
+ * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Hartmut Penner (hp@de.ibm.com)
+ * Ulrich Weigand (weigand@de.ibm.com)
+ * Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/pgtable.h"
+ */
+
+#ifndef _ASM_S390_PGTABLE_H
+#define _ASM_S390_PGTABLE_H
+
+/*
+ * The Linux memory management assumes a three-level page table setup. On
+ * the S390, we use that, but "fold" the mid level into the top-level page
+ * table, so that we physically have the same two-level page table as the
+ * S390 mmu expects.
+ *
+ * This file contains the functions and defines necessary to modify and use
+ * the S390 page table tree.
+ */
+#ifndef __ASSEMBLY__
+#include <asm/processor.h>
+#include <linux/threads.h>
+
+extern pgd_t swapper_pg_dir[] __attribute__ ((aligned (4096)));
+extern void paging_init(void);
+
+/* Caches aren't brain-dead on S390. */
+#define flush_cache_all() do { } while (0)
+#define flush_cache_mm(mm) do { } while (0)
+#define flush_cache_range(mm, start, end) do { } while (0)
+#define flush_cache_page(vma, vmaddr) do { } while (0)
+#define flush_page_to_ram(page) do { } while (0)
+#define flush_dcache_page(page) do { } while (0)
+#define flush_icache_range(start, end) do { } while (0)
+#define flush_icache_page(vma,pg) do { } while (0)
+
+/*
+ * The S390 doesn't have any external MMU info: the kernel page
+ * tables contain all the necessary information.
+ */
+#define update_mmu_cache(vma, address, pte) do { } while (0)
+
+/*
+ * ZERO_PAGE is a global shared page that is always zero: used
+ * for zero-mapped memory areas etc..
+ */
+extern char empty_zero_page[PAGE_SIZE];
+#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
+#endif /* !__ASSEMBLY__ */
+
+/*
+ * Certain architectures need to do special things when PTEs
+ * within a page table are directly modified. Thus, the following
+ * hook is made available.
+ */
+#define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
+
+/*
+ * PMD_SHIFT determines the size of the area a second-level page
+ * table can map
+ */
+#define PMD_SHIFT 21
+#define PMD_SIZE (1UL << PMD_SHIFT)
+#define PMD_MASK (~(PMD_SIZE-1))
+
+/* PGDIR_SHIFT determines what a third-level page table entry can map */
+#define PGDIR_SHIFT 31
+#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
+#define PGDIR_MASK (~(PGDIR_SIZE-1))
+
+/*
+ * entries per page directory level: the S390 is two to five-level,
+ * currently we use a 3 level lookup
+ */
+#define PTRS_PER_PTE 512
+#define PTRS_PER_PMD 1024
+#define PTRS_PER_PGD 2048
+
+/*
+ * pgd entries used up by user/kernel:
+ */
+#define USER_PTRS_PER_PGD 2048
+#define USER_PGD_PTRS 2048
+#define KERNEL_PGD_PTRS 2048
+#define FIRST_USER_PGD_NR 0
+
+#define pte_ERROR(e) \
+ printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
+#define pmd_ERROR(e) \
+ printk("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e))
+#define pgd_ERROR(e) \
+ printk("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e))
+
+#ifndef __ASSEMBLY__
+/*
+ * Just any arbitrary offset to the start of the vmalloc VM area: the
+ * current 8MB value just means that there will be a 8MB "hole" after the
+ * physical memory until the kernel virtual memory starts. That means that
+ * any out-of-bounds memory accesses will hopefully be caught.
+ * The vmalloc() routines leaves a hole of 4kB between each vmalloced
+ * area for the same reason. ;)
+ */
+#define VMALLOC_OFFSET (8*1024*1024)
+#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) \
+ & ~(VMALLOC_OFFSET-1))
+#define VMALLOC_VMADDR(x) ((unsigned long)(x))
+#define VMALLOC_END (0x40000000000L)
+
+
+/*
+ * A pagetable entry of S390 has following format:
+ * | PFRA |0IP0| OS |
+ * 0000000000111111111122222222223333333333444444444455555555556666
+ * 0123456789012345678901234567890123456789012345678901234567890123
+ *
+ * I Page-Invalid Bit: Page is not available for address-translation
+ * P Page-Protection Bit: Store access not possible for page
+ *
+ * A segmenttable entry of S390 has following format:
+ * | P-table origin | TT
+ * 0000000000111111111122222222223333333333444444444455555555556666
+ * 0123456789012345678901234567890123456789012345678901234567890123
+ *
+ * I Segment-Invalid Bit: Segment is not available for address-translation
+ * C Common-Segment Bit: Segment is not private (PoP 3-30)
+ * P Page-Protection Bit: Store access not possible for page
+ * TT Type 00
+ *
+ * A region table entry of S390 has following format:
+ * | S-table origin | TF TTTL
+ * 0000000000111111111122222222223333333333444444444455555555556666
+ * 0123456789012345678901234567890123456789012345678901234567890123
+ *
+ * I Segment-Invalid Bit: Segment is not available for address-translation
+ * TT Type 01
+ * TF
+ * TL Table lenght
+ *
+ * The regiontable origin of S390 has following format:
+ * | region table origon | DTTL
+ * 0000000000111111111122222222223333333333444444444455555555556666
+ * 0123456789012345678901234567890123456789012345678901234567890123
+ *
+ * X Space-Switch event:
+ * G Segment-Invalid Bit:
+ * P Private-Space Bit:
+ * S Storage-Alteration:
+ * R Real space
+ * TL Table-Length:
+ *
+ * A storage key has the following format:
+ * | ACC |F|R|C|0|
+ * 0 3 4 5 6 7
+ * ACC: access key
+ * F : fetch protection bit
+ * R : referenced bit
+ * C : changed bit
+ */
+
+/* Bits in the page table entry */
+#define _PAGE_PRESENT 0x001 /* Software */
+#define _PAGE_RO 0x200 /* HW read-only */
+#define _PAGE_INVALID 0x400 /* HW invalid */
+
+/* Bits in the segment table entry */
+#define _PMD_ENTRY_INV 0x20 /* invalid segment table entry */
+#define _PMD_ENTRY 0x00
+
+/* Bits in the region third table entry */
+#define _PGD_ENTRY_INV 0x20 /* invalid region table entry */
+#define _PGD_ENTRY 0x07
+
+/*
+ * User and kernel page directory
+ */
+#define _REGION_THIRD 0x4
+#define _REGION_THIRD_LEN 0x3
+#define _REGION_TABLE (_REGION_THIRD|_REGION_THIRD_LEN)
+
+/* Bits in the storage key */
+#define _PAGE_CHANGED 0x02 /* HW changed bit */
+#define _PAGE_REFERENCED 0x04 /* HW referenced bit */
+
+/*
+ * No mapping available
+ */
+#define PAGE_INVALID __pgprot(_PAGE_INVALID)
+#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_INVALID)
+#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_RO)
+#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_RO)
+#define PAGE_SHARED __pgprot(_PAGE_PRESENT )
+#define PAGE_KERNEL __pgprot(_PAGE_PRESENT )
+
+/*
+ * The S390 can't do page protection for execute, and considers that the
+ * same are read. Also, write permissions imply read permissions. This is
+ * the closest we can get..
+ */
+#define __P000 PAGE_NONE
+#define __P001 PAGE_READONLY
+#define __P010 PAGE_COPY
+#define __P011 PAGE_COPY
+#define __P100 PAGE_READONLY
+#define __P101 PAGE_READONLY
+#define __P110 PAGE_COPY
+#define __P111 PAGE_COPY
+
+#define __S000 PAGE_NONE
+#define __S001 PAGE_READONLY
+#define __S010 PAGE_SHARED
+#define __S011 PAGE_SHARED
+#define __S100 PAGE_READONLY
+#define __S101 PAGE_READONLY
+#define __S110 PAGE_SHARED
+#define __S111 PAGE_SHARED
+
+/*
+ * Permanent address of a page.
+ */
+#define page_address(page) ((page)->virtual)
+#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
+
+/*
+ * pgd/pmd/pte query functions
+ */
+extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) != 0; }
+extern inline int pgd_none(pgd_t pgd) { return pgd_val(pgd) & _PGD_ENTRY_INV; }
+extern inline int pgd_bad(pgd_t pgd)
+{
+ return (pgd_val(pgd) & (~PAGE_MASK & ~_PGD_ENTRY_INV)) != _PGD_ENTRY;
+}
+
+extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) != 0; }
+extern inline int pmd_none(pmd_t pmd) { return pmd_val(pmd) & _PMD_ENTRY_INV; }
+extern inline int pmd_bad(pmd_t pmd)
+{
+ return (pmd_val(pmd) & (~PAGE_MASK & ~_PMD_ENTRY_INV)) != _PMD_ENTRY;
+}
+
+extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_PRESENT; }
+extern inline int pte_none(pte_t pte)
+{
+ return ((pte_val(pte) &
+ (_PAGE_INVALID | _PAGE_RO | _PAGE_PRESENT)) == _PAGE_INVALID);
+}
+
+#define pte_same(a,b) (pte_val(a) == pte_val(b))
+
+/*
+ * query functions pte_write/pte_dirty/pte_young only work if
+ * pte_present() is true. Undefined behaviour if not..
+ */
+extern inline int pte_write(pte_t pte)
+{
+ return (pte_val(pte) & _PAGE_RO) == 0;
+}
+
+extern inline int pte_dirty(pte_t pte)
+{
+ int skey;
+
+ asm volatile ("iske %0,%1" : "=d" (skey) : "a" (pte_val(pte)));
+ return skey & _PAGE_CHANGED;
+}
+
+extern inline int pte_young(pte_t pte)
+{
+ int skey;
+
+ asm volatile ("iske %0,%1" : "=d" (skey) : "a" (pte_val(pte)));
+ return skey & _PAGE_REFERENCED;
+}
+
+/*
+ * pgd/pmd/pte modification functions
+ */
+extern inline void pgd_clear(pgd_t * pgdp)
+{
+ pgd_val(*pgdp) = _PGD_ENTRY_INV | _PGD_ENTRY;
+}
+
+extern inline void pmd_clear(pmd_t * pmdp)
+{
+ pmd_val(*pmdp) = _PMD_ENTRY_INV | _PMD_ENTRY;
+ pmd_val1(*pmdp) = _PMD_ENTRY_INV | _PMD_ENTRY;
+}
+
+extern inline void pte_clear(pte_t *ptep)
+{
+ pte_val(*ptep) = _PAGE_INVALID;
+}
+
+#define PTE_INIT(x) pte_clear(x)
+
+/*
+ * The following pte_modification functions only work if
+ * pte_present() is true. Undefined behaviour if not..
+ */
+extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
+ pte_val(pte) = (pte_val(pte) & PAGE_MASK) | pgprot_val(newprot);
+ return pte;
+}
+
+extern inline pte_t pte_wrprotect(pte_t pte)
+{
+ pte_val(pte) |= _PAGE_RO;
+ return pte;
+}
+
+extern inline pte_t pte_mkwrite(pte_t pte)
+{
+ pte_val(pte) &= ~_PAGE_RO;
+ return pte;
+}
+
+extern inline pte_t pte_mkclean(pte_t pte)
+{
+ /* We can't clear the changed bit atomically. The iske/and/sske
+ * sequence has a race condition with the page referenced bit.
+ * At the moment pte_mkclean is always followed by a pte_mkold.
+ * So its safe to ignore the problem for now. Hope this will
+ * never change ... */
+ asm volatile ("sske %0,%1"
+ : : "d" (0), "a" (pte_val(pte)));
+ return pte;
+}
+
+extern inline pte_t pte_mkdirty(pte_t pte)
+{
+ /* We can't set the changed bit atomically either. For now we
+ * set (!) the page referenced bit. */
+ asm volatile ("sske %0,%1"
+ : : "d" (_PAGE_CHANGED|_PAGE_REFERENCED),
+ "a" (pte_val(pte)));
+ return pte;
+}
+
+extern inline pte_t pte_mkold(pte_t pte)
+{
+ asm volatile ("rrbe 0,%0" : : "a" (pte_val(pte)));
+ return pte;
+}
+
+extern inline pte_t pte_mkyoung(pte_t pte)
+{
+ /* To set the referenced bit we read the first word from the real
+ * page with a special instruction: load using real address (lura).
+ * Isn't S/390 a nice architecture ?! */
+ asm volatile ("lura 0,%0" : : "a" (pte_val(pte) & PAGE_MASK) : "0" );
+ return pte;
+}
+
+static inline int ptep_test_and_clear_young(pte_t *ptep)
+{
+ int ccode;
+
+ asm volatile ("rrbe 0,%1\n\t"
+ "ipm %0\n\t"
+ "srl %0,28\n\t" : "=d" (ccode) : "a" (pte_val(*ptep)));
+ return ccode & 2;
+}
+
+static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+{
+ int skey;
+
+ asm volatile ("iske %0,%1" : "=d" (skey) : "a" (*ptep));
+ if ((skey & _PAGE_CHANGED) == 0)
+ return 0;
+ /* We can't clear the changed bit atomically. For now we
+ * clear (!) the page referenced bit. */
+ asm volatile ("sske %0,%1"
+ : : "d" (0), "a" (*ptep));
+ return 1;
+}
+
+static inline pte_t ptep_get_and_clear(pte_t *ptep)
+{
+ pte_t pte = *ptep;
+ pte_clear(ptep);
+ return pte;
+}
+
+static inline void ptep_set_wrprotect(pte_t *ptep)
+{
+ pte_t old_pte = *ptep;
+ set_pte(ptep, pte_wrprotect(old_pte));
+}
+
+static inline void ptep_mkdirty(pte_t *ptep)
+{
+ pte_mkdirty(*ptep);
+}
+
+/*
+ * Conversion functions: convert a page and protection to a page entry,
+ * and a page entry and page directory to the page they refer to.
+ */
+extern inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
+{
+ pte_t __pte;
+ pte_val(__pte) = physpage + pgprot_val(pgprot);
+ return __pte;
+}
+#define mk_pte(page,pgprot) mk_pte_phys(__pa(((page)-mem_map)<<PAGE_SHIFT),pgprot)
+
+#define pte_page(x) (mem_map+(unsigned long)((pte_val(x) >> PAGE_SHIFT)))
+
+extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
+{
+ pmd_val(*pmdp) = _PMD_ENTRY | __pa(ptep);
+ pmd_val1(*pmdp) = _PMD_ENTRY | __pa(ptep+256);
+}
+
+extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
+{
+ pgd_val(*pgdp) = _PGD_ENTRY | __pa(pmdp);
+}
+
+#define pmd_page(pmd) \
+ ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
+
+/* to find an entry in a page-table-directory */
+#define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
+#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
+
+#define pgd_page(pmd) \
+ ((unsigned long) __va(pgd_val(pmd) & PAGE_MASK))
+
+/* to find an entry in a kernel page-table-directory */
+#define pgd_offset_k(address) pgd_offset(&init_mm, address)
+
+/* Find an entry in the second-level page table.. */
+#define pmd_offset(dir,addr) \
+ ((pmd_t *) pgd_page(*(dir)) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
+
+/* Find an entry in the third-level page table.. */
+#define pte_offset(dir,addr) \
+ ((pte_t *) pmd_page(*(dir)) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
+
+/*
+ * A page-table entry has some bits we have to treat in a special way.
+ * Bits 52 and bit 55 have to be zero, otherwise an specification
+ * exception will occur instead of a page translation exception. The
+ * specifiation exception has the bad habit not to store necessary
+ * information in the lowcore.
+ * Bit 53 and bit 54 are the page invalid bit and the page protection
+ * bit. We set both to indicate a swapped page.
+ * Bit 63 is used as the software page present bit. If a page is
+ * swapped this obviously has to be zero.
+ * This leaves the bits 0-51 and bits 56-62 to store type and offset.
+ * We use the 7 bits from 56-62 for the type and the 52 bits from 0-51
+ * for the offset.
+ * | offset |0110|type |0
+ * 0000000000111111111122222222223333333333444444444455555555556666
+ * 0123456789012345678901234567890123456789012345678901234567890123
+ */
+extern inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
+{
+ pte_t pte;
+ pte_val(pte) = (type << 1) | (offset << 12) | _PAGE_INVALID | _PAGE_RO;
+ pte_val(pte) &= 0xfffffffffffff6fe; /* better to be paranoid */
+ return pte;
+}
+
+#define SWP_TYPE(entry) (((entry).val >> 1) & 0x3f)
+#define SWP_OFFSET(entry) ((entry).val >> 12)
+#define SWP_ENTRY(type,offset) ((swp_entry_t) { pte_val(mk_swap_pte((type),(offset))) })
+
+#define pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
+#define swp_entry_to_pte(x) ((pte_t) { (x).val })
+
+#endif /* !__ASSEMBLY__ */
+
+/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
+#define PageSkip(page) (0)
+#define kern_addr_valid(addr) (1)
+
+#endif /* _S390_PAGE_H */
+
diff --git a/include/asm-s390x/poll.h b/include/asm-s390x/poll.h
new file mode 100644
index 000000000..011747b53
--- /dev/null
+++ b/include/asm-s390x/poll.h
@@ -0,0 +1,33 @@
+/*
+ * include/asm-s390/poll.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/poll.h"
+ */
+
+#ifndef __S390_POLL_H
+#define __S390_POLL_H
+
+/* These are specified by iBCS2 */
+#define POLLIN 0x0001
+#define POLLPRI 0x0002
+#define POLLOUT 0x0004
+#define POLLERR 0x0008
+#define POLLHUP 0x0010
+#define POLLNVAL 0x0020
+
+/* The rest seem to be more-or-less nonstandard. Check them! */
+#define POLLRDNORM 0x0040
+#define POLLRDBAND 0x0080
+#define POLLWRNORM 0x0100
+#define POLLWRBAND 0x0200
+#define POLLMSG 0x0400
+
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+#endif
diff --git a/include/asm-s390x/posix_types.h b/include/asm-s390x/posix_types.h
new file mode 100644
index 000000000..70ff9dc51
--- /dev/null
+++ b/include/asm-s390x/posix_types.h
@@ -0,0 +1,74 @@
+/*
+ * include/asm-s390/posix_types.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/posix_types.h"
+ */
+
+#ifndef __ARCH_S390_POSIX_TYPES_H
+#define __ARCH_S390_POSIX_TYPES_H
+
+/*
+ * This file is generally used by user-level software, so you need to
+ * be a little careful about namespace pollution etc. Also, we cannot
+ * assume GCC is being used.
+ */
+
+typedef unsigned int __kernel_dev_t;
+typedef unsigned int __kernel_ino_t;
+typedef unsigned int __kernel_mode_t;
+typedef unsigned int __kernel_nlink_t;
+typedef long __kernel_off_t;
+typedef long long __kernel_loff_t;
+typedef int __kernel_pid_t;
+typedef int __kernel_ipc_pid_t;
+typedef unsigned int __kernel_uid_t;
+typedef unsigned int __kernel_gid_t;
+typedef unsigned long __kernel_size_t;
+typedef long __kernel_ssize_t;
+typedef long __kernel_ptrdiff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_suseconds_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_daddr_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned long __kernel_sigset_t; /* at least 32 bits */
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+
+typedef __kernel_uid_t __kernel_old_uid_t;
+typedef __kernel_gid_t __kernel_old_gid_t;
+typedef __kernel_uid_t __kernel_uid32_t;
+typedef __kernel_gid_t __kernel_gid32_t;
+
+typedef struct {
+#if defined(__KERNEL__) || defined(__USE_ALL)
+ int val[2];
+#else /* !defined(__KERNEL__) && !defined(__USE_ALL)*/
+ int __val[2];
+#endif /* !defined(__KERNEL__) && !defined(__USE_ALL)*/
+} __kernel_fsid_t;
+
+
+#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+
+#ifndef _S390_BITOPS_H
+#include <asm/bitops.h>
+#endif
+
+#undef __FD_SET
+#define __FD_SET(fd,fdsetp) set_bit(fd,fdsetp)
+
+#undef __FD_CLR
+#define __FD_CLR(fd,fdsetp) clear_bit(fd,fdsetp)
+
+#undef __FD_ISSET
+#define __FD_ISSET(fd,fdsetp) test_bit(fd,fdsetp)
+
+#undef __FD_ZERO
+#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
+
+#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)*/
+
+#endif
diff --git a/include/asm-s390x/processor.h b/include/asm-s390x/processor.h
new file mode 100644
index 000000000..ea6561100
--- /dev/null
+++ b/include/asm-s390x/processor.h
@@ -0,0 +1,227 @@
+/*
+ * include/asm-s390/processor.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Hartmut Penner (hp@de.ibm.com),
+ * Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/processor.h"
+ * Copyright (C) 1994, Linus Torvalds
+ */
+
+#ifndef __ASM_S390_PROCESSOR_H
+#define __ASM_S390_PROCESSOR_H
+
+#include <asm/page.h>
+#include <asm/ptrace.h>
+
+/*
+ * Default implementation of macro that returns current
+ * instruction pointer ("program counter").
+ */
+#define current_text_addr() ({ void *pc; __asm__("basr %0,0":"=a"(pc)); pc; })
+
+/*
+ * CPU type and hardware bug flags. Kept separately for each CPU.
+ * Members of this structure are referenced in head.S, so think twice
+ * before touching them. [mj]
+ */
+
+typedef struct
+{
+ unsigned int version : 8;
+ unsigned int ident : 24;
+ unsigned int machine : 16;
+ unsigned int unused : 16;
+} __attribute__ ((packed)) cpuid_t;
+
+struct cpuinfo_S390
+{
+ cpuid_t cpu_id;
+ unsigned long loops_per_jiffy;
+ unsigned long *pgd_quick;
+ unsigned long *pmd_quick;
+ unsigned long *pte_quick;
+ unsigned long pgtable_cache_sz;
+ __u16 cpu_addr;
+ __u16 cpu_nr;
+ __u16 pad[2];
+};
+
+extern void print_cpu_info(struct cpuinfo_S390 *);
+
+/* Lazy FPU handling on uni-processor */
+extern struct task_struct *last_task_used_math;
+
+#define S390_FLAG_31BIT 0x01UL
+
+/*
+ * User space process size: 4TB (default).
+ */
+#define TASK_SIZE (0x40000000000UL)
+#define TASK31_SIZE (0x80000000UL)
+
+/* This decides where the kernel will search for a free chunk of vm
+ * space during mmap's.
+ */
+#define TASK_UNMAPPED_BASE ((current->thread.flags & S390_FLAG_31BIT) ? \
+ (TASK31_SIZE / 2) : (TASK_SIZE / 2))
+
+#define THREAD_SIZE (4*PAGE_SIZE)
+
+typedef struct {
+ __u32 ar4;
+} mm_segment_t;
+
+/* if you change the thread_struct structure, you must
+ * update the _TSS_* defines in entry.S
+ */
+
+struct thread_struct
+ {
+ struct pt_regs *regs; /* the user registers can be found on*/
+ s390_fp_regs fp_regs;
+ __u32 ar2; /* kernel access register 2 */
+ __u32 ar4; /* kernel access register 4 */
+ addr_t ksp; /* kernel stack pointer */
+ addr_t user_seg; /* HSTD */
+ addr_t prot_addr; /* address of protection-excep. */
+ __u32 error_code; /* error-code of last prog-excep. */
+ __u32 trap_no;
+ per_struct per_info;/* Must be aligned on an 4 byte boundary*/
+ addr_t ieee_instruction_pointer;
+ /* Used to give failing instruction back to user for ieee exceptions */
+ unsigned long flags; /* various flags */
+};
+
+typedef struct thread_struct thread_struct;
+
+#define INIT_MMAP \
+{ &init_mm, 0, 0, NULL, PAGE_SHARED, \
+VM_READ | VM_WRITE | VM_EXEC, 1, NULL,NULL }
+
+#define INIT_THREAD { (struct pt_regs *) 0, \
+ { 0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \
+ {0},{0},{0},{0},{0},{0}}}, \
+ 0, 0, \
+ sizeof(init_stack) + (addr_t) &init_stack, \
+ (__pa((addr_t) &swapper_pg_dir[0]) + _REGION_TABLE),\
+ 0,0,0, \
+ (per_struct) {{{{0,}}},0,0,0,0,{{0,}}}, \
+ 0 \
+}
+
+/* need to define ... */
+#define start_thread(regs, new_psw, new_stackp) do { \
+ regs->psw.mask = _USER_PSW_MASK; \
+ regs->psw.addr = new_psw; \
+ regs->gprs[15] = new_stackp; \
+} while (0)
+
+#define start_thread31(regs, new_psw, new_stackp) do { \
+ regs->psw.mask = _USER_PSW_MASK & ~(1L << 32); \
+ regs->psw.addr = new_psw; \
+ regs->gprs[15] = new_stackp; \
+} while (0)
+
+
+/* Forward declaration, a strange C thing */
+struct mm_struct;
+
+/* Free all resources held by a thread. */
+extern void release_thread(struct task_struct *);
+extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+
+/* Copy and release all segment info associated with a VM */
+#define copy_segments(nr, mm) do { } while (0)
+#define release_segments(mm) do { } while (0)
+
+/*
+ * Return saved PC of a blocked thread. used in kernel/sched
+ */
+extern inline unsigned long thread_saved_pc(struct thread_struct *t)
+{
+ return (t->regs) ? ((unsigned long)t->regs->psw.addr) : 0;
+}
+
+unsigned long get_wchan(struct task_struct *p);
+#define KSTK_EIP(tsk) ((tsk)->thread.regs->psw.addr)
+#define KSTK_ESP(tsk) ((tsk)->thread.ksp)
+
+/* Allocation and freeing of basic task resources. */
+/*
+ * NOTE! The task struct and the stack go together
+ */
+#define alloc_task_struct() \
+ ((struct task_struct *) __get_free_pages(GFP_KERNEL,2))
+#define free_task_struct(p) free_pages((unsigned long)(p),2)
+#define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
+
+#define init_task (init_task_union.task)
+#define init_stack (init_task_union.stack)
+
+/*
+ * Set of msr bits that gdb can change on behalf of a process.
+ */
+/* Only let our hackers near the condition codes */
+#define PSW_MASK_DEBUGCHANGE 0x0000300000000000UL
+/* Don't let em near the addressing mode either */
+#define PSW_ADDR_DEBUGCHANGE 0xFFFFFFFFFFFFFFFFUL
+#define PSW_ADDR_MASK 0xFFFFFFFFFFFFFFFFUL
+/* Program event recording mask */
+#define PSW_PER_MASK 0x4000000000000000UL
+#define USER_STD_MASK 0x0000000000000080UL
+#define PSW_PROBLEM_STATE 0x0001000000000000UL
+
+/*
+ * Function to drop a processor into disabled wait state
+ */
+
+static inline void disabled_wait(addr_t code)
+{
+ char psw_buffer[2*sizeof(psw_t)];
+ char ctl_buf[8];
+ psw_t *dw_psw = (psw_t *)(((unsigned long) &psw_buffer+sizeof(psw_t)-1)
+ & -sizeof(psw_t));
+
+ dw_psw->mask = 0x0002000180000000;
+ dw_psw->addr = code;
+ /*
+ * Store status and then load disabled wait psw,
+ * the processor is dead afterwards
+ */
+ asm volatile (" stctg 0,0,0(%1)\n"
+ " ni 4(%1),0xef\n" /* switch off protection */
+ " lctlg 0,0,0(%1)\n"
+ " lghi 1,0x1000\n"
+ " stpt 0x328(1)\n" /* store timer */
+ " stckc 0x330(1)\n" /* store clock comparator */
+ " stpx 0x318(1)\n" /* store prefix register */
+ " stam 0,15,0x340(1)\n" /* store access registers */
+ " stfpc 0x31c(1)\n" /* store fpu control */
+ " std 0,0x200(1)\n" /* store f0 */
+ " std 1,0x208(1)\n" /* store f1 */
+ " std 2,0x210(1)\n" /* store f2 */
+ " std 3,0x218(1)\n" /* store f3 */
+ " std 4,0x220(1)\n" /* store f4 */
+ " std 5,0x228(1)\n" /* store f5 */
+ " std 6,0x230(1)\n" /* store f6 */
+ " std 7,0x238(1)\n" /* store f7 */
+ " std 8,0x240(1)\n" /* store f8 */
+ " std 9,0x248(1)\n" /* store f9 */
+ " std 10,0x250(1)\n" /* store f10 */
+ " std 11,0x258(1)\n" /* store f11 */
+ " std 12,0x260(1)\n" /* store f12 */
+ " std 13,0x268(1)\n" /* store f13 */
+ " std 14,0x270(1)\n" /* store f14 */
+ " std 15,0x278(1)\n" /* store f15 */
+ " stmg 0,15,0x280(1)\n" /* store general registers */
+ " stctg 0,15,0x380(1)\n" /* store control registers */
+ " oi 0x384(1),0x10\n" /* fake protection bit */
+ " lpswe 0(%0)"
+ : : "a" (dw_psw), "a" (&ctl_buf) : "0", "1");
+}
+
+#endif /* __ASM_S390_PROCESSOR_H */
+
diff --git a/include/asm-s390x/ptrace.h b/include/asm-s390x/ptrace.h
new file mode 100644
index 000000000..d2559f39a
--- /dev/null
+++ b/include/asm-s390x/ptrace.h
@@ -0,0 +1,326 @@
+/*
+ * include/asm-s390/ptrace.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ */
+
+#ifndef _S390_PTRACE_H
+#define _S390_PTRACE_H
+#include <linux/config.h>
+#include <asm/s390-regs-common.h>
+#include <asm/current.h>
+#include <linux/types.h>
+#include <asm/setup.h>
+#include <linux/stddef.h>
+
+
+#define S390_REGS \
+S390_REGS_COMMON \
+addr_t orig_gpr2;
+
+typedef struct
+{
+ S390_REGS
+} __attribute__ ((packed)) s390_regs;
+
+struct pt_regs
+{
+ S390_REGS
+ __u32 trap;
+} __attribute__ ((packed));
+
+#if CONFIG_REMOTE_DEBUG
+typedef struct
+{
+ S390_REGS
+ __u32 trap;
+ addr_t crs[16];
+ s390_fp_regs fp_regs;
+} __attribute__ ((packed)) gdb_pt_regs;
+#endif
+
+
+typedef struct
+{
+ addr_t cr[3];
+} per_cr_words __attribute__((packed));
+
+#define PER_EM_MASK 0x00000000E8000000UL
+typedef struct
+{
+ unsigned :32;
+ unsigned em_branching:1;
+ unsigned em_instruction_fetch:1;
+ /* Switching on storage alteration automatically fixes
+ the storage alteration event bit in the users std. */
+ unsigned em_storage_alteration:1;
+ unsigned em_gpr_alt_unused:1;
+ unsigned em_store_real_address:1;
+ unsigned :3;
+ unsigned branch_addr_ctl:1;
+ unsigned :1;
+ unsigned storage_alt_space_ctl:1;
+ unsigned :5;
+ unsigned :16;
+ addr_t starting_addr;
+ addr_t ending_addr;
+} per_cr_bits __attribute__((packed));
+
+typedef struct
+{
+ __u16 perc_atmid; /* 0x096 */
+ addr_t address; /* 0x098 */
+ __u8 access_id; /* 0x0a1 */
+} per_lowcore_words __attribute__((packed));
+
+typedef struct
+{
+ unsigned perc_branching:1; /* 0x096 */
+ unsigned perc_instruction_fetch:1;
+ unsigned perc_storage_alteration:1;
+ unsigned perc_gpr_alt_unused:1;
+ unsigned perc_store_real_address:1;
+ unsigned :3;
+ unsigned atmid_psw_bit_31:1;
+ unsigned atmid_validity_bit:1;
+ unsigned atmid_psw_bit_32:1;
+ unsigned atmid_psw_bit_5:1;
+ unsigned atmid_psw_bit_16:1;
+ unsigned atmid_psw_bit_17:1;
+ unsigned ai:2;
+ addr_t address; /* 0x098 */
+ unsigned :4; /* 0x0a1 */
+ unsigned access_id:4;
+} per_lowcore_bits __attribute__((packed));
+
+
+typedef enum
+{
+ primary_asce,
+ ar_asce,
+ secondary_asce,
+ home_space_asce
+} per_ai_codes;
+
+
+
+typedef struct
+{
+ union
+ {
+ per_cr_words words;
+ per_cr_bits bits;
+ } control_regs __attribute__((packed));
+ /* Use these flags instead of setting em_instruction_fetch */
+ /* directly they are used so that single stepping can be */
+ /* switched on & off while not affecting other tracing */
+ unsigned single_step:1;
+ unsigned instruction_fetch:1;
+ unsigned :30;
+ /* These addresses are copied into cr10 & cr11 if single stepping
+ is switched off */
+ addr_t starting_addr;
+ addr_t ending_addr;
+ union
+ {
+ per_lowcore_words words;
+ per_lowcore_bits bits;
+ } lowcore;
+} per_struct __attribute__((packed));
+
+
+
+/* this struct defines the way the registers are stored on the
+ stack during a system call. If you change the pt_regs structure,
+ you'll need to change user.h too.
+
+ N.B. if you modify the pt_regs struct the strace command also has to be
+ modified & recompiled ( just wait till we have gdb going ).
+
+*/
+
+struct user_regs_struct
+{
+ S390_REGS
+ s390_fp_regs fp_regs;
+/* These per registers are in here so that gdb can modify them itself
+ * as there is no "official" ptrace interface for hardware watchpoints.
+ * this is the way intel does it
+ */
+ per_struct per_info;
+ addr_t ieee_instruction_pointer;
+ /* Used to give failing instruction back to user for ieee exceptions */
+};
+
+typedef struct user_regs_struct user_regs_struct;
+
+typedef struct pt_regs pt_regs;
+
+#ifdef __KERNEL__
+#define user_mode(regs) (((regs)->psw.mask & PSW_PROBLEM_STATE) != 0)
+#define instruction_pointer(regs) ((regs)->psw.addr)
+extern void show_regs(struct pt_regs * regs);
+extern char *task_show_regs(struct task_struct *task, char *buffer);
+#endif
+
+
+
+
+
+#define FIX_PSW(addr) ((unsigned long)(addr))
+
+#define MULT_PROCPTR_TYPES ((CONFIG_BINFMT_ELF)&&(CONFIG_BINFMT_TOC))
+
+typedef struct
+{
+ long addr;
+ long toc;
+} routine_descriptor;
+extern void fix_routine_descriptor_regs(routine_descriptor *rdes,pt_regs *regs);
+extern __inline__ void
+fix_routine_descriptor_regs(routine_descriptor *rdes,pt_regs *regs)
+{
+ regs->psw.addr=FIX_PSW(rdes->addr);
+ regs->gprs[12]=rdes->toc;
+}
+
+/*
+ * Compiler optimisation should save this stuff from being non optimal
+ * & remove uneccessary code ( isnt gcc great DJB. )
+ */
+
+/*I'm just using this an indicator of what binformat we are using
+ * (DJB) N.B. this needs to stay a macro unfortunately as I am otherwise
+ * dereferencing incomplete pointer types in with load_toc_binary
+ */
+#if MULT_PROCPTR_TYPES
+#define uses_routine_descriptors() \
+(current->binfmt->load_binary==load_toc_binary)
+#else
+#if CONFIG_BINFMT_TOC
+#define uses_routine_descriptors() 1
+#else
+#define uses_routine_descriptors() 0
+#endif
+#endif
+
+#define pt_off(ptreg) offsetof(user_regs_struct,ptreg)
+enum
+{
+ PT_PSWMASK=pt_off(psw.mask),
+ PT_PSWADDR=pt_off(psw.addr),
+ PT_GPR0=pt_off(gprs[0]),
+ PT_GPR1=pt_off(gprs[1]),
+ PT_GPR2=pt_off(gprs[2]),
+ PT_GPR3=pt_off(gprs[3]),
+ PT_GPR4=pt_off(gprs[4]),
+ PT_GPR5=pt_off(gprs[5]),
+ PT_GPR6=pt_off(gprs[6]),
+ PT_GPR7=pt_off(gprs[7]),
+ PT_GPR8=pt_off(gprs[8]),
+ PT_GPR9=pt_off(gprs[9]),
+ PT_GPR10=pt_off(gprs[10]),
+ PT_GPR11=pt_off(gprs[11]),
+ PT_GPR12=pt_off(gprs[12]),
+ PT_GPR13=pt_off(gprs[13]),
+ PT_GPR14=pt_off(gprs[14]),
+ PT_GPR15=pt_off(gprs[15]),
+ PT_ACR0=pt_off(acrs[0]),
+ PT_ACR1=pt_off(acrs[1]),
+ PT_ACR2=pt_off(acrs[2]),
+ PT_ACR3=pt_off(acrs[3]),
+ PT_ACR4=pt_off(acrs[4]),
+ PT_ACR5=pt_off(acrs[5]),
+ PT_ACR6=pt_off(acrs[6]),
+ PT_ACR7=pt_off(acrs[7]),
+ PT_ACR8=pt_off(acrs[8]),
+ PT_ACR9=pt_off(acrs[9]),
+ PT_ACR10=pt_off(acrs[10]),
+ PT_ACR11=pt_off(acrs[11]),
+ PT_ACR12=pt_off(acrs[12]),
+ PT_ACR13=pt_off(acrs[13]),
+ PT_ACR14=pt_off(acrs[14]),
+ PT_ACR15=pt_off(acrs[15]),
+ PT_ORIGGPR2=pt_off(orig_gpr2),
+ PT_FPC=pt_off(fp_regs.fpc),
+/*
+ * A nasty fact of life that the ptrace api
+ * only supports passing of longs.
+ */
+ PT_FPR0=pt_off(fp_regs.fprs[0].d),
+ PT_FPR1=pt_off(fp_regs.fprs[1].d),
+ PT_FPR2=pt_off(fp_regs.fprs[2].d),
+ PT_FPR3=pt_off(fp_regs.fprs[3].d),
+ PT_FPR4=pt_off(fp_regs.fprs[4].d),
+ PT_FPR5=pt_off(fp_regs.fprs[5].d),
+ PT_FPR6=pt_off(fp_regs.fprs[6].d),
+ PT_FPR7=pt_off(fp_regs.fprs[7].d),
+ PT_FPR8=pt_off(fp_regs.fprs[8].d),
+ PT_FPR9=pt_off(fp_regs.fprs[9].d),
+ PT_FPR10=pt_off(fp_regs.fprs[10].d),
+ PT_FPR11=pt_off(fp_regs.fprs[11].d),
+ PT_FPR12=pt_off(fp_regs.fprs[12].d),
+ PT_FPR13=pt_off(fp_regs.fprs[13].d),
+ PT_FPR14=pt_off(fp_regs.fprs[14].d),
+ PT_FPR15=pt_off(fp_regs.fprs[15].d),
+ PT_CR_9=pt_off(per_info.control_regs.words.cr[0]),
+ PT_CR_10=pt_off(per_info.control_regs.words.cr[1]),
+ PT_CR_11=pt_off(per_info.control_regs.words.cr[2]),
+ PT_IEEE_IP=pt_off(ieee_instruction_pointer),
+ PT_LASTOFF=PT_IEEE_IP,
+ PT_ENDREGS=sizeof(user_regs_struct)-1
+};
+
+#define PTRACE_AREA \
+__u32 len; \
+addr_t kernel_addr; \
+addr_t process_addr;
+
+typedef struct
+{
+ PTRACE_AREA
+} ptrace_area;
+
+/*
+ 390 specific non posix ptrace requests
+ I chose unusual values so they are unlikely to clash with future ptrace definitions.
+ */
+#define PTRACE_PEEKUSR_AREA 0x5000
+#define PTRACE_POKEUSR_AREA 0x5001
+#define PTRACE_PEEKTEXT_AREA 0x5002
+#define PTRACE_PEEKDATA_AREA 0x5003
+#define PTRACE_POKETEXT_AREA 0x5004
+#define PTRACE_POKEDATA_AREA 0x5005
+/* PT_PROT definition is loosely based on hppa bsd definition in gdb/hppab-nat.c */
+#define PTRACE_PROT 21
+
+typedef enum
+{
+ ptprot_set_access_watchpoint,
+ ptprot_set_write_watchpoint,
+ ptprot_disable_watchpoint
+} ptprot_flags;
+
+typedef struct
+{
+ addr_t lowaddr;
+ addr_t hiaddr;
+ ptprot_flags prot;
+} ptprot_area;
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/asm-s390x/queue.h b/include/asm-s390x/queue.h
new file mode 100644
index 000000000..c817d23b3
--- /dev/null
+++ b/include/asm-s390x/queue.h
@@ -0,0 +1,170 @@
+/*
+ * include/asm-s390/queue.h
+ *
+ * S390 version
+ * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ *
+ * A little set of queue utilies.
+ */
+#include <linux/stddef.h>
+#include <asm/types.h>
+
+typedef struct queue
+{
+ struct queue *next;
+} queue;
+
+typedef queue list;
+
+typedef struct
+{
+ queue *head;
+ queue *tail;
+} qheader;
+
+static __inline__ void init_queue(qheader *qhead)
+{
+ memset(qhead,0,sizeof(*qhead));
+}
+
+static __inline__ void enqueue_tail(qheader *qhead,queue *member)
+{
+ queue *tail=qhead->tail;
+ member->next=NULL;
+
+ if(member)
+ {
+ if(tail)
+ tail->next=member;
+ else
+
+ qhead->head=member;
+ qhead->tail=member;
+ member->next=NULL;
+ }
+}
+
+static __inline__ queue *dequeue_head(qheader *qhead)
+{
+ queue *head=qhead->head,*next_head;
+
+ if(head)
+ {
+ next_head=head->next;
+ qhead->head=next_head;
+ if(!next_head)
+ qhead->tail=NULL;
+ }
+ return(head);
+}
+
+static __inline__ void init_list(list **lhead)
+{
+ *lhead=NULL;
+}
+
+static __inline__ void add_to_list(list **lhead,list *member)
+{
+ member->next=*lhead;
+ *lhead=member;
+}
+
+static __inline__ list *remove_listhead(list **lhead)
+{
+ list *oldhead=*lhead;
+
+ if(oldhead)
+ *lhead=(*lhead)->next;
+ return(oldhead);
+}
+
+static __inline__ void add_to_list_tail(list **lhead,list *member)
+{
+ list *curr,*prev;
+ if(*lhead==NULL)
+ *lhead=member;
+ else
+ {
+ prev=*lhead;
+ for(curr=(*lhead)->next;curr!=NULL;curr=curr->next)
+ prev=curr;
+ prev->next=member;
+ }
+}
+static __inline__ void add_to_list_tail_null(list **lhead,list *member)
+{
+ member->next=NULL;
+ add_to_list_tail_null(lhead,member);
+}
+
+
+static __inline__ int is_in_list(list *lhead,list *member)
+{
+ list *curr;
+
+ for(curr=lhead;curr!=NULL;curr=curr->next)
+ if(curr==member)
+ return(TRUE);
+ return(FALSE);
+}
+
+static __inline__ int get_prev(list *lhead,list *member,list **prev)
+{
+ list *curr;
+
+ *prev=NULL;
+ for(curr=lhead;curr!=NULL;curr=curr->next)
+ {
+ if(curr==member)
+ return(TRUE);
+ *prev=curr;
+ }
+ *prev=NULL;
+ return(FALSE);
+}
+
+
+
+static __inline__ int remove_from_list(list **lhead,list *member)
+{
+ list *prev;
+
+ if(get_prev(*lhead,member,&prev))
+ {
+
+ if(prev)
+ prev->next=member->next;
+ else
+ *lhead=member->next;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+static __inline__ int remove_from_queue(qheader *qhead,queue *member)
+{
+ queue *prev;
+
+ if(get_prev(qhead->head,(list *)member,(list **)&prev))
+ {
+
+ if(prev)
+ {
+ prev->next=member->next;
+ if(prev->next==NULL)
+ qhead->tail=prev;
+ }
+ else
+ {
+ if(qhead->head==qhead->tail)
+ qhead->tail=NULL;
+ qhead->head=member->next;
+ }
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+
diff --git a/include/asm-s390x/resource.h b/include/asm-s390x/resource.h
new file mode 100644
index 000000000..4e0f8e7ba
--- /dev/null
+++ b/include/asm-s390x/resource.h
@@ -0,0 +1,56 @@
+/*
+ * include/asm-s390/resource.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/resources.h"
+ */
+
+#ifndef _S390_RESOURCE_H
+#define _S390_RESOURCE_H
+
+/*
+ * Resource limits
+ */
+
+#define RLIMIT_CPU 0 /* CPU time in ms */
+#define RLIMIT_FSIZE 1 /* Maximum filesize */
+#define RLIMIT_DATA 2 /* max data size */
+#define RLIMIT_STACK 3 /* max stack size */
+#define RLIMIT_CORE 4 /* max core file size */
+#define RLIMIT_RSS 5 /* max resident set size */
+#define RLIMIT_NPROC 6 /* max number of processes */
+#define RLIMIT_NOFILE 7 /* max number of open files */
+#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */
+#define RLIMIT_AS 9 /* address space limit */
+#define RLIMIT_LOCKS 10 /* maximum file locks held */
+
+#define RLIM_NLIMITS 11
+
+/*
+ * SuS says limits have to be unsigned.
+ * Which makes a ton more sense anyway.
+ */
+#define RLIM_INFINITY (~0UL)
+
+#ifdef __KERNEL__
+
+#define INIT_RLIMITS \
+{ \
+ { RLIM_INFINITY, RLIM_INFINITY }, \
+ { RLIM_INFINITY, RLIM_INFINITY }, \
+ { RLIM_INFINITY, RLIM_INFINITY }, \
+ { _STK_LIM, RLIM_INFINITY }, \
+ { 0, RLIM_INFINITY }, \
+ { RLIM_INFINITY, RLIM_INFINITY }, \
+ { 0, 0 }, \
+ { INR_OPEN, INR_OPEN }, \
+ { RLIM_INFINITY, RLIM_INFINITY }, \
+ { RLIM_INFINITY, RLIM_INFINITY }, \
+ { RLIM_INFINITY, RLIM_INFINITY }, \
+}
+
+#endif /* __KERNEL__ */
+
+#endif
+
diff --git a/include/asm-s390x/s390-gdbregs.h b/include/asm-s390x/s390-gdbregs.h
new file mode 100644
index 000000000..1d94ee78c
--- /dev/null
+++ b/include/asm-s390x/s390-gdbregs.h
@@ -0,0 +1,89 @@
+/*
+ * include/asm-s390/s390-gdbregs.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ *
+ * used both by the linux kernel for remote debugging & gdb
+ */
+
+#ifndef _S390_GDBREGS_H
+#define _S390_GDBREGS_H
+
+#ifdef __KERNEL__
+#include <asm/s390-regs-common.h>
+#else
+#include <s390x/s390-regs-common.h>
+#endif
+#define S390_MAX_INSTR_SIZE 6
+#define NUM_REGS (2+NUM_GPRS+NUM_ACRS+NUM_CRS+1+NUM_FPRS)
+#define FIRST_ACR (2+NUM_GPRS)
+#define LAST_ACR (FIRST_ACR+NUM_ACRS-1)
+#define FIRST_CR (FIRST_ACR+NUM_ACRS)
+#define LAST_CR (FIRST_CR+NUM_CRS-1)
+
+#define PSWM_REGNUM 0
+#define PC_REGNUM 1
+#define GP0_REGNUM 2 /* GPR register 0 */
+#define GP_LAST_REGNUM (GP0_REGNUM+NUM_GPRS-1)
+#define RETADDR_REGNUM (GP0_REGNUM+14) /* Usually return address */
+#define SP_REGNUM (GP0_REGNUM+15) /* Contains address of top of stack */
+#define FP_REGNUM SP_REGNUM /* needed in findvar.c still */
+#define FRAME_REGNUM (GP0_REGNUM+11)
+#define FPC_REGNUM (GP0_REGNUM+NUM_GPRS+NUM_ACRS+NUM_CRS)
+#define FP0_REGNUM (FPC_REGNUM+1) /* FPR (Floating point) register 0 */
+#define FPLAST_REGNUM (FP0_REGNUM+NUM_FPRS-1) /* Last floating point register */
+
+/* The top of this structure is as similar as possible to a pt_regs structure to */
+/* simplify code */
+typedef struct
+{
+ S390_REGS_COMMON
+ __u32 crs[NUM_CRS];
+ s390_fp_regs fp_regs;
+} s390_gdb_regs __attribute__((packed));
+
+#define REGISTER_NAMES \
+{ \
+"pswm","pswa", \
+"gpr0","gpr1","gpr2","gpr3","gpr4","gpr5","gpr6","gpr7", \
+"gpr8","gpr9","gpr10","gpr11","gpr12","gpr13","gpr14","gpr15", \
+"acr0","acr1","acr2","acr3","acr4","acr5","acr6","acr7", \
+"acr8","acr9","acr10","acr11","acr12","acr13","acr14","acr15", \
+"cr0","cr1","cr2","cr3","cr4","cr5","cr6","cr7", \
+"cr8","cr9","cr10","cr11","cr12","cr13","cr14","cr15", \
+"fpc", \
+"fpr0","fpr1","fpr2","fpr3","fpr4","fpr5","fpr6","fpr7", \
+"fpr8","fpr9","fpr10","fpr11","fpr12","fpr13","fpr14","fpr15" \
+}
+
+/* Index within `registers' of the first byte of the space for
+ register N. */
+
+#define ACR0_OFFSET ((PSW_MASK_SIZE+PSW_ADDR_SIZE)+(GPR_SIZE*NUM_GPRS))
+#define CR0_OFFSET (ACR0_OFFSET+(ACR_SIZE+NUM_ACRS))
+#define FPC_OFFSET (CR0_OFFSET+(CR_SIZE*NUM_CRS))
+#define FP0_OFFSET (FPC_OFFSET+(FPC_SIZE+FPC_PAD_SIZE))
+
+#define REGISTER_BYTES \
+((FP0_OFFSET)+(FPR_SIZE*NUM_FPRS))
+
+#define REGISTER_BYTE(N) ((N)<=GP_LAST_REGNUM ? (N)*8: \
+(N) <= LAST_ACR ? (ACR0_OFFSET+(((N)-FIRST_ACR)*ACR_SIZE)): \
+(N) <= LAST_CR ? (CR0_OFFSET+(((N)-FIRST_CR)*CR_SIZE)): \
+(N) == FPC_REGNUM ? FPC_OFFSET:(FP0_OFFSET+(((N)-FP0_REGNUM)*FPR_SIZE)))
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/asm-s390x/s390-regs-common.h b/include/asm-s390x/s390-regs-common.h
new file mode 100644
index 000000000..cd93f3ef4
--- /dev/null
+++ b/include/asm-s390x/s390-regs-common.h
@@ -0,0 +1,115 @@
+/*
+ * include/asm-s390/s390-regs-common.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
+ *
+ * this file is designed to keep as much compatibility between
+ * gdb's representation of registers & the kernels representation of registers
+ * as possible so as to minimise translation between gdb registers &
+ * kernel registers please keep this matched with gdb & strace
+ */
+
+#ifndef _S390_REGS_COMMON_H
+#define _S390_REGS_COMMON_H
+#ifndef __ASSEMBLY__
+#include <asm/types.h>
+#endif
+#if defined(WANT_S390_TGT_DEFS) || defined(__KERNEL__)
+#define REGISTER_SIZE 8
+#endif
+#define NUM_GPRS 16
+#define GPR_SIZE 8
+#define PSW_MASK_SIZE 8
+#define PSW_ADDR_SIZE 8
+#define NUM_FPRS 16
+#define FPR_SIZE 8
+#define FPC_SIZE 4
+#define FPC_PAD_SIZE 4 /* gcc insists on aligning the fpregs */
+#define NUM_CRS 16
+#define CR_SIZE 8
+#define NUM_ACRS 16
+#define ACR_SIZE 4
+
+#define STACK_FRAME_OVERHEAD 160 /* size of minimum stack frame */
+
+#ifndef __ASSEMBLY__
+/* this typedef defines how a Program Status Word looks like */
+typedef struct
+{
+ __u64 mask;
+ __u64 addr;
+} psw_t __attribute__ ((aligned(8)));
+
+typedef __u64 gpr_t;
+
+/* 2 __u32's are used for floats instead to compile with a __STRICT_ANSI__ defined */
+typedef union
+{
+#ifdef __KERNEL__
+ __u64 d; /* mathemu.h gets upset otherwise */
+#else
+ double d; /* ansi c dosen't like long longs & make sure that */
+ /* alignments are identical for both compiles */
+#endif
+ struct
+ {
+ __u32 hi;
+ __u32 lo;
+ } fp;
+ __u32 f;
+} freg_t;
+
+typedef struct
+{
+/*
+ The compiler appears to like aligning freg_t on an 8 byte boundary
+ so I always access fpregs, this was causing fun when I was doing
+ coersions.
+ */
+ __u32 fpc;
+ freg_t fprs[NUM_FPRS];
+} s390_fp_regs;
+
+#define FPC_EXCEPTION_MASK 0xF8000000
+#define FPC_FLAGS_MASK 0x00F80000
+#define FPC_DXC_MASK 0x0000FF00
+#define FPC_RM_MASK 0x00000003
+#define FPC_VALID_MASK ((FPC_EXCEPTION_MASK|FPC_FLAGS_MASK| \
+ FPC_DXC_MASK|FPC_RM_MASK))
+
+
+/*
+ gdb structures & the kernel have this much always in common
+ */
+#define S390_REGS_COMMON \
+psw_t psw; \
+__u64 gprs[NUM_GPRS]; \
+__u32 acrs[NUM_ACRS]; \
+
+typedef struct
+{
+ S390_REGS_COMMON
+} s390_regs_common __attribute__ ((packed));
+
+
+/* Sequence of bytes for breakpoint illegal instruction. */
+#define S390_BREAKPOINT {0x0,0x1}
+#define S390_BREAKPOINT_U16 ((__u16)0x0001)
+#define S390_SYSCALL_OPCODE ((__u16)0x0a00)
+#define S390_SYSCALL_SIZE 2
+#if defined(WANT_S390_TGT_DEFS) || defined(__KERNEL__)
+#define ADDR_BITS_REMOVE(addr) ((addr))
+#endif
+#endif
+#endif
+
+
+
+
+
+
+
+
+
diff --git a/include/asm-s390x/s390_ext.h b/include/asm-s390x/s390_ext.h
new file mode 100644
index 000000000..08a080441
--- /dev/null
+++ b/include/asm-s390x/s390_ext.h
@@ -0,0 +1,30 @@
+#ifndef _S390_EXTINT_H
+#define _S390_EXTINT_H
+
+/*
+ * include/asm-s390/s390_ext.h
+ *
+ * S390 version
+ * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Holger Smolinski (Holger.Smolinski@de.ibm.com),
+ * Martin Schwidefsky (schwidefsky@de.ibm.com)
+ */
+
+typedef void (*ext_int_handler_t)(struct pt_regs *regs, __u16 code);
+
+/*
+ * Warning: if you change ext_int_info_t you have to change the
+ * external interrupt handler in entry.S too.
+ */
+typedef struct ext_int_info_t {
+ struct ext_int_info_t *next;
+ ext_int_handler_t handler;
+ __u16 code;
+} __attribute__ ((packed)) ext_int_info_t;
+
+extern ext_int_info_t *ext_int_hash[];
+
+int register_external_interrupt(__u16 code, ext_int_handler_t handler);
+int unregister_external_interrupt(__u16 code, ext_int_handler_t handler);
+
+#endif
diff --git a/include/asm-s390x/s390dyn.h b/include/asm-s390x/s390dyn.h
new file mode 100644
index 000000000..a728ddf33
--- /dev/null
+++ b/include/asm-s390x/s390dyn.h
@@ -0,0 +1,50 @@
+/*
+ * arch/s390/kernel/s390dyn.h
+ * S/390 data definitions for dynamic device attachment
+ *
+ * S390 version
+ * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Ingo Adlung (adlung@de.ibm.com)
+ */
+
+#ifndef __s390dyn_h
+#define __s390dyn_h
+
+struct _devreg;
+
+typedef int (* oper_handler_func_t)( int irq,
+ struct _devreg *dreg);
+
+typedef struct _devreg_hc_t {
+ __u16 ctype;
+ __u8 cmode;
+ __u16 dtype;
+ __u8 dmode;
+ } __attribute__ ((packed)) devreg_hc_t;
+
+typedef struct _devreg {
+ union {
+ int devno;
+ devreg_hc_t hc; /* has controller info */
+ } ci;
+
+ int flag;
+ oper_handler_func_t oper_func;
+ struct _devreg *prev;
+ struct _devreg *next;
+} devreg_t;
+
+#define DEVREG_EXACT_MATCH 0x00000001
+#define DEVREG_MATCH_DEV_TYPE 0x00000002
+#define DEVREG_MATCH_CU_TYPE 0x00000004
+#define DEVREG_NO_CU_INFO 0x00000008
+#define DEVREG_NO_DEV_INFO 0x00000010
+
+#define DEVREG_TYPE_DEVNO 0x80000000
+#define DEVREG_TYPE_DEVCHARS 0x40000000
+
+int s390_device_register ( devreg_t *drinfo );
+int s390_device_unregister( devreg_t *dreg );
+devreg_t * s390_search_devreg ( ioinfo_t *ioinfo );
+
+#endif /* __s390dyn */
diff --git a/include/asm-s390x/s390io.h b/include/asm-s390x/s390io.h
new file mode 100644
index 000000000..1a5a0f094
--- /dev/null
+++ b/include/asm-s390x/s390io.h
@@ -0,0 +1,95 @@
+/*
+ * arch/s390/kernel/s390io.h
+ *
+ * S390 version
+ * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Ingo Adlung (adlung@de.ibm.com)
+ */
+
+#ifndef __s390io_h
+#define __s390io_h
+
+/*
+ * IRQ data structure used by I/O subroutines
+ *
+ * Note : If bit flags are added, the "unused" value must be
+ * decremented accordingly !
+ */
+typedef struct _ioinfo {
+ unsigned int irq; /* aka. subchannel number */
+ spinlock_t irq_lock; /* irq lock */
+
+ struct _ioinfo *prev;
+ struct _ioinfo *next;
+
+ union {
+ unsigned int info;
+ struct {
+ unsigned int busy : 1; /* device currently in use */
+ unsigned int oper : 1; /* device is operational */
+ unsigned int fast : 1; /* post with "channel end", ... */
+ /* ... don't wait for "device end" */
+ /* ... from do_IO() parameters */
+ unsigned int ready : 1; /* interrupt handler registered */
+ unsigned int haltio : 1; /* halt_IO in process */
+ unsigned int doio : 1; /* do_IO in process */
+ unsigned int doio_q : 1; /* do_IO queued - only possible ... */
+ /* ... if 'fast' is set too */
+ unsigned int w4final : 1; /* wait for final status, internally */
+ /* ... used with 'fast' setting only */
+ unsigned int repall : 1; /* report every interrupt status */
+ unsigned int unready : 1; /* deregister irq handler in process */
+ unsigned int d_disable : 1; /* delayed disabling required */
+ unsigned int w4sense : 1; /* SENSE status pending */
+ unsigned int syncio : 1; /* synchronous I/O requested */
+ unsigned int consns : 1; /* concurrent sense is available */
+ unsigned int delsense : 1; /* delayed SENSE required */
+ unsigned int s_pend : 1; /* status pending condition */
+ unsigned int pgid : 1; /* "path group ID" is valid */
+ unsigned int pgid_supp : 1; /* "path group ID" command is supported */
+ unsigned int esid : 1; /* Ext. SenseID supported by HW */
+ unsigned int rcd : 1; /* RCD supported by HW */
+ unsigned int repnone : 1; /* don't call IRQ handler on interrupt */
+ unsigned int newreq : 1; /* new register interface */
+ unsigned int dval : 1; /* device number valid */
+ unsigned int unknown : 1; /* unknown device - if SenseID failed */
+ unsigned int unused : (sizeof(unsigned int)*8 - 24); /* unused */
+ } __attribute__ ((packed)) flags;
+ } ui;
+
+ unsigned long u_intparm; /* user interruption parameter */
+ senseid_t senseid; /* SenseID info */
+ irq_desc_t irq_desc; /* irq descriptor */
+ not_oper_handler_func_t nopfunc; /* not oper handler */
+ __u8 ulpm; /* logical path mask used for I/O */
+ __u8 opm; /* path mask of operational paths */
+ __u16 devno; /* device number */
+ pgid_t pgid; /* path group ID */
+ schib_t schib; /* subchannel information block */
+ orb_t orb; /* operation request block */
+ devstat_t devstat; /* device status */
+ ccw1_t *qcpa; /* queued channel program */
+ ccw1_t senseccw; /* ccw for sense command */
+ __u8 sense_data[32];/* buffer for basic sense */
+ unsigned int stctl; /* accumulated status control from irb */
+ unsigned long qintparm; /* queued interruption parameter */
+ unsigned long qflag; /* queued flags */
+ __u8 qlpm; /* queued logical path mask */
+ __u32 syncnt; /* sync I/O recursive usage count */
+
+ } __attribute__ ((aligned(8))) ioinfo_t;
+
+#define IOINFO_FLAGS_BUSY 0x80000000
+#define IOINFO_FLAGS_OPER 0x40000000
+#define IOINFO_FLAGS_FAST 0x20000000
+#define IOINFO_FLAGS_READY 0x10000000
+#define IOINFO_FLAGS_HALTIO 0x08000000
+#define IOINFO_FLAGS_DOIO 0x04000000
+#define IOINFO_FLAGS_DOIO_Q 0x02000000
+#define IOINFO_FLAGS_W4FINAL 0x01000000
+#define IOINFO_FLAGS_REPALL 0x00800000
+
+extern ioinfo_t *ioinfo[];
+
+#endif /* __s390io_h */
+
diff --git a/include/asm-s390x/s390mach.h b/include/asm-s390x/s390mach.h
new file mode 100644
index 000000000..961e17ecf
--- /dev/null
+++ b/include/asm-s390x/s390mach.h
@@ -0,0 +1,106 @@
+/*
+ * arch/s390/kernel/s390mach.h
+ * S/390 data definitions for machine check processing
+ *
+ * S390 version
+ * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Ingo Adlung (adlung@de.ibm.com)
+ */
+
+#ifndef __s390mach_h
+#define __s390mach_h
+
+#include <asm/types.h>
+
+typedef struct _mci {
+ __u32 to_be_defined_1 : 9;
+ __u32 cp : 1; /* channel-report pending */
+ __u32 to_be_defined_2 : 22;
+ __u32 to_be_defined_3;
+ } mci_t;
+
+//
+// machine-check-interruption code
+//
+typedef struct _mcic {
+ union _mcc {
+ __u64 mcl; /* machine check int. code - long info */
+ mci_t mcd; /* machine check int. code - details */
+ } mcc;
+} __attribute__ ((packed)) mcic_t;
+
+//
+// Channel Report Word
+//
+typedef struct _crw {
+ __u32 res1 : 1; /* reserved zero */
+ __u32 slct : 1; /* solicited */
+ __u32 oflw : 1; /* overflow */
+ __u32 chn : 1; /* chained */
+ __u32 rsc : 4; /* reporting source code */
+ __u32 anc : 1; /* ancillary report */
+ __u32 res2 : 1; /* reserved zero */
+ __u32 erc : 6; /* error-recovery code */
+ __u32 rsid : 16; /* reporting-source ID */
+} __attribute__ ((packed)) crw_t;
+
+#define CRW_RSC_MONITOR 0x2 /* monitoring facility */
+#define CRW_RSC_SCH 0x3 /* subchannel */
+#define CRW_RSC_CPATH 0x4 /* channel path */
+#define CRW_RSC_CONFIG 0x9 /* configuration-alert facility */
+#define CRW_RSC_CSS 0xB /* channel subsystem */
+
+#define CRW_ERC_EVENT 0x00 /* event information pending */
+#define CRW_ERC_AVAIL 0x01 /* available */
+#define CRW_ERC_INIT 0x02 /* initialized */
+#define CRW_ERC_TERROR 0x03 /* temporary error */
+#define CRW_ERC_IPARM 0x04 /* installed parm initialized */
+#define CRW_ERC_TERM 0x05 /* terminal */
+#define CRW_ERC_PERRN 0x06 /* perm. error, fac. not init */
+#define CRW_ERC_PERRI 0x07 /* perm. error, facility init */
+#define CRW_ERC_PMOD 0x08 /* installed parameters modified */
+
+#define MAX_CRW_PENDING 1024
+#define MAX_MACH_PENDING 1024
+
+//
+// CRW Entry
+//
+typedef struct _crwe {
+ crw_t crw;
+ struct _crwe *crwe_next;
+} __attribute__ ((packed)) crwe_t;
+
+typedef struct _mache {
+ spinlock_t lock;
+ unsigned int status;
+ mcic_t mcic;
+ union _mc {
+ crwe_t *crwe; /* CRW if applicable */
+ } mc;
+ struct _mache *next;
+ struct _mache *prev;
+} mache_t;
+
+#define MCHCHK_STATUS_TO_PROCESS 0x00000001
+#define MCHCHK_STATUS_IN_PROGRESS 0x00000002
+#define MCHCHK_STATUS_WAITING 0x00000004
+
+void s390_init_machine_check( void );
+void s390_do_machine_check ( void );
+void s390_do_crw_pending ( crwe_t *pcrwe );
+
+extern __inline__ int stcrw( __u32 *pcrw )
+{
+ int ccode;
+
+ __asm__ __volatile__(
+ "STCRW 0(%1)\n\t"
+ "IPM %0\n\t"
+ "SRL %0,28\n\t"
+ : "=d" (ccode) : "a" (pcrw)
+ : "cc", "1" );
+ return ccode;
+}
+
+#endif /* __s390mach */
diff --git a/include/asm-s390x/scatterlist.h b/include/asm-s390x/scatterlist.h
new file mode 100644
index 000000000..e9cfe86f6
--- /dev/null
+++ b/include/asm-s390x/scatterlist.h
@@ -0,0 +1,13 @@
+#ifndef _ASMS390X_SCATTERLIST_H
+#define _ASMS390X_SCATTERLIST_H
+
+struct scatterlist {
+ char * address; /* Location data is to be transferred to */
+ char * alt_address; /* Location of actual if address is a
+ * dma indirect buffer. NULL otherwise */
+ unsigned int length;
+};
+
+#define ISA_DMA_THRESHOLD (0xffffffffffffffff)
+
+#endif /* _ASMS390X_SCATTERLIST_H */
diff --git a/include/asm-s390x/segment.h b/include/asm-s390x/segment.h
new file mode 100644
index 000000000..8bfce3475
--- /dev/null
+++ b/include/asm-s390x/segment.h
@@ -0,0 +1,4 @@
+#ifndef _ASM_SEGMENT_H
+#define _ASM_SEGMENT_H
+
+#endif
diff --git a/include/asm-s390x/semaphore-helper.h b/include/asm-s390x/semaphore-helper.h
new file mode 100644
index 000000000..d822e9a80
--- /dev/null
+++ b/include/asm-s390x/semaphore-helper.h
@@ -0,0 +1,100 @@
+/*
+ * include/asm-s390/semaphore-helper.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *
+ * Derived from "include/asm-i386/semaphore-helper.h"
+ * (C) Copyright 1996 Linus Torvalds
+ * (C) Copyright 1999 Andrea Arcangeli
+ */
+
+#ifndef _S390_SEMAPHORE_HELPER_H
+#define _S390_SEMAPHORE_HELPER_H
+
+/*
+ * These two _must_ execute atomically wrt each other.
+ *
+ * This is trivially done with load_locked/store_cond,
+ * but on the x86 we need an external synchronizer.
+ */
+static inline void wake_one_more(struct semaphore * sem)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&semaphore_wake_lock, flags);
+ sem->waking++;
+ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
+}
+
+static inline int waking_non_zero(struct semaphore *sem)
+{
+ unsigned long flags;
+ int ret = 0;
+
+ spin_lock_irqsave(&semaphore_wake_lock, flags);
+ if (sem->waking > 0) {
+ sem->waking--;
+ ret = 1;
+ }
+ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
+ return ret;
+}
+
+/*
+ * waking_non_zero_interruptible:
+ * 1 got the lock
+ * 0 go to sleep
+ * -EINTR interrupted
+ *
+ * If we give up we must undo our count-decrease we previously did in down().
+ * Subtle: up() can continue to happens and increase the semaphore count
+ * even during our critical section protected by the spinlock. So
+ * we must remeber to undo the sem->waking that will be run from
+ * wake_one_more() some time soon, if the semaphore count become > 0.
+ */
+static inline int waking_non_zero_interruptible(struct semaphore *sem,
+ struct task_struct *tsk)
+{
+ unsigned long flags;
+ int ret = 0;
+
+ spin_lock_irqsave(&semaphore_wake_lock, flags);
+ if (sem->waking > 0) {
+ sem->waking--;
+ ret = 1;
+ } else if (signal_pending(tsk)) {
+ if (atomic_inc_and_test_greater_zero(&sem->count))
+ sem->waking--;
+ ret = -EINTR;
+ }
+ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
+ return ret;
+}
+
+/*
+ * waking_non_zero_trylock:
+ * 1 failed to lock
+ * 0 got the lock
+ *
+ * Implementation details are the same of the interruptible case.
+ */
+static inline int waking_non_zero_trylock(struct semaphore *sem)
+{
+ unsigned long flags;
+ int ret = 1;
+
+ spin_lock_irqsave(&semaphore_wake_lock, flags);
+ if (sem->waking <= 0)
+ {
+ if (atomic_inc_and_test_greater_zero(&sem->count))
+ sem->waking--;
+ } else {
+ sem->waking--;
+ ret = 0;
+ }
+ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
+ return ret;
+}
+
+#endif
diff --git a/include/asm-s390x/semaphore.h b/include/asm-s390x/semaphore.h
new file mode 100644
index 000000000..eda753caa
--- /dev/null
+++ b/include/asm-s390x/semaphore.h
@@ -0,0 +1,191 @@
+/*
+ * include/asm-s390/semaphore.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *
+ * Derived from "include/asm-i386/semaphore.h"
+ * (C) Copyright 1996 Linus Torvalds
+ */
+
+#ifndef _S390_SEMAPHORE_H
+#define _S390_SEMAPHORE_H
+
+#include <asm/system.h>
+#include <asm/atomic.h>
+#include <linux/wait.h>
+
+struct semaphore {
+ atomic_t count;
+ int sleepers;
+ wait_queue_head_t wait;
+};
+
+#define __SEM_DEBUG_INIT(name)
+
+#define __SEMAPHORE_INITIALIZER(name,count) \
+{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
+ __SEM_DEBUG_INIT(name) }
+
+#define __MUTEX_INITIALIZER(name) \
+ __SEMAPHORE_INITIALIZER(name,1)
+
+#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
+
+#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+
+static inline void sema_init (struct semaphore *sem, int val)
+{
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
+}
+
+static inline void init_MUTEX (struct semaphore *sem)
+{
+ sema_init(sem, 1);
+}
+
+static inline void init_MUTEX_LOCKED (struct semaphore *sem)
+{
+ sema_init(sem, 0);
+}
+
+asmlinkage void __down_failed(void /* special register calling convention */);
+asmlinkage int __down_failed_interruptible(void /* params in registers */);
+asmlinkage int __down_failed_trylock(void /* params in registers */);
+asmlinkage void __up_wakeup(void /* special register calling convention */);
+
+asmlinkage void __down(struct semaphore * sem);
+asmlinkage int __down_interruptible(struct semaphore * sem);
+asmlinkage int __down_trylock(struct semaphore * sem);
+asmlinkage void __up(struct semaphore * sem);
+
+static inline void down(struct semaphore * sem)
+{
+ if (atomic_dec_return(&sem->count) < 0)
+ __down(sem);
+}
+
+static inline int down_interruptible(struct semaphore * sem)
+{
+ int ret = 0;
+
+ if (atomic_dec_return(&sem->count) < 0)
+ ret = __down_interruptible(sem);
+ return ret;
+}
+
+static inline int down_trylock(struct semaphore * sem)
+{
+ int ret = 0;
+
+ if (atomic_dec_return(&sem->count) < 0)
+ ret = __down_trylock(sem);
+ return ret;
+}
+
+static inline void up(struct semaphore * sem)
+{
+ if (atomic_inc_return(&sem->count) <= 0)
+ __up(sem);
+}
+
+/* rw mutexes (should that be mutices? =) -- throw rw
+ * spinlocks and semaphores together, and this is what we
+ * end up with...
+ *
+ * The lock is initialized to BIAS. This way, a writer
+ * subtracts BIAS ands gets 0 for the case of an uncontended
+ * lock. Readers decrement by 1 and see a positive value
+ * when uncontended, negative if there are writers waiting
+ * (in which case it goes to sleep).
+ *
+ * The value 0x01000000 supports up to 128 processors and
+ * lots of processes. BIAS must be chosen such that subl'ing
+ * BIAS once per CPU will result in the long remaining
+ * negative.
+ *
+ * In terms of fairness, this should result in the lock
+ * flopping back and forth between readers and writers
+ * under heavy use.
+ *
+ * -ben
+ */
+struct rw_semaphore {
+ atomic_t count;
+ volatile unsigned int write_bias_granted;
+ volatile unsigned int read_bias_granted;
+ wait_queue_head_t wait;
+ wait_queue_head_t write_bias_wait;
+};
+
+#define RW_LOCK_BIAS 0x01000000
+
+#define __RWSEM_DEBUG_INIT /* */
+
+#define __RWSEM_INITIALIZER(name,count) \
+{ ATOMIC_INIT(count), 0, 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
+ __WAIT_QUEUE_HEAD_INITIALIZER((name).write_bias_wait) \
+ __SEM_DEBUG_INIT(name) __RWSEM_DEBUG_INIT }
+
+#define __DECLARE_RWSEM_GENERIC(name,count) \
+ struct rw_semaphore name = __RWSEM_INITIALIZER(name,count)
+
+#define DECLARE_RWSEM(name) __DECLARE_RWSEM_GENERIC(name,RW_LOCK_BIAS)
+#define DECLARE_RWSEM_READ_LOCKED(name) __DECLARE_RWSEM_GENERIC(name,RW_LOCK_BIAS-1)
+#define DECLARE_RWSEM_WRITE_LOCKED(name) __DECLARE_RWSEM_GENERIC(name,0)
+
+static inline void init_rwsem(struct rw_semaphore *sem)
+{
+ atomic_set(&sem->count, RW_LOCK_BIAS);
+ sem->read_bias_granted = 0;
+ sem->write_bias_granted = 0;
+ init_waitqueue_head(&sem->wait);
+ init_waitqueue_head(&sem->write_bias_wait);
+}
+
+extern void __down_read_failed(int, struct rw_semaphore *);
+extern void __down_write_failed(int, struct rw_semaphore *);
+extern void __rwsem_wake(int, struct rw_semaphore *);
+
+static inline void down_read(struct rw_semaphore *sem)
+{
+ int count;
+ count = atomic_dec_return(&sem->count);
+ if (count < 0)
+ __down_read_failed(count, sem);
+}
+
+static inline void down_write(struct rw_semaphore *sem)
+{
+ int count;
+ count = atomic_add_return (-RW_LOCK_BIAS, &sem->count);
+ if (count < 0)
+ __down_write_failed(count, sem);
+}
+
+/* When a reader does a release, the only significant
+ * case is when there was a writer waiting, and we've
+ * bumped the count to 0: we must wake the writer up.
+ */
+static inline void up_read(struct rw_semaphore *sem)
+{
+ int count;
+ count = atomic_inc_return(&sem->count);
+ if (count == 0)
+ __rwsem_wake(count, sem);
+}
+
+/* releasing the writer is easy -- just release it and
+ * wake up any sleepers.
+ */
+static inline void up_write(struct rw_semaphore *sem)
+{
+ int count;
+ count = atomic_add_return(RW_LOCK_BIAS, &sem->count);
+ if (count >= 0 && count < RW_LOCK_BIAS)
+ __rwsem_wake(count, sem);
+}
+
+#endif
diff --git a/include/asm-s390x/sembuf.h b/include/asm-s390x/sembuf.h
new file mode 100644
index 000000000..13bba13a2
--- /dev/null
+++ b/include/asm-s390x/sembuf.h
@@ -0,0 +1,22 @@
+#ifndef _S390_SEMBUF_H
+#define _S390_SEMBUF_H
+
+/*
+ * The semid64_ds structure for S/390 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct semid64_ds {
+ struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
+ __kernel_time_t sem_otime; /* last semop time */
+ __kernel_time_t sem_ctime; /* last change time */
+ unsigned long sem_nsems; /* no. of semaphores in array */
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif /* _S390_SEMBUF_H */
diff --git a/include/asm-s390x/setup.h b/include/asm-s390x/setup.h
new file mode 100644
index 000000000..6dda6a54c
--- /dev/null
+++ b/include/asm-s390x/setup.h
@@ -0,0 +1,52 @@
+/*
+ * include/asm-s390/setup.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ */
+
+#ifndef _ASM_S390_SETUP_H
+#define _ASM_S390_SETUP_H
+
+#define PARMAREA 0x10400
+
+#ifndef __ASSEMBLER__
+
+#define ORIG_ROOT_DEV (*(unsigned long *) (0x10400))
+#define MOUNT_ROOT_RDONLY (*(unsigned short *) (0x10408))
+#define MEMORY_SIZE (*(unsigned long *) (0x1040a))
+#define MACHINE_FLAGS (*(unsigned long *) (0x10412))
+#define INITRD_START (*(unsigned long *) (0x1041a))
+#define INITRD_SIZE (*(unsigned long *) (0x10422))
+#define RAMDISK_FLAGS (*(unsigned short *) (0x1042a))
+#define COMMAND_LINE ((char *) (0x10480))
+
+#else
+
+#define ORIG_ROOT_DEV 0x10400
+#define MOUNT_ROOT_RDONLY 0x10408
+#define MEMORY_SIZE 0x1040a
+#define MACHINE_FLAGS 0x10412
+#define INITRD_START 0x1041a
+#define INITRD_SIZE 0x10422
+#define RAMDISK_FLAGS 0x1042a
+#define COMMAND_LINE 0x10480
+
+#endif
+
+#define COMMAND_LINE_SIZE 896
+/*
+ * Machine features detected in head.S
+ */
+#define MACHINE_IS_VM (MACHINE_FLAGS & 1)
+#define MACHINE_IS_P390 (MACHINE_FLAGS & 4)
+
+#define RAMDISK_ORIGIN 0x800000
+#define RAMDISK_SIZE 0x800000
+#define RAMDISK_BLKSIZE 0x1000
+#define RAMDISK_IMAGE_START_MASK 0x07FF
+#define RAMDISK_PROMPT_FLAG 0x8000
+#define RAMDISK_LOAD_FLAG 0x4000
+
+
+#endif
diff --git a/include/asm-s390x/shmbuf.h b/include/asm-s390x/shmbuf.h
new file mode 100644
index 000000000..0fbcdef50
--- /dev/null
+++ b/include/asm-s390x/shmbuf.h
@@ -0,0 +1,38 @@
+#ifndef _S390_SHMBUF_H
+#define _S390_SHMBUF_H
+
+/*
+ * The shmid64_ds structure for S/390 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct shmid64_ds {
+ struct ipc64_perm shm_perm; /* operation perms */
+ size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_time_t shm_atime; /* last attach time */
+ __kernel_time_t shm_dtime; /* last detach time */
+ __kernel_time_t shm_ctime; /* last change time */
+ __kernel_pid_t shm_cpid; /* pid of creator */
+ __kernel_pid_t shm_lpid; /* pid of last operator */
+ unsigned long shm_nattch; /* no. of current attaches */
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+struct shminfo64 {
+ unsigned long shmmax;
+ unsigned long shmmin;
+ unsigned long shmmni;
+ unsigned long shmseg;
+ unsigned long shmall;
+ unsigned long __unused1;
+ unsigned long __unused2;
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#endif /* _S390_SHMBUF_H */
diff --git a/include/asm-s390x/shmparam.h b/include/asm-s390x/shmparam.h
new file mode 100644
index 000000000..c2e0c0508
--- /dev/null
+++ b/include/asm-s390x/shmparam.h
@@ -0,0 +1,13 @@
+/*
+ * include/asm-s390/shmparam.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/shmparam.h"
+ */
+#ifndef _ASM_S390_SHMPARAM_H
+#define _ASM_S390_SHMPARAM_H
+
+#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
+
+#endif /* _ASM_S390_SHMPARAM_H */
diff --git a/include/asm-s390x/sigcontext.h b/include/asm-s390x/sigcontext.h
new file mode 100644
index 000000000..68aaebfbe
--- /dev/null
+++ b/include/asm-s390x/sigcontext.h
@@ -0,0 +1,56 @@
+/*
+ * include/asm-s390/sigcontext.h
+ *
+ * S390 version
+ * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ */
+
+#ifndef _ASM_S390_SIGCONTEXT_H
+#define _ASM_S390_SIGCONTEXT_H
+
+#define __NUM_GPRS 16
+#define __NUM_FPRS 16
+#define __NUM_ACRS 16
+
+/* Has to be at least _NSIG_WORDS from asm/signal.h */
+#define _SIGCONTEXT_NSIG 64
+#define _SIGCONTEXT_NSIG_BPW 64
+/* Size of stack frame allocated when calling signal handler. */
+#define __SIGNAL_FRAMESIZE 160
+#define _SIGCONTEXT_NSIG_WORDS (_SIGCONTEXT_NSIG / _SIGCONTEXT_NSIG_BPW)
+#define _SIGMASK_COPY_SIZE (sizeof(unsigned long)*_SIGCONTEXT_NSIG_WORDS)
+
+typedef struct
+{
+ unsigned long mask;
+ unsigned long addr;
+} _psw_t __attribute__ ((aligned(8)));
+
+typedef struct
+{
+ _psw_t psw;
+ unsigned long gprs[__NUM_GPRS];
+ unsigned int acrs[__NUM_ACRS];
+} _s390_regs_common __attribute__ ((packed));
+
+typedef struct
+{
+ unsigned int fpc;
+ double fprs[__NUM_FPRS];
+} _s390_fp_regs;
+
+typedef struct
+{
+ _s390_regs_common regs;
+ _s390_fp_regs fpregs;
+} _sigregs;
+
+struct sigcontext
+{
+ unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS];
+ _sigregs *sregs;
+};
+
+
+#endif
+
diff --git a/include/asm-s390x/siginfo.h b/include/asm-s390x/siginfo.h
new file mode 100644
index 000000000..876e8baae
--- /dev/null
+++ b/include/asm-s390x/siginfo.h
@@ -0,0 +1,240 @@
+/*
+ * include/asm-s390/siginfo.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/siginfo.h"
+ */
+
+#ifndef _S390_SIGINFO_H
+#define _S390_SIGINFO_H
+
+#include <linux/types.h>
+
+/* XXX: This structure was copied from the Alpha; is there an iBCS version? */
+
+typedef union sigval {
+ int sival_int;
+ void *sival_ptr;
+} sigval_t;
+
+#define SI_MAX_SIZE 128
+#define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3)
+
+typedef struct siginfo {
+ int si_signo;
+ int si_errno;
+ int si_code;
+
+ union {
+ int _pad[SI_PAD_SIZE];
+
+ /* kill() */
+ struct {
+ pid_t _pid; /* sender's pid */
+ uid_t _uid; /* sender's uid */
+ } _kill;
+
+ /* POSIX.1b timers */
+ struct {
+ unsigned int _timer1;
+ unsigned int _timer2;
+ } _timer;
+
+ /* POSIX.1b signals */
+ struct {
+ pid_t _pid; /* sender's pid */
+ uid_t _uid; /* sender's uid */
+ sigval_t _sigval;
+ } _rt;
+
+ /* SIGCHLD */
+ struct {
+ pid_t _pid; /* which child */
+ uid_t _uid; /* sender's uid */
+ int _status; /* exit code */
+ clock_t _utime;
+ clock_t _stime;
+ } _sigchld;
+
+ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
+ struct {
+ void *_addr; /* faulting insn/memory ref. */
+ } _sigfault;
+
+ /* SIGPOLL */
+ struct {
+ int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
+ int _fd;
+ } _sigpoll;
+ } _sifields;
+} siginfo_t;
+
+/*
+ * How these fields are to be accessed.
+ */
+#define si_pid _sifields._kill._pid
+#define si_uid _sifields._kill._uid
+#define si_status _sifields._sigchld._status
+#define si_utime _sifields._sigchld._utime
+#define si_stime _sifields._sigchld._stime
+#define si_value _sifields._rt._sigval
+#define si_int _sifields._rt._sigval.sival_int
+#define si_ptr _sifields._rt._sigval.sival_ptr
+#define si_addr _sifields._sigfault._addr
+#define si_band _sifields._sigpoll._band
+#define si_fd _sifields._sigpoll._fd
+
+#ifdef __KERNEL__
+#define __SI_MASK 0xffff0000
+#define __SI_KILL (0 << 16)
+#define __SI_TIMER (1 << 16)
+#define __SI_POLL (2 << 16)
+#define __SI_FAULT (3 << 16)
+#define __SI_CHLD (4 << 16)
+#define __SI_RT (5 << 16)
+#define __SI_CODE(T,N) ((T) << 16 | ((N) & 0xffff))
+#else
+#define __SI_KILL 0
+#define __SI_TIMER 0
+#define __SI_POLL 0
+#define __SI_FAULT 0
+#define __SI_CHLD 0
+#define __SI_RT 0
+#define __SI_CODE(T,N) (N)
+#endif
+
+/*
+ * si_code values
+ * Digital reserves positive values for kernel-generated signals.
+ */
+#define SI_USER 0 /* sent by kill, sigsend, raise */
+#define SI_KERNEL 0x80 /* sent by the kernel from somewhere */
+#define SI_QUEUE -1 /* sent by sigqueue */
+#define SI_TIMER -2 /* sent by timer expiration */
+#define SI_MESGQ -3 /* sent by real time mesq state change */
+#define SI_ASYNCIO -4 /* sent by AIO completion */
+#define SI_SIGIO -5 /* sent by queued SIGIO */
+
+#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
+#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
+
+/*
+ * SIGILL si_codes
+ */
+#define ILL_ILLOPC 1 /* illegal opcode */
+#define ILL_ILLOPN 2 /* illegal operand */
+#define ILL_ILLADR 3 /* illegal addressing mode */
+#define ILL_ILLTRP 4 /* illegal trap */
+#define ILL_PRVOPC 5 /* privileged opcode */
+#define ILL_PRVREG 6 /* privileged register */
+#define ILL_COPROC 7 /* coprocessor error */
+#define ILL_BADSTK 8 /* internal stack error */
+#define NSIGILL 8
+
+/*
+ * SIGFPE si_codes
+ */
+#define FPE_INTDIV 1 /* integer divide by zero */
+#define FPE_INTOVF 2 /* integer overflow */
+#define FPE_FLTDIV 3 /* floating point divide by zero */
+#define FPE_FLTOVF 4 /* floating point overflow */
+#define FPE_FLTUND 5 /* floating point underflow */
+#define FPE_FLTRES 6 /* floating point inexact result */
+#define FPE_FLTINV 7 /* floating point invalid operation */
+#define FPE_FLTSUB 8 /* subscript out of range */
+#define NSIGFPE 8
+
+/*
+ * SIGSEGV si_codes
+ */
+#define SEGV_MAPERR 1 /* address not mapped to object */
+#define SEGV_ACCERR 2 /* invalid permissions for mapped object */
+#define NSIGSEGV 2
+
+/*
+ * SIGBUS si_codes
+ */
+#define BUS_ADRALN 1 /* invalid address alignment */
+#define BUS_ADRERR 2 /* non-existant physical address */
+#define BUS_OBJERR 3 /* object specific hardware error */
+#define NSIGBUS 3
+
+/*
+ * SIGTRAP si_codes
+ */
+#define TRAP_BRKPT 1 /* process breakpoint */
+#define TRAP_TRACE 2 /* process trace trap */
+#define NSIGTRAP 2
+
+/*
+ * SIGCHLD si_codes
+ */
+#define CLD_EXITED 1 /* child has exited */
+#define CLD_KILLED 2 /* child was killed */
+#define CLD_DUMPED 3 /* child terminated abnormally */
+#define CLD_TRAPPED 4 /* traced child has trapped */
+#define CLD_STOPPED 5 /* child has stopped */
+#define CLD_CONTINUED 6 /* stopped child has continued */
+#define NSIGCHLD
+
+/*
+ * SIGPOLL si_codes
+ */
+#define POLL_IN 1 /* data input available */
+#define POLL_OUT 2 /* output buffers available */
+#define POLL_MSG 3 /* input message available */
+#define POLL_ERR 4 /* i/o error */
+#define POLL_PRI 5 /* high priority input available */
+#define POLL_HUP 6 /* device disconnected */
+#define NSIGPOLL 6
+
+/*
+ * sigevent definitions
+ *
+ * It seems likely that SIGEV_THREAD will have to be handled from
+ * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
+ * thread manager then catches and does the appropriate nonsense.
+ * However, everything is written out here so as to not get lost.
+ */
+#define SIGEV_SIGNAL 0 /* notify via signal */
+#define SIGEV_NONE 1 /* other notification: meaningless */
+#define SIGEV_THREAD 2 /* deliver via thread creation */
+
+#define SIGEV_MAX_SIZE 64
+#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
+
+typedef struct sigevent {
+ sigval_t sigev_value;
+ int sigev_signo;
+ int sigev_notify;
+ union {
+ int _pad[SIGEV_PAD_SIZE];
+
+ struct {
+ void (*_function)(sigval_t);
+ void *_attribute; /* really pthread_attr_t */
+ } _sigev_thread;
+ } _sigev_un;
+} sigevent_t;
+
+#define sigev_notify_function _sigev_un._sigev_thread._function
+#define sigev_notify_attributes _sigev_un._sigev_thread._attribute
+
+#ifdef __KERNEL__
+#include <linux/string.h>
+
+extern inline void copy_siginfo(siginfo_t *to, siginfo_t *from)
+{
+ if (from->si_code < 0)
+ memcpy(to, from, sizeof(siginfo_t));
+ else
+ /* _sigchld is currently the largest know union member */
+ memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld));
+}
+
+extern int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from);
+
+#endif /* __KERNEL__ */
+
+#endif
diff --git a/include/asm-s390x/signal.h b/include/asm-s390x/signal.h
new file mode 100644
index 000000000..e849415cc
--- /dev/null
+++ b/include/asm-s390x/signal.h
@@ -0,0 +1,185 @@
+/*
+ * include/asm-s390/signal.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/signal.h"
+ */
+
+#ifndef _ASMS390_SIGNAL_H
+#define _ASMS390_SIGNAL_H
+
+#include <linux/types.h>
+
+/* Avoid too many header ordering problems. */
+struct siginfo;
+
+#ifdef __KERNEL__
+/* Most things should be clean enough to redefine this at will, if care
+ is taken to make libc match. */
+#include <asm/sigcontext.h>
+#define _NSIG _SIGCONTEXT_NSIG
+#define _NSIG_BPW _SIGCONTEXT_NSIG_BPW
+#define _NSIG_WORDS _SIGCONTEXT_NSIG_WORDS
+
+typedef unsigned long old_sigset_t; /* at least 32 bits */
+
+typedef struct {
+ unsigned long sig[_NSIG_WORDS];
+} sigset_t;
+
+#else
+/* Here we must cater to libcs that poke about in kernel headers. */
+
+#define NSIG 32
+typedef unsigned long sigset_t;
+
+#endif /* __KERNEL__ */
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGIOT 6
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL SIGIO
+/*
+#define SIGLOST 29
+*/
+#define SIGPWR 30
+#define SIGUNUSED 31
+
+/* These should not be considered constants from userland. */
+#define SIGRTMIN 32
+#define SIGRTMAX (_NSIG-1)
+
+/*
+ * SA_FLAGS values:
+ *
+ * SA_ONSTACK indicates that a registered stack_t will be used.
+ * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
+ * SA_RESTART flag to get restarting signals (which were the default long ago)
+ * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
+ * SA_RESETHAND clears the handler when the signal is delivered.
+ * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
+ * SA_NODEFER prevents the current signal from being masked in the handler.
+ *
+ * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
+ * Unix names RESETHAND and NODEFER respectively.
+ */
+#define SA_NOCLDSTOP 0x00000001
+#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
+#define SA_SIGINFO 0x00000004
+#define SA_ONSTACK 0x08000000
+#define SA_RESTART 0x10000000
+#define SA_NODEFER 0x40000000
+#define SA_RESETHAND 0x80000000
+
+#define SA_NOMASK SA_NODEFER
+#define SA_ONESHOT SA_RESETHAND
+#define SA_INTERRUPT 0x20000000 /* dummy -- ignored */
+
+#define SA_RESTORER 0x04000000
+
+/*
+ * sigaltstack controls
+ */
+#define SS_ONSTACK 1
+#define SS_DISABLE 2
+
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+
+#ifdef __KERNEL__
+
+/*
+ * These values of sa_flags are used only by the kernel as part of the
+ * irq handling routines.
+ *
+ * SA_INTERRUPT is also used by the irq handling routines.
+ * SA_SHIRQ is for shared interrupt support on PCI and EISA.
+ */
+#define SA_PROBE SA_ONESHOT
+#define SA_SAMPLE_RANDOM SA_RESTART
+#define SA_SHIRQ 0x04000000
+#endif
+
+#define SIG_BLOCK 0 /* for blocking signals */
+#define SIG_UNBLOCK 1 /* for unblocking signals */
+#define SIG_SETMASK 2 /* for setting the signal mask */
+
+/* Type of a signal handler. */
+typedef void (*__sighandler_t)(int);
+
+#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
+#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
+#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
+
+#ifdef __KERNEL__
+struct old_sigaction {
+ __sighandler_t sa_handler;
+ old_sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+struct sigaction {
+ __sighandler_t sa_handler;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+ sigset_t sa_mask; /* mask last for extensibility */
+};
+
+struct k_sigaction {
+ struct sigaction sa;
+};
+#else
+/* Here we must cater to libcs that poke about in kernel headers. */
+
+struct sigaction {
+ union {
+ __sighandler_t _sa_handler;
+ void (*_sa_sigaction)(int, struct siginfo *, void *);
+ } _u;
+ sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+#define sa_handler _u._sa_handler
+#define sa_sigaction _u._sa_sigaction
+
+#endif /* __KERNEL__ */
+
+typedef struct sigaltstack {
+ void *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+} stack_t;
+
+
+#endif
diff --git a/include/asm-s390x/sigp.h b/include/asm-s390x/sigp.h
new file mode 100644
index 000000000..6835d5df7
--- /dev/null
+++ b/include/asm-s390x/sigp.h
@@ -0,0 +1,159 @@
+/*
+ * include/asm-s390/sigp.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
+ * Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * sigp.h by D.J. Barrow (c) IBM 1999
+ * contains routines / structures for signalling other S/390 processors in an
+ * SMP configuration.
+ */
+
+#ifndef __SIGP__
+#define __SIGP__
+
+#include <asm/ptrace.h>
+#include <asm/misc390.h>
+#include <asm/atomic.h>
+
+/* get real cpu address from logical cpu number */
+extern volatile int __cpu_logical_map[];
+
+typedef enum
+{
+ sigp_unassigned=0x0,
+ sigp_sense,
+ sigp_external_call,
+ sigp_emergency_signal,
+ sigp_start,
+ sigp_stop,
+ sigp_restart,
+ sigp_unassigned1,
+ sigp_unassigned2,
+ sigp_stop_and_store_status,
+ sigp_unassigned3,
+ sigp_initial_cpu_reset,
+ sigp_cpu_reset,
+ sigp_set_prefix,
+ sigp_store_status_at_address,
+ sigp_store_extended_status_at_address
+} sigp_order_code;
+
+typedef __u32 sigp_status_word;
+
+typedef enum
+{
+ sigp_order_code_accepted=0,
+ sigp_status_stored,
+ sigp_busy,
+ sigp_not_operational
+} sigp_ccode;
+
+
+/*
+ * Definitions for the external call
+ */
+
+/* 'Bit' signals, asynchronous */
+typedef enum
+{
+ ec_schedule=0,
+ ec_restart,
+ ec_halt,
+ ec_power_off,
+ ec_bit_last
+} ec_bit_sig;
+
+/* Signals which come with a parameter area */
+typedef enum
+{
+ ec_callback_sync,
+ ec_callback_async
+} ec_cmd_sig;
+
+/* state information for signals */
+typedef enum
+{
+ ec_pending,
+ ec_executing,
+ ec_done
+} ec_state;
+
+/* header for the queuing of callbacks */
+typedef struct ec_ext_call
+{
+ ec_cmd_sig cmd;
+ atomic_t status;
+ struct ec_ext_call *next;
+ void (*func)(void *info);
+ void *info;
+} ec_ext_call;
+
+/*
+ * Signal processor
+ */
+extern __inline__ sigp_ccode
+signal_processor(__u16 cpu_addr, sigp_order_code order_code)
+{
+ sigp_ccode ccode;
+
+ __asm__ __volatile__(
+ " sgr 1,1\n" /* parameter=0 in gpr 1 */
+ " sigp 1,%1,0(%2)\n"
+ " ipm %0\n"
+ " srl %0,28"
+ : "=d" (ccode)
+ : "d" (__cpu_logical_map[cpu_addr]), "a" (order_code)
+ : "cc" , "memory", "1" );
+ return ccode;
+}
+
+/*
+ * Signal processor with parameter
+ */
+extern __inline__ sigp_ccode
+signal_processor_p(__u64 parameter,__u16 cpu_addr,sigp_order_code order_code)
+{
+ sigp_ccode ccode;
+
+ __asm__ __volatile__(
+ " lgr 1,%1\n" /* parameter in gpr 1 */
+ " sigp 1,%2,0(%3)\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ : "=d" (ccode)
+ : "d" (parameter), "d" (__cpu_logical_map[cpu_addr]),
+ "a" (order_code)
+ : "cc" , "memory", "1" );
+ return ccode;
+}
+
+/*
+ * Signal processor with parameter and return status
+ */
+extern __inline__ sigp_ccode
+signal_processor_ps(__u32 *statusptr, __u64 parameter,
+ __u16 cpu_addr, sigp_order_code order_code)
+{
+ sigp_ccode ccode;
+
+ __asm__ __volatile__(
+ " sgr 2,2\n" /* clear status so it doesn't contain rubbish if not saved. */
+ " lgr 3,%2\n" /* parameter in gpr 3 */
+ " sigp 2,%3,0(%4)\n"
+ " stg 2,%1\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ : "=d" (ccode), "=m" (*statusptr)
+ : "d" (parameter), "d" (__cpu_logical_map[cpu_addr]),
+ "a" (order_code)
+ : "cc" , "memory", "2" , "3"
+ );
+ return ccode;
+}
+
+#endif __SIGP__
+
+
diff --git a/include/asm-s390x/smp.h b/include/asm-s390x/smp.h
new file mode 100644
index 000000000..fe723f044
--- /dev/null
+++ b/include/asm-s390x/smp.h
@@ -0,0 +1,78 @@
+/*
+ * include/asm-s390/smp.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
+ * Martin Schwidefsky (schwidefsky@de.ibm.com)
+ */
+#ifndef __ASM_SMP_H
+#define __ASM_SMP_H
+#include <linux/config.h>
+#ifdef CONFIG_SMP
+#ifndef __ASSEMBLY__
+
+#include <asm/lowcore.h>
+#include <linux/kernel.h> // FOR FASTCALL definition
+
+#define smp_processor_id() (current->processor)
+#define NO_PROC_ID 0xFF /* No processor magic marker */
+
+/*
+ * This magic constant controls our willingness to transfer
+ * a process across CPUs. Such a transfer incurs misses on the L1
+ * cache, and on a P6 or P5 with multiple L2 caches L2 hits. My
+ * gut feeling is this will vary by board in value. For a board
+ * with separate L2 cache it probably depends also on the RSS, and
+ * for a board with shared L2 cache it ought to decay fast as other
+ * processes are run.
+ */
+
+#define PROC_CHANGE_PENALTY 20 /* Schedule penalty */
+
+extern void count_cpus(void);
+
+extern __inline__ int cpu_logical_map(int cpu)
+{
+ return cpu;
+}
+
+extern __inline__ int cpu_number_map(int cpu)
+{
+ return cpu;
+}
+
+extern __inline__ __u16 hard_smp_processor_id(void)
+{
+ __u16 cpu_address;
+
+ __asm__ ("stap %0\n" : "=m" (cpu_address));
+ return cpu_address;
+}
+
+#define cpu_logical_map(cpu) (cpu)
+
+void smp_local_timer_interrupt(struct pt_regs * regs);
+
+/*
+ s390 specific smp.c headers
+ */
+typedef struct
+{
+ int intresting;
+ sigp_ccode ccode;
+ __u32 status;
+ __u16 cpu;
+} sigp_info;
+
+sigp_ccode
+smp_ext_call(int cpu, void (*callback)(void *info), void *info, int wait);
+void smp_ext_call_others(void (*callback)(void *info), void *info, int wait);
+sigp_ccode smp_ext_bitcall(int cpu, ec_bit_sig sig);
+void smp_ext_bitcall_others(ec_bit_sig sig);
+
+int smp_signal_others(sigp_order_code order_code,__u32 parameter,
+ int spin,sigp_info *info);
+#endif
+#endif
+#endif
diff --git a/include/asm-s390x/smplock.h b/include/asm-s390x/smplock.h
new file mode 100644
index 000000000..1f6485fb0
--- /dev/null
+++ b/include/asm-s390x/smplock.h
@@ -0,0 +1,62 @@
+/*
+ * include/asm-s390/smplock.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/smplock.h"
+ */
+
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+
+extern spinlock_t kernel_flag;
+
+#define kernel_locked() spin_is_locked(&kernel_flag)
+
+/*
+ * Release global kernel lock and global interrupt lock
+ */
+#define release_kernel_lock(task, cpu) \
+do { \
+ if (task->lock_depth >= 0) \
+ spin_unlock(&kernel_flag); \
+ release_irqlock(cpu); \
+ __sti(); \
+} while (0)
+
+/*
+ * Re-acquire the kernel lock
+ */
+#define reacquire_kernel_lock(task) \
+do { \
+ if (task->lock_depth >= 0) \
+ spin_lock(&kernel_flag); \
+} while (0)
+
+
+/*
+ * Getting the big kernel lock.
+ *
+ * This cannot happen asynchronously,
+ * so we only need to worry about other
+ * CPU's.
+ */
+/*
+ * Getting the big kernel lock.
+ *
+ * This cannot happen asynchronously,
+ * so we only need to worry about other
+ * CPU's.
+ */
+extern __inline__ void lock_kernel(void)
+{
+ if (!++current->lock_depth)
+ spin_lock(&kernel_flag);
+}
+
+extern __inline__ void unlock_kernel(void)
+{
+ if (--current->lock_depth < 0)
+ spin_unlock(&kernel_flag);
+}
+
diff --git a/include/asm-s390x/socket.h b/include/asm-s390x/socket.h
new file mode 100644
index 000000000..0d00c3b54
--- /dev/null
+++ b/include/asm-s390x/socket.h
@@ -0,0 +1,69 @@
+/*
+ * include/asm-s390/socket.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/socket.h"
+ */
+
+#ifndef _ASM_SOCKET_H
+#define _ASM_SOCKET_H
+
+#include <asm/sockios.h>
+
+/* For setsockoptions(2) */
+#define SOL_SOCKET 1
+
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+#define SO_BSDCOMPAT 14
+/* To add :#define SO_REUSEPORT 15 */
+#define SO_PASSCRED 16
+#define SO_PEERCRED 17
+#define SO_RCVLOWAT 18
+#define SO_SNDLOWAT 19
+#define SO_RCVTIMEO 20
+#define SO_SNDTIMEO 21
+
+/* Security levels - as per NRL IPv6 - don't actually do anything */
+#define SO_SECURITY_AUTHENTICATION 22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
+#define SO_SECURITY_ENCRYPTION_NETWORK 24
+
+#define SO_BINDTODEVICE 25
+
+/* Socket filtering */
+#define SO_ATTACH_FILTER 26
+#define SO_DETACH_FILTER 27
+
+#define SO_PEERNAME 28
+#define SO_TIMESTAMP 29
+#define SCM_TIMESTAMP SO_TIMESTAMP
+
+/* Nast libc5 fixup - bletch */
+#if defined(__KERNEL__)
+/* Socket types. */
+#define SOCK_STREAM 1 /* stream (connection) socket */
+#define SOCK_DGRAM 2 /* datagram (conn.less) socket */
+#define SOCK_RAW 3 /* raw socket */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequential packet socket */
+#define SOCK_PACKET 10 /* linux specific way of */
+ /* getting packets at the dev */
+ /* level. For writing rarp and */
+ /* other similar things on the */
+ /* user level. */
+#endif
+
+#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-s390x/sockios.h b/include/asm-s390x/sockios.h
new file mode 100644
index 000000000..412aeb4dd
--- /dev/null
+++ b/include/asm-s390x/sockios.h
@@ -0,0 +1,20 @@
+/*
+ * include/asm-s390/sockios.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/sockios.h"
+ */
+
+#ifndef __ARCH_S390_SOCKIOS__
+#define __ARCH_S390_SOCKIOS__
+
+/* Socket-level I/O control calls. */
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906 /* Get stamp */
+
+#endif
diff --git a/include/asm-s390x/softirq.h b/include/asm-s390x/softirq.h
new file mode 100644
index 000000000..ce1254eba
--- /dev/null
+++ b/include/asm-s390x/softirq.h
@@ -0,0 +1,35 @@
+/*
+ * include/asm-s390/softirq.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/softirq.h"
+ */
+
+#ifndef __ASM_SOFTIRQ_H
+#define __ASM_SOFTIRQ_H
+
+#ifndef __LINUX_SMP_H
+#include <linux/smp.h>
+#endif
+
+#include <asm/atomic.h>
+#include <asm/hardirq.h>
+#include <asm/lowcore.h>
+
+#define cpu_bh_disable(cpu) do { local_bh_count(cpu)++; barrier(); } while (0)
+#define cpu_bh_enable(cpu) do { barrier(); local_bh_count(cpu)--; } while (0)
+
+#define local_bh_disable() cpu_bh_disable(smp_processor_id())
+#define local_bh_enable() cpu_bh_enable(smp_processor_id())
+
+#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+
+#endif /* __ASM_SOFTIRQ_H */
+
+
+
+
+
+
+
diff --git a/include/asm-s390x/spinlock.h b/include/asm-s390x/spinlock.h
new file mode 100644
index 000000000..260be9b71
--- /dev/null
+++ b/include/asm-s390x/spinlock.h
@@ -0,0 +1,119 @@
+/*
+ * include/asm-s390/spinlock.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/spinlock.h"
+ */
+
+#ifndef __ASM_SPINLOCK_H
+#define __ASM_SPINLOCK_H
+
+/*
+ * Simple spin lock operations. There are two variants, one clears IRQ's
+ * on the local processor, one does not.
+ *
+ * We make no fairness assumptions. They have a cost.
+ */
+
+typedef struct {
+ volatile unsigned int lock;
+} spinlock_t __attribute__ ((aligned (8)));
+
+#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
+#define spin_lock_init(lp) do { (lp)->lock = 0; } while(0)
+#define spin_unlock_wait(lp) do { barrier(); } while(((volatile spinlock_t *)(lp))->lock)
+#define spin_is_locked(x) ((x)->lock != 0)
+
+extern inline void spin_lock(spinlock_t *lp)
+{
+ __asm__ __volatile(" bras 1,1f\n"
+ "0: # diag 0,0,68\n"
+ "1: slr 0,0\n"
+ " cs 0,1,%1\n"
+ " jl 0b\n"
+ : "=m" (lp->lock)
+ : "0" (lp->lock) : "0", "1", "cc" );
+}
+
+extern inline int spin_trylock(spinlock_t *lp)
+{
+ unsigned int result;
+ __asm__ __volatile(" slr %1,%1\n"
+ " basr 1,0\n"
+ "0: cs %1,1,%0"
+ : "=m" (lp->lock), "=&d" (result)
+ : "0" (lp->lock) : "1", "cc" );
+ return !result;
+}
+
+extern inline void spin_unlock(spinlock_t *lp)
+{
+ __asm__ __volatile(" xc 0(4,%0),0(%0)\n"
+ " bcr 15,0"
+ : /* no output */ : "a" (lp) : "memory", "cc" );
+}
+
+/*
+ * Read-write spinlocks, allowing multiple readers
+ * but only one writer.
+ *
+ * NOTE! it is quite common to have readers in interrupts
+ * but no interrupt writers. For those circumstances we
+ * can "mix" irq-safe locks - any writer needs to get a
+ * irq-safe write-lock, but readers can get non-irqsafe
+ * read-locks.
+ */
+typedef struct {
+ volatile unsigned long lock;
+ volatile unsigned long owner_pc;
+} rwlock_t;
+
+#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
+
+#define read_lock(rw) \
+ asm volatile(" la 1,%0\n" \
+ " lg 2,0(1)\n" \
+ " j 1f\n" \
+ "0: # diag 0,0,68\n" \
+ "1: nihh 2,0x7fff\n" /* clear high (=write) bit */ \
+ " la 3,1(2)\n" /* one more reader */ \
+ " csg 2,3,0(1)\n" /* try to write new value */ \
+ " jl 0b" \
+ : "+m" ((rw)->lock) : : "1", "2", "3", "cc" );
+
+#define read_unlock(rw) \
+ asm volatile(" la 1,%0\n" \
+ " lg 2,0(1)\n" \
+ " j 1f\n" \
+ "0: # diag 0,0,68\n" \
+ "1: lgr 3,2\n" \
+ " bctgr 3,0\n" /* one less reader */ \
+ " csg 2,3,0(1)\n" \
+ " jl 0b" \
+ : "+m" ((rw)->lock) : : "1", "2", "3", "cc" );
+
+#define write_lock(rw) \
+ asm volatile(" la 1,%0\n" \
+ " llihh 3,0x8000\n" /* new lock value = 0x80...0 */ \
+ " j 1f\n" \
+ "0: # diag 0,0,68\n" \
+ "1: slgr 2,2\n" /* old lock value must be 0 */ \
+ " csg 2,3,0(1)\n" \
+ " jl 0b" \
+ : "+m" ((rw)->lock) : : "1", "2", "3", "cc" );
+
+#define write_unlock(rw) \
+ asm volatile(" la 1,%0\n" \
+ " slgr 3,3\n" /* new lock value = 0 */ \
+ " j 1f\n" \
+ "0: # diag 0,0,68\n" \
+ "1: llihh 2,0x8000\n" /* old lock value must be 0x8..0 */\
+ " csg 2,3,0(1)\n" \
+ " jl 0b" \
+ : "+m" ((rw)->lock) : : "1", "2", "3", "cc" );
+
+#endif /* __ASM_SPINLOCK_H */
+
diff --git a/include/asm-s390x/stat.h b/include/asm-s390x/stat.h
new file mode 100644
index 000000000..6973d5cf4
--- /dev/null
+++ b/include/asm-s390x/stat.h
@@ -0,0 +1,33 @@
+/*
+ * include/asm-s390x/stat.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/stat.h"
+ */
+
+#ifndef _S390_STAT_H
+#define _S390_STAT_H
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad1;
+ unsigned long st_rdev;
+ unsigned long st_size;
+ unsigned long st_atime;
+ unsigned long __reserved0; /* reserved for atime.nanoseconds */
+ unsigned long st_mtime;
+ unsigned long __reserved1; /* reserved for mtime.nanoseconds */
+ unsigned long st_ctime;
+ unsigned long __reserved2; /* reserved for ctime.nanoseconds */
+ unsigned long st_blksize;
+ long st_blocks;
+ unsigned long __unused[3];
+};
+
+#endif
diff --git a/include/asm-s390x/statfs.h b/include/asm-s390x/statfs.h
new file mode 100644
index 000000000..900d00e54
--- /dev/null
+++ b/include/asm-s390x/statfs.h
@@ -0,0 +1,33 @@
+/*
+ * include/asm-s390/statfs.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/statfs.h"
+ */
+
+#ifndef _S390_STATFS_H
+#define _S390_STATFS_H
+
+#ifndef __KERNEL_STRICT_NAMES
+
+#include <linux/types.h>
+
+typedef __kernel_fsid_t fsid_t;
+
+#endif
+
+struct statfs {
+ int f_type;
+ int f_bsize;
+ long f_blocks;
+ long f_bfree;
+ long f_bavail;
+ long f_files;
+ long f_ffree;
+ __kernel_fsid_t f_fsid;
+ int f_namelen;
+ int f_spare[6];
+};
+
+#endif
diff --git a/include/asm-s390x/string.h b/include/asm-s390x/string.h
new file mode 100644
index 000000000..84a173bc4
--- /dev/null
+++ b/include/asm-s390x/string.h
@@ -0,0 +1,121 @@
+/*
+ * include/asm-s390/string.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
+ */
+
+#ifndef _S390_STRING_H_
+#define _S390_STRING_H_
+
+#ifdef __KERNEL__
+
+#ifndef _LINUX_TYPES_H
+#include <linux/types.h>
+#endif
+
+#define __HAVE_ARCH_MEMCHR
+#define __HAVE_ARCH_MEMCPY
+#define __HAVE_ARCH_MEMSET
+#define __HAVE_ARCH_STRCAT
+#define __HAVE_ARCH_STRCMP
+#define __HAVE_ARCH_STRCPY
+#define __HAVE_ARCH_STRLEN
+#define __HAVE_ARCH_STRNCPY
+
+#undef __HAVE_ARCH_MEMMOVE
+#undef __HAVE_ARCH_STRNICMP
+#undef __HAVE_ARCH_STRNCAT
+#undef __HAVE_ARCH_STRNCMP
+#undef __HAVE_ARCH_STRCHR
+#undef __HAVE_ARCH_STRRCHR
+#undef __HAVE_ARCH_STRNLEN
+#undef __HAVE_ARCH_STRSPN
+#undef __HAVE_ARCH_STRPBRK
+#undef __HAVE_ARCH_STRTOK
+#undef __HAVE_ARCH_BCOPY
+#undef __HAVE_ARCH_MEMCMP
+#undef __HAVE_ARCH_MEMSCAN
+#undef __HAVE_ARCH_STRSTR
+
+extern void *memset(void *, int, size_t);
+extern void *memcpy(void *, const void *, size_t);
+extern void *memmove(void *, const void *, size_t);
+extern char *strncpy(char *, const char *, size_t);
+extern int strcmp(const char *,const char *);
+
+#undef __HAVE_ARCH_MEMCHR
+#if 0
+static inline void * memchr(const void * cs,int c,size_t count)
+{
+ void *ptr;
+
+ __asm__ __volatile__ (" lgr 0,%2\n"
+ " lgr 1,%1\n"
+ " la %0,0(%3,%1)\n"
+ "0: srst %0,1\n"
+ " jo 0b\n"
+ " brc 13,1f\n"
+ " slgr %0,%0\n"
+ "1:"
+ : "=&a" (ptr) : "a" (cs), "d" (c), "d" (count)
+ : "cc", "0", "1" );
+ return ptr;
+}
+#endif
+
+static __inline__ char *strcpy(char *dest, const char *src)
+{
+ char *tmp = dest;
+
+ __asm__ __volatile__ (" slgr 0,0\n"
+ "0: mvst %0,%1\n"
+ " jo 0b"
+ : "+&a" (dest), "+&a" (src) :
+ : "cc", "memory", "0" );
+ return tmp;
+}
+
+#undef __HAVE_ARCH_STRLEN
+#if 0
+static __inline__ size_t strlen(const char *s)
+{
+ size_t len;
+
+ __asm__ __volatile__ (" slgr 0,0\n"
+ " lgr %0,%1\n"
+ "0: srst 0,%0\n"
+ " jo 0b\n"
+ " lgr %0,0\n"
+ " sgr %0,%1"
+ : "=&a" (len) : "a" (s)
+ : "cc", "0" );
+ return len;
+}
+#endif
+
+#undef __HAVE_ARCH_STRCAT
+#if 0
+static __inline__ char *strcat(char *dest, const char *src)
+{
+ char *tmp = dest;
+
+ __asm__ __volatile__ (" slgr 0,0\n"
+ "0: srst 0,%0\n"
+ " jo 0b\n"
+ " lgr %0,0\n"
+ " slgr 0,0\n"
+ "1: mvst %0,%1\n"
+ " jo 1b"
+ : "+&a" (dest), "+&a" (src) :
+ : "cc", "memory", "0" );
+ return tmp;
+}
+#endif
+
+extern void *alloca(size_t);
+#endif /* __KERNEL__ */
+
+#endif /* __S390_STRING_H_ */
+
diff --git a/include/asm-s390x/system.h b/include/asm-s390x/system.h
new file mode 100644
index 000000000..9d77dbc68
--- /dev/null
+++ b/include/asm-s390x/system.h
@@ -0,0 +1,264 @@
+/*
+ * include/asm-s390/system.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
+ *
+ * Derived from "include/asm-i386/system.h"
+ */
+
+#ifndef __ASM_SYSTEM_H
+#define __ASM_SYSTEM_H
+
+#include <linux/config.h>
+#ifdef __KERNEL__
+#include <asm/lowcore.h>
+#endif
+#include <linux/kernel.h>
+
+#define prepare_to_switch() do { } while(0)
+#define switch_to(prev,next,last) do { \
+ if (prev == next) \
+ break; \
+ save_fp_regs(&prev->thread.fp_regs); \
+ restore_fp_regs(&next->thread.fp_regs); \
+ last = resume(&prev->thread,&next->thread); \
+} while (0)
+
+struct task_struct;
+
+#define nop() __asm__ __volatile__ ("nop")
+
+#define xchg(ptr,x) \
+ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(void *)(ptr),sizeof(*(ptr))))
+
+
+static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
+{
+ switch (size) {
+ case 1:
+ asm volatile (
+ " lghi 1,3\n"
+ " nr 1,%0\n" /* isolate last 2 bits */
+ " xr %0,1\n" /* align ptr */
+ " bras 2,0f\n"
+ " icm 1,8,%1\n" /* for ptr&3 == 0 */
+ " stcm 0,8,%1\n"
+ " icm 1,4,%1\n" /* for ptr&3 == 1 */
+ " stcm 0,4,%1\n"
+ " icm 1,2,%1\n" /* for ptr&3 == 2 */
+ " stcm 0,2,%1\n"
+ " icm 1,1,%1\n" /* for ptr&3 == 3 */
+ " stcm 0,1,%1\n"
+ "0: sll 1,3\n"
+ " la 2,0(1,2)\n" /* r2 points to an icm */
+ " l 0,0(%0)\n" /* get fullword */
+ "1: lr 1,0\n" /* cs loop */
+ " ex 0,0(2)\n" /* insert x */
+ " cs 0,1,0(%0)\n"
+ " jl 1b\n"
+ " ex 0,4(2)" /* store *ptr to x */
+ : "+&a" (ptr), "+m" (x) :
+ : "memory", "0", "1", "2");
+ case 2:
+ if(((addr_t)ptr)&1)
+ panic("misaligned (__u16 *) in __xchg\n");
+ asm volatile (
+ " lghi 1,2\n"
+ " nr 1,%0\n" /* isolate bit 2^1 */
+ " xr %0,1\n" /* align ptr */
+ " bras 2,0f\n"
+ " icm 1,12,%1\n" /* for ptr&2 == 0 */
+ " stcm 0,12,%1\n"
+ " icm 1,3,%1\n" /* for ptr&2 == 1 */
+ " stcm 0,3,%1\n"
+ "0: sll 1,2\n"
+ " la 2,0(1,2)\n" /* r2 points to an icm */
+ " l 0,0(%0)\n" /* get fullword */
+ "1: lr 1,0\n" /* cs loop */
+ " ex 0,0(2)\n" /* insert x */
+ " cs 0,1,0(%0)\n"
+ " jl 1b\n"
+ " ex 0,4(2)" /* store *ptr to x */
+ : "+&a" (ptr), "+m" (x) :
+ : "memory", "0", "1", "2");
+ break;
+ case 4:
+ if(((addr_t)ptr)&3)
+ panic("misaligned (__u32 *) in __xchg\n");
+ asm volatile (
+ " l 0,0(%1)\n"
+ "0: cs 0,%0,0(%1)\n"
+ " jl 0b\n"
+ " lgfr %0,0\n"
+ : "+d" (x) : "a" (ptr)
+ : "memory", "0" );
+ break;
+ case 8:
+ if(((addr_t)ptr)&7)
+ panic("misaligned (__u64 *) in __xchg\n");
+ asm volatile (
+ " lg 0,0(%1)\n"
+ "0: csg 0,%0,0(%1)\n"
+ " jl 0b\n"
+ " lgr %0,0\n"
+ : "+d" (x) : "a" (ptr)
+ : "memory", "0" );
+ break;
+ default:
+ abort();
+ }
+ return x;
+}
+
+/*
+ * 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")
+# define SYNC_OTHER_CORES(x) eieio()
+#define mb() eieio()
+#define rmb() eieio()
+#define wmb() eieio()
+#define smp_mb() mb()
+#define smp_rmb() rmb()
+#define smp_wmb() wmb()
+#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)
+#define set_wmb(var, value) do { var = value; wmb(); } while (0)
+
+/* interrupt control.. */
+#define __sti() ({ \
+ unsigned long dummy; \
+ __asm__ __volatile__ ( \
+ "stosm %0,0x03" : "=m" (dummy) : : "memory"); \
+ })
+
+#define __cli() ({ \
+ unsigned long flags; \
+ __asm__ __volatile__ ( \
+ "stnsm %0,0xFC" : "=m" (flags) : : "memory"); \
+ flags; \
+ })
+
+#define __save_flags(x) \
+ __asm__ __volatile__("stosm %0,0" : "=m" (x) : : "memory")
+
+#define __restore_flags(x) \
+ __asm__ __volatile__("ssm %0" : : "m" (x) : "memory")
+
+#define __load_psw(psw) \
+ __asm__ __volatile__("lpswe %0" : : "m" (psw));
+
+#define __ctl_load(array, low, high) ({ \
+ __asm__ __volatile__ ( \
+ " la 1,%0\n" \
+ " bras 2,0f\n" \
+ " lctlg 0,0,0(1)\n" \
+ "0: ex %1,0(2)" \
+ : : "m" (array), "a" (((low)<<4)+(high)) : "1", "2" ); \
+ })
+
+#define __ctl_store(array, low, high) ({ \
+ __asm__ __volatile__ ( \
+ " la 1,%0\n" \
+ " bras 2,0f\n" \
+ " stctg 0,0,0(1)\n" \
+ "0: ex %1,0(2)" \
+ : "=m" (array) : "a" (((low)<<4)+(high)): "1", "2" ); \
+ })
+
+#define __ctl_set_bit(cr, bit) ({ \
+ __u8 dummy[24]; \
+ __asm__ __volatile__ ( \
+ " la 1,%0\n" /* align to 8 byte */ \
+ " aghi 1,7\n" \
+ " nill 1,0xfff8\n" \
+ " bras 2,0f\n" /* skip indirect insns */ \
+ " stctg 0,0,0(1)\n" \
+ " lctlg 0,0,0(1)\n" \
+ "0: ex %1,0(2)\n" /* execute stctl */ \
+ " lg 0,0(1)\n" \
+ " ogr 0,%2\n" /* set the bit */ \
+ " stg 0,0(1)\n" \
+ "1: ex %1,6(2)" /* execute lctl */ \
+ : "=m" (dummy) : "a" (cr*17), "a" (1L<<(bit)) \
+ : "0", "1", "2"); \
+ })
+
+#define __ctl_clear_bit(cr, bit) ({ \
+ __u8 dummy[24]; \
+ __asm__ __volatile__ ( \
+ " la 1,%0\n" /* align to 8 byte */ \
+ " aghi 1,7\n" \
+ " nill 1,0xfff8\n" \
+ " bras 2,0f\n" /* skip indirect insns */ \
+ " stctg 0,0,0(1)\n" \
+ " lctlg 0,0,0(1)\n" \
+ "0: ex %1,0(2)\n" /* execute stctl */ \
+ " lg 0,0(1)\n" \
+ " ngr 0,%2\n" /* set the bit */ \
+ " stg 0,0(1)\n" \
+ "1: ex %1,6(2)" /* execute lctl */ \
+ : "=m" (dummy) : "a" (cr*17), "a" (~(1L<<(bit))) \
+ : "0", "1", "2"); \
+ })
+
+/* For spinlocks etc */
+#define local_irq_save(x) ((x) = __cli())
+#define local_irq_restore(x) __restore_flags(x)
+#define local_irq_disable() __cli()
+#define local_irq_enable() __sti()
+
+#ifdef CONFIG_SMP
+
+extern void __global_cli(void);
+extern void __global_sti(void);
+
+extern unsigned long __global_save_flags(void);
+extern void __global_restore_flags(unsigned long);
+#define cli() __global_cli()
+#define sti() __global_sti()
+#define save_flags(x) ((x)=__global_save_flags())
+#define restore_flags(x) __global_restore_flags(x)
+
+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 cli() __cli()
+#define sti() __sti()
+#define save_flags(x) __save_flags(x)
+#define restore_flags(x) __restore_flags(x)
+
+#define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
+#define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
+
+
+#endif
+
+#ifdef __KERNEL__
+extern struct task_struct *resume(void *,void *);
+
+extern int save_fp_regs1(s390_fp_regs *fpregs);
+extern void save_fp_regs(s390_fp_regs *fpregs);
+extern int restore_fp_regs1(s390_fp_regs *fpregs);
+extern void restore_fp_regs(s390_fp_regs *fpregs);
+#endif
+
+#endif
+
+
+
diff --git a/include/asm-s390x/termbits.h b/include/asm-s390x/termbits.h
new file mode 100644
index 000000000..cfbe7a36a
--- /dev/null
+++ b/include/asm-s390x/termbits.h
@@ -0,0 +1,180 @@
+/*
+ * include/asm-s390/termbits.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/termbits.h"
+ */
+
+#ifndef __ARCH_S390_TERMBITS_H__
+#define __ARCH_S390_TERMBITS_H__
+
+#include <linux/posix_types.h>
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 19
+struct termios {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_line; /* line discipline */
+ cc_t c_cc[NCCS]; /* control characters */
+};
+
+/* c_cc characters */
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+
+/* c_iflag bits */
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+
+/* c_oflag bits */
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#define NLDLY 0000400
+#define NL0 0000000
+#define NL1 0000400
+#define CRDLY 0003000
+#define CR0 0000000
+#define CR1 0001000
+#define CR2 0002000
+#define CR3 0003000
+#define TABDLY 0014000
+#define TAB0 0000000
+#define TAB1 0004000
+#define TAB2 0010000
+#define TAB3 0014000
+#define XTABS 0014000
+#define BSDLY 0020000
+#define BS0 0000000
+#define BS1 0020000
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+#define FFDLY 0100000
+#define FF0 0000000
+#define FF1 0100000
+
+/* c_cflag bit meaning */
+#define CBAUD 0010017
+#define B0 0000000 /* hang up */
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#define EXTA B19200
+#define EXTB B38400
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+#define CBAUDEX 0010000
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B500000 0010005
+#define B576000 0010006
+#define B921600 0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+#define CIBAUD 002003600000 /* input baud rate (not used) */
+#define CMSPAR 010000000000 /* mark or space (stick) parity */
+#define CRTSCTS 020000000000 /* flow control */
+
+/* c_lflag bits */
+#define ISIG 0000001
+#define ICANON 0000002
+#define XCASE 0000004
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#define ECHOCTL 0001000
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
+#define FLUSHO 0010000
+#define PENDIN 0040000
+#define IEXTEN 0100000
+
+/* tcflow() and TCXONC use these */
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+/* tcflush() and TCFLSH use these */
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+/* tcsetattr uses these */
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+#endif
diff --git a/include/asm-s390x/termios.h b/include/asm-s390x/termios.h
new file mode 100644
index 000000000..bab0d5947
--- /dev/null
+++ b/include/asm-s390x/termios.h
@@ -0,0 +1,114 @@
+/*
+ * include/asm-s390/termios.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/termios.h"
+ */
+
+#ifndef _S390_TERMIOS_H
+#define _S390_TERMIOS_H
+
+#include <asm/termbits.h>
+#include <asm/ioctls.h>
+
+
+struct winsize {
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
+};
+
+#define NCC 8
+struct termio {
+ unsigned short c_iflag; /* input mode flags */
+ unsigned short c_oflag; /* output mode flags */
+ unsigned short c_cflag; /* control mode flags */
+ unsigned short c_lflag; /* local mode flags */
+ unsigned char c_line; /* line discipline */
+ unsigned char c_cc[NCC]; /* control characters */
+};
+
+/* modem lines */
+#define TIOCM_LE 0x001
+#define TIOCM_DTR 0x002
+#define TIOCM_RTS 0x004
+#define TIOCM_ST 0x008
+#define TIOCM_SR 0x010
+#define TIOCM_CTS 0x020
+#define TIOCM_CAR 0x040
+#define TIOCM_RNG 0x080
+#define TIOCM_DSR 0x100
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_OUT1 0x2000
+#define TIOCM_OUT2 0x4000
+#define TIOCM_LOOP 0x8000
+
+/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
+
+/* line disciplines */
+#define N_TTY 0
+#define N_SLIP 1
+#define N_MOUSE 2
+#define N_PPP 3
+#define N_STRIP 4
+#define N_AX25 5
+#define N_X25 6 /* X.25 async */
+#define N_6PACK 7
+#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
+#define N_R3964 9 /* Reserved for Simatic R3964 module */
+#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
+#define N_IRDA 11 /* Linux IR - http://www.cs.uit.no/~dagb/irda/irda.html */
+#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
+#define N_HDLC 13 /* synchronous HDLC */
+
+#ifdef __KERNEL__
+
+/* intr=^C quit=^\ erase=del kill=^U
+ eof=^D vtime=\0 vmin=\1 sxtc=\0
+ start=^Q stop=^S susp=^Z eol=\0
+ reprint=^R discard=^U werase=^W lnext=^V
+ eol2=\0
+*/
+#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
+
+/*
+ * Translate a "termio" structure into a "termios". Ugh.
+ */
+
+#define user_termio_to_kernel_termios(termios, termio) \
+({ \
+ unsigned short tmp; \
+ get_user(tmp, &(termio)->c_iflag); \
+ (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
+ get_user(tmp, &(termio)->c_oflag); \
+ (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
+ get_user(tmp, &(termio)->c_cflag); \
+ (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
+ get_user(tmp, &(termio)->c_lflag); \
+ (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
+ get_user((termios)->c_line, &(termio)->c_line); \
+ copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
+})
+
+/*
+ * Translate a "termios" structure into a "termio". Ugh.
+ */
+#define kernel_termios_to_user_termio(termio, termios) \
+({ \
+ put_user((termios)->c_iflag, &(termio)->c_iflag); \
+ put_user((termios)->c_oflag, &(termio)->c_oflag); \
+ put_user((termios)->c_cflag, &(termio)->c_cflag); \
+ put_user((termios)->c_lflag, &(termio)->c_lflag); \
+ put_user((termios)->c_line, &(termio)->c_line); \
+ copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
+})
+
+#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
+#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
+
+#endif /* __KERNEL__ */
+
+#endif /* _S390_TERMIOS_H */
diff --git a/include/asm-s390x/timex.h b/include/asm-s390x/timex.h
new file mode 100644
index 000000000..ad97e0eda
--- /dev/null
+++ b/include/asm-s390x/timex.h
@@ -0,0 +1,29 @@
+/*
+ * include/asm-s390/timex.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *
+ * Derived from "include/asm-i386/timex.h"
+ * Copyright (C) 1992, Linus Torvalds
+ */
+
+#ifndef _ASM_S390_TIMEX_H
+#define _ASM_S390_TIMEX_H
+
+#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
+#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
+#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
+ (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
+ << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
+
+typedef unsigned long cycles_t;
+
+extern cycles_t cacheflush_time;
+
+static inline cycles_t get_cycles(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/include/asm-s390x/todclk.h b/include/asm-s390x/todclk.h
new file mode 100644
index 000000000..92a27a9d4
--- /dev/null
+++ b/include/asm-s390x/todclk.h
@@ -0,0 +1,19 @@
+/*
+ * File...........: linux/include/asm/todclk.h
+ * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
+ * Bugreports.to..: <Linux390@de.ibm.com>
+ * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
+ *
+ * History of changes (starts July 2000)
+ */
+
+#ifndef __ASM_TODCLK_H
+#define __ASM_TODCLK_H
+
+#define TOD_uSEC (0x1000ULL)
+#define TOD_mSEC (1000 * TOD_uSEC)
+#define TOD_SEC (1000 * TOD_mSEC)
+#define TOD_MIN (60 * TOD_SEC)
+#define TOD_HOUR (60 * TOD_MIN)
+
+#endif
diff --git a/include/asm-s390x/types.h b/include/asm-s390x/types.h
new file mode 100644
index 000000000..b3eca30be
--- /dev/null
+++ b/include/asm-s390x/types.h
@@ -0,0 +1,69 @@
+/*
+ * include/asm-s390/types.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/types.h"
+ */
+
+#ifndef _S390_TYPES_H
+#define _S390_TYPES_H
+
+typedef unsigned short umode_t;
+
+/*
+ * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
+ * header files exported to user space
+ */
+
+typedef __signed__ char __s8;
+typedef unsigned char __u8;
+
+typedef __signed__ short __s16;
+typedef unsigned short __u16;
+
+typedef __signed__ int __s32;
+typedef unsigned int __u32;
+
+typedef __signed__ long __s64;
+typedef unsigned long __u64;
+
+/*
+ * A address type so that arithmetic can be done on it & it can be upgraded to
+ * 64 bit when neccessary
+ */
+
+typedef unsigned long addr_t;
+typedef signed long saddr_t;
+
+/*
+ * These aren't exported outside the kernel to avoid name space clashes
+ */
+#ifdef __KERNEL__
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long s64;
+typedef unsigned long u64;
+
+#define BITS_PER_LONG 64
+
+typedef u32 dma_addr_t;
+
+#endif /* __KERNEL__ */
+#endif
diff --git a/include/asm-s390x/uaccess.h b/include/asm-s390x/uaccess.h
new file mode 100644
index 000000000..419d87afc
--- /dev/null
+++ b/include/asm-s390x/uaccess.h
@@ -0,0 +1,559 @@
+/*
+ * include/asm-s390/uaccess.h
+ *
+ * S390 version
+ * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Hartmut Penner (hpenner@de.ibm.com),
+ * Martin Schwidefsky (schwidefsky@de.ibm.com)
+ *
+ * Derived from "include/asm-i386/uaccess.h"
+ */
+#ifndef __S390_UACCESS_H
+#define __S390_UACCESS_H
+
+/*
+ * User space memory access functions
+ */
+#include <linux/sched.h>
+
+#define VERIFY_READ 0
+#define VERIFY_WRITE 1
+
+
+/*
+ * The fs value determines whether argument validity checking should be
+ * performed or not. If get_fs() == USER_DS, checking is performed, with
+ * get_fs() == KERNEL_DS, checking is bypassed.
+ *
+ * For historical reasons, these macros are grossly misnamed.
+ */
+
+#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
+
+
+#define KERNEL_DS MAKE_MM_SEG(0)
+#define USER_DS MAKE_MM_SEG(1)
+
+#define get_ds() (KERNEL_DS)
+#define get_fs() (current->addr_limit)
+#define set_fs(x) ({asm volatile("sar 4,%0"::"a" ((x).ar4));\
+ current->addr_limit = (x);})
+
+#define segment_eq(a,b) ((a).ar4 == (b).ar4)
+
+
+#define __access_ok(addr,size) (1)
+
+#define access_ok(type,addr,size) __access_ok(addr,size)
+
+extern inline int verify_area(int type, const void * addr, unsigned long size)
+{
+ return access_ok(type,addr,size)?0:-EFAULT;
+}
+
+/*
+ * The exception table consists of pairs of addresses: the first is the
+ * address of an instruction that is allowed to fault, and the second is
+ * the address at which the program should continue. No registers are
+ * modified, so it is entirely up to the continuation code to figure out
+ * what to do.
+ *
+ * All the routines below use bits of fixup code that are out of line
+ * with the main instruction path. This means when everything is well,
+ * we don't even have to jump over them. Further, they do not intrude
+ * on our cache or tlb entries.
+ */
+
+struct exception_table_entry
+{
+ unsigned long insn, fixup;
+};
+
+/* Returns 0 if exception not found and fixup otherwise. */
+extern unsigned long search_exception_table(unsigned long);
+
+
+/*
+ * These are the main single-value transfer routines. They automatically
+ * use the right size if we just have the right pointer type.
+ */
+
+extern inline int __put_user_asm_8(__u64 x, void *ptr)
+{
+ int err;
+
+ __asm__ __volatile__ ( " sr %1,%1\n"
+ " la 4,%0\n"
+ " sacf 512\n"
+ "0: stg %2,0(4)\n"
+ "1: sacf 0\n"
+ ".section .fixup,\"ax\"\n"
+ "2: lhi %1,%h3\n"
+ " jg 1b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,2b\n"
+ ".previous"
+ : "=m" (*((__u64*) ptr)) , "=&d" (err)
+ : "d" (x), "K" (-EFAULT)
+ : "4" );
+ return err;
+}
+extern inline int __put_user_asm_4(__u32 x, void *ptr)
+{
+ int err;
+
+ __asm__ __volatile__ ( " sr %1,%1\n"
+ " la 4,%0\n"
+ " sacf 512\n"
+ "0: st %2,0(4)\n"
+ "1: sacf 0\n"
+ ".section .fixup,\"ax\"\n"
+ "2: lhi %1,%h3\n"
+ " jg 1b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,2b\n"
+ ".previous"
+ : "=m" (*((__u32*) ptr)) , "=&d" (err)
+ : "d" (x), "K" (-EFAULT)
+ : "4" );
+ return err;
+}
+
+extern inline int __put_user_asm_2(__u16 x, void *ptr)
+{
+ int err;
+
+ __asm__ __volatile__ ( " sr %1,%1\n"
+ " la 4,%0\n"
+ " sacf 512\n"
+ "0: sth %2,0(4)\n"
+ "1: sacf 0\n"
+ ".section .fixup,\"ax\"\n"
+ "2: lhi %1,%h3\n"
+ " jg 1b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,2b\n"
+ ".previous"
+ : "=m" (*((__u16*) ptr)) , "=&d" (err)
+ : "d" (x), "K" (-EFAULT)
+ : "4" );
+ return err;
+}
+
+extern inline int __put_user_asm_1(__u8 x, void *ptr)
+{
+ int err;
+
+ __asm__ __volatile__ ( " sr %1,%1\n"
+ " la 4,%0\n"
+ " sacf 512\n"
+ "0: stc %2,0(4)\n"
+ "1: sacf 0\n"
+ ".section .fixup,\"ax\"\n"
+ "2: lhi %1,%h3\n"
+ " jg 1b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,2b\n"
+ ".previous"
+ : "=m" (*((__u8*) ptr)) , "=&d" (err)
+ : "d" (x), "K" (-EFAULT)
+ : "1", "4" );
+ return err;
+}
+
+/*
+ * (u?)(u64) ... autsch, but that the only way we can suppress the
+ * warnings when compiling binfmt_elf.c
+ */
+#define __put_user(x, ptr) \
+({ \
+ int __pu_err; \
+ switch (sizeof (*(ptr))) { \
+ case 1: \
+ __pu_err = __put_user_asm_1((__u8)(__u64)(x),(ptr));\
+ break; \
+ case 2: \
+ __pu_err = __put_user_asm_2((__u16)(__u64)(x),(ptr));\
+ break; \
+ case 4: \
+ __pu_err = __put_user_asm_4((__u32)(__u64)(x),(ptr));\
+ break; \
+ case 8: \
+ __pu_err = __put_user_asm_8((__u64)(x),(ptr));\
+ break; \
+ default: \
+ __pu_err = __put_user_bad(); \
+ break; \
+ } \
+ __pu_err; \
+})
+
+#define put_user(x, ptr) \
+({ \
+ long __pu_err = -EFAULT; \
+ __typeof__(*(ptr)) *__pu_addr = (ptr); \
+ __typeof__(*(ptr)) __x = (x); \
+ if (__access_ok((long)__pu_addr,sizeof(*(ptr)))) { \
+ __pu_err = 0; \
+ __put_user((__x), (__pu_addr)); \
+ } \
+ __pu_err; \
+})
+
+extern int __put_user_bad(void);
+
+
+#define __get_user_asm_8(x, ptr, err) \
+({ \
+ __asm__ __volatile__ ( " sr %1,%1\n" \
+ " la 4,%2\n" \
+ " sacf 512\n" \
+ "0: lg %0,0(4)\n" \
+ "1: sacf 0\n" \
+ ".section .fixup,\"ax\"\n" \
+ "2: lhi %1,%h3\n" \
+ " jg 1b\n" \
+ ".previous\n" \
+ ".section __ex_table,\"a\"\n" \
+ " .align 8\n" \
+ " .quad 0b,2b\n" \
+ ".previous" \
+ : "=d" (x) , "=&d" (err) \
+ : "m" (*(const __u64*)(ptr)),"K" (-EFAULT) \
+ : "4" ); \
+})
+#define __get_user_asm_4(x, ptr, err) \
+({ \
+ __asm__ __volatile__ ( " sr %1,%1\n" \
+ " la 4,%2\n" \
+ " sacf 512\n" \
+ "0: l %0,0(4)\n" \
+ "1: sacf 0\n" \
+ ".section .fixup,\"ax\"\n" \
+ "2: lhi %1,%h3\n" \
+ " jg 1b\n" \
+ ".previous\n" \
+ ".section __ex_table,\"a\"\n" \
+ " .align 8\n" \
+ " .quad 0b,2b\n" \
+ ".previous" \
+ : "=d" (x) , "=&d" (err) \
+ : "m" (*(const __u32*)(ptr)),"K" (-EFAULT) \
+ : "4" ); \
+})
+
+#define __get_user_asm_2(x, ptr, err) \
+({ \
+ __asm__ __volatile__ ( " sr %1,%1\n" \
+ " la 4,%2\n" \
+ " sacf 512\n" \
+ "0: lh %0,0(4)\n" \
+ "1: sacf 0\n" \
+ ".section .fixup,\"ax\"\n" \
+ "2: lhi %1,%h3\n" \
+ " jg 1b\n" \
+ ".previous\n" \
+ ".section __ex_table,\"a\"\n" \
+ " .align 8\n" \
+ " .quad 0b,2b\n" \
+ ".previous" \
+ : "=d" (x) , "=&d" (err) \
+ : "m" (*(const __u16*)(ptr)),"K" (-EFAULT) \
+ : "4" ); \
+})
+
+#define __get_user_asm_1(x, ptr, err) \
+({ \
+ __asm__ __volatile__ ( " sr %1,%1\n" \
+ " la 4,%2\n" \
+ " sr %0,%0\n" \
+ " sacf 512\n" \
+ "0: ic %0,0(4)\n" \
+ "1: sacf 0\n" \
+ ".section .fixup,\"ax\"\n" \
+ "2: lhi %1,%h3\n" \
+ " jg 1b\n" \
+ ".previous\n" \
+ ".section __ex_table,\"a\"\n" \
+ " .align 8\n" \
+ " .quad 0b,2b\n" \
+ ".previous" \
+ : "=d" (x) , "=&d" (err) \
+ : "m" (*(const __u8*)(ptr)),"K" (-EFAULT) \
+ : "4" ); \
+})
+
+#define __get_user(x, ptr) \
+({ \
+ int __gu_err; \
+ switch (sizeof(*(ptr))) { \
+ case 1: \
+ __get_user_asm_1(x,ptr,__gu_err); \
+ break; \
+ case 2: \
+ __get_user_asm_2(x,ptr,__gu_err); \
+ break; \
+ case 4: \
+ __get_user_asm_4(x,ptr,__gu_err); \
+ break; \
+ case 8: \
+ __get_user_asm_8(x,ptr,__gu_err); \
+ break; \
+ default: \
+ (x) = 0; \
+ __gu_err = __get_user_bad(); \
+ break; \
+ } \
+ __gu_err; \
+})
+
+#define get_user(x, ptr) \
+({ \
+ long __gu_err = -EFAULT; \
+ __typeof__(ptr) __gu_addr = (ptr); \
+ __typeof__(*(ptr)) __x; \
+ if (__access_ok((long)__gu_addr,sizeof(*(ptr)))) { \
+ __gu_err = 0; \
+ __get_user((__x), (__gu_addr)); \
+ (x) = __x; \
+ } \
+ else \
+ (x) = 0; \
+ __gu_err; \
+})
+
+extern int __get_user_bad(void);
+
+/*
+ * access register are set up, that 4 points to secondary (user) , 2 to primary (kernel)
+ */
+
+asmlinkage void __copy_from_user_fixup(void /* special calling convention */);
+asmlinkage void __copy_to_user_fixup(void /* special calling convention */);
+
+extern inline unsigned long
+__copy_to_user_asm(void* to, const void* from, long n)
+{
+
+ __asm__ __volatile__ ( " lgr 2,%2\n"
+ " lgr 4,%1\n"
+ " lgr 3,%0\n"
+ " lgr 5,3\n"
+ " sacf 512\n"
+ "0: mvcle 4,2,0\n"
+ " jo 0b\n"
+ " sacf 0\n"
+ " lgr %0,3\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,__copy_to_user_fixup\n"
+ ".previous"
+ : "+&d" (n) : "d" (to), "d" (from)
+ : "1", "2", "3", "4", "5" );
+ return n;
+}
+
+#define __copy_to_user(to, from, n) \
+({ \
+ __copy_to_user_asm(to,from,n); \
+})
+
+#define copy_to_user(to, from, n) \
+({ \
+ long err = 0; \
+ __typeof__(n) __n = (n); \
+ if (__access_ok(to,__n)) { \
+ err = __copy_to_user_asm(to,from,__n); \
+ } \
+ else \
+ err = __n; \
+ err; \
+})
+
+extern inline unsigned long
+__copy_from_user_asm(void* to, const void* from, long n)
+{
+ __asm__ __volatile__ ( " lgr 2,%1\n"
+ " lgr 4,%2\n"
+ " lgr 3,%0\n"
+ " lgr 5,3\n"
+ " sacf 512\n"
+ "0: mvcle 2,4,0\n"
+ " jo 0b\n"
+ " sacf 0\n"
+ " lgr %0,5\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,__copy_from_user_fixup\n"
+ ".previous"
+ : "+&d" (n) : "d" (to), "d" (from)
+ : "1", "2", "3", "4", "5" );
+ return n;
+}
+
+
+#define __copy_from_user(to, from, n) \
+({ \
+ __copy_from_user_asm(to,from,n); \
+})
+
+#define copy_from_user(to, from, n) \
+({ \
+ long err = 0; \
+ __typeof__(n) __n = (n); \
+ if (__access_ok(from,__n)) { \
+ err = __copy_from_user_asm(to,from,__n); \
+ } \
+ else \
+ err = __n; \
+ err; \
+})
+
+/*
+ * Copy a null terminated string from userspace.
+ */
+
+static inline long
+__strncpy_from_user(char *dst, const char *src, long count)
+{
+ long len;
+ __asm__ __volatile__ ( " slgr %0,%0\n"
+ " lgr 2,%1\n"
+ " lgr 4,%2\n"
+ " slr 3,3\n"
+ " sacf 512\n"
+ "0: ic 3,0(%0,4)\n"
+ "1: stc 3,0(%0,2)\n"
+ " aghi %0,1\n"
+ " cgr %0,%3\n"
+ " je 2f\n"
+ " ltr 3,3\n"
+ " jne 0b\n"
+ "2: sacf 0\n"
+ "3:\n"
+ ".section .fixup,\"ax\"\n"
+ "4: lghi %0,%h4\n"
+ " jg 3b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,4b\n"
+ " .quad 1b,4b\n"
+ ".previous"
+ : "=&a" (len)
+ : "a" (dst), "d" (src), "d" (count),
+ "K" (-EFAULT)
+ : "2" ,"3", "4" );
+ return len;
+}
+
+static inline long
+strncpy_from_user(char *dst, const char *src, long count)
+{
+ long res = -EFAULT;
+ if (access_ok(VERIFY_READ, src, 1))
+ res = __strncpy_from_user(dst, src, count);
+ return res;
+}
+
+/*
+ * Return the size of a string (including the ending 0)
+ *
+ * Return 0 for error
+ */
+static inline unsigned long
+strnlen_user(const char * src, unsigned long n)
+{
+#if 0
+ __asm__ __volatile__ (" algr %0,%1\n"
+ " slgr 0,0\n"
+ " lgr 4,%1\n"
+ " sacf 512\n"
+ "0: srst %0,4\n"
+ " jo 0b\n"
+ " slgr %0,%1\n"
+ " aghi %0,1\n"
+ "1: sacf 0\n"
+ ".section .fixup,\"ax\"\n"
+ "2: slgr %0,%0\n"
+ " jg 1b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,2b\n"
+ ".previous"
+ : "+&a" (n) : "d" (src)
+ : "cc", "0", "4" );
+#else
+ __asm__ __volatile__ (" lgr 4,%1\n"
+ " sacf 512\n"
+ "0: cli 0(4),0x00\n"
+ " la 4,1(4)\n"
+ " je 1f\n"
+ " brctg %0,0b\n"
+ "1: lgr %0,4\n"
+ " slgr %0,%1\n"
+ "2: sacf 0\n"
+ ".section .fixup,\"ax\"\n"
+ "3: slgr %0,%0\n"
+ " jg 2b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,3b\n"
+ ".previous"
+ : "+&a" (n) : "d" (src)
+ : "cc", "4" );
+#endif
+ return n;
+}
+#define strlen_user(str) strnlen_user(str, ~0UL)
+
+/*
+ * Zero Userspace
+ */
+
+static inline unsigned long
+__clear_user(void *to, unsigned long n)
+{
+ __asm__ __volatile__ ( " sacf 512\n"
+ " lgr 4,%1\n"
+ " lgr 5,%0\n"
+ " sgr 2,2\n"
+ " sgr 3,3\n"
+ "0: mvcle 4,2,0\n"
+ " jo 0b\n"
+ "1: sacf 0\n"
+ " lgr %0,5\n"
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,__copy_to_user_fixup\n"
+ ".previous"
+ : "+&a" (n)
+ : "a" (to)
+ : "cc", "1", "2", "3", "4", "5" );
+ return n;
+}
+
+static inline unsigned long
+clear_user(void *to, unsigned long n)
+{
+ if (access_ok(VERIFY_WRITE, to, n))
+ n = __clear_user(to, n);
+ return n;
+}
+
+#endif /* _S390_UACCESS_H */
+
+
+
+
+
diff --git a/include/asm-s390x/ucontext.h b/include/asm-s390x/ucontext.h
new file mode 100644
index 000000000..d4e39ae77
--- /dev/null
+++ b/include/asm-s390x/ucontext.h
@@ -0,0 +1,22 @@
+/*
+ * include/asm-s390/ucontext.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/ucontext.h"
+ */
+
+#ifndef _ASM_S390_UCONTEXT_H
+#define _ASM_S390_UCONTEXT_H
+
+struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ sigset_t uc_sigmask; /* mask last for extensibility */
+ struct sigcontext *sc; /* Added for pthread support */
+};
+
+
+
+#endif /* !_ASM_S390_UCONTEXT_H */
diff --git a/include/asm-s390x/unaligned.h b/include/asm-s390x/unaligned.h
new file mode 100644
index 000000000..8ee86dbed
--- /dev/null
+++ b/include/asm-s390x/unaligned.h
@@ -0,0 +1,24 @@
+/*
+ * include/asm-s390/unaligned.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/unaligned.h"
+ */
+
+#ifndef __S390_UNALIGNED_H
+#define __S390_UNALIGNED_H
+
+/*
+ * The S390 can do unaligned accesses itself.
+ *
+ * The strange macros are there to make sure these can't
+ * be misused in a way that makes them not work on other
+ * architectures where unaligned accesses aren't as simple.
+ */
+
+#define get_unaligned(ptr) (*(ptr))
+
+#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
+
+#endif
diff --git a/include/asm-s390x/unistd.h b/include/asm-s390x/unistd.h
new file mode 100644
index 000000000..1ac8474ee
--- /dev/null
+++ b/include/asm-s390x/unistd.h
@@ -0,0 +1,346 @@
+/*
+ * include/asm-s390/unistd.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/unistd.h"
+ */
+
+#ifndef _ASM_S390_UNISTD_H_
+#define _ASM_S390_UNISTD_H_
+
+/*
+ * This file contains the system call numbers.
+ */
+
+#define __NR_exit 1
+#define __NR_fork 2
+#define __NR_read 3
+#define __NR_write 4
+#define __NR_open 5
+#define __NR_close 6
+#define __NR_creat 8
+#define __NR_link 9
+#define __NR_unlink 10
+#define __NR_execve 11
+#define __NR_chdir 12
+#define __NR_mknod 14
+#define __NR_chmod 15
+#define __NR_lseek 19
+#define __NR_getpid 20
+#define __NR_mount 21
+#define __NR_umount 22
+#define __NR_ptrace 26
+#define __NR_alarm 27
+#define __NR_pause 29
+#define __NR_utime 30
+#define __NR_access 33
+#define __NR_nice 34
+#define __NR_sync 36
+#define __NR_kill 37
+#define __NR_rename 38
+#define __NR_mkdir 39
+#define __NR_rmdir 40
+#define __NR_dup 41
+#define __NR_pipe 42
+#define __NR_times 43
+#define __NR_brk 45
+#define __NR_signal 48
+#define __NR_acct 51
+#define __NR_umount2 52
+#define __NR_ioctl 54
+#define __NR_fcntl 55
+#define __NR_setpgid 57
+#define __NR_umask 60
+#define __NR_chroot 61
+#define __NR_ustat 62
+#define __NR_dup2 63
+#define __NR_getppid 64
+#define __NR_getpgrp 65
+#define __NR_setsid 66
+#define __NR_sigaction 67
+#define __NR_sigsuspend 72
+#define __NR_sigpending 73
+#define __NR_sethostname 74
+#define __NR_setrlimit 75
+#define __NR_getrusage 77
+#define __NR_gettimeofday 78
+#define __NR_settimeofday 79
+#define __NR_symlink 83
+#define __NR_readlink 85
+#define __NR_uselib 86
+#define __NR_swapon 87
+#define __NR_reboot 88
+#define __NR_readdir 89
+#define __NR_mmap 90
+#define __NR_munmap 91
+#define __NR_truncate 92
+#define __NR_ftruncate 93
+#define __NR_fchmod 94
+#define __NR_getpriority 96
+#define __NR_setpriority 97
+#define __NR_statfs 99
+#define __NR_fstatfs 100
+#define __NR_socketcall 102
+#define __NR_syslog 103
+#define __NR_setitimer 104
+#define __NR_getitimer 105
+#define __NR_stat 106
+#define __NR_lstat 107
+#define __NR_fstat 108
+#define __NR_vhangup 111
+#define __NR_idle 112
+#define __NR_wait4 114
+#define __NR_swapoff 115
+#define __NR_sysinfo 116
+#define __NR_ipc 117
+#define __NR_fsync 118
+#define __NR_sigreturn 119
+#define __NR_clone 120
+#define __NR_setdomainname 121
+#define __NR_uname 122
+#define __NR_adjtimex 124
+#define __NR_mprotect 125
+#define __NR_sigprocmask 126
+#define __NR_create_module 127
+#define __NR_init_module 128
+#define __NR_delete_module 129
+#define __NR_get_kernel_syms 130
+#define __NR_quotactl 131
+#define __NR_getpgid 132
+#define __NR_fchdir 133
+#define __NR_bdflush 134
+#define __NR_sysfs 135
+#define __NR_personality 136
+#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
+#define __NR_getdents 141
+#define __NR_select 142
+#define __NR_flock 143
+#define __NR_msync 144
+#define __NR_readv 145
+#define __NR_writev 146
+#define __NR_getsid 147
+#define __NR_fdatasync 148
+#define __NR__sysctl 149
+#define __NR_mlock 150
+#define __NR_munlock 151
+#define __NR_mlockall 152
+#define __NR_munlockall 153
+#define __NR_sched_setparam 154
+#define __NR_sched_getparam 155
+#define __NR_sched_setscheduler 156
+#define __NR_sched_getscheduler 157
+#define __NR_sched_yield 158
+#define __NR_sched_get_priority_max 159
+#define __NR_sched_get_priority_min 160
+#define __NR_sched_rr_get_interval 161
+#define __NR_nanosleep 162
+#define __NR_mremap 163
+#define __NR_query_module 167
+#define __NR_poll 168
+#define __NR_nfsservctl 169
+#define __NR_prctl 172
+#define __NR_rt_sigreturn 173
+#define __NR_rt_sigaction 174
+#define __NR_rt_sigprocmask 175
+#define __NR_rt_sigpending 176
+#define __NR_rt_sigtimedwait 177
+#define __NR_rt_sigqueueinfo 178
+#define __NR_rt_sigsuspend 179
+#define __NR_pread 180
+#define __NR_pwrite 181
+#define __NR_getcwd 183
+#define __NR_capget 184
+#define __NR_capset 185
+#define __NR_sigaltstack 186
+#define __NR_sendfile 187
+#define __NR_vfork 190
+#define __NR_getrlimit 191 /* SuS compliant getrlimit */
+#define __NR_lchown 198
+#define __NR_getuid 199
+#define __NR_getgid 200
+#define __NR_geteuid 201
+#define __NR_getegid 202
+#define __NR_setreuid 203
+#define __NR_setregid 204
+#define __NR_getgroups 205
+#define __NR_setgroups 206
+#define __NR_fchown 207
+#define __NR_setresuid 208
+#define __NR_getresuid 209
+#define __NR_setresgid 210
+#define __NR_getresgid 211
+#define __NR_chown 212
+#define __NR_setuid 213
+#define __NR_setgid 214
+#define __NR_setfsuid 215
+#define __NR_setfsgid 216
+#define __NR_pivot_root 217
+#define __NR_mincore 218
+#define __NR_madvise 219
+#define __NR_getdents64 220
+#define __NR_fcntl64 221
+
+
+/* user-visible error numbers are in the range -1 - -122: see <asm-s390/errno.h> */
+
+#define __syscall_return(type, res) \
+do { \
+ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ errno = -(res); \
+ res = -1; \
+ } \
+ return (type) (res); \
+} while (0)
+
+#define _svc_clobber "2", "cc", "memory"
+
+#define _syscall0(type,name) \
+type name(void) { \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name) \
+ : _svc_clobber ); \
+ __syscall_return(type,__res); \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) { \
+ register type1 __arg1 asm("2") = arg1; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__arg1) \
+ : _svc_clobber ); \
+ __syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1, type2 arg2) { \
+ register type1 __arg1 asm("2") = arg1; \
+ register type2 __arg2 asm("3") = arg2; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__arg1), \
+ "d" (__arg2) \
+ : _svc_clobber ); \
+ __syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)\
+type name(type1 arg1, type2 arg2, type3 arg3) { \
+ register type1 __arg1 asm("2") = arg1; \
+ register type2 __arg2 asm("3") = arg2; \
+ register type3 __arg3 asm("4") = arg3; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__arg1), \
+ "d" (__arg2), \
+ "d" (__arg3) \
+ : _svc_clobber ); \
+ __syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,\
+ type4,name4) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
+ register type1 __arg1 asm("2") = arg1; \
+ register type2 __arg2 asm("3") = arg2; \
+ register type3 __arg3 asm("4") = arg3; \
+ register type4 __arg4 asm("5") = arg4; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__arg1), \
+ "d" (__arg2), \
+ "d" (__arg3), \
+ "d" (__arg4) \
+ : _svc_clobber ); \
+ __syscall_return(type,__res); \
+}
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,\
+ type4,name4,type5,name5) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5) { \
+ register type1 __arg1 asm("2") = arg1; \
+ register type2 __arg2 asm("3") = arg2; \
+ register type3 __arg3 asm("4") = arg3; \
+ register type4 __arg4 asm("5") = arg4; \
+ register type5 __arg5 asm("6") = arg5; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__arg1), \
+ "d" (__arg2), \
+ "d" (__arg3), \
+ "d" (__arg4), \
+ "d" (__arg5) \
+ : _svc_clobber ); \
+ __syscall_return(type,__res); \
+}
+
+#ifdef __KERNEL_SYSCALLS__
+
+/*
+ * we need this inline - forking from kernel space will result
+ * in NO COPY ON WRITE (!!!), until an execve is executed. This
+ * is no problem, but for the stack. This is handled by not letting
+ * main() use the stack at all after fork(). Thus, no function
+ * calls - which means inline code for fork too, as otherwise we
+ * would use the stack upon exit from 'fork()'.
+ *
+ * Actually only pause and fork are needed inline, so that there
+ * won't be any messing with the stack from main(), but we define
+ * some others too.
+ */
+#define __NR__exit __NR_exit
+static inline _syscall0(int,idle)
+static inline _syscall0(int,pause)
+static inline _syscall0(int,sync)
+static inline _syscall0(pid_t,setsid)
+static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
+static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
+static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
+static inline _syscall1(int,dup,int,fd)
+static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
+static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
+static inline _syscall1(int,close,int,fd)
+static inline _syscall1(int,_exit,int,exitcode)
+static inline _syscall1(int,delete_module,const char *,name)
+static inline _syscall2(long,stat,char *,filename,struct stat *,statbuf)
+
+extern int sys_wait4(int, int *, int, struct rusage *);
+static inline pid_t waitpid(int pid, int * wait_stat, int flags)
+{
+ return sys_wait4(pid, wait_stat, flags, NULL);
+}
+
+static inline pid_t wait(int * wait_stat)
+{
+ return waitpid(-1,wait_stat,0);
+}
+
+#endif
+
+#endif /* _ASM_S390_UNISTD_H_ */
diff --git a/include/asm-s390x/user.h b/include/asm-s390x/user.h
new file mode 100644
index 000000000..2e91b881b
--- /dev/null
+++ b/include/asm-s390x/user.h
@@ -0,0 +1,77 @@
+/*
+ * include/asm-s390/user.h
+ *
+ * S390 version
+ *
+ * Derived from "include/asm-i386/usr.h"
+ */
+
+#ifndef _S390_USER_H
+#define _S390_USER_H
+
+#include <asm/page.h>
+#include <linux/ptrace.h>
+/* Core file format: The core file is written in such a way that gdb
+ can understand it and provide useful information to the user (under
+ linux we use the 'trad-core' bfd). There are quite a number of
+ obstacles to being able to view the contents of the floating point
+ registers, and until these are solved you will not be able to view the
+ contents of them. Actually, you can read in the core file and look at
+ the contents of the user struct to find out what the floating point
+ registers contain.
+ The actual file contents are as follows:
+ UPAGE: 1 page consisting of a user struct that tells gdb what is present
+ in the file. Directly after this is a copy of the task_struct, which
+ is currently not used by gdb, but it may come in useful at some point.
+ All of the registers are stored as part of the upage. The upage should
+ always be only one page.
+ DATA: The data area is stored. We use current->end_text to
+ current->brk to pick up all of the user variables, plus any memory
+ that may have been malloced. No attempt is made to determine if a page
+ is demand-zero or if a page is totally unused, we just cover the entire
+ range. All of the addresses are rounded in such a way that an integral
+ number of pages is written.
+ STACK: We need the stack information in order to get a meaningful
+ backtrace. We need to write the data from (esp) to
+ current->start_stack, so we round each of these off in order to be able
+ to write an integer number of pages.
+ The minimum core file size is 3 pages, or 12288 bytes.
+*/
+
+
+/*
+ * This is the old layout of "struct pt_regs", and
+ * is still the layout used by user mode (the new
+ * pt_regs doesn't have all registers as the kernel
+ * doesn't use the extra segment registers)
+ */
+
+/* When the kernel dumps core, it starts by dumping the user struct -
+ this will be used by gdb to figure out where the data and stack segments
+ are within the file, and what virtual addresses to use. */
+struct user {
+/* We start with the registers, to mimic the way that "memory" is returned
+ from the ptrace(3,...) function. */
+ struct user_regs_struct regs; /* Where the registers are actually stored */
+/* The rest of this junk is to help gdb figure out what goes where */
+ size_t u_tsize; /* Text segment size (pages). */
+ size_t u_dsize; /* Data segment size (pages). */
+ size_t u_ssize; /* Stack segment size (pages). */
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack area.
+ This is actually the bottom of the stack,
+ the top of the stack is always found in the
+ gprs[15] register. */
+ long int signal; /* Signal that caused the core dump. */
+ struct user_regs_struct *u_ar0;
+ /* Used by gdb to help find the values for */
+ /* the registers. */
+ unsigned long magic; /* To uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+};
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif /* _S390_USER_H */
diff --git a/include/asm-s390x/xor.h b/include/asm-s390x/xor.h
new file mode 100644
index 000000000..c82eb12a5
--- /dev/null
+++ b/include/asm-s390x/xor.h
@@ -0,0 +1 @@
+#include <asm-generic/xor.h>