-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpciev.h
More file actions
30 lines (23 loc) · 886 Bytes
/
pciev.h
File metadata and controls
30 lines (23 loc) · 886 Bytes
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
#ifndef _LIB_PCIEV_H
#define _LIB_PCIEV_H
#define PCIEV_VERSION 0x0110
#define PCIEV_DEVICE_ID PCIEV_VERSION
#define PCIEV_VENDOR_ID 0x0c51
#define PCIEV_SUBSYSTEM_ID 0x370d
#define PCIEV_SUBSYSTEM_VENDOR_ID PCIEV_VENDOR_ID
/* pcie 设备的bar资源,保留了物理地址前 1MB 的空间 */
struct __packed pciev_bar {
// read only config
uint32_t dev_cnt;
struct __packed {
volatile uint64_t offset, size;
volatile uint64_t sector_sta;
volatile uint32_t io_num, io_done;
// 未进行的 io 操作区间为 (io_done, io_num]
} io_property;
};
#define PTR_BAR_TO_CHUNK_O(addr) ((uint8_t*)(addr))
#define PTR_BAR_TO_CHUNK_N(addr) ((uint8_t*)(addr) + CHUNK_SIZE)
#define PTR_BAR_TO_CHUNK_V(addr) ((uint8_t*)(addr) + CHUNK_SIZE * 2)
#define U64_DATA(ptr, offset) (*(uint64_t*)((uint8_t*)(ptr) + (offset)))
#endif /* _LIB_PCIEV_H */