Return to BSD News archive
Newsgroups: comp.unix.bsd Path: sserve!manuel.anu.edu.au!munnari.oz.au!hp9000.csc.cuhk.hk!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!tfs.com!tfs.com!julian From: julian@tfs.com (Julian Elischer) Subject: pio.h (needed for aha1742 driver) Message-ID: <1992Oct16.001132.23742@tfs.com> Organization: TRW Financial Systems Date: Fri, 16 Oct 1992 00:11:32 GMT Lines: 264 These files allow gcc code to directly impliment fast inb/outb type instructions using gcc's inline assembler stuff. They make any driver written in C instantly faster if there is any i/o to devices. There are also calls to do fast block copies etc. I should have posted pio.h with the scsi stuff (it's needed for the 1740 driver and some of the timing loops sort of assume that it's used) julian # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # i386/include/pio.h # i386/include/block.h # echo x - i386/include/pio.h sed 's/^X//' >i386/include/pio.h << 'END-of-i386/include/pio.h' X/* X * Mach Operating System X * Copyright (c) 1991,1990 Carnegie Mellon University X * All Rights Reserved. X * X * Permission to use, copy, modify and distribute this software and its X * documentation is hereby granted, provided that both the copyright X * notice and this permission notice appear in all copies of the X * software, derivative works or modified versions, and any portions X * thereof, and that both notices appear in supporting documentation. X * X * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" X * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR X * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. X * X * Carnegie Mellon requests users of this software to return to X * X * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU X * School of Computer Science X * Carnegie Mellon University X * Pittsburgh PA 15213-3890 X * X * any improvements or extensions that they make and grant Carnegie Mellon X * the rights to redistribute these changes. X */ X/* X * HISTORY X * $Log: pio.h,v $ X * Revision 2.5 91/05/14 16:14:20 mrt X * Correcting copyright X * X * Revision 2.4 91/02/05 17:13:56 mrt X * Changed to new Mach copyright X * [91/02/01 17:37:08 mrt] X * X * Revision 2.3 90/12/20 16:36:37 jeffreyh X * changes for __STDC__ X * [90/12/07 jeffreyh] X * X * Revision 2.2 90/11/26 14:48:41 rvb X * Pulled from 2.5 X * [90/11/22 10:09:38 rvb] X * X * [90/08/14 mg32] X * X * Now we know how types are factor in. X * Cleaned up a bunch: eliminated ({ for output and flushed unused X * output variables. X * [90/08/14 rvb] X * X * This is how its done in gcc: X * Created. X * [90/03/26 rvb] X * X */ X X#ifndef __GNUC__ X /* You don't stand a chance. This file is gcc only. */ X#endif __GNUC__ X X#define inl(y) \ X({ unsigned long _tmp__; \ X asm volatile("inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ X _tmp__; }) X X#define inw(y) \ X({ unsigned short _tmp__; \ X asm volatile(".byte 0x66; inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ X _tmp__; }) X X#define inb(y) \ X({ unsigned char _tmp__; \ X asm volatile("inb %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ X _tmp__; }) X X X#define outl(x, y) \ X{ asm volatile("outl %0, %1" : : "a" (y) , "d" ((unsigned short)(x))); } X X X#define outw(x, y) \ X{asm volatile(".byte 0x66; outl %0, %1" : : "a" ((unsigned short)(y)) , "d" ((unsigned short)(x))); } X X X#define outb(x, y) \ X{ asm volatile("outb %0, %1" : : "a" ((unsigned char)(y)) , "d" ((unsigned short)(x))); } END-of-i386/include/pio.h echo x - i386/include/block.h sed 's/^X//' >i386/include/block.h << 'END-of-i386/include/block.h' X#ifndef _block_h X#define _block_h 1 X X X /* X * The various stos? routines fill memory with a pattern X * This is ideal for zero filling pages. X * X * The arguments are: X * BASE address in memory X * VALUE to fill memory with X * COUNT of times to load value X * X $Log: block.h,v $ X */ X X#define stosb(base,value,count) \ X { asm volatile( "cld;movl %1,%%edi; rep; stosb ;"\ X : /* No Output */\ X : "A" ((unsigned char) (value)), /* value comes from anywhere */\ X "g>" ((char*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "cx", "dx" ); } X X#define stosw(base,value,count) \ X { asm volatile( "cld;movl %1,%%edi; rep; stosw ;"\ X : /* No Output */\ X : "a" ((unsigned short) (value)), /* value comes from anywhere */\ X "g>" ((short*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "cx", "dx" ); } X X#define stosl(base,value,count) \ X { asm volatile( "cld;movl %1,%%edi; rep; stosl ;"\ X : /* No Output */\ X : "a" ((unsigned int) (value)), /* value comes from anywhere */\ X "g>" ((int*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "cx", "dx" ); } X X X/* X * X * The various ins? routines input a stream of data. X * X * arguments X * BASE address in memory to load the data to X * PORT the port to get the data from X * COUNT the number of 'units' of data to get X * X */ X X#define insb(base,port,count) \ X { asm volatile( "cld;movl %1,%%edi; rep; insb ;"\ X : /* No Output */\ X : "d" ((unsigned short) (port)), /* port comes from anywhere */\ X "g>" ((char*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "cx", "dx" ); } X X#define insw(base,port,count) \ X { asm volatile( "cld;movl %1,%%edi; rep; insw ;"\ X : /* No Output */\ X : "d" ((unsigned short) (port)), /* port comes from anywhere */\ X "g>" ((short*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "cx", "dx" ); } X X#define insl(base,port,count) \ X { asm volatile( "cld;movl %1,%%edi; rep; insw ;"\ X : /* No Output */\ X : "d" ((unsigned short) (port)), /* port comes from anywhere */\ X "g>" ((int*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "cx", "dx" ); } X X/* X * X * The various out? routines output a stream of data to a port X * X * arguments X * BASE address in memory to get the data from X * PORT the port to send the data to X * COUNT the number of 'units' of data to send X * X */ X X#define outsb(base,port,count) \ X { asm volatile( "cld;movl %1,%%esi; rep; outsb ;"\ X : /* No Output */\ X : "d" ((unsigned short) (port)), /* port comes from anywhere */\ X "g>" ((char*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "si", "ax", "dx", "cx", "dx" ); } X X#define outsw(base,port,count) \ X { asm volatile( "cld;movl %1,%%esi; rep; outsw ;"\ X : /* No Output */\ X : "d" ((unsigned short) (port)), /* port comes from anywhere */\ X "g>" ((short*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "si", "ax", "dx", "cx", "dx" ); } X X#define outsl(base,port,count) \ X { asm volatile( "cld;movl %1,%%esi; rep; outsl ;"\ X : /* No Output */\ X : "d" ((unsigned short) (port)), /* port comes from anywhere */\ X "g>" ((int*) (base)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "si", "ax", "dx", "cx", "dx" ); } X X/* X * The movs? routines move blocks of data from one location to another X * X * FROM address to move data from X * TO address to move data to X * COUNT number of 'units' of data to move X */ X X#define movsl(from,to,count) \ X { asm volatile( "cld;movl %1,%%edi; movl %0,%%esi; rep; movsl ;"\ X : /* No Output */\ X :"g" ((int*) (from)),\ X "g>" ((int*) (to)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "si", "cx", "dx" ); } X X#define movsw(from,to,count) \ X { asm volatile( "cld;movl %1,%%edi; movl %0,%%esi; rep; movsw ;"\ X : /* No Output */\ X :"g" ((short*) (from)),\ X "g>" ((short*) (to)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "si", "cx", "dx" ); } X X#define movsb(from,to,count) \ X { asm volatile( "cld;movl %1,%%edi; movl %0,%%esi; rep; movsb ;"\ X : /* No Output */\ X :"g" ((char*) (from)),\ X "g>" ((char*) (to)), /* auto incrimented integer pointer */\ X "c" ((unsigned int) (count))\ X : "di", "ax", "dx", "si", "cx", "dx" ); } X X X#endif _block_h END-of-i386/include/block.h exit