1 /** @file
2 Emulator Thunk to abstract OS services from pure EFI code
3
4 Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
5 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include <PiPei.h>
18 #include <Library/BaseLib.h>
19 #include <Library/MemoryAllocationLib.h>
20
21
22 UINTN gThunkPpiListSize = 0;
23 EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL;
24
25
26
27 EFI_PEI_PPI_DESCRIPTOR *
GetThunkPpiList(VOID)28 GetThunkPpiList (
29 VOID
30 )
31 {
32 UINTN Index;
33
34 if (gThunkPpiList == NULL) {
35 return NULL;
36 }
37
38 Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;
39 gThunkPpiList[Index].Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
40
41 return gThunkPpiList;
42 }
43
44
45 EFI_STATUS
46 EFIAPI
AddThunkPpi(IN UINTN Flags,IN EFI_GUID * Guid,IN VOID * Ppi)47 AddThunkPpi (
48 IN UINTN Flags,
49 IN EFI_GUID *Guid,
50 IN VOID *Ppi
51 )
52 {
53 UINTN Index;
54
55 gThunkPpiList = ReallocatePool (
56 gThunkPpiListSize,
57 gThunkPpiListSize + sizeof (EFI_PEI_PPI_DESCRIPTOR),
58 gThunkPpiList
59 );
60 if (gThunkPpiList == NULL) {
61 return EFI_OUT_OF_RESOURCES;
62 }
63
64 Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR));
65 gThunkPpiList[Index].Flags = Flags;
66 gThunkPpiList[Index].Guid = Guid;
67 gThunkPpiList[Index].Ppi = Ppi;
68 gThunkPpiListSize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
69
70 return EFI_SUCCESS;
71 }
72
73
74
75
76
77