From 04e440e608865dfb10c5061cd979ef81153fd5eb Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 7 May 2023 00:33:15 +0600 Subject: [PATCH] usb: Start implementing end-of-frame and start-of-frame signals --- src/usb.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/usb.c b/src/usb.c index 3310c0786..cde3ee4a9 100644 --- a/src/usb.c +++ b/src/usb.c @@ -239,6 +239,18 @@ ohci_set_interrupt(usb_t* usb, uint8_t bit) usb_interrupt_ohci(usb); } +void +ohci_end_of_frame(usb_t* dev) +{ + /* TODO: Put endpoint and transfer descriptor processing here. */ +} + +void +ohci_start_of_frame(usb_t* dev) +{ + ohci_set_interrupt(dev, OHCI_HcInterruptEnable_SO); +} + void ohci_update_frame_counter(void* priv) { @@ -246,12 +258,15 @@ ohci_update_frame_counter(void* priv) dev->ohci_mmio_w[OHCI_HcFmRemaining / 2] &= 0x3fff; if (dev->ohci_mmio_w[OHCI_HcFmRemaining / 2] == 0) { + ohci_end_of_frame(dev); dev->ohci_mmio_w[OHCI_HcFmRemaining / 2] = dev->ohci_mmio_w[OHCI_HcFmInterval / 2] & 0x3fff; dev->ohci_mmio_l[OHCI_HcFmRemaining / 4] &= ~(1 << 31); dev->ohci_mmio_l[OHCI_HcFmRemaining / 4] |= dev->ohci_mmio_l[OHCI_HcFmInterval / 4] & (1 << 31); - ohci_set_interrupt(dev, OHCI_HcInterruptEnable_SO); + dev->ohci_mmio_w[OHCI_HcFmNumber / 2]++; + ohci_start_of_frame(dev); } if (dev->ohci_mmio_w[OHCI_HcFmRemaining / 2]) dev->ohci_mmio_w[OHCI_HcFmRemaining / 2]--; + timer_on_auto(&dev->ohci_frame_timer, 1. / (12. * 1000. * 1000.)); } void