feature (PCI): added subclass strings

This commit is contained in:
antifallobst 2023-04-26 21:57:18 +02:00
parent 8dd28a6bf6
commit b3d06f829e
3 changed files with 338 additions and 16 deletions

View File

@ -6,6 +6,195 @@
#include "utils/stdtypes.h" #include "utils/stdtypes.h"
#include "utils/string.h" #include "utils/string.h"
typedef enum {
PCI_CLASS_UNCLASSIFIED = 0x00,
PCI_CLASS_MASS_STORAGE_CONTROLLER = 0x01,
PCI_CLASS_NETWORK_CONTROLLER = 0x02,
PCI_CLASS_DISPLAY_CONTROLLER = 0x03,
PCI_CLASS_MULTIMEDIA_CONTROLLER = 0x04,
PCI_CLASS_MEMORY_CONTROLLER = 0x05,
PCI_CLASS_BRIDGE = 0x06,
PCI_CLASS_SIMPLE_COMMUNICATION_CONTROLLER = 0x07,
PCI_CLASS_BASE_SYSTEM_PERIPHERAL = 0x08,
PCI_CLASS_INPUT_DEVICE_CONTROLLER = 0x09,
PCI_CLASS_DOCKING_STATION = 0x0a,
PCI_CLASS_PROCESSOR = 0x0b,
PCI_CLASS_SERIAL_BUS_CONTROLLER = 0x0c,
PCI_CLASS_WIRELESS_CONTROLLER = 0x0d,
PCI_CLASS_INTELLIGENT_CONTROLLER = 0x0e,
PCI_CLASS_SATELLITE_COMMUNICATION_CONTROLLER = 0x0f,
PCI_CLASS_ENCRYPTION_CONTROLLER = 0x10,
PCI_CLASS_SIGNAL_PROCESSING_CONTROLLER = 0x11,
PCI_CLASS_PROCESSING_ACCELERATOR = 0x12,
PCI_CLASS_NON_ESSENTIAL_INSTRUMENTATION = 0x13,
PCI_CLASS_COPROCESSOR = 0x40
} pci_class_E;
typedef enum {
PCI_SUBCLASS_NON_VGA_COMPATIBLE_UNCLASSIFIED_DEVICE = 0x00,
PCI_SUBCLASS_VGA_COMPATIBLE_UNCLASSIFIED_DEVICE = 0x01
} pci_unclassified_sublasses_E;
typedef enum {
PCI_SUBCLASS_SCSI_BUS_CONTROLLER = 0x00,
PCI_SUBCLASS_IDE_CONTROLLER = 0x01,
PCI_SUBCLASS_FLOPPY_DISK_CONTROLLER = 0x02,
PCI_SUBCLASS_IPI_BUS_CONTROLLER = 0x03,
PCI_SUBCLASS_RAID_CONTROLLER = 0x04,
PCI_SUBCLASS_ATA_CONTROLLER = 0x05,
PCI_SUBCLASS_SERIAL_ATA_CONTROLLER = 0x06,
PCI_SUBCLASS_SERIAL_ATTACHED_SCSI_CONTROLLER = 0x07,
PCI_SUBCLASS_NON_VOLATILE_MEMORY_CONTROLLER = 0x08,
PCI_SUBCLASS_OTHER_MASS_STORAGE_CONTROLLER = 0x80
} pci_mass_storage_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_ETHERNET_CONTROLLER = 0x00,
PCI_SUBCLASS_TOKEN_RING_CONTROLLER = 0x01,
PCI_SUBCLASS_FDDI_CONTROLLER = 0x02,
PCI_SUBCLASS_ATM_CONTROLLER = 0x03,
PCI_SUBCLASS_ISDN_CONTROLLER = 0x04,
PCI_SUBCLASS_WORLDFIP_CONTROLLER = 0x05,
PCI_SUBCLASS_PICMG_2_14_MULTI_COMPUTING_CONTROLLER = 0x06,
PCI_SUBCLASS_INFINIBAND_NETWORKCONTROLLER = 0x07,
PCI_SUBCLASS_FABRIC_CONTROLLER = 0x08,
PCI_SUBCLASS_OTHER_NETWORK_CONTROLLER = 0x80
} pci_network_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_VGA_COMPATIBLE_CONTROLLER = 0x00,
PCI_SUBCLASS_XGA_COMPATIBLE_CONTROLLER = 0x01,
PCI_SUBCLASS_3D_CONTROLLER_NOT_VGA_COMPATIBLE = 0x02,
PCI_SUBCLASS_OTHER_DISPLAY_CONTROLLER = 0x80
} pci_display_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_MULTIMEDIA_VIDEO_CONTROLLER = 0x00,
PCI_SUBCLASS_MULTIMEDIA_AUDIO_CONTROLLER = 0x01,
PCI_SUBCLASS_COMPUTER_TELEPHONY_DEVICE = 0x02,
PCI_SUBCLASS_AUDIO_DEVICE = 0x03,
PCI_SUBCLASS_OTHER_MULTIMEDIA_CONTROLLER = 0x80
} pci_multimedia_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_RAM_CONTROLLER = 0x00,
PCI_SUBCLASS_FLASH_CONTROLLER = 0x01,
PCI_SUBCLASS_OTHER_MEMORY_CONTROLLER = 0x80
} pci_memory_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_HOST_BRIDGE = 0x00,
PCI_SUBCLASS_ISA_BRIDGE = 0x01,
PCI_SUBCLASS_EISA_BRIDGE = 0x02,
PCI_SUBCLASS_MCA_BRIDGE = 0x03,
PCI_SUBCLASS_PCI_TO_PCI_BRIDGE = 0x04,
PCI_SUBCLASS_PCMCIA_BRIDGE = 0x05,
PCI_SUBCLASS_NUBUS_BRIDGE = 0x06,
PCI_SUBCLASS_CARDBUS_BRIDGE = 0x07,
PCI_SUBCLASS_RACEWAY_BRIDGE = 0x08,
PCI_SUBCLASS_PCI_TO_PCI_BRIDGE_2 = 0x09,
PCI_SUBCLASS_INFINIBAND_TO_PCI_HOST_BRIDGE = 0x0a,
PCI_SUBCLASS_OTHER_BRIDGE = 0x80
} pci_bridge_subclasses_E;
typedef enum {
PCI_SUBCLASS_SERIAL_SIMPLE_COMMUNICATION_CONTROLLER = 0x00,
PCI_SUBCLASS_PARALLEL_SIMPLE_COMMUNICATION_CONTROLLER = 0x01,
PCI_SUBCLASS_MULTIPORT_SERIAL_CONTROLLER = 0x02,
PCI_SUBCLASS_MODEM = 0x03,
PCI_SUBCLASS_IEEE_488_1_2_GPIB_CONTROLLER = 0x04,
PCI_SUBCLASS_SMART_CARD_CONTROLLER = 0x05,
PCI_SUBCLASS_OTHER_SIMPLE_COMMUNICATION_CONTROLLER = 0x80
} pci_simple_communication_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_PIC = 0x00,
PCI_SUBCLASS_DMA_CONTROLLER = 0x01,
PCI_SUBCLASS_TIMER = 0x02,
PCI_SUBCLASS_RTC_CONTROLLER = 0x03,
PCI_SUBCLASS_PCI_HOT_PLUG_CONTROLLER = 0x04,
PCI_SUBCLASS_SD_HOST_CONTROLLER = 0x05,
PCI_SUBCLASS_IOMMU = 0x06,
PCI_SUBCLASS_OTHER_BASE_SYSTEM_PERIPHERAL = 0x80
} pci_base_system_peripheral_subclasses_E;
typedef enum {
PCI_SUBCLASS_KEYBOARD_CONTROLLER = 0x00,
PCI_SUBCLASS_DIGITIZER_PEN = 0x01,
PCI_SUBCLASS_MOUSE_CONTROLLER = 0x02,
PCI_SUBCLASS_SCANNER_CONTROLLER = 0x03,
PCI_SUBCLASS_GAMEPORT_CONTROLLER = 0x04,
PCI_SUBCLASS_OTHER_INPUT_DEVICE_CONTROLLER = 0x80
} pci_input_device_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_GENERIC_DOCKING_STATION = 0x00,
PCI_SUBCLASS_OTHER_DOCKING_STATION = 0x80
} pci_docking_station_subclasses_E;
typedef enum {
PCI_SUBCLASS_386_PROCESSOR = 0x00,
PCI_SUBCLASS_486_PROCESSOR = 0x01,
PCI_SUBCLASS_PENTIUM_PROCESSOR = 0x02,
PCI_SUBCLASS_PENTIUM_PRO_PROCESSOR = 0x03,
PCI_SUBCLASS_ALPHA_PROCESSOR = 0x10,
PCI_SUBCLASS_POWERPC_PROCESSOR = 0x20,
PCI_SUBCLASS_MIPS_PROCESSOR = 0x30,
PCI_SUBCLASS_COPROCESSOR = 0x40,
PCI_SUBCLASS_OTHER_PROCESSOR = 0x80
} pci_processor_subclasses_E;
typedef enum {
PCI_SUBCLASS_FIREWIRE_CONTROLLER = 0x00,
PCI_SUBCLASS_ACCESS_BUS_CONTROLLER = 0x01,
PCI_SUBCLASS_SSA = 0x02,
PCI_SUBCLASS_USB_CONTROLLER = 0x03,
PCI_SUBCLASS_FIBRE_CHANNEL = 0x04,
PCI_SUBCLASS_SMBUS_CONTROLLER = 0x05,
PCI_SUBCLASS_INFINIBAND_SERIAL_BUS_CONTROLLER = 0x06,
PCI_SUBCLASS_IPMI_INTERFACE = 0x07,
PCI_SUBCLASS_SERCOS_INTERFACE = 0x08,
PCI_SUBCLASS_CANBUS_CONTROOLLER = 0x09,
PCI_SUBCLASS_OTHER_SERIAL_BUS_CONTROLLER = 0x80
} pci_serial_bus_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_IRDA_COMPATIBLE_CONTROLLER = 0x00,
PCI_SUBCLASS_CONSUMER_IR_CONTROLLER = 0x01,
PCI_SUBCLASS_RF_CONTROLLER = 0x10,
PCI_SUBCLASS_BLUETOOTH_CONTROLLER = 0x11,
PCI_SUBCLASS_BROADBAND_CONTROLLER = 0x12,
PCI_SUBCLASS_ETHERNET_CONTROLLER_802_1A = 0x20,
PCI_SUBCLASS_ETHERNET_CONTROLLER_802_1B = 0x21,
PCI_SUBCLASS_OTHER_WIRELESS_CONTROLLER = 0x80
} pci_wireless_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_I20_INTELLIGENT_CONTROLLER = 0x00
} pci_intelligent_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_SATELLITE_TV_CONTROLLER = 0x01,
PCI_SUBCLASS_SATELLITE_AUDIO_CONTROLLER = 0x02,
PCI_SUBCLASS_SATELLITE_VOICE_CONTROLLER = 0x03,
PCI_SUBCLASS_SATELLITE_DATA_CONTROLLER = 0x04
} pci_satellite_communication_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_NETWORK_AND_COMPUTING_ENCRYPTION_DECRYPTION = 0x00,
PCI_SUBCLASS_ENTERTAINMENT_ENCRYPTION_DECRYPTION = 0x10,
PCI_SUBCLASS_OTHER_ENCRYPTION_CONTROLLER = 0x80
} pci_encryption_controller_subclasses_E;
typedef enum {
PCI_SUBCLASS_DPIO_MODULES = 0x00,
PCI_SUBCLASS_PERFORMANCE_COUTNERS = 0x01,
PCI_SUBCLASS_COMMUNICATION_SYNCHRONIZER = 0x10,
PCI_SUBCLASS_SIGNAL_PROCESSING_MANAGEMENT = 0x20,
PCI_SUBCLASS_OTHER_SIGNAL_PROCESSING_CONTROLLER = 0x80
} pci_signal_processing_controller_subclasses_E;
typedef struct { typedef struct {
uint16_t vendor_id; uint16_t vendor_id;
uint16_t device_id; uint16_t device_id;
@ -42,7 +231,7 @@ typedef struct {
} __attribute__((packed)) pci_header_0_T; } __attribute__((packed)) pci_header_0_T;
void pci_init (); void pci_init ();
string_t pci_get_subclass_string (pci_class_E class, uint8_t subclass);
string_t pci_get_vendor_string (uint16_t vendor_id); string_t pci_get_vendor_string (uint16_t vendor_id);
string_t pci_get_device_string (uint16_t device_id);
#endif // NOXOS_PCI_H #endif // NOXOS_PCI_H

5
run.sh
View File

@ -1,9 +1,8 @@
#!/bin/bash #!/bin/bash
# This file is part of noxos and licensed under the MIT open source license # This file is part of noxos and licensed under the MIT open source license
EMUFLAGS="-no-reboot -machine q35 -cpu qemu64 -m 256M \ EMUFLAGS="-no-reboot -machine type=q35,accel=kvm -cpu max -m 256M \
-drive file=build/noxos.iso,id=disk \ -drive file=build/noxos.iso \
-drive file=fat:rw:ramdisk \
-chardev stdio,id=log,logfile=noxos.log -serial chardev:log" -chardev stdio,id=log,logfile=noxos.log -serial chardev:log"
emulate_bios() { emulate_bios() {

View File

@ -6,19 +6,154 @@
#include "mm/page_map.h" #include "mm/page_map.h"
#include "utils/logger.h" #include "utils/logger.h"
string_t pci_get_subclass_string(pci_class_E class, uint8_t subclass) {
switch (class) {
case PCI_CLASS_UNCLASSIFIED: {
switch (subclass) {
case PCI_SUBCLASS_NON_VGA_COMPATIBLE_UNCLASSIFIED_DEVICE: return "Non-VGA-Compatible Unclassified Device";
case PCI_SUBCLASS_VGA_COMPATIBLE_UNCLASSIFIED_DEVICE: return "VGA-Compatible Unclassified Device";
default: break;
}
break;
}
case PCI_CLASS_MASS_STORAGE_CONTROLLER: {
switch (subclass) {
case PCI_SUBCLASS_SCSI_BUS_CONTROLLER: return "SCSI Bus Controller";
case PCI_SUBCLASS_IDE_CONTROLLER: return "IDE Controller";
case PCI_SUBCLASS_FLOPPY_DISK_CONTROLLER: return "Floppy Disk Controller";
case PCI_SUBCLASS_IPI_BUS_CONTROLLER: return "IPI Bus Controller";
case PCI_SUBCLASS_RAID_CONTROLLER: return "RAID Controller";
case PCI_SUBCLASS_ATA_CONTROLLER: return "ATA Controller";
case PCI_SUBCLASS_SERIAL_ATA_CONTROLLER: return "SATA Controller";
case PCI_SUBCLASS_SERIAL_ATTACHED_SCSI_CONTROLLER: return "Serial Attached SCSI Controller";
case PCI_SUBCLASS_NON_VOLATILE_MEMORY_CONTROLLER: return "Non-Volatile Memory Controller";
case PCI_SUBCLASS_OTHER_MASS_STORAGE_CONTROLLER: return "Other Mass storage Controller";
default: break;
}
break;
}
case PCI_CLASS_NETWORK_CONTROLLER: {
switch (subclass) {
case PCI_SUBCLASS_ETHERNET_CONTROLLER: return "Ethernet Controller";
case PCI_SUBCLASS_TOKEN_RING_CONTROLLER: return "Token Ring Controller";
case PCI_SUBCLASS_FDDI_CONTROLLER: return "FDDI Controller";
case PCI_SUBCLASS_ATM_CONTROLLER: return "ATM Controller";
case PCI_SUBCLASS_ISDN_CONTROLLER: return "ISDN Controller";
case PCI_SUBCLASS_WORLDFIP_CONTROLLER: return "WorldFip Controller";
case PCI_SUBCLASS_PICMG_2_14_MULTI_COMPUTING_CONTROLLER: return "PICMG 2.14 Multi Computing Controller";
case PCI_SUBCLASS_INFINIBAND_NETWORKCONTROLLER: return "Infiniband Controller";
case PCI_SUBCLASS_FABRIC_CONTROLLER: return "Fabric Controller";
case PCI_SUBCLASS_OTHER_NETWORK_CONTROLLER: return "Other Network Controller";
default: break;
}
break;
}
case PCI_CLASS_DISPLAY_CONTROLLER: {
switch (subclass) {
case PCI_SUBCLASS_VGA_COMPATIBLE_CONTROLLER: return "VGA Compatible Controller";
case PCI_SUBCLASS_XGA_COMPATIBLE_CONTROLLER: return "XGA Controller";
case PCI_SUBCLASS_3D_CONTROLLER_NOT_VGA_COMPATIBLE: return "3D Controller (Not VGA-Compatible)";
case PCI_SUBCLASS_OTHER_DISPLAY_CONTROLLER: return "Other Display Controller";
default: break;
}
break;
}
case PCI_CLASS_MULTIMEDIA_CONTROLLER: {
switch (subclass) {
case PCI_SUBCLASS_MULTIMEDIA_VIDEO_CONTROLLER: return "Multimedia Video Controller";
case PCI_SUBCLASS_MULTIMEDIA_AUDIO_CONTROLLER: return "Multimedia Audio Controller";
case PCI_SUBCLASS_COMPUTER_TELEPHONY_DEVICE: return "Computer Telephony Device";
case PCI_SUBCLASS_AUDIO_DEVICE: return "Audio Device";
case PCI_SUBCLASS_OTHER_MULTIMEDIA_CONTROLLER: return "Other Multimedia Controller";
default: break;
}
break;
}
case PCI_CLASS_MEMORY_CONTROLLER: {
switch (subclass) {
case PCI_SUBCLASS_RAM_CONTROLLER: return "RAM Controller";
case PCI_SUBCLASS_FLASH_CONTROLLER: return "Flash Controller";
case PCI_SUBCLASS_OTHER_MEMORY_CONTROLLER: return "Other Memory Controller";
default: break;
}
break;
}
case PCI_CLASS_BRIDGE: {
switch (subclass) {
case PCI_SUBCLASS_HOST_BRIDGE: return "Host Bridge";
case PCI_SUBCLASS_ISA_BRIDGE: return "ISA Bridge";
case PCI_SUBCLASS_EISA_BRIDGE: return "EISA Bridge";
case PCI_SUBCLASS_MCA_BRIDGE: return "MCA Bridge";
case PCI_SUBCLASS_PCI_TO_PCI_BRIDGE: return "PCI-to-PCI Bridge";
case PCI_SUBCLASS_PCMCIA_BRIDGE: return "PCMCIA Bridge";
case PCI_SUBCLASS_NUBUS_BRIDGE: return "NuBus Bridge";
case PCI_SUBCLASS_CARDBUS_BRIDGE: return "CardBus Bridge";
case PCI_SUBCLASS_RACEWAY_BRIDGE: return "RACEway Bridge";
case PCI_SUBCLASS_PCI_TO_PCI_BRIDGE_2: return "PCI-to-PCI Bridge";
case PCI_SUBCLASS_INFINIBAND_TO_PCI_HOST_BRIDGE: return "InfiniBand-to-PCI Host Bridge";
case PCI_SUBCLASS_OTHER_BRIDGE: return "Other Bridge";
default: break;
}
break;
}
case PCI_CLASS_SIMPLE_COMMUNICATION_CONTROLLER: {
switch (subclass) {
case PCI_SUBCLASS_SERIAL_SIMPLE_COMMUNICATION_CONTROLLER: return "Serial Controller";
case PCI_SUBCLASS_PARALLEL_SIMPLE_COMMUNICATION_CONTROLLER: return "Parallel Controller";
case PCI_SUBCLASS_MULTIPORT_SERIAL_CONTROLLER: return "Multiport Serial Controller";
case PCI_SUBCLASS_MODEM: return "Modem";
case PCI_SUBCLASS_IEEE_488_1_2_GPIB_CONTROLLER: return "IEEE 488.1/2 (GPIB) Controller";
case PCI_SUBCLASS_SMART_CARD_CONTROLLER: return "Smart Card Controller";
case PCI_SUBCLASS_OTHER_SIMPLE_COMMUNICATION_CONTROLLER: return "Other Simple Communication Controller";
default: break;
}
break;
}
case PCI_CLASS_BASE_SYSTEM_PERIPHERAL: {
switch (subclass) {
case PCI_SUBCLASS_PIC: return "PIC";
case PCI_SUBCLASS_DMA_CONTROLLER: return "DMA Controller";
case PCI_SUBCLASS_TIMER: return "Timer";
case PCI_SUBCLASS_RTC_CONTROLLER: return "RTC Controller";
case PCI_SUBCLASS_PCI_HOT_PLUG_CONTROLLER: return "PCI Hot-Plug Controller";
case PCI_SUBCLASS_SD_HOST_CONTROLLER: return "SD Host Controller";
case PCI_SUBCLASS_IOMMU: return "IOMMU";
case PCI_SUBCLASS_OTHER_BASE_SYSTEM_PERIPHERAL: return "Other Base System Peripheral";
default: break;
}
break;
}
case PCI_CLASS_INPUT_DEVICE_CONTROLLER: {
switch (subclass) {
case PCI_SUBCLASS_KEYBOARD_CONTROLLER: return "Keyboard Controller";
case PCI_SUBCLASS_DIGITIZER_PEN: return "Digitizer Pen";
case PCI_SUBCLASS_MOUSE_CONTROLLER: return "Mouse Controller";
case PCI_SUBCLASS_SCANNER_CONTROLLER: return "Scanner Controller";
case PCI_SUBCLASS_GAMEPORT_CONTROLLER: return "Gameport Controller";
case PCI_SUBCLASS_OTHER_INPUT_DEVICE_CONTROLLER: return "Other Input Device Controller";
default: break;
}
break;
}
case PCI_CLASS_DOCKING_STATION: {
switch (subclass) {
default: break;
}
break;
}
default: break;
}
return "Unknown Device";
}
string_t pci_get_vendor_string(uint16_t vendor_id) { string_t pci_get_vendor_string(uint16_t vendor_id) {
switch (vendor_id) { switch (vendor_id) {
case 0x1234: return "QEMU"; case 0x1234: return "QEMU";
case 0x8086: return "Intel"; case 0x8086: return "Intel";
default: return "Unknown"; default: return "Unknown Vendor";
}
}
string_t pci_get_device_string(uint16_t device_id) {
switch (device_id) {
case 0x1111: return "Bochs Graphics Adaptor";
case 0x29C0: return "Express DRAM Controller";
default: return "Unknown";
} }
} }
@ -28,10 +163,9 @@ void pci_enumerate_function(void* device_address, uint8_t function) {
pci_device_header_T* device_header = (pci_device_header_T*)function_address; pci_device_header_T* device_header = (pci_device_header_T*)function_address;
if (device_header->device_id == 0 || device_header->device_id == 0xFFFF) return; if (device_header->device_id == 0 || device_header->device_id == 0xFFFF) return;
log(LOG_DEBUG, " Vendor ID: 0x%xw - %s", device_header->vendor_id, pci_get_vendor_string(device_header->vendor_id));
log(LOG_DEBUG, " Device ID: 0x%xw - %s", device_header->device_id, pci_get_device_string(device_header->device_id));
log(LOG_DEBUG, "<PCI> Found device CLASS[0x%xb] SUBCLASS[0x%xb] PROGIF[0x%xb]", device_header->main_class, device_header->subclass, device_header->progif); log(LOG_DEBUG, "<PCI> Found %s - %s - %xw:%xw", pci_get_subclass_string(device_header->main_class, device_header->subclass),
pci_get_vendor_string(device_header->vendor_id), device_header->vendor_id, device_header->device_id);
} }
void pci_enumerate_device(void* bus_address, uint8_t device) { void pci_enumerate_device(void* bus_address, uint8_t device) {