root/arch/mips/kernel/ioport.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. set_bitmap
  2. sys_ioperm
  3. sys_iopl
  4. find_gap

   1 /*
   2  * linux/arch/mips/kernel/ioport.c
   3  */
   4 #include <linux/sched.h>
   5 #include <linux/kernel.h>
   6 #include <linux/errno.h>
   7 #include <linux/types.h>
   8 #include <linux/ioport.h>
   9 
  10 #define IOTABLE_SIZE 32
  11 
  12 typedef struct resource_entry_t {
  13         u_long from, num;
  14         const char *name;
  15         struct resource_entry_t *next;
  16 } resource_entry_t;
  17 
  18 static resource_entry_t iolist = { 0, 0, "", NULL };
  19 
  20 static resource_entry_t iotable[IOTABLE_SIZE];
  21 
  22 /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
  23 static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value)
     /* [previous][next][first][last][top][bottom][index][help] */
  24 {
  25         int mask;
  26         unsigned long *bitmap_base = bitmap + (base >> 5);
  27         unsigned short low_index = base & 0x1f;
  28         int length = low_index + extent;
  29 
  30         if (low_index != 0) {
  31                 mask = (~0 << low_index);
  32                 if (length < 32)
  33                                 mask &= ~(~0 << length);
  34                 if (new_value)
  35                         *bitmap_base++ |= mask;
  36                 else
  37                         *bitmap_base++ &= ~mask;
  38                 length -= 32;
  39         }
  40 
  41         mask = (new_value ? ~0 : 0);
  42         while (length >= 32) {
  43                 *bitmap_base++ = mask;
  44                 length -= 32;
  45         }
  46 
  47         if (length > 0) {
  48                 mask = ~(~0 << length);
  49                 if (new_value)
  50                         *bitmap_base++ |= mask;
  51                 else
  52                         *bitmap_base++ &= ~mask;
  53         }
  54 }
  55 
  56 /*
  57  * this changes the io permissions bitmap in the current task.
  58  */
  59 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61         return -ENOSYS;
  62 }
  63 
  64 unsigned int *stack;
  65 
  66 /*
  67  * sys_iopl has to be used when you want to access the IO ports
  68  * beyond the 0x3ff range: to get the full 65536 ports bitmapped
  69  * you'd need 8kB of bitmaps/process, which is a bit excessive.
  70  *
  71  * Here we just change the eflags value on the stack: we allow
  72  * only the super-user to do it. This depends on the stack-layout
  73  * on system-call entry - see also fork() and the signal handling
  74  * code.
  75  */
  76 asmlinkage int sys_iopl(long ebx,long ecx,long edx,
     /* [previous][next][first][last][top][bottom][index][help] */
  77              long esi, long edi, long ebp, long eax, long ds,
  78              long es, long fs, long gs, long orig_eax,
  79              long eip,long cs,long eflags,long esp,long ss)
  80 {
  81         return -ENOSYS;
  82 }
  83 
  84 /*
  85  * The workhorse function: find where to put a new entry
  86  */
  87 static resource_entry_t *find_gap(resource_entry_t *root,
     /* [previous][next][first][last][top][bottom][index][help] */
  88                                   u_long from, u_long num)
  89 {
  90         unsigned long flags;
  91         resource_entry_t *p;
  92         
  93         if (from > from+num-1)
  94                 return NULL;
  95         save_flags(flags);
  96         cli();
  97         for (p = root; ; p = p->next) {
  98                 if ((p != root) && (p->from+p->num-1 >= from)) {
  99                         p = NULL;
 100                         break;
 101                 }
 102                 if ((p->next == NULL) || (p->next->from > from+num-1))
 103                         break;
 104         }
 105         restore_flags(flags);
 106         return p;
 107 }

/* [previous][next][first][last][top][bottom][index][help] */