iPXE
mlx_pci.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Mellanox Technologies Ltd.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <stddef.h>
23 
24 #include "../../include/private/mlx_pci_priv.h"
25 #include "../../include/public/mlx_pci.h"
26 
29  IN mlx_utils *utils
30  )
31 {
33  if( utils == NULL){
35  goto bail;
36  }
37  status = mlx_pci_init_priv(utils);
38 bail:
39  return status;
40 }
41 
44  IN mlx_utils *utils
45  )
46 {
48  if( utils == NULL){
50  goto bail;
51  }
53 bail:
54  return status;
55 }
56 
59  IN mlx_utils *utils,
60  IN mlx_pci_width width,
64  )
65 {
67  if( utils == NULL || count == 0){
69  goto bail;
70  }
71  status = mlx_pci_read_priv(utils, width, offset, count, buffer);
72 bail:
73  return status;
74 }
75 
78  IN mlx_utils *utils,
79  IN mlx_pci_width width,
83  )
84 {
86  if( utils == NULL || count == 0){
88  goto bail;
89  }
90  status = mlx_pci_write_priv(utils, width, offset, count, buffer);
91 bail:
92  return status;
93 }
94 
97  IN mlx_utils *utils,
98  IN mlx_pci_width width,
99  IN mlx_uint8 bar_index,
103  )
104 {
106  if( utils == NULL || count == 0){
108  goto bail;
109  }
110  status = mlx_pci_mem_read_priv(utils, width,bar_index, offset, count, buffer);
111 bail:
112  return status;
113 }
114 
117  IN mlx_utils *utils,
118  IN mlx_pci_width width,
119  IN mlx_uint8 bar_index,
123  )
124 {
126  if( utils == NULL || count == 0){
128  goto bail;
129  }
130  status = mlx_pci_mem_write_priv(utils, width, bar_index, offset, count, buffer);
131 bail:
132  return status;
133 }
mlx_status mlx_pci_read(IN mlx_utils *utils, IN mlx_pci_width width, IN mlx_uint32 offset, IN mlx_uintn count, OUT mlx_void *buffer)
Definition: mlx_pci.c:58
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: mlx_pci_priv.c:137
#define MLX_INVALID_PARAMETER
mlx_status mlx_pci_init(IN mlx_utils *utils)
Definition: mlx_pci.c:28
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: mlx_pci_priv.c:181
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
mlx_status mlx_pci_teardown_priv(IN mlx_utils *utils)
Definition: mlx_pci_priv.c:125
mlx_pci_width
Definition: mlx_pci.h:27
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
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: mlx_pci_priv.c:165
#define OUT
Definition: mlx_utils.h:29
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
mlx_status mlx_pci_init_priv(IN mlx_utils *utils)
Definition: mlx_pci_priv.c:111
#define MLX_SUCCESS
mlx_status mlx_pci_teardown(IN mlx_utils *utils)
Definition: mlx_pci.c:43
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: mlx_pci_priv.c:151
FILE_LICENCE(GPL2_OR_LATER)
void mlx_void
#define IN
Definition: mlx_utils.h:28
unsigned long mlx_uintn
uint8_t mlx_uint8
uint16_t count
Number of entries.
Definition: ena.h:22
int mlx_status
mlx_status mlx_pci_write(IN mlx_utils *utils, IN mlx_pci_width width, IN mlx_uint32 offset, IN mlx_uintn count, IN mlx_void *buffer)
Definition: mlx_pci.c:77
uint64_t mlx_uint64
mlx_status mlx_pci_mem_write(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: mlx_pci.c:116
mlx_status mlx_pci_mem_read(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: mlx_pci.c:96
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362