2 * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gpxe/x86_io.h>
24 * gPXE I/O API for x86
29 * Read 64-bit qword from memory-mapped device
31 * @v io_addr I/O address
32 * @ret data Value read
34 * This routine uses MMX instructions.
36 static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
38 __asm__ __volatile__ ( "pushl %%edx\n\t"
40 "movq (%1), %%mm0\n\t"
41 "movq %%mm0, (%%esp)\n\t"
45 : "=A" ( data ) : "r" ( io_addr ) );
50 * Write 64-bit qword to memory-mapped device
52 * @v data Value to write
53 * @v io_addr I/O address
55 * This routine uses MMX instructions.
57 static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
58 __asm__ __volatile__ ( "pushl %%edx\n\t"
60 "movq (%%esp), %%mm0\n\t"
61 "movq %%mm0, (%1)\n\t"
65 : : "A" ( data ), "r" ( io_addr ) );
68 PROVIDE_IOAPI_INLINE ( x86, virt_to_phys );
69 PROVIDE_IOAPI_INLINE ( x86, phys_to_virt );
70 PROVIDE_IOAPI_INLINE ( x86, virt_to_bus );
71 PROVIDE_IOAPI_INLINE ( x86, bus_to_virt );
72 PROVIDE_IOAPI_INLINE ( x86, ioremap );
73 PROVIDE_IOAPI_INLINE ( x86, iounmap );
74 PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
75 PROVIDE_IOAPI_INLINE ( x86, readb );
76 PROVIDE_IOAPI_INLINE ( x86, readw );
77 PROVIDE_IOAPI_INLINE ( x86, readl );
78 PROVIDE_IOAPI ( x86, readq, x86_readq );
79 PROVIDE_IOAPI_INLINE ( x86, writeb );
80 PROVIDE_IOAPI_INLINE ( x86, writew );
81 PROVIDE_IOAPI_INLINE ( x86, writel );
82 PROVIDE_IOAPI ( x86, writeq, x86_writeq );
83 PROVIDE_IOAPI_INLINE ( x86, inb );
84 PROVIDE_IOAPI_INLINE ( x86, inw );
85 PROVIDE_IOAPI_INLINE ( x86, inl );
86 PROVIDE_IOAPI_INLINE ( x86, outb );
87 PROVIDE_IOAPI_INLINE ( x86, outw );
88 PROVIDE_IOAPI_INLINE ( x86, outl );
89 PROVIDE_IOAPI_INLINE ( x86, insb );
90 PROVIDE_IOAPI_INLINE ( x86, insw );
91 PROVIDE_IOAPI_INLINE ( x86, insl );
92 PROVIDE_IOAPI_INLINE ( x86, outsb );
93 PROVIDE_IOAPI_INLINE ( x86, outsw );
94 PROVIDE_IOAPI_INLINE ( x86, outsl );
95 PROVIDE_IOAPI_INLINE ( x86, iodelay );
96 PROVIDE_IOAPI_INLINE ( x86, mb );