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
20 FILE_LICENCE ( GPL2_OR_LATER );
23 #include <ipxe/efi/efi.h>
24 #include <ipxe/efi/efi_driver.h>
25 #include <ipxe/efi/efi_snp.h>
36 * Check to see if driver supports a device
38 * @v device EFI device handle
39 * @ret rc Return status code
41 static int snp_supported ( EFI_HANDLE device ) {
42 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
45 /* Check that this is not a device we are providing ourselves */
46 if ( find_snpdev ( device ) != NULL ) {
47 DBGCP ( device, "SNP %p %s is provided by this binary\n",
48 device, efi_handle_name ( device ) );
52 /* Test for presence of simple network protocol */
53 if ( ( efirc = bs->OpenProtocol ( device,
54 &efi_simple_network_protocol_guid,
55 NULL, efi_image_handle, device,
56 EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
57 DBGCP ( device, "SNP %p %s is not an SNP device\n",
58 device, efi_handle_name ( device ) );
59 return -EEFI ( efirc );
61 DBGC ( device, "SNP %p %s is an SNP device\n",
62 device, efi_handle_name ( device ) );
68 * Check to see if driver supports a device
70 * @v device EFI device handle
71 * @ret rc Return status code
73 static int nii_supported ( EFI_HANDLE device ) {
74 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
77 /* Check that this is not a device we are providing ourselves */
78 if ( find_snpdev ( device ) != NULL ) {
79 DBGCP ( device, "NII %p %s is provided by this binary\n",
80 device, efi_handle_name ( device ) );
84 /* Test for presence of NII protocol */
85 if ( ( efirc = bs->OpenProtocol ( device,
86 &efi_nii31_protocol_guid,
87 NULL, efi_image_handle, device,
88 EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
89 DBGCP ( device, "NII %p %s is not an NII device\n",
90 device, efi_handle_name ( device ) );
91 return -EEFI ( efirc );
93 DBGC ( device, "NII %p %s is an NII device\n",
94 device, efi_handle_name ( device ) );
100 struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
102 .supported = snp_supported,
103 .start = snpnet_start,
107 /** EFI NII driver */
108 struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
110 .supported = nii_supported,