SayoriOS 0.3.3

pci.h
1
11 #pragma once
12
13 #include <common.h>
14
15 #define CLASS_DEVICE_TOO_OLD 0x00
16 #define CLASS_MASS_STORAGE 0x01
17 #define CLASS_NETWORK_CTRLR 0x02
18 #define CLASS_DISPLAY 0x03
19 #define CLASS_MULTIMEDIA 0x04
20 #define CLASS_MEMORY 0x05
21 #define CLASS_BRIDGE 0x06
22 #define CLASS_SCC 0x07
23 #define CLASS_SYSTEM 0x08
24 #define CLASS_INPUT 0x09
25 #define CLASS_DOCK 0x0A
26 #define CLASS_PROCESSOR 0x0B
27 #define CLASS_SERIAL_BUS 0x0C
28 #define CLASS_WIRELESS 0x0D
29 #define CLASS_INTELLIGENTIO 0x0E
30 #define CLASS_SATELLITE 0x0F
31 #define CLASS_ENCRYPT 0x10
32 #define CLASS_SIGNAL_PROC 0x11
33 #define CLASS_PROC_ACCEL 0x12
34 #define CLASS_NO_ESS_INS 0x13
35 #define CLASS_CO_CPU 0x40
36
37 #define PCI_ADDRESS_PORT 0xCF8
38 #define PCI_DATA_PORT 0xCFC
39
40 #define PCI_VENDOR_NO_DEVICE 0xFFFF
41
42 #define PCI_BAR0 0x10
43 #define PCI_BAR1 0x14
44 #define PCI_BAR2 0x18
45 #define PCI_BAR3 0x1C
46 #define PCI_BAR4 0x20
47 #define PCI_BAR5 0x24
48
52 typedef struct pci_header_t {
53 uint16_t vendor_id;
54 uint16_t device_id;
55 uint8_t revision;
56 uint8_t prog_if;
57 uint8_t subclass_id;
58 uint8_t class_id;
59 uint8_t cache_line_size;
60 uint8_t latency_timer;
61 uint8_t hdr_type;
62 uint8_t bist;
63 uint32_t bar[6];
64 uint32_t cardbus_cis_ptr;
65 uint16_t subsys_vendor;
66 uint16_t subsys_id;
67 uint32_t expansion_rom;
68 uint8_t capatibilities;
69 uint8_t reserved[3];
70 uint32_t reserved2;
71 uint8_t int_line;
72 uint8_t int_pin;
73 uint8_t min_grant;
74 uint8_t max_latency;
75 } pci_header_t;
76
77 typedef struct {
78 uint16_t vendor_id;
79 uint16_t device_id;
80 uint16_t klass;
81 uint16_t subclass;
82 uint16_t bus;
83 uint16_t slot;
84 uint16_t func;
85 uint16_t hdrtype;
86 } pci_device_t;
87
88 uint16_t pci_read_confspc_word(uint8_t bus, uint8_t slot, uint8_t function, uint8_t offset);
89 uint8_t pci_get_class(uint8_t bus, uint8_t slot, uint8_t function);
90 uint8_t pci_get_subclass(uint8_t bus, uint8_t slot, uint8_t function);
91 uint8_t pci_get_hdr_type(uint8_t bus, uint8_t slot, uint8_t function);
92 uint16_t pci_get_vendor(uint8_t bus, uint8_t slot, uint8_t function);
93 uint16_t pci_get_device(uint8_t bus, uint8_t slot, uint8_t function);
94 const char *pci_get_device_type(uint8_t klass, uint8_t subclass);
95 const char *pci_get_vendor_name(uint16_t vendor);
96 uint32_t pci_get_bar(uint8_t hdrtype, uint8_t bus, uint8_t slot, uint8_t func, uint8_t bar_number, uint8_t *bar_type);
97 void pci_find_device(uint16_t vendor, uint16_t device, uint8_t *bus_ret, uint8_t *slot_ret, uint8_t *func_ret);
98 void pci_print_list();
99 void pci_write(uint8_t bus, uint8_t slot, uint8_t func, uint32_t offset, uint32_t value);
100 void pci_find_device_by_class_and_subclass(uint16_t class, uint16_t subclass, uint16_t *vendor_ret, uint16_t *deviceid_ret,
101 uint8_t *bus_ret, uint8_t *slot_ret, uint8_t *func_ret);
102 void pci_enable_bus_mastering(uint8_t bus, uint8_t slot, uint8_t func);
103 uint32_t pci_read32(uint8_t bus, uint8_t slot, uint8_t function, uint8_t offset);
104
105 void pci_scan_everything();
common.h
Основные определения ядра
pci_get_bar
uint32_t pci_get_bar(uint8_t hdrtype, uint8_t bus, uint8_t slot, uint8_t func, uint8_t bar_number, uint8_t *bar_type)
[PCI] ???
Definition: pci.c:318
pci_read_confspc_word
uint16_t pci_read_confspc_word(uint8_t bus, uint8_t slot, uint8_t function, uint8_t offset)
[PCI] Чтение 16-битных полей из пространства механизма конфигураций 1
Definition: pci.c:32
pci_find_device
void pci_find_device(uint16_t vendor, uint16_t device, uint8_t *bus_ret, uint8_t *slot_ret, uint8_t *func_ret)
[PCI] Поиск устройства по ID-поставшика и устройства
Definition: pci.c:362
pci_get_hdr_type
uint8_t pci_get_hdr_type(uint8_t bus, uint8_t slot, uint8_t function)
[PCI] Получение HDR-тип устройства
Definition: pci.c:243
pci_get_vendor
uint16_t pci_get_vendor(uint8_t bus, uint8_t slot, uint8_t function)
[PCI] Получение ID-поставщика
Definition: pci.c:256
pci_get_device_type
const char * pci_get_device_type(uint8_t klass, uint8_t subclass)
[PCI] Получение классификации устройства
Definition: pci.c:281
pci_get_vendor_name
const char * pci_get_vendor_name(uint16_t vendor)
[PCI] Получение названия поставщика
Definition: pci.c:295
pci_read32
uint32_t pci_read32(uint8_t bus, uint8_t slot, uint8_t function, uint8_t offset)
Чтение данных из шины PCI.
Definition: pci.c:54
pci_get_class
uint8_t pci_get_class(uint8_t bus, uint8_t slot, uint8_t function)
[PCI] Получение основной категории устройства
Definition: pci.c:217
pci_get_device
uint16_t pci_get_device(uint8_t bus, uint8_t slot, uint8_t function)
[PCI] Получение ID-Устройства
Definition: pci.c:269
pci_get_subclass
uint8_t pci_get_subclass(uint8_t bus, uint8_t slot, uint8_t function)
[PCI] Получение под-категории устройства
Definition: pci.c:230
pci_device_t
Definition: pci.h:77
pci_header_t
Структура устройства
Definition: pci.h:52
pci_header_t::min_grant
uint8_t min_grant
ПИН-код прерывания
Definition: pci.h:73
pci_header_t::max_latency
uint8_t max_latency
???
Definition: pci.h:74
pci_header_t::cache_line_size
uint8_t cache_line_size
Категория устройства
Definition: pci.h:59
pci_header_t::latency_timer
uint8_t latency_timer
Размер строки кэша
Definition: pci.h:60
pci_header_t::subclass_id
uint8_t subclass_id
Положение дел (???) Prog IF.
Definition: pci.h:57
pci_header_t::hdr_type
uint8_t hdr_type
Таймер задержки
Definition: pci.h:61
pci_header_t::reserved
uint8_t reserved[3]
???
Definition: pci.h:69
pci_header_t::subsys_id
uint16_t subsys_id
???
Definition: pci.h:66
pci_header_t::bist
uint8_t bist
Тип заголовка (???)
Definition: pci.h:62
pci_header_t::revision
uint8_t revision
ID-Устройства
Definition: pci.h:55
pci_header_t::prog_if
uint8_t prog_if
ID-Реверсии
Definition: pci.h:56
pci_header_t::bar
uint32_t bar[6]
БИСТ (???) BIST.
Definition: pci.h:63
pci_header_t::int_line
uint8_t int_line
Зарезервированный
Definition: pci.h:71
pci_header_t::device_id
uint16_t device_id
ID-Поставщика
Definition: pci.h:54
pci_header_t::reserved2
uint32_t reserved2
Зарезервированный
Definition: pci.h:70
pci_header_t::cardbus_cis_ptr
uint32_t cardbus_cis_ptr
???
Definition: pci.h:64
pci_header_t::class_id
uint8_t class_id
Подкатегория устройства
Definition: pci.h:58
pci_header_t::int_pin
uint8_t int_pin
Линия прерывания
Definition: pci.h:72
pci_header_t::expansion_rom
uint32_t expansion_rom
???
Definition: pci.h:67
pci_header_t::subsys_vendor
uint16_t subsys_vendor
Базовый адрес CardBus Socket/ExCa.
Definition: pci.h:65
pci_header_t::capatibilities
uint8_t capatibilities
???
Definition: pci.h:68