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
24FILE_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 */
41void 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
unsigned short uint16_t
Definition stdint.h:11
uint16_t busdevfn
PCI bus:dev.fn address.
Definition ena.h:17
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
iPXE I/O API
#define outl(data, io_addr)
Definition io.h:330
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_can_probe(struct pci_device *pci)
Check if PCI bus probing is allowed.
void pci_discover(uint32_t busdevfn, struct pci_range *range)
Find next PCI bus:dev.fn address range in system.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define PCIAPI_PRIORITY_DIRECT
Direct Type 1 accesses.
Definition pci_io.h:199
#define PROVIDE_PCIAPI_RUNTIME(subsys, priority)
Provide a runtime selectable PCI I/O API.
Definition pci_io.h:202
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
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_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
#define PROVIDE_PCIAPI_INLINE(_subsys, _api_func)
Provide a static inline PCI I/O API implementation.
Definition pci_io.h:60
PCI bus.
static __always_inline int unsigned int where
Definition pcibios.h:57
void pcidirect_prepare(struct pci_device *pci, int where)
Prepare for Type 1 PCI configuration space access.
Definition pcidirect.c:41
#define PCIDIRECT_CONFIG_ADDRESS
Definition pcidirect.h:22
A PCI device.
Definition pci.h:211
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition pci.h:238