00001 /***************************************************************************************** 00002 Copyright (c) 2002-2005 The UbixOS Project 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are 00006 permitted provided that the following conditions are met: 00007 00008 Redistributions of source code must retain the above copyright notice, this list of 00009 conditions, the following disclaimer and the list of authors. Redistributions in binary 00010 form must reproduce the above copyright notice, this list of conditions, the following 00011 disclaimer and the list of authors in the documentation and/or other materials provided 00012 with the distribution. Neither the name of the UbixOS Project nor the names of its 00013 contributors may be used to endorse or promote products derived from this software 00014 without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 00017 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00019 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00022 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00023 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 $Id$ 00027 00028 *****************************************************************************************/ 00029 00030 #include <sys/io.h> 00031 00032 /************************************************************************ 00033 00034 Function: inline unsigned char inportByte(unsigned int port); 00035 Description: This Funciton Will Input One Byte From A Port 00036 Notes: 00037 00038 ************************************************************************/ 00039 unsigned char inportByte(unsigned int port) { 00040 unsigned char retVal; 00041 asm volatile( 00042 "inb %%dx,%%al" 00043 : "=a" (retVal) 00044 : "d" (port) 00045 ); 00046 return(retVal); 00047 } 00048 00049 /************************************************************************ 00050 00051 Function: inline unsigned char inportWord(unsigned int port); 00052 Description: This Funciton Will Input One Word From A Port 00053 Notes: 00054 00055 ************************************************************************/ 00056 unsigned short inportWord(unsigned int port) { 00057 unsigned short retVal; 00058 asm volatile( 00059 "inw %%dx,%%ax" 00060 : "=a" (retVal) 00061 : "d" (port) 00062 ); 00063 return(retVal); 00064 } 00065 00066 /************************************************************************ 00067 00068 Function: inline void outportByte(unsigned int port,unsigned char value); 00069 Description: This Funciton Will Outputut One Byte To A Port 00070 Notes: 00071 00072 ************************************************************************/ 00073 void outportByte(unsigned int port,unsigned char value) { 00074 asm volatile( 00075 "outb %%al,%%dx" 00076 : 00077 : "d" (port), "a" (value) 00078 ); 00079 } 00080 00081 /************************************************************************ 00082 00083 Function: inline void outportByteP(unsigned int port,unsigned char value); 00084 Description: This Funciton Will Outputut One Byte To A Port With A Delay 00085 Notes: 00086 00087 ************************************************************************/ 00088 void outportByteP(unsigned int port,unsigned char value) { 00089 asm volatile( 00090 "outb %%al,%%dx\n" 00091 "outb %%al,$0x80\n" 00092 : 00093 : "d" (port), "a" (value) 00094 ); 00095 } 00096 00097 /************************************************************************ 00098 00099 Function: inline void outportWord(unsigned int port,unsigned char value); 00100 Description: This Funciton Will Outputut One Word To A Port 00101 Notes: 00102 00103 ************************************************************************/ 00104 void outportWord(unsigned int port,unsigned short value) { 00105 asm volatile( 00106 "outw %%ax,%%dx" 00107 : 00108 : "d" (port), "a" (value) 00109 ); 00110 } 00111 00112 /************************************************************************ 00113 00114 Function: inline void outportDWord(unsigned int port,unsigned char value); 00115 Description: This Funciton Will Outputut One DWord To A Port 00116 Notes: 00117 00118 ************************************************************************/ 00119 void outportDWord(unsigned int port,unsigned long value) { 00120 asm volatile( 00121 "outl %%eax,%%dx" 00122 : 00123 : "d" (port), "a" (value) 00124 ); 00125 } 00126 00127 /************************************************************************ 00128 00129 Function: inline unsigned char inportDWord(unsigned int port); 00130 Description: This Funciton Will Input One DWord From A Port 00131 Notes: 00132 00133 ************************************************************************/ 00134 unsigned long inportDWord(unsigned int port) { 00135 unsigned long retVal; 00136 asm volatile( 00137 "inl %%dx,%%eax" 00138 : "=a" (retVal) 00139 : "d" (port) 00140 ); 00141 return(retVal); 00142 } 00143 00144 /*** 00145 END 00146 ***/
1.4.7