hcd-ohci.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /* Number of Downstream Ports on the root hub: */
  24. #define OHCI_MAX_PORTS 15
  25. typedef struct OHCIPort {
  26. USBPort port;
  27. uint32_t ctrl;
  28. } OHCIPort;
  29. typedef struct OHCIState {
  30. USBBus bus;
  31. qemu_irq irq;
  32. MemoryRegion mem;
  33. AddressSpace *as;
  34. uint32_t num_ports;
  35. const char *name;
  36. QEMUTimer *eof_timer;
  37. int64_t sof_time;
  38. /* OHCI state */
  39. /* Control partition */
  40. uint32_t ctl, status;
  41. uint32_t intr_status;
  42. uint32_t intr;
  43. /* memory pointer partition */
  44. uint32_t hcca;
  45. uint32_t ctrl_head, ctrl_cur;
  46. uint32_t bulk_head, bulk_cur;
  47. uint32_t per_cur;
  48. uint32_t done;
  49. int32_t done_count;
  50. /* Frame counter partition */
  51. uint16_t fsmps;
  52. uint8_t fit;
  53. uint16_t fi;
  54. uint8_t frt;
  55. uint16_t frame_number;
  56. uint16_t padding;
  57. uint32_t pstart;
  58. uint32_t lst;
  59. /* Root Hub partition */
  60. uint32_t rhdesc_a, rhdesc_b;
  61. uint32_t rhstatus;
  62. OHCIPort rhport[OHCI_MAX_PORTS];
  63. /* PXA27x Non-OHCI events */
  64. uint32_t hstatus;
  65. uint32_t hmask;
  66. uint32_t hreset;
  67. uint32_t htest;
  68. /* SM501 local memory offset */
  69. dma_addr_t localmem_base;
  70. /* Active packets. */
  71. uint32_t old_ctl;
  72. USBPacket usb_packet;
  73. uint8_t usb_buf[8192];
  74. uint32_t async_td;
  75. bool async_complete;
  76. void (*ohci_die)(struct OHCIState *ohci);
  77. } OHCIState;
  78. extern const VMStateDescription vmstate_ohci_state;
  79. void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports,
  80. dma_addr_t localmem_base, char *masterbus,
  81. uint32_t firstport, AddressSpace *as,
  82. void (*ohci_die_fn)(struct OHCIState *), Error **errp);
  83. void ohci_bus_stop(OHCIState *ohci);
  84. void ohci_stop_endpoints(OHCIState *ohci);
  85. void ohci_hard_reset(OHCIState *ohci);
  86. void ohci_sysbus_die(struct OHCIState *ohci);
  87. #endif