diff options
author | Michael Brown <mcb30@ipxe.org> | 2014-07-01 17:58:09 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2014-07-03 15:28:17 +0100 |
commit | c7051d826b43954b1e191667a75b21b44ec02c35 (patch) | |
tree | c29a4e22878c42f4c31900e5582a055287bbe939 /src/include | |
parent | cb2f6ca46fdea7607d077df956689d694a7bd517 (diff) | |
download | ipxe-c7051d826b43954b1e191667a75b21b44ec02c35.zip ipxe-c7051d826b43954b1e191667a75b21b44ec02c35.tar.gz ipxe-c7051d826b43954b1e191667a75b21b44ec02c35.tar.bz2 |
[efi] Allow network devices to be created on top of arbitrary SNP devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ipxe/device.h | 3 | ||||
-rw-r--r-- | src/include/ipxe/efi/efi_driver.h | 49 | ||||
-rw-r--r-- | src/include/ipxe/efi/efi_pci.h | 32 | ||||
-rw-r--r-- | src/include/ipxe/efi/efi_snp.h | 5 | ||||
-rw-r--r-- | src/include/ipxe/errfile.h | 1 |
5 files changed, 56 insertions, 34 deletions
diff --git a/src/include/ipxe/device.h b/src/include/ipxe/device.h index c59697c..8950973 100644 --- a/src/include/ipxe/device.h +++ b/src/include/ipxe/device.h @@ -57,6 +57,9 @@ struct device_description { /** TAP bus type */ #define BUS_TYPE_TAP 6 +/** EFI bus type */ +#define BUS_TYPE_EFI 7 + /** A hardware device */ struct device { /** Name */ diff --git a/src/include/ipxe/efi/efi_driver.h b/src/include/ipxe/efi/efi_driver.h index 600d304..21bff0e 100644 --- a/src/include/ipxe/efi/efi_driver.h +++ b/src/include/ipxe/efi/efi_driver.h @@ -8,10 +8,25 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include <ipxe/device.h> #include <ipxe/tables.h> #include <ipxe/efi/efi.h> #include <ipxe/efi/Protocol/DevicePath.h> +/** An EFI device */ +struct efi_device { + /** Generic device */ + struct device dev; + /** EFI device handle */ + EFI_HANDLE device; + /** Device path */ + EFI_DEVICE_PATH_PROTOCOL *path; + /** Driver for this device */ + struct efi_driver *driver; + /** Driver-private data */ + void *priv; +}; + /** An EFI driver */ struct efi_driver { /** Name */ @@ -19,23 +34,23 @@ struct efi_driver { /** * Check if driver supports device * - * @v device Device + * @v device EFI device handle * @ret rc Return status code */ int ( * supported ) ( EFI_HANDLE device ); /** * Attach driver to device * - * @v device Device + * @v efidev EFI device * @ret rc Return status code */ - int ( * start ) ( EFI_HANDLE device ); + int ( * start ) ( struct efi_device *efidev ); /** * Detach driver from device * - * @v device Device + * @v efidev EFI device */ - void ( * stop ) ( EFI_HANDLE device ); + void ( * stop ) ( struct efi_device *efidev ); }; /** EFI driver table */ @@ -48,8 +63,32 @@ struct efi_driver { #define EFI_DRIVER_NORMAL 02 /**< Normal drivers */ #define EFI_DRIVER_LATE 03 /**< Late drivers */ +/** + * Set EFI driver-private data + * + * @v efidev EFI device + * @v priv Private data + */ +static inline void efidev_set_drvdata ( struct efi_device *efidev, + void *priv ) { + efidev->priv = priv; +} + +/** + * Get EFI driver-private data + * + * @v efidev EFI device + * @ret priv Private data + */ +static inline void * efidev_get_drvdata ( struct efi_device *efidev ) { + return efidev->priv; +} + extern EFI_DEVICE_PATH_PROTOCOL * efi_devpath_end ( EFI_DEVICE_PATH_PROTOCOL *path ); +extern struct efi_device * efidev_parent ( struct device *dev ); +extern int efidev_child_add ( struct efi_device *efidev, EFI_HANDLE device ); +extern void efidev_child_del ( struct efi_device *efidev, EFI_HANDLE device ); extern int efi_driver_install ( void ); extern void efi_driver_uninstall ( void ); extern int efi_driver_connect_all ( void ); diff --git a/src/include/ipxe/efi/efi_pci.h b/src/include/ipxe/efi/efi_pci.h index c5ff366..af36613 100644 --- a/src/include/ipxe/efi/efi_pci.h +++ b/src/include/ipxe/efi/efi_pci.h @@ -8,40 +8,18 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include <ipxe/pci.h> #include <ipxe/efi/efi.h> #include <ipxe/efi/Protocol/PciIo.h> -#include <ipxe/efi/Protocol/DevicePath.h> /* PciRootBridgeIo.h uses LShiftU64(), which isn't defined anywhere else */ static inline EFIAPI uint64_t LShiftU64 ( UINT64 value, UINTN shift ) { return ( value << shift ); } -struct device; - -/** An EFI PCI device */ -struct efi_pci_device { - /** List of EFI PCI devices */ - struct list_head list; - /** iPXE PCI device */ - struct pci_device pci; - /** Underlying EFI device */ - EFI_HANDLE device; - /** PCI I/O protocol */ - EFI_PCI_IO_PROTOCOL *pci_io; - /** Device path */ - EFI_DEVICE_PATH_PROTOCOL *path; -}; - -extern int efipci_create ( EFI_HANDLE device, UINT32 attributes, - struct efi_pci_device **efipci ); -extern int efipci_enable ( struct efi_pci_device *efipci ); -extern struct efi_pci_device * efipci_find_efi ( EFI_HANDLE device ); -extern struct efi_pci_device * efipci_find ( struct device *dev ); -extern int efipci_child_add ( struct efi_pci_device *efipci, - EFI_HANDLE device ); -extern void efipci_child_del ( struct efi_pci_device *efipci, - EFI_HANDLE device ); -extern void efipci_destroy ( struct efi_pci_device *efipci ); +extern int efipci_open ( EFI_HANDLE device, UINT32 attributes, + struct pci_device *pci ); +extern void efipci_close ( EFI_HANDLE device ); +extern int efipci_info ( EFI_HANDLE device, struct pci_device *pci ); #endif /* _IPXE_EFI_PCI_H */ diff --git a/src/include/ipxe/efi/efi_snp.h b/src/include/ipxe/efi/efi_snp.h index a468165..06483cf 100644 --- a/src/include/ipxe/efi/efi_snp.h +++ b/src/include/ipxe/efi/efi_snp.h @@ -24,8 +24,8 @@ struct efi_snp_device { struct list_head list; /** The underlying iPXE network device */ struct net_device *netdev; - /** The underlying EFI PCI device */ - struct efi_pci_device *efipci; + /** The underlying EFI device */ + struct efi_device *efidev; /** EFI device handle */ EFI_HANDLE handle; /** The SNP structure itself */ @@ -76,6 +76,7 @@ struct efi_snp_device { extern int efi_snp_hii_install ( struct efi_snp_device *snpdev ); extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev ); +extern struct efi_snp_device * find_snpdev ( EFI_HANDLE handle ); extern struct efi_snp_device * last_opened_snpdev ( void ); extern void efi_snp_claim ( void ); extern void efi_snp_release ( void ); diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index e3b6b87..a8b3a8e 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -154,6 +154,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define ERRFILE_intel ( ERRFILE_DRIVER | 0x00650000 ) #define ERRFILE_myson ( ERRFILE_DRIVER | 0x00660000 ) #define ERRFILE_intelx ( ERRFILE_DRIVER | 0x00670000 ) +#define ERRFILE_snp ( ERRFILE_DRIVER | 0x00680000 ) #define ERRFILE_scsi ( ERRFILE_DRIVER | 0x00700000 ) #define ERRFILE_arbel ( ERRFILE_DRIVER | 0x00710000 ) |