summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/sysdeps/linux/arm/ioperm.c59
1 files changed, 22 insertions, 37 deletions
diff --git a/libc/sysdeps/linux/arm/ioperm.c b/libc/sysdeps/linux/arm/ioperm.c
index 0b13e6c92..bd935600c 100644
--- a/libc/sysdeps/linux/arm/ioperm.c
+++ b/libc/sysdeps/linux/arm/ioperm.c
@@ -41,8 +41,8 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
-//#include <sys/mman.h>
-//#include <asm/page.h>
+#include <sys/types.h>
+#include <sys/mman.h>
#define IO_BASE 0x7c000000
@@ -50,62 +50,47 @@
#define IO_ADDR(port) (IO_BASE + ((port) << IO_SHIFT))
-#if 0
-static struct {
- unsigned long int base;
- unsigned long int io_base;
- unsigned int shift;
- unsigned int initdone; /* since all the above could be 0 */
-} io;
-
-
#define MAX_PORT 0x10000
int ioperm(unsigned long int from, unsigned long int num, int turn_on)
{
- /* this test isn't as silly as it may look like; consider overflows! */
- if (from >= MAX_PORT || from + num > MAX_PORT)
- {
- __set_errno (EINVAL);
- return -1;
+ /* this test isn't as silly as it may look like; consider overflows! */
+ if (from >= MAX_PORT || from + num > MAX_PORT) {
+ __set_errno (EINVAL);
+ return -1;
}
- if (turn_on)
+ if (turn_on)
{
- if (! io.base)
- {
- int fd;
+ int fd;
+ unsigned long int base;
- fd = open ("/dev/mem", O_RDWR);
- if (fd < 0)
+ fd = open ("/dev/mem", O_RDWR);
+ if (fd < 0)
return -1;
- io.base = (unsigned long int) mmap (0, MAX_PORT << io.shift,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, io.io_base);
- close (fd);
- if ((long) io.base == -1)
+ base = (unsigned long int) mmap (0, MAX_PORT << IO_SHIFT,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, IO_BASE);
+ close (fd);
+ if ((long) base == -1)
return -1;
- }
}
- return 0;
+ return 0;
}
int iopl (unsigned int level)
{
- if (level > 3)
- {
+ if (level > 3) {
__set_errno (EINVAL);
return -1;
- }
- if (level)
- {
- return _ioperm (0, MAX_PORT, 1);
- }
+ }
+ if (level) {
+ return ioperm (0, MAX_PORT, 1);
+ }
return 0;
}
-#endif
void outb (unsigned char b, unsigned long int port)
{