summaryrefslogtreecommitdiffstats
path: root/include/asm-ppc
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
committer <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
commit19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch)
tree40b1cb534496a7f1ca0f5c314a523c69f1fee464 /include/asm-ppc
parent7206675c40394c78a90e74812bbdbf8cf3cca1be (diff)
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'include/asm-ppc')
-rw-r--r--include/asm-ppc/atomic.h19
-rw-r--r--include/asm-ppc/bitops.h181
-rw-r--r--include/asm-ppc/byteorder.h93
-rw-r--r--include/asm-ppc/cache.h12
-rw-r--r--include/asm-ppc/checksum.h2
-rw-r--r--include/asm-ppc/current.h12
-rw-r--r--include/asm-ppc/dma.h2
-rw-r--r--include/asm-ppc/elf.h21
-rw-r--r--include/asm-ppc/errno.h3
-rw-r--r--include/asm-ppc/fcntl.h6
-rw-r--r--include/asm-ppc/floppy.h2
-rw-r--r--include/asm-ppc/ide.h119
-rw-r--r--include/asm-ppc/init.h14
-rw-r--r--include/asm-ppc/io.h22
-rw-r--r--include/asm-ppc/ipc.h28
-rw-r--r--include/asm-ppc/mman.h3
-rw-r--r--include/asm-ppc/mmu.h7
-rw-r--r--include/asm-ppc/mmu_context.h3
-rw-r--r--include/asm-ppc/page.h31
-rw-r--r--include/asm-ppc/pgtable.h263
-rw-r--r--include/asm-ppc/pnp.h641
-rw-r--r--include/asm-ppc/posix_types.h3
-rw-r--r--include/asm-ppc/ppc_machine.h12
-rw-r--r--include/asm-ppc/processor.h91
-rw-r--r--include/asm-ppc/ptrace.h44
-rw-r--r--include/asm-ppc/residual.h315
-rw-r--r--include/asm-ppc/resource.h36
-rw-r--r--include/asm-ppc/scatterlist.h13
-rw-r--r--include/asm-ppc/segment.h134
-rw-r--r--include/asm-ppc/semaphore.h56
-rw-r--r--include/asm-ppc/smp.h26
-rw-r--r--include/asm-ppc/socket.h9
-rw-r--r--include/asm-ppc/stat.h6
-rw-r--r--include/asm-ppc/string.h44
-rw-r--r--include/asm-ppc/system.h1
-rw-r--r--include/asm-ppc/termios.h88
-rw-r--r--include/asm-ppc/uaccess.h150
-rw-r--r--include/asm-ppc/unistd.h242
-rw-r--r--include/asm-ppc/unistd.h.cort376
39 files changed, 1932 insertions, 1198 deletions
diff --git a/include/asm-ppc/atomic.h b/include/asm-ppc/atomic.h
index a54e6af42..c34bc36ef 100644
--- a/include/asm-ppc/atomic.h
+++ b/include/asm-ppc/atomic.h
@@ -5,6 +5,23 @@
#ifndef _ASM_PPC_ATOMIC_H_
#define _ASM_PPC_ATOMIC_H_
-typedef int atomic_t;
+typedef struct { int counter; } atomic_t;
+#define ATOMIC_INIT(i) { (i) }
+
+/*
+ * Make sure gcc doesn't try to be clever and move things around
+ * on us. We need to use _exactly_ the address the user gave us,
+ * not some alias that contains the same information.
+ */
+#define __atomic_fool_gcc(x) (*(struct { int a[100]; } *)x)
+
+#define atomic_read(v) ((v)->counter)
+#define atomic_set(v) (((v)->counter) = i)
+
+#define atomic_dec_return(v) ({atomic_sub(1,(v));(v);})
+#define atomic_inc_return(v) ({atomic_add(1,(v));(v);})
+
+#define atomic_inc(v) atomic_add(1,(v))
+#define atomic_dec(v) atomic_sub(1,(v))
#endif
diff --git a/include/asm-ppc/bitops.h b/include/asm-ppc/bitops.h
index 5e0407abd..959f2b302 100644
--- a/include/asm-ppc/bitops.h
+++ b/include/asm-ppc/bitops.h
@@ -1,39 +1,32 @@
#ifndef _ASM_PPC_BITOPS_H_
#define _ASM_PPC_BITOPS_H_
-/*
- * For the benefit of those who are trying to port Linux to another
- * architecture, here are some C-language equivalents. You should
- * recode these in the native assembly language, if at all possible.
- * To guarantee atomicity, these routines call cli() and sti() to
- * disable interrupts while they operate. (You have to provide inline
- * routines to cli() and sti().)
- *
- * Also note, these routines assume that you have 32 bit integers.
- * You will have to change this if you are trying to port Linux to the
- * Alpha architecture or to a Cray. :-)
- *
- * C language equivalents written by Theodore Ts'o, 9/26/92
- */
-
-#include "asm/system.h" /* For cli/sti declaration */
+#include <asm/system.h>
+#include <asm/byteorder.h>
#define BIT(n) 1<<(n&0x1F)
typedef unsigned long BITFIELD;
+
+/* Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
+ * is in the highest of the four bytes and bit '31' is the high bit
+ * within the first byte. powerpc is BIG-Endian. Unless noted otherwise
+ * all bit-ops return 0 if bit was previously clear and != 0 otherwise.
+ */
extern __inline__ int set_bit(int nr, void * add)
{
- int mask, oldbit;
BITFIELD *addr = add;
-
+ long mask,oldbit;
+#ifdef __KERNEL__
int s = _disable_interrupts();
+#endif
addr += nr >> 5;
mask = BIT(nr);
oldbit = (mask & *addr) != 0;
*addr |= mask;
+#ifdef __KERNEL__
_enable_interrupts(s);
-
-
+#endif
return oldbit;
}
@@ -41,12 +34,16 @@ extern __inline__ int change_bit(int nr, void *add)
{
BITFIELD *addr = add;
int mask, retval;
+#ifdef __KERNEL__
int s = _disable_interrupts();
+#endif
addr += nr >> 5;
mask = BIT(nr);
retval = (mask & *addr) != 0;
*addr ^= mask;
+#ifdef __KERNEL__
_enable_interrupts(s);
+#endif
return retval;
}
@@ -54,77 +51,115 @@ extern __inline__ int clear_bit(int nr, void *add)
{
BITFIELD *addr = add;
int mask, retval;
+#ifdef __KERNEL__
int s = _disable_interrupts();
+#endif
addr += nr >> 5;
mask = BIT(nr);
retval = (mask & *addr) != 0;
*addr &= ~mask;
+#ifdef __KERNEL__
_enable_interrupts(s);
+#endif
return retval;
}
-extern __inline__ int test_bit(int nr, void *add)
+#define _EXT2_HAVE_ASM_BITOPS_
+#define ext2_find_first_zero_bit(addr, size) \
+ ext2_find_next_zero_bit((addr), (size), 0)
+
+
+extern __inline__ int ext2_set_bit(int nr, void * addr)
{
- int mask;
- BITFIELD *addr = add;
+#ifdef __KERNEL__
+ int s = _disable_interrupts();
+#endif
+ int mask;
+ unsigned char *ADDR = (unsigned char *) addr;
+ int oldbit;
+
+ ADDR += nr >> 3;
+ mask = 1 << (nr & 0x07);
+ oldbit = (*ADDR & mask) ? 1 : 0;
+ *ADDR |= mask;
+#ifdef __KERNEL__
+ _enable_interrupts(s);
+#endif
+ return oldbit;
+}
- addr += nr >> 5;
- mask = BIT(nr);
- return ((mask & *addr) != 0);
+extern __inline__ int ext2_clear_bit(int nr, void * addr)
+{
+#ifdef __KERNEL__
+ int s = _disable_interrupts();
+#endif
+ int mask;
+ unsigned char *ADDR = (unsigned char *) addr;
+ int oldbit;
+
+ ADDR += nr >> 3;
+ mask = 1 << (nr & 0x07);
+ oldbit = (*ADDR & mask) ? 1 : 0;
+ *ADDR = *ADDR & ~mask;
+#ifdef __KERNEL__
+ _enable_interrupts(s);
+#endif
+ return oldbit;
}
-#if 0
-extern __inline__ int find_first_zero_bit(void *add, int len)
+
+
+/* The following routine need not be atomic. */
+extern __inline__ unsigned long test_bit(int nr, void *addr)
{
- int mask, nr, i;
- BITFIELD *addr = add;
- nr = 0;
- while (len)
- {
- if (~*addr != 0)
- { /* Contains at least one zero */
- for (i = 0; i < 32; i++, nr++)
- {
- mask = BIT(nr);
- if ((mask & *addr) == 0)
- {
- return (nr);
- }
- }
- }
- len -= 32;
- addr++;
- nr += 32;
- }
- return (0); /* Shouldn't happen */
+ return 1UL & (((__const__ unsigned int *) addr)[nr >> 5] >> (nr & 31));
}
-extern __inline__ int find_next_zero_bit(void *add, int len, int nr)
+extern __inline__ int ext2_test_bit(int nr, __const__ void * addr)
{
- int mask, i;
- BITFIELD *addr = add;
- addr += nr >> 5;
- len -= nr;
- while (len)
- {
- if (*addr != 0xFFFFFFFF)
- { /* Contains at least one zero */
- for (i = 0; i < 32; i++, nr++)
- {
- mask = BIT(nr);
- if ((mask & *addr) == 0)
- {
-printk("Bit: %d(%d), Pat: %x\n", nr, nr&0x1F, *addr);
- return (nr);
- }
- }
- }
- len -= 32;
- addr++;
- nr += 32;
+ int mask;
+ __const__ unsigned char *ADDR = (__const__ unsigned char *) addr;
+
+ ADDR += nr >> 3;
+ mask = 1 << (nr & 0x07);
+ return ((mask & *ADDR) != 0);
+}
+
+extern __inline__ unsigned long ext2_find_next_zero_bit(void *addr, unsigned long size, unsigned long offset)
+{
+ unsigned long *p = ((unsigned long *) addr) + (offset >> 5);
+ unsigned long result = offset & ~31UL;
+ unsigned long tmp;
+
+ if (offset >= size)
+ return size;
+ size -= result;
+ offset &= 31UL;
+ if(offset) {
+ tmp = *(p++);
+ tmp |= le32_to_cpu(~0UL >> (32-offset));
+ if(size < 32)
+ goto found_first;
+ if(~tmp)
+ goto found_middle;
+ size -= 32;
+ result += 32;
}
- return (0); /* Shouldn't happen */
+ while(size & ~31UL) {
+ if(~(tmp = *(p++)))
+ goto found_middle;
+ result += 32;
+ size -= 32;
+ }
+ if(!size)
+ return result;
+ tmp = *p;
+
+found_first:
+ return result + ffz(le32_to_cpu(tmp) | (~0UL << size));
+found_middle:
+ return result + ffz(le32_to_cpu(tmp));
}
-#endif
+
#endif /* _ASM_PPC_BITOPS_H */
diff --git a/include/asm-ppc/byteorder.h b/include/asm-ppc/byteorder.h
index 240e7401a..0c771b2f4 100644
--- a/include/asm-ppc/byteorder.h
+++ b/include/asm-ppc/byteorder.h
@@ -9,85 +9,48 @@
#define __BIG_ENDIAN_BITFIELD
#endif
-#if 0 /* Assume PowerPC is Big-Endian! */
-#undef ntohl
-#undef ntohs
-#undef htonl
-#undef htons
-
-extern unsigned long int ntohl(unsigned long int);
-extern unsigned short int ntohs(unsigned short int);
-extern unsigned long int htonl(unsigned long int);
-extern unsigned short int htons(unsigned short int);
-
-extern unsigned long int __ntohl(unsigned long int);
-extern unsigned short int __ntohs(unsigned short int);
-extern unsigned long int __constant_ntohl(unsigned long int);
-extern unsigned short int __constant_ntohs(unsigned short int);
-
-extern __inline__ unsigned long int
-__ntohl(unsigned long int x)
-{
- return (((x & 0x000000ffU) << 24) |
- ((x & 0x0000ff00U) << 8) |
- ((x & 0x00ff0000U) >> 8) |
- ((x & 0xff000000U) >> 24));
-}
+#define ntohl(x) (x)
+#define ntohs(x) (x)
+#define htonl(x) (x)
+#define htons(x) (x)
+
+#define __htonl(x) ntohl(x)
+#define __htons(x) ntohs(x)
+#define __constant_htonl(x) ntohl(x)
+#define __constant_htons(x) ntohs(x)
+
+/*
+ * In-kernel byte order macros to handle stuff like
+ * byte-order-dependent filesystems etc.
+ */
-extern __inline__ unsigned long int
-__constant_ntohl(unsigned long int x)
+#define cpu_to_le32(x) le32_to_cpu((x))
+extern __inline__ unsigned long le32_to_cpu(unsigned long x)
{
- return (((x & 0x000000ffU) << 24) |
+ return (((x & 0x000000ffU) << 24) |
((x & 0x0000ff00U) << 8) |
((x & 0x00ff0000U) >> 8) |
((x & 0xff000000U) >> 24));
}
-extern __inline__ unsigned short int
-__ntohs(unsigned short int x)
-{
- return (((x & 0x00ff) << 8) |
- ((x & 0xff00) >> 8));
-}
-extern __inline__ unsigned short int
-__constant_ntohs(unsigned short int x)
+#define cpu_to_le16(x) le16_to_cpu((x))
+extern __inline__ unsigned short le16_to_cpu(unsigned short x)
{
return (((x & 0x00ff) << 8) |
((x & 0xff00) >> 8));
}
-#define __htonl(x) __ntohl(x)
-#define __htons(x) __ntohs(x)
-#define __constant_htonl(x) __constant_ntohl(x)
-#define __constant_htons(x) __constant_ntohs(x)
-
-#ifdef __OPTIMIZE__
-# define ntohl(x) \
-(__builtin_constant_p((long)(x)) ? \
- __constant_ntohl((x)) : \
- __ntohl((x)))
-# define ntohs(x) \
-(__builtin_constant_p((short)(x)) ? \
- __constant_ntohs((x)) : \
- __ntohs((x)))
-# define htonl(x) \
-(__builtin_constant_p((long)(x)) ? \
- __constant_htonl((x)) : \
- __htonl((x)))
-# define htons(x) \
-(__builtin_constant_p((short)(x)) ? \
- __constant_htons((x)) : \
- __htons((x)))
-#endif
+#define cpu_to_be32(x) (x)
+#define be32_to_cpu(x) (x)
+#define cpu_to_be16(x) (x)
+#define be16_to_cpu(x) (x)
+
+
+#endif /* !(_PPC_BYTEORDER_H) */
+
+
-#else
-#define ntohl(x) (x)
-#define ntohs(x) (x)
-#define htonl(x) (x)
-#define htons(x) (x)
-#endif
-#endif /* !(_PPC_BYTEORDER_H) */
diff --git a/include/asm-ppc/cache.h b/include/asm-ppc/cache.h
new file mode 100644
index 000000000..da609f271
--- /dev/null
+++ b/include/asm-ppc/cache.h
@@ -0,0 +1,12 @@
+/*
+ * include/asm-ppc/cache.h
+ */
+#ifndef __ARCH_PPC_CACHE_H
+#define __ARCH_PPC_CACHE_H
+
+/* bytes per L1 cache line */
+#define L1_CACHE_BYTES 32 /* a guess */
+
+#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
+
+#endif
diff --git a/include/asm-ppc/checksum.h b/include/asm-ppc/checksum.h
index 99dbed2e3..74e943792 100644
--- a/include/asm-ppc/checksum.h
+++ b/include/asm-ppc/checksum.h
@@ -54,5 +54,5 @@ unsigned int csum_partial_copy( const char *src, char *dst, int len, int sum);
A */
extern unsigned short ip_compute_csum(unsigned char * buff, int len);
-
+extern unsigned int csum_fold(unsigned int sum);
#endif
diff --git a/include/asm-ppc/current.h b/include/asm-ppc/current.h
new file mode 100644
index 000000000..d815aaad3
--- /dev/null
+++ b/include/asm-ppc/current.h
@@ -0,0 +1,12 @@
+#ifndef _PPC_CURRENT_H
+#define _PPC_CURRENT_H
+
+/* Some architectures may want to do something "clever" here since
+ * this is the most frequently accessed piece of data in the entire
+ * kernel. For an example, see the Sparc implementation where an
+ * entire register is hard locked to contain the value of current.
+ */
+extern struct task_struct *current_set[NR_CPUS];
+#define current (current_set[smp_processor_id()]) /* Current on this processor */
+
+#endif /* !(_PPC_CURRENT_H) */
diff --git a/include/asm-ppc/dma.h b/include/asm-ppc/dma.h
index 9e6608d54..ca609062e 100644
--- a/include/asm-ppc/dma.h
+++ b/include/asm-ppc/dma.h
@@ -7,6 +7,7 @@
/*
* Note: Adapted for PowerPC by Gary Thomas
+ * Modified by Cort Dougan <cort@cs.nmt.edu>
*
* There may be some comments or restrictions made here which are
* not valid for the PowerPC (PreP) platform. Take what you read
@@ -292,7 +293,6 @@ static __inline__ int get_dma_residue(unsigned int dmanr)
/* These are in kernel/dma.c: */
-/*extern int request_dma(unsigned int dmanr, char * device_id);*/ /* reserve a DMA channel */
extern void free_dma(unsigned int dmanr); /* release it again */
diff --git a/include/asm-ppc/elf.h b/include/asm-ppc/elf.h
index 875064189..d0e758efd 100644
--- a/include/asm-ppc/elf.h
+++ b/include/asm-ppc/elf.h
@@ -4,27 +4,30 @@
/*
* ELF register definitions..
*/
+#include <asm/ptrace.h>
#define ELF_NGREG 32
#define ELF_NFPREG 32
-typedef unsigned long elf_greg_t;
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-
-typedef double elf_fpreg_t;
-typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
-
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
#define elf_check_arch(x) ((x) == EM_PPC)
/*
* These are used to set parameters in the core dumps.
- * FIXME(eric) I don't know what the correct endianness to use is.
*/
-#define ELF_CLASS ELFCLASS32
-#define ELF_DATA ELFDATA2LSB;
#define ELF_ARCH EM_PPC
+#define ELF_CLASS ELFCLASS32
+#define ELF_DATA ELFDATA2MSB;
#define USE_ELF_CORE_DUMP
#define ELF_EXEC_PAGESIZE 4096
+typedef unsigned long elf_greg_t;
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef double elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
#endif
diff --git a/include/asm-ppc/errno.h b/include/asm-ppc/errno.h
index 1b5d9f387..8c47b73e7 100644
--- a/include/asm-ppc/errno.h
+++ b/include/asm-ppc/errno.h
@@ -124,6 +124,9 @@
#define EREMOTEIO 121 /* Remote I/O error */
#define EDQUOT 122 /* Quota exceeded */
+#define ENOMEDIUM 123 /* No medium found */
+#define EMEDIUMTYPE 124 /* Wrong medium type */
+
/* Should never be seen by user programs */
#define ERESTARTSYS 512
#define ERESTARTNOINTR 513
diff --git a/include/asm-ppc/fcntl.h b/include/asm-ppc/fcntl.h
index 9b0f41c73..61d0fa703 100644
--- a/include/asm-ppc/fcntl.h
+++ b/include/asm-ppc/fcntl.h
@@ -48,6 +48,12 @@
blocking */
#define LOCK_UN 8 /* remove lock */
+#ifdef __KERNEL__
+#define F_POSIX 1
+#define F_FLOCK 2
+#define F_BROKEN 4 /* broken flock() emulation */
+#endif /* __KERNEL__ */
+
struct flock {
short l_type;
short l_whence;
diff --git a/include/asm-ppc/floppy.h b/include/asm-ppc/floppy.h
index eb52f4611..342379294 100644
--- a/include/asm-ppc/floppy.h
+++ b/include/asm-ppc/floppy.h
@@ -19,7 +19,7 @@
#define fd_free_dma() free_dma(FLOPPY_DMA)
#define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA)
#define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA,mode)
-#define fd_set_dma_addr(addr) set_dma_addr(FLOPPY_DMA,virt_to_bus(addr))
+#define fd_set_dma_addr(addr) set_dma_addr(FLOPPY_DMA,(unsigned int)virt_to_bus(addr))
#define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA,count)
#define fd_enable_irq() enable_irq(FLOPPY_IRQ)
#define fd_disable_irq() disable_irq(FLOPPY_IRQ)
diff --git a/include/asm-ppc/ide.h b/include/asm-ppc/ide.h
new file mode 100644
index 000000000..69838b8b1
--- /dev/null
+++ b/include/asm-ppc/ide.h
@@ -0,0 +1,119 @@
+/*
+ * linux/include/asm-i386/ide.h
+ *
+ * Copyright (C) 1994-1996 Linus Torvalds & authors
+ */
+
+/*
+ * This file contains the ppc architecture specific IDE code.
+ */
+
+#ifndef __ASMPPC_IDE_H
+#define __ASMPPC_IDE_H
+
+#ifdef __KERNEL__
+
+typedef unsigned short ide_ioreg_t;
+
+#ifndef MAX_HWIFS
+#define MAX_HWIFS 4
+#endif
+
+#define ide_sti() sti()
+
+static __inline__ int ide_default_irq(ide_ioreg_t base)
+{
+ switch (base) {
+ case 0x1f0: return 14;
+ case 0x170: return 15;
+ case 0x1e8: return 11;
+ case 0x168: return 10;
+ default:
+ return 0;
+ }
+}
+
+static __inline__ ide_ioreg_t ide_default_io_base(int index)
+{
+ switch (index) {
+ case 0: return 0x1f0;
+ case 1: return 0x170;
+ case 2: return 0x1e8;
+ case 3: return 0x168;
+ default:
+ return 0;
+ }
+}
+
+static __inline__ void ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq)
+{
+ ide_ioreg_t port = base;
+ int i = 8;
+
+ while (i--)
+ *p++ = port++;
+ *p++ = base + 0x206;
+ if (irq != NULL)
+ *irq = 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;
+
+static __inline__ int ide_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
+ unsigned long flags, const char *device, void *dev_id)
+{
+ return request_irq(irq, handler, flags, device, dev_id);
+}
+
+static __inline__ void ide_free_irq(unsigned int irq, void *dev_id)
+{
+ free_irq(irq, dev_id);
+}
+
+static __inline__ int ide_check_region (ide_ioreg_t from, unsigned int extent)
+{
+ return check_region(from, extent);
+}
+
+static __inline__ void ide_request_region (ide_ioreg_t from, unsigned int extent, const char *name)
+{
+ request_region(from, extent, name);
+}
+
+static __inline__ void ide_release_region (ide_ioreg_t from, unsigned int extent)
+{
+ release_region(from, extent);
+}
+
+/*
+ * The following are not needed for the non-m68k ports
+ */
+static __inline__ int ide_ack_intr (ide_ioreg_t base_port, ide_ioreg_t irq_port)
+{
+ return(1);
+}
+
+static __inline__ void ide_fix_driveid(struct hd_driveid *id)
+{
+}
+
+static __inline__ void ide_release_lock (int *ide_lock)
+{
+}
+
+static __inline__ void ide_get_lock (int *ide_lock, void (*handler)(int, void *, struct pt_regs *), void *data)
+{
+}
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASMPPC_IDE_H */
diff --git a/include/asm-ppc/init.h b/include/asm-ppc/init.h
new file mode 100644
index 000000000..82ce44ce8
--- /dev/null
+++ b/include/asm-ppc/init.h
@@ -0,0 +1,14 @@
+#ifndef _PPC_INIT_H
+#define _PPC_INIT_H
+
+/* Throwing the initialization code and data out is not supported yet... */
+
+#define __init
+#define __initdata
+#define __initfunc(__arginit) __arginit
+/* For assembly routines */
+#define __INIT
+#define __FINIT
+#define __INITDATA
+
+#endif
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index 35cd7e2f2..581d51643 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -1,16 +1,28 @@
#ifndef _PPC_IO_H
#define _PPC_IO_H
-/* Define the particulars of outb/outw/outl "instructions" */
+#include <asm/page.h>
+
+/* from the Carolina Technical Spec -- Cort */
+#define IBM_ACORN 0x82A
+#define SIO_CONFIG_RA 0x398
+#define SIO_CONFIG_RD 0x399
+
+#define IBM_HDD_LED 0x808
+#define IBM_EQUIP_PRESENT 0x80c
+#define IBM_L2_STATUS 0x80d
+#define IBM_L2_INVALIDATE 0x814
+#define IBM_SYS_CTL 0x81c
+
+
+/* Define the particulars of outb/outw/outl "instructions" */
#define SLOW_DOWN_IO
#ifndef PCI_DRAM_OFFSET
#define PCI_DRAM_OFFSET 0x80000000
#endif
-#ifndef KERNELBASE
-#define KERNELBASE 0x90000000
-#endif
+
/*
* The PCI bus is inherently Little-Endian. The PowerPC is being
@@ -39,11 +51,11 @@ extern inline void * bus_to_virt(unsigned long address)
#define readb(addr) (*(volatile unsigned char *) (addr))
#define readw(addr) (*(volatile unsigned short *) (addr))
#define readl(addr) (*(volatile unsigned int *) (addr))
-
#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
+
/*
* Change virtual addresses to physical addresses and vv.
* These are trivial on the 1:1 Linux/i386 mapping (but if we ever
diff --git a/include/asm-ppc/ipc.h b/include/asm-ppc/ipc.h
new file mode 100644
index 000000000..f368d14c8
--- /dev/null
+++ b/include/asm-ppc/ipc.h
@@ -0,0 +1,28 @@
+#ifndef __i386_IPC_H__
+#define __i386_IPC_H__
+
+/*
+ * These are used to wrap system calls on x86.
+ *
+ * See arch/i386/kernel/sys_i386.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
+
+#define IPCCALL(version,op) ((version)<<16 | (op))
+
+#endif
diff --git a/include/asm-ppc/mman.h b/include/asm-ppc/mman.h
index d377dfc62..ebea80172 100644
--- a/include/asm-ppc/mman.h
+++ b/include/asm-ppc/mman.h
@@ -12,10 +12,11 @@
#define MAP_FIXED 0x10 /* Interpret addr exactly */
#define MAP_ANONYMOUS 0x20 /* don't use a file */
#define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */
+#define MAP_NORESERVE 0x40 /* don't reserve swap pages */
#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
+#define MAP_EXECUTABLE 0x1000 /* mark it as a executable */
#define MS_ASYNC 1 /* sync memory asynchronously */
#define MS_INVALIDATE 2 /* invalidate the caches */
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h
index b26b79cd6..1b3217cfd 100644
--- a/include/asm-ppc/mmu.h
+++ b/include/asm-ppc/mmu.h
@@ -6,7 +6,6 @@
#define _PPC_MMU_H_
/* Hardware Page Table Entry */
-
typedef struct _PTE
{
unsigned long v:1; /* Entry is valid */
@@ -32,7 +31,6 @@ typedef struct _PTE
#define PP_RXRX 3 /* Supervisor read, User read */
/* Segment Register */
-
typedef struct _SEGREG
{
unsigned long t:1; /* Normal or I/O type */
@@ -44,7 +42,6 @@ typedef struct _SEGREG
} SEGREG;
/* Block Address Translation (BAT) Registers */
-
typedef struct _BATU /* Upper part of BAT */
{
unsigned long bepi:15; /* Effective page index (virtual address) */
@@ -146,8 +143,6 @@ unsigned long sdr; /* Hardware image of SDR */
#define HASH_TABLE_MASK_2M 0x01F
#define HASH_TABLE_MASK_4M 0x03F
-#define MMU_PAGE_SIZE 4096
-
-extern int MMU_hash_page(struct thread_struct *tss, unsigned long va, pte *pg);
+extern inline int MMU_hash_page(struct thread_struct *tss, unsigned long va, pte *pg);
#endif
diff --git a/include/asm-ppc/mmu_context.h b/include/asm-ppc/mmu_context.h
index 8cee7fb30..f4bd1e84f 100644
--- a/include/asm-ppc/mmu_context.h
+++ b/include/asm-ppc/mmu_context.h
@@ -6,5 +6,8 @@
*/
#define get_mmu_context(x) do { } while (0)
+#define init_new_context(mm) do { } while(0)
+#define destroy_context(mm) do { } while(0)
+
#endif
diff --git a/include/asm-ppc/page.h b/include/asm-ppc/page.h
index 6984b2a08..273d31fd0 100644
--- a/include/asm-ppc/page.h
+++ b/include/asm-ppc/page.h
@@ -6,8 +6,6 @@
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
-void invalidate(void);
-
#ifdef __KERNEL__
#define STRICT_MM_TYPECHECKS
@@ -59,30 +57,15 @@ typedef unsigned long pgprot_t;
#define KERNELBASE 0x90000000
#define PAGE_OFFSET KERNELBASE
-#define MAP_NR(addr) ((((unsigned long)addr) - PAGE_OFFSET) >> PAGE_SHIFT)
-#define MAP_PAGE_RESERVED (1<<15)
-
-#if 0 /* Now defined in "mm.h" */
-/*
- * This used to be an unsigned short...
- *
- * -- Cort
- */
-/*typedef unsigned short mem_map_t;*/
+#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
+#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
+/* map phys->virtual and virtual->phys */
+#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
+#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
-typedef struct {
- unsigned count:30,
- dirty:1,
- reserved:1;
-} mem_map_t;
-#endif
-
-/* Certain architectures need to do special things when pte's
- * within a page table are directly modified. Thus, the following
- * hook is made available.
- */
-#define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
+#define MAP_NR(addr) (__pa(addr) >> PAGE_SHIFT)
+#define MAP_PAGE_RESERVED (1<<15)
#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
index b8425f882..243a0b115 100644
--- a/include/asm-ppc/pgtable.h
+++ b/include/asm-ppc/pgtable.h
@@ -5,75 +5,16 @@
#include <asm/page.h>
#include <asm/mmu.h>
-/*
- * Memory management on the PowerPC is a software emulation of the i386
- * MMU folded onto the PowerPC hardware MMU. The emulated version looks
- * and behaves like the two-level i386 MMU. Entries from these tables
- * are merged into the PowerPC hashed MMU tables, on demand, treating the
- * hashed tables like a special cache.
- *
- * Since the PowerPC does not have separate kernel and user address spaces,
- * the user virtual address space must be a [proper] subset of the kernel
- * space. Thus, all tasks will have a specific virtual mapping for the
- * user virtual space and a common mapping for the kernel space. The
- * simplest way to split this was literally in half. Also, life is so
- * much simpler for the kernel if the machine hardware resources are
- * always mapped in. Thus, some additional space is given up to the
- * kernel space to accommodate this.
- *
- * CAUTION! Some of the trade-offs make sense for the PreP platform on
- * which this code was originally developed. When it migrates to other
- * PowerPC environments, some of the assumptions may fail and the whole
- * setup may need to be reevaluated.
- *
- * On the PowerPC, page translations are kept in a hashed table. There
- * is exactly one of these tables [although the architecture supports
- * an arbitrary number]. Page table entries move in/out of this hashed
- * structure on demand, with the kernel filling in entries as they are
- * needed. Just where a page table entry hits in the hashed table is a
- * function of the hashing which is in turn based on the upper 4 bits
- * of the logical address. These 4 bits address a "virtual segment id"
- * which is unique per task/page combination for user addresses and
- * fixed for the kernel addresses. Thus, the kernel space can be simply
- * shared [indeed at low overhead] among all tasks.
- *
- * The basic virtual address space is thus:
- *
- * 0x0XXXXXX --+
- * 0x1XXXXXX |
- * 0x2XXXXXX | User address space.
- * 0x3XXXXXX |
- * 0x4XXXXXX |
- * 0x5XXXXXX |
- * 0x6XXXXXX |
- * 0x7XXXXXX --+
- * 0x8XXXXXX PCI/ISA I/O space
- * 0x9XXXXXX --+
- * 0xAXXXXXX | Kernel virtual memory
- * 0xBXXXXXX --+
- * 0xCXXXXXX PCI/ISA Memory space
- * 0xDXXXXXX
- * 0xEXXXXXX
- * 0xFXXXXXX Board I/O space
- *
- * CAUTION! One of the real problems here is keeping the software
- * managed tables coherent with the hardware hashed tables. When
- * the software decides to update the table, it's normally easy to
- * update the hardware table. But when the hardware tables need
- * changed, e.g. as the result of a page fault, it's more difficult
- * to reflect those changes back into the software entries. Currently,
- * this process is quite crude, with updates causing the entire set
- * of tables to become invalidated. Some performance could certainly
- * be regained by improving this.
- *
- * The Linux memory management assumes a three-level page table setup. On
- * the i386, 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
- * i386 mmu expects.
- *
- * This file contains the functions and defines necessary to modify and use
- * the i386 page table tree.
- */
+inline void flush_tlb(void);
+inline void flush_tlb_all(void);
+inline void flush_tlb_mm(struct mm_struct *mm);
+inline void flush_tlb_page(struct vm_area_struct *vma, long vmaddr);
+inline void flush_tlb_range(struct mm_struct *mm, long start, long end);
+inline void flush_page_to_ram(unsigned long);
+inline void really_flush_cache_all(void);
+
+/* only called from asm in head.S, so why bother? */
+/*void MMU_init(void);*/
/* PMD_SHIFT determines the size of the area a second-level page table can map */
#define PMD_SHIFT 22
@@ -100,8 +41,17 @@
* 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 ((high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
+/* this must be a decent size since the ppc bat's can map only certain sizes
+ but these can be different from the physical ram size configured.
+ bat mapping must map at least physical ram size and vmalloc start addr
+ must beging AFTER the area mapped by the bat.
+ 32 works for now, but may need to be changed with larger differences.
+ offset = next greatest bat mapping to ramsize - ramsize
+ (ie would be 0 if batmapping = ramsize)
+ -- Cort 10/6/96
+ */
+#define VMALLOC_OFFSET (32*1024*1024)
+#define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
#define VMALLOC_VMADDR(x) ((unsigned long)(x))
#define _PAGE_PRESENT 0x001
@@ -146,36 +96,16 @@
#define __S111 PAGE_SHARED
/*
- * TLB invalidation:
- *
- * - invalidate() invalidates the current mm struct TLBs
- * - invalidate_all() invalidates all processes TLBs
- * - invalidate_mm(mm) invalidates the specified mm context TLB's
- * - invalidate_page(mm, vmaddr) invalidates one page
- * - invalidate_range(mm, start, end) invalidates a range of pages
- *
- * FIXME: This could be done much better!
- */
-
-#define invalidate_all() printk("invalidate_all()\n");invalidate()
-#if 0
-#define invalidate_mm(mm_struct) \
-do { if ((mm_struct) == current->mm) invalidate(); else printk("Can't invalidate_mm(%x)\n", mm_struct);} while (0)
-#define invalidate_page(mm_struct,addr) \
-do { if ((mm_struct) == current->mm) invalidate(); else printk("Can't invalidate_page(%x,%x)\n", mm_struct, addr);} while (0)
-#define invalidate_range(mm_struct,start,end) \
-do { if ((mm_struct) == current->mm) invalidate(); else printk("Can't invalidate_range(%x,%x,%x)\n", mm_struct, start, end);} while (0)
-#endif
-
-/*
- * Define this if things work differently on an i386 and an i486:
- * it will (on an i486) warn about kernel memory accesses that are
+ * Define this if things work differently on a i386 and a i486:
+ * it will (on a i486) warn about kernel memory accesses that are
* done without a 'verify_area(VERIFY_WRITE,..)'
*/
#undef CONFIG_TEST_VERIFY_AREA
+#if 0
/* page table for 0-4MB for everybody */
extern unsigned long pg0[1024];
+#endif
/*
* BAD_PAGETABLE is used when we need a bogus page-table, while
@@ -187,11 +117,11 @@ extern unsigned long pg0[1024];
extern pte_t __bad_page(void);
extern pte_t * __bad_pagetable(void);
-extern unsigned long __zero_page(void);
+extern unsigned long empty_zero_page[1024];
#define BAD_PAGETABLE __bad_pagetable()
#define BAD_PAGE __bad_page()
-#define ZERO_PAGE __zero_page()
+#define ZERO_PAGE ((unsigned long) empty_zero_page)
/* number of bits that fit into a memory pointer */
#define BITS_PER_PTR (8*sizeof(unsigned long))
@@ -218,29 +148,13 @@ do { \
} \
} while (0)
-extern unsigned long high_memory;
+/* comes from include/linux/mm.h now -- Cort */
+/*extern void *high_memory;*/
extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_PRESENT; }
-#if 0
-extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)].reserved; }
-/*extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] != 1; }*/
-#endif
extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; }
-#if 0
-extern inline void pte_reuse(pte_t * ptep)
-{
- if (!mem_map[MAP_NR(ptep)].reserved)
- mem_map[MAP_NR(ptep)].count++;
-}
-#endif
-/*
- extern inline void pte_reuse(pte_t * ptep)
-{
- if (!(mem_map[MAP_NR(ptep)] & MAP_PAGE_RESERVED))
- mem_map[MAP_NR(ptep)]++;
-}
-*/
+
extern inline int pmd_none(pmd_t pmd) { return !pmd_val(pmd); }
extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~PAGE_MASK) != _PAGE_TABLE; }
extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_PRESENT; }
@@ -256,19 +170,8 @@ extern inline void pmd_reuse(pmd_t * pmdp) { }
extern inline int pgd_none(pgd_t pgd) { return 0; }
extern inline int pgd_bad(pgd_t pgd) { return 0; }
extern inline int pgd_present(pgd_t pgd) { return 1; }
-#if 0
-/*extern inline int pgd_inuse(pgd_t * pgdp) { return mem_map[MAP_NR(pgdp)] != 1; }*/
-extern inline int pgd_inuse(pgd_t *pgdp) { return mem_map[MAP_NR(pgdp)].reserved; }
-#endif
extern inline void pgd_clear(pgd_t * pgdp) { }
-/*
-extern inline void pgd_reuse(pgd_t * pgdp)
-{
- if (!mem_map[MAP_NR(pgdp)].reserved)
- mem_map[MAP_NR(pgdp)].count++;
-}
-*/
/*
* The following only work if pte_present() is true.
@@ -298,15 +201,24 @@ extern inline pte_t pte_mkcow(pte_t pte) { pte_val(pte) |= _PAGE_COW; return pte
* Conversion functions: convert a page and protection to a page entry,
* and a page entry and page directory to the page they refer to.
*/
+
+/* Certain architectures need to do special things when pte's
+ * within a page table are directly modified. Thus, the following
+ * hook is made available.
+ */
+#define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
+
+static pte_t mk_pte_phys(unsigned long page, pgprot_t pgprot)
+{ pte_t pte; pte_val(pte) = (page) | pgprot_val(pgprot); return pte; }
+/*#define mk_pte_phys(physpage, pgprot) \
+({ pte_t __pte; pte_val(__pte) = physpage + pgprot_val(pgprot); __pte; })*/
+
extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
{ pte_t pte; pte_val(pte) = page | pgprot_val(pgprot); return pte; }
extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
-/*extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
-{ pmd_val(*pmdp) = _PAGE_TABLE | ((((unsigned long) ptep) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
-*/
extern inline unsigned long pte_page(pte_t pte)
{ return pte_val(pte) & PAGE_MASK; }
@@ -314,6 +226,9 @@ extern inline unsigned long pmd_page(pmd_t pmd)
{ return pmd_val(pmd) & PAGE_MASK; }
+/* to find an entry in a kernel page-table-directory */
+#define pgd_offset_k(address) pgd_offset(&init_mm, address)
+
/* to find an entry in a page-table-directory */
extern inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
{
@@ -342,75 +257,6 @@ extern inline void pte_free_kernel(pte_t * pte)
{
free_page((unsigned long) pte);
}
-/*extern inline void pte_free_kernel(pte_t * pte)
-{
- mem_map[MAP_NR(pte)] = 1;
- free_page((unsigned long) pte);
-}
-*/
-
-/*
-extern inline pte_t * pte_alloc_kernel(pmd_t * pmd, unsigned long address)
-{
- address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
- if (pmd_none(*pmd)) {
- pte_t * page = (pte_t *) get_free_page(GFP_KERNEL);
- if (pmd_none(*pmd)) {
- if (page) {
- pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page;
- mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED;
- return page + address;
- }
- pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE;
- return NULL;
- }
- free_page((unsigned long) page);
- }
- if (pmd_bad(*pmd)) {
- printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
- pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE;
- return NULL;
- }
- return (pte_t *) pmd_page(*pmd) + address;
-}*/
-/*
-extern inline pte_t * pte_alloc_kernel(pmd_t *pmd, unsigned long address)
-{
-printk("pte_alloc_kernel pmd = %08X, address = %08X\n", pmd, address);
- address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
-printk("address now = %08X\n", address);
- if (pmd_none(*pmd)) {
- pte_t *page;
-printk("pmd_none(*pmd) true\n");
- page = (pte_t *) get_free_page(GFP_KERNEL);
-printk("page = %08X after get_free_page(%08X)\n",page,GFP_KERNEL);
- if (pmd_none(*pmd)) {
-printk("pmd_none(*pmd=%08X) still\n",*pmd);
- if (page) {
-printk("page true = %08X\n",page);
- pmd_set(pmd, page);
-printk("pmd_set(%08X,%08X)\n",pmd,page);
- mem_map[MAP_NR(page)].reserved = 1;
-printk("did mem_map\n",pmd,page);
- return page + address;
- }
-printk("did pmd_set(%08X, %08X\n",pmd,BAD_PAGETABLE);
- pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
- return NULL;
- }
-printk("did free_page(%08X)\n",page);
- free_page((unsigned long) page);
- }
- if (pmd_bad(*pmd)) {
- printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
- pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
- return NULL;
- }
-printk("returning pmd_page(%08X) + %08X\n",pmd_page(*pmd) , address);
-
- return (pte_t *) pmd_page(*pmd) + address;
-}
-*/
extern inline pte_t * pte_alloc_kernel(pmd_t * pmd, unsigned long address)
{
address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
@@ -501,30 +347,15 @@ extern inline pgd_t * pgd_alloc(void)
return (pgd_t *) get_free_page(GFP_KERNEL);
}
-extern pgd_t swapper_pg_dir[1024*8];
-/*extern pgd_t *swapper_pg_dir;*/
+extern pgd_t swapper_pg_dir[1024];
/*
* Software maintained MMU tables may have changed -- update the
* hardware [aka cache]
*/
extern inline void update_mmu_cache(struct vm_area_struct * vma,
- unsigned long address, pte_t _pte)
-{
-#if 0
- printk("Update MMU cache - VMA: %x, Addr: %x, PTE: %x\n", vma, address, *(long *)&_pte);
- _printk("Update MMU cache - VMA: %x, Addr: %x, PTE: %x\n", vma, address, *(long *)&_pte);
-/* MMU_hash_page(&(vma->vm_task)->tss, address & PAGE_MASK, (pte *)&_pte);*/
-#endif
- MMU_hash_page(&(current)->tss, address & PAGE_MASK, (pte *)&_pte);
-
-}
-
-
-#ifdef _SCHED_INIT_
-#define INIT_MMAP { &init_task, 0, 0x40000000, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC }
+ unsigned long address, pte_t _pte);
-#endif
#define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)
#define SWP_OFFSET(entry) ((entry) >> 8)
diff --git a/include/asm-ppc/pnp.h b/include/asm-ppc/pnp.h
new file mode 100644
index 000000000..53f27eff4
--- /dev/null
+++ b/include/asm-ppc/pnp.h
@@ -0,0 +1,641 @@
+/* 11/02/95 */
+/*----------------------------------------------------------------------------*/
+/* Plug and Play header definitions */
+/*----------------------------------------------------------------------------*/
+
+/* Structure map for PnP on PowerPC Reference Platform */
+/* See Plug and Play ISA Specification, Version 1.0, May 28, 1993. It */
+/* (or later versions) is available on Compuserve in the PLUGPLAY area. */
+/* This code has extensions to that specification, namely new short and */
+/* long tag types for platform dependent information */
+
+/* Warning: LE notation used throughout this file */
+
+/* For enum's: if given in hex then they are bit significant, i.e. */
+/* only one bit is on for each enum */
+
+#ifndef _PNP_
+#define _PNP_
+
+#define MAX_MEM_REGISTERS 9
+#define MAX_IO_PORTS 20
+#define MAX_IRQS 7
+#define MAX_DMA_CHANNELS 7
+
+/* Interrupt controllers */
+
+#define PNPinterrupt0 "PNP0000" /* AT Interrupt Controller */
+#define PNPinterrupt1 "PNP0001" /* EISA Interrupt Controller */
+#define PNPinterrupt2 "PNP0002" /* MCA Interrupt Controller */
+#define PNPinterrupt3 "PNP0003" /* APIC */
+#define PNPExtInt "IBM000D" /* PowerPC Extended Interrupt Controller */
+
+/* Timers */
+
+#define PNPtimer0 "PNP0100" /* AT Timer */
+#define PNPtimer1 "PNP0101" /* EISA Timer */
+#define PNPtimer2 "PNP0102" /* MCA Timer */
+
+/* DMA controllers */
+
+#define PNPdma0 "PNP0200" /* AT DMA Controller */
+#define PNPdma1 "PNP0201" /* EISA DMA Controller */
+#define PNPdma2 "PNP0202" /* MCA DMA Controller */
+
+/* start of August 15, 1994 additions */
+/* CMOS */
+#define PNPCMOS "IBM0009" /* CMOS */
+
+/* L2 Cache */
+#define PNPL2 "IBM0007" /* L2 Cache */
+
+/* NVRAM */
+#define PNPNVRAM "IBM0008" /* NVRAM */
+
+/* Power Management */
+#define PNPPM "IBM0005" /* Power Management */
+/* end of August 15, 1994 additions */
+
+/* Keyboards */
+
+#define PNPkeyboard0 "PNP0300" /* IBM PC/XT KB Cntlr (83 key, no mouse) */
+#define PNPkeyboard1 "PNP0301" /* Olivetti ICO (102 key) */
+#define PNPkeyboard2 "PNP0302" /* IBM PC/AT KB Cntlr (84 key) */
+#define PNPkeyboard3 "PNP0303" /* IBM Enhanced (101/2 key, PS/2 mouse) */
+#define PNPkeyboard4 "PNP0304" /* Nokia 1050 KB Cntlr */
+#define PNPkeyboard5 "PNP0305" /* Nokia 9140 KB Cntlr */
+#define PNPkeyboard6 "PNP0306" /* Standard Japanese KB Cntlr */
+#define PNPkeyboard7 "PNP0307" /* Microsoft Windows (R) KB Cntlr */
+
+/* Parallel port controllers */
+
+#define PNPparallel0 "PNP0400" /* Standard LPT Parallel Port */
+#define PNPparallel1 "PNP0401" /* ECP Parallel Port */
+#define PNPepp "IBM001C" /* EPP Parallel Port */
+
+/* Serial port controllers */
+
+#define PNPserial0 "PNP0500" /* Standard PC Serial port */
+#define PNPSerial1 "PNP0501" /* 16550A Compatible Serial port */
+
+/* Disk controllers */
+
+#define PNPdisk0 "PNP0600" /* Generic ESDI/IDE/ATA Compat HD Cntlr */
+#define PNPdisk1 "PNP0601" /* Plus Hardcard II */
+#define PNPdisk2 "PNP0602" /* Plus Hardcard IIXL/EZ */
+
+/* Diskette controllers */
+
+#define PNPdiskette0 "PNP0700" /* PC Standard Floppy Disk Controller */
+
+/* Display controllers */
+
+#define PNPdisplay0 "PNP0900" /* VGA Compatible */
+#define PNPdisplay1 "PNP0901" /* Video Seven VGA */
+#define PNPdisplay2 "PNP0902" /* 8514/A Compatible */
+#define PNPdisplay3 "PNP0903" /* Trident VGA */
+#define PNPdisplay4 "PNP0904" /* Cirrus Logic Laptop VGA */
+#define PNPdisplay5 "PNP0905" /* Cirrus Logic VGA */
+#define PNPdisplay6 "PNP0906" /* Tseng ET4000 or ET4000/W32 */
+#define PNPdisplay7 "PNP0907" /* Western Digital VGA */
+#define PNPdisplay8 "PNP0908" /* Western Digital Laptop VGA */
+#define PNPdisplay9 "PNP0909" /* S3 */
+#define PNPdisplayA "PNP090A" /* ATI Ultra Pro/Plus (Mach 32) */
+#define PNPdisplayB "PNP090B" /* ATI Ultra (Mach 8) */
+#define PNPdisplayC "PNP090C" /* XGA Compatible */
+#define PNPdisplayD "PNP090D" /* ATI VGA Wonder */
+#define PNPdisplayE "PNP090E" /* Weitek P9000 Graphics Adapter */
+#define PNPdisplayF "PNP090F" /* Oak Technology VGA */
+
+/* Peripheral busses */
+
+#define PNPbuses0 "PNP0A00" /* ISA Bus */
+#define PNPbuses1 "PNP0A01" /* EISA Bus */
+#define PNPbuses2 "PNP0A02" /* MCA Bus */
+#define PNPbuses3 "PNP0A03" /* PCI Bus */
+#define PNPbuses4 "PNP0A04" /* VESA/VL Bus */
+
+/* RTC, BIOS, planar devices */
+
+#define PNPspeaker0 "PNP0800" /* AT Style Speaker Sound */
+#define PNPrtc0 "PNP0B00" /* AT RTC */
+#define PNPpnpbios0 "PNP0C00" /* PNP BIOS (only created by root enum) */
+#define PNPpnpbios1 "PNP0C01" /* System Board Memory Device */
+#define PNPpnpbios2 "PNP0C02" /* Math Coprocessor */
+#define PNPpnpbios3 "PNP0C03" /* PNP BIOS Event Notification Interrupt */
+
+/* PCMCIA controller */
+
+#define PNPpcmcia0 "PNP0E00" /* Intel 82365 Compatible PCMCIA Cntlr */
+
+/* Mice */
+
+#define PNPmouse0 "PNP0F00" /* Microsoft Bus Mouse */
+#define PNPmouse1 "PNP0F01" /* Microsoft Serial Mouse */
+#define PNPmouse2 "PNP0F02" /* Microsoft Inport Mouse */
+#define PNPmouse3 "PNP0F03" /* Microsoft PS/2 Mouse */
+#define PNPmouse4 "PNP0F04" /* Mousesystems Mouse */
+#define PNPmouse5 "PNP0F05" /* Mousesystems 3 Button Mouse - COM2 */
+#define PNPmouse6 "PNP0F06" /* Genius Mouse - COM1 */
+#define PNPmouse7 "PNP0F07" /* Genius Mouse - COM2 */
+#define PNPmouse8 "PNP0F08" /* Logitech Serial Mouse */
+#define PNPmouse9 "PNP0F09" /* Microsoft Ballpoint Serial Mouse */
+#define PNPmouseA "PNP0F0A" /* Microsoft PNP Mouse */
+#define PNPmouseB "PNP0F0B" /* Microsoft PNP Ballpoint Mouse */
+
+/* Modems */
+
+#define PNPmodem0 "PNP9000" /* Specific IDs TBD */
+
+/* Network controllers */
+
+#define PNPnetworkC9 "PNP80C9" /* IBM Token Ring */
+#define PNPnetworkCA "PNP80CA" /* IBM Token Ring II */
+#define PNPnetworkCB "PNP80CB" /* IBM Token Ring II/Short */
+#define PNPnetworkCC "PNP80CC" /* IBM Token Ring 4/16Mbs */
+#define PNPnetwork27 "PNP8327" /* IBM Token Ring (All types) */
+#define PNPnetworket "IBM0010" /* IBM Ethernet used by Power PC */
+#define PNPneteisaet "IBM2001" /* IBM Ethernet EISA adapter */
+#define PNPAMD79C970 "IBM0016" /* AMD 79C970 (PCI Ethernet) */
+
+/* SCSI controllers */
+
+#define PNPscsi0 "PNPA000" /* Adaptec 154x Compatible SCSI Cntlr */
+#define PNPscsi1 "PNPA001" /* Adaptec 174x Compatible SCSI Cntlr */
+#define PNPscsi2 "PNPA002" /* Future Domain 16-700 Compat SCSI Cntlr*/
+#define PNPscsi3 "PNPA003" /* Panasonic CDROM Adapter (SBPro/SB16) */
+#define PNPscsiF "IBM000F" /* NCR 810 SCSI Controller */
+#define PNPscsi825 "IBM001B" /* NCR 825 SCSI Controller */
+#define PNPscsi875 "IBM0018" /* NCR 875 SCSI Controller */
+
+/* Sound/Video, Multimedia */
+
+#define PNPmm0 "PNPB000" /* Sound Blaster Compatible Sound Device */
+#define PNPmm1 "PNPB001" /* MS Windows Sound System Compat Device */
+#define PNPmmF "IBM000E" /* Crystal CS4231 Audio Device */
+#define PNPv7310 "IBM0015" /* ASCII V7310 Video Capture Device */
+#define PNPmm4232 "IBM0017" /* Crystal CS4232 Audio Device */
+#define PNPpmsyn "IBM001D" /* YMF 289B chip (Yamaha) */
+#define PNPgp4232 "IBM0012" /* Crystal CS4232 Game Port */
+#define PNPmidi4232 "IBM0013" /* Crystal CS4232 MIDI */
+
+/* Operator Panel */
+#define PNPopctl "IBM000B" /* Operator's panel */
+
+/* Service Processor */
+#define PNPsp "IBM0011" /* IBM Service Processor */
+#define PNPLTsp "IBM001E" /* Lightning/Terlingua Support Processor */
+#define PNPLTmsp "IBM001F" /* Lightning/Terlingua Mini-SP */
+
+/* Memory Controller */
+#define PNPmemctl "IBM000A" /* Memory controller */
+
+/* Graphics Assist */
+#define PNPg_assist "IBM0014" /* Graphics Assist */
+
+/* Miscellaneous Device Controllers */
+#define PNPtablet "IBM0019" /* IBM Tablet Controller */
+
+/* PNP Packet Handles */
+
+#define S1_Packet 0x0A /* Version resource */
+#define S2_Packet 0x15 /* Logical DEVID (without flags) */
+#define S2_Packet_flags 0x16 /* Logical DEVID (with flags) */
+#define S3_Packet 0x1C /* Compatible device ID */
+#define S4_Packet 0x22 /* IRQ resource (without flags) */
+#define S4_Packet_flags 0x23 /* IRQ resource (with flags) */
+#define S5_Packet 0x2A /* DMA resource */
+#define S6_Packet 0x30 /* Depend funct start (w/o priority) */
+#define S6_Packet_priority 0x31 /* Depend funct start (w/ priority) */
+#define S7_Packet 0x38 /* Depend funct end */
+#define S8_Packet 0x47 /* I/O port resource (w/o fixed loc) */
+#define S9_Packet_fixed 0x4B /* I/O port resource (w/ fixed loc) */
+#define S14_Packet 0x71 /* Vendor defined */
+#define S15_Packet 0x78 /* End of resource (w/o checksum) */
+#define S15_Packet_checksum 0x79 /* End of resource (w/ checksum) */
+#define L1_Packet 0x81 /* Memory range */
+#define L1_Shadow 0x20 /* Memory is shadowable */
+#define L1_32bit_mem 0x18 /* 32-bit memory only */
+#define L1_8_16bit_mem 0x10 /* 8- and 16-bit supported */
+#define L1_Decode_Hi 0x04 /* decode supports high address */
+#define L1_Cache 0x02 /* read cacheable, write-through */
+#define L1_Writeable 0x01 /* Memory is writeable */
+#define L2_Packet 0x82 /* ANSI ID string */
+#define L3_Packet 0x83 /* Unicode ID string */
+#define L4_Packet 0x84 /* Vendor defined */
+#define L5_Packet 0x85 /* Large I/O */
+#define L6_Packet 0x86 /* 32-bit Fixed Loc Mem Range Desc */
+#define END_TAG 0x78 /* End of resource */
+#define DF_START_TAG 0x30 /* Dependent function start */
+#define DF_START_TAG_priority 0x31 /* Dependent function start */
+#define DF_END_TAG 0x38 /* Dependent function end */
+#define SUBOPTIMAL_CONFIGURATION 0x2 /* Priority byte sub optimal config */
+
+/* Device Base Type Codes */
+
+typedef enum _PnP_BASE_TYPE {
+ Reserved = 0,
+ MassStorageDevice = 1,
+ NetworkInterfaceController = 2,
+ DisplayController = 3,
+ MultimediaController = 4,
+ MemoryController = 5,
+ BridgeController = 6,
+ CommunicationsDevice = 7,
+ SystemPeripheral = 8,
+ InputDevice = 9,
+ ServiceProcessor = 0x0A, /* 11/2/95 */
+ } PnP_BASE_TYPE;
+
+/* Device Sub Type Codes */
+
+typedef enum _PnP_SUB_TYPE {
+ SCSIController = 0,
+ IDEController = 1,
+ FloppyController = 2,
+ IPIController = 3,
+ OtherMassStorageController = 0x80,
+
+ EthernetController = 0,
+ TokenRingController = 1,
+ FDDIController = 2,
+ OtherNetworkController = 0x80,
+
+ VGAController= 0,
+ SVGAController= 1,
+ XGAController= 2,
+ OtherDisplayController = 0x80,
+
+ VideoController = 0,
+ AudioController = 1,
+ OtherMultimediaController = 0x80,
+
+ RAM = 0,
+ FLASH = 1,
+ OtherMemoryDevice = 0x80,
+
+ HostProcessorBridge = 0,
+ ISABridge = 1,
+ EISABridge = 2,
+ MicroChannelBridge = 3,
+ PCIBridge = 4,
+ PCMCIABridge = 5,
+ VMEBridge = 6,
+ OtherBridgeDevice = 0x80,
+
+ RS232Device = 0,
+ ATCompatibleParallelPort = 1,
+ OtherCommunicationsDevice = 0x80,
+
+ ProgrammableInterruptController = 0,
+ DMAController = 1,
+ SystemTimer = 2,
+ RealTimeClock = 3,
+ L2Cache = 4,
+ NVRAM = 5,
+ PowerManagement = 6,
+ CMOS = 7,
+ OperatorPanel = 8,
+ ServiceProcessorClass1 = 9,
+ ServiceProcessorClass2 = 0xA,
+ ServiceProcessorClass3 = 0xB,
+ GraphicAssist = 0xC,
+ SystemPlanar = 0xF, /* 10/5/95 */
+ OtherSystemPeripheral = 0x80,
+
+ KeyboardController = 0,
+ Digitizer = 1,
+ MouseController = 2,
+ TabletController = 3, /* 10/27/95 */
+ OtherInputController = 0x80,
+
+ GeneralMemoryController = 0,
+ } PnP_SUB_TYPE;
+
+/* Device Interface Type Codes */
+
+typedef enum _PnP_INTERFACE {
+ General = 0,
+ GeneralSCSI = 0,
+ GeneralIDE = 0,
+ ATACompatible = 1,
+
+ GeneralFloppy = 0,
+ Compatible765 = 1,
+ NS398_Floppy = 2, /* NS Super I/O wired to use index
+ register at port 398 and data
+ register at port 399 */
+ NS26E_Floppy = 3, /* Ports 26E and 26F */
+ NS15C_Floppy = 4, /* Ports 15C and 15D */
+ NS2E_Floppy = 5, /* Ports 2E and 2F */
+ CHRP_Floppy = 6, /* CHRP Floppy in PR*P system */
+
+ GeneralIPI = 0,
+
+ GeneralEther = 0,
+ GeneralToken = 0,
+ GeneralFDDI = 0,
+
+ GeneralVGA = 0,
+ GeneralSVGA = 0,
+ GeneralXGA = 0,
+
+ GeneralVideo = 0,
+ GeneralAudio = 0,
+ CS4232Audio = 1, /* CS 4232 Plug 'n Play Configured */
+
+ GeneralRAM = 0,
+ GeneralFLASH = 0,
+ PCIMemoryController = 0, /* PCI Config Method */
+ RS6KMemoryController = 1, /* RS6K Config Method */
+
+ GeneralHostBridge = 0,
+ GeneralISABridge = 0,
+ GeneralEISABridge = 0,
+ GeneralMCABridge = 0,
+ GeneralPCIBridge = 0,
+ PCIBridgeDirect = 0,
+ PCIBridgeIndirect = 1,
+ PCIBridgeRS6K = 2,
+ GeneralPCMCIABridge = 0,
+ GeneralVMEBridge = 0,
+
+ GeneralRS232 = 0,
+ COMx = 1,
+ Compatible16450 = 2,
+ Compatible16550 = 3,
+ NS398SerPort = 4, /* NS Super I/O wired to use index
+ register at port 398 and data
+ register at port 399 */
+ NS26ESerPort = 5, /* Ports 26E and 26F */
+ NS15CSerPort = 6, /* Ports 15C and 15D */
+ NS2ESerPort = 7, /* Ports 2E and 2F */
+
+ GeneralParPort = 0,
+ LPTx = 1,
+ NS398ParPort = 2, /* NS Super I/O wired to use index
+ register at port 398 and data
+ register at port 399 */
+ NS26EParPort = 3, /* Ports 26E and 26F */
+ NS15CParPort = 4, /* Ports 15C and 15D */
+ NS2EParPort = 5, /* Ports 2E and 2F */
+
+ GeneralPIC = 0,
+ ISA_PIC = 1,
+ EISA_PIC = 2,
+ MPIC = 3,
+ RS6K_PIC = 4,
+
+ GeneralDMA = 0,
+ ISA_DMA = 1,
+ EISA_DMA = 2,
+
+ GeneralTimer = 0,
+ ISA_Timer = 1,
+ EISA_Timer = 2,
+ GeneralRTC = 0,
+ ISA_RTC = 1,
+
+ StoreThruOnly = 1,
+ StoreInEnabled = 2,
+ RS6KL2Cache = 3,
+
+ IndirectNVRAM = 0, /* Indirectly addressed */
+ DirectNVRAM = 1, /* Memory Mapped */
+ IndirectNVRAM24 = 2, /* Indirectly addressed - 24 bit */
+
+ GeneralPowerManagement = 0,
+ EPOWPowerManagement = 1,
+ PowerControl = 2, // d1378
+
+ GeneralCMOS = 0,
+
+ GeneralOPPanel = 0,
+ HarddiskLight = 1,
+ CDROMLight = 2,
+ PowerLight = 3,
+ KeyLock = 4,
+ ANDisplay = 5, /* AlphaNumeric Display */
+ SystemStatusLED = 6, /* 3 digit 7 segment LED */
+ CHRP_SystemStatusLED = 7, /* CHRP LEDs in PR*P system */
+
+ GeneralServiceProcessor = 0,
+
+ TransferData = 1,
+ IGMC32 = 2,
+ IGMC64 = 3,
+
+ GeneralSystemPlanar = 0, /* 10/5/95 */
+
+ } PnP_INTERFACE;
+
+/* PnP resources */
+
+/* Compressed ASCII is 5 bits per char; 00001=A ... 11010=Z */
+
+typedef struct _SERIAL_ID {
+ unsigned char VendorID0; /* Bit(7)=0 */
+ /* Bits(6:2)=1st character in */
+ /* compressed ASCII */
+ /* Bits(1:0)=2nd character in */
+ /* compressed ASCII bits(4:3) */
+ unsigned char VendorID1; /* Bits(7:5)=2nd character in */
+ /* compressed ASCII bits(2:0) */
+ /* Bits(4:0)=3rd character in */
+ /* compressed ASCII */
+ unsigned char VendorID2; /* Product number - vendor assigned */
+ unsigned char VendorID3; /* Product number - vendor assigned */
+
+/* Serial number is to provide uniqueness if more than one board of same */
+/* type is in system. Must be "FFFFFFFF" if feature not supported. */
+
+ unsigned char Serial0; /* Unique serial number bits (7:0) */
+ unsigned char Serial1; /* Unique serial number bits (15:8) */
+ unsigned char Serial2; /* Unique serial number bits (23:16) */
+ unsigned char Serial3; /* Unique serial number bits (31:24) */
+ unsigned char Checksum;
+ } SERIAL_ID;
+
+typedef enum _PnPItemName {
+ Unused = 0,
+ PnPVersion = 1,
+ LogicalDevice = 2,
+ CompatibleDevice = 3,
+ IRQFormat = 4,
+ DMAFormat = 5,
+ StartDepFunc = 6,
+ EndDepFunc = 7,
+ IOPort = 8,
+ FixedIOPort = 9,
+ Res1 = 10,
+ Res2 = 11,
+ Res3 = 12,
+ SmallVendorItem = 14,
+ EndTag = 15,
+ MemoryRange = 1,
+ ANSIIdentifier = 2,
+ UnicodeIdentifier = 3,
+ LargeVendorItem = 4,
+ MemoryRange32 = 5,
+ MemoryRangeFixed32 = 6,
+ } PnPItemName;
+
+/* Define a bunch of access functions for the bits in the tag field */
+
+/* Tag type - 0 = small; 1 = large */
+#define tag_type(t) (((t) & 0x80)>>7)
+#define set_tag_type(t,v) (t = (t & 0x7f) | ((v)<<7))
+
+/* Small item name is 4 bits - one of PnPItemName enum above */
+#define tag_small_item_name(t) (((t) & 0x78)>>3)
+#define set_tag_small_item_name(t,v) (t = (t & 0x07) | ((v)<<3))
+
+/* Small item count is 3 bits - count of further bytes in packet */
+#define tag_small_count(t) ((t) & 0x07)
+#define set_tag_count(t,v) (t = (t & 0x78) | (v))
+
+/* Large item name is 7 bits - one of PnPItemName enum above */
+#define tag_large_item_name(t) ((t) & 0x7f)
+#define set_tag_large_item_name(t,v) (t = (t | 0x80) | (v))
+
+/* a PnP resource is a bunch of contiguous TAG packets ending with an end tag */
+
+typedef union _PnP_TAG_PACKET {
+ struct _S1_Pack{ /* VERSION PACKET */
+ unsigned char Tag; /* small tag = 0x0a */
+ unsigned char Version[2]; /* PnP version, Vendor version */
+ } S1_Pack;
+
+ struct _S2_Pack{ /* LOGICAL DEVICE ID PACKET */
+ unsigned char Tag; /* small tag = 0x15 or 0x16 */
+ unsigned char DevId[4]; /* Logical device id */
+ unsigned char Flags[2]; /* bit(0) boot device; */
+ /* bit(7:1) cmd in range x31-x37 */
+ /* bit(7:0) cmd in range x28-x3f (opt)*/
+ } S2_Pack;
+
+ struct _S3_Pack{ /* COMPATIBLE DEVICE ID PACKET */
+ unsigned char Tag; /* small tag = 0x1c */
+ unsigned char CompatId[4]; /* Compatible device id */
+ } S3_Pack;
+
+ struct _S4_Pack{ /* IRQ PACKET */
+ unsigned char Tag; /* small tag = 0x22 or 0x23 */
+ unsigned char IRQMask[2]; /* bit(0) is IRQ0, ...; */
+ /* bit(0) is IRQ8 ... */
+ unsigned char IRQInfo; /* optional; assume bit(0)=1; else */
+ /* bit(0) - high true edge sensitive */
+ /* bit(1) - low true edge sensitive */
+ /* bit(2) - high true level sensitive*/
+ /* bit(3) - low true level sensitive */
+ /* bit(7:4) - must be 0 */
+ } S4_Pack;
+
+ struct _S5_Pack{ /* DMA PACKET */
+ unsigned char Tag; /* small tag = 0x2a */
+ unsigned char DMAMask; /* bit(0) is channel 0 ... */
+ unsigned char DMAInfo;
+ } S5_Pack;
+
+ struct _S6_Pack{ /* START DEPENDENT FUNCTION PACKET */
+ unsigned char Tag; /* small tag = 0x30 or 0x31 */
+ unsigned char Priority; /* Optional; if missing then x01; else*/
+ /* x00 = best possible */
+ /* x01 = acceptible */
+ /* x02 = sub-optimal but functional */
+ } S6_Pack;
+
+ struct _S7_Pack{ /* END DEPENDENT FUNCTION PACKET */
+ unsigned char Tag; /* small tag = 0x38 */
+ } S7_Pack;
+
+ struct _S8_Pack{ /* VARIABLE I/O PORT PACKET */
+ unsigned char Tag; /* small tag x47 */
+ unsigned char IOInfo; /* x0 = decode only bits(9:0); */
+#define ISAAddr16bit 0x01 /* x01 = decode bits(15:0) */
+ unsigned char RangeMin[2]; /* Min base address */
+ unsigned char RangeMax[2]; /* Max base address */
+ unsigned char IOAlign; /* base alignmt, incr in 1B blocks */
+ unsigned char IONum; /* number of contiguous I/O ports */
+ } S8_Pack;
+
+ struct _S9_Pack{ /* FIXED I/O PORT PACKET */
+ unsigned char Tag; /* small tag = 0x4b */
+ unsigned char Range[2]; /* base address 10 bits */
+ unsigned char IONum; /* number of contiguous I/O ports */
+ } S9_Pack;
+
+ struct _S14_Pack{ /* VENDOR DEFINED PACKET */
+ unsigned char Tag; /* small tag = 0x7m m = 1-7 */
+ union _S14_Data{
+ unsigned char Data[7]; /* Vendor defined */
+ struct _S14_PPCPack{ /* Pr*p s14 pack */
+ unsigned char Type; /* 00=non-IBM */
+ unsigned char PPCData[6]; /* Vendor defined */
+ } S14_PPCPack;
+ } S14_Data;
+ } S14_Pack;
+
+ struct _S15_Pack{ /* END PACKET */
+ unsigned char Tag; /* small tag = 0x78 or 0x79 */
+ unsigned char Check; /* optional - checksum */
+ } S15_Pack;
+
+ struct _L1_Pack{ /* MEMORY RANGE PACKET */
+ unsigned char Tag; /* large tag = 0x81 */
+ unsigned char Count0; /* x09 */
+ unsigned char Count1; /* x00 */
+ unsigned char Data[9]; /* a variable array of bytes, */
+ /* count in tag */
+ } L1_Pack;
+
+ struct _L2_Pack{ /* ANSI ID STRING PACKET */
+ unsigned char Tag; /* large tag = 0x82 */
+ unsigned char Count0; /* Length of string */
+ unsigned char Count1;
+ unsigned char Identifier[1]; /* a variable array of bytes, */
+ /* count in tag */
+ } L2_Pack;
+
+ struct _L3_Pack{ /* UNICODE ID STRING PACKET */
+ unsigned char Tag; /* large tag = 0x83 */
+ unsigned char Count0; /* Length + 2 of string */
+ unsigned char Count1;
+ unsigned char Country0; /* TBD */
+ unsigned char Country1; /* TBD */
+ unsigned char Identifier[1]; /* a variable array of bytes, */
+ /* count in tag */
+ } L3_Pack;
+
+ struct _L4_Pack{ /* VENDOR DEFINED PACKET */
+ unsigned char Tag; /* large tag = 0x84 */
+ unsigned char Count0;
+ unsigned char Count1;
+ union _L4_Data{
+ unsigned char Data[1]; /* a variable array of bytes, */
+ /* count in tag */
+ struct _L4_PPCPack{ /* Pr*p L4 packet */
+ unsigned char Type; /* 00=non-IBM */
+ unsigned char PPCData[1]; /* a variable array of bytes, */
+ /* count in tag */
+ } L4_PPCPack;
+ } L4_Data;
+ } L4_Pack;
+
+ struct _L5_Pack{
+ unsigned char Tag; /* large tag = 0x85 */
+ unsigned char Count0; /* Count = 17 */
+ unsigned char Count1;
+ unsigned char Data[17];
+ } L5_Pack;
+
+ struct _L6_Pack{
+ unsigned char Tag; /* large tag = 0x86 */
+ unsigned char Count0; /* Count = 9 */
+ unsigned char Count1;
+ unsigned char Data[9];
+ } L6_Pack;
+
+ } PnP_TAG_PACKET;
+
+#endif /* ndef _PNP_ */
diff --git a/include/asm-ppc/posix_types.h b/include/asm-ppc/posix_types.h
index 0b180d795..72b24318e 100644
--- a/include/asm-ppc/posix_types.h
+++ b/include/asm-ppc/posix_types.h
@@ -22,6 +22,7 @@ typedef long __kernel_time_t;
typedef long __kernel_clock_t;
typedef int __kernel_daddr_t;
typedef char * __kernel_caddr_t;
+typedef short __kernel_ipc_pid_t;
#ifdef __GNUC__
typedef long long __kernel_loff_t;
@@ -74,7 +75,7 @@ static __inline__ int __FD_ISSET(unsigned long fd, __kernel_fd_set *p)
#undef __FD_ZERO
static __inline__ void __FD_ZERO(__kernel_fd_set *p)
{
- unsigned int *tmp = p->fds_bits;
+ unsigned int *tmp = (unsigned int *)p->fds_bits;
int i;
if (__builtin_constant_p(__FDSET_LONGS)) {
diff --git a/include/asm-ppc/ppc_machine.h b/include/asm-ppc/ppc_machine.h
index 2891e5a4f..1cf9a7930 100644
--- a/include/asm-ppc/ppc_machine.h
+++ b/include/asm-ppc/ppc_machine.h
@@ -5,6 +5,9 @@
#ifndef _PPC_MACHINE_H_
#define _PPC_MACHINE_H_
+#define KERNEL_STACK_SIZE (4096) /* usable stack -- not buffers at either end */
+#define KERNEL_STACK_MASK (~(KERNEL_STACK_SIZE-1))
+
/* Bit encodings for Machine State Register (MSR) */
#define MSR_POW (1<<18) /* Enable Power Management */
#define MSR_TGPR (1<<17) /* TLB Update registers in use */
@@ -23,8 +26,8 @@
#define MSR_RI (1<<1) /* Recoverable Exception */
#define MSR_LE (1<<0) /* Little-Endian enable */
-#define MSR_ MSR_FP|MSR_FE0|MSR_FE1|MSR_ME
-#define MSR_USER MSR_|MSR_PR|MSR_EE|MSR_IR|MSR_DR
+#define MSR_ MSR_FE0|MSR_FE1|MSR_ME|MSR_FP
+#define MSR_USER MSR_FE0|MSR_FE1|MSR_ME|MSR_PR|MSR_EE|MSR_IR|MSR_DR
/* Bit encodings for Hardware Implementation Register (HID0) */
#define HID0_EMCP (1<<31) /* Enable Machine Check pin */
@@ -46,5 +49,8 @@
#define HID0_DCI (1<<10) /* Data Cache Invalidate */
#define HID0_SIED (1<<7) /* Serial Instruction Execution [Disable] */
#define HID0_BHTE (1<<2) /* Branch History Table Enable */
-
+
+/* fpscr settings */
+#define FPSCR_FX (1<<31)
+#define FPSCR_FEX (1<<30)
#endif
diff --git a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h
index e14f2b270..ef797b4a7 100644
--- a/include/asm-ppc/processor.h
+++ b/include/asm-ppc/processor.h
@@ -5,8 +5,8 @@
* PowerPC machine specifics
*/
-#ifndef _PPC_MACHINE_H_
-#define _PPC_MACHINE_H_
+#define KERNEL_STACK_SIZE (4096) /* usable stack -- not buffers at either end */
+#define KERNEL_STACK_MASK (~(KERNEL_STACK_SIZE-1))
/* Bit encodings for Machine State Register (MSR) */
#define MSR_POW (1<<18) /* Enable Power Management */
@@ -26,8 +26,8 @@
#define MSR_RI (1<<1) /* Recoverable Exception */
#define MSR_LE (1<<0) /* Little-Endian enable */
-#define MSR_ MSR_FP|MSR_FE0|MSR_FE1|MSR_ME
-#define MSR_USER MSR_|MSR_PR|MSR_EE|MSR_IR|MSR_DR
+#define MSR_ MSR_FE0|MSR_FE1|MSR_ME|MSR_FP
+#define MSR_USER MSR_FE0|MSR_FE1|MSR_ME|MSR_PR|MSR_EE|MSR_IR|MSR_DR
/* Bit encodings for Hardware Implementation Register (HID0) */
#define HID0_EMCP (1<<31) /* Enable Machine Check pin */
@@ -47,15 +47,20 @@
#define HID0_DLOCK (1<<12) /* Data Cache Lock */
#define HID0_ICFI (1<<11) /* Instruction Cache Flash Invalidate */
#define HID0_DCI (1<<10) /* Data Cache Invalidate */
-
-#endif
+#define HID0_SIED (1<<7) /* Serial Instruction Execution [Disable] */
+#define HID0_BHTE (1<<2) /* Branch History Table Enable */
+
+/* fpscr settings */
+#define FPSCR_FX (1<<31)
+#define FPSCR_FEX (1<<30)
-static inline void start_thread(struct pt_regs * regs, unsigned long eip, unsigned long esp)
-{
- regs->nip = eip;
- regs->gpr[1] = esp;
- regs->msr = MSR_USER;
-}
+
+
+#ifndef __ASSEMBLY__
+/*
+ * PowerPC machine specifics
+ */
+extern inline void start_thread(struct pt_regs *, unsigned long, unsigned long );
/*
@@ -69,7 +74,6 @@ static inline void start_thread(struct pt_regs * regs, unsigned long eip, unsign
/*
* Write Protection works right in supervisor mode on the PowerPC
*/
-
#define wp_works_ok 1
#define wp_works_ok__is_a_macro /* for versions in ksyms.c */
@@ -81,28 +85,41 @@ static inline void start_thread(struct pt_regs * regs, unsigned long eip, unsign
*/
#define TASK_SIZE (0x80000000UL)
+/* This decides where the kernel will search for a free chunk of vm
+ * space during mmap's.
+ */
+#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
+
struct thread_struct
- {
- unsigned long ksp; /* Kernel stack pointer */
- unsigned long *pg_tables; /* MMU information */
- unsigned long segs[16]; /* MMU Segment registers */
- unsigned long last_pc; /* PC when last entered system */
- unsigned long user_stack; /* [User] Stack when entered kernel */
- double fpr[32]; /* Complete floating point set */
- unsigned long wchan; /* Event task is sleeping on */
- unsigned long *regs; /* Pointer to saved register state */
- };
+{
+ unsigned long ksp; /* Kernel stack pointer */
+ unsigned long *pg_tables; /* MMU information */
+ unsigned long segs[16]; /* MMU Segment registers */
+ unsigned long last_pc; /* PC when last entered system */
+ unsigned long user_stack; /* [User] Stack when entered kernel */
+ double fpr[32]; /* Complete floating point set */
+ unsigned long wchan; /* Event task is sleeping on */
+ unsigned long *regs; /* Pointer to saved register state */
+ unsigned long fp_used; /* number of quantums fp was used */
+ unsigned long fs; /* for get_fs() validation */
+ unsigned long expc; /* exception handler addr (see fault.c) */
+ unsigned long excount; /* exception handler count */
+};
+
#define INIT_TSS { \
+ sizeof(init_kernel_stack) + (long) &init_kernel_stack,\
+ (long *)swapper_pg_dir, {0}, \
0, 0, {0}, \
- 0, 0, {0}, \
+ 0, 0, 0, \
+ KERNEL_DS, 0, 0 \
}
#define INIT_MMAP { &init_mm, 0, 0x40000000, \
PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC }
-#define alloc_kernel_stack() get_free_page(GFP_KERNEL)
-#define free_kernel_stack(page) free_page((page))
+/* Free all resources held by a thread. */
+extern void release_thread(struct task_struct *);
/*
* Return saved PC of a blocked thread. For now, this is the "user" PC
@@ -112,6 +129,28 @@ static inline unsigned long thread_saved_pc(struct thread_struct *t)
return (t->last_pc);
}
+#define _PROC_Motorola 0
+#define _PROC_IBM 1
+#define _PROC_Be 2
+
+int _Processor;
+
+/* Allocation and freeing of basic task resources. */
+#define alloc_task_struct() kmalloc(sizeof(struct task_struct), GFP_KERNEL)
+#define free_task_struct(p) kfree(p)
+
+#ifdef KERNEL_STACK_BUFFER
+/* give a 1 page buffer below the stack - if change then change ppc_machine.h */
+#define alloc_kernel_stack() \
+ (memset((void *)__get_free_pages(GFP_KERNEL,1,0),0,KERNEL_STACK_SIZE+PAGE_SIZE)+PAGE_SIZE)
+#define free_kernel_stack(page) free_pages((page)-PAGE_SIZE,1)
+#else
+#define alloc_kernel_stack() get_free_page(GFP_KERNEL)
+#define free_kernel_stack(page) free_page((page))
+#endif
+
+#endif /* ASSEMBLY*/
+
/*
* Return_address is a replacement for __builtin_return_address(count)
* which on certain architectures cannot reasonably be implemented in GCC
diff --git a/include/asm-ppc/ptrace.h b/include/asm-ppc/ptrace.h
index c654d86b7..5bad3b9da 100644
--- a/include/asm-ppc/ptrace.h
+++ b/include/asm-ppc/ptrace.h
@@ -1,7 +1,6 @@
#ifndef _PPC_PTRACE_H
#define _PPC_PTRACE_H
-
/*
* This struct defines the way the registers are stored on the
* kernel stack during a system call or other kernel entry.
@@ -21,27 +20,28 @@
*/
struct pt_regs {
- unsigned long _overhead[14]; /* Callee's SP,LR,params */
- unsigned long gpr[32];
- unsigned long nip;
- unsigned long msr;
- unsigned long ctr;
- unsigned long link;
- unsigned long ccr;
- unsigned long xer;
- unsigned long dar; /* Fault registers */
- unsigned long dsisr;
- unsigned long hash1, hash2;
- unsigned long imiss, dmiss;
- unsigned long icmp, dcmp;
- unsigned long orig_gpr3; /* Used for restarting system calls */
- unsigned long result; /* Result of a system call */
- double fpr[4]; /* Caution! Only FP0-FP3 save on interrupts */
- double fpcsr;
- unsigned long trap; /* Reason for being here */
- unsigned long marker; /* Should have DEADDEAD */
- unsigned long _underhead[20]; /* Callee's register save area */
- unsigned long edx; /* for binfmt_elf.c which wants edx */
+ unsigned long _overhead[14]; /* Callee's SP,LR,params */
+ unsigned long gpr[32];
+ unsigned long nip;
+ unsigned long msr;
+ unsigned long ctr;
+ unsigned long link;
+ unsigned long ccr;
+ unsigned long xer;
+ unsigned long dar; /* Fault registers */
+ unsigned long dsisr;
+ unsigned long srr1;
+ unsigned long srr0;
+ unsigned long hash1, hash2;
+ unsigned long imiss, dmiss;
+ unsigned long icmp, dcmp;
+ unsigned long orig_gpr3; /* Used for restarting system calls */
+ unsigned long result; /* Result of a system call */
+ double fpcsr;
+ unsigned long trap; /* Reason for being here */
+ unsigned long marker; /* Should have DEADDEAD */
+ /*unsigned long _underhead[20]; *//* Callee's register save area */
+ unsigned long edx; /* for binfmt_elf.c which wants edx */
};
#define instruction_pointer(regs) ((regs)->nip)
diff --git a/include/asm-ppc/residual.h b/include/asm-ppc/residual.h
new file mode 100644
index 000000000..3812decf6
--- /dev/null
+++ b/include/asm-ppc/residual.h
@@ -0,0 +1,315 @@
+/* 7/18/95 */
+/*----------------------------------------------------------------------------*/
+/* Residual Data header definitions and prototypes */
+/*----------------------------------------------------------------------------*/
+
+/* Structure map for RESIDUAL on PowerPC Reference Platform */
+/* residual.h - Residual data structure passed in r3. */
+/* Load point passed in r4 to boot image. */
+/* For enum's: if given in hex then they are bit significant, */
+/* i.e. only one bit is on for each enum */
+/* Reserved fields must be filled with zeros. */
+
+#ifndef _RESIDUAL_
+#define _RESIDUAL_
+
+#define MAX_CPUS 32 /* These should be set to the maximum */
+#define MAX_MEMS 64 /* number possible for this system. */
+#define MAX_DEVICES 256 /* Changing these will change the */
+#define AVE_PNP_SIZE 32 /* structure, hence the version of */
+#define MAX_MEM_SEGS 64 /* this header file. */
+
+/*----------------------------------------------------------------------------*/
+/* Public structures... */
+/*----------------------------------------------------------------------------*/
+
+#include "pnp.h"
+
+typedef enum _L1CACHE_TYPE {
+ NoneCAC = 0,
+ SplitCAC = 1,
+ CombinedCAC = 2
+ } L1CACHE_TYPE;
+
+typedef enum _TLB_TYPE {
+ NoneTLB = 0,
+ SplitTLB = 1,
+ CombinedTLB = 2
+ } TLB_TYPE;
+
+typedef enum _FIRMWARE_SUPPORT {
+ Conventional = 0x01,
+ OpenFirmware = 0x02,
+ Diagnostics = 0x04,
+ LowDebug = 0x08,
+ Multiboot = 0x10,
+ LowClient = 0x20,
+ Hex41 = 0x40,
+ FAT = 0x80,
+ ISO9660 = 0x0100,
+ SCSI_InitiatorID_Override = 0x0200,
+ Tape_Boot = 0x0400,
+ FW_Boot_Path = 0x0800
+ } FIRMWARE_SUPPORT;
+
+typedef enum _FIRMWARE_SUPPLIERS {
+ IBMFirmware = 0x00,
+ MotoFirmware = 0x01, /* 7/18/95 */
+ FirmWorks = 0x02, /* 10/5/95 */
+ Bull = 0x03, /* 04/03/96 */
+ } FIRMWARE_SUPPLIERS;
+
+typedef enum _ENDIAN_SWITCH_METHODS {
+ UsePort92 = 0x01,
+ UsePCIConfigA8 = 0x02,
+ UseFF001030 = 0x03,
+ } ENDIAN_SWITCH_METHODS;
+
+typedef enum _SPREAD_IO_METHODS {
+ UsePort850 = 0x00,
+/*UsePCIConfigA8 = 0x02,*/
+ } SPREAD_IO_METHODS;
+
+typedef struct _VPD {
+
+ /* Box dependent stuff */
+ unsigned char PrintableModel[32]; /* Null terminated string.
+ Must be of the form:
+ vvv,<20h>,<model designation>,<0x0>
+ where vvv is the vendor ID
+ e.g. IBM PPS MODEL 6015<0x0> */
+ unsigned char Serial[16]; /* 12/94:
+ Serial Number; must be of the form:
+ vvv<serial number> where vvv is the
+ vendor ID.
+ e.g. IBM60151234567<20h><20h> */
+ unsigned char Reserved[48];
+ unsigned long FirmwareSupplier; /* See FirmwareSuppliers enum */
+ unsigned long FirmwareSupports; /* See FirmwareSupport enum */
+ unsigned long NvramSize; /* Size of nvram in bytes */
+ unsigned long NumSIMMSlots;
+ unsigned short EndianSwitchMethod; /* See EndianSwitchMethods enum */
+ unsigned short SpreadIOMethod; /* See SpreadIOMethods enum */
+ unsigned long SmpIar;
+ unsigned long RAMErrLogOffset; /* Heap offset to error log */
+ unsigned long Reserved5;
+ unsigned long Reserved6;
+ unsigned long ProcessorHz; /* Processor clock frequency in Hertz */
+ unsigned long ProcessorBusHz; /* Processor bus clock frequency */
+ unsigned long Reserved7;
+ unsigned long TimeBaseDivisor; /* (Bus clocks per timebase tic)*1000 */
+ unsigned long WordWidth; /* Word width in bits */
+ unsigned long PageSize; /* Page size in bytes */
+ unsigned long CoherenceBlockSize; /* Unit of transfer in/out of cache
+ for which coherency is maintained;
+ normally <= CacheLineSize. */
+ unsigned long GranuleSize; /* Unit of lock allocation to avoid */
+ /* false sharing of locks. */
+
+ /* L1 Cache variables */
+ unsigned long CacheSize; /* L1 Cache size in KB. This is the */
+ /* total size of the L1, whether */
+ /* combined or split */
+ unsigned long CacheAttrib; /* L1CACHE_TYPE */
+ unsigned long CacheAssoc; /* L1 Cache associativity. Use this
+ for combined cache. If split, put
+ zeros here. */
+ unsigned long CacheLineSize; /* L1 Cache line size in bytes. Use
+ for combined cache. If split, put
+ zeros here. */
+ /* For split L1 Cache: (= combined if combined cache) */
+ unsigned long I_CacheSize;
+ unsigned long I_CacheAssoc;
+ unsigned long I_CacheLineSize;
+ unsigned long D_CacheSize;
+ unsigned long D_CacheAssoc;
+ unsigned long D_CacheLineSize;
+
+ /* Translation Lookaside Buffer variables */
+ unsigned long TLBSize; /* Total number of TLBs on the system */
+ unsigned long TLBAttrib; /* Combined I+D or split TLB */
+ unsigned long TLBAssoc; /* TLB Associativity. Use this for
+ combined TLB. If split, put zeros
+ here. */
+ /* For split TLB: (= combined if combined TLB) */
+ unsigned long I_TLBSize;
+ unsigned long I_TLBAssoc;
+ unsigned long D_TLBSize;
+ unsigned long D_TLBAssoc;
+
+ unsigned long ExtendedVPD; /* Offset to extended VPD area;
+ null if unused */
+ } VPD;
+
+typedef enum _DEVICE_FLAGS {
+ Enabled = 0x4000, /* 1 - PCI device is enabled */
+ Integrated = 0x2000,
+ Failed = 0x1000, /* 1 - device failed POST code tests */
+ Static = 0x0800, /* 0 - dynamically configurable
+ 1 - static */
+ Dock = 0x0400, /* 0 - not a docking station device
+ 1 - is a docking station device */
+ Boot = 0x0200, /* 0 - device cannot be used for BOOT
+ 1 - can be a BOOT device */
+ Configurable = 0x0100, /* 1 - device is configurable */
+ Disableable = 0x80, /* 1 - device can be disabled */
+ PowerManaged = 0x40, /* 0 - not managed; 1 - managed */
+ ReadOnly = 0x20, /* 1 - device is read only */
+ Removable = 0x10, /* 1 - device is removable */
+ ConsoleIn = 0x08,
+ ConsoleOut = 0x04,
+ Input = 0x02,
+ Output = 0x01
+ } DEVICE_FLAGS;
+
+typedef enum _BUS_ID {
+ ISADEVICE = 0x01,
+ EISADEVICE = 0x02,
+ PCIDEVICE = 0x04,
+ PCMCIADEVICE = 0x08,
+ PNPISADEVICE = 0x10,
+ MCADEVICE = 0x20,
+ MXDEVICE = 0x40, /* Devices on mezzanine bus */
+ PROCESSORDEVICE = 0x80, /* Devices on processor bus */
+ VMEDEVICE = 0x100,
+ } BUS_ID;
+
+typedef struct _DEVICE_ID {
+ unsigned long BusId; /* See BUS_ID enum above */
+ unsigned long DevId; /* Big Endian format */
+ unsigned long SerialNum; /* For multiple usage of a single
+ DevId */
+ unsigned long Flags; /* See DEVICE_FLAGS enum above */
+ unsigned char BaseType; /* See pnp.h for bit definitions */
+ unsigned char SubType; /* See pnp.h for bit definitions */
+ unsigned char Interface; /* See pnp.h for bit definitions */
+ unsigned char Spare;
+ } DEVICE_ID;
+
+typedef union _BUS_ACCESS {
+ struct _PnPAccess{
+ unsigned char CSN;
+ unsigned char LogicalDevNumber;
+ unsigned short ReadDataPort;
+ } PnPAccess;
+ struct _ISAAccess{
+ unsigned char SlotNumber; /* ISA Slot Number generally not
+ available; 0 if unknown */
+ unsigned char LogicalDevNumber;
+ unsigned short ISAReserved;
+ } ISAAccess;
+ struct _MCAAccess{
+ unsigned char SlotNumber;
+ unsigned char LogicalDevNumber;
+ unsigned short MCAReserved;
+ } MCAAccess;
+ struct _PCMCIAAccess{
+ unsigned char SlotNumber;
+ unsigned char LogicalDevNumber;
+ unsigned short PCMCIAReserved;
+ } PCMCIAAccess;
+ struct _EISAAccess{
+ unsigned char SlotNumber;
+ unsigned char FunctionNumber;
+ unsigned short EISAReserved;
+ } EISAAccess;
+ struct _PCIAccess{
+ unsigned char BusNumber;
+ unsigned char DevFuncNumber;
+ unsigned short PCIReserved;
+ } PCIAccess;
+ struct _ProcBusAccess{
+ unsigned char BusNumber;
+ unsigned char BUID;
+ unsigned short ProcBusReserved;
+ } ProcBusAccess;
+ } BUS_ACCESS;
+
+/* Per logical device information */
+typedef struct _PPC_DEVICE {
+ DEVICE_ID DeviceId;
+ BUS_ACCESS BusAccess;
+
+ /* The following three are offsets into the DevicePnPHeap */
+ /* All are in PnP compressed format */
+ unsigned long AllocatedOffset; /* Allocated resource description */
+ unsigned long PossibleOffset; /* Possible resource description */
+ unsigned long CompatibleOffset; /* Compatible device identifiers */
+ } PPC_DEVICE;
+
+typedef enum _CPU_STATE {
+ CPU_GOOD = 0, /* CPU is present, and active */
+ CPU_GOOD_FW = 1, /* CPU is present, and in firmware */
+ CPU_OFF = 2, /* CPU is present, but inactive */
+ CPU_FAILED = 3, /* CPU is present, but failed POST */
+ CPU_NOT_PRESENT = 255 /* CPU not present */
+ } CPU_STATE;
+
+typedef struct _PPC_CPU {
+ unsigned long CpuType; /* Result of mfspr from Processor
+ Version Register (PVR).
+ PVR(0-15) = Version (e.g. 601)
+ PVR(16-31 = EC Level */
+ unsigned char CpuNumber; /* CPU Number for this processor */
+ unsigned char CpuState; /* CPU State, see CPU_STATE enum */
+ unsigned short Reserved;
+ } PPC_CPU;
+
+typedef struct _PPC_MEM {
+ unsigned long SIMMSize; /* 0 - absent or bad
+ 8M, 32M (in MB) */
+ } PPC_MEM;
+
+typedef enum _MEM_USAGE {
+ Other = 0x8000,
+ ResumeBlock = 0x4000, /* for use by power management */
+ SystemROM = 0x2000, /* Flash memory (populated) */
+ UnPopSystemROM = 0x1000, /* Unpopulated part of SystemROM area */
+ IOMemory = 0x0800,
+ SystemIO = 0x0400,
+ SystemRegs = 0x0200,
+ PCIAddr = 0x0100,
+ PCIConfig = 0x80,
+ ISAAddr = 0x40,
+ Unpopulated = 0x20, /* Unpopulated part of System Memory */
+ Free = 0x10, /* Free part of System Memory */
+ BootImage = 0x08, /* BootImage part of System Memory */
+ FirmwareCode = 0x04, /* FirmwareCode part of System Memory */
+ FirmwareHeap = 0x02, /* FirmwareHeap part of System Memory */
+ FirmwareStack = 0x01 /* FirmwareStack part of System Memory*/
+ } MEM_USAGE;
+
+typedef struct _MEM_MAP {
+ unsigned long Usage; /* See MEM_USAGE above */
+ unsigned long BasePage; /* Page number measured in 4KB pages */
+ unsigned long PageCount; /* Page count measured in 4KB pages */
+ } MEM_MAP;
+
+typedef struct _RESIDUAL {
+ unsigned long ResidualLength; /* Length of Residual */
+ unsigned char Version; /* of this data structure */
+ unsigned char Revision; /* of this data structure */
+ unsigned short EC; /* of this data structure */
+ /* VPD */
+ VPD VitalProductData;
+ /* CPU */
+ unsigned short MaxNumCpus; /* Max CPUs in this system */
+ unsigned short ActualNumCpus; /* ActualNumCpus < MaxNumCpus means */
+ /* that there are unpopulated or */
+ /* otherwise unusable cpu locations */
+ PPC_CPU Cpus[MAX_CPUS];
+ /* Memory */
+ unsigned long TotalMemory; /* Total amount of memory installed */
+ unsigned long GoodMemory; /* Total amount of good memory */
+ unsigned long ActualNumMemSegs;
+ MEM_MAP Segs[MAX_MEM_SEGS];
+ unsigned long ActualNumMemories;
+ PPC_MEM Memories[MAX_MEMS];
+ /* Devices */
+ unsigned long ActualNumDevices;
+ PPC_DEVICE Devices[MAX_DEVICES];
+ unsigned char DevicePnPHeap[2*MAX_DEVICES*AVE_PNP_SIZE];
+ } RESIDUAL;
+
+#endif /* ndef _RESIDUAL_ */
+
diff --git a/include/asm-ppc/resource.h b/include/asm-ppc/resource.h
index 2cffda871..bd0d5e02d 100644
--- a/include/asm-ppc/resource.h
+++ b/include/asm-ppc/resource.h
@@ -1,35 +1,33 @@
#ifndef _PPC_RESOURCE_H
#define _PPC_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_NOFILE 6 /* max number of open files */
+#define RLIMIT_AS 7 /* address space limit(?) */
+#define RLIMIT_NPROC 8 /* max number of processes */
+#define RLIMIT_MEMLOCK 9 /* max locked-in-memory address space */
-#define RLIM_NLIMITS 9
+#define RLIM_NLIMITS 10
#ifdef __KERNEL__
-#define INIT_RLIMITS \
-{ \
- { LONG_MAX, LONG_MAX }, \
- { LONG_MAX, LONG_MAX }, \
- { LONG_MAX, LONG_MAX }, \
- { _STK_LIM, _STK_LIM }, \
- { 0, LONG_MAX }, \
- { LONG_MAX, LONG_MAX }, \
- { MAX_TASKS_PER_USER, MAX_TASKS_PER_USER }, \
- { NR_OPEN, NR_OPEN }, \
- { LONG_MAX, LONG_MAX }, \
+#define INIT_RLIMITS \
+{ \
+ {LONG_MAX, LONG_MAX}, /* RLIMIT_CPU */ \
+ {LONG_MAX, LONG_MAX}, /* RLIMIT_FSIZE */ \
+ {LONG_MAX, LONG_MAX}, /* RLIMIT_DATA */ \
+ {_STK_LIM, _STK_LIM}, /* RLIMIT_STACK */ \
+ { 0, LONG_MAX}, /* RLIMIT_CORE */ \
+ {LONG_MAX, LONG_MAX}, /* RLIMIT_RSS */ \
+ { NR_OPEN, NR_OPEN}, /* RLIMIT_NOFILE */ \
+ {LONG_MAX, LONG_MAX}, /* RLIMIT_AS */ \
+ {MAX_TASKS_PER_USER, MAX_TASKS_PER_USER}, /* RLIMIT_NPROC */ \
+ {LONG_MAX, LONG_MAX}, /* RLIMIT_MEMLOCK */ \
}
#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/scatterlist.h b/include/asm-ppc/scatterlist.h
new file mode 100644
index 000000000..80aa3b64a
--- /dev/null
+++ b/include/asm-ppc/scatterlist.h
@@ -0,0 +1,13 @@
+#ifndef _PPC_SCATTERLIST_H
+#define _PPC_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 (0x00ffffff)
+
+#endif /* !(_PPC_SCATTERLIST_H) */
diff --git a/include/asm-ppc/segment.h b/include/asm-ppc/segment.h
index ee728959c..0eef1e5e7 100644
--- a/include/asm-ppc/segment.h
+++ b/include/asm-ppc/segment.h
@@ -1,131 +1,7 @@
-#ifndef _ASM_PPC_SEGMENT_H
-#define _ASM_PPC_SEGMENT_H
+#ifndef __PPC_SEGMENT_H
+#define __PPC_SEGMENT_H
-#include <linux/string.h>
+/* Only here because we have some old header files that expect it.. */
-#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
-#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
-
-extern int bad_user_access_length(void);
-
-static inline void __put_user(unsigned long x, void * y, int size)
-{
- switch (size) {
- case 1:
- *(char *) y = x;
- break;
- case 2:
- *(short *) y = x;
- break;
- case 4:
- *(int *) y = x;
- break;
- case 8:
- *(long *) y = x;
- break;
- default:
- bad_user_access_length();
- }
-}
-
-static inline unsigned long __get_user(const void * y, int size)
-{
- switch (size) {
- case 1:
- return *(unsigned char *) y;
- case 2:
- return *(unsigned short *) y;
- case 4:
- return *(unsigned int *) y;
- case 8:
- return *(unsigned long *) y;
- default:
- return bad_user_access_length();
- }
-}
-
-static inline unsigned char get_user_byte(const char * addr)
-{
- return *addr;
-}
-
-#define get_fs_byte(addr) get_user_byte((char *)(addr))
-
-static inline unsigned short get_user_word(const short *addr)
-{
- return *addr;
-}
-
-#define get_fs_word(addr) get_user_word((short *)(addr))
-
-static inline unsigned long get_user_long(const int *addr)
-{
- return *addr;
-}
-
-#define get_fs_long(addr) get_user_long((int *)(addr))
-
-static inline unsigned long get_user_quad(const long *addr)
-{
- return *addr;
-}
-
-#define get_fs_quad(addr) get_user_quad((long *)(addr))
-
-static inline void put_user_byte(char val,char *addr)
-{
- *addr = val;
-}
-
-#define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr))
-
-static inline void put_user_word(short val,short * addr)
-{
- *addr = val;
-}
-
-#define put_fs_word(x,addr) put_user_word((x),(short *)(addr))
-
-static inline void put_user_long(unsigned long val,int * addr)
-{
- *addr = val;
-}
-
-#define put_fs_long(x,addr) put_user_long((x),(int *)(addr))
-
-static inline void put_user_quad(unsigned long val,long * addr)
-{
- *addr = val;
-}
-
-#define put_fs_quad(x,addr) put_user_quad((x),(long *)(addr))
-
-#define memcpy_fromfs(to, from, n) memcpy((to),(from),(n))
-
-#define memcpy_tofs(to, from, n) memcpy((to),(from),(n))
-
-/*
- * For segmented architectures, these are used to specify which segment
- * to use for the above functions.
- *
- * The powerpc is not segmented, so these are just dummies.
- */
-
-#define KERNEL_DS 0
-#define USER_DS 1
-
-static inline unsigned long get_fs(void)
-{
- return 0;
-}
-
-static inline unsigned long get_ds(void)
-{
- return 0;
-}
-
-static inline void set_fs(unsigned long val)
-{
-}
-
-#endif /* _ASM_SEGMENT_H */
+#endif
+#include <asm/uaccess.h>
diff --git a/include/asm-ppc/semaphore.h b/include/asm-ppc/semaphore.h
new file mode 100644
index 000000000..4d1f91372
--- /dev/null
+++ b/include/asm-ppc/semaphore.h
@@ -0,0 +1,56 @@
+#ifndef _PPC_SEMAPHORE_H
+#define _PPC_SEMAPHORE_H
+
+#include <asm/atomic.h>
+
+struct semaphore {
+ atomic_t count;
+ atomic_t waiting;
+ struct wait_queue * wait;
+};
+
+#define MUTEX ((struct semaphore) { ATOMIC_INIT(1), ATOMIC_INIT(0), NULL })
+#define MUTEX_LOCKED ((struct semaphore) { ATOMIC_INIT(0), ATOMIC_INIT(0), NULL })
+
+extern void __down(struct semaphore * sem);
+extern void __up(struct semaphore * sem);
+
+extern void atomic_add(int c, int *v);
+extern void atomic_sub(int c, int *v);
+
+#define sema_init(sem, val) atomic_set(&((sem)->count), val)
+
+static inline int waking_non_zero(struct semaphore *sem)
+{
+ unsigned long flags;
+ int ret = 0;
+
+ save_flags(flags);
+ cli();
+ if (atomic_read(&sem->waking) > 0) {
+ atomic_dec(&sem->waking);
+ ret = 1;
+ }
+ restore_flags(flags);
+ return ret;
+}
+
+extern inline void down(struct semaphore * sem)
+{
+ for (;;)
+ {
+ atomic_dec_return(&sem->count);
+ if ( sem->count >= 0)
+ break;
+ __down(sem);
+ }
+}
+
+extern inline void up(struct semaphore * sem)
+{
+ atomic_inc_return(&sem->count);
+ if ( sem->count <= 0)
+ __up(sem);
+}
+
+#endif /* !(_PPC_SEMAPHORE_H) */
diff --git a/include/asm-ppc/smp.h b/include/asm-ppc/smp.h
new file mode 100644
index 000000000..00a1e7c9a
--- /dev/null
+++ b/include/asm-ppc/smp.h
@@ -0,0 +1,26 @@
+/* smp.h: PPC specific SMP stuff.
+ *
+ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
+ */
+
+#ifndef _PPC_SMP_H
+#define _PPC_SMP_H
+
+#ifdef __SMP__
+
+#ifndef __ASSEMBLY__
+
+extern struct prom_cpuinfo linux_cpus[NCPUS];
+
+/* Per processor PPC parameters we need. */
+
+struct cpuinfo_PPC {
+ unsigned long udelay_val; /* that's it */
+};
+
+extern struct cpuinfo_PPC cpu_data[NR_CPUS];
+
+
+#endif /* !(__SMP__) */
+
+#endif /* !(_PPC_SMP_H) */
diff --git a/include/asm-ppc/socket.h b/include/asm-ppc/socket.h
index eadf15190..d09474696 100644
--- a/include/asm-ppc/socket.h
+++ b/include/asm-ppc/socket.h
@@ -27,5 +27,14 @@
#define SO_LINGER 13
#define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 14 */
+#define SO_RCVLOWAT 16
+#define SO_SNDLOWAT 17
+#define SO_RCVTIMEO 18
+#define SO_SNDTIMEO 19
+
+/* Security levels - as per NRL IPv6 - don't actually do anything */
+#define SO_SECURITY_AUTHENTICATION 20
+#define SO_SECURITY_ENCRYPTION_TRANSPORT 21
+#define SO_SECURITY_ENCRYPTION_NETWORK 22
#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-ppc/stat.h b/include/asm-ppc/stat.h
index 462cfa0cd..1c2d42966 100644
--- a/include/asm-ppc/stat.h
+++ b/include/asm-ppc/stat.h
@@ -3,7 +3,7 @@
#include <linux/types.h>
-struct old_stat {
+struct __old_kernel_stat {
unsigned short st_dev;
unsigned short st_ino;
unsigned short st_mode;
@@ -16,8 +16,7 @@ struct old_stat {
unsigned long st_mtime;
unsigned long st_ctime;
};
-
-struct new_stat {
+struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
@@ -37,5 +36,4 @@ struct new_stat {
unsigned long __unused4;
unsigned long __unused5;
};
-
#endif
diff --git a/include/asm-ppc/string.h b/include/asm-ppc/string.h
index 7d550d1ed..66243582e 100644
--- a/include/asm-ppc/string.h
+++ b/include/asm-ppc/string.h
@@ -5,12 +5,12 @@
/*
* keep things happy, the compile became unhappy since memset is
- * in include/string.h and lib/string.c with different args
+ * in include/linux/string.h and lib/string.c with different prototypes
* -- Cort
*/
-
+#if 1
#define __HAVE_ARCH_MEMSET
-extern inline void * memset(void * s,int c,size_t count)
+extern __inline__ void * memset(void * s,int c,__kernel_size_t count)
{
char *xs = (char *) s;
@@ -19,44 +19,8 @@ extern inline void * memset(void * s,int c,size_t count)
return s;
}
-#define __HAVE_ARCH_STRSTR
-/* Return the first occurrence of NEEDLE in HAYSTACK. */
-extern inline char *
-strstr(const char *haystack, const char *needle)
-{
- const char *const needle_end = strchr(needle, '\0');
- const char *const haystack_end = strchr(haystack, '\0');
- const size_t needle_len = needle_end - needle;
- const size_t needle_last = needle_len - 1;
- const char *begin;
-
- if (needle_len == 0)
-#ifdef __linux__
- return (char *) haystack;
-#else
- return (char *) haystack_end;
#endif
- if ((size_t) (haystack_end - haystack) < needle_len)
- return NULL;
-
- for (begin = &haystack[needle_last]; begin < haystack_end; ++begin)
- {
- register const char *n = &needle[needle_last];
- register const char *h = begin;
-
- do
- if (*h != *n)
- goto loop; /* continue for loop */
- while (--n >= needle && --h >= haystack);
-
- return (char *) h;
-
- loop:;
- }
-
- return NULL;
-}
-
+#define bzero(addr,size) memset((addr),(int)(0),(size))
#endif
diff --git a/include/asm-ppc/system.h b/include/asm-ppc/system.h
index b507d7a89..a1a3f12a0 100644
--- a/include/asm-ppc/system.h
+++ b/include/asm-ppc/system.h
@@ -16,7 +16,6 @@ extern int _disable_interrupts(void);
extern void _enable_interrupts(int);
/*extern void memcpy(void *, void *, int);*/
-extern void bzero(void *, int);
struct task_struct;
extern void switch_to(struct task_struct *prev, struct task_struct *next);
diff --git a/include/asm-ppc/termios.h b/include/asm-ppc/termios.h
index a87c495a4..26d88027f 100644
--- a/include/asm-ppc/termios.h
+++ b/include/asm-ppc/termios.h
@@ -343,60 +343,64 @@ struct termios {
#define N_SLIP 1
#define N_MOUSE 2
#define N_PPP 3
-#define N_AX25 5
#ifdef __KERNEL__
/*
* Translate a "termio" structure into a "termios". Ugh.
*/
-extern inline void trans_from_termio(struct termio * termio,
- struct termios * termios)
-{
-#define SET_LOW_BITS(x,y) ((x) = (0xffff0000 & (x)) | (y))
- SET_LOW_BITS(termios->c_iflag, termio->c_iflag);
- SET_LOW_BITS(termios->c_oflag, termio->c_oflag);
- SET_LOW_BITS(termios->c_cflag, termio->c_cflag);
- SET_LOW_BITS(termios->c_lflag, termio->c_lflag);
-#undef SET_LOW_BITS
- termios->c_cc[VINTR] = termio->c_cc[_VINTR];
- termios->c_cc[VQUIT] = termio->c_cc[_VQUIT];
- termios->c_cc[VERASE]= termio->c_cc[_VERASE];
- termios->c_cc[VKILL] = termio->c_cc[_VKILL];
- termios->c_cc[VEOF] = termio->c_cc[_VEOF];
- termios->c_cc[VMIN] = termio->c_cc[_VMIN];
- termios->c_cc[VEOL] = termio->c_cc[_VEOL];
- termios->c_cc[VTIME] = termio->c_cc[_VTIME];
- termios->c_cc[VEOL2] = termio->c_cc[_VEOL2];
- termios->c_cc[VSWTC] = termio->c_cc[_VSWTC];
-}
+#define user_termio_to_kernel_termios(termios, termio) \
+do { \
+ 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); \
+ get_user((termios)->c_cc[VINTR], &(termio)->c_cc[_VINTR]); \
+ get_user((termios)->c_cc[VQUIT], &(termio)->c_cc[_VQUIT]); \
+ get_user((termios)->c_cc[VERASE], &(termio)->c_cc[_VERASE]); \
+ get_user((termios)->c_cc[VKILL], &(termio)->c_cc[_VKILL]); \
+ get_user((termios)->c_cc[VEOF], &(termio)->c_cc[_VEOF]); \
+ get_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
+ get_user((termios)->c_cc[VEOL], &(termio)->c_cc[_VEOL]); \
+ get_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
+ get_user((termios)->c_cc[VEOL2], &(termio)->c_cc[_VEOL2]); \
+ get_user((termios)->c_cc[VSWTC], &(termio)->c_cc[_VSWTC]); \
+} while(0)
/*
* Translate a "termios" structure into a "termio". Ugh.
*
* Note the "fun" _VMIN overloading.
*/
-extern inline void trans_to_termio(struct termios * termios,
- struct termio * termio)
-{
- termio->c_iflag = termios->c_iflag;
- termio->c_oflag = termios->c_oflag;
- termio->c_cflag = termios->c_cflag;
- termio->c_lflag = termios->c_lflag;
- termio->c_line = termios->c_line;
- termio->c_cc[_VINTR] = termios->c_cc[VINTR];
- termio->c_cc[_VQUIT] = termios->c_cc[VQUIT];
- termio->c_cc[_VERASE]= termios->c_cc[VERASE];
- termio->c_cc[_VKILL] = termios->c_cc[VKILL];
- termio->c_cc[_VEOF] = termios->c_cc[VEOF];
- termio->c_cc[_VEOL] = termios->c_cc[VEOL];
- termio->c_cc[_VEOL2] = termios->c_cc[VEOL2];
- termio->c_cc[_VSWTC] = termios->c_cc[VSWTC];
- if (1/*!(termios->c_lflag & ICANON)*/) {
- termio->c_cc[_VMIN] = termios->c_cc[VMIN];
- termio->c_cc[_VTIME] = termios->c_cc[VTIME];
- }
-}
+#define kernel_termios_to_user_termio(termio, termios) \
+do { \
+ 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); \
+ put_user((termios)->c_cc[VINTR], &(termio)->c_cc[_VINTR]); \
+ put_user((termios)->c_cc[VQUIT], &(termio)->c_cc[_VQUIT]); \
+ put_user((termios)->c_cc[VERASE], &(termio)->c_cc[_VERASE]); \
+ put_user((termios)->c_cc[VKILL], &(termio)->c_cc[_VKILL]); \
+ put_user((termios)->c_cc[VEOF], &(termio)->c_cc[_VEOF]); \
+ put_user((termios)->c_cc[VEOL], &(termio)->c_cc[_VEOL]); \
+ put_user((termios)->c_cc[VEOL2], &(termio)->c_cc[_VEOL2]); \
+ put_user((termios)->c_cc[VSWTC], &(termio)->c_cc[_VSWTC]); \
+ if (1/*!((termios)->c_lflag & ICANON)*/) { \
+ put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
+ put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
+ } \
+} while(0)
+
+#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__ */
diff --git a/include/asm-ppc/uaccess.h b/include/asm-ppc/uaccess.h
new file mode 100644
index 000000000..927447dbd
--- /dev/null
+++ b/include/asm-ppc/uaccess.h
@@ -0,0 +1,150 @@
+#ifndef _ASM_UACCESS_H
+#define _ASM_UACCESS_H
+
+#ifndef __ASSEMBLY__
+#include <linux/sched.h>
+#include <linux/errno.h>
+
+#define KERNEL_DS (0)
+#define USER_DS (1)
+
+#define VERIFY_READ 0
+#define VERIFY_WRITE 1
+
+#define get_fs() (current->tss.fs)
+#define get_ds() (KERNEL_DS)
+#define set_fs(val) ( current->tss.fs = (val))
+
+#define __user_ok(addr,size) (((size) <= 0x80000000)&&((addr) <= 0x80000000-(size)))
+#define __kernel_ok (get_fs() == KERNEL_DS)
+#define __access_ok(addr,size) (__kernel_ok || __user_ok((addr),(size)))
+#define access_ok(type,addr,size) __access_ok((unsigned long)(addr),(size))
+
+extern inline int verify_area(int type, const void * addr, unsigned long size)
+{
+ return access_ok(type,addr,size) ? 0 : -EFAULT;
+}
+
+/*
+ * These are the main single-value transfer routines. They automatically
+ * use the right size if we just have the right pointer type.
+ *
+ * As the powerpc uses the same address space for kernel and user
+ * data, we can just do these as direct assignments. (Of course, the
+ * exception handling means that it's no longer "just"...)
+ *
+ * Careful to not
+ * (a) re-use the arguments for side effects (sizeof/typeof is ok)
+ * (b) require any knowledge of processes at this stage
+ */
+/*
+ * The "__xxx" versions do not do address space checking, useful when
+ * doing multiple accesses to the same area (the programmer has to do the
+ * checks by hand with "access_ok()")
+ */
+#define put_user(x,ptr) ({ \
+unsigned long __pu_addr = (unsigned long)(ptr); \
+__put_user_check((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); })
+
+#define get_user(x,ptr) ({ \
+unsigned long __gu_addr = (unsigned long)(ptr); \
+__get_user_check((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); })
+
+#define __put_user(x,ptr) __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
+#define __get_user(x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr)),__typeof__(*(ptr)))
+struct __large_struct { unsigned long buf[100]; };
+#define __m(x) ((struct __large_struct *)(x))
+
+#define __put_user_check(x,addr,size) ({ \
+int __pu_ret; \
+__pu_ret = -EFAULT; \
+if (__access_ok(addr,size)) { \
+switch (size) { \
+case 1: __pu_ret =__put_user_8(x,addr); break; \
+case 2: __pu_ret =__put_user_16(x,addr); break; \
+case 4: __pu_ret =__put_user_32(x,addr); break; \
+default: __pu_ret = __put_user_bad(); break; \
+} } __pu_ret; })
+
+#define __put_user_nocheck(x,addr,size) ({ \
+int __pu_ret; \
+__pu_ret = -EFAULT; \
+switch (size) { \
+case 1: __pu_ret =__put_user_8(x,addr); break; \
+case 2: __pu_ret =__put_user_16(x,addr); break; \
+case 4: __pu_ret =__put_user_32(x,addr); break; \
+default: __pu_ret = __put_user_bad(); break; \
+} __pu_ret; })
+
+extern int __put_user_bad(void);
+
+#define __get_user_check(x,addr,size,type) ({ \
+register int __gu_ret asm("r4"); \
+unsigned long __gu_val = 0; \
+__gu_ret = -EFAULT; \
+if (__access_ok(addr,size)) { \
+switch (size) { \
+case 1: __gu_val = __get_user_8(__gu_val,addr); break; \
+case 2: __gu_val = __get_user_16(__gu_val,addr); break; \
+case 4: __gu_val = __get_user_32(__gu_val,addr); break; \
+default: __get_user_bad(); break; \
+} } (x) = (type) __gu_val; __gu_ret; })
+
+#define __get_user_nocheck(x,addr,size,type) ({ \
+register int __gu_ret asm("r4"); \
+unsigned long __gu_val = 0; \
+__gu_ret = -EFAULT; \
+switch (size) { \
+case 1: __gu_val =__get_user_8(__gu_val,addr); break; \
+case 2: __gu_val =__get_user_16(__gu_val,addr); break; \
+case 4: __gu_val =__get_user_32(__gu_val,addr); break; \
+default: __gu_val = __get_user_bad(); break; \
+} (x) = (type) __gu_val; __gu_ret; })
+
+
+/* more complex routines */
+
+extern int __copy_tofrom_user(unsigned long to, unsigned long from, int size);
+
+#define copy_to_user(to,from,n) ({ \
+unsigned long __copy_to = (unsigned long) (to); \
+unsigned long __copy_size = (unsigned long) (n); \
+unsigned long __copy_res = -EFAULT; \
+if(__copy_size && __access_ok(__copy_to, __copy_size)) { \
+__copy_res = __copy_tofrom_user(__copy_to, (unsigned long) (from), __copy_size); \
+} \
+__copy_res; })
+
+#define copy_from_user(to,from,n) ({ \
+unsigned long __copy_from = (unsigned long) (from); \
+unsigned long __copy_size = (unsigned long) (n); \
+unsigned long __copy_res = -EFAULT; \
+if(__copy_size && __access_ok(__copy_from, __copy_size)) { \
+__copy_res = __copy_tofrom_user((unsigned long) (to), __copy_from, __copy_size); \
+} \
+__copy_res; })
+
+extern int __clear_user(unsigned long addr, int size);
+
+#define clear_user(addr,n) ({ \
+unsigned long __clear_addr = (unsigned long) (addr); \
+int __clear_size = (int) (n); \
+int __clear_res = -EFAULT; \
+if(__clear_size && __access_ok(__clear_addr, __clear_size)) { \
+__clear_res = __clear_user(__clear_addr, __clear_size); \
+} \
+__clear_res; })
+
+extern int __strncpy_from_user(unsigned long dest, unsigned long src, int count);
+
+#define strncpy_from_user(dest,src,count) ({ \
+unsigned long __sfu_src = (unsigned long) (src); \
+int __sfu_count = (int) (count); \
+long __sfu_res = -EFAULT; \
+if(__access_ok(__sfu_src, __sfu_count)) { \
+__sfu_res = __strncpy_from_user((unsigned long) (dest), __sfu_src, __sfu_count); \
+} __sfu_res; })
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _ASM_UACCESS_H */
diff --git a/include/asm-ppc/unistd.h b/include/asm-ppc/unistd.h
index be4cee27e..887c08856 100644
--- a/include/asm-ppc/unistd.h
+++ b/include/asm-ppc/unistd.h
@@ -1,3 +1,4 @@
+/* * Last edited: Nov 17 16:28 1995 (cort) */
#ifndef _ASM_PPC_UNISTD_H_
#define _ASM_PPC_UNISTD_H_
@@ -156,142 +157,114 @@
#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_setresuid 164
+#define __NR_getresuid 165
+#define __NR_nfsservctl 166
-
+/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
#define _syscall0(type,name) \
type name(void) \
{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval);\
+ __asm__ (_lisc(__NR_##name)); \
+ __asm__ ("sc"); \
+ __asm__ ("mr 31,3"); \
+ __asm__ ("bns 10f"); \
+ __asm__ ("mr 0,3"); \
+ __asm__ ("lis 3,errno@ha"); \
+ __asm__ ("stw 0,errno@l(3)"); \
+ __asm__ ("li 3,-1"); \
+ __asm__ ("10:"); \
}
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
+ __asm__ (_lisc(__NR_##name)); \
+ __asm__ ("sc"); \
+ __asm__ ("mr 31,3"); \
+ __asm__ ("bns 10f"); \
+ __asm__ ("mr 0,3"); \
+ __asm__ ("lis 3,errno@ha"); \
+ __asm__ ("stw 0,errno@l(3)"); \
+ __asm__ ("li 3,-1"); \
+ __asm__ ("10:"); \
}
#define _syscall2(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1,type2 arg2) \
{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
+ __asm__ (_lisc(__NR_##name)); \
+ __asm__ ("sc"); \
+ __asm__ ("mr 31,3"); \
+ __asm__ ("bns 10f"); \
+ __asm__ ("mr 0,3"); \
+ __asm__ ("lis 3,errno@ha"); \
+ __asm__ ("stw 0,errno@l(3)"); \
+ __asm__ ("li 3,-1"); \
+ __asm__ ("10:"); \
}
-
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2, type3 arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
+ __asm__ (_lisc(__NR_##name)); \
+ __asm__ ("sc"); \
+ __asm__ ("mr 31,3"); \
+ __asm__ ("bns 10f"); \
+ __asm__ ("mr 0,3"); \
+ __asm__ ("lis 3,errno@ha"); \
+ __asm__ ("stw 0,errno@l(3)"); \
+ __asm__ ("li 3,-1"); \
+ __asm__ ("10:"); \
}
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
-}
+ __asm__ (_lisc(__NR_##name)); \
+ __asm__ ("sc"); \
+ __asm__ ("mr 31,3"); \
+ __asm__ ("bns 10f"); \
+ __asm__ ("mr 0,3"); \
+ __asm__ ("lis 3,errno@ha"); \
+ __asm__ ("stw 0,errno@l(3)"); \
+ __asm__ ("li 3,-1"); \
+ __asm__ ("10:"); \
+}
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5) \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
+ __asm__ (_lisc(__NR_##name)); \
+ __asm__ ("sc"); \
+ __asm__ ("mr 31,3"); \
+ __asm__ ("bns 10f"); \
+ __asm__ ("mr 0,3"); \
+ __asm__ ("lis 3,errno@ha"); \
+ __asm__ ("stw 0,errno@l(3)"); \
+ __asm__ ("li 3,-1"); \
+ __asm__ ("10:"); \
}
#ifdef __KERNEL_SYSCALLS__
+
/*
* we need this inline - forking from kernel space will result
* in NO COPY ON WRITE (!!!), until an execve is executed. This
@@ -305,42 +278,16 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
* some others too.
*/
-/*
- some of these had problems getting the right arguments (namely sys_clone())
- when they were inline so I made them non-inline until we get problems with gcc
- worked out. I need to check with Linus to find out which he wants inline now
- since the above comment was written a long time ago.
-
- Once I understand the macro language better this should go away.
- -- Cort
- */
-
-#define __NR__exit __NR_exit
-static /*__inline__*/ _syscall0(int,setup)
-static __inline__ _syscall0(int,idle)
-static /*__inline__*/ _syscall0(int,fork)
-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__*/ _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__ _syscall2(int,clone,unsigned long,flags,char *,esp)
-static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-
-static __inline__ pid_t wait(int * wait_stat)
-{
- return waitpid(-1,wait_stat,0);
-}
+#if 0
/*
This is the mechanism for creating a new kernel thread.
For the time being it only behaves the same as clone().
It should be changed very soon to work properly and cleanly. This
gets us going for now, though.
+
+ some versions of gcc hate this -- complains about constraints being
+ incorrect. not sure why so it's in arch/ppc/kernel/misc.S now.
-- Cort
*/
static __inline__ long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
@@ -369,8 +316,39 @@ static __inline__ long kernel_thread(int (*fn)(void *), void * arg, unsigned lon
:"cc", "1", "0", "3", "7", "31", "memory" );
return retval;
}
+#else
+extern long __kernel_thread(unsigned long, int (*)(void *), void *);
+
+static inline long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
+{
+ return __kernel_thread(flags | CLONE_VM, fn, arg);
+}
+#endif
+
+#define __NR__exit __NR_exit
+static inline _syscall0(int,idle) /* made inline "just in case" -- Cort */
+static inline _syscall0(int,fork) /* needs to be inline */
+static inline _syscall0(int,pause) /* needs to be inline */
+static inline _syscall0(int,setup) /* called in init before execve */
+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*/ _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 _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
+static inline _syscall2(int,clone,unsigned long,flags,char *,esp)
+/* called from init before execve -- need to be inline? -- Cort */
+static inline pid_t wait(int * wait_stat)
+{
+ return waitpid(-1,wait_stat,0);
+}
-#endif /* __KERNEL_SYSCALLS__ */
+#endif
#endif /* _ASM_PPC_UNISTD_H_ */
+
+
diff --git a/include/asm-ppc/unistd.h.cort b/include/asm-ppc/unistd.h.cort
deleted file mode 100644
index be4cee27e..000000000
--- a/include/asm-ppc/unistd.h.cort
+++ /dev/null
@@ -1,376 +0,0 @@
-#ifndef _ASM_PPC_UNISTD_H_
-#define _ASM_PPC_UNISTD_H_
-
-#define _NR(n) #n
-#define _lisc(n) "li 0," _NR(n)
-
-/*
- * This file contains the system call numbers.
- */
-
-#define __NR_setup 0 /* used only by init, to get system going */
-#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_waitpid 7
-#define __NR_creat 8
-#define __NR_link 9
-#define __NR_unlink 10
-#define __NR_execve 11
-#define __NR_chdir 12
-#define __NR_time 13
-#define __NR_mknod 14
-#define __NR_chmod 15
-#define __NR_chown 16
-#define __NR_break 17
-#define __NR_oldstat 18
-#define __NR_lseek 19
-#define __NR_getpid 20
-#define __NR_mount 21
-#define __NR_umount 22
-#define __NR_setuid 23
-#define __NR_getuid 24
-#define __NR_stime 25
-#define __NR_ptrace 26
-#define __NR_alarm 27
-#define __NR_oldfstat 28
-#define __NR_pause 29
-#define __NR_utime 30
-#define __NR_stty 31
-#define __NR_gtty 32
-#define __NR_access 33
-#define __NR_nice 34
-#define __NR_ftime 35
-#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_prof 44
-#define __NR_brk 45
-#define __NR_setgid 46
-#define __NR_getgid 47
-#define __NR_signal 48
-#define __NR_geteuid 49
-#define __NR_getegid 50
-#define __NR_acct 51
-#define __NR_phys 52
-#define __NR_lock 53
-#define __NR_ioctl 54
-#define __NR_fcntl 55
-#define __NR_mpx 56
-#define __NR_setpgid 57
-#define __NR_ulimit 58
-#define __NR_oldolduname 59
-#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_sgetmask 68
-#define __NR_ssetmask 69
-#define __NR_setreuid 70
-#define __NR_setregid 71
-#define __NR_sigsuspend 72
-#define __NR_sigpending 73
-#define __NR_sethostname 74
-#define __NR_setrlimit 75
-#define __NR_getrlimit 76
-#define __NR_getrusage 77
-#define __NR_gettimeofday 78
-#define __NR_settimeofday 79
-#define __NR_getgroups 80
-#define __NR_setgroups 81
-#define __NR_select 82
-#define __NR_symlink 83
-#define __NR_oldlstat 84
-#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_fchown 95
-#define __NR_getpriority 96
-#define __NR_setpriority 97
-#define __NR_profil 98
-#define __NR_statfs 99
-#define __NR_fstatfs 100
-#define __NR_ioperm 101
-#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_olduname 109
-#define __NR_iopl 110
-#define __NR_vhangup 111
-#define __NR_idle 112
-#define __NR_vm86 113
-#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_modify_ldt 123
-#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_setfsuid 138
-#define __NR_setfsgid 139
-#define __NR__llseek 140
-#define __NR_getdents 141
-#define __NR__newselect 142
-#define __NR_flock 143
-#define __NR_msync 144
-#define __NR_readv 145
-#define __NR_writev 146
-#define __NR_getsid 147
-
-#define __NR_mlock 150
-#define __NR_munlock 151
-#define __NR_mlockall 152
-#define __NR_munlockall 153
-
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval);\
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
-}
-
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2, type3 arg3) \
-{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
- long retval; \
- __asm__ ( \
- "li 0, %0 \n\t" \
- "sc \n\t" \
- "mr 31,3 \n\t" \
- "bns 10f \n\t" \
- "mr 0,3 \n\t" \
- "lis 3,errno@ha \n\t" \
- "stw 0,errno@l(3) \n\t" \
- "li 3,-1 \n\t" \
- "10: \n\t" \
- : \
- : "i" (__NR_##name) \
- : "0", "31", "3", "cc", "memory" \
- ); \
- return(retval); \
-}
-
-#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.
- */
-
-/*
- some of these had problems getting the right arguments (namely sys_clone())
- when they were inline so I made them non-inline until we get problems with gcc
- worked out. I need to check with Linus to find out which he wants inline now
- since the above comment was written a long time ago.
-
- Once I understand the macro language better this should go away.
- -- Cort
- */
-
-#define __NR__exit __NR_exit
-static /*__inline__*/ _syscall0(int,setup)
-static __inline__ _syscall0(int,idle)
-static /*__inline__*/ _syscall0(int,fork)
-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__*/ _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__ _syscall2(int,clone,unsigned long,flags,char *,esp)
-static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-
-static __inline__ pid_t wait(int * wait_stat)
-{
- return waitpid(-1,wait_stat,0);
-}
-
-/*
- This is the mechanism for creating a new kernel thread.
- For the time being it only behaves the same as clone().
- It should be changed very soon to work properly and cleanly. This
- gets us going for now, though.
- -- Cort
- */
-static __inline__ long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
-{
- long retval;
- __asm__ (
- "li 0, 120 \n\t" /* __NR_clone */
- "li 3, %5 \n\t" /* load flags as arg to clone */
- /*"mr 1,7 \n\t"*/ /* save kernel stack */
- "sc \n\t" /* syscall */
- /*"cmp 0,1,7 \n\t"*/ /* if kernel stack changes -- child */
- "cmpi 0,3,0 \n\t"
- "bne 1f \n\t" /* return if parent */
- /* this is in child */
- "li 3, %3 \n\t" /* child -- load args and call fn */
- "mtlr %4 \n\t"
- "blrl \n\t"
- "li 0, %2 \n\t" /* exit after child exits */
- "li 3, 0 \n\t"
- "sc \n\t"
- /* parent */
- "1: \n\t"
- :"=3" (retval)
- :"i" (__NR_clone), "i" (__NR_exit),
- "r" (arg), "r" (fn), "g" (CLONE_VM|flags)
- :"cc", "1", "0", "3", "7", "31", "memory" );
- return retval;
-}
-
-
-#endif /* __KERNEL_SYSCALLS__ */
-
-#endif /* _ASM_PPC_UNISTD_H_ */