Skip to content

Commit

Permalink
drivers: add legacy virtio-blk driver
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
  • Loading branch information
mcayland committed Mar 13, 2017
1 parent edaca74 commit e3db36b
Show file tree
Hide file tree
Showing 7 changed files with 769 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/build.xml
Expand Up @@ -26,6 +26,7 @@
<object source="usbhid.c" condition="USB_HID"/>
<object source="usbohci.c" condition="DRIVER_USB"/>
<object source="usbohci_rh.c" condition="DRIVER_USB"/>
<object source="virtio.c" condition="DRIVER_VIRTIO_BLK"/>
</library>

<dictionary name="openbios" target="forth">
Expand Down
18 changes: 18 additions & 0 deletions drivers/pci.c
Expand Up @@ -582,6 +582,24 @@ int rtl8139_config_cb(const pci_config_t *config)
return eth_config_cb(config);
}

int virtio_blk_config_cb(const pci_config_t *config)
{
#ifdef CONFIG_DRIVER_VIRTIO_BLK
pci_addr addr;
uint8_t idx;

addr = PCI_ADDR(
PCI_BUS(config->dev),
PCI_DEV(config->dev),
PCI_FN(config->dev));

idx = (uint8_t)(pci_config_read16(addr, PCI_DEVICE_ID) & 0xff) - 1;

ob_virtio_init(config->path, "virtio-blk", arch->io_base, config->assigned[0] & ~0x0000000F, idx);
#endif
return 0;
}

static inline void pci_decode_pci_addr(pci_addr addr, int *flags,
int *space_code, uint32_t *mask)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/pci_database.c
Expand Up @@ -52,7 +52,7 @@ static const pci_dev_t scsi_devices[] = {
NULL, "virtio-blk", NULL,
"pci1af4,1001\0pci1af4,1001\0pciclass,01018f\0",
0, 0, 0,
NULL, NULL,
virtio_blk_config_cb, NULL,
},
{
0xFFFF, 0xFFFF,
Expand Down
1 change: 1 addition & 0 deletions drivers/pci_database.h
Expand Up @@ -29,6 +29,7 @@ struct pci_dev_t {
};

extern int ide_config_cb2(const pci_config_t *config);
extern int virtio_blk_config_cb(const pci_config_t *config);
extern int eth_config_cb(const pci_config_t *config);
extern int macio_heathrow_config_cb(const pci_config_t *config);
extern int macio_keylargo_config_cb(const pci_config_t *config);
Expand Down

0 comments on commit e3db36b

Please sign in to comment.