iPXE
pcidirect.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3  *
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.
8  *
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.
13  *
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
17  * 02110-1301, USA.
18  *
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.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 #include <ipxe/io.h>
27 #include <ipxe/pci.h>
28 
29 /** @file
30  *
31  * PCI configuration space access via Type 1 accesses
32  *
33  */
34 
35 /**
36  * Prepare for Type 1 PCI configuration space access
37  *
38  * @v pci PCI device
39  * @v where Location within PCI configuration space
40  */
41 void pcidirect_prepare ( struct pci_device *pci, int where ) {
42  uint16_t busdevfn = ( pci->busdevfn & 0xffff );
43 
44  outl ( ( 0x80000000 | ( busdevfn << 8 ) | ( where & ~3 ) ),
46 }
47 
iPXE I/O API
unsigned short uint16_t
Definition: stdint.h:11
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
PROVIDE_PCIAPI_INLINE(direct, pci_num_bus)
#define outl(data, io_addr)
Definition: io.h:329
PCI bus.
A PCI device.
Definition: pci.h:187
static __always_inline int unsigned int where
Definition: efi_pci_api.h:56
#define PCIDIRECT_CONFIG_ADDRESS
Definition: pcidirect.h:21
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:210
int pci_num_bus(void)
Determine number of PCI buses within system.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
void pcidirect_prepare(struct pci_device *pci, int where)
Prepare for Type 1 PCI configuration space access.
Definition: pcidirect.c:41
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.