1*f439973dSWarner Losh /** @file 2*f439973dSWarner Losh This files describes the CPU I/O 2 Protocol. 3*f439973dSWarner Losh 4*f439973dSWarner Losh This protocol provides an I/O abstraction for a system processor. This protocol 5*f439973dSWarner Losh is used by a PCI root bridge I/O driver to perform memory-mapped I/O and I/O transactions. 6*f439973dSWarner Losh The I/O or memory primitives can be used by the consumer of the protocol to materialize 7*f439973dSWarner Losh bus-specific configuration cycles, such as the transitional configuration address and data 8*f439973dSWarner Losh ports for PCI. Only drivers that require direct access to the entire system should use this 9*f439973dSWarner Losh protocol. 10*f439973dSWarner Losh 11*f439973dSWarner Losh Note: This is a boot-services only protocol and it may not be used by runtime drivers after 12*f439973dSWarner Losh ExitBootServices(). It is different from the Framework CPU I/O Protocol, which is a runtime 13*f439973dSWarner Losh protocol and can be used by runtime drivers after ExitBootServices(). 14*f439973dSWarner Losh 15*f439973dSWarner Losh Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> 16*f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent 17*f439973dSWarner Losh 18*f439973dSWarner Losh @par Revision Reference: 19*f439973dSWarner Losh This Protocol is defined in UEFI Platform Initialization Specification 1.2 20*f439973dSWarner Losh Volume 5: Standards 21*f439973dSWarner Losh 22*f439973dSWarner Losh **/ 23*f439973dSWarner Losh 24*f439973dSWarner Losh #ifndef __CPU_IO2_H__ 25*f439973dSWarner Losh #define __CPU_IO2_H__ 26*f439973dSWarner Losh 27*f439973dSWarner Losh #define EFI_CPU_IO2_PROTOCOL_GUID \ 28*f439973dSWarner Losh { \ 29*f439973dSWarner Losh 0xad61f191, 0xae5f, 0x4c0e, {0xb9, 0xfa, 0xe8, 0x69, 0xd2, 0x88, 0xc6, 0x4f} \ 30*f439973dSWarner Losh } 31*f439973dSWarner Losh 32*f439973dSWarner Losh typedef struct _EFI_CPU_IO2_PROTOCOL EFI_CPU_IO2_PROTOCOL; 33*f439973dSWarner Losh 34*f439973dSWarner Losh /// 35*f439973dSWarner Losh /// Enumeration that defines the width of the I/O operation. 36*f439973dSWarner Losh /// 37*f439973dSWarner Losh typedef enum { 38*f439973dSWarner Losh EfiCpuIoWidthUint8, 39*f439973dSWarner Losh EfiCpuIoWidthUint16, 40*f439973dSWarner Losh EfiCpuIoWidthUint32, 41*f439973dSWarner Losh EfiCpuIoWidthUint64, 42*f439973dSWarner Losh EfiCpuIoWidthFifoUint8, 43*f439973dSWarner Losh EfiCpuIoWidthFifoUint16, 44*f439973dSWarner Losh EfiCpuIoWidthFifoUint32, 45*f439973dSWarner Losh EfiCpuIoWidthFifoUint64, 46*f439973dSWarner Losh EfiCpuIoWidthFillUint8, 47*f439973dSWarner Losh EfiCpuIoWidthFillUint16, 48*f439973dSWarner Losh EfiCpuIoWidthFillUint32, 49*f439973dSWarner Losh EfiCpuIoWidthFillUint64, 50*f439973dSWarner Losh EfiCpuIoWidthMaximum 51*f439973dSWarner Losh } EFI_CPU_IO_PROTOCOL_WIDTH; 52*f439973dSWarner Losh 53*f439973dSWarner Losh /** 54*f439973dSWarner Losh Enables a driver to access registers in the PI CPU I/O space. 55*f439973dSWarner Losh 56*f439973dSWarner Losh The Io.Read() and Io.Write() functions enable a driver to access PCI controller 57*f439973dSWarner Losh registers in the PI CPU I/O space. 58*f439973dSWarner Losh 59*f439973dSWarner Losh The I/O operations are carried out exactly as requested. The caller is responsible 60*f439973dSWarner Losh for satisfying any alignment and I/O width restrictions that a PI System on a 61*f439973dSWarner Losh platform might require. For example on some platforms, width requests of 62*f439973dSWarner Losh EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will 63*f439973dSWarner Losh be handled by the driver. 64*f439973dSWarner Losh 65*f439973dSWarner Losh If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, 66*f439973dSWarner Losh or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for 67*f439973dSWarner Losh each of the Count operations that is performed. 68*f439973dSWarner Losh 69*f439973dSWarner Losh If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, 70*f439973dSWarner Losh EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is 71*f439973dSWarner Losh incremented for each of the Count operations that is performed. The read or 72*f439973dSWarner Losh write operation is performed Count times on the same Address. 73*f439973dSWarner Losh 74*f439973dSWarner Losh If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, 75*f439973dSWarner Losh EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is 76*f439973dSWarner Losh incremented for each of the Count operations that is performed. The read or 77*f439973dSWarner Losh write operation is performed Count times from the first element of Buffer. 78*f439973dSWarner Losh 79*f439973dSWarner Losh @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. 80*f439973dSWarner Losh @param[in] Width Signifies the width of the I/O or Memory operation. 81*f439973dSWarner Losh @param[in] Address The base address of the I/O operation. 82*f439973dSWarner Losh @param[in] Count The number of I/O operations to perform. The number 83*f439973dSWarner Losh of bytes moved is Width size * Count, starting at Address. 84*f439973dSWarner Losh @param[in, out] Buffer For read operations, the destination buffer to store the results. 85*f439973dSWarner Losh For write operations, the source buffer from which to write data. 86*f439973dSWarner Losh 87*f439973dSWarner Losh @retval EFI_SUCCESS The data was read from or written to the PI system. 88*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. 89*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Buffer is NULL. 90*f439973dSWarner Losh @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. 91*f439973dSWarner Losh @retval EFI_UNSUPPORTED The address range specified by Address, Width, 92*f439973dSWarner Losh and Count is not valid for this PI system. 93*f439973dSWarner Losh 94*f439973dSWarner Losh **/ 95*f439973dSWarner Losh typedef 96*f439973dSWarner Losh EFI_STATUS 97*f439973dSWarner Losh (EFIAPI *EFI_CPU_IO_PROTOCOL_IO_MEM)( 98*f439973dSWarner Losh IN EFI_CPU_IO2_PROTOCOL *This, 99*f439973dSWarner Losh IN EFI_CPU_IO_PROTOCOL_WIDTH Width, 100*f439973dSWarner Losh IN UINT64 Address, 101*f439973dSWarner Losh IN UINTN Count, 102*f439973dSWarner Losh IN OUT VOID *Buffer 103*f439973dSWarner Losh ); 104*f439973dSWarner Losh 105*f439973dSWarner Losh /// 106*f439973dSWarner Losh /// Service for read and write accesses. 107*f439973dSWarner Losh /// 108*f439973dSWarner Losh typedef struct { 109*f439973dSWarner Losh /// 110*f439973dSWarner Losh /// This service provides the various modalities of memory and I/O read. 111*f439973dSWarner Losh /// 112*f439973dSWarner Losh EFI_CPU_IO_PROTOCOL_IO_MEM Read; 113*f439973dSWarner Losh /// 114*f439973dSWarner Losh /// This service provides the various modalities of memory and I/O write. 115*f439973dSWarner Losh /// 116*f439973dSWarner Losh EFI_CPU_IO_PROTOCOL_IO_MEM Write; 117*f439973dSWarner Losh } EFI_CPU_IO_PROTOCOL_ACCESS; 118*f439973dSWarner Losh 119*f439973dSWarner Losh /// 120*f439973dSWarner Losh /// Provides the basic memory and I/O interfaces that are used to abstract 121*f439973dSWarner Losh /// accesses to devices in a system. 122*f439973dSWarner Losh /// 123*f439973dSWarner Losh struct _EFI_CPU_IO2_PROTOCOL { 124*f439973dSWarner Losh /// 125*f439973dSWarner Losh /// Enables a driver to access memory-mapped registers in the EFI system memory space. 126*f439973dSWarner Losh /// 127*f439973dSWarner Losh EFI_CPU_IO_PROTOCOL_ACCESS Mem; 128*f439973dSWarner Losh /// 129*f439973dSWarner Losh /// Enables a driver to access registers in the EFI CPU I/O space. 130*f439973dSWarner Losh /// 131*f439973dSWarner Losh EFI_CPU_IO_PROTOCOL_ACCESS Io; 132*f439973dSWarner Losh }; 133*f439973dSWarner Losh 134*f439973dSWarner Losh extern EFI_GUID gEfiCpuIo2ProtocolGuid; 135*f439973dSWarner Losh 136*f439973dSWarner Losh #endif 137