iPXE
mlx_utils.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_utils_priv.h"
00025 #include "../../include/public/mlx_pci.h"
00026 #include "../../include/public/mlx_utils.h"
00027 mlx_status
00028 mlx_utils_init(
00029                                 IN mlx_utils *utils,
00030                                 IN mlx_pci *pci
00031                                 )
00032 {
00033         mlx_status status = MLX_SUCCESS;
00034         if( pci == NULL || utils == NULL ){
00035                 status = MLX_INVALID_PARAMETER;
00036                 goto bail;
00037         }
00038         utils->pci = pci;
00039         status = mlx_pci_init(utils);
00040         status = mlx_utils_init_lock(utils);
00041 bail:
00042         return status;
00043 }
00044 
00045 mlx_status
00046 mlx_utils_teardown(
00047                                 IN mlx_utils *utils
00048                                 )
00049 {
00050         mlx_status status = MLX_SUCCESS;
00051         mlx_utils_free_lock(utils);
00052         mlx_pci_teardown(utils);
00053         return status;
00054 }
00055 
00056 mlx_status
00057 mlx_utils_delay_in_ms(
00058                         IN mlx_uint32 msecs
00059                 )
00060 {
00061         mlx_utils_delay_in_ms_priv(msecs);
00062         return MLX_SUCCESS;
00063 }
00064 mlx_status
00065 mlx_utils_delay_in_us(
00066                         IN mlx_uint32 usecs
00067                 )
00068 {
00069         mlx_utils_delay_in_us_priv(usecs);
00070         return MLX_SUCCESS;
00071 }
00072 mlx_status
00073 mlx_utils_ilog2(
00074                         IN mlx_uint32 i,
00075                         OUT mlx_uint32 *log
00076                 )
00077 {
00078         mlx_utils_ilog2_priv(i, log);
00079         return MLX_SUCCESS;
00080 }
00081 
00082 mlx_status
00083 mlx_utils_init_lock(
00084                         IN OUT mlx_utils *utils
00085                 )
00086 {
00087         return mlx_utils_init_lock_priv(&(utils->lock));
00088 
00089 }
00090 
00091 mlx_status
00092 mlx_utils_free_lock(
00093                         IN OUT mlx_utils *utils
00094                 )
00095 {
00096         return mlx_utils_free_lock_priv(utils->lock);
00097 }
00098 
00099 mlx_status
00100 mlx_utils_acquire_lock (
00101                         IN OUT mlx_utils *utils
00102                 )
00103 {
00104         return mlx_utils_acquire_lock_priv(utils->lock);
00105 }
00106 
00107 mlx_status
00108 mlx_utils_release_lock (
00109                 IN OUT mlx_utils *utils
00110                 )
00111 {
00112         return mlx_utils_release_lock_priv(utils->lock);
00113 }
00114 
00115 mlx_status
00116 mlx_utils_rand (
00117                 IN mlx_utils *utils,
00118                 OUT mlx_uint32 *rand_num
00119                 )
00120 {
00121         return mlx_utils_rand_priv(utils, rand_num);
00122 }