Back to index

glibc  2.9
Classes | Defines | Enumerations | Functions | Variables
ioperm.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/io.h>
#include <sysdep.h>
#include <sys/syscall.h>

Go to the source code of this file.

Classes

struct  io_system
struct  platform
struct  ioswtch
struct  cpuinfo_data

Defines

#define PATH_ALPHA_SYSTYPE   "/etc/alpha_systype"
#define PATH_CPUINFO   "/proc/cpuinfo"
#define MAX_PORT   0x10000
#define vip   volatile int *
#define vuip   volatile unsigned int *
#define vusp   volatile unsigned short *
#define vucp   volatile unsigned char *
#define JENSEN_IO_BASE   (0x300000000UL)
#define JENSEN_SPARSE_MEM   (0x200000000UL)
#define APECS_IO_BASE   (0x1c0000000UL)
#define APECS_SPARSE_MEM   (0x200000000UL)
#define APECS_DENSE_MEM   (0x300000000UL)
#define CIA_IO_BASE   (0x8580000000UL)
#define CIA_SPARSE_MEM   (0x8000000000UL)
#define CIA_DENSE_MEM   (0x8600000000UL)
#define PYXIS_IO_BASE   (0x8900000000UL)
#define PYXIS_DENSE_MEM   (0x8800000000UL)
#define T2_IO_BASE   (0x3a0000000UL)
#define T2_SPARSE_MEM   (0x200000000UL)
#define T2_DENSE_MEM   (0x3c0000000UL)
#define GAMMA_IO_BASE   (0x83a0000000UL)
#define GAMMA_SPARSE_MEM   (0x8200000000UL)
#define GAMMA_DENSE_MEM   (0x83c0000000UL)
#define MCPCIA_IO_BASE   (0xf980000000UL)
#define MCPCIA_SPARSE_MEM   (0xf800000000UL)
#define MCPCIA_DENSE_MEM   (0xf900000000UL)
#define TSUNAMI_IO_BASE   (0x801fc000000UL)
#define TSUNAMI_DENSE_MEM   (0x80000000000UL)
#define POLARIS_IO_BASE   (0xf9fc000000UL)
#define POLARIS_DENSE_MEM   (0xf900000000UL)
#define DCL_SETHAE(name, ioswiz)
#define DCL_OUT(name, func, type, ioswiz)
#define DCL_IN(name, func, ioswiz)
#define DCL_OUT_BWX(name, func, type)
#define DCL_IN_BWX(name, func)

Enumerations

enum  iosys_t {
  IOSYS_UNKNOWN, IOSYS_JENSEN, IOSYS_APECS, IOSYS_CIA,
  IOSYS_PYXIS, IOSYS_T2, IOSYS_TSUNAMI, IOSYS_MCPCIA,
  IOSYS_GAMMA, IOSYS_POLARIS, IOSYS_CPUDEP, IOSYS_PCIDEP
}
enum  ioswizzle_t { IOSWIZZLE_JENSEN, IOSWIZZLE_SPARSE, IOSWIZZLE_DENSE }

Functions

 asm (".arch ev56")
static void stb_mb (unsigned char val, unsigned long addr)
static void stw_mb (unsigned short val, unsigned long addr)
static void stl_mb (unsigned int val, unsigned long addr)
static void __sethae (unsigned long value)
long __pciconfig_iobase (enum __pciconfig_iobase_which __which, unsigned long int __bus, unsigned long int __dfn)
static unsigned long int port_to_cpu_addr (unsigned long int port, ioswizzle_t ioswiz, int size)
static void inline_sethae (unsigned long int addr, ioswizzle_t ioswiz)
static void inline_outb (unsigned char b, unsigned long int port, ioswizzle_t ioswiz)
static void inline_outw (unsigned short int b, unsigned long int port, ioswizzle_t ioswiz)
static void inline_outl (unsigned int b, unsigned long int port, ioswizzle_t ioswiz)
static unsigned int inline_inb (unsigned long int port, ioswizzle_t ioswiz)
static unsigned int inline_inw (unsigned long int port, ioswizzle_t ioswiz)
static unsigned int inline_inl (unsigned long int port, ioswizzle_t ioswiz)
static unsigned long int dense_port_to_cpu_addr (unsigned long int port)
static void inline_bwx_outb (unsigned char b, unsigned long int port)
static void inline_bwx_outw (unsigned short int b, unsigned long int port)
static void inline_bwx_outl (unsigned int b, unsigned long int port)
static unsigned int inline_bwx_inb (unsigned long int port)
static unsigned int inline_bwx_inw (unsigned long int port)
static unsigned int inline_bwx_inl (unsigned long int port)
static int process_cpuinfo (struct cpuinfo_data *data)
static int init_iosys (void)
int _ioperm (unsigned long int from, unsigned long int num, int turn_on)
int _iopl (int level)
void _sethae (unsigned long int addr)
void _outb (unsigned char b, unsigned long int port)
void _outw (unsigned short b, unsigned long int port)
void _outl (unsigned int b, unsigned long int port)
unsigned int _inb (unsigned long int port)
unsigned int _inw (unsigned long int port)
unsigned int _inl (unsigned long int port)
unsigned long int _bus_base (void)
unsigned long int _bus_base_sparse (void)
int _hae_shift (void)
 weak_alias (_sethae, sethae)
 weak_alias (_ioperm, ioperm)
 weak_alias (_iopl, iopl)
 weak_alias (_inb, inb)
 weak_alias (_inw, inw)
 weak_alias (_inl, inl)
 weak_alias (_outb, outb)
 weak_alias (_outw, outw)
 weak_alias (_outl, outl)
 weak_alias (_bus_base, bus_base)
 weak_alias (_bus_base_sparse, bus_base_sparse)
 weak_alias (_hae_shift, hae_shift)

Variables

static struct io_system io_system []
static struct platform platform []
struct {
unsigned long int hae_cache
unsigned long int base
struct ioswtchswp
unsigned long int bus_memory_base
unsigned long int sparse_bus_memory_base
unsigned long int io_base
ioswizzle_t swiz
io
static struct ioswtch []

Class Documentation

struct io_system

Definition at line 114 of file ioperm.c.

Class Members
unsigned long int bus_io_base
unsigned long int bus_memory_base
unsigned long int sparse_bus_mem_base
struct platform

Definition at line 65 of file ioperm.c.

Class Members
unsigned long int io_base
iosys_t io_sys
const char * name
unsigned int shift
struct cpuinfo_data

Definition at line 472 of file ioperm.c.

Class Members
char cpumodel
char systype
char sysvari

Define Documentation

#define APECS_DENSE_MEM   (0x300000000UL)

Definition at line 71 of file ioperm.c.

#define APECS_IO_BASE   (0x1c0000000UL)

Definition at line 69 of file ioperm.c.

#define APECS_SPARSE_MEM   (0x200000000UL)

Definition at line 70 of file ioperm.c.

#define CIA_DENSE_MEM   (0x8600000000UL)

Definition at line 76 of file ioperm.c.

#define CIA_IO_BASE   (0x8580000000UL)

Definition at line 74 of file ioperm.c.

#define CIA_SPARSE_MEM   (0x8000000000UL)

Definition at line 75 of file ioperm.c.

#define DCL_IN (   name,
  func,
  ioswiz 
)
Value:
static unsigned int                              \
name##_##func (unsigned long int addr)                  \
{                                                \
  return inline_##func (addr, IOSWIZZLE_##ioswiz);      \
}

Definition at line 399 of file ioperm.c.

#define DCL_IN_BWX (   name,
  func 
)
Value:
static unsigned int                              \
name##_##func (unsigned long int addr)                  \
{                                                \
  return inline_bwx_##func (addr);               \
}

Definition at line 415 of file ioperm.c.

#define DCL_OUT (   name,
  func,
  type,
  ioswiz 
)
Value:
static void                                      \
name##_##func (unsigned type b, unsigned long int addr) \
{                                                \
  inline_##func (b, addr, IOSWIZZLE_##ioswiz);          \
}

Definition at line 392 of file ioperm.c.

#define DCL_OUT_BWX (   name,
  func,
  type 
)
Value:
static void                                      \
name##_##func (unsigned type b, unsigned long int addr) \
{                                                \
  inline_bwx_##func (b, addr);                          \
}

Definition at line 408 of file ioperm.c.

#define DCL_SETHAE (   name,
  ioswiz 
)
Value:
static void                                             \
name##_sethae (unsigned long int addr)                  \
{                                                       \
  inline_sethae (addr, IOSWIZZLE_##ioswiz);             \
}

Definition at line 385 of file ioperm.c.

#define GAMMA_DENSE_MEM   (0x83c0000000UL)

Definition at line 88 of file ioperm.c.

#define GAMMA_IO_BASE   (0x83a0000000UL)

Definition at line 86 of file ioperm.c.

#define GAMMA_SPARSE_MEM   (0x8200000000UL)

Definition at line 87 of file ioperm.c.

#define JENSEN_IO_BASE   (0x300000000UL)

Definition at line 64 of file ioperm.c.

#define JENSEN_SPARSE_MEM   (0x200000000UL)

Definition at line 65 of file ioperm.c.

#define MAX_PORT   0x10000

Definition at line 58 of file ioperm.c.

#define MCPCIA_DENSE_MEM   (0xf900000000UL)

Definition at line 93 of file ioperm.c.

#define MCPCIA_IO_BASE   (0xf980000000UL)

Definition at line 91 of file ioperm.c.

#define MCPCIA_SPARSE_MEM   (0xf800000000UL)

Definition at line 92 of file ioperm.c.

#define PATH_ALPHA_SYSTYPE   "/etc/alpha_systype"

Definition at line 55 of file ioperm.c.

#define PATH_CPUINFO   "/proc/cpuinfo"

Definition at line 56 of file ioperm.c.

#define POLARIS_DENSE_MEM   (0xf900000000UL)

Definition at line 102 of file ioperm.c.

#define POLARIS_IO_BASE   (0xf9fc000000UL)

Definition at line 101 of file ioperm.c.

#define PYXIS_DENSE_MEM   (0x8800000000UL)

Definition at line 79 of file ioperm.c.

#define PYXIS_IO_BASE   (0x8900000000UL)

Definition at line 78 of file ioperm.c.

#define T2_DENSE_MEM   (0x3c0000000UL)

Definition at line 84 of file ioperm.c.

#define T2_IO_BASE   (0x3a0000000UL)

Definition at line 82 of file ioperm.c.

#define T2_SPARSE_MEM   (0x200000000UL)

Definition at line 83 of file ioperm.c.

#define TSUNAMI_DENSE_MEM   (0x80000000000UL)

Definition at line 97 of file ioperm.c.

#define TSUNAMI_IO_BASE   (0x801fc000000UL)

Definition at line 96 of file ioperm.c.

#define vip   volatile int *

Definition at line 59 of file ioperm.c.

#define vucp   volatile unsigned char *

Definition at line 62 of file ioperm.c.

#define vuip   volatile unsigned int *

Definition at line 60 of file ioperm.c.

#define vusp   volatile unsigned short *

Definition at line 61 of file ioperm.c.


Enumeration Type Documentation

Enumerator:
IOSWIZZLE_JENSEN 
IOSWIZZLE_SPARSE 
IOSWIZZLE_DENSE 

Definition at line 110 of file ioperm.c.

enum iosys_t
Enumerator:
IOSYS_UNKNOWN 
IOSYS_JENSEN 
IOSYS_APECS 
IOSYS_CIA 
IOSYS_PYXIS 
IOSYS_T2 
IOSYS_TSUNAMI 
IOSYS_MCPCIA 
IOSYS_GAMMA 
IOSYS_POLARIS 
IOSYS_CPUDEP 
IOSYS_PCIDEP 

Definition at line 104 of file ioperm.c.


Function Documentation

long __pciconfig_iobase ( enum __pciconfig_iobase_which  __which,
unsigned long int  __bus,
unsigned long int  __dfn 
)

Here is the caller graph for this function:

static void __sethae ( unsigned long  value) [inline, static]

Definition at line 198 of file ioperm.c.

{
  register unsigned long r16 __asm__("$16") = value;
  register unsigned long r0 __asm__("$0") = __NR_sethae;
  __asm__ __volatile__ ("callsys"
                     : "=r"(r0)
                     : "0"(r0), "r" (r16)
                     : inline_syscall_clobbers, "$19");
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long int _bus_base ( void  )

Definition at line 845 of file ioperm.c.

{
  if (!io.swp && init_iosys () < 0)
    return -1;
  return io.bus_memory_base;
}

Here is the call graph for this function:

unsigned long int _bus_base_sparse ( void  )

Definition at line 853 of file ioperm.c.

{
  if (!io.swp && init_iosys () < 0)
    return -1;
  return io.sparse_bus_memory_base;
}

Here is the call graph for this function:

int _hae_shift ( void  )

Definition at line 861 of file ioperm.c.

{
  if (!io.swp && init_iosys () < 0)
    return -1;
  if (io.swiz == IOSWIZZLE_JENSEN)
    return 7;
  if (io.swiz == IOSWIZZLE_SPARSE)
    return 5;
  return 0;
}

Here is the call graph for this function:

unsigned int _inb ( unsigned long int  port)

Definition at line 824 of file ioperm.c.

{
  return io.swp->inb (port);
}
unsigned int _inl ( unsigned long int  port)

Definition at line 838 of file ioperm.c.

{
  return io.swp->inl (port);
}
unsigned int _inw ( unsigned long int  port)

Definition at line 831 of file ioperm.c.

{
  return io.swp->inw (port);
}
int _ioperm ( unsigned long int  from,
unsigned long int  num,
int  turn_on 
)

Definition at line 686 of file ioperm.c.

{
  unsigned long int addr, len, pagesize = __getpagesize();
  int prot;

  if (!io.swp && init_iosys() < 0)
    {
#ifdef DEBUG_IOPERM
      fprintf(stderr, "ioperm: init_iosys() failed (%m)\n");
#endif
      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);
#ifdef DEBUG_IOPERM
      fprintf(stderr, "ioperm: from/num out of range\n");
#endif
      return -1;
    }

#ifdef DEBUG_IOPERM
  fprintf(stderr, "ioperm: turn_on %d io.base %ld\n", turn_on, io.base);
#endif

  if (turn_on)
    {
      if (!io.base)
       {
         int fd;

         io.hae_cache = 0;
         if (io.swiz != IOSWIZZLE_DENSE)
           {
             /* Synchronize with hw.  */
             __sethae (0);
           }

         fd = __open ("/dev/mem", O_RDWR);
         if (fd < 0)
           {
#ifdef DEBUG_IOPERM
             fprintf(stderr, "ioperm: /dev/mem open failed (%m)\n");
#endif
             return -1;
           }

         addr = port_to_cpu_addr (0, io.swiz, 1);
         len = port_to_cpu_addr (MAX_PORT, io.swiz, 1) - addr;
         io.base =
           (unsigned long int) __mmap (0, len, PROT_NONE, MAP_SHARED,
                                   fd, io.io_base);
         __close (fd);
#ifdef DEBUG_IOPERM
         fprintf(stderr, "ioperm: mmap of len 0x%lx  returned 0x%lx\n",
                len, io.base);
#endif
         if ((long) io.base == -1)
           return -1;
       }
      prot = PROT_READ | PROT_WRITE;
    }
  else
    {
      if (!io.base)
       return 0;     /* never was turned on... */

      /* turnoff access to relevant pages: */
      prot = PROT_NONE;
    }
  addr = port_to_cpu_addr (from, io.swiz, 1);
  addr &= ~(pagesize - 1);
  len = port_to_cpu_addr (from + num, io.swiz, 1) - addr;
  return __mprotect ((void *) addr, len, prot);
}

Here is the call graph for this function:

int _iopl ( int  level)

Definition at line 766 of file ioperm.c.

{
  switch (level)
    {
    case 0:
      return 0;

    case 1: case 2: case 3:
      return _ioperm (0, MAX_PORT, 1);

    default:
      __set_errno (EINVAL);
      return -1;
    }
}

Here is the call graph for this function:

void _outb ( unsigned char  b,
unsigned long int  port 
)

Definition at line 794 of file ioperm.c.

{
  if (port >= MAX_PORT)
    return;

  io.swp->outb (b, port);
}
void _outl ( unsigned int  b,
unsigned long int  port 
)

Definition at line 814 of file ioperm.c.

{
  if (port >= MAX_PORT)
    return;

  io.swp->outl (b, port);
}
void _outw ( unsigned short  b,
unsigned long int  port 
)

Definition at line 804 of file ioperm.c.

{
  if (port >= MAX_PORT)
    return;

  io.swp->outw (b, port);
}
void _sethae ( unsigned long int  addr)

Definition at line 784 of file ioperm.c.

{
  if (!io.swp && init_iosys () < 0)
    return;

  io.swp->sethae (addr);
}

Here is the call graph for this function:

asm ( ".arch ev56"  )
static unsigned long int dense_port_to_cpu_addr ( unsigned long int  port) [inline, static]

Definition at line 327 of file ioperm.c.

{
  return port + io.base;
}

Here is the caller graph for this function:

static int init_iosys ( void  ) [static]

Definition at line 537 of file ioperm.c.

{
  long addr;
  int i, olderrno = errno;
  struct cpuinfo_data data;

  /* First try the pciconfig_iobase syscall added to 2.2.15 and 2.3.99.  */

#ifdef __NR_pciconfig_iobase
  addr = __pciconfig_iobase (IOBASE_DENSE_MEM, 0, 0);
  if (addr != -1)
    {
      ioswizzle_t io_swiz;

      if (addr == 0)
        {
         /* Only Jensen doesn't have dense mem space.  */
         io.sparse_bus_memory_base
           = io_system[IOSYS_JENSEN].sparse_bus_mem_base;
         io.io_base = io_system[IOSYS_JENSEN].bus_io_base;
         io_swiz = IOSWIZZLE_JENSEN;
       }
      else
       {
         io.bus_memory_base = addr;

         addr = __pciconfig_iobase (IOBASE_DENSE_IO, 0, 0);
         if (addr != 0)
           {
             /* The X server uses _bus_base_sparse == 0 to know that
               BWX access are supported to dense mem space.  This is
               true of every system that supports dense io space, so
                never fill in io.sparse_bus_memory_base in this case.  */
             io_swiz = IOSWIZZLE_DENSE;
              io.io_base = addr;
           }
         else
           {
             io.sparse_bus_memory_base
              = __pciconfig_iobase (IOBASE_SPARSE_MEM, 0, 0);
             io.io_base = __pciconfig_iobase (IOBASE_SPARSE_IO, 0, 0);
             io_swiz = IOSWIZZLE_SPARSE;
           }
       }

      io.swiz = io_swiz;
      io.swp = &ioswtch[io_swiz];

      return 0;
    }
#endif

  /* Second, collect the contents of /etc/alpha_systype or /proc/cpuinfo.  */

  if (process_cpuinfo(&data) == 0)
    {
      /* This can happen if the format of /proc/cpuinfo changes.  */
      fprintf (stderr,
              "ioperm.init_iosys: Unable to determine system type.\n"
              "\t(May need " PATH_ALPHA_SYSTYPE " symlink?)\n");
      __set_errno (ENODEV);
      return -1;
    }

  /* Translate systype name into i/o system.  */
  for (i = 0; i < sizeof (platform) / sizeof (platform[0]); ++i)
    {
      if (strcmp (platform[i].name, data.systype) == 0)
       {
         iosys_t io_sys = platform[i].io_sys;

         /* Some platforms can have either EV4 or EV5 CPUs.  */
         if (io_sys == IOSYS_CPUDEP)
           {
             /* SABLE or MIKASA or NORITAKE so far.  */
             if (strcmp (platform[i].name, "Sable") == 0)
              {
                if (strncmp (data.cpumodel, "EV4", 3) == 0)
                  io_sys = IOSYS_T2;
                else if (strncmp (data.cpumodel, "EV5", 3) == 0)
                  io_sys = IOSYS_GAMMA;
              }
             else
              {
                /* This covers MIKASA/NORITAKE.  */
                if (strncmp (data.cpumodel, "EV4", 3) == 0)
                  io_sys = IOSYS_APECS;
                else if (strncmp (data.cpumodel, "EV5", 3) == 0)
                  io_sys = IOSYS_CIA;
              }
             if (io_sys == IOSYS_CPUDEP)
              {
                /* This can happen if the format of /proc/cpuinfo changes.*/
                fprintf (stderr, "ioperm.init_iosys: Unable to determine"
                        " CPU model.\n");
                __set_errno (ENODEV);
                return -1;
              }
           }
         /* Some platforms can have different core logic chipsets */
         if (io_sys == IOSYS_PCIDEP)
           {
             /* EB164 so far */
             if (strcmp (data.systype, "EB164") == 0)
              {
                if (strncmp (data.sysvari, "RX164", 5) == 0)
                  io_sys = IOSYS_POLARIS;
                else if (strncmp (data.sysvari, "LX164", 5) == 0
                        || strncmp (data.sysvari, "SX164", 5) == 0)
                  io_sys = IOSYS_PYXIS;
                else
                  io_sys = IOSYS_CIA;
              }
             if (io_sys == IOSYS_PCIDEP)
              {
                /* This can happen if the format of /proc/cpuinfo changes.*/
                fprintf (stderr, "ioperm.init_iosys: Unable to determine"
                        " core logic chipset.\n");
                __set_errno (ENODEV);
                return -1;
              }
           }
         io.bus_memory_base = io_system[io_sys].bus_memory_base;
         io.sparse_bus_memory_base = io_system[io_sys].sparse_bus_mem_base;
         io.io_base = io_system[io_sys].bus_io_base;

         if (io_sys == IOSYS_JENSEN)
           io.swiz = IOSWIZZLE_JENSEN;
         else if (io_sys == IOSYS_TSUNAMI
                 || io_sys == IOSYS_POLARIS
                 || io_sys == IOSYS_PYXIS)
           io.swiz = IOSWIZZLE_DENSE;
         else
           io.swiz = IOSWIZZLE_SPARSE;
         io.swp = &ioswtch[io.swiz];

         __set_errno (olderrno);
         return 0;
       }
    }

  __set_errno (ENODEV);
  fprintf(stderr, "ioperm.init_iosys: Platform not recognized.\n"
         "\t(May need " PATH_ALPHA_SYSTYPE " symlink?)\n");
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned int inline_bwx_inb ( unsigned long int  port) [inline, static]

Definition at line 354 of file ioperm.c.

{
  unsigned long int addr = dense_port_to_cpu_addr (port);
  unsigned char r;

  __asm__ ("ldbu %0,%1" : "=r"(r) : "m"(*(vucp)addr));
  return r;
}

Here is the call graph for this function:

static unsigned int inline_bwx_inl ( unsigned long int  port) [inline, static]

Definition at line 374 of file ioperm.c.

{
  unsigned long int addr = dense_port_to_cpu_addr (port);

  return *(vuip) addr;
}

Here is the call graph for this function:

static unsigned int inline_bwx_inw ( unsigned long int  port) [inline, static]

Definition at line 364 of file ioperm.c.

{
  unsigned long int addr = dense_port_to_cpu_addr (port);
  unsigned short r;

  __asm__ ("ldwu %0,%1" : "=r"(r) : "m"(*(vusp)addr));
  return r;
}

Here is the call graph for this function:

static void inline_bwx_outb ( unsigned char  b,
unsigned long int  port 
) [inline, static]

Definition at line 333 of file ioperm.c.

{
  unsigned long int addr = dense_port_to_cpu_addr (port);
  stb_mb (b, addr);
}

Here is the call graph for this function:

static void inline_bwx_outl ( unsigned int  b,
unsigned long int  port 
) [inline, static]

Definition at line 347 of file ioperm.c.

{
  unsigned long int addr = dense_port_to_cpu_addr (port);
  stl_mb (b, addr);
}

Here is the call graph for this function:

static void inline_bwx_outw ( unsigned short int  b,
unsigned long int  port 
) [inline, static]

Definition at line 340 of file ioperm.c.

{
  unsigned long int addr = dense_port_to_cpu_addr (port);
  stw_mb (b, addr);
}

Here is the call graph for this function:

static unsigned int inline_inb ( unsigned long int  port,
ioswizzle_t  ioswiz 
) [inline, static]

Definition at line 282 of file ioperm.c.

{
  unsigned long int addr = port_to_cpu_addr (port, ioswiz, 1);
  int result;

  result = *(vip) addr;
  result >>= (port & 3) * 8;
  return 0xffUL & result;
}

Here is the call graph for this function:

static unsigned int inline_inl ( unsigned long int  port,
ioswizzle_t  ioswiz 
) [inline, static]

Definition at line 306 of file ioperm.c.

{
  unsigned long int addr = port_to_cpu_addr (port, ioswiz, 4);

  return *(vuip) addr;
}

Here is the call graph for this function:

static unsigned int inline_inw ( unsigned long int  port,
ioswizzle_t  ioswiz 
) [inline, static]

Definition at line 294 of file ioperm.c.

{
  unsigned long int addr = port_to_cpu_addr (port, ioswiz, 2);
  int result;

  result = *(vip) addr;
  result >>= (port & 3) * 8;
  return 0xffffUL & result;
}

Here is the call graph for this function:

static void inline_outb ( unsigned char  b,
unsigned long int  port,
ioswizzle_t  ioswiz 
) [inline, static]

Definition at line 251 of file ioperm.c.

{
  unsigned int w;
  unsigned long int addr = port_to_cpu_addr (port, ioswiz, 1);

  asm ("insbl %2,%1,%0" : "=r" (w) : "ri" (port & 0x3), "r" (b));
  stl_mb(w, addr);
}

Here is the call graph for this function:

static void inline_outl ( unsigned int  b,
unsigned long int  port,
ioswizzle_t  ioswiz 
) [inline, static]

Definition at line 273 of file ioperm.c.

{
  unsigned long int addr = port_to_cpu_addr (port, ioswiz, 4);

  stl_mb(b, addr);
}

Here is the call graph for this function:

static void inline_outw ( unsigned short int  b,
unsigned long int  port,
ioswizzle_t  ioswiz 
) [inline, static]

Definition at line 262 of file ioperm.c.

{
  unsigned long w;
  unsigned long int addr = port_to_cpu_addr (port, ioswiz, 2);

  asm ("inswl %2,%1,%0" : "=r" (w) : "ri" (port & 0x3), "r" (b));
  stl_mb(w, addr);
}

Here is the call graph for this function:

static void inline_sethae ( unsigned long int  addr,
ioswizzle_t  ioswiz 
) [inline, static]

Definition at line 224 of file ioperm.c.

{
  if (ioswiz == IOSWIZZLE_SPARSE)
    {
      unsigned long int msb;

      /* no need to set hae if msb is 0: */
      msb = addr & 0xf8000000;
      if (msb && msb != io.hae_cache)
       {
         io.hae_cache = msb;
         __sethae (msb);
       }
    }
  else if (ioswiz == IOSWIZZLE_JENSEN)
    {
      /* HAE on the Jensen is bits 31:25 shifted right.  */
      addr >>= 25;
      if (addr != io.hae_cache)
       {
         io.hae_cache = addr;
         __sethae (addr);
       }
    }
}

Here is the call graph for this function:

static unsigned long int port_to_cpu_addr ( unsigned long int  port,
ioswizzle_t  ioswiz,
int  size 
) [inline, static]

Definition at line 213 of file ioperm.c.

{
  if (ioswiz == IOSWIZZLE_SPARSE)
    return io.base + (port << 5) + ((size - 1) << 3);
  else if (ioswiz == IOSWIZZLE_DENSE)
    return port + io.base;
  else
    return io.base + (port << 7) + ((size - 1) << 5);
}

Here is the caller graph for this function:

static int process_cpuinfo ( struct cpuinfo_data data) [inline, static]

Definition at line 480 of file ioperm.c.

{
  int got_type, got_vari, got_model;
  char dummy[256];
  FILE * fp;
  int n;

  data->systype[0] = 0;
  data->sysvari[0] = 0;
  data->cpumodel[0] = 0;

  /* If there's an /etc/alpha_systype link, we're intending to override
     whatever's in /proc/cpuinfo.  */
  n = __readlink (PATH_ALPHA_SYSTYPE, data->systype, 256 - 1);
  if (n > 0)
    {
      data->systype[n] = '\0';
      return 1;
    }

  fp = fopen (PATH_CPUINFO, "r");
  if (!fp)
    return 0;

  got_type = got_vari = got_model = 0;

  while (1)
    {
      if (fgets (dummy, 256, fp) == NULL)
       break;
      if (!got_type &&
         sscanf (dummy, "system type : %256[^\n]\n", data->systype) == 1)
       got_type = 1;
      if (!got_vari &&
         sscanf (dummy, "system variation : %256[^\n]\n", data->sysvari) == 1)
       got_vari = 1;
      if (!got_model &&
         sscanf (dummy, "cpu model : %256[^\n]\n", data->cpumodel) == 1)
       got_model = 1;
    }

  fclose (fp);

#ifdef DEBUG_IOPERM
  fprintf(stderr, "system type: `%s'\n", data->systype);
  fprintf(stderr, "system vari: `%s'\n", data->sysvari);
  fprintf(stderr, "cpu model: `%s'\n", data->cpumodel);
#endif

  return got_type + got_vari + got_model;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void stb_mb ( unsigned char  val,
unsigned long  addr 
) [inline, static]

Definition at line 179 of file ioperm.c.

{
  __asm__("stb %1,%0; mb" : "=m"(*(vucp)addr) : "r"(val));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void stl_mb ( unsigned int  val,
unsigned long  addr 
) [inline, static]

Definition at line 191 of file ioperm.c.

{
  __asm__("stl %1,%0; mb" : "=m"(*(vip)addr) : "r"(val));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void stw_mb ( unsigned short  val,
unsigned long  addr 
) [inline, static]

Definition at line 185 of file ioperm.c.

{
  __asm__("stw %1,%0; mb" : "=m"(*(vusp)addr) : "r"(val));
}

Here is the call graph for this function:

Here is the caller graph for this function:

weak_alias ( _sethae  ,
sethae   
)
weak_alias ( _ioperm  ,
ioperm   
)
weak_alias ( _iopl  ,
iopl   
)
weak_alias ( _inb  ,
inb   
)
weak_alias ( _inw  ,
inw   
)
weak_alias ( _inl  ,
inl   
)
weak_alias ( _outb  ,
outb   
)
weak_alias ( _outw  ,
outw   
)
weak_alias ( _outl  ,
outl   
)

Variable Documentation

struct { ... } io [static]
struct io_system io_system[] [static]
struct ioswtch[] [static]
Initial value:
 {
  {
    jensen_sethae,
    jensen_outb, jensen_outw, jensen_outl,
    jensen_inb, jensen_inw, jensen_inl
  },
  {
    sparse_sethae,
    sparse_outb, sparse_outw, sparse_outl,
    sparse_inb, sparse_inw, sparse_inl
  },
  {
    dense_sethae,
    dense_outb, dense_outw, dense_outl,
    dense_inb, dense_inw, dense_inl
  }
}

Definition at line 449 of file ioperm.c.

struct platform platform[] [static]