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

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