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., 51 Franklin Street, Fifth Floor, Boston, MA
20 FILE_LICENCE ( GPL2_OR_LATER );
23 #include <ipxe/x86_io.h>
27 * iPXE I/O API for x86
32 * Read 64-bit qword from memory-mapped device
34 * @v io_addr I/O address
35 * @ret data Value read
37 * This routine uses MMX instructions.
39 static __unused uint64_t i386_readq ( volatile uint64_t *io_addr ) {
41 __asm__ __volatile__ ( "pushl %%edx\n\t"
43 "movq (%1), %%mm0\n\t"
44 "movq %%mm0, (%%esp)\n\t"
48 : "=A" ( data ) : "r" ( io_addr ) );
53 * Write 64-bit qword to memory-mapped device
55 * @v data Value to write
56 * @v io_addr I/O address
58 * This routine uses MMX instructions.
60 static __unused void i386_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
61 __asm__ __volatile__ ( "pushl %%edx\n\t"
63 "movq (%%esp), %%mm0\n\t"
64 "movq %%mm0, (%1)\n\t"
68 : : "A" ( data ), "r" ( io_addr ) );
71 PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
72 PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
73 PROVIDE_IOAPI_INLINE ( x86, ioremap );
74 PROVIDE_IOAPI_INLINE ( x86, iounmap );
75 PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
76 PROVIDE_IOAPI_INLINE ( x86, readb );
77 PROVIDE_IOAPI_INLINE ( x86, readw );
78 PROVIDE_IOAPI_INLINE ( x86, readl );
79 PROVIDE_IOAPI_INLINE ( x86, writeb );
80 PROVIDE_IOAPI_INLINE ( x86, writew );
81 PROVIDE_IOAPI_INLINE ( x86, writel );
82 PROVIDE_IOAPI_INLINE ( x86, inb );
83 PROVIDE_IOAPI_INLINE ( x86, inw );
84 PROVIDE_IOAPI_INLINE ( x86, inl );
85 PROVIDE_IOAPI_INLINE ( x86, outb );
86 PROVIDE_IOAPI_INLINE ( x86, outw );
87 PROVIDE_IOAPI_INLINE ( x86, outl );
88 PROVIDE_IOAPI_INLINE ( x86, insb );
89 PROVIDE_IOAPI_INLINE ( x86, insw );
90 PROVIDE_IOAPI_INLINE ( x86, insl );
91 PROVIDE_IOAPI_INLINE ( x86, outsb );
92 PROVIDE_IOAPI_INLINE ( x86, outsw );
93 PROVIDE_IOAPI_INLINE ( x86, outsl );
94 PROVIDE_IOAPI_INLINE ( x86, iodelay );
95 PROVIDE_IOAPI_INLINE ( x86, mb );
97 PROVIDE_IOAPI_INLINE ( x86, readq );
98 PROVIDE_IOAPI_INLINE ( x86, writeq );
100 PROVIDE_IOAPI ( x86, readq, i386_readq );
101 PROVIDE_IOAPI ( x86, writeq, i386_writeq );