x86_io.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020 
00021 #include <gpxe/io.h>
00022 #include <gpxe/x86_io.h>
00023 
00024 /** @file
00025  *
00026  * gPXE I/O API for x86
00027  *
00028  */
00029 
00030 /**
00031  * Read 64-bit qword from memory-mapped device
00032  *
00033  * @v io_addr           I/O address
00034  * @ret data            Value read
00035  *
00036  * This routine uses MMX instructions.
00037  */
00038 static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
00039         uint64_t data;
00040         __asm__ __volatile__ ( "pushl %%edx\n\t"
00041                                "pushl %%eax\n\t"
00042                                "movq (%1), %%mm0\n\t"
00043                                "movq %%mm0, (%%esp)\n\t"
00044                                "popl %%eax\n\t"
00045                                "popl %%edx\n\t"
00046                                "emms\n\t"
00047                                : "=A" ( data ) : "r" ( io_addr ) );
00048         return data;
00049 }
00050 
00051 /**
00052  * Write 64-bit qword to memory-mapped device
00053  *
00054  * @v data              Value to write
00055  * @v io_addr           I/O address
00056  *
00057  * This routine uses MMX instructions.
00058  */
00059 static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
00060         __asm__ __volatile__ ( "pushl %%edx\n\t"
00061                                "pushl %%eax\n\t"
00062                                "movq (%%esp), %%mm0\n\t"
00063                                "movq %%mm0, (%1)\n\t"
00064                                "popl %%eax\n\t"
00065                                "popl %%edx\n\t"
00066                                "emms\n\t"
00067                                : : "A" ( data ), "r" ( io_addr ) );
00068 }
00069 
00070 PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
00071 PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
00072 PROVIDE_IOAPI_INLINE ( x86, ioremap );
00073 PROVIDE_IOAPI_INLINE ( x86, iounmap );
00074 PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
00075 PROVIDE_IOAPI_INLINE ( x86, readb );
00076 PROVIDE_IOAPI_INLINE ( x86, readw );
00077 PROVIDE_IOAPI_INLINE ( x86, readl );
00078 PROVIDE_IOAPI ( x86, readq, x86_readq );
00079 PROVIDE_IOAPI_INLINE ( x86, writeb );
00080 PROVIDE_IOAPI_INLINE ( x86, writew );
00081 PROVIDE_IOAPI_INLINE ( x86, writel );
00082 PROVIDE_IOAPI ( x86, writeq, x86_writeq );
00083 PROVIDE_IOAPI_INLINE ( x86, inb );
00084 PROVIDE_IOAPI_INLINE ( x86, inw );
00085 PROVIDE_IOAPI_INLINE ( x86, inl );
00086 PROVIDE_IOAPI_INLINE ( x86, outb );
00087 PROVIDE_IOAPI_INLINE ( x86, outw );
00088 PROVIDE_IOAPI_INLINE ( x86, outl );
00089 PROVIDE_IOAPI_INLINE ( x86, insb );
00090 PROVIDE_IOAPI_INLINE ( x86, insw );
00091 PROVIDE_IOAPI_INLINE ( x86, insl );
00092 PROVIDE_IOAPI_INLINE ( x86, outsb );
00093 PROVIDE_IOAPI_INLINE ( x86, outsw );
00094 PROVIDE_IOAPI_INLINE ( x86, outsl );
00095 PROVIDE_IOAPI_INLINE ( x86, iodelay );
00096 PROVIDE_IOAPI_INLINE ( x86, mb );

Generated on Tue Apr 6 20:00:49 2010 for gPXE by  doxygen 1.5.7.1