pcibios.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020
00021 #include <stdint.h>
00022 #include <gpxe/pci.h>
00023 #include <realmode.h>
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 static int pcibios_max_bus ( void ) {
00037 int discard_a, discard_D;
00038 uint8_t max_bus;
00039
00040 __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
00041 "int $0x1a\n\t"
00042 "jnc 1f\n\t"
00043 "xorw %%cx, %%cx\n\t"
00044 "\n1:\n\t" )
00045 : "=c" ( max_bus ), "=a" ( discard_a ),
00046 "=D" ( discard_D )
00047 : "a" ( PCIBIOS_INSTALLATION_CHECK >> 16 ),
00048 "D" ( 0 )
00049 : "ebx", "edx" );
00050
00051 return max_bus;
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 int pcibios_read ( struct pci_device *pci, uint32_t command, uint32_t *value ){
00063 int discard_b, discard_D;
00064 int status;
00065
00066 __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
00067 "int $0x1a\n\t"
00068 "jnc 1f\n\t"
00069 "xorl %%eax, %%eax\n\t"
00070 "decl %%eax\n\t"
00071 "movl %%eax, %%ecx\n\t"
00072 "\n1:\n\t" )
00073 : "=a" ( status ), "=b" ( discard_b ),
00074 "=c" ( *value ), "=D" ( discard_D )
00075 : "a" ( command >> 16 ), "D" ( command ),
00076 "b" ( PCI_BUSDEVFN ( pci->bus, pci->devfn ) )
00077 : "edx" );
00078
00079 return ( ( status >> 8 ) & 0xff );
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 int pcibios_write ( struct pci_device *pci, uint32_t command, uint32_t value ){
00091 int discard_b, discard_c, discard_D;
00092 int status;
00093
00094 __asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
00095 "int $0x1a\n\t"
00096 "jnc 1f\n\t"
00097 "movb $0xff, %%ah\n\t"
00098 "\n1:\n\t" )
00099 : "=a" ( status ), "=b" ( discard_b ),
00100 "=c" ( discard_c ), "=D" ( discard_D )
00101 : "a" ( command >> 16 ), "D" ( command ),
00102 "b" ( PCI_BUSDEVFN ( pci->bus, pci->devfn ) ),
00103 "c" ( value )
00104 : "edx" );
00105
00106 return ( ( status >> 8 ) & 0xff );
00107 }
00108
00109 PROVIDE_PCIAPI ( pcbios, pci_max_bus, pcibios_max_bus );
00110 PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_byte );
00111 PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_word );
00112 PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_dword );
00113 PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_byte );
00114 PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_word );
00115 PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_dword );