]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
Adding support for BeagleBoard.
[mirror_edk2.git] / EmbeddedPkg / Library / TemplateResetSystemLib / ResetSystemLib.c
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.
8
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18
19
20 #include <PiDxe.h>
21
22 #include <Library/BaseLib.h>
23 #include <Library/IoLib.h>
24 #include <Library/EfiResetSystemLib.h>
25
26
27 /**
28 Resets the entire platform.
29
30 @param ResetType The type of reset to perform.
31 @param ResetStatus The status code for the reset.
32 @param DataSize The size, in bytes, of WatchdogData.
33 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
34 EfiResetShutdown the data buffer starts with a Null-terminated
35 Unicode string, optionally followed by additional binary data.
36
37 **/
38 EFI_STATUS
39 EFIAPI
40 LibResetSystem (
41 IN EFI_RESET_TYPE ResetType,
42 IN EFI_STATUS ResetStatus,
43 IN UINTN DataSize,
44 IN CHAR16 *ResetData OPTIONAL
45 )
46 {
47 UINTN Address;
48 UINT8 Data;
49
50
51 switch (ResetType) {
52 case EfiResetCold:
53 // system power cycle
54
55 // Example using IoLib functions to do IO.
56 Address = 0x12345678;
57 Data = MmioRead8 (Address);
58 MmioWrite8 (Address, Data | 0x01);
59
60 // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing
61 break;
62
63 case EfiResetWarm:
64 // not a full power cycle, maybe memory stays around.
65 // if not support do the same thing as EfiResetCold.
66 break;
67
68 case EfiResetShutdown:
69 // turn off the system.
70 // if not support do the same thing as EfiResetCold.
71 break;
72
73 default:
74 return EFI_INVALID_PARAMETER;
75 }
76
77 //
78 // If we reset, we would not have returned...
79 //
80 return EFI_DEVICE_ERROR;
81 }
82
83
84
85 /**
86 Initialize any infrastructure required for LibResetSystem () to function.
87
88 @param ImageHandle The firmware allocated handle for the EFI image.
89 @param SystemTable A pointer to the EFI System Table.
90
91 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
92
93 **/
94 EFI_STATUS
95 EFIAPI
96 LibInitializeResetSystem (
97 IN EFI_HANDLE ImageHandle,
98 IN EFI_SYSTEM_TABLE *SystemTable
99 )
100 {
101 return EFI_SUCCESS;
102 }
103