1 /**@file
2 
3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5 
6 
7 Module Name:
8   WinHost.h
9 
10 Abstract:
11   Include file for Windows Host
12 
13 **/
14 #ifndef _HOST_H_
15 #define _HOST_H_
16 
17 #include <stdio.h>
18 #include <time.h>
19 #include "WinInclude.h"
20 
21 #include <PiPei.h>
22 #include <IndustryStandard/PeImage.h>
23 #include <Guid/FileInfo.h>
24 #include <Guid/FileSystemInfo.h>
25 #include <Guid/FileSystemVolumeLabelInfo.h>
26 #include <Ppi/EmuThunk.h>
27 #include <Protocol/EmuThunk.h>
28 #include <Protocol/SimpleFileSystem.h>
29 
30 #include <Protocol/EmuBlockIo.h>
31 #include <Protocol/BlockIo.h>
32 
33 #include <Library/BaseLib.h>
34 #include <Library/PeCoffLib.h>
35 #include <Library/DebugLib.h>
36 #include <Library/MemoryAllocationLib.h>
37 #include <Library/ThunkPpiList.h>
38 #include <Library/ThunkProtocolList.h>
39 #include <Library/PcdLib.h>
40 #include <Library/PrintLib.h>
41 #include <Library/BaseMemoryLib.h>
42 #include <Library/PeiServicesLib.h>
43 #include <Library/PeCoffExtraActionLib.h>
44 
45 
46 #define TEMPORARY_RAM_SIZE                0x20000
47 
48 typedef struct {
49   VOID                  *Address;
50   UINTN                 Size;
51 } NT_FD_INFO;
52 
53 typedef struct {
54   EFI_PHYSICAL_ADDRESS  Memory;
55   UINT64                Size;
56 } NT_SYSTEM_MEMORY;
57 
58 RETURN_STATUS
59 EFIAPI
60 SecPeCoffGetEntryPoint (
61   IN     VOID  *Pe32Data,
62   IN OUT VOID  **EntryPoint
63 );
64 
65 VOID
66 SecLoadSecCore (
67   IN  UINTN   TemporaryRam,
68   IN  UINTN   TemporaryRamSize,
69   IN  VOID    *BootFirmwareVolumeBase,
70   IN  UINTN   BootFirmwareVolumeSize,
71   IN  VOID    *SecCorePe32File
72 )
73 /*++
74 
75 Routine Description:
76   This is the service to load the SEC Core from the Firmware Volume
77 
78 Arguments:
79   TemporaryRam            - Memory to use for SEC.
80   TemporaryRamSize        - Size of Memory to use for SEC
81   BootFirmwareVolumeBase  - Start of the Boot FV
82   SecCorePe32File         - SEC Core PE32
83 
84 Returns:
85   Success means control is transfered and thus we should never return
86 
87 --*/
88 ;
89 
90 EFI_STATUS
91 EFIAPI
92 SecWinNtFdAddress (
93   IN     UINTN                 Index,
94   IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,
95   IN OUT UINT64                *FdSize
96   )
97 /*++
98 
99 Routine Description:
100 
101   TODO: Add function description
102 
103 Arguments:
104 
105   Index   - TODO: add argument description
106   FdBase  - TODO: add argument description
107   FdSize  - TODO: add argument description
108 
109 Returns:
110 
111   TODO: add return values
112 
113 --*/
114 ;
115 
116 
117 EFI_STATUS
118 EFIAPI
119 SecImageRead (
120   IN     VOID    *FileHandle,
121   IN     UINTN   FileOffset,
122   IN OUT UINTN   *ReadSize,
123   OUT    VOID    *Buffer
124   )
125 /*++
126 
127 Routine Description:
128 
129   TODO: Add function description
130 
131 Arguments:
132 
133   FileHandle  - TODO: add argument description
134   FileOffset  - TODO: add argument description
135   ReadSize    - TODO: add argument description
136   Buffer      - TODO: add argument description
137 
138 Returns:
139 
140   TODO: add return values
141 
142 --*/
143 ;
144 
145 CHAR16                            *
146 AsciiToUnicode (
147   IN  CHAR8   *Ascii,
148   IN  UINTN   *StrLen OPTIONAL
149   )
150 /*++
151 
152 Routine Description:
153 
154   TODO: Add function description
155 
156 Arguments:
157 
158   Ascii   - TODO: add argument description
159   StrLen  - TODO: add argument description
160 
161 Returns:
162 
163   TODO: add return values
164 
165 --*/
166 ;
167 
168 UINTN
169 CountSeparatorsInString (
170   IN  CONST CHAR16   *String,
171   IN  CHAR16   Separator
172   )
173 /*++
174 
175 Routine Description:
176 
177   TODO: Add function description
178 
179 Arguments:
180 
181   String    - TODO: add argument description
182   Separator - TODO: add argument description
183 
184 Returns:
185 
186   TODO: add return values
187 
188 --*/
189 ;
190 
191 BOOLEAN
192 EfiSystemMemoryRange (
193   IN  VOID *MemoryAddress
194   );
195 VOID
196 SecInitializeThunk (
197   VOID
198 );
199 extern EMU_THUNK_PROTOCOL    gEmuThunkProtocol;
200 extern EMU_IO_THUNK_PROTOCOL mWinNtWndThunkIo;
201 extern EMU_IO_THUNK_PROTOCOL mWinNtFileSystemThunkIo;
202 extern EMU_IO_THUNK_PROTOCOL mWinNtBlockIoThunkIo;
203 #endif
204