]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IPXE/ipxe_mod_code/ipxe-3fe683e/src/drivers/net/efi/snp.c
1. change some directory structure for the build script
[Ventoy.git] / IPXE / ipxe_mod_code / ipxe-3fe683e / src / drivers / net / efi / snp.c
1 /*
2 * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3 *
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.
8 *
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.
13 *
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
17 * 02110-1301, USA.
18 *
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.
22 */
23
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
26 #if 0
27
28 #include <errno.h>
29 #include <ipxe/efi/efi.h>
30 #include <ipxe/efi/efi_driver.h>
31 #include <ipxe/efi/efi_snp.h>
32 #include "snpnet.h"
33 #include "nii.h"
34
35 /** @file
36 *
37 * SNP driver
38 *
39 */
40
41 /**
42 * Check to see if driver supports a device
43 *
44 * @v device EFI device handle
45 * @ret rc Return status code
46 */
47 static int snp_supported ( EFI_HANDLE device ) {
48 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
49 EFI_STATUS efirc;
50
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 ) );
55 return -ENOTTY;
56 }
57
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 );
66 }
67 DBGC ( device, "SNP %s is an SNP device\n",
68 efi_handle_name ( device ) );
69
70 return 0;
71 }
72
73 /**
74 * Check to see if driver supports a device
75 *
76 * @v device EFI device handle
77 * @ret rc Return status code
78 */
79 static int nii_supported ( EFI_HANDLE device ) {
80 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
81 EFI_STATUS efirc;
82
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 ) );
87 return -ENOTTY;
88 }
89
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 );
98 }
99 DBGC ( device, "NII %s is an NII device\n",
100 efi_handle_name ( device ) );
101
102 return 0;
103 }
104
105 /** EFI SNP driver */
106 struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
107 .name = "SNP",
108 .supported = snp_supported,
109 .start = snpnet_start,
110 .stop = snpnet_stop,
111 };
112
113 /** EFI NII driver */
114 struct efi_driver nii_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
115 .name = "NII",
116 .supported = nii_supported,
117 .start = nii_start,
118 .stop = nii_stop,
119 };
120
121 #endif
122