PacketTypes.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Types.h>
  8. namespace Kernel::USB {
  9. // Setup descriptor bit definitions
  10. static constexpr u8 BM_REQUEST_HOST_TO_DEVICE = (0 << 7);
  11. static constexpr u8 BM_REQUEST_DEVICE_TO_HOST = (1 << 7);
  12. static constexpr u8 BM_REQUEST_TYPE_STANDARD = (0 << 5);
  13. static constexpr u8 BM_REQUEST_TYPE_CLASS = (1 << 5);
  14. static constexpr u8 BM_REQUEST_TYPE_VENDOR = (2 << 5);
  15. static constexpr u8 BM_REQUEST_TYPE_RESERVED = (3 << 5);
  16. static constexpr u8 BM_REQUEST_RECIPEINT_DEVICE = (0 << 0);
  17. static constexpr u8 BM_REQUEST_RECIPIENT_INTERFACE = (1 << 0);
  18. static constexpr u8 BM_REQUEST_RECIPIENT_ENDPOINT = (2 << 0);
  19. static constexpr u8 BM_REQUEST_RECIPIENT_OTHER = (3 << 0);
  20. //
  21. // This is also known as the "setup" packet. It's attached to the
  22. // first TD in the chain and is the first piece of data sent to the
  23. // USB device over the bus.
  24. // https://beyondlogic.org/usbnutshell/usb6.shtml#StandardEndpointRequests
  25. //
  26. struct USBRequestData {
  27. u8 request_type;
  28. u8 request;
  29. u16 value;
  30. u16 index;
  31. u16 length;
  32. };
  33. }