Расширение получаемой информации от PCI

This commit is contained in:
Aren Elchinyan 2023-12-14 12:48:27 +03:00
parent 730fa37119
commit 7fb682ba9e
5 changed files with 27 additions and 12 deletions

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_BUILD 840
#define VERSION_BUILD 852

View File

@ -63,6 +63,7 @@ void isr_generic(struct frame state) {
void idt_init( ) {
asm volatile("cli");
idtr = (idt_ptr_t){ .limit = sizeof(idt) - 1, .base = (uint64_t)idt };
tool_memset(isr, 0, 256 * sizeof(int_entry_t));
for (uint64_t i = 0; i < 256; i++) {
if (i < 32) {

View File

@ -36,5 +36,5 @@ void pit_set_interval(int hz) {
void pit_init( ) {
idt_set_int(32, isr_local);
pit_set_interval(10);
pit_set_interval(1);
}

View File

@ -60,7 +60,7 @@ void _start( ) {
LOG("Вызов прерывания переключения задач!\n");
asm volatile("int $32");
break;
default: io_wait( ); break;
default: break;
}
}
}

View File

@ -37,23 +37,23 @@ static inline uint16_t pci_read_word(uint16_t bus, uint16_t slot, uint16_t func,
return (tmp);
}
static inline uint16_t get_vendor_id(uint16_t bus, uint16_t device, uint16_t function) {
uint32_t r0 = pci_read_word(bus, device, function, 0);
static inline uint16_t get_vendor_id(uint16_t bus, uint16_t slot, uint16_t function) {
uint32_t r0 = pci_read_word(bus, slot, function, 0);
return r0;
}
static inline uint16_t get_device_id(uint16_t bus, uint16_t device, uint16_t function) {
uint32_t r0 = pci_read_word(bus, device, function, 2);
static inline uint16_t get_device_id(uint16_t bus, uint16_t slot, uint16_t function) {
uint32_t r0 = pci_read_word(bus, slot, function, 2);
return r0;
}
static inline uint16_t get_class_id(uint16_t bus, uint16_t device, uint16_t function) {
uint32_t r0 = pci_read_word(bus, device, function, 0xA);
static inline uint16_t get_class_id(uint16_t bus, uint16_t slot, uint16_t function) {
uint32_t r0 = pci_read_word(bus, slot, function, 0xA);
return (r0 & ~0x00FF) >> 8;
}
static inline uint16_t get_sub_class_id(uint16_t bus, uint16_t device, uint16_t function) {
uint32_t r0 = pci_read_word(bus, device, function, 0xA);
static inline uint16_t get_sub_class_id(uint16_t bus, uint16_t slot, uint16_t function) {
uint32_t r0 = pci_read_word(bus, slot, function, 0xA);
return (r0 & ~0xFF00);
}
@ -92,12 +92,26 @@ static inline void scan( ) {
uint16_t device_id = get_device_id(bus, slot, function);
uint16_t class_id = get_class_id(bus, slot, function);
uint16_t status = pci_read_word(bus, slot, function, 0x6);
uint32_t mem_addr_0 = pci_read_word(bus, slot, function, 0x1C);
uint32_t mem_addr_1 = pci_read_word(bus, slot, function, 0x24);
uint32_t mem_lim_0 = pci_read_word(bus, slot, function, 0x20);
uint32_t mem_lim_1 = pci_read_word(bus, slot, function, 0x28);
uint32_t io_addr_0 = pci_read_word(bus, slot, function, 0x2C);
uint32_t io_addr_1 = pci_read_word(bus, slot, function, 0x34);
uint32_t io_lim_0 = pci_read_word(bus, slot, function, 0x30);
uint32_t io_lim_1 = pci_read_word(bus, slot, function, 0x38);
char *name = find_vendor(vendor);
fb_printf("[%u] %x [%s], устройство: %x, класс: %u, "
"%u.%u.%u\n",
devices, vendor, name, device_id, class_id, bus, slot, function);
fb_printf("\t\\->%s\n", get_class_name(class_id));
fb_printf("\t\\->%s", get_class_name(class_id));
fb_printf(" | 0x%x : 0x%x", mem_addr_0, mem_lim_0);
fb_printf(" | 0x%x : 0x%x", mem_addr_1, mem_lim_1);
fb_printf(" | 0x%x : 0x%x", io_addr_0, io_lim_0);
fb_printf(" | 0x%x : 0x%x", io_addr_1, io_lim_1);
fb_printf(" | 0x%x\n", status);
devices++;
}