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
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
27 #include <ipxe/x86_io.h>
31 * iPXE I/O API for x86
36 * Read 64-bit qword from memory-mapped device
38 * @v io_addr I/O address
39 * @ret data Value read
41 * This routine uses MMX instructions.
43 static __unused uint64_t i386_readq ( volatile uint64_t *io_addr ) {
45 __asm__ __volatile__ ( "pushl %%edx\n\t"
47 "movq (%1), %%mm0\n\t"
48 "movq %%mm0, (%%esp)\n\t"
52 : "=A" ( data ) : "r" ( io_addr ) );
57 * Write 64-bit qword to memory-mapped device
59 * @v data Value to write
60 * @v io_addr I/O address
62 * This routine uses MMX instructions.
64 static __unused void i386_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
65 __asm__ __volatile__ ( "pushl %%edx\n\t"
67 "movq (%%esp), %%mm0\n\t"
68 "movq %%mm0, (%1)\n\t"
72 : : "A" ( data ), "r" ( io_addr ) );
75 PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
76 PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
77 PROVIDE_IOAPI_INLINE ( x86, ioremap );
78 PROVIDE_IOAPI_INLINE ( x86, iounmap );
79 PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
80 PROVIDE_IOAPI_INLINE ( x86, readb );
81 PROVIDE_IOAPI_INLINE ( x86, readw );
82 PROVIDE_IOAPI_INLINE ( x86, readl );
83 PROVIDE_IOAPI_INLINE ( x86, writeb );
84 PROVIDE_IOAPI_INLINE ( x86, writew );
85 PROVIDE_IOAPI_INLINE ( x86, writel );
86 PROVIDE_IOAPI_INLINE ( x86, inb );
87 PROVIDE_IOAPI_INLINE ( x86, inw );
88 PROVIDE_IOAPI_INLINE ( x86, inl );
89 PROVIDE_IOAPI_INLINE ( x86, outb );
90 PROVIDE_IOAPI_INLINE ( x86, outw );
91 PROVIDE_IOAPI_INLINE ( x86, outl );
92 PROVIDE_IOAPI_INLINE ( x86, insb );
93 PROVIDE_IOAPI_INLINE ( x86, insw );
94 PROVIDE_IOAPI_INLINE ( x86, insl );
95 PROVIDE_IOAPI_INLINE ( x86, outsb );
96 PROVIDE_IOAPI_INLINE ( x86, outsw );
97 PROVIDE_IOAPI_INLINE ( x86, outsl );
98 PROVIDE_IOAPI_INLINE ( x86, iodelay );
99 PROVIDE_IOAPI_INLINE ( x86, mb );
101 PROVIDE_IOAPI_INLINE ( x86, readq );
102 PROVIDE_IOAPI_INLINE ( x86, writeq );
104 PROVIDE_IOAPI ( x86, readq, i386_readq );
105 PROVIDE_IOAPI ( x86, writeq, i386_writeq );