1 /** @file
2   The default version of EFI_PEI_CPU_IO_PPI support published by PeiServices in
3   PeiCore initialization phase.
4 
5   EFI_PEI_CPU_IO_PPI is installed by some platform or chipset-specific PEIM that
6   abstracts the processor-visible I/O operations. When PeiCore is started, the
7   default version of EFI_PEI_CPU_IO_PPI will be assigned to PeiServices table.
8 
9 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
10 SPDX-License-Identifier: BSD-2-Clause-Patent
11 
12 **/
13 
14 #include "PeiMain.h"
15 
16 ///
17 /// This default instance of EFI_PEI_CPU_IO_PPI install assigned to EFI_PEI_SERVICE.CpuIo
18 /// when PeiCore's initialization.
19 ///
20 EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi = {
21   {
22     PeiDefaultMemRead,
23     PeiDefaultMemWrite
24   },
25   {
26     PeiDefaultIoRead,
27     PeiDefaultIoWrite
28   },
29   PeiDefaultIoRead8,
30   PeiDefaultIoRead16,
31   PeiDefaultIoRead32,
32   PeiDefaultIoRead64,
33   PeiDefaultIoWrite8,
34   PeiDefaultIoWrite16,
35   PeiDefaultIoWrite32,
36   PeiDefaultIoWrite64,
37   PeiDefaultMemRead8,
38   PeiDefaultMemRead16,
39   PeiDefaultMemRead32,
40   PeiDefaultMemRead64,
41   PeiDefaultMemWrite8,
42   PeiDefaultMemWrite16,
43   PeiDefaultMemWrite32,
44   PeiDefaultMemWrite64
45 };
46 
47 /**
48   Memory-based read services.
49 
50   This function is to perform the Memory Access Read service based on installed
51   instance of the EFI_PEI_CPU_IO_PPI.
52   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
53   return EFI_NOT_YET_AVAILABLE.
54 
55   @param  PeiServices           An indirect pointer to the PEI Services Table
56                                 published by the PEI Foundation.
57   @param  This                  Pointer to local data for the interface.
58   @param  Width                 The width of the access. Enumerated in bytes.
59   @param  Address               The physical address of the access.
60   @param  Count                 The number of accesses to perform.
61   @param  Buffer                A pointer to the buffer of data.
62 
63   @retval EFI_SUCCESS           The function completed successfully.
64   @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
65 **/
66 EFI_STATUS
67 EFIAPI
PeiDefaultMemRead(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN EFI_PEI_CPU_IO_PPI_WIDTH Width,IN UINT64 Address,IN UINTN Count,IN OUT VOID * Buffer)68 PeiDefaultMemRead (
69   IN  CONST EFI_PEI_SERVICES            **PeiServices,
70   IN  CONST EFI_PEI_CPU_IO_PPI          *This,
71   IN  EFI_PEI_CPU_IO_PPI_WIDTH          Width,
72   IN  UINT64                            Address,
73   IN  UINTN                             Count,
74   IN  OUT VOID                          *Buffer
75   )
76 {
77   return EFI_NOT_AVAILABLE_YET;
78 }
79 
80 /**
81   Memory-based write services.
82 
83   This function is to perform the Memory Access Write service based on installed
84   instance of the EFI_PEI_CPU_IO_PPI.
85   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
86   return EFI_NOT_YET_AVAILABLE.
87 
88   @param  PeiServices           An indirect pointer to the PEI Services Table
89                                 published by the PEI Foundation.
90   @param  This                  Pointer to local data for the interface.
91   @param  Width                 The width of the access. Enumerated in bytes.
92   @param  Address               The physical address of the access.
93   @param  Count                 The number of accesses to perform.
94   @param  Buffer                A pointer to the buffer of data.
95 
96   @retval EFI_SUCCESS           The function completed successfully.
97   @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
98 **/
99 EFI_STATUS
100 EFIAPI
PeiDefaultMemWrite(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN EFI_PEI_CPU_IO_PPI_WIDTH Width,IN UINT64 Address,IN UINTN Count,IN OUT VOID * Buffer)101 PeiDefaultMemWrite (
102   IN  CONST EFI_PEI_SERVICES            **PeiServices,
103   IN  CONST EFI_PEI_CPU_IO_PPI          *This,
104   IN  EFI_PEI_CPU_IO_PPI_WIDTH          Width,
105   IN  UINT64                            Address,
106   IN  UINTN                             Count,
107   IN  OUT VOID                          *Buffer
108   )
109 {
110   return EFI_NOT_AVAILABLE_YET;
111 }
112 
113 /**
114   IO-based read services.
115 
116   This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.
117   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
118   return EFI_NOT_YET_AVAILABLE.
119 
120   @param  PeiServices           An indirect pointer to the PEI Services Table
121                                 published by the PEI Foundation.
122   @param  This                  Pointer to local data for the interface.
123   @param  Width                 The width of the access. Enumerated in bytes.
124   @param  Address               The physical address of the access.
125   @param  Count                 The number of accesses to perform.
126   @param  Buffer                A pointer to the buffer of data.
127 
128   @retval EFI_SUCCESS           The function completed successfully.
129   @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
130 **/
131 EFI_STATUS
132 EFIAPI
PeiDefaultIoRead(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN EFI_PEI_CPU_IO_PPI_WIDTH Width,IN UINT64 Address,IN UINTN Count,IN OUT VOID * Buffer)133 PeiDefaultIoRead (
134   IN      CONST EFI_PEI_SERVICES          **PeiServices,
135   IN      CONST EFI_PEI_CPU_IO_PPI        *This,
136   IN      EFI_PEI_CPU_IO_PPI_WIDTH        Width,
137   IN      UINT64                          Address,
138   IN      UINTN                           Count,
139   IN OUT  VOID                            *Buffer
140   )
141 {
142   return EFI_NOT_AVAILABLE_YET;
143 }
144 
145 /**
146   IO-based write services.
147 
148   This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.
149   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
150   return EFI_NOT_YET_AVAILABLE.
151 
152   @param  PeiServices           An indirect pointer to the PEI Services Table
153                                 published by the PEI Foundation.
154   @param  This                  Pointer to local data for the interface.
155   @param  Width                 The width of the access. Enumerated in bytes.
156   @param  Address               The physical address of the access.
157   @param  Count                 The number of accesses to perform.
158   @param  Buffer                A pointer to the buffer of data.
159 
160   @retval EFI_SUCCESS           The function completed successfully.
161   @retval EFI_NOT_YET_AVAILABLE The service has not been installed.
162 **/
163 EFI_STATUS
164 EFIAPI
PeiDefaultIoWrite(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN EFI_PEI_CPU_IO_PPI_WIDTH Width,IN UINT64 Address,IN UINTN Count,IN OUT VOID * Buffer)165 PeiDefaultIoWrite (
166   IN      CONST EFI_PEI_SERVICES          **PeiServices,
167   IN      CONST EFI_PEI_CPU_IO_PPI        *This,
168   IN      EFI_PEI_CPU_IO_PPI_WIDTH        Width,
169   IN      UINT64                          Address,
170   IN      UINTN                           Count,
171   IN OUT  VOID                            *Buffer
172   )
173 {
174   return EFI_NOT_AVAILABLE_YET;
175 }
176 
177 /**
178   8-bit I/O read operations.
179 
180   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
181   return 0.
182 
183   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
184   @param  This           Pointer to local data for the interface.
185   @param  Address        The physical address of the access.
186 
187   @return An 8-bit value returned from the I/O space.
188 **/
189 UINT8
190 EFIAPI
PeiDefaultIoRead8(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)191 PeiDefaultIoRead8 (
192   IN  CONST EFI_PEI_SERVICES      **PeiServices,
193   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
194   IN  UINT64                      Address
195   )
196 {
197   return 0;
198 }
199 
200 /**
201   Reads an 16-bit I/O port.
202 
203   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
204   return 0.
205 
206   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
207   @param  This           Pointer to local data for the interface.
208   @param  Address        The physical address of the access.
209 
210   @return A 16-bit value returned from the I/O space.
211 **/
212 UINT16
213 EFIAPI
PeiDefaultIoRead16(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)214 PeiDefaultIoRead16 (
215   IN  CONST EFI_PEI_SERVICES      **PeiServices,
216   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
217   IN  UINT64                      Address
218   )
219 {
220   return 0;
221 }
222 
223 /**
224   Reads an 32-bit I/O port.
225 
226   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
227   return 0.
228 
229   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
230   @param  This           Pointer to local data for the interface.
231   @param  Address        The physical address of the access.
232 
233   @return A 32-bit value returned from the I/O space.
234 **/
235 UINT32
236 EFIAPI
PeiDefaultIoRead32(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)237 PeiDefaultIoRead32 (
238   IN  CONST EFI_PEI_SERVICES      **PeiServices,
239   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
240   IN  UINT64                      Address
241   )
242 {
243   return 0;
244 }
245 
246 /**
247   Reads an 64-bit I/O port.
248 
249   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
250   return 0.
251 
252   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
253   @param  This           Pointer to local data for the interface.
254   @param  Address        The physical address of the access.
255 
256   @return A 64-bit value returned from the I/O space.
257 **/
258 UINT64
259 EFIAPI
PeiDefaultIoRead64(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)260 PeiDefaultIoRead64 (
261   IN  CONST EFI_PEI_SERVICES      **PeiServices,
262   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
263   IN  UINT64                      Address
264   )
265 {
266   return 0;
267 }
268 
269 /**
270   8-bit I/O write operations.
271   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
272   nothing.
273 
274   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
275   @param  This           Pointer to local data for the interface.
276   @param  Address        The physical address of the access.
277   @param  Data           The data to write.
278 **/
279 VOID
280 EFIAPI
PeiDefaultIoWrite8(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT8 Data)281 PeiDefaultIoWrite8 (
282   IN  CONST EFI_PEI_SERVICES      **PeiServices,
283   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
284   IN  UINT64                      Address,
285   IN  UINT8                       Data
286   )
287 {
288 }
289 
290 /**
291   16-bit I/O write operations.
292   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
293   nothing.
294 
295   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
296   @param  This           Pointer to local data for the interface.
297   @param  Address        The physical address of the access.
298   @param  Data           The data to write.
299 **/
300 VOID
301 EFIAPI
PeiDefaultIoWrite16(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT16 Data)302 PeiDefaultIoWrite16 (
303   IN  CONST EFI_PEI_SERVICES      **PeiServices,
304   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
305   IN  UINT64                      Address,
306   IN  UINT16                      Data
307   )
308 {
309 }
310 
311 /**
312   32-bit I/O write operations.
313   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
314   nothing.
315 
316   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
317   @param  This           Pointer to local data for the interface.
318   @param  Address        The physical address of the access.
319   @param  Data           The data to write.
320 **/
321 VOID
322 EFIAPI
PeiDefaultIoWrite32(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT32 Data)323 PeiDefaultIoWrite32 (
324   IN  CONST EFI_PEI_SERVICES      **PeiServices,
325   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
326   IN  UINT64                      Address,
327   IN  UINT32                      Data
328   )
329 {
330 }
331 
332 /**
333   64-bit I/O write operations.
334   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
335   nothing.
336 
337   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
338   @param  This           Pointer to local data for the interface.
339   @param  Address        The physical address of the access.
340   @param  Data           The data to write.
341 **/
342 VOID
343 EFIAPI
PeiDefaultIoWrite64(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT64 Data)344 PeiDefaultIoWrite64 (
345   IN  CONST EFI_PEI_SERVICES      **PeiServices,
346   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
347   IN  UINT64                      Address,
348   IN  UINT64                      Data
349   )
350 {
351 }
352 
353 /**
354   8-bit memory read operations.
355 
356   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
357   return 0.
358 
359   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
360   @param  This           Pointer to local data for the interface.
361   @param  Address        The physical address of the access.
362 
363   @return An 8-bit value returned from the memory space.
364 
365 **/
366 UINT8
367 EFIAPI
PeiDefaultMemRead8(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)368 PeiDefaultMemRead8 (
369   IN  CONST EFI_PEI_SERVICES      **PeiServices,
370   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
371   IN  UINT64                      Address
372   )
373 {
374   return 0;
375 }
376 
377 /**
378   16-bit memory read operations.
379 
380   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
381   return 0.
382 
383   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
384   @param  This           Pointer to local data for the interface.
385   @param  Address        The physical address of the access.
386 
387   @return An 16-bit value returned from the memory space.
388 
389 **/
390 UINT16
391 EFIAPI
PeiDefaultMemRead16(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)392 PeiDefaultMemRead16 (
393   IN  CONST EFI_PEI_SERVICES      **PeiServices,
394   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
395   IN  UINT64                      Address
396   )
397 {
398   return 0;
399 }
400 
401 /**
402   32-bit memory read operations.
403 
404   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
405   return 0.
406 
407   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
408   @param  This           Pointer to local data for the interface.
409   @param  Address        The physical address of the access.
410 
411   @return An 32-bit value returned from the memory space.
412 
413 **/
414 UINT32
415 EFIAPI
PeiDefaultMemRead32(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)416 PeiDefaultMemRead32 (
417   IN  CONST EFI_PEI_SERVICES      **PeiServices,
418   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
419   IN  UINT64                      Address
420   )
421 {
422   return 0;
423 }
424 
425 /**
426   64-bit memory read operations.
427 
428   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then
429   return 0.
430 
431   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
432   @param  This           Pointer to local data for the interface.
433   @param  Address        The physical address of the access.
434 
435   @return An 64-bit value returned from the memory space.
436 
437 **/
438 UINT64
439 EFIAPI
PeiDefaultMemRead64(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address)440 PeiDefaultMemRead64 (
441   IN  CONST EFI_PEI_SERVICES      **PeiServices,
442   IN  CONST EFI_PEI_CPU_IO_PPI    *This,
443   IN  UINT64                      Address
444   )
445 {
446   return 0;
447 }
448 
449 /**
450   8-bit memory write operations.
451   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
452   nothing.
453 
454   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
455   @param  This           Pointer to local data for the interface.
456   @param  Address        The physical address of the access.
457   @param  Data           The data to write.
458 
459 **/
460 VOID
461 EFIAPI
PeiDefaultMemWrite8(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT8 Data)462 PeiDefaultMemWrite8 (
463   IN  CONST EFI_PEI_SERVICES        **PeiServices,
464   IN  CONST EFI_PEI_CPU_IO_PPI      *This,
465   IN  UINT64                        Address,
466   IN  UINT8                         Data
467   )
468 {
469 }
470 
471 /**
472   16-bit memory write operations.
473   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
474   nothing.
475 
476   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
477   @param  This           Pointer to local data for the interface.
478   @param  Address        The physical address of the access.
479   @param  Data           The data to write.
480 
481 **/
482 VOID
483 EFIAPI
PeiDefaultMemWrite16(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT16 Data)484 PeiDefaultMemWrite16 (
485   IN  CONST EFI_PEI_SERVICES        **PeiServices,
486   IN  CONST EFI_PEI_CPU_IO_PPI      *This,
487   IN  UINT64                        Address,
488   IN  UINT16                        Data
489   )
490 {
491 }
492 
493 /**
494   32-bit memory write operations.
495   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
496   nothing.
497 
498   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
499   @param  This           Pointer to local data for the interface.
500   @param  Address        The physical address of the access.
501   @param  Data           The data to write.
502 
503 **/
504 VOID
505 EFIAPI
PeiDefaultMemWrite32(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT32 Data)506 PeiDefaultMemWrite32 (
507   IN  CONST EFI_PEI_SERVICES        **PeiServices,
508   IN  CONST EFI_PEI_CPU_IO_PPI      *This,
509   IN  UINT64                        Address,
510   IN  UINT32                        Data
511   )
512 {
513 }
514 
515 /**
516   64-bit memory write operations.
517   If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then do
518   nothing.
519 
520   @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.
521   @param  This           Pointer to local data for the interface.
522   @param  Address        The physical address of the access.
523   @param  Data           The data to write.
524 
525 **/
526 VOID
527 EFIAPI
PeiDefaultMemWrite64(IN CONST EFI_PEI_SERVICES ** PeiServices,IN CONST EFI_PEI_CPU_IO_PPI * This,IN UINT64 Address,IN UINT64 Data)528 PeiDefaultMemWrite64 (
529   IN  CONST EFI_PEI_SERVICES        **PeiServices,
530   IN  CONST EFI_PEI_CPU_IO_PPI      *This,
531   IN  UINT64                        Address,
532   IN  UINT64                        Data
533   )
534 {
535 }
536