usb: bos: cleanup Binary Device Object Store header
We could reuse the BOS header, but there are parts that are only needed in the legacy device support or used internally and the tests. Move this parts to the appropriate places. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
4f17bc6051
commit
29003ff264
6 changed files with 60 additions and 48 deletions
|
@ -17,12 +17,13 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Helper macro to place the BOS compatibility descriptor
|
||||
* in the right memory section.
|
||||
*/
|
||||
#define USB_DEVICE_BOS_DESC_DEFINE_CAP \
|
||||
static __in_section(usb, bos_desc_area, 1) __aligned(1) __used
|
||||
/** Root BOS Descriptor */
|
||||
struct usb_bos_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bNumDeviceCaps;
|
||||
} __packed;
|
||||
|
||||
/** Device capability type codes */
|
||||
enum usb_bos_capability_types {
|
||||
|
@ -62,45 +63,6 @@ struct usb_bos_capability_msos {
|
|||
uint8_t bAltEnumCode;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* @brief Register BOS capability descriptor
|
||||
*
|
||||
* This function should be used by the application to register BOS capability
|
||||
* descriptors before the USB device stack is enabled.
|
||||
*
|
||||
* @param[in] hdr Pointer to BOS capability descriptor
|
||||
*/
|
||||
void usb_bos_register_cap(struct usb_bos_platform_descriptor *hdr);
|
||||
|
||||
/**
|
||||
* @cond INTERNAL_HIDDEN
|
||||
* Internally used functions
|
||||
*/
|
||||
|
||||
/* BOS Descriptor (root descriptor) */
|
||||
struct usb_bos_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bNumDeviceCaps;
|
||||
} __packed;
|
||||
|
||||
#define USB_DEVICE_BOS_DESC_DEFINE_HDR \
|
||||
static __in_section(usb, bos_desc_area, 0) __aligned(1) __used
|
||||
|
||||
size_t usb_bos_get_length(void);
|
||||
|
||||
void usb_bos_fix_total_length(void);
|
||||
|
||||
const void *usb_bos_get_header(void);
|
||||
|
||||
#if defined(CONFIG_USB_DEVICE_BOS)
|
||||
int usb_handle_bos(struct usb_setup_packet *setup, int32_t *len, uint8_t **data);
|
||||
#else
|
||||
#define usb_handle_bos(x, y, z) -ENOTSUP
|
||||
#endif
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -446,6 +446,23 @@ int usb_wakeup_request(void);
|
|||
*/
|
||||
bool usb_get_remote_wakeup_status(void);
|
||||
|
||||
/**
|
||||
* @brief Helper macro to place the BOS compatibility descriptor
|
||||
* in the right memory section.
|
||||
*/
|
||||
#define USB_DEVICE_BOS_DESC_DEFINE_CAP \
|
||||
static __in_section(usb, bos_desc_area, 1) __aligned(1) __used
|
||||
|
||||
/**
|
||||
* @brief Register BOS capability descriptor
|
||||
*
|
||||
* This function should be used by the application to register BOS capability
|
||||
* descriptors before the USB device stack is enabled.
|
||||
*
|
||||
* @param[in] hdr Pointer to BOS capability descriptor
|
||||
*/
|
||||
void usb_bos_register_cap(void *hdr);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -7,15 +7,18 @@
|
|||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(usb_bos, CONFIG_USB_DEVICE_LOG_LEVEL);
|
||||
|
||||
#include <bos_desc.h>
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <zephyr/usb/usb_device.h>
|
||||
|
||||
#include <zephyr/usb/bos.h>
|
||||
|
||||
extern const uint8_t __usb_bos_desc_start[];
|
||||
extern const uint8_t __usb_bos_desc_end[];
|
||||
|
||||
#define USB_DEVICE_BOS_DESC_DEFINE_HDR \
|
||||
static __in_section(usb, bos_desc_area, 0) __aligned(1) __used
|
||||
|
||||
USB_DEVICE_BOS_DESC_DEFINE_HDR struct usb_bos_descriptor bos_hdr = {
|
||||
.bLength = sizeof(struct usb_bos_descriptor),
|
||||
.bDescriptorType = USB_DESC_BOS,
|
||||
|
@ -38,8 +41,10 @@ void usb_bos_fix_total_length(void)
|
|||
bos_hdr.wTotalLength = usb_bos_get_length();
|
||||
}
|
||||
|
||||
void usb_bos_register_cap(struct usb_bos_platform_descriptor *desc)
|
||||
void usb_bos_register_cap(void *desc)
|
||||
{
|
||||
ARG_UNUSED(desc);
|
||||
|
||||
/* Has effect only on first register */
|
||||
bos_hdr.wTotalLength = usb_bos_get_length();
|
||||
|
||||
|
|
25
subsys/usb/device/bos_desc.h
Normal file
25
subsys/usb/device/bos_desc.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_USB_DEVICE_BOS_DESC_H_
|
||||
#define ZEPHYR_INCLUDE_USB_DEVICE_BOS_DESC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <zephyr/usb/usb_ch9.h>
|
||||
|
||||
size_t usb_bos_get_length(void);
|
||||
|
||||
void usb_bos_fix_total_length(void);
|
||||
|
||||
const void *usb_bos_get_header(void);
|
||||
|
||||
#if defined(CONFIG_USB_DEVICE_BOS)
|
||||
int usb_handle_bos(struct usb_setup_packet *setup, int32_t *len, uint8_t **data);
|
||||
#else
|
||||
#define usb_handle_bos(x, y, z) -ENOTSUP
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_USB_DEVICE_BOS_DESC_H_ */
|
|
@ -59,6 +59,7 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <bos_desc.h>
|
||||
#include <zephyr/sys/util.h>
|
||||
#include <zephyr/sys/__assert.h>
|
||||
#include <zephyr/init.h>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <bos_desc.h>
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <zephyr/tc_util.h>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue