iPXE
efi_snp.h
Go to the documentation of this file.
00001 #ifndef _IPXE_EFI_SNP_H
00002 #define _IPXE_EFI_SNP_H
00003 
00004 /** @file
00005  *
00006  * iPXE EFI SNP interface
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011 
00012 #include <ipxe/list.h>
00013 #include <ipxe/netdevice.h>
00014 #include <ipxe/efi/efi.h>
00015 #include <ipxe/efi/Protocol/SimpleNetwork.h>
00016 #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
00017 #include <ipxe/efi/Protocol/ComponentName2.h>
00018 #include <ipxe/efi/Protocol/DevicePath.h>
00019 #include <ipxe/efi/Protocol/HiiConfigAccess.h>
00020 #include <ipxe/efi/Protocol/HiiDatabase.h>
00021 #include <ipxe/efi/Protocol/LoadFile.h>
00022 
00023 /** SNP transmit completion ring size */
00024 #define EFI_SNP_NUM_TX 32
00025 
00026 /** An SNP device */
00027 struct efi_snp_device {
00028         /** List of SNP devices */
00029         struct list_head list;
00030         /** The underlying iPXE network device */
00031         struct net_device *netdev;
00032         /** The underlying EFI device */
00033         struct efi_device *efidev;
00034         /** EFI device handle */
00035         EFI_HANDLE handle;
00036         /** The SNP structure itself */
00037         EFI_SIMPLE_NETWORK_PROTOCOL snp;
00038         /** The SNP "mode" (parameters) */
00039         EFI_SIMPLE_NETWORK_MODE mode;
00040         /** Started flag */
00041         int started;
00042         /** Pending interrupt status */
00043         unsigned int interrupts;
00044         /** Transmit completion ring */
00045         VOID *tx[EFI_SNP_NUM_TX];
00046         /** Transmit completion ring producer counter */
00047         unsigned int tx_prod;
00048         /** Transmit completion ring consumer counter */
00049         unsigned int tx_cons;
00050         /** Receive queue */
00051         struct list_head rx;
00052         /** The network interface identifier */
00053         EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii;
00054         /** Component name protocol */
00055         EFI_COMPONENT_NAME2_PROTOCOL name2;
00056         /** Load file protocol handle */
00057         EFI_LOAD_FILE_PROTOCOL load_file;
00058         /** HII configuration access protocol */
00059         EFI_HII_CONFIG_ACCESS_PROTOCOL hii;
00060         /** HII package list */
00061         EFI_HII_PACKAGE_LIST_HEADER *package_list;
00062         /** EFI child handle for HII association */
00063         EFI_HANDLE hii_child_handle;
00064         /** Device path of HII child handle */
00065         EFI_DEVICE_PATH_PROTOCOL *hii_child_path;
00066         /** HII handle */
00067         EFI_HII_HANDLE hii_handle;
00068         /** Device name */
00069         wchar_t name[ sizeof ( ( ( struct net_device * ) NULL )->name ) ];
00070         /** Driver name */
00071         wchar_t driver_name[16];
00072         /** Controller name */
00073         wchar_t controller_name[64];
00074         /** The device path */
00075         EFI_DEVICE_PATH_PROTOCOL *path;
00076 };
00077 
00078 extern int efi_snp_hii_install ( struct efi_snp_device *snpdev );
00079 extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev );
00080 extern struct efi_snp_device * find_snpdev ( EFI_HANDLE handle );
00081 extern struct efi_snp_device * last_opened_snpdev ( void );
00082 extern void efi_snp_add_claim ( int delta );
00083 
00084 /**
00085  * Claim network devices for use by iPXE
00086  *
00087  */
00088 static inline void efi_snp_claim ( void ) {
00089         efi_snp_add_claim ( +1 );
00090 }
00091 
00092 /**
00093  * Release network devices for use via SNP
00094  *
00095  */
00096 static inline void efi_snp_release ( void ) {
00097         efi_snp_add_claim ( -1 );
00098 }
00099 
00100 #endif /* _IPXE_EFI_SNP_H */