StandaloneMmDriverEntryPoint.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /** @file
  2. Entry point to a Standalone MM driver.
  3. Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
  4. Copyright (c) 2016 - 2018, ARM Ltd. All rights reserved.<BR>
  5. This program and the accompanying materials
  6. are licensed and made available under the terms and conditions of the BSD License
  7. which accompanies this distribution. The full text of the license may be found at
  8. http://opensource.org/licenses/bsd-license.php
  9. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  11. **/
  12. #include <PiMm.h>
  13. #include <Library/BaseLib.h>
  14. #include <Library/DebugLib.h>
  15. VOID
  16. EFIAPI
  17. ProcessLibraryConstructorList (
  18. IN EFI_HANDLE ImageHandle,
  19. IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
  20. );
  21. EFI_STATUS
  22. EFIAPI
  23. ProcessModuleEntryPointList (
  24. IN EFI_HANDLE ImageHandle,
  25. IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
  26. );
  27. VOID
  28. EFIAPI
  29. ProcessLibraryDestructorList (
  30. IN EFI_HANDLE ImageHandle,
  31. IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
  32. );
  33. /**
  34. The entry point of PE/COFF Image for a Standalone MM Driver.
  35. This function is the entry point for a Standalone MM Driver.
  36. This function must call ProcessLibraryConstructorList() and
  37. ProcessModuleEntryPointList().
  38. If the return status from ProcessModuleEntryPointList()
  39. is an error status, then ProcessLibraryDestructorList() must be called.
  40. The return value from ProcessModuleEntryPointList() is returned.
  41. If _gDriverUnloadImageCount is greater than zero, then an unload
  42. handler must be registered for this image
  43. and the unload handler must invoke ProcessModuleUnloadList().
  44. If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less
  45. than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.
  46. @param ImageHandle The image handle of the Standalone MM Driver.
  47. @param SystemTable A pointer to the EFI System Table.
  48. @retval EFI_SUCCESS The Standalone MM Driver exited normally.
  49. @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than
  50. SystemTable->Hdr.Revision.
  51. @retval Other Return value from ProcessModuleEntryPointList().
  52. **/
  53. EFI_STATUS
  54. EFIAPI
  55. _ModuleEntryPoint (
  56. IN EFI_HANDLE ImageHandle,
  57. IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
  58. )
  59. {
  60. EFI_STATUS Status;
  61. //
  62. // Call constructor for all libraries
  63. //
  64. ProcessLibraryConstructorList (ImageHandle, MmSystemTable);
  65. //
  66. // Call the driver entry point
  67. //
  68. Status = ProcessModuleEntryPointList (ImageHandle, MmSystemTable);
  69. //
  70. // If all of the drivers returned errors, then invoke all of the library destructors
  71. //
  72. if (EFI_ERROR (Status)) {
  73. ProcessLibraryDestructorList (ImageHandle, MmSystemTable);
  74. }
  75. //
  76. // Return the cumulative return status code from all of the driver entry points
  77. //
  78. return Status;
  79. }