12 #ifndef __PCI_ACCESS_H__ 13 #define __PCI_ACCESS_H__ 16 #include <libcpu/byteorder.h> 25 typedef uint16_t pci_dev_t;
27 #define PCI_DEV(bus, slot, func) (((bus)<<8) | ((slot)<<3) | (func)) 29 #define PCI_DEV_BUS(dev) (((dev) >> 8) & 0xff) 31 #define PCI_DEV_SLOT(dev) (((dev) >> 3) & 0x1f) 33 #define PCI_DEV_FUNC(dev) ((dev) & 0x7) 35 #define PCI_DEV_DEVFUNC(dev) ((dev) & 0xff) 37 #define PCI_DEV_EXPAND(dev) PCI_DEV_BUS((dev)), PCI_DEV_SLOT((dev)), PCI_DEV_FUNC((dev)) 42 int (*read8)(pci_dev_t dev,
int ofs, uint8_t *data);
43 int (*read16)(pci_dev_t dev,
int ofs, uint16_t *data);
44 int (*read32)(pci_dev_t dev,
int ofs, uint32_t *data);
45 int (*write8)(pci_dev_t dev,
int ofs, uint8_t data);
46 int (*write16)(pci_dev_t dev,
int ofs, uint16_t data);
47 int (*write32)(pci_dev_t dev,
int ofs, uint32_t data);
54 uint8_t (*read8)(uint8_t *adr);
55 uint16_t(*read16)(uint16_t *adr);
56 uint32_t (*read32)(uint32_t *adr);
57 void (*write8)(uint8_t *adr, uint8_t data);
58 void (*write16)(uint16_t *adr, uint16_t data);
59 void (*write32)(uint32_t *adr, uint32_t data);
66 uint8_t (*ld8)(uint8_t *adr);
67 void (*st8)(uint8_t *adr, uint8_t data);
69 uint16_t(*ld_le16)(uint16_t *adr);
70 void (*st_le16)(uint16_t *adr, uint16_t data);
71 uint16_t(*ld_be16)(uint16_t *adr);
72 void (*st_be16)(uint16_t *adr, uint16_t data);
74 uint32_t (*ld_le32)(uint32_t *adr);
75 void (*st_le32)(uint32_t *adr, uint32_t data);
76 uint32_t (*ld_be32)(uint32_t *adr);
77 void (*st_be32)(uint32_t *adr, uint32_t data);
80 typedef uint8_t (*pci_ld8_t)(uint8_t *adr);
81 typedef void (*pci_st8_t)(uint8_t *adr, uint8_t data);
82 typedef uint16_t(pci_ld16_t)(uint16_t *adr);
83 typedef void (*pci_st16_t)(uint16_t *adr, uint16_t data);
84 typedef uint32_t (*pci_ld32_t)(uint32_t *adr);
85 typedef void (*pci_st32_t)(uint32_t *adr, uint32_t data);
117 int (*translate)(uint32_t *address,
int type,
int dir);
127 extern void pci_modify_cmdsts(pci_dev_t dev, uint32_t mask, uint32_t val);
132 pci_modify_cmdsts(dev, PCIM_CMD_MEMEN, PCIM_CMD_MEMEN);
137 pci_modify_cmdsts(dev, PCIM_CMD_MEMEN, 0);
142 pci_modify_cmdsts(dev, PCIM_CMD_PORTEN, PCIM_CMD_PORTEN);
147 pci_modify_cmdsts(dev, PCIM_CMD_PORTEN, 0);
152 pci_modify_cmdsts(dev, PCIM_CMD_BUSMASTEREN, PCIM_CMD_BUSMASTEREN);
157 pci_modify_cmdsts(dev, PCIM_CMD_BUSMASTEREN, 0);
161 extern int pci_cfg_r8(pci_dev_t dev,
int ofs, uint8_t *data);
162 extern int pci_cfg_r16(pci_dev_t dev,
int ofs, uint16_t *data);
163 extern int pci_cfg_r32(pci_dev_t dev,
int ofs, uint32_t *data);
166 extern int pci_cfg_w8(pci_dev_t dev,
int ofs, uint8_t data);
167 extern int pci_cfg_w16(pci_dev_t dev,
int ofs, uint16_t data);
168 extern int pci_cfg_w32(pci_dev_t dev,
int ofs, uint32_t data);
171 extern uint8_t pci_io_r8(uint32_t adr);
172 extern uint16_t pci_io_r16(uint32_t adr);
173 extern uint32_t pci_io_r32(uint32_t adr);
176 extern void pci_io_w8(uint32_t adr, uint8_t data);
177 extern void pci_io_w16(uint32_t adr, uint16_t data);
178 extern void pci_io_w32(uint32_t adr, uint32_t data);
183 return pci_access_ops.translate(address, type, 0);
189 return pci_access_ops.translate(address, type, 1);
211 uint8_t pci_mem_ld8(uint8_t *adr);
212 void pci_mem_st8(uint8_t *adr, uint8_t data);
214 uint16_t pci_mem_be_ld_le16(uint16_t *adr);
215 uint16_t pci_mem_be_ld_be16(uint16_t *adr);
216 uint32_t pci_mem_be_ld_le32(uint32_t *adr);
217 uint32_t pci_mem_be_ld_be32(uint32_t *adr);
218 void pci_mem_be_st_le16(uint16_t *adr, uint16_t data);
219 void pci_mem_be_st_be16(uint16_t *adr, uint16_t data);
220 void pci_mem_be_st_le32(uint32_t *adr, uint32_t data);
221 void pci_mem_be_st_be32(uint32_t *adr, uint32_t data);
223 uint16_t pci_mem_le_ld_le16(uint16_t *adr);
224 uint16_t pci_mem_le_ld_be16(uint16_t *adr);
225 uint32_t pci_mem_le_ld_le32(uint32_t *adr);
226 uint32_t pci_mem_le_ld_be32(uint32_t *adr);
227 void pci_mem_le_st_le16(uint16_t *adr, uint16_t data);
228 void pci_mem_le_st_be16(uint16_t *adr, uint16_t data);
229 void pci_mem_le_st_le32(uint32_t *adr, uint32_t data);
230 void pci_mem_le_st_be32(uint32_t *adr, uint32_t data);
246 extern int pci_access_func(
int wr,
int size,
void **func,
int endian,
int type);
unsigned size
Definition: tte.h:74
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66