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 );
27 #include <ipxe/efi/efi.h>
28 #include <ipxe/efi/efi_driver.h>
29 #include <ipxe/efi/efi_snp.h>
40 * Check to see if driver supports a device
42 * @v device EFI device handle
43 * @ret rc Return status code
45 static int snp_supported ( EFI_HANDLE device ) {
46 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
49 /* Check that this is not a device we are providing ourselves */
50 if ( find_snpdev ( device ) != NULL ) {
51 DBGCP ( device, "SNP %p %s is provided by this binary\n",
52 device, efi_handle_name ( device ) );
56 /* Test for presence of simple network protocol */
57 if ( ( efirc = bs->OpenProtocol ( device,
58 &efi_simple_network_protocol_guid,
59 NULL, efi_image_handle, device,
60 EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
61 DBGCP ( device, "SNP %p %s is not an SNP device\n",
62 device, efi_handle_name ( device ) );
63 return -EEFI ( efirc );
65 DBGC ( device, "SNP %p %s is an SNP device\n",
66 device, efi_handle_name ( device ) );
72 * Check to see if driver supports a device
74 * @v device EFI device handle
75 * @ret rc Return status code
77 static int nii_supported ( EFI_HANDLE device ) {
78 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
81 /* Check that this is not a device we are providing ourselves */
82 if ( find_snpdev ( device ) != NULL ) {
83 DBGCP ( device, "NII %p %s is provided by this binary\n",
84 device, efi_handle_name ( device ) );
88 /* Test for presence of NII protocol */
89 if ( ( efirc = bs->OpenProtocol ( device,
90 &efi_nii31_protocol_guid,
91 NULL, efi_image_handle, device,
92 EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
93 DBGCP ( device, "NII %p %s is not an NII device\n",
94 device, efi_handle_name ( device ) );
95 return -EEFI ( efirc );
97 DBGC ( device, "NII %p %s is an NII device\n",
98 device, efi_handle_name ( device ) );
103 /** EFI SNP driver */
104 struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
106 .supported = snp_supported,
107 .start = snpnet_start,
111 /** EFI NII driver */
112 struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
114 .supported = nii_supported,