iPXE
Functions
mlx_pci_priv.c File Reference
#include <ipxe/pci.h>
#include "../../mlx_utils/include/private/mlx_pci_priv.h"

Go to the source code of this file.

Functions

static mlx_status mlx_pci_config_byte (IN mlx_utils *utils, IN mlx_boolean read, IN mlx_uint32 offset, IN OUT mlx_uint8 *buffer)
static mlx_status mlx_pci_config_word (IN mlx_utils *utils, IN mlx_boolean read, IN mlx_uint32 offset, IN OUT mlx_uint16 *buffer)
static mlx_status mlx_pci_config_dword (IN mlx_utils *utils, IN mlx_boolean read, IN mlx_uint32 offset, IN OUT mlx_uint32 *buffer)
static mlx_status mlx_pci_config (IN mlx_utils *utils, IN mlx_boolean read, IN mlx_pci_width width, IN mlx_uint32 offset, IN mlx_uintn count, IN OUT mlx_void *buffer)
mlx_status mlx_pci_init_priv (IN mlx_utils *utils)
mlx_status mlx_pci_teardown_priv (IN mlx_utils *utils)
mlx_status mlx_pci_read_priv (IN mlx_utils *utils, IN mlx_pci_width width, IN mlx_uint32 offset, IN mlx_uintn count, OUT mlx_void *buffer)
mlx_status mlx_pci_write_priv (IN mlx_utils *utils, IN mlx_pci_width width, IN mlx_uint32 offset, IN mlx_uintn count, IN mlx_void *buffer)
mlx_status mlx_pci_mem_read_priv (IN mlx_utils *utils, IN mlx_pci_width width, IN mlx_uint8 bar_index, IN mlx_uint64 offset, IN mlx_uintn count, OUT mlx_void *buffer)
mlx_status mlx_pci_mem_write_priv (IN mlx_utils *utils, IN mlx_pci_width width, IN mlx_uint8 bar_index, IN mlx_uint64 offset, IN mlx_uintn count, IN mlx_void *buffer)

Function Documentation

static mlx_status mlx_pci_config_byte ( IN mlx_utils utils,
IN mlx_boolean  read,
IN mlx_uint32  offset,
IN OUT mlx_uint8 buffer 
) [static]

Definition at line 15 of file mlx_pci_priv.c.

References MLX_SUCCESS, pci_read_config_byte(), pci_write_config_byte(), and status.

Referenced by mlx_pci_config().

{
        mlx_status status = MLX_SUCCESS;
        if (read) {
                status = pci_read_config_byte(utils->pci, offset, buffer);
        }else {
                status = pci_write_config_byte(utils->pci, offset, *buffer);
        }
        return status;
}
static mlx_status mlx_pci_config_word ( IN mlx_utils utils,
IN mlx_boolean  read,
IN mlx_uint32  offset,
IN OUT mlx_uint16 buffer 
) [static]

Definition at line 33 of file mlx_pci_priv.c.

References MLX_SUCCESS, pci_read_config_word(), pci_write_config_word(), and status.

Referenced by mlx_pci_config().

{
        mlx_status status = MLX_SUCCESS;
        if (read) {
                status = pci_read_config_word(utils->pci, offset, buffer);
        }else {
                status = pci_write_config_word(utils->pci, offset, *buffer);
        }
        return status;
}
static mlx_status mlx_pci_config_dword ( IN mlx_utils utils,
IN mlx_boolean  read,
IN mlx_uint32  offset,
IN OUT mlx_uint32 buffer 
) [static]

Definition at line 51 of file mlx_pci_priv.c.

References MLX_SUCCESS, pci_read_config_dword(), pci_write_config_dword(), and status.

Referenced by mlx_pci_config().

{
        mlx_status status = MLX_SUCCESS;
        if (read) {
                status = pci_read_config_dword(utils->pci, offset, buffer);
        }else {
                status = pci_write_config_dword(utils->pci, offset, *buffer);
        }
        return status;
}
static mlx_status mlx_pci_config ( IN mlx_utils utils,
IN mlx_boolean  read,
IN mlx_pci_width  width,
IN mlx_uint32  offset,
IN mlx_uintn  count,
IN OUT mlx_void buffer 
) [static]

Definition at line 68 of file mlx_pci_priv.c.

References count, MLX_INVALID_PARAMETER, mlx_pci_config_byte(), mlx_pci_config_dword(), mlx_pci_config_word(), MLX_SUCCESS, MlxPciWidthUint16, MlxPciWidthUint32, MlxPciWidthUint64, MlxPciWidthUint8, and status.

Referenced by mlx_pci_read_priv(), and mlx_pci_write_priv().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint8 *tmp =  (mlx_uint8*)buffer;
        mlx_uintn iteration = 0;
        if( width == MlxPciWidthUint64) {
                width = MlxPciWidthUint32;
                count = count * 2;
        }

        for(;iteration < count ; iteration++) {
                switch (width){
                case MlxPciWidthUint8:
                        status = mlx_pci_config_byte(utils, read , offset++, tmp++);
                        break;
                case MlxPciWidthUint16:
                        status = mlx_pci_config_word(utils, read , offset, (mlx_uint16*)tmp);
                        tmp += 2;
                        offset += 2;
                        break;
                case MlxPciWidthUint32:
                        status = mlx_pci_config_dword(utils, read , offset, (mlx_uint32*)tmp);
                        tmp += 4;
                        offset += 4;
                        break;
                default:
                        status = MLX_INVALID_PARAMETER;
                }
                if(status != MLX_SUCCESS) {
                        goto config_error;
                }
        }
config_error:
        return status;
}

Definition at line 111 of file mlx_pci_priv.c.

References adjust_pci_device(), ioremap(), MLX_SUCCESS, pci_bar_start(), PCI_BASE_ADDRESS_0, and status.

Referenced by mlx_pci_init().

{
        mlx_status status = MLX_SUCCESS;
        adjust_pci_device ( utils->pci );
#ifdef DEVICE_CX3
        utils->config = ioremap ( pci_bar_start ( utils->pci, PCI_BASE_ADDRESS_0),
                        0x100000 );
#endif
        return status;
}

Definition at line 125 of file mlx_pci_priv.c.

References iounmap(), MLX_SUCCESS, and status.

Referenced by mlx_pci_teardown().

{
        mlx_status status = MLX_SUCCESS;
#ifdef DEVICE_CX3
        iounmap( utils->config );
#endif
        return status;
}
mlx_status mlx_pci_read_priv ( IN mlx_utils utils,
IN mlx_pci_width  width,
IN mlx_uint32  offset,
IN mlx_uintn  count,
OUT mlx_void buffer 
)

Definition at line 137 of file mlx_pci_priv.c.

References mlx_pci_config(), MLX_SUCCESS, status, and TRUE.

Referenced by mlx_pci_read().

{
        mlx_status status = MLX_SUCCESS;
        status = mlx_pci_config(utils, TRUE, width, offset, count, buffer);
        return status;
}
mlx_status mlx_pci_write_priv ( IN mlx_utils utils,
IN mlx_pci_width  width,
IN mlx_uint32  offset,
IN mlx_uintn  count,
IN mlx_void buffer 
)

Definition at line 151 of file mlx_pci_priv.c.

References FALSE, mlx_pci_config(), MLX_SUCCESS, and status.

Referenced by mlx_pci_write().

{
        mlx_status status = MLX_SUCCESS;
        status = mlx_pci_config(utils, FALSE, width, offset, count, buffer);
        return status;
}
mlx_status mlx_pci_mem_read_priv ( IN mlx_utils utils,
IN mlx_pci_width  width,
IN mlx_uint8  bar_index,
IN mlx_uint64  offset,
IN mlx_uintn  count,
OUT mlx_void buffer 
)

Definition at line 165 of file mlx_pci_priv.c.

References MLX_INVALID_PARAMETER, MLX_SUCCESS, MlxPciWidthUint32, NULL, and readl().

Referenced by mlx_pci_mem_read().

{
        if (buffer == NULL || width != MlxPciWidthUint32)
                return MLX_INVALID_PARAMETER;
        *((mlx_uint32 *)buffer) = readl(offset);
        return MLX_SUCCESS;
}
mlx_status mlx_pci_mem_write_priv ( IN mlx_utils utils,
IN mlx_pci_width  width,
IN mlx_uint8  bar_index,
IN mlx_uint64  offset,
IN mlx_uintn  count,
IN mlx_void buffer 
)

Definition at line 181 of file mlx_pci_priv.c.

References barrier, MLX_INVALID_PARAMETER, MLX_SUCCESS, MlxPciWidthUint32, NULL, and writel().

Referenced by mlx_pci_mem_write().