From d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 11 Dec 2023 02:45:28 +0000
Subject: [PATCH] add boot partition  size

---
 kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/trxhdr.h |   87 ++++++++++++++++++++++++++-----------------
 1 files changed, 53 insertions(+), 34 deletions(-)

diff --git a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/trxhdr.h b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/trxhdr.h
index fa9b8c8..45ac434 100644
--- a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/trxhdr.h
+++ b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/trxhdr.h
@@ -1,15 +1,16 @@
-/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * TRX image file header format.
  *
- * Copyright (C) 1999-2019, Broadcom Corporation
- * 
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
+ *
+ * Copyright (C) 1999-2017, Broadcom Corporation
+ *
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
  * under the terms of the GNU General Public License version 2 (the "GPL"),
  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  * following added to such license:
- * 
+ *
  *      As a special exception, the copyright holders of this software give you
  * permission to link this software with independent modules, and to copy and
  * distribute the resulting executable under terms of your choice, provided that
@@ -17,7 +18,7 @@
  * the license of that module.  An independent module is a module which is not
  * derived from this software.  The special exception does not apply to any
  * modifications of the software.
- * 
+ *
  *      Notwithstanding the above, under no circumstances may you combine this
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
@@ -42,13 +43,47 @@
 #define TRX_UNCOMP_IMAGE	0x20	/* Trx contains uncompressed rtecdc.bin image */
 #define TRX_BOOTLOADER		0x40	/* the image is a bootloader */
 
-#define TRX_V1		1
-#define TRX_V1_MAX_OFFSETS	3		/* V1: Max number of individual files */
+#define TRX_VERSION_BIT_OFFSET  16
+#define R_COMP_SIZE             32	/* R component - 32 bytes */
+#define S_COMP_SIZE             32	/* S component - 32 bytes */
+#define ECDSA_SIGNATURE_SIZE (R_COMP_SIZE + S_COMP_SIZE) /* r[32bytes] and s[32bytes] components */
 
-#ifndef BCMTRXV2
-#define TRX_VERSION	TRX_V1		/* Version 1 */
-#define TRX_MAX_OFFSET TRX_V1_MAX_OFFSETS
-#endif
+enum {
+	TRX_V4_OFFS_SIGN_INFO_IDX                   = 0,
+	TRX_V4_OFFS_DATA_FOR_SIGN1_IDX              = 1,
+	TRX_V4_OFFS_DATA_FOR_SIGN2_IDX              = 2,
+	TRX_V4_OFFS_ROOT_MODULUS_IDX                = 3,
+	TRX_V4_OFFS_ROOT_EXPONENT_IDX               = 67,
+	TRX_V4_OFFS_CONT_MODULUS_IDX                = 68,
+	TRX_V4_OFFS_CONT_EXPONENT_IDX               = 132,
+	TRX_V4_OFFS_HASH_FW_IDX                     = 133,
+	TRX_V4_OFFS_FW_LEN_IDX                      = 149,
+	TRX_V4_OFFS_TR_RST_IDX                      = 150,
+	TRX_V4_OFFS_FW_VER_FOR_ANTIROOLBACK_IDX     = 151,
+	TRX_V4_OFFS_IV_IDX                          = 152,
+	TRX_V4_OFFS_NONCE_IDX                       = 160,
+	TRX_V4_OFFS_SIGN_INFO2_IDX                  = 168,
+	TRX_V4_OFFS_MAX_IDX
+};
+
+#if defined BCMTRXV4
+#define TRX_VERSION     4                       /* Version 4 */
+#define TRX_MAX_OFFSET  (TRX_V4_OFFS_MAX_IDX)
+
+#elif defined BCMTRXV3
+#define TRX_VERSION     3		/* Version 3 */
+#define TRX_MAX_OFFSET  4		/* FW size + Jump_addr + NVRAM size[if exist]
+					 * + signature size
+					 */
+#elif defined BCMTRXV2
+#define TRX_VERSION     2		/* Version 2 */
+#define TRX_MAX_OFFSET  5		/* Max number of individual files
+					 * to support SDR signature + Config data region
+					 */
+#else
+#define TRX_VERSION     1		/* Version 1 */
+#define TRX_MAX_OFFSET  3		/* Max number of individual files */
+#endif /* BCMTRXV3 BCMTRXV2 BCMTRXV4 */
 
 /* BMAC Host driver/application like bcmdl need to support both Ver 1 as well as
  * Ver 2 of trx header. To make it generic, trx_header is structure is modified
@@ -63,32 +98,16 @@
 	uint32 len;		/* Length of file including header */
 	uint32 crc32;		/* 32-bit CRC from flag_version to end of file */
 	uint32 flag_version;	/* 0:15 flags, 16:31 version */
-#ifndef BCMTRXV2
 	uint32 offsets[TRX_MAX_OFFSET];	/* Offsets of partitions from start of header */
-#else
-	uint32 offsets[1];	/* Offsets of partitions from start of header */
-#endif
 };
 
-#ifdef BCMTRXV2
-#define TRX_VERSION		TRX_V2		/* Version 2 */
-#define TRX_MAX_OFFSET  TRX_V2_MAX_OFFSETS
-
-#define TRX_V2		2
-/* V2: Max number of individual files
- * To support SDR signature + Config data region
- */
-#define TRX_V2_MAX_OFFSETS	5
-#define SIZEOF_TRXHDR_V1	(sizeof(struct trx_header)+(TRX_V1_MAX_OFFSETS-1)*sizeof(uint32))
-#define SIZEOF_TRXHDR_V2	(sizeof(struct trx_header)+(TRX_V2_MAX_OFFSETS-1)*sizeof(uint32))
-#define TRX_VER(trx)		((trx)->flag_version>>16)
-#define ISTRX_V1(trx)		(TRX_VER(trx) == TRX_V1)
-#define ISTRX_V2(trx)		(TRX_VER(trx) == TRX_V2)
-/* For V2, return size of V2 size: others, return V1 size */
-#define SIZEOF_TRX(trx)	    (ISTRX_V2(trx) ? SIZEOF_TRXHDR_V2: SIZEOF_TRXHDR_V1)
-#else
-#define SIZEOF_TRX(trx)	    (sizeof(struct trx_header))
-#endif /* BCMTRXV2 */
+/* bootloader makes special use of trx header "offsets" array */
+enum {
+	TRX_OFFS_FW_LEN_IDX     = 0,	/* Size of the fw; used in uncompressed case */
+	TRX_OFFS_TR_RST_IDX     = 1,	/* RAM address[tr_rst] for jump to after download */
+	TRX_OFFS_DSG_LEN_IDX    = 2,	/* Len of digital signature */
+	TRX_OFFS_CFG_LEN_IDX    = 3	/* Len of config region */
+};
 
 /* Compatibility */
 typedef struct trx_header TRXHDR, *PTRXHDR;

--
Gitblit v1.6.2