fusb_private.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: fusb_private.h
  15. * Date: 2022-02-11 13:33:11
  16. * LastEditTime: 2022-02-18 09:21:22
  17. * Description:  This files is for definition of internal function interface
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. * 1.0 Zhugengyu 2022/2/7 init commit
  23. */
  24. #pragma once
  25. /***************************** Include Files *********************************/
  26. #ifdef __aarch64__
  27. #include "faarch64.h"
  28. #else
  29. #include "fcp15.h"
  30. #endif
  31. #include "fkernel.h"
  32. #include "fio.h"
  33. #include "fassert.h"
  34. #include "fusb.h"
  35. /************************** Constant Definitions *****************************/
  36. /**************************** Type Definitions *******************************/
  37. /************************** Variable Definitions *****************************/
  38. /***************** Macros (Inline Functions) Definitions *********************/
  39. #define FUSB_REG32_GET_BITS(x, a, b) (u32)((((u32)(x)) & GENMASK(a, b)) >> b)
  40. #define FUSB_REG32_SET_BITS(x, a, b) (u32)((((u32)(x)) << b) & GENMASK(a, b))
  41. #define FUSB_REG64_GET_BITS(x, a, b) (u64)((((u64)(x)) & GENMASK_ULL(a, b)) >> b)
  42. #define FUSB_REG64_SET_BITS(x, a, b) (u64)((((u64)(x)) << b) & GENMASK_ULL(a, b))
  43. /************************** Function Prototypes ******************************/
  44. /* 创建USB控制器实例,添加到USB实例的Hc链表中 */
  45. FUsbHc *FUsbAllocateHc(FUsb *instance);
  46. /* 删除USB控制器实例,从USB实例的Hc链表中删去 */
  47. void FUsbDetachHc(FUsbHc *controller);
  48. /* 初始化USB设备 */
  49. FUsbDev *FUsbInitDevEntry(FUsbHc *controller, int slot_id);
  50. /* 根据USB设备速度,选择最大包长度 */
  51. int FUsbDecodeMaxPacketSz0(FUsbSpeed speed, u8 bMaxPacketSize0);
  52. /* 据设备速度获取最大包长度 */
  53. int FUsbSpeedtoDefaultMaxPacketSz(FUsbSpeed speed);
  54. /* 配置USB配置描述符解析器 */
  55. FError FUsbSetupConfigParser(FUsbDev *dev, const void *buf, u32 buf_len);
  56. /* 去初始化USB配置描述符解析器 */
  57. void FUsbRevokeConfigParser(FUsbDev *dev);
  58. /* 初始化字符串描述符解析器 */
  59. void FUsbSetupStringParser(FUsbDev *dev);
  60. /* 去初始化字符串描述符解析器 */
  61. void FUsbRevokeStringParser(FUsbDev *dev);
  62. /* 检索字符串描述符,保存在FUsbStringParser结构中 */
  63. FError FUsbSearchStringDescriptor(FUsb *instance, FUsbDev *dev, u8 id);
  64. /* 获取刚刚检索到的字符串描述符内容 */
  65. const char *FUsbGetString(const FUsbDev *const dev);
  66. /* 从配置描述符解析器中获取指定类型的描述符(端点描述符/接口描述符) */
  67. const FUsbDescriptor *FUsbGetDescriptorFromParser(FUsbConfigParser *parser, FUsbDescriptorType type);
  68. /* 默认的USB设备初始化函数 */
  69. void FUsbNopDevInit(FUsbDev *dev);
  70. /* 默认的USB设备初始化函数 */
  71. void FUsbGenericDevInit(FUsbDev *dev);
  72. /* 打印设备描述符信息 */
  73. void FUsbDumpDeviceDescriptor(const FUsbDeviceDescriptor *descriptor);
  74. /* 打印配置描述符信息 */
  75. void FUsbDumpConfigDescriptor(const FUsbConfigurationDescriptor *descriptor);
  76. /* 打印接口描述符信息 */
  77. void FUsbDumpInterfaceDescriptor(const FUsbInterfaceDescriptor *descriptor);
  78. /* 打印端点描述符信息 */
  79. void FUsbDumpEndpointDescriptor(const FUsbEndpointDescriptor *descriptor);