iPXE
mlx_pci_priv.c
Go to the documentation of this file.
1/*
2 * MlxPciPriv.c
3 *
4 * Created on: Jan 21, 2015
5 * Author: maord
6 */
7
8#include <ipxe/pci.h>
9
11
12
13static
16 IN mlx_utils *utils,
20 )
21{
23 if (read) {
25 }else {
27 }
28 return status;
29}
30
31static
34 IN mlx_utils *utils,
38 )
39{
41 if (read) {
43 }else {
45 }
46 return status;
47}
48
49static
52 IN mlx_utils *utils,
56 )
57{
59 if (read) {
61 }else {
63 }
64 return status;
65}
66static
69 IN mlx_utils *utils,
71 IN mlx_pci_width width,
75 )
76{
79 mlx_uintn iteration = 0;
80 if( width == MlxPciWidthUint64) {
81 width = MlxPciWidthUint32;
82 count = count * 2;
83 }
84
85 for(;iteration < count ; iteration++) {
86 switch (width){
88 status = mlx_pci_config_byte(utils, read , offset++, tmp++);
89 break;
92 tmp += 2;
93 offset += 2;
94 break;
97 tmp += 4;
98 offset += 4;
99 break;
100 default:
102 }
103 if(status != MLX_SUCCESS) {
104 goto config_error;
105 }
106 }
107config_error:
108 return status;
109}
112 IN mlx_utils *utils
113 )
114{
116 adjust_pci_device ( utils->pci );
117#ifdef DEVICE_CX3
118 utils->config = pci_ioremap ( utils->pci, pci_bar_start ( utils->pci, PCI_BASE_ADDRESS_0),
119 0x100000 );
120#endif
121 return status;
122}
123
127 )
128{
130#ifdef DEVICE_CX3
131 iounmap( utils->config );
132#endif
133 return status;
134}
135
138 IN mlx_utils *utils,
139 IN mlx_pci_width width,
143 )
144{
146 status = mlx_pci_config(utils, TRUE, width, offset, count, buffer);
147 return status;
148}
149
152 IN mlx_utils *utils,
153 IN mlx_pci_width width,
157 )
158{
160 status = mlx_pci_config(utils, FALSE, width, offset, count, buffer);
161 return status;
162}
163
179
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
uint16_t offset
Offset to command line.
Definition bzimage.h:3
uint8_t status
Status.
Definition ena.h:5
static unsigned int count
Number of entries.
Definition dwmac.h:220
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition netvsc.h:5
#define barrier()
Optimisation barrier.
Definition compiler.h:633
#define __attribute__(x)
Definition compiler.h:10
void iounmap(volatile const void *io_addr)
Unmap I/O address.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
uint8_t unused
Unused.
Definition librm.h:5
unsigned long tmp
Definition linux_pci.h:65
mlx_pci_width
Definition mlx_pci.h:27
@ MlxPciWidthUint16
Definition mlx_pci.h:29
@ MlxPciWidthUint64
Definition mlx_pci.h:31
@ MlxPciWidthUint32
Definition mlx_pci.h:30
@ MlxPciWidthUint8
Definition mlx_pci.h:28
mlx_status mlx_pci_init_priv(IN mlx_utils *utils)
mlx_status mlx_pci_teardown_priv(IN mlx_utils *utils)
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 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_byte(IN mlx_utils *utils, IN mlx_boolean read, IN mlx_uint32 offset, IN OUT mlx_uint8 *buffer)
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)
static mlx_status mlx_pci_config_dword(IN mlx_utils *utils, IN mlx_boolean read, IN mlx_uint32 offset, IN OUT mlx_uint32 *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)
uint16_t mlx_uint16
uint32_t mlx_uint32
uint64_t mlx_uint64
#define MLX_INVALID_PARAMETER
void mlx_void
#define MLX_SUCCESS
int mlx_status
uint8_t mlx_boolean
uint8_t mlx_uint8
unsigned long mlx_uintn
#define IN
Definition mlx_utils.h:28
#define OUT
Definition mlx_utils.h:29
struct option_descriptor read[1]
Definition nvo_cmd.c:116
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition pci.c:97
PCI bus.
#define PCI_BASE_ADDRESS_0
Definition pci.h:63
#define TRUE
Definition tlan.h:46
#define FALSE
Definition tlan.h:45
#define readl
Definition w89c840.c:157
#define writel
Definition w89c840.c:160