diff options
author | H. Peter Anvin <hpa@zytor.com> | 2004-01-22 21:07:54 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2004-01-22 21:07:54 +0000 |
commit | dd83e842761f6e938373fa015b9fa79c16560e94 (patch) | |
tree | 45cd22b00ae13862c4fb8f568bdfeec8e2fd17e0 | |
parent | 421ff35c0f20ad784d834f51343582e5d9c3fe0b (diff) | |
download | klibc-dd83e842761f6e938373fa015b9fa79c16560e94.tar.gz |
i386, x86_64: add basic I/O operationsklibc-0.97
-rw-r--r-- | include/arch/i386/sys/io.h | 126 | ||||
-rw-r--r-- | include/arch/i386/sys/vm86.h | 41 | ||||
-rw-r--r-- | include/arch/x86_64/sys/io.h | 126 | ||||
-rw-r--r-- | klibc/SYSCALLS | 7 | ||||
-rw-r--r-- | klibc/arch/i386/include/sys/io.h | 126 | ||||
-rw-r--r-- | klibc/arch/i386/include/sys/vm86.h | 41 | ||||
-rw-r--r-- | klibc/arch/x86_64/include/sys/io.h | 126 | ||||
-rw-r--r-- | klibc/syscommon.h | 4 |
8 files changed, 597 insertions, 0 deletions
diff --git a/include/arch/i386/sys/io.h b/include/arch/i386/sys/io.h new file mode 100644 index 0000000000000..48c862ef90beb --- /dev/null +++ b/include/arch/i386/sys/io.h @@ -0,0 +1,126 @@ +#ident "$Id: io.h,v 1.1 2004/01/25 01:34:28 hpa Exp $" +/* ----------------------------------------------------------------------- * + * + * Copyright 2004 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * sys/io.h for the i386 architecture + * + * Basic I/O macros + */ + +#ifndef _SYS_IO_H +#define _SYS_IO_H 1 + +/* I/O-related system calls */ + +int iopl(int); +int ioperm(unsigned long, unsigned long, int); + +/* Basic I/O macros */ + +static __inline__ void +outb(unsigned char __v, unsigned short __p) +{ + asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outw(unsigned short __v, unsigned short __p) +{ + asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outl(unsigned int __v, unsigned short __p) +{ + asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ unsigned char +inb(unsigned short __p) +{ + unsigned char __v; + asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned short +inw(unsigned short __p) +{ + unsigned short __v; + asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned int +inl(unsigned short __p) +{ + unsigned int __v; + asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +/* String I/O macros */ + +static __inline__ void +outsb (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsw (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsl (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + + +static __inline__ void +insb (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insw (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insl (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +#endif /* _SYS_IO_H */ diff --git a/include/arch/i386/sys/vm86.h b/include/arch/i386/sys/vm86.h new file mode 100644 index 0000000000000..d3272393dca5b --- /dev/null +++ b/include/arch/i386/sys/vm86.h @@ -0,0 +1,41 @@ +#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $" +/* ----------------------------------------------------------------------- * + * + * Copyright 2004 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * sys/vm86.h for i386 + */ + +#ifndef _SYS_VM86_H +#define _SYS_VM86_H 1 + +#include <asm/vm86.h> + +/* Actual system call */ +int vm86(struct vm86_struct *); + +#endif diff --git a/include/arch/x86_64/sys/io.h b/include/arch/x86_64/sys/io.h new file mode 100644 index 0000000000000..4a0ae449857d8 --- /dev/null +++ b/include/arch/x86_64/sys/io.h @@ -0,0 +1,126 @@ +#ident "$Id: io.h,v 1.1 2004/01/25 01:34:29 hpa Exp $" +/* ----------------------------------------------------------------------- * + * + * Copyright 2004 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * sys/io.h for the i386 architecture + * + * Basic I/O macros + */ + +#ifndef _SYS_IO_H +#define _SYS_IO_H 1 + +/* I/O-related system calls */ + +int iopl(int); +int ioperm(unsigned long, unsigned long, int); + +/* Basic I/O macros */ + +static __inline__ void +outb(unsigned char __v, unsigned short __p) +{ + asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outw(unsigned short __v, unsigned short __p) +{ + asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outl(unsigned int __v, unsigned short __p) +{ + asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ unsigned char +inb(unsigned short __p) +{ + unsigned char __v; + asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned short +inw(unsigned short __p) +{ + unsigned short __v; + asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned int +inl(unsigned short __p) +{ + unsigned int __v; + asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +/* String I/O macros */ + +static __inline__ void +outsb (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsw (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsl (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + + +static __inline__ void +insb (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insw (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insl (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +#endif /* _SYS_IO_H */ diff --git a/klibc/SYSCALLS b/klibc/SYSCALLS index 0648777ad8c8c..00883cc098722 100644 --- a/klibc/SYSCALLS +++ b/klibc/SYSCALLS @@ -145,3 +145,10 @@ long delete_module(const char *, unsigned int) <!ia64> int query_module(const char *, int, void *, size_t, size_t) int reboot::__reboot(int, int, int, void *) int syslog::klogctl(int, char *, int) + +# +# Low-level I/O (generally architecture-specific) +# +<i386,x86_64> int iopl(int) +<i386,x86_64> int ioperm(unsigned long, unsigned long, int) +<i386> int vm86(struct vm86_struct *) diff --git a/klibc/arch/i386/include/sys/io.h b/klibc/arch/i386/include/sys/io.h new file mode 100644 index 0000000000000..48c862ef90beb --- /dev/null +++ b/klibc/arch/i386/include/sys/io.h @@ -0,0 +1,126 @@ +#ident "$Id: io.h,v 1.1 2004/01/25 01:34:28 hpa Exp $" +/* ----------------------------------------------------------------------- * + * + * Copyright 2004 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * sys/io.h for the i386 architecture + * + * Basic I/O macros + */ + +#ifndef _SYS_IO_H +#define _SYS_IO_H 1 + +/* I/O-related system calls */ + +int iopl(int); +int ioperm(unsigned long, unsigned long, int); + +/* Basic I/O macros */ + +static __inline__ void +outb(unsigned char __v, unsigned short __p) +{ + asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outw(unsigned short __v, unsigned short __p) +{ + asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outl(unsigned int __v, unsigned short __p) +{ + asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ unsigned char +inb(unsigned short __p) +{ + unsigned char __v; + asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned short +inw(unsigned short __p) +{ + unsigned short __v; + asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned int +inl(unsigned short __p) +{ + unsigned int __v; + asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +/* String I/O macros */ + +static __inline__ void +outsb (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsw (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsl (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + + +static __inline__ void +insb (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insw (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insl (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +#endif /* _SYS_IO_H */ diff --git a/klibc/arch/i386/include/sys/vm86.h b/klibc/arch/i386/include/sys/vm86.h new file mode 100644 index 0000000000000..d3272393dca5b --- /dev/null +++ b/klibc/arch/i386/include/sys/vm86.h @@ -0,0 +1,41 @@ +#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $" +/* ----------------------------------------------------------------------- * + * + * Copyright 2004 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * sys/vm86.h for i386 + */ + +#ifndef _SYS_VM86_H +#define _SYS_VM86_H 1 + +#include <asm/vm86.h> + +/* Actual system call */ +int vm86(struct vm86_struct *); + +#endif diff --git a/klibc/arch/x86_64/include/sys/io.h b/klibc/arch/x86_64/include/sys/io.h new file mode 100644 index 0000000000000..4a0ae449857d8 --- /dev/null +++ b/klibc/arch/x86_64/include/sys/io.h @@ -0,0 +1,126 @@ +#ident "$Id: io.h,v 1.1 2004/01/25 01:34:29 hpa Exp $" +/* ----------------------------------------------------------------------- * + * + * Copyright 2004 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * sys/io.h for the i386 architecture + * + * Basic I/O macros + */ + +#ifndef _SYS_IO_H +#define _SYS_IO_H 1 + +/* I/O-related system calls */ + +int iopl(int); +int ioperm(unsigned long, unsigned long, int); + +/* Basic I/O macros */ + +static __inline__ void +outb(unsigned char __v, unsigned short __p) +{ + asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outw(unsigned short __v, unsigned short __p) +{ + asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ void +outl(unsigned int __v, unsigned short __p) +{ + asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p)); +} + +static __inline__ unsigned char +inb(unsigned short __p) +{ + unsigned char __v; + asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned short +inw(unsigned short __p) +{ + unsigned short __v; + asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +static __inline__ unsigned int +inl(unsigned short __p) +{ + unsigned int __v; + asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p)); + return v; +} + +/* String I/O macros */ + +static __inline__ void +outsb (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsw (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +outsl (unsigned short __p, const void *__d, unsigned long __n) +{ + asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p)); +} + + +static __inline__ void +insb (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insw (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +static __inline__ void +insl (unsigned short __p, void *__d, unsigned long __n) +{ + asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p)); +} + +#endif /* _SYS_IO_H */ diff --git a/klibc/syscommon.h b/klibc/syscommon.h index 916d4eb0c02af..3093920739107 100644 --- a/klibc/syscommon.h +++ b/klibc/syscommon.h @@ -26,3 +26,7 @@ #include <sys/vfs.h> #include <sys/wait.h> #include <unistd.h> + +#ifdef __i386__ +#include <sys/vm86.h> +#endif |