1 | /** @file
|
---|
2 | Template library implementation to support ResetSystem Runtime call.
|
---|
3 |
|
---|
4 | Fill in the templates with what ever makes you system reset.
|
---|
5 |
|
---|
6 |
|
---|
7 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
---|
8 |
|
---|
9 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
10 |
|
---|
11 | **/
|
---|
12 |
|
---|
13 | #include <PiDxe.h>
|
---|
14 |
|
---|
15 | #include <Library/BaseLib.h>
|
---|
16 | #include <Library/IoLib.h>
|
---|
17 | #include <Library/EfiResetSystemLib.h>
|
---|
18 |
|
---|
19 | /**
|
---|
20 | Resets the entire platform.
|
---|
21 |
|
---|
22 | @param ResetType The type of reset to perform.
|
---|
23 | @param ResetStatus The status code for the reset.
|
---|
24 | @param DataSize The size, in bytes, of WatchdogData.
|
---|
25 | @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
|
---|
26 | EfiResetShutdown the data buffer starts with a Null-terminated
|
---|
27 | Unicode string, optionally followed by additional binary data.
|
---|
28 |
|
---|
29 | **/
|
---|
30 | EFI_STATUS
|
---|
31 | EFIAPI
|
---|
32 | LibResetSystem (
|
---|
33 | IN EFI_RESET_TYPE ResetType,
|
---|
34 | IN EFI_STATUS ResetStatus,
|
---|
35 | IN UINTN DataSize,
|
---|
36 | IN CHAR16 *ResetData OPTIONAL
|
---|
37 | )
|
---|
38 | {
|
---|
39 | UINTN Address;
|
---|
40 | UINT8 Data;
|
---|
41 |
|
---|
42 | switch (ResetType) {
|
---|
43 | case EfiResetCold:
|
---|
44 | // system power cycle
|
---|
45 |
|
---|
46 | // Example using IoLib functions to do IO.
|
---|
47 | Address = 0x12345678;
|
---|
48 | Data = MmioRead8 (Address);
|
---|
49 | MmioWrite8 (Address, Data | 0x01);
|
---|
50 |
|
---|
51 | // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing
|
---|
52 | break;
|
---|
53 |
|
---|
54 | case EfiResetWarm:
|
---|
55 | // not a full power cycle, maybe memory stays around.
|
---|
56 | // if not support do the same thing as EfiResetCold.
|
---|
57 | break;
|
---|
58 |
|
---|
59 | case EfiResetShutdown:
|
---|
60 | // turn off the system.
|
---|
61 | // if not support do the same thing as EfiResetCold.
|
---|
62 | break;
|
---|
63 |
|
---|
64 | default:
|
---|
65 | return EFI_INVALID_PARAMETER;
|
---|
66 | }
|
---|
67 |
|
---|
68 | //
|
---|
69 | // If we reset, we would not have returned...
|
---|
70 | //
|
---|
71 | return EFI_DEVICE_ERROR;
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**
|
---|
75 | Initialize any infrastructure required for LibResetSystem () to function.
|
---|
76 |
|
---|
77 | @param ImageHandle The firmware allocated handle for the EFI image.
|
---|
78 | @param SystemTable A pointer to the EFI System Table.
|
---|
79 |
|
---|
80 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
---|
81 |
|
---|
82 | **/
|
---|
83 | EFI_STATUS
|
---|
84 | EFIAPI
|
---|
85 | LibInitializeResetSystem (
|
---|
86 | IN EFI_HANDLE ImageHandle,
|
---|
87 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
88 | )
|
---|
89 | {
|
---|
90 | return EFI_SUCCESS;
|
---|
91 | }
|
---|