From ae123f1f380e00f85215b99e289838a7ccf115a3 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 7 May 2023 16:55:15 +0600 Subject: [PATCH] usb: Implement HCCA reads and writes --- src/include/86box/usb.h | 4 ++-- src/usb.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/include/86box/usb.h b/src/include/86box/usb.h index 6582f05e4..d8101c880 100644 --- a/src/include/86box/usb.h +++ b/src/include/86box/usb.h @@ -58,6 +58,7 @@ typedef struct usb_t } usb_t; #pragma pack(push, 1) + /* Base USB descriptor struct. */ typedef struct { @@ -76,6 +77,7 @@ typedef struct uint8_t bmAttributes; uint8_t bMaxPower; } usb_desc_conf_t; + #pragma pack(pop) typedef struct @@ -84,9 +86,7 @@ typedef struct uint16_t HccaFrameNumber; uint16_t HccaPad1; uint32_t HccaDoneHead; - uint32_t Reserved[29]; } usb_hcca_t; - /* USB endpoint device struct. Incomplete and unused. */ typedef struct { diff --git a/src/usb.c b/src/usb.c index 5b5e68bf2..0b3b5efe1 100644 --- a/src/usb.c +++ b/src/usb.c @@ -300,8 +300,13 @@ ohci_set_interrupt(usb_t *dev, uint8_t bit) void ohci_end_of_frame(usb_t* dev) { + usb_hcca_t hcca; /* TODO: Put endpoint and transfer descriptor processing here. */ + dma_bm_read(dev->ohci_mmio[OHCI_HcHCCA].l, (uint8_t*)&hcca, sizeof(usb_hcca_t), 4); + dev->ohci_mmio[OHCI_HcFmNumber].w[0]++; + + dma_bm_write(dev->ohci_mmio[OHCI_HcHCCA].l, (uint8_t*)&hcca, sizeof(usb_hcca_t), 4); } void