blob: 892e1c6f0405f66db8828b9ca9d95b8ab46e9b7d [file] [log] [blame]
andrewfish949f3882011-05-11 18:31:20 +00001/** @file
2
3Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4Portions copyright (c) 2011, Apple Inc. All rights reserved.
jljustend18d8a12011-06-28 16:50:26 +00005This program and the accompanying materials
6are licensed and made available under the terms and conditions of the BSD License
7which accompanies this distribution. The full text of the license may be found at
8http://opensource.org/licenses/bsd-license.php
9
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
andrewfish949f3882011-05-11 18:31:20 +000012
13**/
14
15
16
17//
18// The package level header files this module uses
19//
20#include <PiPei.h>
21
22#include <Library/PcdLib.h>
23#include <Library/PeiServicesLib.h>
24
25
26//
27// The protocols, PPI and GUID defintions for this module
28//
29#include <Ppi/MasterBootMode.h>
30#include <Ppi/BootInRecoveryMode.h>
31//
32// The Library classes this module consumes
33//
34#include <Library/DebugLib.h>
35#include <Library/PeimEntryPoint.h>
36
37
38//
39// Module globals
40//
41EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
42 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
43 &gEfiPeiMasterBootModePpiGuid,
44 NULL
45};
46
47EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
48 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
49 &gEfiPeiBootInRecoveryModePpiGuid,
50 NULL
51};
52
53EFI_STATUS
54EFIAPI
55InitializeBootMode (
56 IN EFI_PEI_FILE_HANDLE FileHandle,
57 IN CONST EFI_PEI_SERVICES **PeiServices
58 )
59/*++
60
61Routine Description:
62
63 Peform the boot mode determination logic
64
65Arguments:
66
67 PeiServices - General purpose services available to every PEIM.
jljustend18d8a12011-06-28 16:50:26 +000068
andrewfish949f3882011-05-11 18:31:20 +000069Returns:
70
71 Status - EFI_SUCCESS if the boot mode could be set
72
73**/
74{
75 EFI_STATUS Status;
76 EFI_BOOT_MODE BootMode;
77
78 DEBUG ((EFI_D_ERROR, "Emu Boot Mode PEIM Loaded\n"));
79
80 BootMode = FixedPcdGet32 (PcdEmuBootMode);
81
82 Status = PeiServicesSetBootMode (BootMode);
83 ASSERT_EFI_ERROR (Status);
84
85 Status = PeiServicesInstallPpi (&mPpiListBootMode);
86 ASSERT_EFI_ERROR (Status);
87
88 if (BootMode == BOOT_IN_RECOVERY_MODE) {
89 Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);
90 ASSERT_EFI_ERROR (Status);
91 }
92
93 return Status;
94}