SnpStart.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /** @file
  2. Implementation of the SNP.Start() function and its private helpers if any.
  3. Copyright (C) 2013, Red Hat, Inc.
  4. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <Library/UefiBootServicesTableLib.h>
  8. #include "VirtioNet.h"
  9. /**
  10. Changes the state of a network interface from "stopped" to "started".
  11. @param This Protocol instance pointer.
  12. @retval EFI_SUCCESS The network interface was started.
  13. @retval EFI_ALREADY_STARTED The network interface is already in the started
  14. state.
  15. @retval EFI_INVALID_PARAMETER One or more of the parameters has an
  16. unsupported value.
  17. @retval EFI_DEVICE_ERROR The command could not be sent to the network
  18. interface.
  19. @retval EFI_UNSUPPORTED This function is not supported by the network
  20. interface.
  21. **/
  22. EFI_STATUS
  23. EFIAPI
  24. VirtioNetStart (
  25. IN EFI_SIMPLE_NETWORK_PROTOCOL *This
  26. )
  27. {
  28. VNET_DEV *Dev;
  29. EFI_TPL OldTpl;
  30. EFI_STATUS Status;
  31. if (This == NULL) {
  32. return EFI_INVALID_PARAMETER;
  33. }
  34. Dev = VIRTIO_NET_FROM_SNP (This);
  35. OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  36. if (Dev->Snm.State != EfiSimpleNetworkStopped) {
  37. Status = EFI_ALREADY_STARTED;
  38. } else {
  39. Dev->Snm.State = EfiSimpleNetworkStarted;
  40. Status = EFI_SUCCESS;
  41. }
  42. gBS->RestoreTPL (OldTpl);
  43. return Status;
  44. }