hcd-uhci.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * USB UHCI controller emulation
  3. *
  4. * Copyright (c) 2005 Fabrice Bellard
  5. *
  6. * Copyright (c) 2008 Max Krasnyansky
  7. * Magor rewrite of the UHCI data structures parser and frame processor
  8. * Support for fully async operation and multiple outstanding transactions
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11. * of this software and associated documentation files (the "Software"), to deal
  12. * in the Software without restriction, including without limitation the rights
  13. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. * copies of the Software, and to permit persons to whom the Software is
  15. * furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice shall be included in
  18. * all copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  23. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26. * THE SOFTWARE.
  27. */
  28. #ifndef HW_USB_HCD_UHCI_H
  29. #define HW_USB_HCD_UHCI_H
  30. #include "exec/memory.h"
  31. #include "qemu/timer.h"
  32. #include "hw/pci/pci_device.h"
  33. #include "hw/usb.h"
  34. typedef struct UHCIQueue UHCIQueue;
  35. #define UHCI_PORTS 2
  36. typedef struct UHCIPort {
  37. USBPort port;
  38. uint16_t ctrl;
  39. } UHCIPort;
  40. typedef struct UHCIState {
  41. PCIDevice dev;
  42. MemoryRegion io_bar;
  43. USBBus bus; /* Note unused when we're a companion controller */
  44. uint16_t cmd; /* cmd register */
  45. uint16_t status;
  46. uint16_t intr; /* interrupt enable register */
  47. uint16_t frnum; /* frame number */
  48. uint32_t fl_base_addr; /* frame list base address */
  49. uint8_t sof_timing;
  50. uint8_t status2; /* bit 0 and 1 are used to generate UHCI_STS_USBINT */
  51. int64_t expire_time;
  52. QEMUTimer *frame_timer;
  53. QEMUBH *bh;
  54. uint32_t frame_bytes;
  55. uint32_t frame_bandwidth;
  56. bool completions_only;
  57. UHCIPort ports[UHCI_PORTS];
  58. qemu_irq irq;
  59. /* Interrupts that should be raised at the end of the current frame. */
  60. uint32_t pending_int_mask;
  61. /* Active packets */
  62. QTAILQ_HEAD(, UHCIQueue) queues;
  63. uint8_t num_ports_vmstate;
  64. /* Properties */
  65. char *masterbus;
  66. uint32_t firstport;
  67. uint32_t maxframes;
  68. } UHCIState;
  69. #define TYPE_UHCI "pci-uhci-usb"
  70. OBJECT_DECLARE_TYPE(UHCIState, UHCIPCIDeviceClass, UHCI)
  71. typedef struct UHCIInfo {
  72. const char *name;
  73. uint16_t vendor_id;
  74. uint16_t device_id;
  75. uint8_t revision;
  76. uint8_t irq_pin;
  77. void (*realize)(PCIDevice *dev, Error **errp);
  78. bool unplug;
  79. bool notuser; /* disallow user_creatable */
  80. } UHCIInfo;
  81. void uhci_data_class_init(ObjectClass *klass, void *data);
  82. void usb_uhci_common_realize(PCIDevice *dev, Error **errp);
  83. #define TYPE_PIIX3_USB_UHCI "piix3-usb-uhci"
  84. #define TYPE_PIIX4_USB_UHCI "piix4-usb-uhci"
  85. #define TYPE_ICH9_USB_UHCI(fn) "ich9-usb-uhci" #fn
  86. #endif