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