iPXE
mlx_pci.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2015 Mellanox Technologies Ltd.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  */
00019 
00020 FILE_LICENCE ( GPL2_OR_LATER );
00021 
00022 #include <stddef.h>
00023 
00024 #include "../../include/private/mlx_pci_priv.h"
00025 #include "../../include/public/mlx_pci.h"
00026 
00027 mlx_status
00028 mlx_pci_init(
00029                         IN mlx_utils *utils
00030                         )
00031 {
00032         mlx_status status = MLX_SUCCESS;
00033         if( utils == NULL){
00034                 status = MLX_INVALID_PARAMETER;
00035                 goto bail;
00036         }
00037         status = mlx_pci_init_priv(utils);
00038 bail:
00039         return status;
00040 }
00041 
00042 mlx_status
00043 mlx_pci_teardown(
00044                         IN mlx_utils *utils
00045                         )
00046 {
00047         mlx_status status = MLX_SUCCESS;
00048         if( utils == NULL){
00049                 status = MLX_INVALID_PARAMETER;
00050                 goto bail;
00051         }
00052         status = mlx_pci_teardown_priv(utils);
00053 bail:
00054         return status;
00055 }
00056 
00057 mlx_status
00058 mlx_pci_read(
00059                         IN mlx_utils *utils,
00060                         IN mlx_pci_width width,
00061                         IN mlx_uint32 offset,
00062                         IN mlx_uintn count,
00063                         OUT mlx_void *buffer
00064                         )
00065 {
00066         mlx_status status = MLX_SUCCESS;
00067         if( utils == NULL || count == 0){
00068                 status = MLX_INVALID_PARAMETER;
00069                 goto bail;
00070         }
00071         status = mlx_pci_read_priv(utils, width, offset, count, buffer);
00072 bail:
00073         return status;
00074 }
00075 
00076 mlx_status
00077 mlx_pci_write(
00078                         IN mlx_utils *utils,
00079                         IN mlx_pci_width width,
00080                         IN mlx_uint32 offset,
00081                         IN mlx_uintn count,
00082                         IN mlx_void *buffer
00083                         )
00084 {
00085         mlx_status status = MLX_SUCCESS;
00086         if( utils == NULL || count == 0){
00087                 status = MLX_INVALID_PARAMETER;
00088                 goto bail;
00089         }
00090         status = mlx_pci_write_priv(utils, width, offset, count, buffer);
00091 bail:
00092         return status;
00093 }
00094 
00095 mlx_status
00096 mlx_pci_mem_read(
00097                                 IN mlx_utils *utils,
00098                                 IN mlx_pci_width width,
00099                                 IN mlx_uint8 bar_index,
00100                                 IN mlx_uint64 offset,
00101                                 IN mlx_uintn count,
00102                                 OUT mlx_void *buffer
00103                                 )
00104 {
00105         mlx_status status = MLX_SUCCESS;
00106         if( utils == NULL || count == 0){
00107                 status = MLX_INVALID_PARAMETER;
00108                 goto bail;
00109         }
00110         status = mlx_pci_mem_read_priv(utils, width,bar_index, offset, count, buffer);
00111 bail:
00112         return status;
00113 }
00114 
00115 mlx_status
00116 mlx_pci_mem_write(
00117                                 IN mlx_utils *utils,
00118                                 IN mlx_pci_width width,
00119                                 IN mlx_uint8 bar_index,
00120                                 IN mlx_uint64 offset,
00121                                 IN mlx_uintn count,
00122                                 IN mlx_void *buffer
00123                                 )
00124 {
00125         mlx_status status = MLX_SUCCESS;
00126         if( utils == NULL || count == 0){
00127                 status = MLX_INVALID_PARAMETER;
00128                 goto bail;
00129         }
00130         status = mlx_pci_mem_write_priv(utils, width, bar_index, offset, count, buffer);
00131 bail:
00132         return status;
00133 }