00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
#if defined(__GNUC__)
00064
00065
#if defined(linux) && (defined(__alpha__) || defined(__ia64__))
00066
00067
#include <sys/io.h>
00068
00069
#undef inb
00070
#undef inw
00071
#undef inl
00072
#undef outb
00073
#undef outw
00074
#undef outl
00075
00076
static __inline__
unsigned int inb(
unsigned long int p) {
return _inb(p); };
00077
static __inline__
unsigned int inw(
unsigned long int p) {
return _inw(p); };
00078
static __inline__
unsigned int inl(
unsigned long int p) {
return _inl(p); };
00079
static __inline__
void outb(
unsigned long int p,
unsigned char v) { _outb(v,p); };
00080
static __inline__
void outw(
unsigned long int p,
unsigned short v) { _outw(v,p); };
00081
static __inline__
void outl(
unsigned long int p,
unsigned int v) { _outl(v,p); };
00082
00083
#else
00084
00085
#if defined(__sparc__)
00086
#ifndef ASI_PL
00087
#define ASI_PL 0x88
00088
#endif
00089
00090
static __inline__
void
00091 outb(port, val)
00092 unsigned
long port;
00093
char val;
00094 {
00095 __asm__ __volatile__(
"stba %0, [%1] %2" : :
"r" (val),
"r" (port),
"i" (ASI_PL));
00096 }
00097
00098
static __inline__
void
00099 outw(port, val)
00100 unsigned
long port;
00101
char val;
00102 {
00103 __asm__ __volatile__(
"stha %0, [%1] %2" : :
"r" (val),
"r" (port),
"i" (ASI_PL));
00104 }
00105
00106
static __inline__
void
00107 outl(port, val)
00108 unsigned
long port;
00109
char val;
00110 {
00111 __asm__ __volatile__(
"sta %0, [%1] %2" : :
"r" (val),
"r" (port),
"i" (ASI_PL));
00112 }
00113
00114
static __inline__
unsigned int
00115 inb(port)
00116 unsigned
long port;
00117 {
00118
unsigned char ret;
00119 __asm__ __volatile__(
"lduba [%1] %2, %0" :
"=r" (ret) :
"r" (port),
"i" (ASI_PL));
00120
return ret;
00121 }
00122
00123
static __inline__
unsigned int
00124 inw(port)
00125 unsigned
long port;
00126 {
00127
unsigned char ret;
00128 __asm__ __volatile__(
"lduha [%1] %2, %0" :
"=r" (ret) :
"r" (port),
"i" (ASI_PL));
00129
return ret;
00130 }
00131
00132
static __inline__
unsigned int
00133 inl(port)
00134 unsigned
long port;
00135 {
00136
unsigned char ret;
00137 __asm__ __volatile__(
"lda [%1] %2, %0" :
"=r" (ret) :
"r" (port),
"i" (ASI_PL));
00138
return ret;
00139 }
00140
#else
00141
#ifdef __arm32__
00142
unsigned int IOPortBase;
00143
00144
static __inline__
void
00145 outb(port, val)
00146 short port;
00147
char val;
00148 {
00149
if ((
unsigned short)port >= 0x400)
return;
00150
00151 *(
volatile unsigned char*)(((
unsigned short)(port))+IOPortBase) =
val;
00152 }
00153
00154
static __inline__
void
00155 outw(port, val)
00156 short port;
00157
short val;
00158 {
00159
if ((
unsigned short)port >= 0x400)
return;
00160
00161 *(
volatile unsigned short*)(((
unsigned short)(port))+IOPortBase) =
val;
00162 }
00163
00164
static __inline__
void
00165 outl(port, val)
00166 short port;
00167
int val;
00168 {
00169
if ((
unsigned short)port >= 0x400)
return;
00170
00171 *(
volatile unsigned long*)(((
unsigned short)(port))+IOPortBase) =
val;
00172 }
00173
00174
static __inline__
unsigned int
00175 inb(port)
00176 short port;
00177 {
00178
if ((
unsigned short)port >= 0x400)
return((
unsigned int)-1);
00179
00180
return(*(
volatile unsigned char*)(((
unsigned short)(port))+IOPortBase));
00181 }
00182
00183
static __inline__
unsigned int
00184 inw(port)
00185 short port;
00186 {
00187
if ((
unsigned short)port >= 0x400)
return((
unsigned int)-1);
00188
00189
return(*(
volatile unsigned short*)(((
unsigned short)(port))+IOPortBase));
00190 }
00191
00192
static __inline__
unsigned int
00193 inl(port)
00194 short port;
00195 {
00196
if ((
unsigned short)port >= 0x400)
return((
unsigned int)-1);
00197
00198
return(*(
volatile unsigned long*)(((
unsigned short)(port))+IOPortBase));
00199 }
00200
#else
00201
#if defined(Lynx) && defined(__powerpc__)
00202
extern unsigned char *ioBase;
00203
00204
static volatile void
00205 eieio()
00206 {
00207 __asm__ __volatile__ (
"eieio");
00208 }
00209
00210
static void
00211 outb(port, value)
00212 short port;
00213
unsigned char value;
00214 {
00215 *(uchar *)(ioBase + port) = value; eieio();
00216 }
00217
00218
static void
00219 outw(port, value)
00220 short port;
00221
unsigned short value;
00222 {
00223 *(
unsigned short *)(ioBase + port) = value; eieio();
00224 }
00225
00226
static void
00227 outl(port, value)
00228 short port;
00229
unsigned long value;
00230 {
00231 *(
unsigned long *)(ioBase + port) = value; eieio();
00232 }
00233
00234
static unsigned char
00235 inb(port)
00236 short port;
00237 {
00238
unsigned char val;
00239
00240
val = *((
unsigned char *)(ioBase + port)); eieio();
00241
return(
val);
00242 }
00243
00244
static unsigned short
00245 inw(port)
00246 short port;
00247 {
00248
unsigned short val;
00249
00250
val = *((
unsigned short *)(ioBase + port)); eieio();
00251
return(
val);
00252 }
00253
00254
static unsigned long
00255 inl(port)
00256 short port;
00257 {
00258
unsigned long val;
00259
00260
val = *((
unsigned long *)(ioBase + port)); eieio();
00261
return(
val);
00262 }
00263
00264
#else
00265
#if defined(__FreeBSD__) && defined(__alpha__)
00266
00267
#include <sys/types.h>
00268
00269
extern void outb(u_int32_t port, u_int8_t val);
00270
extern void outw(u_int32_t port, u_int16_t val);
00271
extern void outl(u_int32_t port, u_int32_t val);
00272
extern u_int8_t inb(u_int32_t port);
00273
extern u_int16_t inw(u_int32_t port);
00274
extern u_int32_t inl(u_int32_t port);
00275
00276
#else
00277
#ifdef GCCUSESGAS
00278
static __inline__
void
00279 outb(port, val)
00280 short port;
00281
char val;
00282 {
00283 __asm__ __volatile__(
"outb %0,%1" : :
"a" (val),
"d" (port));
00284 }
00285
00286
static __inline__
void
00287 outw(port, val)
00288 short port;
00289
short val;
00290 {
00291 __asm__ __volatile__(
"outw %0,%1" : :
"a" (val),
"d" (port));
00292 }
00293
00294
static __inline__
void
00295 outl(port, val)
00296 short port;
00297
unsigned int val;
00298 {
00299 __asm__ __volatile__(
"outl %0,%1" : :
"a" (val),
"d" (port));
00300 }
00301
00302
static __inline__
unsigned int
00303 inb(port)
00304 short port;
00305 {
00306
unsigned char ret;
00307 __asm__ __volatile__(
"inb %1,%0" :
00308
"=a" (ret) :
00309
"d" (port));
00310
return ret;
00311 }
00312
00313
static __inline__
unsigned int
00314 inw(port)
00315 short port;
00316 {
00317
unsigned short ret;
00318 __asm__ __volatile__(
"inw %1,%0" :
00319
"=a" (ret) :
00320
"d" (port));
00321
return ret;
00322 }
00323
00324
static __inline__
unsigned int
00325 inl(port)
00326 short port;
00327 {
00328
unsigned int ret;
00329 __asm__ __volatile__(
"inl %1,%0" :
00330
"=a" (ret) :
00331
"d" (port));
00332
return ret;
00333 }
00334
00335
#else
00336
00337
static __inline__
void
00338 outb(port, val)
00339 short port;
00340
char val;
00341 {
00342 __asm__ __volatile__(
"out%B0 (%1)" : :
"a" (val),
"d" (port));
00343 }
00344
00345
static __inline__
void
00346 outw(port, val)
00347 short port;
00348
short val;
00349 {
00350 __asm__ __volatile__(
"out%W0 (%1)" : :
"a" (val),
"d" (port));
00351 }
00352
00353
static __inline__
void
00354 outl(port, val)
00355 short port;
00356
unsigned int val;
00357 {
00358 __asm__ __volatile__(
"out%L0 (%1)" : :
"a" (val),
"d" (port));
00359 }
00360
00361
static __inline__
unsigned int
00362 inb(port)
00363 short port;
00364 {
00365
unsigned int ret;
00366 __asm__ __volatile__(
"in%B0 (%1)" :
00367
"=a" (ret) :
00368
"d" (port));
00369
return ret;
00370 }
00371
00372
static __inline__
unsigned int
00373 inw(port)
00374 short port;
00375 {
00376
unsigned int ret;
00377 __asm__ __volatile__(
"in%W0 (%1)" :
00378
"=a" (ret) :
00379
"d" (port));
00380
return ret;
00381 }
00382
00383
static __inline__
unsigned int
00384 inl(port)
00385 short port;
00386 {
00387
unsigned int ret;
00388 __asm__ __volatile__(
"in%L0 (%1)" :
00389
"=a" (ret) :
00390
"d" (port));
00391
return ret;
00392 }
00393
00394
#endif
00395
#endif
00396
#endif
00397
#endif
00398
#endif
00399
#endif
00400
00401
#if defined(linux) || defined(__arm32__) || (defined(Lynx) && defined(__powerpc__))
00402
00403
#define intr_disable()
00404
#define intr_enable()
00405
00406
#else
00407
00408
static __inline__
void
00409
intr_disable()
00410 {
00411 __asm__ __volatile__(
"cli");
00412 }
00413
00414
static __inline__
void
00415
intr_enable()
00416 {
00417 __asm__ __volatile__(
"sti");
00418 }
00419
00420
#endif
00421
00422
#else
00423
00424
#if defined(_MINIX) && defined(_ACK)
00425
00426
00427
00428
00429 u8_t inb(U16_t);
00430
void outb(U16_t, U8_t);
00431 u16_t inw(U16_t);
00432
void outw(U16_t, U16_t);
00433 u32_t inl(U16_t);
00434
void outl(U16_t, U32_t);
00435
00436
#else
00437
00438
# if defined(__STDC__) && (__STDC__ == 1)
00439
# ifndef NCR
00440
# define asm __asm
00441
# endif
00442
# endif
00443
# ifdef SVR4
00444
# include <sys/types.h>
00445
# ifndef __USLC__
00446
# define __USLC__
00447
# endif
00448
# endif
00449
#ifndef SCO325
00450
# include <sys/inline.h>
00451
#else
00452
# include "../common/scoasm.h"
00453
#endif
00454 #define intr_disable() asm("cli")
00455 #define intr_enable() asm("sti")
00456
00457
#endif
00458
#endif