kvm, pci: Claim virtio device ioport in pci header

It still doesn't work because we need to fill .class
properly. But at least virtio probe function passes fine now.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov
2015-06-01 16:39:40 +01:00
committed by Will Deacon
parent 70d08766ef
commit beb095eb19
4 changed files with 29 additions and 3 deletions
+4
View File
@@ -4,6 +4,10 @@
#include <stdbool.h>
#include <stdint.h>
/* some ports we reserve for own use */
#define IOPORT_DBG 0xe0
#define IOPORT_VIRTIO 0xea
struct kvm;
struct ioport_operations {
+2 -2
View File
@@ -34,8 +34,8 @@ struct pci_device_header {
uint8_t cacheline_size;
uint8_t latency_timer;
uint8_t header_type;
uint8_t BIST;
uint32_t BAR[6];
uint8_t bist;
uint32_t bar[6];
uint32_t card_bus;
uint16_t subsys_vendor_id;
uint16_t subsys_id;
+1 -1
View File
@@ -86,7 +86,7 @@ static struct ioport_operations *ioport_ops[USHRT_MAX] = {
/* PORT 00E0-00EF are 'motherboard specific' so we use them for our
internal debugging purposes. */
[0x00E0] = &debug_ops,
[IOPORT_DBG] = &debug_ops,
/* PORT 00ED - DUMMY PORT FOR DELAY??? */
[0x00ED] = &dummy_write_only_ioport_ops,
+22
View File
@@ -41,6 +41,8 @@ static struct pci_device_header virtio_device = {
.vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
.device_id = PCI_DEVICE_ID_VIRTIO_BLK,
.header_type = PCI_HEADER_TYPE_NORMAL,
/* .class = (0x01 << 16) | (0x01 << 8) | ((1<<7) | * (1<<1)), */
.bar[0] = (IOPORT_VIRTIO << 4) | PCI_BASE_ADDRESS_SPACE_IO,
};
static bool pci_device_matches(uint8_t bus_number, uint8_t device_number, uint8_t function_number)
@@ -84,8 +86,28 @@ static struct ioport_operations pci_config_data_ops = {
.io_out = pci_config_data_out,
};
static bool virtio_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
{
info("virtio_in");
return true;
}
static bool virtio_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
{
info("virtio_out");
return true;
}
static struct ioport_operations virtio_io_ops = {
.io_in = virtio_in,
.io_out = virtio_out,
};
void pci__init(void)
{
ioport__register(IOPORT_VIRTIO, &virtio_io_ops);
ioport__register(PCI_CONFIG_DATA + 0, &pci_config_data_ops);
ioport__register(PCI_CONFIG_DATA + 1, &pci_config_data_ops);
ioport__register(PCI_CONFIG_DATA + 2, &pci_config_data_ops);