Port EdkUnixPkg to UnixPkg. The changes are listed as follows:
[edk2.git] / UnixPkg / BootModePei / BootModePei.c
blobb7f3ad059863ff9e4bbe35ad9a14922ce48ab1bd
1 /**@file
3 Copyright (c) 2006 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 Module Name:
14 BootMode.c
16 Abstract:
18 Tiano PEIM to provide the platform support functionality within Unix
20 **/
25 // The package level header files this module uses
27 #include <PiPei.h>
29 // The protocols, PPI and GUID defintions for this module
31 #include <Ppi/MasterBootMode.h>
32 #include <Ppi/BootInRecoveryMode.h>
34 // The Library classes this module consumes
36 #include <Library/DebugLib.h>
37 #include <Library/PeimEntryPoint.h>
41 // Module globals
43 EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
44 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
45 &gEfiPeiMasterBootModePpiGuid,
46 NULL
49 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
50 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
51 &gEfiPeiBootInRecoveryModePpiGuid,
52 NULL
55 EFI_STATUS
56 EFIAPI
57 InitializeBootMode (
58 IN EFI_FFS_FILE_HEADER *FfsHeader,
59 IN EFI_PEI_SERVICES **PeiServices
61 /*++
63 Routine Description:
65 Peform the boot mode determination logic
67 Arguments:
69 PeiServices - General purpose services available to every PEIM.
71 Returns:
73 Status - EFI_SUCCESS if the boot mode could be set
75 --*/
76 // TODO: FfsHeader - add argument and description to function comment
78 EFI_STATUS Status;
79 UINTN BootMode;
81 DEBUG ((EFI_D_ERROR, "Unix Boot Mode PEIM Loaded\n"));
84 // Let's assume things are OK if not told otherwise
85 // Should we read an environment variable in order to easily change this?
87 BootMode = BOOT_WITH_FULL_CONFIGURATION;
89 Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
90 ASSERT_EFI_ERROR (Status);
92 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
93 ASSERT_EFI_ERROR (Status);
95 if (BootMode == BOOT_IN_RECOVERY_MODE) {
96 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
97 ASSERT_EFI_ERROR (Status);
100 return Status;