summaryrefslogtreecommitdiffstats
path: root/include/asm-m68k
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-m68k')
-rw-r--r--include/asm-m68k/bitops.h120
-rw-r--r--include/asm-m68k/delay.h40
-rw-r--r--include/asm-m68k/dma.h6
-rw-r--r--include/asm-m68k/io.h24
-rw-r--r--include/asm-m68k/irq.h6
-rw-r--r--include/asm-m68k/segment.h241
-rw-r--r--include/asm-m68k/string.h154
-rw-r--r--include/asm-m68k/system.h53
-rw-r--r--include/asm-m68k/unistd.h114
9 files changed, 758 insertions, 0 deletions
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
new file mode 100644
index 000000000..901fa48a0
--- /dev/null
+++ b/include/asm-m68k/bitops.h
@@ -0,0 +1,120 @@
+#ifndef _M68K_BITOPS_H
+#define _M68K_BITOPS_H
+/*
+ * Copyright 1992, Linus Torvalds.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file README.legal in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * Require 68020 or better.
+ *
+ * They don't use the standard m680x0 bit ordering.
+ * Instead, the use the standard m680x0 bitfield ordering.
+ *
+ * Thus, bit 0 is the MSB of addr; bit 32 is the MSB of (addr+1).
+ */
+
+extern __inline__ int set_bit(int nr,void * vaddr)
+{
+ char retval;
+
+ __asm__ __volatile__ ("bfset %2@{%1:#1}; sne %0"
+ : "=d" (retval) : "d" (nr), "a" (vaddr));
+
+ return retval;
+}
+
+extern __inline__ int clear_bit(int nr, void * vaddr)
+{
+ char retval;
+
+ __asm__ __volatile__ ("bfclr %2@{%1:#1}; sne %0"
+ : "=d" (retval) : "d" (nr), "a" (vaddr));
+
+ return retval;
+}
+
+extern __inline__ int change_bit(int nr, void * vaddr)
+{
+ char retval;
+
+ __asm__ __volatile__ ("bfchg %2@{%1:#1}; sne %0"
+ : "=d" (retval) : "d" (nr), "a" (vaddr));
+
+ return retval;
+}
+
+extern __inline__ int test_bit(int nr, const void * vaddr)
+{
+ char retval;
+
+ __asm__ __volatile__ ("bftst %2@{%1:#1}; sne %0"
+ : "=d" (retval) : "d" (nr), "a" (vaddr));
+
+ return retval;
+}
+
+extern inline int find_first_zero_bit(void * vaddr, unsigned size)
+{
+ unsigned long res;
+ unsigned long *p;
+ unsigned long *addr = vaddr;
+
+ if (!size)
+ return 0;
+ __asm__ __volatile__ (" moveq #-1,d0\n\t"
+ "1:"
+ " cmpl %1@+,d0\n\t"
+ " bne 2f\n\t"
+ " subql #1,%0\n\t"
+ " bne 1b\n\t"
+ " bra 5f\n\t"
+ "2:"
+ " movel %1@-,d0\n\t"
+ " notl d0\n\t"
+ " bfffo d0{#0,#0},%0\n\t"
+ "5:"
+ : "=d" (res), "=a" (p)
+ : "0" ((size + 31) >> 5), "1" (addr)
+ : "d0");
+ return ((p - addr) << 5) + res;
+}
+
+static inline int find_next_zero_bit (void *vaddr, int size,
+ int offset)
+{
+ unsigned long *addr = vaddr;
+ unsigned long *p = addr + (offset >> 5);
+ int set = 0, bit = offset & 31, res;
+
+ if (bit) {
+ /* Look for zero in first longword */
+ __asm__("bfffo %1{#0,#0},%0"
+ : "=d" (set)
+ : "d" (~*p << bit));
+ if (set < (32 - bit))
+ return set + offset;
+ set = 32 - bit;
+ p++;
+ }
+ /* No zero yet, search remaining full bytes for a zero */
+ res = find_first_zero_bit (p, size - 32 * (p - addr));
+ return (offset + set + res);
+}
+
+/*
+ * ffz = Find First Zero in word. Undefined if no zero exists,
+ * so code should check against ~0UL first..
+ */
+extern inline unsigned long ffz(unsigned long word)
+{
+ __asm__ __volatile__ ("bfffo %1{#0,#0},%0"
+ : "=d" (word)
+ : "d" (~(word)));
+ return word;
+}
+
+#endif /* _M68K_BITOPS_H */
diff --git a/include/asm-m68k/delay.h b/include/asm-m68k/delay.h
new file mode 100644
index 000000000..804a654b7
--- /dev/null
+++ b/include/asm-m68k/delay.h
@@ -0,0 +1,40 @@
+#ifndef _M68K_DELAY_H
+#define _M68K_DELAY_H
+
+/*
+ * Copyright (C) 1994 Hamish Macdonald
+ *
+ * Delay routines, using a pre-computed "loops_per_second" value.
+ */
+
+extern __inline__ void __delay(int loops)
+{
+ __asm__("\n\tmovel %0,d0\n1:\tsubql #1,d0\n\tbpls 1b\n"
+ : /* no outputs */
+ : "g" (loops)
+ : "d0");
+}
+
+/*
+ * division by multiplication: you don't have to worry about
+ * loss of precision.
+ *
+ * Use only for very small delays ( < 1 msec). Should probably use a
+ * lookup table, really, as the multiplications take much too long with
+ * short delays. This is a "reasonable" implementation, though (and the
+ * first constant multiplications gets optimized away if the delay is
+ * a constant)
+ */
+extern __inline__ void udelay(unsigned long usecs)
+{
+ asm ("mulul %1,d0,%0\n\t"
+ "divul %2,d0,%0"
+ : "=d" (usecs)
+ : "d" (usecs),
+ "i" (1000000),
+ "0" (loops_per_sec)
+ : "d0");
+ __delay(usecs);
+}
+
+#endif /* defined(_M68K_DELAY_H) */
diff --git a/include/asm-m68k/dma.h b/include/asm-m68k/dma.h
new file mode 100644
index 000000000..2820f20a1
--- /dev/null
+++ b/include/asm-m68k/dma.h
@@ -0,0 +1,6 @@
+#ifndef _M68K_DMA_H
+#define _M68K_DMA_H 1
+
+/* dummy for m68k */
+
+#endif /* _M68K_DMA_H */
diff --git a/include/asm-m68k/io.h b/include/asm-m68k/io.h
new file mode 100644
index 000000000..0cde22fd3
--- /dev/null
+++ b/include/asm-m68k/io.h
@@ -0,0 +1,24 @@
+#ifndef _M68K_IO_H
+#define _M68K_IO_H
+
+static inline unsigned char get_user_byte_io(const char * addr)
+{
+ register unsigned char _v;
+
+ __asm__ __volatile__ ("moveb %1,%0":"=r" (_v):"m" (*addr));
+ return _v;
+}
+#define inb_p(addr) get_user_byte_io((char *)(addr))
+#define inb(addr) get_user_byte_io((char *)(addr))
+
+static inline void put_user_byte_io(char val,char *addr)
+{
+ __asm__ __volatile__ ("moveb %0,%1"
+ : /* no outputs */
+ :"r" (val),"m" (*addr)
+ : "memory");
+}
+#define outb_p(x,addr) put_user_byte_io((x),(char *)(addr))
+#define outb(x,addr) put_user_byte_io((x),(char *)(addr))
+
+#endif /* _M68K_IO_H */
diff --git a/include/asm-m68k/irq.h b/include/asm-m68k/irq.h
new file mode 100644
index 000000000..c8f300ca8
--- /dev/null
+++ b/include/asm-m68k/irq.h
@@ -0,0 +1,6 @@
+#ifndef _M68K_IRQ_H_
+#define _M68K_IRQ_H_
+
+/* dummy for m68k */
+
+#endif /* _M68K_IRQ_H_ */
diff --git a/include/asm-m68k/segment.h b/include/asm-m68k/segment.h
new file mode 100644
index 000000000..89079be3f
--- /dev/null
+++ b/include/asm-m68k/segment.h
@@ -0,0 +1,241 @@
+/*
+ * linux/include/asm-m68k/segment.h
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file README.legal in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * 680x0 support added by Hamish Macdonald
+ */
+
+#ifndef _M68K_SEGMENT_H
+#define _M68K_SEGMENT_H
+
+static inline unsigned char get_user_byte(const char * addr)
+{
+ register unsigned char _v;
+
+ __asm__ __volatile__ ("movesb %1,%0":"=r" (_v):"m" (*addr));
+ return _v;
+}
+
+#define get_fs_byte(addr) get_user_byte((char *)(addr))
+
+static inline unsigned short get_user_word(const short *addr)
+{
+ unsigned short _v;
+
+ __asm__ __volatile__ ("movesw %1,%0":"=r" (_v):"m" (*addr));
+ return _v;
+}
+
+#define get_fs_word(addr) get_user_word((short *)(addr))
+
+static inline unsigned long get_user_long(const int *addr)
+{
+ unsigned long _v;
+
+ __asm__ __volatile__ ("movesl %1,%0":"=r" (_v):"m" (*addr)); \
+ return _v;
+}
+
+#define get_fs_long(addr) get_user_long((int *)(addr))
+
+static inline void put_user_byte(char val,char *addr)
+{
+ __asm__ __volatile__ ("movesb %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory");
+}
+
+#define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr))
+
+static inline void put_user_word(short val,short * addr)
+{
+ __asm__ __volatile__ ("movesw %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory");
+}
+
+#define put_fs_word(x,addr) put_user_word((x),(short *)(addr))
+
+static inline void put_user_long(unsigned long val,int * addr)
+{
+ __asm__ __volatile__ ("movesl %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory");
+}
+
+#define put_fs_long(x,addr) put_user_long((x),(int *)(addr))
+
+static inline void __generic_memcpy_tofs(void * to, const void * from, unsigned long n)
+{
+ if (n == 0) return;
+ __asm__ __volatile__ ("1:\n\t"
+ "moveb %1@+,d0\n\t"
+ "movesb d0,%2@+\n\t"
+ "dbra %0,1b\n\t"
+ "clrw %0\n\t"
+ "subql #1,%0\n\t"
+ "bccs 1b"
+ : "=d" (n), "=a" (from), "=a" (to)
+ : "1" (from), "2" (to), "0" (n-1)
+ : "d0", "memory");
+}
+
+static inline void __constant_memcpy_tofs(void * to, const void * from, unsigned long n)
+{
+ if (n == 0) {
+ return;
+ } else if (n == 1) {
+ put_user_byte(*(const char *) from, (char *) to);
+ return;
+ } else if (n == 2) {
+ put_user_word(*(const short *) from, (short *) to);
+ return;
+ } else if (n == 3) {
+ put_user_word(*(const short *) from, (short *) to);
+ put_user_byte(*(2+(const char *) from), 2+(char *) to);
+ return;
+ } else if (n == 4) {
+ put_user_long(*(const int *) from, (int *) to);
+ return;
+ }
+#if 0
+#define COMMON(x) \
+__asm__("cld\n\t" \
+ "push %%es\n\t" \
+ "push %%fs\n\t" \
+ "pop %%es\n\t" \
+ "rep ; movsl\n\t" \
+ x \
+ "pop %%es" \
+ : /* no outputs */ \
+ :"c" (n/4),"D" ((long) to),"S" ((long) from) \
+ :"cx","di","si")
+
+ switch (n % 4) {
+ case 0:
+ COMMON("");
+ return;
+ case 1:
+ COMMON("movsb\n\t");
+ return;
+ case 2:
+ COMMON("movsw\n\t");
+ return;
+ case 3:
+ COMMON("movsw\n\tmovsb\n\t");
+ return;
+ }
+#undef COMMON
+#else
+ __generic_memcpy_tofs(to,from,n);
+#endif
+}
+
+static inline void __generic_memcpy_fromfs(void * to, const void * from, unsigned long n)
+{
+ if (n == 0) return;
+ __asm__ __volatile__ ("1:\n\t"
+ "movesb %1@+,d0\n\t"
+ "moveb d0,%2@+\n\t"
+ "dbra %0,1b\n\t"
+ "clrw %0\n\t"
+ "subql #1,%0\n\t"
+ "bccs 1b"
+ : "=d" (n), "=a" (from), "=a" (to)
+ : "1" (from), "2" (to), "0" (n-1)
+ : "d0", "memory");
+}
+
+static inline void __constant_memcpy_fromfs(void * to, const void * from, unsigned long n)
+{
+ if (n == 0) {
+ return;
+ } else if (n == 1) {
+ *(char *)to = get_user_byte((const char *) from);
+ return;
+ } else if (n == 2) {
+ *(short *)to = get_user_word((const short *) from);
+ return;
+ } else if (n == 3) {
+ *(short *) to = get_user_word((const short *) from);
+ *(2+(char *) to) = get_user_byte(2+(const char *) from);
+ return;
+ } else if (n == 4) {
+ *(int *) to = get_user_long((const int *) from);
+ return;
+ }
+#if 0
+#define COMMON(x) \
+__asm__("cld\n\t" \
+ "rep ; fs ; movsl\n\t" \
+ x \
+ : /* no outputs */ \
+ :"c" (n/4),"D" ((long) to),"S" ((long) from) \
+ :"cx","di","si","memory")
+
+ switch (n % 4) {
+ case 0:
+ COMMON("");
+ return;
+ case 1:
+ COMMON("fs ; movsb");
+ return;
+ case 2:
+ COMMON("fs ; movsw");
+ return;
+ case 3:
+ COMMON("fs ; movsw\n\tfs ; movsb");
+ return;
+ }
+#undef COMMON
+#else
+ __generic_memcpy_fromfs(to,from,n);
+#endif
+}
+
+#define memcpy_fromfs(to, from, n) \
+(__builtin_constant_p(n) ? \
+ __constant_memcpy_fromfs((to),(from),(n)) : \
+ __generic_memcpy_fromfs((to),(from),(n)))
+
+#define memcpy_tofs(to, from, n) \
+(__builtin_constant_p(n) ? \
+ __constant_memcpy_tofs((to),(from),(n)) : \
+ __generic_memcpy_tofs((to),(from),(n)))
+
+/*
+ * Get/set the SFC/DFC registers for MOVES instructions
+ */
+
+static inline unsigned long get_fs(void)
+{
+ unsigned long _v;
+ __asm__ ("movec dfc,%0":"=r" (_v):);
+
+ return _v;
+}
+
+static inline unsigned long get_ds(void)
+{
+ /* return the supervisor data space code */
+ return 0x5;
+}
+
+static inline void set_fs(unsigned long val)
+{
+ __asm__ __volatile__ ("movec %0,sfc\n\t"
+ "movec %0,dfc\n\t"
+ : /* no outputs */ : "r" (val), "r" (val) : "memory");
+}
+
+/* define constants */
+/* Address spaces (FC0-FC2) */
+#ifndef USER_DS
+#define USER_DS (1)
+#endif
+#ifndef KERNEL_DS
+#define KERNEL_DS (5)
+#endif
+
+#endif /* _M68K_SEGMENT_H */
diff --git a/include/asm-m68k/string.h b/include/asm-m68k/string.h
new file mode 100644
index 000000000..70466ed5e
--- /dev/null
+++ b/include/asm-m68k/string.h
@@ -0,0 +1,154 @@
+#ifndef _M68K_STRING_H_
+#define _M68K_STRING_H_
+
+#define __USE_PORTABLE_STRINGS_H_
+
+extern inline char * strcpy(char * dest,const char *src)
+{
+ char *xdest = dest;
+
+ __asm__ __volatile__
+ ("1:\tmoveb %1@+,%0@+\n\t"
+ "bne 1b"
+ : "=a" (dest), "=a" (src)
+ : "0" (dest), "1" (src) : "memory");
+ return xdest;
+}
+
+extern inline char * strncpy(char *dest, const char *src, size_t n)
+{
+ char *xdest = dest;
+
+ if (n == 0)
+ return xdest;
+
+ __asm__ __volatile__
+ ("1:\tmoveb %1@+,%0@+\n\t"
+ "beq 2f\n\t"
+ "subql #1,%2\n\t"
+ "bne 1b\n\t"
+ "2:"
+ : "=a" (dest), "=a" (src), "=d" (n)
+ : "0" (dest), "1" (src), "2" (n)
+ : "memory");
+ return xdest;
+}
+
+#define __USE_PORTABLE_strcat
+
+#define __USE_PORTABLE_strncat
+
+extern inline int strcmp(const char * cs,const char * ct)
+{
+ char __res;
+
+ __asm__
+ ("1:\tmoveb %0@+,%2\n\t" /* get *cs */
+ "cmpb %1@+,%2\n\t" /* compare a byte */
+ "bne 2f\n\t" /* not equal, break out */
+ "tstb %2\n\t" /* at end of cs? */
+ "bne 1b\n\t" /* no, keep going */
+ "bra 3f\n\t" /* strings are equal */
+ "2:\tsubb %1@-,%2\n\t" /* *cs - *ct */
+ "3:"
+ : "=a" (cs), "=a" (ct), "=d" (__res)
+ : "0" (cs), "1" (ct));
+ return __res;
+}
+
+extern inline int strncmp(const char * cs,const char * ct,size_t count)
+{
+ char __res;
+
+ if (!count)
+ return 0;
+ __asm__
+ ("1:\tmovb %0@+,%3\n\t" /* get *cs */
+ "cmpb %1@+,%3\n\t" /* compare a byte */
+ "bne 3f\n\t" /* not equal, break out */
+ "tstb %3\n\t" /* at end of cs? */
+ "beq 4f\n\t" /* yes, all done */
+ "subql #1,%2\n\t" /* no, adjust count */
+ "bne 1b\n\t" /* more to do, keep going */
+ "2:\tmoveq #0,%3\n\t" /* strings are equal */
+ "bra 4f\n\t"
+ "3:\tsubb %1@-,%3\n\t" /* *cs - *ct */
+ "4:"
+ : "=a" (cs), "=a" (ct), "=d" (count), "=d" (__res)
+ : "0" (cs), "1" (ct), "2" (count));
+ return __res;
+}
+
+#define __USE_PORTABLE_strchr
+
+#define __USE_PORTABLE_strlen
+
+#define __USE_PORTABLE_strspn
+
+#define __USE_PORTABLE_strpbrk
+
+#define __USE_PORTABLE_strtok
+
+extern inline void * memset(void * s,char c,size_t count)
+{
+ void *xs = s;
+
+ if (!count)
+ return xs;
+ __asm__ __volatile__
+ ("1:\tmoveb %3,%0@+\n\t"
+ "subql #1,%1\n\t"
+ "bne 1b"
+ : "=a" (s), "=d" (count)
+ : "0" (s), "d" (c), "1" (count)
+ : "memory");
+ return xs;
+}
+
+extern inline void * memcpy(void * to, const void * from, size_t n)
+{
+ void *xto = to;
+
+ if (!n)
+ return xto;
+ __asm__ __volatile__
+ ("1:\tmoveb %1@+,%0@+\n\t"
+ "subql #1,%2\n\t"
+ "bne 1b"
+ : "=a" (to), "=a" (from), "=d" (n)
+ : "0" (to), "1" (from), "2" (n)
+ : "memory" );
+ return xto;
+}
+
+extern inline void * memmove(void * dest,const void * src, size_t n)
+{
+ void *xdest = dest;
+
+ if (!n)
+ return xdest;
+
+ if (dest < src)
+ __asm__ __volatile__
+ ("1:\tmoveb %1@+,%0@+\n\t"
+ "subql #1,%2\n\t"
+ "bne 1b"
+ : "=a" (dest), "=a" (src), "=d" (n)
+ : "0" (dest), "1" (src), "2" (n)
+ : "memory" );
+ else
+ __asm__ __volatile__
+ ("1:\tmoveb %1@-,%0@-\n\t"
+ "subql #1,%2\n\t"
+ "bne 1b"
+ : "=a" (dest), "=a" (src), "=d" (n)
+ : "0" (dest+n), "1" (src+n), "2" (n)
+ : "memory" );
+ return xdest;
+}
+
+#define __USE_PORTABLE_memcmp
+
+#define __USE_PORTABLE_memscan
+
+#endif /* _M68K_STRING_H_ */
diff --git a/include/asm-m68k/system.h b/include/asm-m68k/system.h
new file mode 100644
index 000000000..e987f1f46
--- /dev/null
+++ b/include/asm-m68k/system.h
@@ -0,0 +1,53 @@
+/*
+ * linux/include/asm-m68k/system.h
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file README.legal in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * 680x0 support added by Hamish Macdonald
+ */
+
+#ifndef _M68K_SYSTEM_H
+#define _M68K_SYSTEM_H
+
+#include <linux/config.h> /* get configuration macros */
+
+#if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA) && !defined(CONFIG_MAC)
+/* block out HSYNC on the atari */
+#define sti() __asm__ __volatile__ ("andiw #0xfbff,sr": : : "memory")
+#else /* portable version */
+#define sti() __asm__ __volatile__ ("andiw #0xf8ff,sr": : : "memory")
+#endif /* machine compilation types */
+#define cli() __asm__ __volatile__ ("oriw #0x0700,sr": : : "memory")
+#define nop() __asm__ __volatile__ ("nop"::)
+
+#define save_flags(x) \
+__asm__ __volatile__("movew sr,%0":"=d" (x) : /* no input */ :"memory")
+
+#define restore_flags(x) \
+__asm__ __volatile__("movew %0,sr": /* no outputs */ :"d" (x) : "memory")
+
+#define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc")
+
+#define move_to_user_mode() \
+ __asm__ __volatile__ ("movel sp,usp\n\t" /* setup user sp */ \
+ "movec %0,msp\n\t" /* setup kernel sp */ \
+ "andiw #0xdfff,sr" /* return to user mode */ \
+ : /* no output */ \
+ : "r" (current->kernel_stack_page + PAGE_SIZE) \
+ : "memory", "sp")
+
+static inline void clear_fpu(void) {
+ unsigned long nilstate = 0;
+ __asm__ __volatile__ ("frestore %0@" : : "a" (&nilstate));
+}
+
+#define halt() \
+ __asm__ __volatile__ ("halt")
+
+#endif /* _M68K_SYSTEM_H */
diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h
new file mode 100644
index 000000000..acad643bf
--- /dev/null
+++ b/include/asm-m68k/unistd.h
@@ -0,0 +1,114 @@
+#ifndef _ASM_M68K_UNISTD_H_
+#define _ASM_M68K_UNISTD_H_
+
+/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
+#define _syscall0(type,name) \
+type name(void) \
+{ \
+register long __res __asm__ ("d0") = __NR_##name; \
+__asm__ __volatile__ ("trap #0" \
+ : "=g" (__res) \
+ : "0" (__NR_##name) \
+ : "d0"); \
+if (__res >= 0) \
+ return (type) __res; \
+errno = -__res; \
+return -1; \
+}
+
+#define _syscall1(type,name,atype,a) \
+type name(atype a) \
+{ \
+register long __res __asm__ ("d0") = __NR_##name; \
+__asm__ __volatile__ ("movel %2,d1\n\t" \
+ "trap #0" \
+ : "=g" (__res) \
+ : "0" (__NR_##name), "g" ((long)(a)) \
+ : "d0", "d1"); \
+if (__res >= 0) \
+ return (type) __res; \
+errno = -__res; \
+return -1; \
+}
+
+#define _syscall2(type,name,atype,a,btype,b) \
+type name(atype a,btype b) \
+{ \
+register long __res __asm__ ("d0") = __NR_##name; \
+__asm__ __volatile__ ("movel %2,d1\n\t" \
+ "movel %3,d2\n\t" \
+ "trap #0" \
+ : "=g" (__res) \
+ : "0" (__NR_##name), "g" ((long)(a)), \
+ "g" ((long)(b)) \
+ : "d0", "d1", "d2"); \
+if (__res >= 0) \
+ return (type) __res; \
+errno = -__res; \
+return -1; \
+}
+
+#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
+type name(atype a,btype b,ctype c) \
+{ \
+register long __res __asm__ ("d0") = __NR_##name; \
+__asm__ __volatile__ ("movel %2,d1\n\t" \
+ "movel %3,d2\n\t" \
+ "movel %4,d3\n\t" \
+ "trap #0" \
+ : "=g" (__res) \
+ : "0" (__NR_##name), "g" ((long)(a)), \
+ "g" ((long)(b)), \
+ "g" ((long)(c)) \
+ : "d0", "d1", "d2", "d3"); \
+if (__res >= 0) \
+ return (type) __res; \
+errno = -__res; \
+return -1; \
+}
+
+#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
+type name (atype a, btype b, ctype c, dtype d) \
+{ \
+register long __res __asm__ ("d0") = __NR_##name; \
+__asm__ __volatile__ ("movel %2,d1\n\t" \
+ "movel %3,d2\n\t" \
+ "movel %4,d3\n\t" \
+ "movel %5,d4\n\t" \
+ "trap #0" \
+ : "=g" (__res) \
+ : "0" (__NR_##name), "g" ((long)(a)), \
+ "g" ((long)(b)), \
+ "g" ((long)(c)), \
+ "g" ((long)(d)) \
+ : "d0", "d1", "d2", "d3", "d4"); \
+if (__res >= 0) \
+ return (type) __res; \
+errno = -__res; \
+return -1; \
+}
+
+#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
+type name (atype a,btype b,ctype c,dtype d,etype e) \
+{ \
+register long __res __asm__ ("d0") = __NR_##name; \
+__asm__ __volatile__ ("movel %2,d1\n\t" \
+ "movel %3,d2\n\t" \
+ "movel %4,d3\n\t" \
+ "movel %5,d4\n\t" \
+ "movel %6,d5\n\t" \
+ "trap #0" \
+ : "=g" (__res) \
+ : "0" (__NR_##name), "g" ((long)(a)), \
+ "g" ((long)(b)), \
+ "g" ((long)(c)), \
+ "g" ((long)(d)), \
+ "g" ((long)(e)) \
+ : "d0", "d1", "d2", "d3", "d4", "d5"); \
+if (__res >= 0) \
+ return (type) __res; \
+errno = -__res; \
+return -1; \
+}
+
+#endif /* _ASM_M68K_UNISTD_H_ */