diff options
author | Michael Brown <mcb30@etherboot.org> | 2008-11-18 14:30:37 -0800 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-12-05 00:06:27 +0000 |
commit | ce0a0ccf5c2b99be684f13a9418d1556bae5f0ed (patch) | |
tree | 965c86dafc3fbdca8e46ee22b94387242cc0e288 /src/arch/i386 | |
parent | b0d2c9a4d5b5dd669a845127a37ba08440e2820b (diff) | |
download | ipxe-ce0a0ccf5c2b99be684f13a9418d1556bae5f0ed.tar.gz |
[x86_64] Add support for compilation as an x86_64 binary
Currently the only supported platform for x86_64 is EFI.
Building an EFI64 gPXE requires a version of gcc that supports
__attribute__((ms_abi)). This currently means a development build of
gcc; the feature should be present when gcc 4.4 is released.
In the meantime; you can grab a suitable gcc tree from
git://git.etherboot.org/scm/people/mcb30/gcc/.git
Diffstat (limited to 'src/arch/i386')
-rw-r--r-- | src/arch/i386/Makefile | 6 | ||||
-rw-r--r-- | src/arch/i386/core/i386_string.c | 63 | ||||
-rw-r--r-- | src/arch/i386/core/pcidirect.c | 44 | ||||
-rw-r--r-- | src/arch/i386/include/bits/byteswap.h | 45 | ||||
-rw-r--r-- | src/arch/i386/include/bits/pci_io.h | 13 | ||||
-rw-r--r-- | src/arch/i386/include/bits/stdint.h | 4 | ||||
-rw-r--r-- | src/arch/i386/include/bits/string.h | 252 | ||||
-rw-r--r-- | src/arch/i386/include/gpxe/efi/efix86_nap.h | 16 | ||||
-rw-r--r-- | src/arch/i386/include/gpxe/pcibios.h | 133 | ||||
-rw-r--r-- | src/arch/i386/include/gpxe/pcidirect.h | 139 | ||||
-rw-r--r-- | src/arch/i386/interface/efi/efix86_nap.c | 46 |
11 files changed, 12 insertions, 749 deletions
diff --git a/src/arch/i386/Makefile b/src/arch/i386/Makefile index e376b481..1392bbac 100644 --- a/src/arch/i386/Makefile +++ b/src/arch/i386/Makefile @@ -68,7 +68,6 @@ SRCDIRS += arch/i386/drivers/net SRCDIRS += arch/i386/interface/pcbios SRCDIRS += arch/i386/interface/pxe SRCDIRS += arch/i386/interface/syslinux -SRCDIRS += arch/i386/interface/efi # The various xxx_loader.c files are #included into core/loader.c and # should not be compiled directly. @@ -82,6 +81,11 @@ NON_AUTO_SRCS += arch/i386/core/wince_loader.c OBJS_unnrv2b = unnrv2b unnrv2b16 CFLAGS_unnrv2b16 = -DCODE16 +# Include common x86 Makefile +# +MAKEDEPS += arch/x86/Makefile +include arch/x86/Makefile + # Include platform-specific Makefile # MAKEDEPS += arch/i386/Makefile.$(PLATFORM) diff --git a/src/arch/i386/core/i386_string.c b/src/arch/i386/core/i386_string.c deleted file mode 100644 index 9917363a..00000000 --- a/src/arch/i386/core/i386_string.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/** @file - * - * Optimised string operations - * - */ - -#include <string.h> - -/** - * Copy memory area - * - * @v dest Destination address - * @v src Source address - * @v len Length - * @ret dest Destination address - */ -__attribute__ (( regparm ( 3 ) )) void * __memcpy ( void *dest, - const void *src, - size_t len ) { - void *edi = dest; - const void *esi = src; - int discard_ecx; - - /* We often do large dword-aligned and dword-length block - * moves. Using movsl rather than movsb speeds these up by - * around 32%. - */ - if ( len >> 2 ) { - __asm__ __volatile__ ( "rep movsl" - : "=&D" ( edi ), "=&S" ( esi ), - "=&c" ( discard_ecx ) - : "0" ( edi ), "1" ( esi ), - "2" ( len >> 2 ) - : "memory" ); - } - if ( len & 0x02 ) { - __asm__ __volatile__ ( "movsw" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - } - if ( len & 0x01 ) { - __asm__ __volatile__ ( "movsb" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - } - return dest; -} diff --git a/src/arch/i386/core/pcidirect.c b/src/arch/i386/core/pcidirect.c deleted file mode 100644 index fec2e3c1..00000000 --- a/src/arch/i386/core/pcidirect.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <gpxe/pci.h> - -/** @file - * - * PCI configuration space access via Type 1 accesses - * - */ - -/** - * Prepare for Type 1 PCI configuration space access - * - * @v pci PCI device - * @v where Location within PCI configuration space - */ -void pcidirect_prepare ( struct pci_device *pci, int where ) { - outl ( ( 0x80000000 | ( pci->bus << 16 ) | ( pci->devfn << 8 ) | - ( where & ~3 ) ), PCIDIRECT_CONFIG_ADDRESS ); -} - -PROVIDE_PCIAPI_INLINE ( direct, pci_max_bus ); -PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_byte ); -PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_word ); -PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_dword ); -PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_byte ); -PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_word ); -PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_dword ); diff --git a/src/arch/i386/include/bits/byteswap.h b/src/arch/i386/include/bits/byteswap.h index 54b93ab9..98418c29 100644 --- a/src/arch/i386/include/bits/byteswap.h +++ b/src/arch/i386/include/bits/byteswap.h @@ -2,7 +2,7 @@ #define ETHERBOOT_BITS_BYTESWAP_H static inline __attribute__ ((always_inline, const)) uint16_t -__i386_bswap_16(uint16_t x) +__bswap_variable_16(uint16_t x) { __asm__("xchgb %b0,%h0\n\t" : "=q" (x) @@ -11,7 +11,7 @@ __i386_bswap_16(uint16_t x) } static inline __attribute__ ((always_inline, const)) uint32_t -__i386_bswap_32(uint32_t x) +__bswap_variable_32(uint32_t x) { __asm__("xchgb %b0,%h0\n\t" "rorl $16,%0\n\t" @@ -22,7 +22,7 @@ __i386_bswap_32(uint32_t x) } static inline __attribute__ ((always_inline, const)) uint64_t -__i386_bswap_64(uint64_t x) +__bswap_variable_64(uint64_t x) { union { uint64_t qword; @@ -30,47 +30,12 @@ __i386_bswap_64(uint64_t x) } u; u.qword = x; - u.dword[0] = __i386_bswap_32(u.dword[0]); - u.dword[1] = __i386_bswap_32(u.dword[1]); + u.dword[0] = __bswap_variable_32(u.dword[0]); + u.dword[1] = __bswap_variable_32(u.dword[1]); __asm__("xchgl %0,%1" : "=r" ( u.dword[0] ), "=r" ( u.dword[1] ) : "0" ( u.dword[0] ), "1" ( u.dword[1] ) ); return u.qword; } -#define __bswap_constant_16(x) \ - ((uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \ - (((uint16_t)(x) & 0xff00) >> 8))) - -#define __bswap_constant_32(x) \ - ((uint32_t)((((uint32_t)(x) & 0x000000ffU) << 24) | \ - (((uint32_t)(x) & 0x0000ff00U) << 8) | \ - (((uint32_t)(x) & 0x00ff0000U) >> 8) | \ - (((uint32_t)(x) & 0xff000000U) >> 24))) - -#define __bswap_constant_64(x) \ - ((uint64_t)((((uint64_t)(x) & 0x00000000000000ffULL) << 56) | \ - (((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \ - (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \ - (((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \ - (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \ - (((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \ - (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \ - (((uint64_t)(x) & 0xff00000000000000ULL) >> 56))) - -#define __bswap_16(x) \ - ((uint16_t)(__builtin_constant_p(x) ? \ - __bswap_constant_16(x) : \ - __i386_bswap_16(x))) - -#define __bswap_32(x) \ - ((uint32_t)(__builtin_constant_p(x) ? \ - __bswap_constant_32(x) : \ - __i386_bswap_32(x))) - -#define __bswap_64(x) \ - ((uint64_t)(__builtin_constant_p(x) ? \ - __bswap_constant_64(x) : \ - __i386_bswap_64(x))) - #endif /* ETHERBOOT_BITS_BYTESWAP_H */ diff --git a/src/arch/i386/include/bits/pci_io.h b/src/arch/i386/include/bits/pci_io.h deleted file mode 100644 index 0fbb439d..00000000 --- a/src/arch/i386/include/bits/pci_io.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _BITS_PCI_IO_H -#define _BITS_PCI_IO_H - -/** @file - * - * i386-specific PCI I/O API implementations - * - */ - -#include <gpxe/pcibios.h> -#include <gpxe/pcidirect.h> - -#endif /* _BITS_PCI_IO_H */ diff --git a/src/arch/i386/include/bits/stdint.h b/src/arch/i386/include/bits/stdint.h index 1c9706c1..6ccf0971 100644 --- a/src/arch/i386/include/bits/stdint.h +++ b/src/arch/i386/include/bits/stdint.h @@ -1,8 +1,8 @@ #ifndef _BITS_STDINT_H #define _BITS_STDINT_H -typedef typeof(sizeof(int)) size_t; -typedef signed long ssize_t; +typedef unsigned int size_t; +typedef signed int ssize_t; typedef signed long off_t; typedef unsigned char uint8_t; diff --git a/src/arch/i386/include/bits/string.h b/src/arch/i386/include/bits/string.h deleted file mode 100644 index c05a7df8..00000000 --- a/src/arch/i386/include/bits/string.h +++ /dev/null @@ -1,252 +0,0 @@ -#ifndef ETHERBOOT_BITS_STRING_H -#define ETHERBOOT_BITS_STRING_H -/* - * Taken from Linux /usr/include/asm/string.h - * All except memcpy, memmove, memset and memcmp removed. - * - * Non-standard memswap() function added because it saves quite a bit - * of code (mbrown@fensystems.co.uk). - */ - -/* - * This string-include defines all string functions as inline - * functions. Use gcc. It also assumes ds=es=data space, this should be - * normal. Most of the string-functions are rather heavily hand-optimized, - * see especially strtok,strstr,str[c]spn. They should work, but are not - * very easy to understand. Everything is done entirely within the register - * set, making the functions fast and clean. String instructions have been - * used through-out, making for "slightly" unclear code :-) - * - * NO Copyright (C) 1991, 1992 Linus Torvalds, - * consider these trivial functions to be PD. - */ - -#define __HAVE_ARCH_MEMCPY - -extern __attribute__ (( regparm ( 3 ) )) void * __memcpy ( void *dest, - const void *src, - size_t len ); - -#if 0 -static inline __attribute__ (( always_inline )) void * -__memcpy ( void *dest, const void *src, size_t len ) { - int d0, d1, d2; - __asm__ __volatile__ ( "rep ; movsb" - : "=&c" ( d0 ), "=&S" ( d1 ), "=&D" ( d2 ) - : "0" ( len ), "1" ( src ), "2" ( dest ) - : "memory" ); - return dest; -} -#endif - -static inline __attribute__ (( always_inline )) void * -__constant_memcpy ( void *dest, const void *src, size_t len ) { - union { - uint32_t u32[2]; - uint16_t u16[4]; - uint8_t u8[8]; - } __attribute__ (( __may_alias__ )) *dest_u = dest; - const union { - uint32_t u32[2]; - uint16_t u16[4]; - uint8_t u8[8]; - } __attribute__ (( __may_alias__ )) *src_u = src; - const void *esi; - void *edi; - - switch ( len ) { - case 0 : /* 0 bytes */ - return dest; - /* - * Single-register moves; these are always better than a - * string operation. We can clobber an arbitrary two - * registers (data, source, dest can re-use source register) - * instead of being restricted to esi and edi. There's also a - * much greater potential for optimising with nearby code. - * - */ - case 1 : /* 4 bytes */ - dest_u->u8[0] = src_u->u8[0]; - return dest; - case 2 : /* 6 bytes */ - dest_u->u16[0] = src_u->u16[0]; - return dest; - case 4 : /* 4 bytes */ - dest_u->u32[0] = src_u->u32[0]; - return dest; - /* - * Double-register moves; these are probably still a win. - * - */ - case 3 : /* 12 bytes */ - dest_u->u16[0] = src_u->u16[0]; - dest_u->u8[2] = src_u->u8[2]; - return dest; - case 5 : /* 10 bytes */ - dest_u->u32[0] = src_u->u32[0]; - dest_u->u8[4] = src_u->u8[4]; - return dest; - case 6 : /* 12 bytes */ - dest_u->u32[0] = src_u->u32[0]; - dest_u->u16[2] = src_u->u16[2]; - return dest; - case 8 : /* 10 bytes */ - dest_u->u32[0] = src_u->u32[0]; - dest_u->u32[1] = src_u->u32[1]; - return dest; - } - - /* Even if we have to load up esi and edi ready for a string - * operation, we can sometimes save space by using multiple - * single-byte "movs" operations instead of loading up ecx and - * using "rep movsb". - * - * "load ecx, rep movsb" is 7 bytes, plus an average of 1 byte - * to allow for saving/restoring ecx 50% of the time. - * - * "movsl" and "movsb" are 1 byte each, "movsw" is two bytes. - * (In 16-bit mode, "movsl" is 2 bytes and "movsw" is 1 byte, - * but "movsl" moves twice as much data, so it balances out). - * - * The cutoff point therefore occurs around 26 bytes; the byte - * requirements for each method are: - * - * len 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 - * #bytes (ecx) 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 - * #bytes (no ecx) 4 5 6 7 5 6 7 8 6 7 8 9 7 8 9 10 - */ - - esi = src; - edi = dest; - - if ( len >= 26 ) - return __memcpy ( dest, src, len ); - - if ( len >= 6*4 ) - __asm__ __volatile__ ( "movsl" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - if ( len >= 5*4 ) - __asm__ __volatile__ ( "movsl" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - if ( len >= 4*4 ) - __asm__ __volatile__ ( "movsl" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - if ( len >= 3*4 ) - __asm__ __volatile__ ( "movsl" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - if ( len >= 2*4 ) - __asm__ __volatile__ ( "movsl" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - if ( len >= 1*4 ) - __asm__ __volatile__ ( "movsl" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - if ( ( len % 4 ) >= 2 ) - __asm__ __volatile__ ( "movsw" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - if ( ( len % 2 ) >= 1 ) - __asm__ __volatile__ ( "movsb" : "=&D" ( edi ), "=&S" ( esi ) - : "0" ( edi ), "1" ( esi ) : "memory" ); - - return dest; -} - -#define memcpy( dest, src, len ) \ - ( __builtin_constant_p ( (len) ) ? \ - __constant_memcpy ( (dest), (src), (len) ) : \ - __memcpy ( (dest), (src), (len) ) ) - -#define __HAVE_ARCH_MEMMOVE -static inline void * memmove(void * dest,const void * src, size_t n) -{ -int d0, d1, d2; -if (dest<src) -__asm__ __volatile__( - "cld\n\t" - "rep\n\t" - "movsb" - : "=&c" (d0), "=&S" (d1), "=&D" (d2) - :"0" (n),"1" (src),"2" (dest) - : "memory"); -else -__asm__ __volatile__( - "std\n\t" - "rep\n\t" - "movsb\n\t" - "cld" - : "=&c" (d0), "=&S" (d1), "=&D" (d2) - :"0" (n), - "1" (n-1+(const char *)src), - "2" (n-1+(char *)dest) - :"memory"); -return dest; -} - -#define __HAVE_ARCH_MEMSET -static inline void * memset(void *s, int c,size_t count) -{ -int d0, d1; -__asm__ __volatile__( - "cld\n\t" - "rep\n\t" - "stosb" - : "=&c" (d0), "=&D" (d1) - :"a" (c),"1" (s),"0" (count) - :"memory"); -return s; -} - -#define __HAVE_ARCH_MEMSWAP -static inline void * memswap(void *dest, void *src, size_t n) -{ -int d0, d1, d2, d3; -__asm__ __volatile__( - "\n1:\t" - "movb (%%edi),%%al\n\t" - "xchgb (%%esi),%%al\n\t" - "incl %%esi\n\t" - "stosb\n\t" - "loop 1b" - : "=&c" (d0), "=&S" (d1), "=&D" (d2), "=&a" (d3) - : "0" (n), "1" (src), "2" (dest) - : "memory" ); -return dest; -} - -#define __HAVE_ARCH_STRNCMP -static inline int strncmp(const char * cs,const char * ct,size_t count) -{ -register int __res; -int d0, d1, d2; -__asm__ __volatile__( - "1:\tdecl %3\n\t" - "js 2f\n\t" - "lodsb\n\t" - "scasb\n\t" - "jne 3f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n" - "2:\txorl %%eax,%%eax\n\t" - "jmp 4f\n" - "3:\tsbbl %%eax,%%eax\n\t" - "orb $1,%%al\n" - "4:" - :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) - :"1" (cs),"2" (ct),"3" (count)); -return __res; -} - -#define __HAVE_ARCH_STRLEN -static inline size_t strlen(const char * s) -{ -int d0; -register int __res; -__asm__ __volatile__( - "repne\n\t" - "scasb\n\t" - "notl %0\n\t" - "decl %0" - :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff)); -return __res; -} - -#endif /* ETHERBOOT_BITS_STRING_H */ diff --git a/src/arch/i386/include/gpxe/efi/efix86_nap.h b/src/arch/i386/include/gpxe/efi/efix86_nap.h deleted file mode 100644 index 91424c54..00000000 --- a/src/arch/i386/include/gpxe/efi/efix86_nap.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _GPXE_EFIX86_NAP_H -#define _GPXE_EFIX86_NAP_H - -/** @file - * - * EFI CPU sleeping - * - */ - -#ifdef NAP_EFIX86 -#define NAP_PREFIX_efix86 -#else -#define NAP_PREFIX_efix86 __efix86_ -#endif - -#endif /* _GPXE_EFIX86_NAP_H */ diff --git a/src/arch/i386/include/gpxe/pcibios.h b/src/arch/i386/include/gpxe/pcibios.h deleted file mode 100644 index b86f5abd..00000000 --- a/src/arch/i386/include/gpxe/pcibios.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef _GPXE_PCIBIOS_H -#define _GPXE_PCIBIOS_H - -#include <stdint.h> - -/** @file - * - * PCI configuration space access via PCI BIOS - * - */ - -#ifdef PCIAPI_PCBIOS -#define PCIAPI_PREFIX_pcbios -#else -#define PCIAPI_PREFIX_pcbios __pcbios_ -#endif - -struct pci_device; - -#define PCIBIOS_INSTALLATION_CHECK 0xb1010000 -#define PCIBIOS_READ_CONFIG_BYTE 0xb1080000 -#define PCIBIOS_READ_CONFIG_WORD 0xb1090000 -#define PCIBIOS_READ_CONFIG_DWORD 0xb10a0000 -#define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b0000 -#define PCIBIOS_WRITE_CONFIG_WORD 0xb10c0000 -#define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d0000 - -extern int pcibios_read ( struct pci_device *pci, uint32_t command, - uint32_t *value ); -extern int pcibios_write ( struct pci_device *pci, uint32_t command, - uint32_t value ); - -/** - * Read byte from PCI configuration space via PCI BIOS - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( pcbios, pci_read_config_byte ) ( struct pci_device *pci, - unsigned int where, - uint8_t *value ) { - uint32_t tmp; - int rc; - - rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_BYTE | where, &tmp ); - *value = tmp; - return rc; -} - -/** - * Read word from PCI configuration space via PCI BIOS - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( pcbios, pci_read_config_word ) ( struct pci_device *pci, - unsigned int where, - uint16_t *value ) { - uint32_t tmp; - int rc; - - rc = pcibios_read ( pci, PCIBIOS_READ_CONFIG_WORD | where, &tmp ); - *value = tmp; - return rc; -} - -/** - * Read dword from PCI configuration space via PCI BIOS - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( pcbios, pci_read_config_dword ) ( struct pci_device *pci, - unsigned int where, - uint32_t *value ) { - return pcibios_read ( pci, PCIBIOS_READ_CONFIG_DWORD | where, value ); -} - -/** - * Write byte to PCI configuration space via PCI BIOS - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( pcbios, pci_write_config_byte ) ( struct pci_device *pci, - unsigned int where, - uint8_t value ) { - return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_BYTE | where, value ); -} - -/** - * Write word to PCI configuration space via PCI BIOS - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( pcbios, pci_write_config_word ) ( struct pci_device *pci, - unsigned int where, - uint16_t value ) { - return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_WORD | where, value ); -} - -/** - * Write dword to PCI configuration space via PCI BIOS - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci, - unsigned int where, - uint32_t value ) { - return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_DWORD | where, value); -} - -#endif /* _GPXE_PCIBIOS_H */ diff --git a/src/arch/i386/include/gpxe/pcidirect.h b/src/arch/i386/include/gpxe/pcidirect.h deleted file mode 100644 index fe433c6f..00000000 --- a/src/arch/i386/include/gpxe/pcidirect.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef _PCIDIRECT_H -#define _PCIDIRECT_H - -#include <stdint.h> -#include <gpxe/io.h> - -#ifdef PCIAPI_DIRECT -#define PCIAPI_PREFIX_direct -#else -#define PCIAPI_PREFIX_direct __direct_ -#endif - -/** @file - * - * PCI configuration space access via Type 1 accesses - * - */ - -#define PCIDIRECT_CONFIG_ADDRESS 0xcf8 -#define PCIDIRECT_CONFIG_DATA 0xcfc - -struct pci_device; - -extern void pcidirect_prepare ( struct pci_device *pci, int where ); - -/** - * Determine maximum PCI bus number within system - * - * @ret max_bus Maximum bus number - */ -static inline __always_inline int -PCIAPI_INLINE ( direct, pci_max_bus ) ( void ) { - /* No way to work this out via Type 1 accesses */ - return 0xff; -} - -/** - * Read byte from PCI configuration space via Type 1 access - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( direct, pci_read_config_byte ) ( struct pci_device *pci, - unsigned int where, - uint8_t *value ) { - pcidirect_prepare ( pci, where ); - *value = inb ( PCIDIRECT_CONFIG_DATA + ( where & 3 ) ); - return 0; -} - -/** - * Read word from PCI configuration space via Type 1 access - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( direct, pci_read_config_word ) ( struct pci_device *pci, - unsigned int where, - uint16_t *value ) { - pcidirect_prepare ( pci, where ); - *value = inw ( PCIDIRECT_CONFIG_DATA + ( where & 2 ) ); - return 0; -} - -/** - * Read dword from PCI configuration space via Type 1 access - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value read - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( direct, pci_read_config_dword ) ( struct pci_device *pci, - unsigned int where, - uint32_t *value ) { - pcidirect_prepare ( pci, where ); - *value = inl ( PCIDIRECT_CONFIG_DATA ); - return 0; -} - -/** - * Write byte to PCI configuration space via Type 1 access - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( direct, pci_write_config_byte ) ( struct pci_device *pci, - unsigned int where, - uint8_t value ) { - pcidirect_prepare ( pci, where ); - outb ( value, PCIDIRECT_CONFIG_DATA + ( where & 3 ) ); - return 0; -} - -/** - * Write word to PCI configuration space via Type 1 access - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( direct, pci_write_config_word ) ( struct pci_device *pci, - unsigned int where, - uint16_t value ) { - pcidirect_prepare ( pci, where ); - outw ( value, PCIDIRECT_CONFIG_DATA + ( where & 2 ) ); - return 0; -} - -/** - * Write dword to PCI configuration space via Type 1 access - * - * @v pci PCI device - * @v where Location within PCI configuration space - * @v value Value to be written - * @ret rc Return status code - */ -static inline __always_inline int -PCIAPI_INLINE ( direct, pci_write_config_dword ) ( struct pci_device *pci, - unsigned int where, - uint32_t value ) { - pcidirect_prepare ( pci, where ); - outl ( value, PCIDIRECT_CONFIG_DATA ); - return 0; -} - -#endif /* _PCIDIRECT_H */ diff --git a/src/arch/i386/interface/efi/efix86_nap.c b/src/arch/i386/interface/efi/efix86_nap.c deleted file mode 100644 index 45e99a68..00000000 --- a/src/arch/i386/interface/efi/efix86_nap.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <gpxe/nap.h> -#include <gpxe/efi/efi.h> - -/** @file - * - * gPXE CPU sleeping API for EFI - * - */ - -/** - * Sleep until next interrupt - * - */ -static void efix86_cpu_nap ( void ) { - /* - * I can't find any EFI API that allows us to put the CPU to - * sleep. The CpuSleep() function is defined in CpuLib.h, but - * isn't part of any exposed protocol so we have no way to - * call it. - * - * The EFI shell doesn't seem to bother sleeping the CPU; it - * just sits there idly burning power. - * - */ - __asm__ __volatile__ ( "hlt" ); -} - -PROVIDE_NAP ( efix86, cpu_nap, efix86_cpu_nap ); |