1 /* Copyright (C) 1992, 1996-1999, 2000 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 /* I/O access is restricted to ISA port space (ports 0..65535).
21 Modern devices hopefully are sane enough not to put any performance
22 critical registers in i/o space.
24 On the first call to ioperm, the entire (E)ISA port space is mapped
25 into the virtual address space at address io.base. mprotect calls
26 are then used to enable/disable access to ports. Per page, there
27 are PAGE_SIZE>>IO_SHIFT I/O ports (e.g., 256 ports on a Low Cost Alpha
28 based system using 8KB pages).
30 Keep in mind that this code should be able to run in a 32bit address
31 space. It is therefore unreasonable to expect mmap'ing the entire
32 sparse address space would work (e.g., the Low Cost Alpha chip has an
33 I/O address space that's 512MB large!). */
35 /* Make sure the ldbu/stb asms below are not expaneded to macros. */
48 #include <sys/types.h>
53 #include <sys/syscall.h>
55 #define PATH_ALPHA_SYSTYPE "/etc/alpha_systype"
56 #define PATH_CPUINFO "/proc/cpuinfo"
58 #define MAX_PORT 0x10000
59 #define vip volatile int *
60 #define vuip volatile unsigned int *
61 #define vusp volatile unsigned short *
62 #define vucp volatile unsigned char *
64 #define JENSEN_IO_BASE (0x300000000UL)
65 #define JENSEN_SPARSE_MEM (0x200000000UL)
67 /* With respect to the I/O architecture, APECS and LCA are identical,
68 so the following defines apply to LCA as well. */
69 #define APECS_IO_BASE (0x1c0000000UL)
70 #define APECS_SPARSE_MEM (0x200000000UL)
71 #define APECS_DENSE_MEM (0x300000000UL)
73 /* The same holds for CIA and PYXIS, except for PYXIS we prefer BWX. */
74 #define CIA_IO_BASE (0x8580000000UL)
75 #define CIA_SPARSE_MEM (0x8000000000UL)
76 #define CIA_DENSE_MEM (0x8600000000UL)
78 #define PYXIS_IO_BASE (0x8900000000UL)
79 #define PYXIS_DENSE_MEM (0x8800000000UL)
81 /* SABLE is EV4, GAMMA is EV5 */
82 #define T2_IO_BASE (0x3a0000000UL)
83 #define T2_SPARSE_MEM (0x200000000UL)
84 #define T2_DENSE_MEM (0x3c0000000UL)
86 #define GAMMA_IO_BASE (0x83a0000000UL)
87 #define GAMMA_SPARSE_MEM (0x8200000000UL)
88 #define GAMMA_DENSE_MEM (0x83c0000000UL)
90 /* NOTE: these are hardwired to PCI bus 0 addresses!!! */
91 #define MCPCIA_IO_BASE (0xf980000000UL)
92 #define MCPCIA_SPARSE_MEM (0xf800000000UL)
93 #define MCPCIA_DENSE_MEM (0xf900000000UL)
95 /* Tsunami and Irongate use the same offsets, at least for hose 0. */
96 #define TSUNAMI_IO_BASE (0x801fc000000UL)
97 #define TSUNAMI_DENSE_MEM (0x80000000000UL)
99 /* Polaris has SPARSE space, but we prefer to use only DENSE
100 because of some idiosyncracies in actually using SPARSE. */
101 #define POLARIS_IO_BASE (0xf9fc000000UL)
102 #define POLARIS_DENSE_MEM (0xf900000000UL)
105 IOSYS_UNKNOWN
, IOSYS_JENSEN
, IOSYS_APECS
, IOSYS_CIA
, IOSYS_PYXIS
, IOSYS_T2
,
106 IOSYS_TSUNAMI
, IOSYS_MCPCIA
, IOSYS_GAMMA
, IOSYS_POLARIS
,
107 IOSYS_CPUDEP
, IOSYS_PCIDEP
111 IOSWIZZLE_JENSEN
, IOSWIZZLE_SPARSE
, IOSWIZZLE_DENSE
114 static struct io_system
{
115 unsigned long int bus_memory_base
;
116 unsigned long int sparse_bus_mem_base
;
117 unsigned long int bus_io_base
;
118 } io_system
[] = { /* NOTE! must match iosys_t enumeration */
119 /* UNKNOWN */ {0, 0, 0},
120 /* JENSEN */ {0, JENSEN_SPARSE_MEM
, JENSEN_IO_BASE
},
121 /* APECS */ {APECS_DENSE_MEM
, APECS_SPARSE_MEM
, APECS_IO_BASE
},
122 /* CIA */ {CIA_DENSE_MEM
, CIA_SPARSE_MEM
, CIA_IO_BASE
},
123 /* PYXIS */ {PYXIS_DENSE_MEM
, 0, PYXIS_IO_BASE
},
124 /* T2 */ {T2_DENSE_MEM
, T2_SPARSE_MEM
, T2_IO_BASE
},
125 /* TSUNAMI */ {TSUNAMI_DENSE_MEM
, 0, TSUNAMI_IO_BASE
},
126 /* MCPCIA */ {MCPCIA_DENSE_MEM
, MCPCIA_SPARSE_MEM
, MCPCIA_IO_BASE
},
127 /* GAMMA */ {GAMMA_DENSE_MEM
, GAMMA_SPARSE_MEM
, GAMMA_IO_BASE
},
128 /* POLARIS */ {POLARIS_DENSE_MEM
, 0, POLARIS_IO_BASE
},
129 /* CPUDEP */ {0, 0, 0}, /* for platforms dependent on CPU type */
130 /* PCIDEP */ {0, 0, 0}, /* for platforms dependent on core logic */
133 static struct platform
{
137 {"Alcor", IOSYS_CIA
},
138 {"Avanti", IOSYS_APECS
},
139 {"Cabriolet", IOSYS_APECS
},
140 {"EB164", IOSYS_PCIDEP
},
141 {"EB64+", IOSYS_APECS
},
142 {"EB66", IOSYS_APECS
},
143 {"EB66P", IOSYS_APECS
},
144 {"Jensen", IOSYS_JENSEN
},
145 {"Miata", IOSYS_PYXIS
},
146 {"Mikasa", IOSYS_CPUDEP
},
147 {"Nautilus", IOSYS_TSUNAMI
},
148 {"Noname", IOSYS_APECS
},
149 {"Noritake", IOSYS_CPUDEP
},
150 {"Rawhide", IOSYS_MCPCIA
},
151 {"Ruffian", IOSYS_PYXIS
},
152 {"Sable", IOSYS_CPUDEP
},
153 {"Takara", IOSYS_CIA
},
154 {"Tsunami", IOSYS_TSUNAMI
},
159 void (*sethae
)(unsigned long int addr
);
160 void (*outb
)(unsigned char b
, unsigned long int port
);
161 void (*outw
)(unsigned short b
, unsigned long int port
);
162 void (*outl
)(unsigned int b
, unsigned long int port
);
163 unsigned int (*inb
)(unsigned long int port
);
164 unsigned int (*inw
)(unsigned long int port
);
165 unsigned int (*inl
)(unsigned long int port
);
169 unsigned long int hae_cache
;
170 unsigned long int base
;
171 struct ioswtch
* swp
;
172 unsigned long int bus_memory_base
;
173 unsigned long int sparse_bus_memory_base
;
174 unsigned long int io_base
;
179 stb_mb(unsigned char val
, unsigned long addr
)
181 __asm__("stb %1,%0; mb" : "=m"(*(vucp
)addr
) : "r"(val
));
185 stw_mb(unsigned short val
, unsigned long addr
)
187 __asm__("stw %1,%0; mb" : "=m"(*(vusp
)addr
) : "r"(val
));
191 stl_mb(unsigned int val
, unsigned long addr
)
193 __asm__("stl %1,%0; mb" : "=m"(*(vip
)addr
) : "r"(val
));
196 /* No need to examine error -- sethae never fails. */
198 __sethae(unsigned long value
)
200 register unsigned long r16
__asm__("$16") = value
;
201 register unsigned long r0
__asm__("$0") = __NR_sethae
;
202 __asm__
__volatile__ ("callsys"
205 : inline_syscall_clobbers
, "$19");
208 extern long __pciconfig_iobase(enum __pciconfig_iobase_which __which
,
209 unsigned long int __bus
,
210 unsigned long int __dfn
);
212 static inline unsigned long int
213 port_to_cpu_addr (unsigned long int port
, ioswizzle_t ioswiz
, int size
)
215 if (ioswiz
== IOSWIZZLE_SPARSE
)
216 return io
.base
+ (port
<< 5) + ((size
- 1) << 3);
217 else if (ioswiz
== IOSWIZZLE_DENSE
)
218 return port
+ io
.base
;
220 return io
.base
+ (port
<< 7) + ((size
- 1) << 5);
224 inline_sethae (unsigned long int addr
, ioswizzle_t ioswiz
)
226 if (ioswiz
== IOSWIZZLE_SPARSE
)
228 unsigned long int msb
;
230 /* no need to set hae if msb is 0: */
231 msb
= addr
& 0xf8000000;
232 if (msb
&& msb
!= io
.hae_cache
)
238 else if (ioswiz
== IOSWIZZLE_JENSEN
)
240 /* HAE on the Jensen is bits 31:25 shifted right. */
242 if (addr
!= io
.hae_cache
)
251 inline_outb (unsigned char b
, unsigned long int port
, ioswizzle_t ioswiz
)
254 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 1);
256 asm ("insbl %2,%1,%0" : "=r" (w
) : "ri" (port
& 0x3), "r" (b
));
262 inline_outw (unsigned short int b
, unsigned long int port
, ioswizzle_t ioswiz
)
265 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 2);
267 asm ("inswl %2,%1,%0" : "=r" (w
) : "ri" (port
& 0x3), "r" (b
));
273 inline_outl (unsigned int b
, unsigned long int port
, ioswizzle_t ioswiz
)
275 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 4);
281 static inline unsigned int
282 inline_inb (unsigned long int port
, ioswizzle_t ioswiz
)
284 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 1);
287 result
= *(vip
) addr
;
288 result
>>= (port
& 3) * 8;
289 return 0xffUL
& result
;
293 static inline unsigned int
294 inline_inw (unsigned long int port
, ioswizzle_t ioswiz
)
296 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 2);
299 result
= *(vip
) addr
;
300 result
>>= (port
& 3) * 8;
301 return 0xffffUL
& result
;
305 static inline unsigned int
306 inline_inl (unsigned long int port
, ioswizzle_t ioswiz
)
308 unsigned long int addr
= port_to_cpu_addr (port
, ioswiz
, 4);
314 * Now define the inline functions for CPUs supporting byte/word insns,
315 * and whose core logic supports I/O space accesses utilizing them.
317 * These routines could be used by MIATA, for example, because it has
318 * and EV56 plus PYXIS, but it currently uses SPARSE anyway. This is
319 * also true of RX164 which used POLARIS, but we will choose to use
320 * these routines in that case instead of SPARSE.
322 * These routines are necessary for TSUNAMI/TYPHOON based platforms,
323 * which will have (at least) EV6.
326 static inline unsigned long int
327 dense_port_to_cpu_addr (unsigned long int port
)
329 return port
+ io
.base
;
333 inline_bwx_outb (unsigned char b
, unsigned long int port
)
335 unsigned long int addr
= dense_port_to_cpu_addr (port
);
340 inline_bwx_outw (unsigned short int b
, unsigned long int port
)
342 unsigned long int addr
= dense_port_to_cpu_addr (port
);
347 inline_bwx_outl (unsigned int b
, unsigned long int port
)
349 unsigned long int addr
= dense_port_to_cpu_addr (port
);
353 static inline unsigned int
354 inline_bwx_inb (unsigned long int port
)
356 unsigned long int addr
= dense_port_to_cpu_addr (port
);
359 __asm__ ("ldbu %0,%1" : "=r"(r
) : "m"(*(vucp
)addr
));
363 static inline unsigned int
364 inline_bwx_inw (unsigned long int port
)
366 unsigned long int addr
= dense_port_to_cpu_addr (port
);
369 __asm__ ("ldwu %0,%1" : "=r"(r
) : "m"(*(vusp
)addr
));
373 static inline unsigned int
374 inline_bwx_inl (unsigned long int port
)
376 unsigned long int addr
= dense_port_to_cpu_addr (port
);
381 /* macros to define routines with appropriate names and functions */
383 /* these do either SPARSE or JENSEN swizzle */
385 #define DCL_SETHAE(name, ioswiz) \
387 name##_sethae (unsigned long int addr) \
389 inline_sethae (addr, IOSWIZZLE_##ioswiz); \
392 #define DCL_OUT(name, func, type, ioswiz) \
394 name##_##func (unsigned type b, unsigned long int addr) \
396 inline_##func (b, addr, IOSWIZZLE_##ioswiz); \
399 #define DCL_IN(name, func, ioswiz) \
400 static unsigned int \
401 name##_##func (unsigned long int addr) \
403 return inline_##func (addr, IOSWIZZLE_##ioswiz); \
406 /* these do DENSE, so no swizzle is needed */
408 #define DCL_OUT_BWX(name, func, type) \
410 name##_##func (unsigned type b, unsigned long int addr) \
412 inline_bwx_##func (b, addr); \
415 #define DCL_IN_BWX(name, func) \
416 static unsigned int \
417 name##_##func (unsigned long int addr) \
419 return inline_bwx_##func (addr); \
422 /* now declare/define the necessary routines */
424 DCL_SETHAE(jensen
, JENSEN
)
425 DCL_OUT(jensen
, outb
, char, JENSEN
)
426 DCL_OUT(jensen
, outw
, short int, JENSEN
)
427 DCL_OUT(jensen
, outl
, int, JENSEN
)
428 DCL_IN(jensen
, inb
, JENSEN
)
429 DCL_IN(jensen
, inw
, JENSEN
)
430 DCL_IN(jensen
, inl
, JENSEN
)
432 DCL_SETHAE(sparse
, SPARSE
)
433 DCL_OUT(sparse
, outb
, char, SPARSE
)
434 DCL_OUT(sparse
, outw
, short int, SPARSE
)
435 DCL_OUT(sparse
, outl
, int, SPARSE
)
436 DCL_IN(sparse
, inb
, SPARSE
)
437 DCL_IN(sparse
, inw
, SPARSE
)
438 DCL_IN(sparse
, inl
, SPARSE
)
440 DCL_SETHAE(dense
, DENSE
)
441 DCL_OUT_BWX(dense
, outb
, char)
442 DCL_OUT_BWX(dense
, outw
, short int)
443 DCL_OUT_BWX(dense
, outl
, int)
444 DCL_IN_BWX(dense
, inb
)
445 DCL_IN_BWX(dense
, inw
)
446 DCL_IN_BWX(dense
, inl
)
448 /* define the "swizzle" switch */
449 static struct ioswtch ioswtch
[] = {
452 jensen_outb
, jensen_outw
, jensen_outl
,
453 jensen_inb
, jensen_inw
, jensen_inl
457 sparse_outb
, sparse_outw
, sparse_outl
,
458 sparse_inb
, sparse_inw
, sparse_inl
462 dense_outb
, dense_outw
, dense_outl
,
463 dense_inb
, dense_inw
, dense_inl
469 /* Routine to process the /proc/cpuinfo information into the fields
470 that are required for correctly determining the platform parameters. */
474 char systype
[256]; /* system type field */
475 char sysvari
[256]; /* system variation field */
476 char cpumodel
[256]; /* cpu model field */
480 process_cpuinfo(struct cpuinfo_data
*data
)
482 int got_type
, got_vari
, got_model
;
487 data
->systype
[0] = 0;
488 data
->sysvari
[0] = 0;
489 data
->cpumodel
[0] = 0;
491 /* If there's an /etc/alpha_systype link, we're intending to override
492 whatever's in /proc/cpuinfo. */
493 n
= __readlink (PATH_ALPHA_SYSTYPE
, data
->systype
, 256 - 1);
496 data
->systype
[n
] = '\0';
500 fp
= fopen (PATH_CPUINFO
, "r");
504 got_type
= got_vari
= got_model
= 0;
508 if (fgets (dummy
, 256, fp
) == NULL
)
511 sscanf (dummy
, "system type : %256[^\n]\n", data
->systype
) == 1)
514 sscanf (dummy
, "system variation : %256[^\n]\n", data
->sysvari
) == 1)
517 sscanf (dummy
, "cpu model : %256[^\n]\n", data
->cpumodel
) == 1)
524 fprintf(stderr
, "system type: `%s'\n", data
->systype
);
525 fprintf(stderr
, "system vari: `%s'\n", data
->sysvari
);
526 fprintf(stderr
, "cpu model: `%s'\n", data
->cpumodel
);
529 return got_type
+ got_vari
+ got_model
;
534 * Initialize I/O system.
540 int i
, olderrno
= errno
;
541 struct cpuinfo_data data
;
543 /* First try the pciconfig_iobase syscall added to 2.2.15 and 2.3.99. */
545 #ifdef __NR_pciconfig_iobase
546 addr
= __pciconfig_iobase (IOBASE_DENSE_MEM
, 0, 0);
553 /* Only Jensen doesn't have dense mem space. */
554 io
.sparse_bus_memory_base
555 = io_system
[IOSYS_JENSEN
].sparse_bus_mem_base
;
556 io
.io_base
= io_system
[IOSYS_JENSEN
].bus_io_base
;
557 io_swiz
= IOSWIZZLE_JENSEN
;
561 io
.bus_memory_base
= addr
;
563 addr
= __pciconfig_iobase (IOBASE_DENSE_IO
, 0, 0);
566 /* The X server uses _bus_base_sparse == 0 to know that
567 BWX access are supported to dense mem space. This is
568 true of every system that supports dense io space, so
569 never fill in io.sparse_bus_memory_base in this case. */
570 io_swiz
= IOSWIZZLE_DENSE
;
575 io
.sparse_bus_memory_base
576 = __pciconfig_iobase (IOBASE_SPARSE_MEM
, 0, 0);
577 io
.io_base
= __pciconfig_iobase (IOBASE_SPARSE_IO
, 0, 0);
578 io_swiz
= IOSWIZZLE_SPARSE
;
583 io
.swp
= &ioswtch
[io_swiz
];
589 /* Second, collect the contents of /etc/alpha_systype or /proc/cpuinfo. */
591 if (process_cpuinfo(&data
) == 0)
593 /* This can happen if the format of /proc/cpuinfo changes. */
595 "ioperm.init_iosys: Unable to determine system type.\n"
596 "\t(May need " PATH_ALPHA_SYSTYPE
" symlink?)\n");
597 __set_errno (ENODEV
);
601 /* Translate systype name into i/o system. */
602 for (i
= 0; i
< sizeof (platform
) / sizeof (platform
[0]); ++i
)
604 if (strcmp (platform
[i
].name
, data
.systype
) == 0)
606 iosys_t io_sys
= platform
[i
].io_sys
;
608 /* Some platforms can have either EV4 or EV5 CPUs. */
609 if (io_sys
== IOSYS_CPUDEP
)
611 /* SABLE or MIKASA or NORITAKE so far. */
612 if (strcmp (platform
[i
].name
, "Sable") == 0)
614 if (strncmp (data
.cpumodel
, "EV4", 3) == 0)
616 else if (strncmp (data
.cpumodel
, "EV5", 3) == 0)
617 io_sys
= IOSYS_GAMMA
;
621 /* This covers MIKASA/NORITAKE. */
622 if (strncmp (data
.cpumodel
, "EV4", 3) == 0)
623 io_sys
= IOSYS_APECS
;
624 else if (strncmp (data
.cpumodel
, "EV5", 3) == 0)
627 if (io_sys
== IOSYS_CPUDEP
)
629 /* This can happen if the format of /proc/cpuinfo changes.*/
630 fprintf (stderr
, "ioperm.init_iosys: Unable to determine"
632 __set_errno (ENODEV
);
636 /* Some platforms can have different core logic chipsets */
637 if (io_sys
== IOSYS_PCIDEP
)
640 if (strcmp (data
.systype
, "EB164") == 0)
642 if (strncmp (data
.sysvari
, "RX164", 5) == 0)
643 io_sys
= IOSYS_POLARIS
;
644 else if (strncmp (data
.sysvari
, "LX164", 5) == 0
645 || strncmp (data
.sysvari
, "SX164", 5) == 0)
646 io_sys
= IOSYS_PYXIS
;
650 if (io_sys
== IOSYS_PCIDEP
)
652 /* This can happen if the format of /proc/cpuinfo changes.*/
653 fprintf (stderr
, "ioperm.init_iosys: Unable to determine"
654 " core logic chipset.\n");
655 __set_errno (ENODEV
);
659 io
.bus_memory_base
= io_system
[io_sys
].bus_memory_base
;
660 io
.sparse_bus_memory_base
= io_system
[io_sys
].sparse_bus_mem_base
;
661 io
.io_base
= io_system
[io_sys
].bus_io_base
;
663 if (io_sys
== IOSYS_JENSEN
)
664 io
.swiz
= IOSWIZZLE_JENSEN
;
665 else if (io_sys
== IOSYS_TSUNAMI
666 || io_sys
== IOSYS_POLARIS
667 || io_sys
== IOSYS_PYXIS
)
668 io
.swiz
= IOSWIZZLE_DENSE
;
670 io
.swiz
= IOSWIZZLE_SPARSE
;
671 io
.swp
= &ioswtch
[io
.swiz
];
673 __set_errno (olderrno
);
678 __set_errno (ENODEV
);
679 fprintf(stderr
, "ioperm.init_iosys: Platform not recognized.\n"
680 "\t(May need " PATH_ALPHA_SYSTYPE
" symlink?)\n");
686 _ioperm (unsigned long int from
, unsigned long int num
, int turn_on
)
688 unsigned long int addr
, len
, pagesize
= __getpagesize();
691 if (!io
.swp
&& init_iosys() < 0)
694 fprintf(stderr
, "ioperm: init_iosys() failed (%m)\n");
699 /* This test isn't as silly as it may look like; consider overflows! */
700 if (from
>= MAX_PORT
|| from
+ num
> MAX_PORT
)
702 __set_errno (EINVAL
);
704 fprintf(stderr
, "ioperm: from/num out of range\n");
710 fprintf(stderr
, "ioperm: turn_on %d io.base %ld\n", turn_on
, io
.base
);
720 if (io
.swiz
!= IOSWIZZLE_DENSE
)
722 /* Synchronize with hw. */
726 fd
= __open ("/dev/mem", O_RDWR
);
730 fprintf(stderr
, "ioperm: /dev/mem open failed (%m)\n");
735 addr
= port_to_cpu_addr (0, io
.swiz
, 1);
736 len
= port_to_cpu_addr (MAX_PORT
, io
.swiz
, 1) - addr
;
738 (unsigned long int) __mmap (0, len
, PROT_NONE
, MAP_SHARED
,
742 fprintf(stderr
, "ioperm: mmap of len 0x%lx returned 0x%lx\n",
745 if ((long) io
.base
== -1)
748 prot
= PROT_READ
| PROT_WRITE
;
753 return 0; /* never was turned on... */
755 /* turnoff access to relevant pages: */
758 addr
= port_to_cpu_addr (from
, io
.swiz
, 1);
759 addr
&= ~(pagesize
- 1);
760 len
= port_to_cpu_addr (from
+ num
, io
.swiz
, 1) - addr
;
761 return __mprotect ((void *) addr
, len
, prot
);
773 case 1: case 2: case 3:
774 return _ioperm (0, MAX_PORT
, 1);
777 __set_errno (EINVAL
);
784 _sethae (unsigned long int addr
)
786 if (!io
.swp
&& init_iosys () < 0)
789 io
.swp
->sethae (addr
);
794 _outb (unsigned char b
, unsigned long int port
)
796 if (port
>= MAX_PORT
)
799 io
.swp
->outb (b
, port
);
804 _outw (unsigned short b
, unsigned long int port
)
806 if (port
>= MAX_PORT
)
809 io
.swp
->outw (b
, port
);
814 _outl (unsigned int b
, unsigned long int port
)
816 if (port
>= MAX_PORT
)
819 io
.swp
->outl (b
, port
);
824 _inb (unsigned long int port
)
826 return io
.swp
->inb (port
);
831 _inw (unsigned long int port
)
833 return io
.swp
->inw (port
);
838 _inl (unsigned long int port
)
840 return io
.swp
->inl (port
);
847 if (!io
.swp
&& init_iosys () < 0)
849 return io
.bus_memory_base
;
853 _bus_base_sparse(void)
855 if (!io
.swp
&& init_iosys () < 0)
857 return io
.sparse_bus_memory_base
;
863 if (!io
.swp
&& init_iosys () < 0)
865 if (io
.swiz
== IOSWIZZLE_JENSEN
)
867 if (io
.swiz
== IOSWIZZLE_SPARSE
)
872 weak_alias (_sethae
, sethae
);
873 weak_alias (_ioperm
, ioperm
);
874 weak_alias (_iopl
, iopl
);
875 weak_alias (_inb
, inb
);
876 weak_alias (_inw
, inw
);
877 weak_alias (_inl
, inl
);
878 weak_alias (_outb
, outb
);
879 weak_alias (_outw
, outw
);
880 weak_alias (_outl
, outl
);
881 weak_alias (_bus_base
, bus_base
);
882 weak_alias (_bus_base_sparse
, bus_base_sparse
);
883 weak_alias (_hae_shift
, hae_shift
);