<commit_before>/** @file
  Entry point to a EFI/DXE driver.

Copyright (c) 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

/**
  Unload function that is registered in the LoadImage protocol.  It un-installs
  protocols produced and deallocates pool used by the driver.  Called by the core
  when unloading the driver.

  @param  ImageHandle

  @retval EFI_SUCCESS

**/

EFI_EVENT  _mDriverExitBootServicesNotifyEvent;

EFI_STATUS
EFIAPI
_DriverUnloadHandler (
  EFI_HANDLE ImageHandle
  )
{
  EFI_STATUS  Status;

  //
  // If an UnloadImage() handler is specified, then call it
  //
  Status = ProcessModuleUnloadList (ImageHandle);

  //
  // If the driver specific unload handler does not return an error, then call all of the
  // library destructors.  If the unload handler returned an error, then the driver can not be
  // unloaded, and the library destructors should not be called
  //
  if (!EFI_ERROR (Status)) {
    //
    // Close our ExitBootServices () notify function
    //
    if (_gDriverExitBootServicesEvent[0] != NULL) {
      Status = gBS->CloseEvent (_mDriverExitBootServicesNotifyEvent);
      ASSERT_EFI_ERROR (Status);
    }

    ProcessLibraryDestructorList (ImageHandle, gST);
  }

  //
  // Return the status from the driver specific unload handler
  //
  return Status;
}

VOID
EFIAPI
_DriverExitBootServices (
  IN EFI_EVENT        Event,
  IN VOID             *Context
  )
/*++

Routine Description:

  Set AtRuntime flag as TRUE after ExitBootServices

Arguments:

  Event   - The Event that is being processed
  
  Context - Event Context

Returns: 

  None

--*/
{
  EFI_EVENT_NOTIFY  ChildNotifyEventHandler;
  UINTN             Index;

  for (Index = 0; _gDriverExitBootServicesEvent[Index] != NULL; Index++) {
    ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index];
    ChildNotifyEventHandler (Event, NULL);
  }<commit_msg>Updated the function comments in UefiDriverEntryLib to fix EDKT502.<commit_after>/** @file
  Entry point to a EFI/DXE driver.

Copyright (c) 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/


EFI_EVENT  _mDriverExitBootServicesNotifyEvent;

/**
  Unload function that is registered in the LoadImage protocol.  It un-installs
  protocols produced and deallocates pool used by the driver.  Called by the core
  when unloading the driver.

  @param  ImageHandle

  @retval EFI_SUCCESS

**/
EFI_STATUS
EFIAPI
_DriverUnloadHandler (
  EFI_HANDLE ImageHandle
  )
{
  EFI_STATUS  Status;

  //
  // If an UnloadImage() handler is specified, then call it
  //
  Status = ProcessModuleUnloadList (ImageHandle);

  //
  // If the driver specific unload handler does not return an error, then call all of the
  // library destructors.  If the unload handler returned an error, then the driver can not be
  // unloaded, and the library destructors should not be called
  //
  if (!EFI_ERROR (Status)) {
    //
    // Close our ExitBootServices () notify function
    //
    if (_gDriverExitBootServicesEvent[0] != NULL) {
      Status = gBS->CloseEvent (_mDriverExitBootServicesNotifyEvent);
      ASSERT_EFI_ERROR (Status);
    }

    ProcessLibraryDestructorList (ImageHandle, gST);
  }

  //
  // Return the status from the driver specific unload handler
  //
  return Status;
}


/**
  Notification Entry of ExitBootService event. In the entry, all notifications in _gDriverExitBootServicesEvent[] 
  would be invoked.

  @param Event   The Event that is being processed.
  @param Context Event Context.

**/
VOID
EFIAPI
_DriverExitBootServices (
  IN EFI_EVENT        Event,
  IN VOID             *Context
  )
{
  EFI_EVENT_NOTIFY  ChildNotifyEventHandler;
  UINTN             Index;

  for (Index = 0; _gDriverExitBootServicesEvent[Index] != NULL; Index++) {
    ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index];
    ChildNotifyEventHandler (Event, NULL);
  }
{'fraction_non_alphanumeric': 0.06969761955822432, 'fraction_numerical': 0.0032168132103795838, 'mean_word_length': 3.450381679389313, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6032780', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1336, 'n_words': 501}