XenevaOS
Loading...
Searching...
No Matches
pcie.h
Go to the documentation of this file.
1
30#ifndef __PCIE_H__
31#define __PCIE_H__
32
33#include <stdint.h>
34#include <Hal\basicacpi.h>
35#include <Hal\hal.h>
36
37
38#define PCI_VENDOR_ID 0x00
39#define PCI_DEVICE_ID 0x02
40#define PCI_COMMAND 0x04
41#define PCI_STATUS 0x06
42#define PCI_REVISION_ID 0x08
43#define PCI_PROG_IF 0x09
44#define PCI_SUBCLASS 0x0a
45#define PCI_CLASS 0x0b
46#define PCI_CACHE_LINE_SIZE 0x0c
47#define PCI_LATENCY_TIMER 0x0d
48#define PCI_HEADER_TYPE 0x0e
49#define PCI_BIST 0x0f
50#define PCI_BAR0 0x10
51#define PCI_BAR1 0x14
52#define PCI_BAR2 0x18
53#define PCI_BAR3 0x1C
54#define PCI_BAR4 0x20
55#define PCI_BAR5 0x24
56#define PCI_CAPABILITIES_PTR 0x34
57#define PCI_INTERRUPT_LINE 0x3C
58#define PCI_INTERRUPT_PIN 0x3D
59
60#define PCI_MAX_BUS 0x20
61#define PCI_DEVICE_PER_BUS 32
62#define PCI_FUNCTION_PER_DEVICE 8
63
64
65/*
66* AuPCIEGetDevice -- gets a device address from its bus
67* dev and func
68* @param seg -- device segment
69* @param bus -- bus of the device
70* @param dev -- device number
71* @param func -- function number
72*/
73extern uint64_t AuPCIEGetDevice(uint16_t seg, int bus, int dev, int func);
74/*
75* AuPCIEAllocMSI -- Allocate MSI/MSI-X for interrupt
76* @todo -- MSIX not implemented yet
77* @param device -- PCIe device address
78* @param vector -- interrupt vector
79* @param bus -- PCIe device bus number
80* @param dev -- PCIe device dev number
81* @param func -- PCIe device function number
82*/
83AU_EXTERN AU_EXPORT bool AuPCIEAllocMSI(uint64_t device, size_t vector, int bus, int dev, int func);
84
85/*
86* AuPCIEScanClassIF -- scans and return pcie device with given class code and sub class code
87* @param classCode -- class code
88* @param subClassCode -- sub class code
89* @param bus -- address, where bus number will be stored
90* @param dev -- address, where device number will be stored
91* @param func -- address, where function number will be stored
92* @param progIf -- Programming interface
93*/
94AU_EXTERN AU_EXPORT uint64_t AuPCIEScanClassIF(uint8_t classCode, uint8_t subClassCode, uint8_t progIf, int *bus_, int *dev_, int *func_);
95
96/*
97* AuPCIEScanVendorDevice -- scans and return pcie device with given vendor id and device id
98* @param vendor -- vendor id
99* @param device -- device id
100* @param bus -- address, where bus number will be stored
101* @param dev -- address, where device number will be stored
102* @param func -- address, where function number will be stored
103*/
104AU_EXTERN AU_EXPORT uint64_t AuPCIEScanVendorDevice(uint16_t vendor, uint16_t device, int* bus_, int* dev_, int* func_);
105
106/*
107* AuPCIEScanClass -- scans and return pcie device with given class code and sub class code
108* @param classCode -- class code
109* @param subClassCode -- sub class code
110* @param bus -- address, where bus number will be stored
111* @param dev -- address, where device number will be stored
112* @param func -- address, where function number will be stored
113*/
114AU_EXTERN AU_EXPORT uint64_t AuPCIEScanClass(uint8_t classCode, uint8_t subClassCode, int *bus_, int *dev_, int *func_);
115
116/*
117* AuPCIEWrite -- writes to a register
118* @param device -- device address
119* @param reg -- register
120* @param size -- size to read
121* @param bus -- bus num
122* @param dev -- device number
123* @param func -- func number
124*/
125AU_EXTERN AU_EXPORT void AuPCIEWrite(uint64_t device, int reg, uint32_t val, int bus, int dev, int func);
126
127/*
128* AuPCIERead -- reads a register from pci express
129* @param device -- device address
130* @param reg -- register to read
131* @param bus -- bus number
132* @param dev -- device number
133* @param func -- function number
134*/
135AU_EXTERN AU_EXPORT uint32_t AuPCIERead(uint64_t device, int reg, int bus, int dev, int func);
136
137/*
138* AuPCIERead64 -- reads in 64
139* @param device -- device address
140* @param reg -- register
141* @param size -- size to read
142* @param bus -- bus num
143* @param dev -- device number
144* @param func -- func number
145*/
146AU_EXTERN AU_EXPORT uint64_t AuPCIERead64(uint64_t device, int reg, int size, int bus, int dev, int func);
147
148
149// {@private use|
150AU_EXTERN AU_EXPORT void AuPCIEWrite64(uint64_t device, int reg, int size, uint64_t val, int bus, int dev, int func);
151#endif
#define AU_EXTERN
Definition aurora.h:50
#define AU_EXPORT
Definition aurora.h:38
AuUSBDeviceStruc * device
Definition main.cpp:148
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165
unsigned short int uint16_t
Definition acefiex.h:162
AU_EXTERN AU_EXPORT uint64_t AuPCIEScanVendorDevice(uint16_t vendor, uint16_t device, int *bus_, int *dev_, int *func_)
AuPCIEScanVendorDevice – scans and return pcie device with given vendor id and device id.
Definition pcie.c:416
uint64_t AuPCIEGetDevice(uint16_t seg, int bus, int dev, int func)
AuPCIEGetDevice – gets a device address from its bus dev and func.
Definition pcie.cpp:44
AU_EXTERN AU_EXPORT void AuPCIEWrite64(uint64_t device, int reg, int size, uint64_t val, int bus, int dev, int func)
Definition pcie.cpp:326
AU_EXTERN AU_EXPORT uint64_t AuPCIERead64(uint64_t device, int reg, int size, int bus, int dev, int func)
AuPCIERead64 – reads in 64.
Definition pcie.cpp:183
AU_EXTERN AU_EXPORT uint64_t AuPCIEScanClassIF(uint8_t classCode, uint8_t subClassCode, uint8_t progIf, int *bus_, int *dev_, int *func_)
AuPCIEScanClassIF – scans and return pcie device with given class code and sub class code.
Definition pcie.cpp:405
AU_EXTERN AU_EXPORT bool AuPCIEAllocMSI(uint64_t device, size_t vector, int bus, int dev, int func)
AuPCIEAllocMSI – Allocate MSI/MSI-X for interrupt.
Definition pcie.cpp:454
AU_EXTERN AU_EXPORT void AuPCIEWrite(uint64_t device, int reg, uint32_t val, int bus, int dev, int func)
AuPCIEWrite – writes to a register.
Definition pcie.cpp:226
AU_EXTERN AU_EXPORT uint64_t AuPCIEScanClass(uint8_t classCode, uint8_t subClassCode, int *bus_, int *dev_, int *func_)
AuPCIEScanClass – scans and return pcie device with given class code and sub class code.
Definition pcie.cpp:358
AU_EXTERN AU_EXPORT uint32_t AuPCIERead(uint64_t device, int reg, int bus, int dev, int func)
AuPCIERead – reads a register from pci express.
Definition pcie.cpp:72