You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

snp.c 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <errno.h>
  21. #include <ipxe/efi/efi.h>
  22. #include <ipxe/efi/Protocol/SimpleNetwork.h>
  23. #include <ipxe/efi/efi_driver.h>
  24. #include <ipxe/efi/efi_snp.h>
  25. #include "snpnet.h"
  26. /** @file
  27. *
  28. * SNP driver
  29. *
  30. */
  31. /** EFI simple network protocol GUID */
  32. static EFI_GUID efi_simple_network_protocol_guid
  33. = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
  34. /**
  35. * Check to see if driver supports a device
  36. *
  37. * @v device EFI device handle
  38. * @ret rc Return status code
  39. */
  40. static int snp_supported ( EFI_HANDLE device ) {
  41. EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
  42. EFI_STATUS efirc;
  43. /* Check that this is not a device we are providing ourselves */
  44. if ( find_snpdev ( device ) != NULL ) {
  45. DBGCP ( device, "SNP %p %s is provided by this binary\n",
  46. device, efi_handle_name ( device ) );
  47. return -ENOTTY;
  48. }
  49. /* Test for presence of simple network protocol */
  50. if ( ( efirc = bs->OpenProtocol ( device,
  51. &efi_simple_network_protocol_guid,
  52. NULL, efi_image_handle, device,
  53. EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
  54. DBGCP ( device, "SNP %p %s is not an SNP device\n",
  55. device, efi_handle_name ( device ) );
  56. return -EEFI ( efirc );
  57. }
  58. DBGC ( device, "SNP %p %s is an SNP device\n",
  59. device, efi_handle_name ( device ) );
  60. return 0;
  61. }
  62. /** EFI SNP driver */
  63. struct efi_driver snp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
  64. .name = "SNP",
  65. .supported = snp_supported,
  66. .start = snpnet_start,
  67. .stop = snpnet_stop,
  68. };