2 * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL
);
29 #include <ipxe/efi/efi.h>
30 #include <ipxe/efi/efi_driver.h>
31 #include <ipxe/efi/efi_snp.h>
42 * Check to see if driver supports a device
44 * @v device EFI device handle
45 * @ret rc Return status code
47 static int snp_supported ( EFI_HANDLE device
) {
48 EFI_BOOT_SERVICES
*bs
= efi_systab
->BootServices
;
51 /* Check that this is not a device we are providing ourselves */
52 if ( find_snpdev ( device
) != NULL
) {
53 DBGCP ( device
, "SNP %s is provided by this binary\n",
54 efi_handle_name ( device
) );
58 /* Test for presence of simple network protocol */
59 if ( ( efirc
= bs
->OpenProtocol ( device
,
60 &efi_simple_network_protocol_guid
,
61 NULL
, efi_image_handle
, device
,
62 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
))!=0){
63 DBGCP ( device
, "SNP %s is not an SNP device\n",
64 efi_handle_name ( device
) );
65 return -EEFI ( efirc
);
67 DBGC ( device
, "SNP %s is an SNP device\n",
68 efi_handle_name ( device
) );
74 * Check to see if driver supports a device
76 * @v device EFI device handle
77 * @ret rc Return status code
79 static int nii_supported ( EFI_HANDLE device
) {
80 EFI_BOOT_SERVICES
*bs
= efi_systab
->BootServices
;
83 /* Check that this is not a device we are providing ourselves */
84 if ( find_snpdev ( device
) != NULL
) {
85 DBGCP ( device
, "NII %s is provided by this binary\n",
86 efi_handle_name ( device
) );
90 /* Test for presence of NII protocol */
91 if ( ( efirc
= bs
->OpenProtocol ( device
,
92 &efi_nii31_protocol_guid
,
93 NULL
, efi_image_handle
, device
,
94 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
))!=0){
95 DBGCP ( device
, "NII %s is not an NII device\n",
96 efi_handle_name ( device
) );
97 return -EEFI ( efirc
);
99 DBGC ( device
, "NII %s is an NII device\n",
100 efi_handle_name ( device
) );
105 /** EFI SNP driver */
106 struct efi_driver snp_driver
__efi_driver ( EFI_DRIVER_NORMAL
) = {
108 .supported
= snp_supported
,
109 .start
= snpnet_start
,
113 /** EFI NII driver */
114 struct efi_driver nii_driver
__efi_driver ( EFI_DRIVER_NORMAL
) = {
116 .supported
= nii_supported
,