You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

efi_snp.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _IPXE_EFI_SNP_H
  2. #define _IPXE_EFI_SNP_H
  3. /** @file
  4. *
  5. * iPXE EFI SNP interface
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <ipxe/list.h>
  10. #include <ipxe/netdevice.h>
  11. #include <ipxe/efi/efi.h>
  12. #include <ipxe/efi/Protocol/SimpleNetwork.h>
  13. #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
  14. #include <ipxe/efi/Protocol/ComponentName2.h>
  15. #include <ipxe/efi/Protocol/DevicePath.h>
  16. #include <ipxe/efi/Protocol/HiiConfigAccess.h>
  17. #include <ipxe/efi/Protocol/HiiDatabase.h>
  18. #include <ipxe/efi/Protocol/LoadFile.h>
  19. /** SNP transmit completion ring size */
  20. #define EFI_SNP_NUM_TX 32
  21. /** An SNP device */
  22. struct efi_snp_device {
  23. /** List of SNP devices */
  24. struct list_head list;
  25. /** The underlying iPXE network device */
  26. struct net_device *netdev;
  27. /** The underlying EFI device */
  28. struct efi_device *efidev;
  29. /** EFI device handle */
  30. EFI_HANDLE handle;
  31. /** The SNP structure itself */
  32. EFI_SIMPLE_NETWORK_PROTOCOL snp;
  33. /** The SNP "mode" (parameters) */
  34. EFI_SIMPLE_NETWORK_MODE mode;
  35. /** Started flag */
  36. int started;
  37. /** Pending interrupt status */
  38. unsigned int interrupts;
  39. /** Transmit completion ring */
  40. VOID *tx[EFI_SNP_NUM_TX];
  41. /** Transmit completion ring producer counter */
  42. unsigned int tx_prod;
  43. /** Transmit completion ring consumer counter */
  44. unsigned int tx_cons;
  45. /** Receive queue */
  46. struct list_head rx;
  47. /** The network interface identifier */
  48. EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii;
  49. /** Component name protocol */
  50. EFI_COMPONENT_NAME2_PROTOCOL name2;
  51. /** Load file protocol handle */
  52. EFI_LOAD_FILE_PROTOCOL load_file;
  53. /** HII configuration access protocol */
  54. EFI_HII_CONFIG_ACCESS_PROTOCOL hii;
  55. /** HII package list */
  56. EFI_HII_PACKAGE_LIST_HEADER *package_list;
  57. /** EFI child handle for HII association */
  58. EFI_HANDLE hii_child_handle;
  59. /** Device path of HII child handle */
  60. EFI_DEVICE_PATH_PROTOCOL *hii_child_path;
  61. /** HII handle */
  62. EFI_HII_HANDLE hii_handle;
  63. /** Device name */
  64. wchar_t name[ sizeof ( ( ( struct net_device * ) NULL )->name ) ];
  65. /** Driver name */
  66. wchar_t driver_name[16];
  67. /** Controller name */
  68. wchar_t controller_name[64];
  69. /** The device path */
  70. EFI_DEVICE_PATH_PROTOCOL *path;
  71. };
  72. extern int efi_snp_hii_install ( struct efi_snp_device *snpdev );
  73. extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev );
  74. extern struct efi_snp_device * find_snpdev ( EFI_HANDLE handle );
  75. extern struct efi_snp_device * last_opened_snpdev ( void );
  76. extern void efi_snp_add_claim ( int delta );
  77. /**
  78. * Claim network devices for use by iPXE
  79. *
  80. */
  81. static inline void efi_snp_claim ( void ) {
  82. efi_snp_add_claim ( +1 );
  83. }
  84. /**
  85. * Release network devices for use via SNP
  86. *
  87. */
  88. static inline void efi_snp_release ( void ) {
  89. efi_snp_add_claim ( -1 );
  90. }
  91. #endif /* _IPXE_EFI_SNP_H */