Path: blob/main/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h
108460 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2013 Adrian Chadd <[email protected]>4* Copyright (c) 2019 Vladimir Kondratyev <[email protected]>5* Copyright (c) 2023 Future Crew LLC.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef __IWMBT_FW_H__30#define __IWMBT_FW_H__3132#include <sys/types.h>33#define L2CAP_SOCKET_CHECKED34#include <bluetooth.h>3536#define RSA_HEADER_LEN 64437#define ECDSA_HEADER_LEN 32038#define ECDSA_OFFSET RSA_HEADER_LEN39#define CSS_HEADER_OFFSET 84041struct iwmbt_version {42uint8_t status;43uint8_t hw_platform;44uint8_t hw_variant;45uint8_t hw_revision;46uint8_t fw_variant;47uint8_t fw_revision;48uint8_t fw_build_num;49uint8_t fw_build_ww;50uint8_t fw_build_yy;51uint8_t fw_patch_num;52} __attribute__ ((packed));5354/* Known values for fw_variant */55#define FW_VARIANT_BOOTLOADER 0x06 /* Bootloader mode */56#define FW_VARIANT_OPERATIONAL 0x23 /* Operational mode */5758struct iwmbt_boot_params {59uint8_t status;60uint8_t otp_format;61uint8_t otp_content;62uint8_t otp_patch;63uint16_t dev_revid;64uint8_t secure_boot;65uint8_t key_from_hdr;66uint8_t key_type;67uint8_t otp_lock;68uint8_t api_lock;69uint8_t debug_lock;70uint8_t otp_bdaddr[6];71uint8_t min_fw_build_nn;72uint8_t min_fw_build_cw;73uint8_t min_fw_build_yy;74uint8_t limited_cce;75uint8_t unlocked_state;76} __attribute__ ((packed));7778enum {79IWMBT_TLV_CNVI_TOP = 0x10,80IWMBT_TLV_CNVR_TOP,81IWMBT_TLV_CNVI_BT,82IWMBT_TLV_CNVR_BT,83IWMBT_TLV_CNVI_OTP,84IWMBT_TLV_CNVR_OTP,85IWMBT_TLV_DEV_REV_ID,86IWMBT_TLV_USB_VENDOR_ID,87IWMBT_TLV_USB_PRODUCT_ID,88IWMBT_TLV_PCIE_VENDOR_ID,89IWMBT_TLV_PCIE_DEVICE_ID,90IWMBT_TLV_PCIE_SUBSYSTEM_ID,91IWMBT_TLV_IMAGE_TYPE,92IWMBT_TLV_TIME_STAMP,93IWMBT_TLV_BUILD_TYPE,94IWMBT_TLV_BUILD_NUM,95IWMBT_TLV_FW_BUILD_PRODUCT,96IWMBT_TLV_FW_BUILD_HW,97IWMBT_TLV_FW_STEP,98IWMBT_TLV_BT_SPEC,99IWMBT_TLV_MFG_NAME,100IWMBT_TLV_HCI_REV,101IWMBT_TLV_LMP_SUBVER,102IWMBT_TLV_OTP_PATCH_VER,103IWMBT_TLV_SECURE_BOOT,104IWMBT_TLV_KEY_FROM_HDR,105IWMBT_TLV_OTP_LOCK,106IWMBT_TLV_API_LOCK,107IWMBT_TLV_DEBUG_LOCK,108IWMBT_TLV_MIN_FW,109IWMBT_TLV_LIMITED_CCE,110IWMBT_TLV_SBE_TYPE,111IWMBT_TLV_OTP_BDADDR,112IWMBT_TLV_UNLOCKED_STATE113};114115struct iwmbt_version_tlv {116uint32_t cnvi_top;117uint32_t cnvr_top;118uint32_t cnvi_bt;119uint32_t cnvr_bt;120uint16_t dev_rev_id;121uint8_t img_type;122uint16_t timestamp;123uint8_t build_type;124uint32_t build_num;125uint8_t secure_boot;126uint8_t otp_lock;127uint8_t api_lock;128uint8_t debug_lock;129uint8_t min_fw_build_nn;130uint8_t min_fw_build_cw;131uint8_t min_fw_build_yy;132uint8_t limited_cce;133uint8_t sbe_type;134bdaddr_t otp_bd_addr;135};136137/* Known TLV img_type values */138#define TLV_IMG_TYPE_BOOTLOADER 0x01 /* Bootloader mode */139#define TLV_IMG_TYPE_OPERATIONAL 0x03 /* Operational mode */140141struct iwmbt_firmware {142char *fwname;143int len;144unsigned char *buf;145};146147extern int iwmbt_fw_read(struct iwmbt_firmware *fw, const char *fwname);148extern void iwmbt_fw_free(struct iwmbt_firmware *fw);149extern char *iwmbt_get_fwname(struct iwmbt_version *ver,150struct iwmbt_boot_params *params, const char *prefix,151const char *suffix);152extern char *iwmbt_get_fwname_tlv(struct iwmbt_version_tlv *ver,153const char *prefix, const char *suffix);154155#endif156157158