adb.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * QEMU ADB emulation shared definitions and prototypes
  3. *
  4. * Copyright (c) 2004-2007 Fabrice Bellard
  5. * Copyright (c) 2007 Jocelyn Mayer
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. * THE SOFTWARE.
  24. */
  25. #if !defined(__ADB_H__)
  26. #define __ADB_H__
  27. #include "qdev.h"
  28. #define MAX_ADB_DEVICES 16
  29. #define ADB_MAX_OUT_LEN 16
  30. typedef struct ADBBusState ADBBusState;
  31. typedef struct ADBDevice ADBDevice;
  32. /* buf = NULL means polling */
  33. typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
  34. const uint8_t *buf, int len);
  35. #define TYPE_ADB_DEVICE "adb-device"
  36. #define ADB_DEVICE(obj) OBJECT_CHECK(ADBDevice, (obj), TYPE_ADB_DEVICE)
  37. struct ADBDevice {
  38. /*< private >*/
  39. DeviceState parent_obj;
  40. /*< public >*/
  41. int devaddr;
  42. int handler;
  43. };
  44. #define ADB_DEVICE_CLASS(cls) \
  45. OBJECT_CLASS_CHECK(ADBDeviceClass, (cls), TYPE_ADB_DEVICE)
  46. #define ADB_DEVICE_GET_CLASS(obj) \
  47. OBJECT_GET_CLASS(ADBDeviceClass, (obj), TYPE_ADB_DEVICE)
  48. typedef struct ADBDeviceClass {
  49. /*< private >*/
  50. DeviceClass parent_class;
  51. /*< public >*/
  52. ADBDeviceRequest *devreq;
  53. } ADBDeviceClass;
  54. #define TYPE_ADB_BUS "apple-desktop-bus"
  55. #define ADB_BUS(obj) OBJECT_CHECK(ADBBusState, (obj), TYPE_ADB_BUS)
  56. struct ADBBusState {
  57. /*< private >*/
  58. BusState parent_obj;
  59. /*< public >*/
  60. ADBDevice *devices[MAX_ADB_DEVICES];
  61. int nb_devices;
  62. int poll_index;
  63. };
  64. int adb_request(ADBBusState *s, uint8_t *buf_out,
  65. const uint8_t *buf, int len);
  66. int adb_poll(ADBBusState *s, uint8_t *buf_out);
  67. #define TYPE_ADB_KEYBOARD "adb-keyboard"
  68. #define TYPE_ADB_MOUSE "adb-mouse"
  69. #endif /* !defined(__ADB_H__) */