Browse Source

[efi] Add EFI_COMPONENT_NAME2_PROTOCOL instance for each SNP device

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
7cf6c6bfed
2 changed files with 75 additions and 0 deletions
  1. 7
    0
      src/include/ipxe/efi/efi_snp.h
  2. 68
    0
      src/interface/efi/efi_snp.c

+ 7
- 0
src/include/ipxe/efi/efi_snp.h View File

12
 #include <ipxe/efi/efi.h>
12
 #include <ipxe/efi/efi.h>
13
 #include <ipxe/efi/Protocol/SimpleNetwork.h>
13
 #include <ipxe/efi/Protocol/SimpleNetwork.h>
14
 #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
14
 #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
15
+#include <ipxe/efi/Protocol/ComponentName2.h>
15
 #include <ipxe/efi/Protocol/DevicePath.h>
16
 #include <ipxe/efi/Protocol/DevicePath.h>
16
 #include <ipxe/efi/Protocol/HiiConfigAccess.h>
17
 #include <ipxe/efi/Protocol/HiiConfigAccess.h>
17
 #include <ipxe/efi/Protocol/HiiDatabase.h>
18
 #include <ipxe/efi/Protocol/HiiDatabase.h>
46
 	unsigned int rx_count_events;
47
 	unsigned int rx_count_events;
47
 	/** The network interface identifier */
48
 	/** The network interface identifier */
48
 	EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii;
49
 	EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL nii;
50
+	/** Component name protocol */
51
+	EFI_COMPONENT_NAME2_PROTOCOL name2;
49
 	/** HII configuration access protocol */
52
 	/** HII configuration access protocol */
50
 	EFI_HII_CONFIG_ACCESS_PROTOCOL hii;
53
 	EFI_HII_CONFIG_ACCESS_PROTOCOL hii;
51
 	/** HII package list */
54
 	/** HII package list */
54
 	EFI_HII_HANDLE hii_handle;
57
 	EFI_HII_HANDLE hii_handle;
55
 	/** Device name */
58
 	/** Device name */
56
 	wchar_t name[ sizeof ( ( ( struct net_device * ) NULL )->name ) ];
59
 	wchar_t name[ sizeof ( ( ( struct net_device * ) NULL )->name ) ];
60
+	/** Driver name */
61
+	wchar_t driver_name[16];
62
+	/** Controller name */
63
+	wchar_t controller_name[32];
57
 	/** The device path
64
 	/** The device path
58
 	 *
65
 	 *
59
 	 * This field is variable in size and must appear at the end
66
 	 * This field is variable in size and must appear at the end

+ 68
- 0
src/interface/efi/efi_snp.c View File

56
 	{ 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 }
56
 	{ 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 }
57
 };
57
 };
58
 
58
 
59
+/** EFI component name protocol */
60
+static EFI_GUID efi_component_name2_protocol_guid
61
+	= EFI_COMPONENT_NAME2_PROTOCOL_GUID;
62
+
59
 /** List of SNP devices */
63
 /** List of SNP devices */
60
 static LIST_HEAD ( efi_snp_devices );
64
 static LIST_HEAD ( efi_snp_devices );
61
 
65
 
701
 	.Receive	= efi_snp_receive,
705
 	.Receive	= efi_snp_receive,
702
 };
706
 };
703
 
707
 
708
+/******************************************************************************
709
+ *
710
+ * Component name protocol
711
+ *
712
+ ******************************************************************************
713
+ */
714
+
715
+/**
716
+ * Look up driver name
717
+ *
718
+ * @v name2		Component name protocol
719
+ * @v language		Language to use
720
+ * @v driver_name	Driver name to fill in
721
+ * @ret efirc		EFI status code
722
+ */
723
+static EFI_STATUS EFIAPI
724
+efi_snp_get_driver_name ( EFI_COMPONENT_NAME2_PROTOCOL *name2,
725
+			  CHAR8 *language __unused, CHAR16 **driver_name ) {
726
+	struct efi_snp_device *snpdev =
727
+		container_of ( name2, struct efi_snp_device, name2 );
728
+
729
+	*driver_name = snpdev->driver_name;
730
+	return 0;
731
+}
732
+
733
+/**
734
+ * Look up controller name
735
+ *
736
+ * @v name2     		Component name protocol
737
+ * @v device		Device
738
+ * @v child		Child device, or NULL
739
+ * @v language		Language to use
740
+ * @v driver_name	Device name to fill in
741
+ * @ret efirc		EFI status code
742
+ */
743
+static EFI_STATUS EFIAPI
744
+efi_snp_get_controller_name ( EFI_COMPONENT_NAME2_PROTOCOL *name2,
745
+			      EFI_HANDLE device __unused,
746
+			      EFI_HANDLE child __unused,
747
+			      CHAR8 *language __unused,
748
+			      CHAR16 **controller_name ) {
749
+	struct efi_snp_device *snpdev =
750
+		container_of ( name2, struct efi_snp_device, name2 );
751
+
752
+	*controller_name = snpdev->controller_name;
753
+	return 0;
754
+}
755
+
704
 /******************************************************************************
756
 /******************************************************************************
705
  *
757
  *
706
  * iPXE network driver
758
  * iPXE network driver
794
 	strncpy ( snpdev->nii.StringId, "iPXE",
846
 	strncpy ( snpdev->nii.StringId, "iPXE",
795
 		  sizeof ( snpdev->nii.StringId ) );
847
 		  sizeof ( snpdev->nii.StringId ) );
796
 
848
 
849
+	/* Populate the component name structure */
850
+	efi_snprintf ( snpdev->driver_name,
851
+		       ( sizeof ( snpdev->driver_name ) /
852
+			 sizeof ( snpdev->driver_name[0] ) ), "%s",
853
+		       netdev->dev->driver_name );
854
+	efi_snprintf ( snpdev->controller_name,
855
+		       ( sizeof ( snpdev->controller_name ) /
856
+			 sizeof ( snpdev->controller_name[0] ) ), "%s (%s)",
857
+		       netdev->name, netdev_addr ( netdev ) );
858
+	snpdev->name2.GetDriverName = efi_snp_get_driver_name;
859
+	snpdev->name2.GetControllerName = efi_snp_get_controller_name;
860
+	snpdev->name2.SupportedLanguages = "en";
861
+
797
 	/* Populate the device name */
862
 	/* Populate the device name */
798
 	efi_snprintf ( snpdev->name, ( sizeof ( snpdev->name ) /
863
 	efi_snprintf ( snpdev->name, ( sizeof ( snpdev->name ) /
799
 				       sizeof ( snpdev->name[0] ) ),
864
 				       sizeof ( snpdev->name[0] ) ),
822
 			&efi_device_path_protocol_guid, &snpdev->path,
887
 			&efi_device_path_protocol_guid, &snpdev->path,
823
 			&efi_nii_protocol_guid, &snpdev->nii,
888
 			&efi_nii_protocol_guid, &snpdev->nii,
824
 			&efi_nii31_protocol_guid, &snpdev->nii,
889
 			&efi_nii31_protocol_guid, &snpdev->nii,
890
+			&efi_component_name2_protocol_guid, &snpdev->name2,
825
 			NULL ) ) != 0 ) {
891
 			NULL ) ) != 0 ) {
826
 		DBGC ( snpdev, "SNPDEV %p could not install protocols: "
892
 		DBGC ( snpdev, "SNPDEV %p could not install protocols: "
827
 		       "%s\n", snpdev, efi_strerror ( efirc ) );
893
 		       "%s\n", snpdev, efi_strerror ( efirc ) );
862
 			&efi_device_path_protocol_guid, &snpdev->path,
928
 			&efi_device_path_protocol_guid, &snpdev->path,
863
 			&efi_nii_protocol_guid, &snpdev->nii,
929
 			&efi_nii_protocol_guid, &snpdev->nii,
864
 			&efi_nii31_protocol_guid, &snpdev->nii,
930
 			&efi_nii31_protocol_guid, &snpdev->nii,
931
+			&efi_component_name2_protocol_guid, &snpdev->name2,
865
 			NULL );
932
 			NULL );
866
  err_install_protocol_interface:
933
  err_install_protocol_interface:
867
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
934
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
922
 			&efi_device_path_protocol_guid, &snpdev->path,
989
 			&efi_device_path_protocol_guid, &snpdev->path,
923
 			&efi_nii_protocol_guid, &snpdev->nii,
990
 			&efi_nii_protocol_guid, &snpdev->nii,
924
 			&efi_nii31_protocol_guid, &snpdev->nii,
991
 			&efi_nii31_protocol_guid, &snpdev->nii,
992
+			&efi_component_name2_protocol_guid, &snpdev->name2,
925
 			NULL );
993
 			NULL );
926
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
994
 	bs->CloseEvent ( snpdev->snp.WaitForPacket );
927
 	netdev_put ( snpdev->netdev );
995
 	netdev_put ( snpdev->netdev );

Loading…
Cancel
Save