1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
/* linux_lowio.c */
/* -O optimization flag is needed */
/* % gcc -c -Di386 -DLinux -DGCC -fpic -O linux_lowio.c -I/usr/local/eus/include
/* % ld -shared -o linux_lowio.so linux_lowio.o
*/
#include "eus.h"
#include <asm/io.h>
pointer IOPERM(context *ctx, int n, pointer argv[])
{ int val, stat;
val= intval(argv[0]);
stat= ioperm(0, 0x3ff, val);
if (stat<0) {
error("IOPERM failed because of insufficient priviledge");}
return(T); }
pointer OUTB(context *ctx, int n, pointer argv[])
{ int port, val;
port=intval(argv[0]);
val=intval(argv[1]);
outb(val, port);
return(argv[1]);
}
pointer INB(context *ctx, int n, pointer argv[])
{ int port, val;
port=intval(argv[0]);
val=inb(port);
return(makeint(val));
}
pointer linux_lowio(context *ctx, int n, pointer argv[], pointer env)
{ pointer p=Spevalof(PACKAGE);
pointer mod;
mod = argv[0];
/* Spevalof(PACKAGE)=unixpkg; */
printf("ioperm, outb, inb\n");
defun(ctx,"IOPERM", mod, IOPERM,NULL);
defun(ctx,"OUTB", mod, OUTB,NULL);
defun(ctx,"INB", mod, INB,NULL);
printf("linux low level IO functions defined.\n");
return(NIL);
}
|