RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
pci_endpoint.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2022, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2022-08-25 GuEe-GUI first version
9 */
10
11#ifndef __PCI_ENDPOINT_H__
12#define __PCI_ENDPOINT_H__
13
14#include <drivers/pci.h>
15
24
32
47
49{
50 /* To PCI Bus */
52 /* To CPU */
54};
55
56/*
57 * Type of MSI-X table, For more format detail,
58 * please read `components/drivers/include/drivers/pci_msi.h`
59 */
74
75struct rt_pci_ep_ops;
76struct rt_pci_ep_mem;
77
79{
81 const char *name;
82
83 struct rt_ref ref;
84
85 const struct rt_device *rc_dev;
86 const struct rt_pci_ep_ops *ops;
87
90
92 RT_BITMAP_DECLARE(functions_map, 8);
94 struct rt_mutex lock;
95
96 void *priv;
97};
98
108
123
125{
127 struct rt_pci_ep_header *hdr);
128
129 rt_err_t (*set_bar)(struct rt_pci_ep *ep, rt_uint8_t func_no,
130 struct rt_pci_ep_bar *bar, int bar_idx);
131 rt_err_t (*clear_bar)(struct rt_pci_ep *ep, rt_uint8_t func_no,
132 struct rt_pci_ep_bar *bar, int bar_idx);
133
134 rt_err_t (*map_addr)(struct rt_pci_ep *ep, rt_uint8_t func_no,
135 rt_ubase_t addr, rt_uint64_t pci_addr, rt_size_t size);
136 rt_err_t (*unmap_addr)(struct rt_pci_ep *ep, rt_uint8_t func_no, rt_ubase_t addr);
137
138 rt_err_t (*set_msi)(struct rt_pci_ep *ep, rt_uint8_t func_no,
139 unsigned irq_nr);
140 rt_err_t (*get_msi)(struct rt_pci_ep *ep, rt_uint8_t func_no,
141 unsigned *out_irq_nr);
142
143 rt_err_t (*set_msix)(struct rt_pci_ep *ep, rt_uint8_t func_no,
144 unsigned irq_nr, int bar_idx, rt_off_t offset);
145 rt_err_t (*get_msix)(struct rt_pci_ep *ep, rt_uint8_t func_no,
146 unsigned *out_irq_nr);
147
148 rt_err_t (*raise_irq)(struct rt_pci_ep *ep, rt_uint8_t func_no,
149 enum rt_pci_ep_irq type, unsigned irq);
150
151 rt_err_t (*start)(struct rt_pci_ep *ep);
152 rt_err_t (*stop)(struct rt_pci_ep *ep);
153};
154
156 struct rt_pci_ep_header *hdr);
157
159 struct rt_pci_ep_bar *bar, int bar_idx);
161 struct rt_pci_ep_bar *bar, int bar_idx);
162
164 rt_ubase_t addr, rt_uint64_t pci_addr, rt_size_t size);
166 rt_ubase_t addr);
167
169 unsigned irq_nr);
171 unsigned *out_irq_nr);
172
174 unsigned irq_nr, int bar_idx, rt_off_t offset);
176 unsigned *out_irq_nr);
177
179 enum rt_pci_ep_irq type, unsigned irq);
180
183
186
190 rt_ubase_t cpu_addr, rt_size_t size, rt_size_t page_size);
191
193 rt_ubase_t *out_cpu_addr, rt_size_t size);
195 void *vaddr, rt_ubase_t cpu_addr, rt_size_t size);
196
199
200struct rt_pci_ep *rt_pci_ep_get(const char *name);
201void rt_pci_ep_put(struct rt_pci_ep *ep);
202
203#endif /* __PCI_ENDPOINT_H__ */
rt_pci_ep_pin
@ RT_PCI_EP_PIN_INTB
@ RT_PCI_EP_PIN_INTA
@ RT_PCI_EP_PIN_INTC
@ RT_PCI_EP_PIN_INTD
@ RT_PCI_EP_PIN_UNKNOWN
rt_err_t rt_pci_ep_raise_irq(struct rt_pci_ep *ep, rt_uint8_t func_no, enum rt_pci_ep_irq type, unsigned irq)
rt_err_t rt_pci_ep_register(struct rt_pci_ep *ep)
rt_err_t rt_pci_ep_add_epf(struct rt_pci_ep *ep, struct rt_pci_epf *epf)
rt_err_t rt_pci_ep_mem_init(struct rt_pci_ep *ep, rt_ubase_t cpu_addr, rt_size_t size, rt_size_t page_size)
rt_err_t rt_pci_ep_mem_array_init(struct rt_pci_ep *ep, struct rt_pci_ep_mem *mems, rt_size_t mems_nr)
rt_err_t rt_pci_ep_start(struct rt_pci_ep *ep)
rt_err_t rt_pci_ep_unmap_addr(struct rt_pci_ep *ep, rt_uint8_t func_no, rt_ubase_t addr)
rt_err_t rt_pci_ep_stop(struct rt_pci_ep *ep)
rt_err_t rt_pci_ep_set_bar(struct rt_pci_ep *ep, rt_uint8_t func_no, struct rt_pci_ep_bar *bar, int bar_idx)
rt_pci_ep_irq
@ RT_PCI_EP_IRQ_MSIX
@ RT_PCI_EP_IRQ_LEGACY
@ RT_PCI_EP_IRQ_MSI
@ RT_PCI_EP_IRQ_UNKNOWN
rt_err_t rt_pci_ep_set_msix(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned irq_nr, int bar_idx, rt_off_t offset)
rt_err_t rt_pci_ep_map_addr(struct rt_pci_ep *ep, rt_uint8_t func_no, rt_ubase_t addr, rt_uint64_t pci_addr, rt_size_t size)
void rt_pci_ep_mem_free(struct rt_pci_ep *ep, void *vaddr, rt_ubase_t cpu_addr, rt_size_t size)
struct rt_pci_ep * rt_pci_ep_get(const char *name)
rt_err_t rt_pci_ep_remove_epf(struct rt_pci_ep *ep, struct rt_pci_epf *epf)
rt_err_t rt_pci_ep_get_msi(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned *out_irq_nr)
rt_err_t rt_pci_ep_write_header(struct rt_pci_ep *ep, rt_uint8_t func_no, struct rt_pci_ep_header *hdr)
rt_err_t rt_pci_ep_clear_bar(struct rt_pci_ep *ep, rt_uint8_t func_no, struct rt_pci_ep_bar *bar, int bar_idx)
void * rt_pci_ep_mem_alloc(struct rt_pci_ep *ep, rt_ubase_t *out_cpu_addr, rt_size_t size)
rt_err_t rt_pci_ep_unregister(struct rt_pci_ep *ep)
void rt_pci_ep_put(struct rt_pci_ep *ep)
rt_err_t rt_pci_ep_set_msi(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned irq_nr)
rt_err_t rt_pci_ep_get_msix(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned *out_irq_nr)
rt_base_t rt_off_t
rt_base_t rt_err_t
unsigned char rt_uint8_t
unsigned short rt_uint16_t
rt_ubase_t rt_size_t
struct rt_list_node rt_list_t
unsigned int rt_uint32_t
rt_uint32_t rt_ubase_t
unsigned long long rt_uint64_t
struct rt_pci_bus_resource bus
rt_uint16_t subsystem_vendor
rt_uint16_t subsystem_device
enum rt_pci_ep_pin intx
rt_bitmap_t * map
rt_err_t(* start)(struct rt_pci_ep *ep)
rt_err_t(* raise_irq)(struct rt_pci_ep *ep, rt_uint8_t func_no, enum rt_pci_ep_irq type, unsigned irq)
rt_err_t(* map_addr)(struct rt_pci_ep *ep, rt_uint8_t func_no, rt_ubase_t addr, rt_uint64_t pci_addr, rt_size_t size)
rt_err_t(* unmap_addr)(struct rt_pci_ep *ep, rt_uint8_t func_no, rt_ubase_t addr)
rt_err_t(* set_bar)(struct rt_pci_ep *ep, rt_uint8_t func_no, struct rt_pci_ep_bar *bar, int bar_idx)
rt_err_t(* get_msix)(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned *out_irq_nr)
rt_err_t(* clear_bar)(struct rt_pci_ep *ep, rt_uint8_t func_no, struct rt_pci_ep_bar *bar, int bar_idx)
rt_err_t(* set_msi)(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned irq_nr)
rt_err_t(* get_msi)(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned *out_irq_nr)
rt_err_t(* set_msix)(struct rt_pci_ep *ep, rt_uint8_t func_no, unsigned irq_nr, int bar_idx, rt_off_t offset)
rt_err_t(* write_header)(struct rt_pci_ep *ep, rt_uint8_t func_no, struct rt_pci_ep_header *hdr)
rt_err_t(* stop)(struct rt_pci_ep *ep)
struct rt_pci_ep_mem * mems
struct rt_ref ref
const char * name
rt_uint8_t max_functions
const struct rt_device * rc_dev
rt_list_t epf_nodes
struct rt_mutex lock
RT_BITMAP_DECLARE(functions_map, 8)
const struct rt_pci_ep_ops * ops
rt_size_t mems_nr
struct rt_pci_ep_bar bar[PCI_STD_NUM_BARS]
rt_uint8_t func_no
rt_uint16_t msix_interrupts
const char * name
struct rt_pci_ep_header * header
struct rt_pci_ep * ep
rt_uint8_t msi_interrupts