[pci] Add minimal PCI bridge driver

Add a minimal driver for PCI bridges that can be used to locate the
bridge to which a PCI device is attached.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2022-09-19 17:47:57 +01:00
parent 649176cd60
commit 3aa6b79c8d
4 changed files with 191 additions and 0 deletions

View File

@@ -217,6 +217,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_rdc ( ERRFILE_DRIVER | 0x00d10000 )
#define ERRFILE_ice ( ERRFILE_DRIVER | 0x00d20000 )
#define ERRFILE_ecam ( ERRFILE_DRIVER | 0x00d30000 )
#define ERRFILE_pcibridge ( ERRFILE_DRIVER | 0x00d40000 )
#define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 )
#define ERRFILE_arp ( ERRFILE_NET | 0x00010000 )

View File

@@ -127,6 +127,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** Network controller */
#define PCI_CLASS_NETWORK 0x02
/** Bridge device */
#define PCI_CLASS_BRIDGE 0x06
#define PCI_CLASS_BRIDGE_PCI 0x04 /**< PCI-to-PCI bridge */
/** Serial bus controller */
#define PCI_CLASS_SERIAL 0x0c
#define PCI_CLASS_SERIAL_USB 0x03 /**< USB controller */
@@ -135,9 +139,20 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define PCI_CLASS_SERIAL_USB_EHCI 0x20 /**< ECHI USB controller */
#define PCI_CLASS_SERIAL_USB_XHCI 0x30 /**< xHCI USB controller */
/** Primary bus number */
#define PCI_PRIMARY 0x18
/** Secondary bus number */
#define PCI_SECONDARY 0x19
/** Subordinate bus number */
#define PCI_SUBORDINATE 0x1a
/** Memory base and limit */
#define PCI_MEM_BASE 0x20
#define PCI_MEM_LIMIT 0x22
#define PCI_MEM_MASK 0x000f
/** Construct PCI class
*
* @v base Base class (or PCI_ANY_ID)

View File

@@ -0,0 +1,43 @@
#ifndef _IPXE_PCIBRIDGE_H
#define _IPXE_PCIBRIDGE_H
/** @file
*
* PCI-to-PCI bridge
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <ipxe/list.h>
#include <ipxe/pci.h>
/** A PCI-to-PCI bridge */
struct pci_bridge {
/** PCI device */
struct pci_device *pci;
/** Bridge numbers */
union {
/** Raw dword */
uint32_t buses;
struct {
/** Primary bus */
uint8_t primary;
/** Secondary bus */
uint8_t secondary;
/** Subordinate bus */
uint8_t subordinate;
} __attribute__ (( packed ));
};
/** Memory base */
uint32_t membase;
/** Memory limit */
uint32_t memlimit;
/** List of bridges */
struct list_head list;
};
extern struct pci_bridge * pcibridge_find ( struct pci_device *pci );
#endif /* _IPXE_PCIBRIDGE_H */