22#define MAX_IO_PORT_ADDRESS 0xFFFF
93 IN BOOLEAN MmioOperation,
106 if (Buffer ==
NULL) {
107 return EFI_INVALID_PARAMETER;
113 if ((UINT32)Width >= EfiCpuIoWidthMaximum) {
114 return EFI_INVALID_PARAMETER;
121 if ((Width >= EfiCpuIoWidthFifoUint8) && (Width <= EfiCpuIoWidthFifoUint64)) {
129 if (!MmioOperation && (Width == EfiCpuIoWidthUint64)) {
130 return EFI_INVALID_PARAMETER;
136 if ((Address & (UINT64)(mInStride[Width] - 1)) != 0) {
137 return EFI_UNSUPPORTED;
155 Limit = (MmioOperation ?
MAX_ADDRESS : MAX_IO_PORT_ADDRESS);
157 if (Address > Limit) {
158 return EFI_UNSUPPORTED;
162 if (MaxCount < (Count - 1)) {
163 return EFI_UNSUPPORTED;
166 if (Address >
LShiftU64 (MaxCount - Count + 1, Width)) {
167 return EFI_UNSUPPORTED;
174 if (((
UINTN)Buffer & ((
MIN (
sizeof (
UINTN), mInStride[Width]) - 1))) != 0) {
175 return EFI_UNSUPPORTED;
238 if (EFI_ERROR (Status)) {
245 InStride = mInStride[Width];
246 OutStride = mOutStride[Width];
248 for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {
249 if (OperationWidth == EfiCpuIoWidthUint8) {
251 }
else if (OperationWidth == EfiCpuIoWidthUint16) {
253 }
else if (OperationWidth == EfiCpuIoWidthUint32) {
255 }
else if (OperationWidth == EfiCpuIoWidthUint64) {
320 if (EFI_ERROR (Status)) {
327 InStride = mInStride[Width];
328 OutStride = mOutStride[Width];
330 for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {
331 if (OperationWidth == EfiCpuIoWidthUint8) {
333 }
else if (OperationWidth == EfiCpuIoWidthUint16) {
335 }
else if (OperationWidth == EfiCpuIoWidthUint32) {
337 }
else if (OperationWidth == EfiCpuIoWidthUint64) {
402 if (EFI_ERROR (Status)) {
406 Address +=
PcdGet64 (PcdPciIoTranslation);
411 InStride = mInStride[Width];
412 OutStride = mOutStride[Width];
415 for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {
416 if (OperationWidth == EfiCpuIoWidthUint8) {
418 }
else if (OperationWidth == EfiCpuIoWidthUint16) {
420 }
else if (OperationWidth == EfiCpuIoWidthUint32) {
488 if (EFI_ERROR (Status)) {
492 Address +=
PcdGet64 (PcdPciIoTranslation);
497 InStride = mInStride[Width];
498 OutStride = mOutStride[Width];
501 for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {
502 if (OperationWidth == EfiCpuIoWidthUint8) {
504 }
else if (OperationWidth == EfiCpuIoWidthUint16) {
506 }
else if (OperationWidth == EfiCpuIoWidthUint32) {
548 Status =
gBS->InstallMultipleProtocolInterfaces (
550 &gEfiCpuIo2ProtocolGuid,
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
EFI_CPU_IO_PROTOCOL_WIDTH
STATIC EFI_STATUS EFIAPI CpuMemoryServiceRead(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, OUT VOID *Buffer)
STATIC EFI_HANDLE mHandle
EFI_STATUS EFIAPI CpuMmio2Initialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC EFI_STATUS EFIAPI CpuIoServiceWrite(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer)
STATIC EFI_STATUS EFIAPI CpuMemoryServiceWrite(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer)
STATIC EFI_STATUS EFIAPI CpuIoServiceRead(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, OUT VOID *Buffer)
STATIC EFI_STATUS CpuIoCheckParameter(IN BOOLEAN MmioOperation, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer)
UINT64 EFIAPI MmioWrite64(IN UINTN Address, IN UINT64 Value)
UINT64 EFIAPI MmioRead64(IN UINTN Address)
UINT16 EFIAPI MmioRead16(IN UINTN Address)
UINT8 EFIAPI MmioRead8(IN UINTN Address)
UINT8 EFIAPI MmioWrite8(IN UINTN Address, IN UINT8 Value)
UINT32 EFIAPI MmioRead32(IN UINTN Address)
UINT16 EFIAPI MmioWrite16(IN UINTN Address, IN UINT16 Value)
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
#define ASSERT_EFI_ERROR(StatusParameter)
#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
#define PcdGet64(TokenName)