[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / arch / i386 / core / x86_io.c
blobd2c363b9e78a36e9b709f2919d2bbfb4cae6227d
1 /*
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.
19 FILE_LICENCE ( GPL2_OR_LATER );
21 #include <gpxe/io.h>
22 #include <gpxe/x86_io.h>
24 /** @file
26 * gPXE I/O API for x86
30 /**
31 * Read 64-bit qword from memory-mapped device
33 * @v io_addr I/O address
34 * @ret data Value read
36 * This routine uses MMX instructions.
38 static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
39 uint64_t data;
40 __asm__ __volatile__ ( "pushl %%edx\n\t"
41 "pushl %%eax\n\t"
42 "movq (%1), %%mm0\n\t"
43 "movq %%mm0, (%%esp)\n\t"
44 "popl %%eax\n\t"
45 "popl %%edx\n\t"
46 "emms\n\t"
47 : "=A" ( data ) : "r" ( io_addr ) );
48 return data;
51 /**
52 * Write 64-bit qword to memory-mapped device
54 * @v data Value to write
55 * @v io_addr I/O address
57 * This routine uses MMX instructions.
59 static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
60 __asm__ __volatile__ ( "pushl %%edx\n\t"
61 "pushl %%eax\n\t"
62 "movq (%%esp), %%mm0\n\t"
63 "movq %%mm0, (%1)\n\t"
64 "popl %%eax\n\t"
65 "popl %%edx\n\t"
66 "emms\n\t"
67 : : "A" ( data ), "r" ( io_addr ) );
70 PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
71 PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
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 );