andrewfish | 949f388 | 2011-05-11 18:31:20 +0000 | [diff] [blame] | 1 | /*++ @file
|
| 2 | Reset Architectural Protocol as defined in UEFI/PI under Emulation
|
| 3 |
|
| 4 | Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
|
| 5 | Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
|
jljusten | d18d8a1 | 2011-06-28 16:50:26 +0000 | [diff] [blame] | 6 | This program and the accompanying materials
|
| 7 | are licensed and made available under the terms and conditions of the BSD License
|
| 8 | which accompanies this distribution. The full text of the license may be found at
|
| 9 | http://opensource.org/licenses/bsd-license.php
|
| 10 |
|
| 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
| 12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
andrewfish | 949f388 | 2011-05-11 18:31:20 +0000 | [diff] [blame] | 13 |
|
| 14 | **/
|
| 15 |
|
| 16 | #include <PiDxe.h>
|
| 17 |
|
| 18 | #include <Library/BaseLib.h>
|
| 19 | #include <Library/DebugLib.h>
|
| 20 | #include <Library/UefiLib.h>
|
| 21 | #include <Library/UefiDriverEntryPoint.h>
|
| 22 | #include <Library/MemoryAllocationLib.h>
|
| 23 | #include <Library/UefiBootServicesTableLib.h>
|
| 24 | #include <Library/EmuThunkLib.h>
|
| 25 |
|
| 26 | #include <Protocol/Reset.h>
|
| 27 |
|
| 28 |
|
| 29 | VOID
|
| 30 | EFIAPI
|
| 31 | EmuResetSystem (
|
| 32 | IN EFI_RESET_TYPE ResetType,
|
| 33 | IN EFI_STATUS ResetStatus,
|
| 34 | IN UINTN DataSize,
|
| 35 | IN VOID *ResetData OPTIONAL
|
| 36 | )
|
| 37 | {
|
| 38 | EFI_STATUS Status;
|
| 39 | UINTN HandleCount;
|
| 40 | EFI_HANDLE *HandleBuffer;
|
| 41 | UINTN Index;
|
| 42 |
|
| 43 | //
|
| 44 | // Disconnect all
|
| 45 | //
|
| 46 | Status = gBS->LocateHandleBuffer (
|
| 47 | AllHandles,
|
| 48 | NULL,
|
| 49 | NULL,
|
| 50 | &HandleCount,
|
| 51 | &HandleBuffer
|
| 52 | );
|
| 53 | if (!EFI_ERROR (Status)) {
|
| 54 | for (Index = 0; Index < HandleCount; Index++) {
|
| 55 | Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
| 56 | }
|
jljusten | d18d8a1 | 2011-06-28 16:50:26 +0000 | [diff] [blame] | 57 |
|
andrewfish | 949f388 | 2011-05-11 18:31:20 +0000 | [diff] [blame] | 58 | gBS->FreePool (HandleBuffer);
|
| 59 | }
|
| 60 |
|
| 61 |
|
| 62 | //
|
| 63 | // Discard ResetType, always return 0 as exit code
|
| 64 | //
|
| 65 | gEmuThunk->Exit (0);
|
| 66 |
|
| 67 | //
|
| 68 | // Should never go here
|
| 69 | //
|
| 70 | ASSERT (FALSE);
|
| 71 |
|
| 72 | return;
|
| 73 | }
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 | EFI_STATUS
|
| 78 | EFIAPI
|
| 79 | InitializeEmuReset (
|
| 80 | IN EFI_HANDLE ImageHandle,
|
| 81 | IN EFI_SYSTEM_TABLE *SystemTable
|
| 82 | )
|
| 83 | /*++
|
| 84 |
|
| 85 | Routine Description:
|
| 86 |
|
| 87 |
|
| 88 | Arguments:
|
| 89 |
|
| 90 | ImageHandle of the loaded driver
|
| 91 | Pointer to the System Table
|
| 92 |
|
| 93 | Returns:
|
| 94 |
|
| 95 | Status
|
| 96 | **/
|
| 97 | {
|
| 98 | EFI_STATUS Status;
|
| 99 | EFI_HANDLE Handle;
|
| 100 |
|
| 101 | SystemTable->RuntimeServices->ResetSystem = EmuResetSystem;
|
| 102 |
|
| 103 | Handle = NULL;
|
| 104 | Status = gBS->InstallMultipleProtocolInterfaces (
|
| 105 | &Handle,
|
| 106 | &gEfiResetArchProtocolGuid,
|
| 107 | NULL,
|
| 108 | NULL
|
| 109 | );
|
| 110 | ASSERT_EFI_ERROR (Status);
|
| 111 |
|
| 112 | return Status;
|
| 113 | }
|
| 114 |
|