OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [armnommu/] [kernel/] [ioport.c] - Blame information for rev 1622

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
/*
2
 * linux/arch/arm/kernel/ioport.c
3
 *
4
 * This contains the io-permission bitmap code - written by obz, with changes
5
 * by Linus.
6
 *
7
 * Modifications for ARM processor Copyright (C) 1995, 1996 Russell King
8
 */
9
 
10
#include <linux/sched.h>
11
#include <linux/kernel.h>
12
#include <linux/errno.h>
13
#include <linux/types.h>
14
#include <linux/ioport.h>
15
 
16
/* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
17
asmlinkage void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value)
18
{
19
        int mask;
20
        unsigned long *bitmap_base = bitmap + (base >> 5);
21
        unsigned short low_index = base & 0x1f;
22
        int length = low_index + extent;
23
 
24
        if (low_index != 0) {
25
                mask = (~0 << low_index);
26
                if (length < 32)
27
                                mask &= ~(~0 << length);
28
                if (new_value)
29
                        *bitmap_base++ |= mask;
30
                else
31
                        *bitmap_base++ &= ~mask;
32
                length -= 32;
33
        }
34
 
35
        mask = (new_value ? ~0 : 0);
36
        while (length >= 32) {
37
                *bitmap_base++ = mask;
38
                length -= 32;
39
        }
40
 
41
        if (length > 0) {
42
                mask = ~(~0 << length);
43
                if (new_value)
44
                        *bitmap_base++ |= mask;
45
                else
46
                        *bitmap_base++ &= ~mask;
47
        }
48
}
49
 
50
/*
51
 * this changes the io permissions bitmap in the current task.
52
 */
53
asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on)
54
{
55
        if (from + num <= from)
56
                return -EINVAL;
57
#ifndef __arm__
58
        if (from + num > IO_BITMAP_SIZE*32)
59
                return -EINVAL;
60
#endif
61
        if (!suser())
62
                return -EPERM;
63
 
64
#ifdef IODEBUG
65
        printk("io: from=%d num=%d %s\n", from, num, (turn_on ? "on" : "off"));
66
#endif
67
#ifndef __arm__
68
        set_bitmap((unsigned long *)current->tss.io_bitmap, from, num, !turn_on);
69
#endif
70
        return 0;
71
}
72
 
73
unsigned int *stack;
74
 
75
/*
76
 * sys_iopl has to be used when you want to access the IO ports
77
 * beyond the 0x3ff range: to get the full 65536 ports bitmapped
78
 * you'd need 8kB of bitmaps/process, which is a bit excessive.
79
 *
80
 * Here we just change the eflags value on the stack: we allow
81
 * only the super-user to do it. This depends on the stack-layout
82
 * on system-call entry - see also fork() and the signal handling
83
 * code.
84
 */
85
asmlinkage int sys_iopl(long ebx,long ecx,long edx,
86
             long esi, long edi, long ebp, long eax, long ds,
87
             long es, long fs, long gs, long orig_eax,
88
             long eip,long cs,long eflags,long esp,long ss)
89
{
90
        unsigned int level = ebx;
91
 
92
        if (level > 3)
93
                return -EINVAL;
94
        if (!suser())
95
                return -EPERM;
96
        *(&eflags) = (eflags & 0xffffcfff) | (level << 12);
97
        return 0;
98
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.