forked from uart/hardwarePrefetching
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpcie.c
47 lines (36 loc) · 775 Bytes
/
pcie.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <pci/pci.h>
#include "log.h"
#define TAG "PCIE"
static struct pci_access *pacc;
// Initialize the PCIe interface and the static/local pacc structure.
int pcie_init(void)
{
pacc = pci_alloc();
if(pacc == NULL) {
loge(TAG, "PCIe init failed\n");
return -1;
}
pci_init(pacc);
pci_scan_bus(pacc); // Populate the pacc->devices list
if(pacc->devices == NULL) {
loge(TAG, "PCIe init failed, no devices found\n");
return -1;
}
return 0;
}
//Cleanup the pacc structure
void pcie_deinit(void)
{
pci_cleanup(pacc);
}
//returns the handle to the pci access struct
/*struct pci_access* pcie_gethandle()
{
return pacc;
}*/
//returns the handle to the pci device struct
struct pci_dev* pcie_get_devices()
{
return pacc->devices;
}