hcd-ohci.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * QEMU USB OHCI Emulation
  3. * Copyright (c) 2004 Gianni Tedesco
  4. * Copyright (c) 2006 CodeSourcery
  5. * Copyright (c) 2006 Openedhand Ltd.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef HCD_OHCI_H
  21. #define HCD_OHCI_H
  22. #include "sysemu/dma.h"
  23. #include "hw/usb.h"
  24. /* Number of Downstream Ports on the root hub: */
  25. #define OHCI_MAX_PORTS 15
  26. typedef struct OHCIPort {
  27. USBPort port;
  28. uint32_t ctrl;
  29. } OHCIPort;
  30. typedef struct OHCIState {
  31. USBBus bus;
  32. qemu_irq irq;
  33. MemoryRegion mem;
  34. AddressSpace *as;
  35. uint32_t num_ports;
  36. const char *name;
  37. QEMUTimer *eof_timer;
  38. int64_t sof_time;
  39. /* OHCI state */
  40. /* Control partition */
  41. uint32_t ctl, status;
  42. uint32_t intr_status;
  43. uint32_t intr;
  44. /* memory pointer partition */
  45. uint32_t hcca;
  46. uint32_t ctrl_head, ctrl_cur;
  47. uint32_t bulk_head, bulk_cur;
  48. uint32_t per_cur;
  49. uint32_t done;
  50. int32_t done_count;
  51. /* Frame counter partition */
  52. uint16_t fsmps;
  53. uint8_t fit;
  54. uint16_t fi;
  55. uint8_t frt;
  56. uint16_t frame_number;
  57. uint16_t padding;
  58. uint32_t pstart;
  59. uint32_t lst;
  60. /* Root Hub partition */
  61. uint32_t rhdesc_a, rhdesc_b;
  62. uint32_t rhstatus;
  63. OHCIPort rhport[OHCI_MAX_PORTS];
  64. /* PXA27x Non-OHCI events */
  65. uint32_t hstatus;
  66. uint32_t hmask;
  67. uint32_t hreset;
  68. uint32_t htest;
  69. /* SM501 local memory offset */
  70. dma_addr_t localmem_base;
  71. /* Active packets. */
  72. uint32_t old_ctl;
  73. USBPacket usb_packet;
  74. uint8_t usb_buf[8192];
  75. uint32_t async_td;
  76. bool async_complete;
  77. void (*ohci_die)(struct OHCIState *ohci);
  78. } OHCIState;
  79. #define TYPE_SYSBUS_OHCI "sysbus-ohci"
  80. #define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI)
  81. typedef struct {
  82. /*< private >*/
  83. SysBusDevice parent_obj;
  84. /*< public >*/
  85. OHCIState ohci;
  86. char *masterbus;
  87. uint32_t num_ports;
  88. uint32_t firstport;
  89. dma_addr_t dma_offset;
  90. } OHCISysBusState;
  91. extern const VMStateDescription vmstate_ohci_state;
  92. void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports,
  93. dma_addr_t localmem_base, char *masterbus,
  94. uint32_t firstport, AddressSpace *as,
  95. void (*ohci_die_fn)(struct OHCIState *), Error **errp);
  96. void ohci_bus_stop(OHCIState *ohci);
  97. void ohci_stop_endpoints(OHCIState *ohci);
  98. void ohci_hard_reset(OHCIState *ohci);
  99. void ohci_sysbus_die(struct OHCIState *ohci);
  100. #endif