1 /* Copyright (C) 1992-2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by David Mosberger.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 /* I/O access is restricted to ISA port space (ports 0..65535).
20 Modern devices hopefully are sane enough not to put any performance
21 critical registers in i/o space.
23 On the first call to ioperm, the entire (E)ISA port space is mapped
24 into the virtual address space at address io.base. mprotect calls
25 are then used to enable/disable access to ports. Per page, there
26 are PAGE_SIZE>>IO_SHIFT I/O ports (e.g., 256 ports on a Low Cost Alpha
27 based system using 8KB pages).
29 Keep in mind that this code should be able to run in a 32bit address
30 space. It is therefore unreasonable to expect mmap'ing the entire
31 sparse address space would work (e.g., the Low Cost Alpha chip has an
32 I/O address space that's 512MB large!). */
34 /* Make sure the ldbu/stb asms below are not expaneded to macros. */
47 #include <sys/types.h>
52 #include <sys/syscall.h>
54 #define PATH_ALPHA_SYSTYPE "/etc/alpha_systype"
55 #define PATH_CPUINFO "/proc/cpuinfo"
57 #define MAX_PORT 0x10000
58 #define vip volatile int *
59 #define vuip volatile unsigned int *
60 #define vusp volatile unsigned short *
61 #define vucp volatile unsigned char *
63 #define JENSEN_IO_BASE (0x300000000UL)
64 #define JENSEN_SPARSE_MEM (0x200000000UL)
66 /* With respect to the I/O architecture, APECS and LCA are identical,
67 so the following defines apply to LCA as well. */
68 #define APECS_IO_BASE (0x1c0000000UL)
69 #define APECS_SPARSE_MEM (0x200000000UL)
70 #define APECS_DENSE_MEM (0x300000000UL)
72 /* The same holds for CIA and PYXIS, except for PYXIS we prefer BWX. */
73 #define CIA_IO_BASE (0x8580000000UL)
74 #define CIA_SPARSE_MEM (0x8000000000UL)
75 #define CIA_DENSE_MEM (0x8600000000UL)
77 #define PYXIS_IO_BASE (0x8900000000UL)
78 #define PYXIS_DENSE_MEM (0x8800000000UL)
80 /* SABLE is EV4, GAMMA is EV5 */
81 #define T2_IO_BASE (0x3a0000000UL)
82 #define T2_SPARSE_MEM (0x200000000UL)
83 #define T2_DENSE_MEM (0x3c0000000UL)
85 #define GAMMA_IO_BASE (0x83a0000000UL)
86 #define GAMMA_SPARSE_MEM (0x8200000000UL)
87 #define GAMMA_DENSE_MEM (0x83c0000000UL)
89 /* NOTE: these are hardwired to PCI bus 0 addresses!!! */
90 #define MCPCIA_IO_BASE (0xf980000000UL)
91 #define MCPCIA_SPARSE_MEM (0xf800000000UL)
92 #define MCPCIA_DENSE_MEM (0xf900000000UL)
94 /* Tsunami and Irongate use the same offsets, at least for hose 0. */
95 #define TSUNAMI_IO_BASE (0x801fc000000UL)
96 #define TSUNAMI_DENSE_MEM (0x80000000000UL)
98 /* Polaris has SPARSE space, but we prefer to use only DENSE
99 because of some idiosyncracies in actually using SPARSE. */
100 #define POLARIS_IO_BASE (0xf9fc000000UL)
101 #define POLARIS_DENSE_MEM (0xf900000000UL)
104 IOSYS_UNKNOWN
, IOSYS_JENSEN
, IOSYS_APECS
, IOSYS_CIA
, IOSYS_PYXIS
, IOSYS_T2
,
105 IOSYS_TSUNAMI
, IOSYS_MCPCIA
, IOSYS_GAMMA
, IOSYS_POLARIS
,
106 IOSYS_CPUDEP
, IOSYS_PCIDEP
110 IOSWIZZLE_JENSEN
, IOSWIZZLE_SPARSE
, IOSWIZZLE_DENSE
113 static struct io_system
{
114 unsigned long int bus_memory_base
;
115 unsigned long int sparse_bus_mem_base
;
116 unsigned long int bus_io_base
;
117 } io_system
[] = { /* NOTE! must match iosys_t enumeration */
118 /* UNKNOWN */ {0, 0, 0},
119 /* JENSEN */ {0, JENSEN_SPARSE_MEM
, JENSEN_IO_BASE
},
120 /* APECS */ {APECS_DENSE_MEM
, APECS_SPARSE_MEM
, APECS_IO_BASE
},
121 /* CIA */ {CIA_DENSE_MEM
, CIA_SPARSE_MEM
, CIA_IO_BASE
},
122 /* PYXIS */ {PYXIS_DENSE_MEM
, 0, PYXIS_IO_BASE
},
123 /* T2 */ {T2_DENSE_MEM
, T2_SPARSE_MEM
, T2_IO_BASE
},
124 /* TSUNAMI */ {TSUNAMI_DENSE_MEM
, 0, TSUNAMI_IO_BASE
},
125 /* MCPCIA */ {MCPCIA_DENSE_MEM
, MCPCIA_SPARSE_MEM
, MCPCIA_IO_BASE
},
126 /* GAMMA */ {GAMMA_DENSE_MEM
, GAMMA_SPARSE_MEM
, GAMMA_IO_BASE
},
127 /* POLARIS */ {POLARIS_DENSE_MEM
, 0, POLARIS_IO_BASE
},
128 /* CPUDEP */ {0, 0, 0}, /* for platforms dependent on CPU type */
129 /* PCIDEP */ {0, 0, 0}, /* for platforms dependent on core logic */
132 static struct platform
{
136 {"Alcor", IOSYS_CIA
},
137 {"Avanti", IOSYS_APECS
},
138 {"Cabriolet", IOSYS_APECS
},
139 {"EB164", IOSYS_PCIDEP
},
140 {"EB64+", IOSYS_APECS
},
141 {"EB66", IOSYS_APECS
},
142 {"EB66P", IOSYS_APECS
},
143 {"Jensen", IOSYS_JENSEN
},
144 {"Miata", IOSYS_PYXIS
},
145 {"Mikasa", IOSYS_CPUDEP
},
146 {"Nautilus", IOSYS_TSUNAMI
},
147 {"Noname", IOSYS_APECS
},
148 {"Noritake", IOSYS_CPUDEP
},
149 {"Rawhide", IOSYS_MCPCIA
},
150 {"Ruffian", IOSYS_PYXIS
},
151 {"Sable", IOSYS_CPUDEP
},
152 {"Takara", IOSYS_CIA
},
153 {"Tsunami", IOSYS_TSUNAMI
},
158 void (*sethae
)(unsigned long int addr
);
159 void (*outb
)(unsigned char b
, unsigned long int port
);
160 void (*outw
)(unsigned short b
, unsigned long int port
);
161 void (*outl
)(unsigned int b
, unsigned long int port
);
162 unsigned int (*inb
)(unsigned long int port
);
163 unsigned int (*inw
)(unsigned long int port
);
164 unsigned int (*inl
)(unsigned long int port
);
168 unsigned long int hae_cache
;
169 unsigned long int base
;
170 struct ioswtch
* swp
;
171 unsigned long int bus_memory_base
;
172 unsigned long int sparse_bus_memory_base
;
173 unsigned long int io_base
;
178 stb_mb(unsigned char val
, unsigned long addr
)
180 __asm__("stb %1,%0; mb" : "=m"(*(vucp
)addr
) : "r"(val
));
184 stw_mb(unsigned short val
, unsigned long addr
)
186 __asm__("stw %1,%0; mb" : "=m"(*(vusp
)addr
) : "r"(val
));
190 stl_mb(unsigned int val
, unsigned long addr
)
192 __asm__("stl %1,%0; mb" : "=m"(*(vip
)addr
) : "r"(val
));
195 /* No need to examine error -- sethae never fails. */
197 __sethae(unsigned long value
)
199 register unsigned long r16
__asm__("$16") = value
;
200 register unsigned long r0
__asm__("$0") = __NR_sethae
;
201 __asm__
__volatile__ ("callsys"
204 : inline_syscall_clobbers
, "$19");
207 extern long __pciconfig_iobase(enum __pciconfig_iobase_which __which
,
208 unsigned long int __bus
,
209 unsigned long int __dfn
);
211 static inline unsigned long int
212 port_to_cpu_addr (unsigned long int port
, ioswizzle_t ioswiz
, int size
)
214 if (ioswiz
== IOSWIZZLE_SPARSE
)
215 return io
.base
+ (port
<< 5) + ((size
- 1) << 3);
216 else if (ioswiz
== IOSWIZZLE_DENSE
)
217 return port
+ io
.base
;
219 return io
.base
+ (port
<< 7) + ((size
- 1) << 5);
222 static inline __attribute__((always_inline
)) void
223 inline_sethae (unsigned long int addr
, ioswizzle_t ioswiz
)
225 if (ioswiz
== IOSWIZZLE_SPARSE
)
227 unsigned long int msb
;
229 /* no need to set hae if msb is 0: */
230 msb
= addr
& 0xf8000000;
231 if (msb
&& msb
!= io
.hae_cache
)
237 else if (ioswiz
== IOSWIZZLE_JENSEN
)
239 /* HAE on the Jensen is bits 31:25 shifted right. */
241 if (addr
!= io
.hae_cache
)
250 inline_outb (unsigned char b
, unsigned long int port
, ioswizzle_t ioswiz
)
253 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 1);
255 asm ("insbl %2,%1,%0" : "=r" (w
) : "ri" (port
& 0x3), "r" (b
));
261 inline_outw (unsigned short int b
, unsigned long int port
, ioswizzle_t ioswiz
)
264 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 2);
266 asm ("inswl %2,%1,%0" : "=r" (w
) : "ri" (port
& 0x3), "r" (b
));
272 inline_outl (unsigned int b
, unsigned long int port
, ioswizzle_t ioswiz
)
274 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 4);
280 static inline unsigned int
281 inline_inb (unsigned long int port
, ioswizzle_t ioswiz
)
283 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 1);
286 result
= *(vip
) addr
;
287 result
>>= (port
& 3) * 8;
288 return 0xffUL
& result
;
292 static inline unsigned int
293 inline_inw (unsigned long int port
, ioswizzle_t ioswiz
)
295 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 2);
298 result
= *(vip
) addr
;
299 result
>>= (port
& 3) * 8;
300 return 0xffffUL
& result
;
304 static inline unsigned int
305 inline_inl (unsigned long int port
, ioswizzle_t ioswiz
)
307 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 4);
313 * Now define the inline functions for CPUs supporting byte/word insns,
314 * and whose core logic supports I/O space accesses utilizing them.
316 * These routines could be used by MIATA, for example, because it has
317 * and EV56 plus PYXIS, but it currently uses SPARSE anyway. This is
318 * also true of RX164 which used POLARIS, but we will choose to use
319 * these routines in that case instead of SPARSE.
321 * These routines are necessary for TSUNAMI/TYPHOON based platforms,
322 * which will have (at least) EV6.
325 static inline unsigned long int
326 dense_port_to_cpu_addr (unsigned long int port
)
328 return port
+ io
.base
;
332 inline_bwx_outb (unsigned char b
, unsigned long int port
)
334 unsigned long int addr
= dense_port_to_cpu_addr (port
);
339 inline_bwx_outw (unsigned short int b
, unsigned long int port
)
341 unsigned long int addr
= dense_port_to_cpu_addr (port
);
346 inline_bwx_outl (unsigned int b
, unsigned long int port
)
348 unsigned long int addr
= dense_port_to_cpu_addr (port
);
352 static inline unsigned int
353 inline_bwx_inb (unsigned long int port
)
355 unsigned long int addr
= dense_port_to_cpu_addr (port
);
358 __asm__ ("ldbu %0,%1" : "=r"(r
) : "m"(*(vucp
)addr
));
362 static inline unsigned int
363 inline_bwx_inw (unsigned long int port
)
365 unsigned long int addr
= dense_port_to_cpu_addr (port
);
368 __asm__ ("ldwu %0,%1" : "=r"(r
) : "m"(*(vusp
)addr
));
372 static inline unsigned int
373 inline_bwx_inl (unsigned long int port
)
375 unsigned long int addr
= dense_port_to_cpu_addr (port
);
380 /* macros to define routines with appropriate names and functions */
382 /* these do either SPARSE or JENSEN swizzle */
384 #define DCL_SETHAE(name, ioswiz) \
386 name##_sethae (unsigned long int addr) \
388 inline_sethae (addr, IOSWIZZLE_##ioswiz); \
391 #define DCL_OUT(name, func, type, ioswiz) \
393 name##_##func (unsigned type b, unsigned long int addr) \
395 inline_##func (b, addr, IOSWIZZLE_##ioswiz); \
398 #define DCL_IN(name, func, ioswiz) \
399 static unsigned int \
400 name##_##func (unsigned long int addr) \
402 return inline_##func (addr, IOSWIZZLE_##ioswiz); \
405 /* these do DENSE, so no swizzle is needed */
407 #define DCL_OUT_BWX(name, func, type) \
409 name##_##func (unsigned type b, unsigned long int addr) \
411 inline_bwx_##func (b, addr); \
414 #define DCL_IN_BWX(name, func) \
415 static unsigned int \
416 name##_##func (unsigned long int addr) \
418 return inline_bwx_##func (addr); \
421 /* now declare/define the necessary routines */
423 DCL_SETHAE(jensen
, JENSEN
)
424 DCL_OUT(jensen
, outb
, char, JENSEN
)
425 DCL_OUT(jensen
, outw
, short int, JENSEN
)
426 DCL_OUT(jensen
, outl
, int, JENSEN
)
427 DCL_IN(jensen
, inb
, JENSEN
)
428 DCL_IN(jensen
, inw
, JENSEN
)
429 DCL_IN(jensen
, inl
, JENSEN
)
431 DCL_SETHAE(sparse
, SPARSE
)
432 DCL_OUT(sparse
, outb
, char, SPARSE
)
433 DCL_OUT(sparse
, outw
, short int, SPARSE
)
434 DCL_OUT(sparse
, outl
, int, SPARSE
)
435 DCL_IN(sparse
, inb
, SPARSE
)
436 DCL_IN(sparse
, inw
, SPARSE
)
437 DCL_IN(sparse
, inl
, SPARSE
)
439 DCL_SETHAE(dense
, DENSE
)
440 DCL_OUT_BWX(dense
, outb
, char)
441 DCL_OUT_BWX(dense
, outw
, short int)
442 DCL_OUT_BWX(dense
, outl
, int)
443 DCL_IN_BWX(dense
, inb
)
444 DCL_IN_BWX(dense
, inw
)
445 DCL_IN_BWX(dense
, inl
)
447 /* define the "swizzle" switch */
448 static struct ioswtch ioswtch
[] = {
451 jensen_outb
, jensen_outw
, jensen_outl
,
452 jensen_inb
, jensen_inw
, jensen_inl
456 sparse_outb
, sparse_outw
, sparse_outl
,
457 sparse_inb
, sparse_inw
, sparse_inl
461 dense_outb
, dense_outw
, dense_outl
,
462 dense_inb
, dense_inw
, dense_inl
468 /* Routine to process the /proc/cpuinfo information into the fields
469 that are required for correctly determining the platform parameters. */
473 char systype
[256]; /* system type field */
474 char sysvari
[256]; /* system variation field */
475 char cpumodel
[256]; /* cpu model field */
479 process_cpuinfo(struct cpuinfo_data
*data
)
481 int got_type
, got_vari
, got_model
;
486 data
->systype
[0] = 0;
487 data
->sysvari
[0] = 0;
488 data
->cpumodel
[0] = 0;
490 /* If there's an /etc/alpha_systype link, we're intending to override
491 whatever's in /proc/cpuinfo. */
492 n
= __readlink (PATH_ALPHA_SYSTYPE
, data
->systype
, 256 - 1);
495 data
->systype
[n
] = '\0';
499 fp
= fopen (PATH_CPUINFO
, "rce");
503 got_type
= got_vari
= got_model
= 0;
507 if (fgets_unlocked (dummy
, 256, fp
) == NULL
)
510 sscanf (dummy
, "system type : %256[^\n]\n", data
->systype
) == 1)
513 sscanf (dummy
, "system variation : %256[^\n]\n", data
->sysvari
) == 1)
516 sscanf (dummy
, "cpu model : %256[^\n]\n", data
->cpumodel
) == 1)
523 fprintf(stderr
, "system type: `%s'\n", data
->systype
);
524 fprintf(stderr
, "system vari: `%s'\n", data
->sysvari
);
525 fprintf(stderr
, "cpu model: `%s'\n", data
->cpumodel
);
528 return got_type
+ got_vari
+ got_model
;
533 * Initialize I/O system.
539 int i
, olderrno
= errno
;
540 struct cpuinfo_data data
;
542 /* First try the pciconfig_iobase syscall added to 2.2.15 and 2.3.99. */
544 #ifdef __NR_pciconfig_iobase
545 addr
= __pciconfig_iobase (IOBASE_DENSE_MEM
, 0, 0);
552 /* Only Jensen doesn't have dense mem space. */
553 io
.sparse_bus_memory_base
554 = io_system
[IOSYS_JENSEN
].sparse_bus_mem_base
;
555 io
.io_base
= io_system
[IOSYS_JENSEN
].bus_io_base
;
556 io_swiz
= IOSWIZZLE_JENSEN
;
560 io
.bus_memory_base
= addr
;
562 addr
= __pciconfig_iobase (IOBASE_DENSE_IO
, 0, 0);
565 /* The X server uses _bus_base_sparse == 0 to know that
566 BWX access are supported to dense mem space. This is
567 true of every system that supports dense io space, so
568 never fill in io.sparse_bus_memory_base in this case. */
569 io_swiz
= IOSWIZZLE_DENSE
;
574 io
.sparse_bus_memory_base
575 = __pciconfig_iobase (IOBASE_SPARSE_MEM
, 0, 0);
576 io
.io_base
= __pciconfig_iobase (IOBASE_SPARSE_IO
, 0, 0);
577 io_swiz
= IOSWIZZLE_SPARSE
;
582 io
.swp
= &ioswtch
[io_swiz
];
588 /* Second, collect the contents of /etc/alpha_systype or /proc/cpuinfo. */
590 if (process_cpuinfo(&data
) == 0)
592 /* This can happen if the format of /proc/cpuinfo changes. */
594 "ioperm.init_iosys: Unable to determine system type.\n"
595 "\t(May need " PATH_ALPHA_SYSTYPE
" symlink?)\n");
596 __set_errno (ENODEV
);
600 /* Translate systype name into i/o system. */
601 for (i
= 0; i
< sizeof (platform
) / sizeof (platform
[0]); ++i
)
603 if (strcmp (platform
[i
].name
, data
.systype
) == 0)
605 iosys_t io_sys
= platform
[i
].io_sys
;
607 /* Some platforms can have either EV4 or EV5 CPUs. */
608 if (io_sys
== IOSYS_CPUDEP
)
610 /* SABLE or MIKASA or NORITAKE so far. */
611 if (strcmp (platform
[i
].name
, "Sable") == 0)
613 if (strncmp (data
.cpumodel
, "EV4", 3) == 0)
615 else if (strncmp (data
.cpumodel
, "EV5", 3) == 0)
616 io_sys
= IOSYS_GAMMA
;
620 /* This covers MIKASA/NORITAKE. */
621 if (strncmp (data
.cpumodel
, "EV4", 3) == 0)
622 io_sys
= IOSYS_APECS
;
623 else if (strncmp (data
.cpumodel
, "EV5", 3) == 0)
626 if (io_sys
== IOSYS_CPUDEP
)
628 /* This can happen if the format of /proc/cpuinfo changes.*/
629 fprintf (stderr
, "ioperm.init_iosys: Unable to determine"
631 __set_errno (ENODEV
);
635 /* Some platforms can have different core logic chipsets */
636 if (io_sys
== IOSYS_PCIDEP
)
639 if (strcmp (data
.systype
, "EB164") == 0)
641 if (strncmp (data
.sysvari
, "RX164", 5) == 0)
642 io_sys
= IOSYS_POLARIS
;
643 else if (strncmp (data
.sysvari
, "LX164", 5) == 0
644 || strncmp (data
.sysvari
, "SX164", 5) == 0)
645 io_sys
= IOSYS_PYXIS
;
649 if (io_sys
== IOSYS_PCIDEP
)
651 /* This can happen if the format of /proc/cpuinfo changes.*/
652 fprintf (stderr
, "ioperm.init_iosys: Unable to determine"
653 " core logic chipset.\n");
654 __set_errno (ENODEV
);
658 io
.bus_memory_base
= io_system
[io_sys
].bus_memory_base
;
659 io
.sparse_bus_memory_base
= io_system
[io_sys
].sparse_bus_mem_base
;
660 io
.io_base
= io_system
[io_sys
].bus_io_base
;
662 if (io_sys
== IOSYS_JENSEN
)
663 io
.swiz
= IOSWIZZLE_JENSEN
;
664 else if (io_sys
== IOSYS_TSUNAMI
665 || io_sys
== IOSYS_POLARIS
666 || io_sys
== IOSYS_PYXIS
)
667 io
.swiz
= IOSWIZZLE_DENSE
;
669 io
.swiz
= IOSWIZZLE_SPARSE
;
670 io
.swp
= &ioswtch
[io
.swiz
];
672 __set_errno (olderrno
);
677 __set_errno (ENODEV
);
678 fprintf(stderr
, "ioperm.init_iosys: Platform not recognized.\n"
679 "\t(May need " PATH_ALPHA_SYSTYPE
" symlink?)\n");
685 _ioperm (unsigned long int from
, unsigned long int num
, int turn_on
)
687 unsigned long int addr
, len
, pagesize
= __getpagesize();
690 if (!io
.swp
&& init_iosys() < 0)
693 fprintf(stderr
, "ioperm: init_iosys() failed (%m)\n");
698 /* This test isn't as silly as it may look like; consider overflows! */
699 if (from
>= MAX_PORT
|| from
+ num
> MAX_PORT
)
701 __set_errno (EINVAL
);
703 fprintf(stderr
, "ioperm: from/num out of range\n");
709 fprintf(stderr
, "ioperm: turn_on %d io.base %ld\n", turn_on
, io
.base
);
719 if (io
.swiz
!= IOSWIZZLE_DENSE
)
721 /* Synchronize with hw. */
725 fd
= __open ("/dev/mem", O_RDWR
);
729 fprintf(stderr
, "ioperm: /dev/mem open failed (%m)\n");
734 addr
= port_to_cpu_addr (0, io
.swiz
, 1);
735 len
= port_to_cpu_addr (MAX_PORT
, io
.swiz
, 1) - addr
;
737 (unsigned long int) __mmap (0, len
, PROT_NONE
, MAP_SHARED
,
741 fprintf(stderr
, "ioperm: mmap of len 0x%lx returned 0x%lx\n",
744 if ((long) io
.base
== -1)
747 prot
= PROT_READ
| PROT_WRITE
;
752 return 0; /* never was turned on... */
754 /* turnoff access to relevant pages: */
757 addr
= port_to_cpu_addr (from
, io
.swiz
, 1);
758 addr
&= ~(pagesize
- 1);
759 len
= port_to_cpu_addr (from
+ num
, io
.swiz
, 1) - addr
;
760 return __mprotect ((void *) addr
, len
, prot
);
772 case 1: case 2: case 3:
773 return _ioperm (0, MAX_PORT
, 1);
776 __set_errno (EINVAL
);
783 _sethae (unsigned long int addr
)
785 if (!io
.swp
&& init_iosys () < 0)
788 io
.swp
->sethae (addr
);
793 _outb (unsigned char b
, unsigned long int port
)
795 if (port
>= MAX_PORT
)
798 io
.swp
->outb (b
, port
);
803 _outw (unsigned short b
, unsigned long int port
)
805 if (port
>= MAX_PORT
)
808 io
.swp
->outw (b
, port
);
813 _outl (unsigned int b
, unsigned long int port
)
815 if (port
>= MAX_PORT
)
818 io
.swp
->outl (b
, port
);
823 _inb (unsigned long int port
)
825 return io
.swp
->inb (port
);
830 _inw (unsigned long int port
)
832 return io
.swp
->inw (port
);
837 _inl (unsigned long int port
)
839 return io
.swp
->inl (port
);
846 if (!io
.swp
&& init_iosys () < 0)
848 return io
.bus_memory_base
;
852 _bus_base_sparse(void)
854 if (!io
.swp
&& init_iosys () < 0)
856 return io
.sparse_bus_memory_base
;
862 if (!io
.swp
&& init_iosys () < 0)
864 if (io
.swiz
== IOSWIZZLE_JENSEN
)
866 if (io
.swiz
== IOSWIZZLE_SPARSE
)
871 weak_alias (_sethae
, sethae
);
872 weak_alias (_ioperm
, ioperm
);
873 weak_alias (_iopl
, iopl
);
874 weak_alias (_inb
, inb
);
875 weak_alias (_inw
, inw
);
876 weak_alias (_inl
, inl
);
877 weak_alias (_outb
, outb
);
878 weak_alias (_outw
, outw
);
879 weak_alias (_outl
, outl
);
880 weak_alias (_bus_base
, bus_base
);
881 weak_alias (_bus_base_sparse
, bus_base_sparse
);
882 weak_alias (_hae_shift
, hae_shift
);