]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/AcpiResetDxe/ResetEntry.c
Port AcpiResetDxe from EDK to EDKII to enable reset function on DUET above legacy...
[mirror_edk2.git] / DuetPkg / AcpiResetDxe / ResetEntry.c
1 /*++ @file
2 Entrypoint of AcpiResetDxe driver.
3
4 Copyright (c) 2010, Intel Corporation
5 All rights reserved. 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
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 --*/
13
14 #include "Reset.h"
15
16 EFI_ACPI_DESCRIPTION mAcpiDescription;
17
18 /**
19 Reset the system.
20
21 @param[in] ResetType Warm or cold
22 @param[in] ResetStatus Possible cause of reset
23 @param[in] DataSize Size of ResetData in bytes
24 @param[in] ResetData Optional Unicode string
25
26 **/
27 VOID
28 EFIAPI
29 EfiAcpiResetSystem (
30 IN EFI_RESET_TYPE ResetType,
31 IN EFI_STATUS ResetStatus,
32 IN UINTN DataSize,
33 IN CHAR16 *ResetData OPTIONAL
34 )
35 {
36 AcpiResetSystem (ResetType, ResetStatus, DataSize, ResetData, &mAcpiDescription);
37 }
38
39 /**
40 Initialize the state information for the Reset Architectural Protocol.
41
42 @param[in] ImageHandle Image handle of the loaded driver
43 @param[in] SystemTable Pointer to the System Table
44
45 @retval EFI_SUCCESS Thread can be successfully created
46 @retval EFI_UNSUPPORTED Cannot find the info to reset system
47
48 **/
49 EFI_STATUS
50 EFIAPI
51 InitializeReset (
52 IN EFI_HANDLE ImageHandle,
53 IN EFI_SYSTEM_TABLE *SystemTable
54 )
55 {
56 EFI_STATUS Status;
57 EFI_HANDLE Handle;
58 //
59 // Initialize AcpiDescription
60 //
61 if (!GetAcpiDescription (&mAcpiDescription)) {
62 return EFI_UNSUPPORTED;
63 }
64
65 //
66 // Make sure the Reset Architectural Protocol is not already installed in the system
67 //
68 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);
69
70 //
71 // Hook the runtime service table
72 //
73 SystemTable->RuntimeServices->ResetSystem = EfiAcpiResetSystem;
74
75 //
76 // Now install the Reset RT AP on a new handle
77 //
78 Handle = NULL;
79 Status = gBS->InstallMultipleProtocolInterfaces (
80 &Handle,
81 &gEfiResetArchProtocolGuid,
82 NULL,
83 NULL
84 );
85 ASSERT_EFI_ERROR (Status);
86
87 return Status;
88 }