/** @file
Produces the CPU I/O PPI.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "CpuIoPei.h"
//
// Instance of CPU I/O PPI
//
{
},
{
},
};
//
// PPI Descriptor used to install the CPU I/O PPI
//
};
//
// Lookup table for increment values based on transfer widths
//
1, // EfiPeiCpuIoWidthUint8
2, // EfiPeiCpuIoWidthUint16
4, // EfiPeiCpuIoWidthUint32
8, // EfiPeiCpuIoWidthUint64
0, // EfiPeiCpuIoWidthFifoUint8
0, // EfiPeiCpuIoWidthFifoUint16
0, // EfiPeiCpuIoWidthFifoUint32
0, // EfiPeiCpuIoWidthFifoUint64
1, // EfiPeiCpuIoWidthFillUint8
2, // EfiPeiCpuIoWidthFillUint16
4, // EfiPeiCpuIoWidthFillUint32
8 // EfiPeiCpuIoWidthFillUint64
};
//
// Lookup table for increment values based on transfer widths
//
1, // EfiPeiCpuIoWidthUint8
2, // EfiPeiCpuIoWidthUint16
4, // EfiPeiCpuIoWidthUint32
8, // EfiPeiCpuIoWidthUint64
1, // EfiPeiCpuIoWidthFifoUint8
2, // EfiPeiCpuIoWidthFifoUint16
4, // EfiPeiCpuIoWidthFifoUint32
8, // EfiPeiCpuIoWidthFifoUint64
0, // EfiPeiCpuIoWidthFillUint8
0, // EfiPeiCpuIoWidthFillUint16
0, // EfiPeiCpuIoWidthFillUint32
0 // EfiPeiCpuIoWidthFillUint64
};
/**
Check parameters to a CPU I/O PPI service request.
@param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation.
@param[in] Width The width of the access. Enumerated in bytes.
@param[in] Address The physical address of the access.
@param[in] Count The number of accesses to perform.
@param[in] Buffer A pointer to the buffer of data.
@retval EFI_SUCCESS The parameters for this request pass the checks.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI system.
@retval EFI_INVALID_PARAMETER Buffer is NULL.
@retval EFI_UNSUPPORTED The address range specified by Address, Width,
and Count is not valid for this EFI system.
**/
)
{
//
// Check to see if Buffer is NULL
//
return EFI_INVALID_PARAMETER;
}
//
// Check to see if Width is in the valid range
//
return EFI_INVALID_PARAMETER;
}
//
// For FIFO type, the target address won't increase during the access,
// so treat Count as 1
//
Count = 1;
}
//
// Check to see if Width is in the valid range for I/O Port operations
//
return EFI_INVALID_PARAMETER;
}
//
// Check to see if any address associated with this transfer exceeds the maximum
// allowed address. The maximum address implied by the parameters passed in is
// Address + Size * Count. If the following condition is met, then the transfer
// is not supported.
//
// Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1
//
// Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count
// can also be the maximum integer value supported by the CPU, this range
// check must be adjusted to avoid all overflow conditions.
//
// The following form of the range check is equivalent but assumes that
// MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1).
//
if (Count == 0) {
return EFI_UNSUPPORTED;
}
} else {
return EFI_UNSUPPORTED;
}
return EFI_UNSUPPORTED;
}
}
return EFI_SUCCESS;
}
/**
Reads memory-mapped registers.
@param[in] PeiServices An indirect pointer to the PEI Services Table
published by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Width The width of the access. Enumerated in bytes.
@param[in] Address The physical address of the access.
@param[in] Count The number of accesses to perform.
@param[out] Buffer A pointer to the buffer of data.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI system.
@retval EFI_INVALID_PARAMETER Buffer is NULL.
@retval EFI_UNSUPPORTED The address range specified by Address, Width,
and Count is not valid for this EFI system.
**/
)
{
return Status;
}
//
// Select loop based on the width of the transfer
//
if (OperationWidth == EfiPeiCpuIoWidthUint8) {
} else if (OperationWidth == EfiPeiCpuIoWidthUint16) {
if (Aligned) {
} else {
}
} else if (OperationWidth == EfiPeiCpuIoWidthUint32) {
if (Aligned) {
} else {
}
} else if (OperationWidth == EfiPeiCpuIoWidthUint64) {
if (Aligned) {
} else {
}
}
}
return EFI_SUCCESS;
}
/**
Writes memory-mapped registers.
@param[in] PeiServices An indirect pointer to the PEI Services Table
published by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Width The width of the access. Enumerated in bytes.
@param[in] Address The physical address of the access.
@param[in] Count The number of accesses to perform.
@param[in] Buffer A pointer to the buffer of data.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI system.
@retval EFI_INVALID_PARAMETER Buffer is NULL.
@retval EFI_UNSUPPORTED The address range specified by Address, Width,
and Count is not valid for this EFI system.
**/
)
{
return Status;
}
//
// Select loop based on the width of the transfer
//
if (OperationWidth == EfiPeiCpuIoWidthUint8) {
} else if (OperationWidth == EfiPeiCpuIoWidthUint16) {
if (Aligned) {
} else {
}
} else if (OperationWidth == EfiPeiCpuIoWidthUint32) {
if (Aligned) {
} else {
}
} else if (OperationWidth == EfiPeiCpuIoWidthUint64) {
if (Aligned) {
} else {
}
}
}
return EFI_SUCCESS;
}
/**
Reads I/O registers.
@param[in] PeiServices An indirect pointer to the PEI Services Table
published by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Width The width of the access. Enumerated in bytes.
@param[in] Address The physical address of the access.
@param[in] Count The number of accesses to perform.
@param[out] Buffer A pointer to the buffer of data.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI system.
@retval EFI_INVALID_PARAMETER Buffer is NULL.
@retval EFI_UNSUPPORTED The address range specified by Address, Width,
and Count is not valid for this EFI system.
**/
)
{
return Status;
}
//
// Select loop based on the width of the transfer
//
if (OperationWidth == EfiPeiCpuIoWidthUint8) {
} else if (OperationWidth == EfiPeiCpuIoWidthUint16) {
if (Aligned) {
} else {
}
} else if (OperationWidth == EfiPeiCpuIoWidthUint32) {
if (Aligned) {
} else {
}
}
}
return EFI_SUCCESS;
}
/**
Write I/O registers.
@param[in] PeiServices An indirect pointer to the PEI Services Table
published by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Width The width of the access. Enumerated in bytes.
@param[in] Address The physical address of the access.
@param[in] Count The number of accesses to perform.
@param[in] Buffer A pointer to the buffer of data.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI system.
@retval EFI_INVALID_PARAMETER Buffer is NULL.
@retval EFI_UNSUPPORTED The address range specified by Address, Width,
and Count is not valid for this EFI system.
**/
)
{
//
// Make sure the parameters are valid
//
return Status;
}
//
// Select loop based on the width of the transfer
//
for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {
if (OperationWidth == EfiPeiCpuIoWidthUint8) {
} else if (OperationWidth == EfiPeiCpuIoWidthUint16) {
if (Aligned) {
} else {
}
} else if (OperationWidth == EfiPeiCpuIoWidthUint32) {
if (Aligned) {
} else {
}
}
}
return EFI_SUCCESS;
}
/**
8-bit I/O read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return An 8-bit value returned from the I/O space.
**/
)
{
}
/**
16-bit I/O read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return A 16-bit value returned from the I/O space.
**/
)
{
}
/**
32-bit I/O read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return A 32-bit value returned from the I/O space.
**/
)
{
}
/**
64-bit I/O read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return A 64-bit value returned from the I/O space.
**/
)
{
}
/**
8-bit I/O write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
16-bit I/O write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
32-bit I/O write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
64-bit I/O write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
8-bit memory read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return An 8-bit value returned from the memory space.
**/
)
{
}
/**
16-bit memory read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return A 16-bit value returned from the memory space.
**/
)
{
}
/**
32-bit memory read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return A 32-bit value returned from the memory space.
**/
)
{
}
/**
64-bit memory read operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@return A 64-bit value returned from the memory space.
**/
)
{
}
/**
8-bit memory write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
16-bit memory write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
32-bit memory write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
64-bit memory write operations.
@param[in] PeiServices An indirect pointer to the PEI Services Table published
by the PEI Foundation.
@param[in] This Pointer to local data for the interface.
@param[in] Address The physical address of the access.
@param[in] Data The data to write.
**/
)
{
}
/**
The Entry point of the CPU I/O PEIM
This function is the Entry point of the CPU I/O PEIM which installs CpuIoPpi.
@param[in] FileHandle Pointer to image file handle.
@param[in] PeiServices Pointer to PEI Services Table
@retval EFI_SUCCESS CPU I/O PPI successfully installed
**/
)
{
//
// Register so it will be automatically shadowed to memory
//
//
// Make CpuIo pointer in PeiService table point to gCpuIoPpi
//
if (Status == EFI_ALREADY_STARTED) {
//
// Shadow completed and running from memory
//
} else {
}
return EFI_SUCCESS;
}