# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-shell=/bin/sh
+shell=/bin/bash
prefix=/lib/firmware
install_program=install
aica: Firmware for the sound card in the Sega Dreamcast
-Version: Based on commit 832ea65b43c8b402f19f3b6b3ecb8804f73c948a
-dated 17 May 2018
+Version: Based on commit fae2358ca346842f3f4d36237be3994fe6135139
+dated 7 October 2020
License: KOS License (see README.KOS)
Driver: ath9k_htc - Atheros HTC devices (USB)
-Version: Based on commit 014ff6fde0fab968eb5b4365e83a93a2fff452c2
-dated January 28 2018
+Version: Based on commit d856466a068afe4069335257c0d28295ff777d92
+dated May 22 2022
Licence: Free software. See ath9k_htc/LICENCE.TXT for details.
Driver: carl9170 -- Atheros AR9170 802.11 draft-n USB driver
-Version: Based on commit 001384147050b9cd9daadb4d3115cc0f13f5b319
-dated May 5 2019.
+Version: Based on commit 2f3ccb41237fba9e8dd7543d3b11c0746a5d8313
+dated February 5 2022.
Licence: GPLv2 or later.
uint32 freq_lo, freq_base = 5644800;
int freq_hi = 7;
- uint32 i;
uint32 playCont;
/* Stop the channel (if it's already playing) */
/* Write resulting values */
CHNREG32(ch, 24) = (freq_hi << 11) | (freq_lo & 1023);
- /* Set volume, pan */
+ /* Convert the incoming pan into a hardware value and set it */
CHNREG8(ch, 36) = calc_aica_pan(pan);
CHNREG8(ch, 37) = 0xf;
/* turn off Low Pass Filter (LPF) */
CHNREG8(ch, 40) = 0x24;
- /* Convert the incoming volume and pan into hardware values */
- /* Vol starts at zero so we can ramp */
- CHNREG8(ch, 41) = 0xff;
+ /* Convert the incoming volume into a hardware value and set it */
+ CHNREG8(ch, 41) = calc_aica_vol(vol);
/* If we supported volume envelopes (which we don't yet) then
this value would set that up. The top 4 bits determine the
also set the bits to start playback here. */
CHNREG32(ch, 4) = smpptr & 0xffff;
playCont = (mode << 7) | (smpptr >> 16);
- vol = calc_aica_vol(vol);
if(loopflag)
playCont |= 0x0200;
if(delay) {
CHNREG32(ch, 0) = playCont; /* key off */
- CHNREG8(ch, 41) = vol;
}
else {
CHNREG32(ch, 0) = 0xc000 | playCont; /* key on */
-
- /* ramp up the volume */
- for(i = 0xff; i >= vol; i--)
- CHNREG8(ch, 41) = i;
}
}
#ifndef __ARM_AICA_CMD_IFACE_H
#define __ARM_AICA_CMD_IFACE_H
-#ifndef __ARCH_TYPES_H
-typedef unsigned long uint8;
-typedef unsigned long uint32;
-#endif
-
-/* Command queue; one of these for passing data from the SH-4 to the
- AICA, and another for the other direction. If a command is written
- to the queue and it is longer than the amount of space between the
- head point and the queue size, the command will wrap around to
- the beginning (i.e., queue commands _can_ be split up). */
-typedef struct aica_queue {
- uint32 head; /* Insertion point offset (in bytes) */
- uint32 tail; /* Removal point offset (in bytes) */
- uint32 size; /* Queue size (in bytes) */
- uint32 valid; /* 1 if the queue structs are valid */
- uint32 process_ok; /* 1 if it's ok to process the data */
- uint32 data; /* Pointer to queue data buffer */
-} aica_queue_t;
-
-/* Command queue struct for commanding the AICA from the SH-4 */
-typedef struct aica_cmd {
- uint32 size; /* Command data size in dwords */
- uint32 cmd; /* Command ID */
- uint32 timestamp; /* When to execute the command (0 == now) */
- uint32 cmd_id; /* Command ID, for cmd/response pairs, or channel id */
- uint32 misc[4]; /* Misc Parameters / Padding */
- uint8 cmd_data[]; /* Command data */
-} aica_cmd_t;
-
-/* Maximum command size -- 256 dwords */
-#define AICA_CMD_MAX_SIZE 256
-
-/* This is the cmd_data for AICA_CMD_CHAN. Make this 16 dwords long
- for two aica bus queues. */
-typedef struct aica_channel {
- uint32 cmd; /* Command ID */
- uint32 base; /* Sample base in RAM */
- uint32 type; /* (8/16bit/ADPCM) */
- uint32 length; /* Sample length */
- uint32 loop; /* Sample looping */
- uint32 loopstart; /* Sample loop start */
- uint32 loopend; /* Sample loop end */
- uint32 freq; /* Frequency */
- uint32 vol; /* Volume 0-255 */
- uint32 pan; /* Pan 0-255 */
- uint32 pos; /* Sample playback pos */
- uint32 pad[5]; /* Padding */
-} aica_channel_t;
-
-/* Declare an aica_cmd_t big enough to hold an aica_channel_t
- using temp name T, aica_cmd_t name CMDR, and aica_channel_t name CHANR */
-#define AICA_CMDSTR_CHANNEL(T, CMDR, CHANR) \
- uint8 T[sizeof(aica_cmd_t) + sizeof(aica_channel_t)]; \
- aica_cmd_t * CMDR = (aica_cmd_t *)T; \
- aica_channel_t * CHANR = (aica_channel_t *)(CMDR->cmd_data);
-#define AICA_CMDSTR_CHANNEL_SIZE ((sizeof(aica_cmd_t) + sizeof(aica_channel_t))/4)
-
-/* Command values (for aica_cmd_t) */
-#define AICA_CMD_NONE 0x00000000 /* No command (dummy packet) */
-#define AICA_CMD_PING 0x00000001 /* Check for signs of life */
-#define AICA_CMD_CHAN 0x00000002 /* Perform a wavetable action */
-#define AICA_CMD_SYNC_CLOCK 0x00000003 /* Reset the millisecond clock */
-
-/* Response values (for aica_cmd_t) */
-#define AICA_RESP_NONE 0x00000000
-#define AICA_RESP_PONG 0x00000001 /* Response to CMD_PING */
-#define AICA_RESP_DBGPRINT 0x00000002 /* Entire payload is a null-terminated string */
-
-/* Command values (for aica_channel_t commands) */
-#define AICA_CH_CMD_MASK 0x0000000f
-
-#define AICA_CH_CMD_NONE 0x00000000
-#define AICA_CH_CMD_START 0x00000001
-#define AICA_CH_CMD_STOP 0x00000002
-#define AICA_CH_CMD_UPDATE 0x00000003
-
-/* Start values */
-#define AICA_CH_START_MASK 0x00300000
-
-#define AICA_CH_START_DELAY 0x00100000 /* Set params, but delay key-on */
-#define AICA_CH_START_SYNC 0x00200000 /* Set key-on for all selected channels */
-
-/* Update values */
-#define AICA_CH_UPDATE_MASK 0x000ff000
-
-#define AICA_CH_UPDATE_SET_FREQ 0x00001000 /* frequency */
-#define AICA_CH_UPDATE_SET_VOL 0x00002000 /* volume */
-#define AICA_CH_UPDATE_SET_PAN 0x00004000 /* panning */
-
-/* Sample types */
-#define AICA_SM_8BIT 1
-#define AICA_SM_16BIT 0
-#define AICA_SM_ADPCM 2
-
+#include "aica_comm.h"
/* This is where our SH-4/AICA comm variables go... */
--- /dev/null
+/* KallistiOS ##version##
+
+ aica_comm.h
+ Copyright (C) 2000-2002 Dan Potter
+
+ Structure and constant definitions for the SH-4/AICA interface. This file is
+ included from both the ARM and SH-4 sides of the fence.
+*/
+
+#ifndef __DC_SOUND_AICA_COMM_H
+#define __DC_SOUND_AICA_COMM_H
+
+#ifndef __ARCH_TYPES_H
+typedef unsigned long uint8;
+typedef unsigned long uint32;
+#endif
+
+/* Command queue; one of these for passing data from the SH-4 to the
+ AICA, and another for the other direction. If a command is written
+ to the queue and it is longer than the amount of space between the
+ head point and the queue size, the command will wrap around to
+ the beginning (i.e., queue commands _can_ be split up). */
+typedef struct aica_queue {
+ uint32 head; /* Insertion point offset (in bytes) */
+ uint32 tail; /* Removal point offset (in bytes) */
+ uint32 size; /* Queue size (in bytes) */
+ uint32 valid; /* 1 if the queue structs are valid */
+ uint32 process_ok; /* 1 if it's ok to process the data */
+ uint32 data; /* Pointer to queue data buffer */
+} aica_queue_t;
+
+/* Command queue struct for commanding the AICA from the SH-4 */
+typedef struct aica_cmd {
+ uint32 size; /* Command data size in dwords */
+ uint32 cmd; /* Command ID */
+ uint32 timestamp; /* When to execute the command (0 == now) */
+ uint32 cmd_id; /* Command ID, for cmd/response pairs, or channel id */
+ uint32 misc[4]; /* Misc Parameters / Padding */
+ uint8 cmd_data[]; /* Command data */
+} aica_cmd_t;
+
+/* Maximum command size -- 256 dwords */
+#define AICA_CMD_MAX_SIZE 256
+
+/* This is the cmd_data for AICA_CMD_CHAN. Make this 16 dwords long
+ for two aica bus queues. */
+typedef struct aica_channel {
+ uint32 cmd; /* Command ID */
+ uint32 base; /* Sample base in RAM */
+ uint32 type; /* (8/16bit/ADPCM) */
+ uint32 length; /* Sample length */
+ uint32 loop; /* Sample looping */
+ uint32 loopstart; /* Sample loop start */
+ uint32 loopend; /* Sample loop end */
+ uint32 freq; /* Frequency */
+ uint32 vol; /* Volume 0-255 */
+ uint32 pan; /* Pan 0-255 */
+ uint32 pos; /* Sample playback pos */
+ uint32 pad[5]; /* Padding */
+} aica_channel_t;
+
+/* Declare an aica_cmd_t big enough to hold an aica_channel_t
+ using temp name T, aica_cmd_t name CMDR, and aica_channel_t name CHANR */
+#define AICA_CMDSTR_CHANNEL(T, CMDR, CHANR) \
+ uint8 T[sizeof(aica_cmd_t) + sizeof(aica_channel_t)]; \
+ aica_cmd_t * CMDR = (aica_cmd_t *)T; \
+ aica_channel_t * CHANR = (aica_channel_t *)(CMDR->cmd_data);
+#define AICA_CMDSTR_CHANNEL_SIZE ((sizeof(aica_cmd_t) + sizeof(aica_channel_t))/4)
+
+/* Command values (for aica_cmd_t) */
+#define AICA_CMD_NONE 0x00000000 /* No command (dummy packet) */
+#define AICA_CMD_PING 0x00000001 /* Check for signs of life */
+#define AICA_CMD_CHAN 0x00000002 /* Perform a wavetable action */
+#define AICA_CMD_SYNC_CLOCK 0x00000003 /* Reset the millisecond clock */
+
+/* Response values (for aica_cmd_t) */
+#define AICA_RESP_NONE 0x00000000
+#define AICA_RESP_PONG 0x00000001 /* Response to CMD_PING */
+#define AICA_RESP_DBGPRINT 0x00000002 /* Entire payload is a null-terminated string */
+
+/* Command values (for aica_channel_t commands) */
+#define AICA_CH_CMD_MASK 0x0000000f
+
+#define AICA_CH_CMD_NONE 0x00000000
+#define AICA_CH_CMD_START 0x00000001
+#define AICA_CH_CMD_STOP 0x00000002
+#define AICA_CH_CMD_UPDATE 0x00000003
+
+/* Start values */
+#define AICA_CH_START_MASK 0x00300000
+
+#define AICA_CH_START_DELAY 0x00100000 /* Set params, but delay key-on */
+#define AICA_CH_START_SYNC 0x00200000 /* Set key-on for all selected channels */
+
+/* Update values */
+#define AICA_CH_UPDATE_MASK 0x000ff000
+
+#define AICA_CH_UPDATE_SET_FREQ 0x00001000 /* frequency */
+#define AICA_CH_UPDATE_SET_VOL 0x00002000 /* volume */
+#define AICA_CH_UPDATE_SET_PAN 0x00004000 /* panning */
+
+/* Sample types */
+#define AICA_SM_8BIT 1
+#define AICA_SM_16BIT 0
+#define AICA_SM_ADPCM 2
+
+#endif /* !__DC_SOUND_AICA_COMM_H */
-GMP_VER=6.1.2
+GMP_VER=6.2.0
GMP_URL=https://ftp.gnu.org/gnu/gmp/gmp-$(GMP_VER).tar.bz2
GMP_TAR=gmp-$(GMP_VER).tar.bz2
GMP_DIR=gmp-$(GMP_VER)
-GMP_SUM=5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2
+GMP_SUM=f51c99cb114deb21a60075ffb494c1a210eb9d7cb729ed042ddb7de9534451ea
-MPFR_VER=3.1.6
+MPFR_VER=4.1.0
MPFR_URL=https://ftp.gnu.org/gnu/mpfr/mpfr-$(MPFR_VER).tar.bz2
MPFR_TAR=mpfr-$(MPFR_VER).tar.bz2
MPFR_DIR=mpfr-$(MPFR_VER)
-MPFR_SUM=cf4f4b2d80abb79e820e78c8077b6725bbbb4e8f41896783c899087be0e94068
+MPFR_SUM=feced2d430dd5a97805fa289fed3fc8ff2b094c02d05287fd6133e7f1f0ec926
-MPC_VER=1.0.3
+MPC_VER=1.1.0
MPC_URL=https://ftp.gnu.org/gnu/mpc/mpc-$(MPC_VER).tar.gz
MPC_TAR=mpc-$(MPC_VER).tar.gz
MPC_DIR=mpc-$(MPC_VER)
-MPC_SUM=617decc6ea09889fb08ede330917a00b16809b8db88c29c31bfbb49cbf88ecc3
+MPC_SUM=6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e
-BINUTILS_VER=2.29
+BINUTILS_VER=2.35
BINUTILS_URL=https://ftp.gnu.org/gnu/binutils/binutils-$(BINUTILS_VER).tar.bz2
BINUTILS_TAR=binutils-$(BINUTILS_VER).tar.bz2
BINUTILS_DIR=binutils-$(BINUTILS_VER)
-BINUTILS_PATCHES=local/patches/binutils.patch
-BINUTILS_SUM=29a29549869039aad75fdf507ac30366da5ad0b974fbff4a8e7148dbf4f40ebf
+BINUTILS_PATCHES=local/patches/binutils-2.34_fixup.patch local/patches/binutils.patch
+BINUTILS_SUM=7d24660f87093670738e58bcc7b7b06f121c0fcb0ca8fc44368d675a5ef9cff7
-GCC_VER=7.2.0
+GCC_VER=10.2.0
GCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VER)/gcc-$(GCC_VER).tar.gz
GCC_TAR=gcc-$(GCC_VER).tar.gz
GCC_DIR=gcc-$(GCC_VER)
GCC_PATCHES=local/patches/gcc.patch
-GCC_SUM=0153a003d3b433459336a91610cca2995ee0fb3d71131bd72555f2231a6efcfc
+GCC_SUM=27e879dccc639cd7b0cc08ed575c1669492579529b53c9ff27b0b96265fa867d
BASEDIR=$(shell pwd)
TOOLCHAIN_DIR=$(BASEDIR)/toolchain
Copyright (c) 2013 QUALCOMM ATHEROS Incorporated. All rights reserved.
-QUALCOMM ATHEROS® is a registered trademark and registered service mark of
+QUALCOMM ATHEROS® is a registered trademark and registered service mark of
QUALCOMM ATHEROS Incorporated. All other trademarks and service marks are
the property of their respective owners.
--- /dev/null
+From 4706172d220e9755008c77d780895382025c794c Mon Sep 17 00:00:00 2001
+From: Oleksij Rempel <linux@rempel-privat.de>
+Date: Sun, 23 Feb 2020 08:36:18 +0100
+Subject: [PATCH 1/2] revert: ubsan: xtensa: left shift cannot be represented
+ in type 'int'
+
+Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
+---
+ bfd/xtensa-modules.c | 1528 ++++++++++++++++++++++++++----------------
+ 1 file changed, 962 insertions(+), 566 deletions(-)
+
+diff --git a/bfd/xtensa-modules.c b/bfd/xtensa-modules.c
+index 9af5653313..785dfe7aa0 100644
+--- a/bfd/xtensa-modules.c
++++ b/bfd/xtensa-modules.c
+@@ -302,1356 +302,1539 @@ static xtensa_state_internal states[] = {
+ static unsigned
+ Field_t_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_t_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_t_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_t_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_t_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_t_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_t_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_t_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_t_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_t_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_t_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_t_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_t_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_t_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_bbi4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_bbi4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_bbi_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_bbi_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_bbi_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 26) & 1;
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_bbi_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+ }
+
+ static unsigned
+ Field_imm12_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xfff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 12) | ((insn[0] << 8) >> 20);
+ return tie_t;
+ }
+
+ static void
+ Field_imm12_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xfff;
++ uint32 tie_t;
++ tie_t = (val << 20) >> 20;
+ insn[0] = (insn[0] & ~0xfff000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm8_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 0xff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 8) | ((insn[0] << 8) >> 24);
+ return tie_t;
+ }
+
+ static void
+ Field_imm8_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xff;
++ uint32 tie_t;
++ tie_t = (val << 24) >> 24;
+ insn[0] = (insn[0] & ~0xff0000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_imm8_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 8) | ((insn[0] << 12) >> 24);
+ return tie_t;
+ }
+
+ static void
+ Field_imm8_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xff;
++ uint32 tie_t;
++ tie_t = (val << 24) >> 24;
+ insn[0] = (insn[0] & ~0xff000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm8_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm8_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_s_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_s_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_s_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_s_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_s_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_s_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_s_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_s_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_s_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_s_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_s_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_s_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_s_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_s_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm12b_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
+- tie_t = (tie_t << 8) | ((insn[0] >> 16) & 0xff);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
++ tie_t = (tie_t << 8) | ((insn[0] << 8) >> 24);
+ return tie_t;
+ }
+
+ static void
+ Field_imm12b_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xff;
++ uint32 tie_t;
++ tie_t = (val << 24) >> 24;
+ insn[0] = (insn[0] & ~0xff0000) | (tie_t << 16);
+- tie_t = (val >> 8) & 0xf;
++ tie_t = (val << 20) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_imm12b_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xf;
+- tie_t = (tie_t << 8) | ((insn[0] >> 12) & 0xff);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
++ tie_t = (tie_t << 8) | ((insn[0] << 12) >> 24);
+ return tie_t;
+ }
+
+ static void
+ Field_imm12b_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xff;
++ uint32 tie_t;
++ tie_t = (val << 24) >> 24;
+ insn[0] = (insn[0] & ~0xff000) | (tie_t << 12);
+- tie_t = (val >> 8) & 0xf;
++ tie_t = (val << 20) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm12b_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xfff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 12) | ((insn[0] << 16) >> 20);
+ return tie_t;
+ }
+
+ static void
+ Field_imm12b_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xfff;
++ uint32 tie_t;
++ tie_t = (val << 20) >> 20;
+ insn[0] = (insn[0] & ~0xfff0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm16_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xffff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 16) | ((insn[0] << 8) >> 16);
+ return tie_t;
+ }
+
+ static void
+ Field_imm16_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xffff;
++ uint32 tie_t;
++ tie_t = (val << 16) >> 16;
+ insn[0] = (insn[0] & ~0xffff00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_imm16_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xffff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 16) | ((insn[0] << 12) >> 16);
+ return tie_t;
+ }
+
+ static void
+ Field_imm16_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xffff;
++ uint32 tie_t;
++ tie_t = (val << 16) >> 16;
+ insn[0] = (insn[0] & ~0xffff0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_m_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 24) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_m_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc0) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_m_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 2) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 28) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_m_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc) | (tie_t << 2);
+ }
+
+ static unsigned
+ Field_n_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 26) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_n_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x30) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_n_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 30) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_n_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x3) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_offset_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 0x3ffff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 18) | ((insn[0] << 8) >> 14);
+ return tie_t;
+ }
+
+ static void
+ Field_offset_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x3ffff;
++ uint32 tie_t;
++ tie_t = (val << 14) >> 14;
+ insn[0] = (insn[0] & ~0xffffc0) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_offset_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0x3ffff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 18) | ((insn[0] << 14) >> 14);
+ return tie_t;
+ }
+
+ static void
+ Field_offset_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x3ffff;
++ uint32 tie_t;
++ tie_t = (val << 14) >> 14;
+ insn[0] = (insn[0] & ~0x3ffff) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_op0_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_op0_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_op0_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_op1_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 12) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op1_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_op1_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op1_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_op2_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 20) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 8) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op2_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00000) | (tie_t << 20);
+ }
+
+ static unsigned
+ Field_op2_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 12) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op2_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_op2_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op2_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_r_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_r_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_r_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_r_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_r_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_r_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_r_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_r_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_r_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_r_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_r_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_r_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_r_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_r_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_sa4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 20) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 11) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_sa4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x100000) | (tie_t << 20);
+ }
+
+ static unsigned
+ Field_sae4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 15) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_sae4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x10000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_sae4_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] << 12) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_sae4_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_sae_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 8) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 15) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sae_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x10000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_sae_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sae_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_sae_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x1f;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 5) | ((insn[0] << 15) >> 27);
+ return tie_t;
+ }
+
+ static void
+ Field_sae_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x1f;
++ uint32 tie_t;
++ tie_t = (val << 27) >> 27;
+ insn[0] = (insn[0] & ~0x1f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_sal_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 20) & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 11) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sal_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x100000) | (tie_t << 20);
+ }
+
+ static unsigned
+ Field_sal_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 1;
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 15) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sal_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x10000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_sal_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sal_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_sargt_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 20) & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 8) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 11) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sargt_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x100000) | (tie_t << 20);
+ }
+
+ static unsigned
+ Field_sargt_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 15) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sargt_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x10000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_sargt_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0x1f;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 5) | ((insn[0] << 19) >> 27);
+ return tie_t;
+ }
+
+ static void
+ Field_sargt_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x1f;
++ uint32 tie_t;
++ tie_t = (val << 27) >> 27;
+ insn[0] = (insn[0] & ~0x1f00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_sargt_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0x1f;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 5) | ((insn[0] << 19) >> 27);
+ return tie_t;
+ }
+
+ static void
+ Field_sargt_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x1f;
++ uint32 tie_t;
++ tie_t = (val << 27) >> 27;
+ insn[0] = (insn[0] & ~0x1f00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_sas4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 27) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_sas4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x10) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_sas_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 8) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 27) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sas_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x10) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_sas_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 1;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 31) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sas_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x1) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_sr_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 8) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sr_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_sr_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 8) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sr_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_sr_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 8) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_sr_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_st_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_st_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_st_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_st_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_st_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 4) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 24) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_st_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf0) | (tie_t << 4);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_thi3_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 5) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 24) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_thi3_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe0) | (tie_t << 5);
+ }
+
+ static unsigned
+ Field_thi3_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 1) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 28) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_thi3_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe) | (tie_t << 1);
+ }
+
+ static unsigned
+ Field_imm4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm4_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm4_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm4_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm4_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_mn_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 3;
+- tie_t = (tie_t << 2) | ((insn[0] >> 4) & 3);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 24) >> 30);
++ tie_t = (tie_t << 2) | ((insn[0] << 26) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_mn_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x30) | (tie_t << 4);
+- tie_t = (val >> 2) & 3;
++ tie_t = (val << 28) >> 30;
+ insn[0] = (insn[0] & ~0xc0) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_i_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_i_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_i_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_i_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_imm6lo_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm6lo_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm6lo_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm6lo_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm6hi_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 26) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_imm6hi_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x30) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm6hi_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 26) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_imm6hi_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x30) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm7lo_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm7lo_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm7lo_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm7lo_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_imm7hi_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 25) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_imm7hi_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x70) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm7hi_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 25) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_imm7hi_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x70) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_z_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 25) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_z_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x40) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_z_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 25) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_z_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x40) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_imm6_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 3;
+- tie_t = (tie_t << 4) | ((insn[0] >> 12) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 26) >> 30);
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm6_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+- tie_t = (val >> 4) & 3;
++ tie_t = (val << 26) >> 30;
+ insn[0] = (insn[0] & ~0x30) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm6_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 3;
+- tie_t = (tie_t << 4) | ((insn[0] >> 12) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 26) >> 30);
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm6_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+- tie_t = (val >> 4) & 3;
++ tie_t = (val << 26) >> 30;
+ insn[0] = (insn[0] & ~0x30) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm7_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 7;
+- tie_t = (tie_t << 4) | ((insn[0] >> 12) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 25) >> 29);
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm7_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+- tie_t = (val >> 4) & 7;
++ tie_t = (val << 25) >> 29;
+ insn[0] = (insn[0] & ~0x70) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm7_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 7;
+- tie_t = (tie_t << 4) | ((insn[0] >> 12) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 25) >> 29);
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_imm7_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+- tie_t = (val >> 4) & 7;
++ tie_t = (val << 25) >> 29;
+ insn[0] = (insn[0] & ~0x70) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_imm7_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[0] & 0x7f;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 7) | ((insn[0] << 25) >> 25);
+ return tie_t;
+ }
+
+@@ -1659,1641 +1842,1852 @@ static void
+ Field_imm7_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+ uint32 tie_t;
+- tie_t = val & 0x7f;
++ tie_t = (val << 25) >> 25;
+ insn[0] = (insn[0] & ~0x7f) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_r3_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 15) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 16) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_r3_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x8000) | (tie_t << 15);
+ }
+
+ static unsigned
+ Field_rbit2_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 14) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 17) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_rbit2_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000) | (tie_t << 14);
+ }
+
+ static unsigned
+ Field_rhi_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 14) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 16) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_rhi_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc000) | (tie_t << 14);
+ }
+
+ static unsigned
+ Field_t3_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_t3_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_tbit2_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 25) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_tbit2_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x40) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_tlo_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 4) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 26) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_tlo_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x30) | (tie_t << 4);
+ }
+
+ static unsigned
+ Field_w_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 18) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_w_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x3000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_y_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 25) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_y_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x40) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_x_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 14) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 17) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_x_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000) | (tie_t << 14);
+ }
+
+ static unsigned
+ Field_t2_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 5) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 24) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_t2_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe0) | (tie_t << 5);
+ }
+
+ static unsigned
+ Field_t2_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 5) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 24) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_t2_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe0) | (tie_t << 5);
+ }
+
+ static unsigned
+ Field_t2_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 5) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 24) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_t2_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe0) | (tie_t << 5);
+ }
+
+ static unsigned
+ Field_s2_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 9) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 20) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_s2_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe00) | (tie_t << 9);
+ }
+
+ static unsigned
+ Field_s2_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 9) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 20) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_s2_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe00) | (tie_t << 9);
+ }
+
+ static unsigned
+ Field_s2_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 9) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 20) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_s2_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe00) | (tie_t << 9);
+ }
+
+ static unsigned
+ Field_r2_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 13) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 16) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_r2_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe000) | (tie_t << 13);
+ }
+
+ static unsigned
+ Field_r2_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 13) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 16) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_r2_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe000) | (tie_t << 13);
+ }
+
+ static unsigned
+ Field_r2_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 13) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 16) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_r2_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe000) | (tie_t << 13);
+ }
+
+ static unsigned
+ Field_t4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 24) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_t4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc0) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_t4_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 24) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_t4_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc0) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_t4_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 24) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_t4_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc0) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_s4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 10) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 20) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_s4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc00) | (tie_t << 10);
+ }
+
+ static unsigned
+ Field_s4_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 10) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 20) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_s4_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc00) | (tie_t << 10);
+ }
+
+ static unsigned
+ Field_s4_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 10) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 20) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_s4_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc00) | (tie_t << 10);
+ }
+
+ static unsigned
+ Field_r4_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 14) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 16) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_r4_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc000) | (tie_t << 14);
+ }
+
+ static unsigned
+ Field_r4_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 14) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 16) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_r4_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc000) | (tie_t << 14);
+ }
+
+ static unsigned
+ Field_r4_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 14) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 16) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_r4_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc000) | (tie_t << 14);
+ }
+
+ static unsigned
+ Field_t8_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_t8_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_t8_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_t8_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_t8_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_t8_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_s8_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 11) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 20) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_s8_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x800) | (tie_t << 11);
+ }
+
+ static unsigned
+ Field_s8_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 11) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 20) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_s8_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x800) | (tie_t << 11);
+ }
+
+ static unsigned
+ Field_s8_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 11) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 20) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_s8_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x800) | (tie_t << 11);
+ }
+
+ static unsigned
+ Field_r8_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 15) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 16) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_r8_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x8000) | (tie_t << 15);
+ }
+
+ static unsigned
+ Field_r8_Slot_inst16a_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 15) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 16) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_r8_Slot_inst16a_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x8000) | (tie_t << 15);
+ }
+
+ static unsigned
+ Field_r8_Slot_inst16b_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 15) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 16) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_r8_Slot_inst16b_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x8000) | (tie_t << 15);
+ }
+
+ static unsigned
+ Field_xt_wbr15_imm_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 9) & 0x7fff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 15) | ((insn[0] << 8) >> 17);
+ return tie_t;
+ }
+
+ static void
+ Field_xt_wbr15_imm_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x7fff;
++ uint32 tie_t;
++ tie_t = (val << 17) >> 17;
+ insn[0] = (insn[0] & ~0xfffe00) | (tie_t << 9);
+ }
+
+ static unsigned
+ Field_xt_wbr18_imm_Slot_inst_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 6) & 0x3ffff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 18) | ((insn[0] << 8) >> 14);
+ return tie_t;
+ }
+
+ static void
+ Field_xt_wbr18_imm_Slot_inst_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x3ffff;
++ uint32 tie_t;
++ tie_t = (val << 14) >> 14;
+ insn[0] = (insn[0] & ~0xffffc0) | (tie_t << 6);
+ }
+
+ static unsigned
+ Field_xt_wbr18_imm_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0x3ffff;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 18) | ((insn[0] << 6) >> 14);
+ return tie_t;
+ }
+
+ static void
+ Field_xt_wbr18_imm_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x3ffff;
++ uint32 tie_t;
++ tie_t = (val << 14) >> 14;
+ insn[0] = (insn[0] & ~0x3ffff00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_op0_xt_flix64_slot0_s3_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 20) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 8) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_xt_flix64_slot0_s3_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00000) | (tie_t << 20);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld7_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 13) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 16) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld7_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe000) | (tie_t << 13);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld8_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 13) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 16) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld8_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe000) | (tie_t << 13);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld9_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 17) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 12) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld9_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe0000) | (tie_t << 17);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld11_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 17) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 12) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld11_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe0000) | (tie_t << 17);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld49xt_flix64_slot0_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 0xf;
+- tie_t = (tie_t << 4) | ((insn[0] >> 8) & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 12) >> 28);
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld49xt_flix64_slot0_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+- tie_t = (val >> 4) & 0xf;
++ tie_t = (val << 24) >> 28;
+ insn[0] = (insn[0] & ~0xf0000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_op0_s4_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 18) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 12) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_s4_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc0000) | (tie_t << 18);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld16_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 16) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld16_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld19xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 17) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 14) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld19xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x20000) | (tie_t << 17);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld20xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 16) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 14) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld20xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x30000) | (tie_t << 16);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld21xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 13) & 0x1f;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 5) | ((insn[0] << 14) >> 27);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld21xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x1f;
++ uint32 tie_t;
++ tie_t = (val << 27) >> 27;
+ insn[0] = (insn[0] & ~0x3e000) | (tie_t << 13);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld22xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld22xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x3f;
++ uint32 tie_t;
++ tie_t = (val << 26) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld23xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
+- tie_t = (tie_t << 3) | ((insn[0] >> 4) & 7);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
++ tie_t = (tie_t << 3) | ((insn[0] << 25) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld23xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x70) | (tie_t << 4);
+- tie_t = (val >> 3) & 0x3f;
++ tie_t = (val << 23) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld25xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
+- tie_t = (tie_t << 3) | ((insn[0] >> 4) & 7);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
++ tie_t = (tie_t << 3) | ((insn[0] << 25) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld25xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x70) | (tie_t << 4);
+- tie_t = (val >> 3) & 0x3f;
++ tie_t = (val << 23) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld26xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
+- tie_t = (tie_t << 2) | ((insn[0] >> 5) & 3);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
++ tie_t = (tie_t << 2) | ((insn[0] << 25) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld26xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x60) | (tie_t << 5);
+- tie_t = (val >> 2) & 0x3f;
++ tie_t = (val << 24) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld28xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
+- tie_t = (tie_t << 1) | ((insn[0] >> 6) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
++ tie_t = (tie_t << 1) | ((insn[0] << 25) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld28xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x40) | (tie_t << 6);
+- tie_t = (val >> 1) & 0x3f;
++ tie_t = (val << 25) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld30xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
+- tie_t = (tie_t << 2) | ((insn[0] >> 8) & 3);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
++ tie_t = (tie_t << 2) | ((insn[0] << 22) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld30xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x300) | (tie_t << 8);
+- tie_t = (val >> 2) & 0x3f;
++ tie_t = (val << 24) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld32xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
+- tie_t = (tie_t << 2) | ((insn[0] >> 8) & 3);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
++ tie_t = (tie_t << 2) | ((insn[0] << 22) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld32xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x300) | (tie_t << 8);
+- tie_t = (val >> 2) & 0x3f;
++ tie_t = (val << 24) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld33xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 0x3f;
+- tie_t = (tie_t << 1) | ((insn[0] >> 9) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 6) | ((insn[0] << 14) >> 26);
++ tie_t = (tie_t << 1) | ((insn[0] << 22) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld33xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x200) | (tie_t << 9);
+- tie_t = (val >> 1) & 0x3f;
++ tie_t = (val << 25) >> 26;
+ insn[0] = (insn[0] & ~0x3f000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld35xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 15) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 14) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld35xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x38000) | (tie_t << 15);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld51xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld51xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld52xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld52xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld53xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 10) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 20) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld53xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0xc00) | (tie_t << 10);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld54xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 0x1f;
+- tie_t = (tie_t << 6) | (insn[0] & 0x3f);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 5) | ((insn[0] << 20) >> 27);
++ tie_t = (tie_t << 6) | ((insn[0] << 26) >> 26);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld54xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x3f;
++ uint32 tie_t;
++ tie_t = (val << 26) >> 26;
+ insn[0] = (insn[0] & ~0x3f) | (tie_t << 0);
+- tie_t = (val >> 6) & 0x1f;
++ tie_t = (val << 21) >> 27;
+ insn[0] = (insn[0] & ~0xf80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld57xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld57xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld58xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 10) & 3;
+- tie_t = (tie_t << 1) | ((insn[0] >> 8) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 20) >> 30);
++ tie_t = (tie_t << 1) | ((insn[0] << 23) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld58xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x100) | (tie_t << 8);
+- tie_t = (val >> 1) & 3;
++ tie_t = (val << 29) >> 30;
+ insn[0] = (insn[0] & ~0xc00) | (tie_t << 10);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld60xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 7) & 1;
+- tie_t = (tie_t << 5) | (insn[0] & 0x1f);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
++ tie_t = (tie_t << 5) | ((insn[0] << 27) >> 27);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld60xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x1f;
++ uint32 tie_t;
++ tie_t = (val << 27) >> 27;
+ insn[0] = (insn[0] & ~0x1f) | (tie_t << 0);
+- tie_t = (val >> 5) & 1;
++ tie_t = (val << 26) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld62xt_flix64_slot1_Slot_xt_flix64_slot1_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 17) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld62xt_flix64_slot1_Slot_xt_flix64_slot1_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x7000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_op0_s5_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 13) & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[0] << 16) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_s5_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0xe000) | (tie_t << 13);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld36xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld36xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld37xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 1) | ((insn[0] >> 7) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld37xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+- tie_t = (val >> 1) & 1;
++ tie_t = (val << 30) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld39xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 1) | ((insn[0] >> 7) & 1);
+- tie_t = (tie_t << 1) | ((insn[0] >> 4) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
++ tie_t = (tie_t << 1) | ((insn[0] << 27) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld39xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x10) | (tie_t << 4);
+- tie_t = (val >> 1) & 1;
++ tie_t = (val << 30) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+- tie_t = (val >> 2) & 1;
++ tie_t = (val << 29) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld41xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 1) | ((insn[0] >> 7) & 1);
+- tie_t = (tie_t << 1) | ((insn[0] >> 4) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 1) | ((insn[0] << 24) >> 31);
++ tie_t = (tie_t << 1) | ((insn[0] << 27) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld41xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x10) | (tie_t << 4);
+- tie_t = (val >> 1) & 1;
++ tie_t = (val << 30) >> 31;
+ insn[0] = (insn[0] & ~0x80) | (tie_t << 7);
+- tie_t = (val >> 2) & 1;
++ tie_t = (val << 29) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld42xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 3) | ((insn[0] >> 8) & 7);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 3) | ((insn[0] << 21) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld42xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x700) | (tie_t << 8);
+- tie_t = (val >> 3) & 1;
++ tie_t = (val << 28) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld44xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 3) | ((insn[0] >> 8) & 7);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 3) | ((insn[0] << 21) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld44xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[0] = (insn[0] & ~0x700) | (tie_t << 8);
+- tie_t = (val >> 3) & 1;
++ tie_t = (val << 28) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld45xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 2) | ((insn[0] >> 9) & 3);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 2) | ((insn[0] << 21) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld45xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x600) | (tie_t << 9);
+- tie_t = (val >> 2) & 1;
++ tie_t = (val << 29) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld47xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 12) & 1;
+- tie_t = (tie_t << 1) | ((insn[0] >> 10) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 19) >> 31);
++ tie_t = (tie_t << 1) | ((insn[0] << 21) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld47xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x400) | (tie_t << 10);
+- tie_t = (val >> 1) & 1;
++ tie_t = (val << 30) >> 31;
+ insn[0] = (insn[0] & ~0x1000) | (tie_t << 12);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld63xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 5) & 3;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 2) | ((insn[0] << 25) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld63xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x60) | (tie_t << 5);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld64xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 11) & 1;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 20) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld64xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x800) | (tie_t << 11);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld65xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 8) & 0xf;
+- tie_t = (tie_t << 2) | ((insn[0] >> 5) & 3);
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 20) >> 28);
++ tie_t = (tie_t << 2) | ((insn[0] << 25) >> 30);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld65xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 3;
++ tie_t = (val << 26) >> 30;
+ insn[0] = (insn[0] & ~0x60) | (tie_t << 5);
+- tie_t = (val >> 6) & 0xf;
++ tie_t = (val << 22) >> 28;
+ insn[0] = (insn[0] & ~0xf00) | (tie_t << 8);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld66xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 11) & 1;
+- tie_t = (tie_t << 1) | ((insn[0] >> 8) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 20) >> 31);
++ tie_t = (tie_t << 1) | ((insn[0] << 23) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld66xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x100) | (tie_t << 8);
+- tie_t = (val >> 1) & 1;
++ tie_t = (val << 30) >> 31;
+ insn[0] = (insn[0] & ~0x800) | (tie_t << 11);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld68xt_flix64_slot2_Slot_xt_flix64_slot2_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 11) & 1;
+- tie_t = (tie_t << 2) | ((insn[0] >> 8) & 3);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 1) | ((insn[0] << 20) >> 31);
++ tie_t = (tie_t << 2) | ((insn[0] << 22) >> 30);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld68xt_flix64_slot2_Slot_xt_flix64_slot2_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 3;
++ uint32 tie_t;
++ tie_t = (val << 30) >> 30;
+ insn[0] = (insn[0] & ~0x300) | (tie_t << 8);
+- tie_t = (val >> 2) & 1;
++ tie_t = (val << 29) >> 31;
+ insn[0] = (insn[0] & ~0x800) | (tie_t << 11);
+ }
+
+ static unsigned
+ Field_op0_s6_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 27) & 0x1f;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 5) | ((insn[0] << 0) >> 27);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_s6_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0x1f;
++ uint32 tie_t;
++ tie_t = (val << 27) >> 27;
+ insn[0] = (insn[0] & ~0xf8000000) | (tie_t << 27);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld70xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld70xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 5) & 7;
++ tie_t = (val << 24) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld71_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld71_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 7;
++ uint32 tie_t;
++ tie_t = (val << 29) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld72xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld72xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 5) & 7;
++ tie_t = (val << 24) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld73xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld73xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 5) & 7;
++ tie_t = (val << 24) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld74xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
+- tie_t = (tie_t << 4) | (insn[0] & 0xf);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
++ tie_t = (tie_t << 4) | ((insn[0] << 28) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld74xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf) | (tie_t << 0);
+- tie_t = (val >> 4) & 1;
++ tie_t = (val << 27) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 5) & 7;
++ tie_t = (val << 24) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld75xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld75xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld76xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld76xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld77xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld77xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld78xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld78xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld79xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld79xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld80xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld80xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld81xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld81xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld82xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld82xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld83xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld83xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld84xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld84xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld85xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld85xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld86xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld86xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld87xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld87xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld88xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld88xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld89xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld89xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld90xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld90xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld91xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld91xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld92xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 1) | ((insn[0] >> 26) & 1);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 1) | ((insn[0] << 5) >> 31);
+ return tie_t;
+ }
+
+ static void
+ Field_combined3e2c5767_fld92xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 1;
++ uint32 tie_t;
++ tie_t = (val << 31) >> 31;
+ insn[0] = (insn[0] & ~0x4000000) | (tie_t << 26);
+- tie_t = (val >> 1) & 7;
++ tie_t = (val << 28) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_combined3e2c5767_fld93xt_flix64_slot3_Slot_xt_flix64_slot3_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = insn[1] & 7;
+- tie_t = (tie_t << 27) | (insn[0] & 0x7ffffff);
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 3) | ((insn[1] << 29) >> 29);
++ tie_t = (tie_t << 27) | ((insn[0] << 5) >> 5);
+ return tie_t;
+ }
+
+@@ -3301,23 +3695,25 @@ static void
+ Field_combined3e2c5767_fld93xt_flix64_slot3_Slot_xt_flix64_slot3_set (xtensa_insnbuf insn, uint32 val)
+ {
+ uint32 tie_t;
+- tie_t = val & 0x7ffffff;
++ tie_t = (val << 5) >> 5;
+ insn[0] = (insn[0] & ~0x7ffffff) | (tie_t << 0);
+- tie_t = (val >> 27) & 7;
++ tie_t = (val << 2) >> 29;
+ insn[1] = (insn[1] & ~0x7) | (tie_t << 0);
+ }
+
+ static unsigned
+ Field_op0_xt_flix64_slot0_Slot_xt_flix64_slot0_get (const xtensa_insnbuf insn)
+ {
+- unsigned tie_t = (insn[0] >> 20) & 0xf;
++ unsigned tie_t = 0;
++ tie_t = (tie_t << 4) | ((insn[0] << 8) >> 28);
+ return tie_t;
+ }
+
+ static void
+ Field_op0_xt_flix64_slot0_Slot_xt_flix64_slot0_set (xtensa_insnbuf insn, uint32 val)
+ {
+- uint32 tie_t = val & 0xf;
++ uint32 tie_t;
++ tie_t = (val << 28) >> 28;
+ insn[0] = (insn[0] & ~0xf00000) | (tie_t << 20);
+ }
+
+@@ -3502,7 +3898,7 @@ Operand_soffsetx4_decode (uint32 *valp)
+ {
+ unsigned soffsetx4_0, offset_0;
+ offset_0 = *valp & 0x3ffff;
+- soffsetx4_0 = 0x4 + (((offset_0 ^ 0x20000) - 0x20000) << 2);
++ soffsetx4_0 = 0x4 + ((((int) offset_0 << 14) >> 14) << 2);
+ *valp = soffsetx4_0;
+ return 0;
+ }
+@@ -3556,7 +3952,7 @@ Operand_simm4_decode (uint32 *valp)
+ {
+ unsigned simm4_0, mn_0;
+ mn_0 = *valp & 0xf;
+- simm4_0 = (mn_0 ^ 0x8) - 0x8;
++ simm4_0 = ((int) mn_0 << 28) >> 28;
+ *valp = simm4_0;
+ return 0;
+ }
+@@ -3688,7 +4084,7 @@ Operand_immrx4_decode (uint32 *valp)
+ {
+ unsigned immrx4_0, r_0;
+ r_0 = *valp & 0xf;
+- immrx4_0 = (0xfffffff0 | r_0) << 2;
++ immrx4_0 = (((0xfffffff) << 4) | r_0) << 2;
+ *valp = immrx4_0;
+ return 0;
+ }
+@@ -3976,7 +4372,7 @@ Operand_simm8_decode (uint32 *valp)
+ {
+ unsigned simm8_0, imm8_0;
+ imm8_0 = *valp & 0xff;
+- simm8_0 = (imm8_0 ^ 0x80) - 0x80;
++ simm8_0 = ((int) imm8_0 << 24) >> 24;
+ *valp = simm8_0;
+ return 0;
+ }
+@@ -3996,7 +4392,7 @@ Operand_simm8x256_decode (uint32 *valp)
+ {
+ unsigned simm8x256_0, imm8_0;
+ imm8_0 = *valp & 0xff;
+- simm8x256_0 = ((imm8_0 ^ 0x80) - 0x80) << 8;
++ simm8x256_0 = (((int) imm8_0 << 24) >> 24) << 8;
+ *valp = simm8x256_0;
+ return 0;
+ }
+@@ -4016,7 +4412,7 @@ Operand_simm12b_decode (uint32 *valp)
+ {
+ unsigned simm12b_0, imm12b_0;
+ imm12b_0 = *valp & 0xfff;
+- simm12b_0 = (imm12b_0 ^ 0x800) - 0x800;
++ simm12b_0 = ((int) imm12b_0 << 20) >> 20;
+ *valp = simm12b_0;
+ return 0;
+ }
+@@ -4076,7 +4472,7 @@ Operand_label8_decode (uint32 *valp)
+ {
+ unsigned label8_0, imm8_0;
+ imm8_0 = *valp & 0xff;
+- label8_0 = 0x4 + ((imm8_0 ^ 0x80) - 0x80);
++ label8_0 = 0x4 + (((int) imm8_0 << 24) >> 24);
+ *valp = label8_0;
+ return 0;
+ }
+@@ -4144,7 +4540,7 @@ Operand_label12_decode (uint32 *valp)
+ {
+ unsigned label12_0, imm12_0;
+ imm12_0 = *valp & 0xfff;
+- label12_0 = 0x4 + ((imm12_0 ^ 0x800) - 0x800);
++ label12_0 = 0x4 + (((int) imm12_0 << 20) >> 20);
+ *valp = label12_0;
+ return 0;
+ }
+@@ -4178,7 +4574,7 @@ Operand_soffset_decode (uint32 *valp)
+ {
+ unsigned soffset_0, offset_0;
+ offset_0 = *valp & 0x3ffff;
+- soffset_0 = 0x4 + ((offset_0 ^ 0x20000) - 0x20000);
++ soffset_0 = 0x4 + (((int) offset_0 << 14) >> 14);
+ *valp = soffset_0;
+ return 0;
+ }
+@@ -4212,7 +4608,7 @@ Operand_uimm16x4_decode (uint32 *valp)
+ {
+ unsigned uimm16x4_0, imm16_0;
+ imm16_0 = *valp & 0xffff;
+- uimm16x4_0 = (0xffff0000 | imm16_0) << 2;
++ uimm16x4_0 = (((0xffff) << 16) | imm16_0) << 2;
+ *valp = uimm16x4_0;
+ return 0;
+ }
+@@ -4656,7 +5052,7 @@ Operand_xt_wbr15_label_decode (uint32 *valp)
+ {
+ unsigned xt_wbr15_label_0, xt_wbr15_imm_0;
+ xt_wbr15_imm_0 = *valp & 0x7fff;
+- xt_wbr15_label_0 = 0x4 + ((xt_wbr15_imm_0 ^ 0x4000) - 0x4000);
++ xt_wbr15_label_0 = 0x4 + (((int) xt_wbr15_imm_0 << 17) >> 17);
+ *valp = xt_wbr15_label_0;
+ return 0;
+ }
+@@ -4690,7 +5086,7 @@ Operand_xt_wbr18_label_decode (uint32 *valp)
+ {
+ unsigned xt_wbr18_label_0, xt_wbr18_imm_0;
+ xt_wbr18_imm_0 = *valp & 0x3ffff;
+- xt_wbr18_label_0 = 0x4 + ((xt_wbr18_imm_0 ^ 0x20000) - 0x20000);
++ xt_wbr18_label_0 = 0x4 + (((int) xt_wbr18_imm_0 << 14) >> 14);
+ *valp = xt_wbr18_label_0;
+ return 0;
+ }
+--
+2.20.1
+
#define ALLOCRAM_START ( ((unsigned int)&_fw_image_end) + 4)
#define ALLOCRAM_SIZE ( SYS_RAM_SZIE - ( ALLOCRAM_START - SYS_D_RAM_REGION_0_BASE) - SYS_D_RAM_STACK_SIZE)
+void (* _assfail_ori)(struct register_dump_s *);
+
// support for more than 64 bytes on command pipe
extern void usb_reg_out_patch(void);
extern int _HIFusb_get_max_msg_len_patch(hif_handle_t handle, int pipe);
void AR6002_fatal_exception_handler_patch(CPU_exception_frame_t *exc_frame);
void exception_reset(struct register_dump_s *dump);
-void (* _assfail_ori)(struct register_dump_s *);
+extern void (* _assfail_ori)(struct register_dump_s *);
void HTCMsgRecvHandler_patch(adf_nbuf_t hdr_buf, adf_nbuf_t buffer, void *context);
void HTCControlSvcProcessMsg_patch(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf,
adf_nbuf_t pBuffers, void *arg);
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
compile)
echo "Compile time..."
- make carl9170.elf
make
;;
set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS "${CARLFW_CFLAGS}")
set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds")
-add_custom_target(firmware ALL)
+add_custom_target(firmware ALL DEPENDS carl9170.elf)
add_custom_command(
DEPENDS carl9170.elf
COMMAND ${OBJCOPY}
ARGS --strip-unneeded -O binary -R .sram -R .eeprom -R .fwdsc carl9170.elf carl9170.bin
TARGET firmware
+ BYPRODUCTS carl9170.bin
OUTPUTS carl9170.bin)
add_custom_command(
COMMAND ${OBJCOPY}
ARGS --strip-unneeded -O binary -j .fwdsc carl9170.elf carl9170.dsc
TARGET firmware
+ BYPRODUCTS carl9170.dsc
OUTPUTS carl9170.dsc)
add_custom_command(
config CARL9170FW_GPIO_INTERRUPT
def_bool y
prompt "GPIO Software Interrupt"
- ---help---
+ help
When this option is enabled, the firmware will poll the GPIO
registers and reports to the driver whenever the GPIO state
has changed from a previous state.
config CARL9170FW_SECURITY_ENGINE
def_bool y
prompt "Support Hardware Crypto Engine"
- ---help---
+ help
This options controls if the firmware will allow the driver
to program the security engine / CAM through a firmware
interface.
config CARL9170FW_RADIO_FUNCTIONS
def_bool y
prompt "Enable Firmware-supported Radio/RF functions"
- ---help---
+ help
Some PHY/RF functions (e.g.: AGC and Noise calibration) need
to be done in the firmware.
def_bool y
prompt "Advanced printf"
depends on CARL9170FW_DEBUG_UART || CARL9170FW_DEBUG_USB
- ---help---
+ help
Advanced printf (very useful for debugging purposes)
The formats supported by this implementation are:
'd' 'u' 'c' 's' 'x' 'X' 'p'.
def_bool n
prompt "Wakeup on WLAN"
depends on CARL9170FW_EXPERIMENTAL
- ---help---
+ help
With this option enabled, the firmware can wake-up
suspended hosts... As long as they fully support
USB remote wakeup.
prompt "Standard NL80211 wakeup triggers"
depends on CARL9170FW_WOL_OPTION
select CARL9170FW_WOL
- ---help---
+ help
Available triggers:
* Magic Packet(tm) pattern
* disconnect event
prompt "Probe Request"
depends on CARL9170FW_WOL_OPTION
select CARL9170FW_WOL
- ---help---
+ help
Scan probe requests for a given SSID.
config CARL9170FW_WOL_PROBE_REQUEST_SSID
def_bool n
prompt "Allow 80/88MHz clock for HT40"
depends on CARL9170FW_EXPERIMENTAL
- ---help---
+ help
The SoC can run up to 80/88MHz in HT40 mode. This improves
throughput and timing accuracy over the 40/44MHz clock.
However some devices don't have heat shields and they with
def_bool n
prompt "LED Heartbeat"
depends on CARL9170FW_BROKEN_FEATURES
- ---help---
+ help
This option conflicts with the application's LED code.
Also, it assumes that you have two LEDs, which is not
necessarily true.
def_bool n
prompt "Pass debug messages through Highspeed UART"
depends on CARL9170FW_BROKEN_FEATURES
- ---help---
+ help
This option allows the firmware to send BUG/ERR/INFO/DBG and
hexdumps through the UART _as well_. However, first: you must
connect a working logger.
def_bool n
prompt "USB 1.1 / 2.0 switching support"
depends on CARL9170FW_BROKEN_FEATURES && CARL9170FW_USB_STANDARD_CMDS
- ---help---
+ help
Mostly implemented, but untested and some serious
doubts remain.
config CARL9170FW_AGGRESSIVE_CFLAGS
def_bool y
prompt "Enable aggressive size optimization"
- ---help---
+ help
This option adds several more optimization compiler flags,
which can greatly reduce the firmware size... at the expense
of machine-code readability.
config CARL9170FW_USB_STANDARD_CMDS
def_bool y
prompt "Basic USB Interface"
- ---help---
+ help
Allows the device to be queried about Standard USB 2.0 Device
Description Descriptors.
config CARL9170FW_USB_UP_STREAM
def_bool y
prompt "USB Upload Stream"
- ---help---
+ help
This features allows the USB silicon to combine small, single
frames into bigger transfers. This can help to reduce
some per-transfer overhead in the application.
config CARL9170FW_DEBUG_USB
def_bool y
prompt "Pass debug messages through USB transport"
- ---help---
+ help
Report all firmware messages through the USB transport.
But there is a catch: In case of a BUG, the USB transport
needs to be functional, otherwise the application won't
-zconf.hash.c
-zconf.tab.c
+# SPDX-License-Identifier: GPL-2.0-only
conf
-lex.backup
-zconf.lex.c
-zconf.tab.h
-
+parser.tab.c
+parser.tab.h
+lexer.lex.c
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../include/generated")
-BISON_TARGET(zconf zconf.y zconf.tab.c COMPILE_FLAGS "-l -b zconf -p yy -t")
-FLEX_TARGET(zconfscan zconf.l zconf.lex.c COMPILE_FLAGS "-Pyy -L")
+BISON_TARGET(parser parser.y parser.tab.c COMPILE_FLAGS "-l -b parser -p yy -t")
+FLEX_TARGET(lexer lexer.l lexer.lex.c COMPILE_FLAGS "-Pyy -L")
-SET(zconf_deps ${FLEX_zconfscan_OUTPUTS})
-SET_SOURCE_FILES_PROPERTIES(${BISON_zconf_OUTPUTS}
- PROPERTIES OBJECT_DEPENDS "${zconf_deps}")
+SET(parser_deps ${FLEX_lexer_OUTPUTS})
+SET_SOURCE_FILES_PROPERTIES(${BISON_parser_OUTPUTS}
+ PROPERTIES OBJECT_DEPENDS "${parser_deps}")
-set(conf_src conf.c symbol.c confdata.c expr.c preprocess.c ${BISON_zconf_OUTPUTS} ${FLEX_zconfscan_OUTPUTS})
+set(conf_src conf.c util.c symbol.c confdata.c expr.c preprocess.c ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS})
add_executable(conf ${conf_src})
#include <time.h>
#include <unistd.h>
#include <getopt.h>
-#include <sys/stat.h>
#include <sys/time.h>
#include <errno.h>
defconfig,
savedefconfig,
listnewconfig,
+ helpnewconfig,
olddefconfig,
+ yes2modconfig,
+ mod2yesconfig,
};
static enum input_mode input_mode = oldaskconfig;
line[0] = '\n';
line[1] = 0;
- if (!sym_is_changable(sym)) {
+ if (!sym_is_changeable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
sym = menu->sym;
is_new = !sym_has_value(sym);
- if (sym_is_changable(sym)) {
+ if (sym_is_changeable(sym)) {
conf_sym(menu);
sym_calc_value(sym);
switch (sym_get_tristate_value(sym)) {
sym = menu->sym;
if (sym && !sym_has_value(sym)) {
- if (sym_is_changable(sym) ||
+ if (sym_is_changeable(sym) ||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
if (input_mode == listnewconfig) {
if (sym->name) {
printf("%s%s=%s\n", CONFIG_, sym->name, str);
}
}
+ } else if (input_mode == helpnewconfig) {
+ printf("-----\n");
+ print_help(menu);
+ printf("-----\n");
+
} else {
if (!conf_cnt++)
printf("*\n* Restart config...\n*\n");
{"oldaskconfig", no_argument, NULL, oldaskconfig},
{"oldconfig", no_argument, NULL, oldconfig},
{"syncconfig", no_argument, NULL, syncconfig},
- {"defconfig", optional_argument, NULL, defconfig},
+ {"defconfig", required_argument, NULL, defconfig},
{"savedefconfig", required_argument, NULL, savedefconfig},
{"allnoconfig", no_argument, NULL, allnoconfig},
{"allyesconfig", no_argument, NULL, allyesconfig},
{"alldefconfig", no_argument, NULL, alldefconfig},
{"randconfig", no_argument, NULL, randconfig},
{"listnewconfig", no_argument, NULL, listnewconfig},
+ {"helpnewconfig", no_argument, NULL, helpnewconfig},
{"olddefconfig", no_argument, NULL, olddefconfig},
+ {"yes2modconfig", no_argument, NULL, yes2modconfig},
+ {"mod2yesconfig", no_argument, NULL, mod2yesconfig},
{NULL, 0, NULL, 0}
};
printf("Usage: %s [-s] [option] <kconfig-file>\n", progname);
printf("[option] is _one_ of the following:\n");
printf(" --listnewconfig List new options\n");
+ printf(" --helpnewconfig List new options and help text\n");
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
printf(" --oldconfig Update a configuration using a provided .config as base\n");
printf(" --syncconfig Similar to oldconfig but generates configuration in\n"
printf(" --allmodconfig New config where all options are answered with mod\n");
printf(" --alldefconfig New config with all symbols set to default\n");
printf(" --randconfig New config with random answer to all options\n");
+ printf(" --yes2modconfig Change answers from yes to mod if possible\n");
+ printf(" --mod2yesconfig Change answers from mod to yes if possible\n");
}
int main(int ac, char **av)
const char *progname = av[0];
int opt;
const char *name, *defconfig_file = NULL /* gcc uninit */;
- struct stat tmpstat;
int no_conf_write = 0;
tty_stdio = isatty(0) && isatty(1);
case allmodconfig:
case alldefconfig:
case listnewconfig:
+ case helpnewconfig:
case olddefconfig:
+ case yes2modconfig:
+ case mod2yesconfig:
break;
case '?':
conf_usage(progname);
name = av[optind];
conf_parse(name);
//zconfdump(stdout);
- if (sync_kconfig) {
- name = conf_get_configname();
- if (stat(name, &tmpstat)) {
- fprintf(stderr, "***\n"
- "*** Configuration file \"%s\" not found!\n"
- "***\n"
- "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
- "*** \"make menuconfig\" or \"make xconfig\").\n"
- "***\n", name);
- exit(1);
- }
- }
switch (input_mode) {
case defconfig:
- if (!defconfig_file)
- defconfig_file = conf_get_default_confname();
if (conf_read(defconfig_file)) {
fprintf(stderr,
"***\n"
case oldaskconfig:
case oldconfig:
case listnewconfig:
+ case helpnewconfig:
case olddefconfig:
+ case yes2modconfig:
+ case mod2yesconfig:
conf_read(NULL);
break;
case allnoconfig:
break;
case savedefconfig:
break;
+ case yes2modconfig:
+ conf_rewrite_mod_or_yes(def_y2m);
+ break;
+ case mod2yesconfig:
+ conf_rewrite_mod_or_yes(def_m2y);
+ break;
case oldaskconfig:
rootEntry = &rootmenu;
conf(&rootmenu);
/* fall through */
case oldconfig:
case listnewconfig:
+ case helpnewconfig:
case syncconfig:
/* Update until a loop caused no more changes */
do {
defconfig_file);
return 1;
}
- } else if (input_mode != listnewconfig) {
+ } else if (input_mode != listnewconfig && input_mode != helpnewconfig) {
if (!no_conf_write && conf_write(NULL)) {
fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
exit(1);
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
*/
+#include <sys/mman.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
return S_ISDIR(st.st_mode);
}
+/* return true if the given two files are the same, false otherwise */
+static bool is_same(const char *file1, const char *file2)
+{
+ int fd1, fd2;
+ struct stat st1, st2;
+ void *map1, *map2;
+ bool ret = false;
+
+ fd1 = open(file1, O_RDONLY);
+ if (fd1 < 0)
+ return ret;
+
+ fd2 = open(file2, O_RDONLY);
+ if (fd2 < 0)
+ goto close1;
+
+ ret = fstat(fd1, &st1);
+ if (ret)
+ goto close2;
+ ret = fstat(fd2, &st2);
+ if (ret)
+ goto close2;
+
+ if (st1.st_size != st2.st_size)
+ goto close2;
+
+ map1 = mmap(NULL, st1.st_size, PROT_READ, MAP_PRIVATE, fd1, 0);
+ if (map1 == MAP_FAILED)
+ goto close2;
+
+ map2 = mmap(NULL, st2.st_size, PROT_READ, MAP_PRIVATE, fd2, 0);
+ if (map2 == MAP_FAILED)
+ goto close2;
+
+ if (bcmp(map1, map2, st1.st_size))
+ goto close2;
+
+ ret = true;
+close2:
+ close(fd2);
+close1:
+ close(fd1);
+
+ return ret;
+}
+
/*
* Create the parent directory of the given path.
*
static const char *conf_filename;
static int conf_lineno, conf_warnings;
-const char conf_defname[] = "include/generated/defconfig";
-
static void conf_warning(const char *fmt, ...)
{
va_list ap;
return name ? name : ".config";
}
-const char *conf_get_autoconfig_name(void)
+static const char *conf_get_autoconfig_name(void)
{
char *name = getenv("KCONFIG_AUTOCONFIG");
return name ? name : "include/generated/auto.conf";
}
-char *conf_get_default_confname(void)
-{
- static char fullname[PATH_MAX+1];
- char *env, *name;
-
- name = expand_string(conf_defname);
- env = getenv(SRCTREE);
- if (env) {
- sprintf(fullname, "%s/%s", env, name);
- if (is_present(fullname))
- return fullname;
- }
- return name;
-}
-
static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
{
char *p2;
switch (sym->type) {
case S_BOOLEAN:
case S_TRISTATE:
- if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
- break;
- if (!sym_is_choice(sym))
+ if (sym->def[S_DEF_USER].tri == sym_get_tristate_value(sym))
continue;
- /* fall through */
+ break;
default:
if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
continue;
.print_comment = header_print_comment,
};
-/*
- * Tristate printer
- *
- * This printer is used when generating the `include/generated/tristate.conf' file.
- */
-static void
-tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
-{
-
- if (sym->type == S_TRISTATE && *value != 'n')
- fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
-}
-
-static struct conf_printer tristate_printer_cb =
-{
- .print_symbol = tristate_print_symbol,
- .print_comment = kconfig_print_comment,
-};
-
static void conf_write_symbol(FILE *fp, struct symbol *sym,
struct conf_printer *printer, void *printer_arg)
{
goto next_menu;
sym->flags &= ~SYMBOL_WRITE;
/* If we cannot change the symbol - skip */
- if (!sym_is_changable(sym))
+ if (!sym_is_changeable(sym))
goto next_menu;
/* If symbol equals to default value - skip */
if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
FILE *out;
struct symbol *sym;
struct menu *menu;
- const char *basename;
const char *str;
- char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8];
+ char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
char *env;
+ int i;
+ bool need_newline = false;
+
+ if (!name)
+ name = conf_get_configname();
+
+ if (!*name) {
+ fprintf(stderr, "config name is empty\n");
+ return -1;
+ }
+
+ if (is_dir(name)) {
+ fprintf(stderr, "%s: Is a directory\n", name);
+ return -1;
+ }
+
+ if (make_parent_dir(name))
+ return -1;
- dirname[0] = 0;
- if (name && name[0]) {
- char *slash;
-
- if (is_dir(name)) {
- strcpy(dirname, name);
- strcat(dirname, "/");
- basename = conf_get_configname();
- } else if ((slash = strrchr(name, '/'))) {
- int size = slash - name + 1;
- memcpy(dirname, name, size);
- dirname[size] = 0;
- if (slash[1])
- basename = slash + 1;
- else
- basename = conf_get_configname();
- } else
- basename = name;
- } else
- basename = conf_get_configname();
-
- sprintf(newname, "%s%s", dirname, basename);
env = getenv("KCONFIG_OVERWRITECONFIG");
- if (!env || !*env) {
- sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
- out = fopen(tmpname, "w");
- } else {
+ if (env && *env) {
*tmpname = 0;
- out = fopen(newname, "w");
+ out = fopen(name, "w");
+ } else {
+ snprintf(tmpname, sizeof(tmpname), "%s.%d.tmp",
+ name, (int)getpid());
+ out = fopen(tmpname, "w");
}
if (!out)
return 1;
"#\n"
"# %s\n"
"#\n", str);
- } else if (!(sym->flags & SYMBOL_CHOICE)) {
+ need_newline = false;
+ } else if (!(sym->flags & SYMBOL_CHOICE) &&
+ !(sym->flags & SYMBOL_WRITTEN)) {
sym_calc_value(sym);
if (!(sym->flags & SYMBOL_WRITE))
goto next;
- sym->flags &= ~SYMBOL_WRITE;
-
+ if (need_newline) {
+ fprintf(out, "\n");
+ need_newline = false;
+ }
+ sym->flags |= SYMBOL_WRITTEN;
conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
}
if (menu->next)
menu = menu->next;
else while ((menu = menu->parent)) {
+ if (!menu->sym && menu_is_visible(menu) &&
+ menu != &rootmenu) {
+ str = menu_get_prompt(menu);
+ fprintf(out, "# end of %s\n", str);
+ need_newline = true;
+ }
if (menu->next) {
menu = menu->next;
break;
}
fclose(out);
+ for_all_symbols(i, sym)
+ sym->flags &= ~SYMBOL_WRITTEN;
+
if (*tmpname) {
- strcat(dirname, basename);
- strcat(dirname, ".old");
- rename(newname, dirname);
- if (rename(tmpname, newname))
+ if (is_same(name, tmpname)) {
+ conf_message("No change to %s", name);
+ unlink(tmpname);
+ sym_set_change_count(0);
+ return 0;
+ }
+
+ snprintf(oldname, sizeof(oldname), "%s.old", name);
+ rename(name, oldname);
+ if (rename(tmpname, name))
return 1;
}
- conf_message("configuration written to %s", newname);
+ conf_message("configuration written to %s", name);
sym_set_change_count(0);
struct file *file;
FILE *out;
- if (!name)
- name = ".kconfig.d";
out = fopen("..config.tmp", "w");
if (!out)
return 1;
struct symbol *sym;
const char *name;
const char *autoconf_name = conf_get_autoconfig_name();
- FILE *out, *tristate, *out_h, *out_c;
+ FILE *out, *out_h, *out_c;
int i;
if (!overwrite && is_present(autoconf_name))
return 0;
- sym_clear_all_valid();
-
conf_write_dep("include/generated/auto.conf.cmd");
if (conf_touch_deps())
if (!out)
return 1;
- tristate = fopen(".tmpconfig_tristate", "w");
- if (!tristate) {
- fclose(out);
- return 1;
- }
-
out_h = fopen(".tmpconfig.h", "w");
if (!out_h) {
fclose(out);
- fclose(tristate);
return 1;
}
out_c = fopen(".tmpconfig.cmake", "w");
if (!out_c) {
fclose(out);
- fclose(tristate);
fclose(out_h);
}
conf_write_heading(out, &kconfig_printer_cb, NULL);
- conf_write_heading(tristate, &tristate_printer_cb, NULL);
-
conf_write_heading(out_h, &header_printer_cb, NULL);
conf_write_heading(out_c, &kconfig_printer_cmake_cb, NULL);
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
continue;
- /* write symbol to auto.conf, tristate and header files */
+ /* write symbol to auto.conf and header files */
conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
- conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
-
conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
conf_write_symbol(out_c, sym, &kconfig_printer_cmake_cb, NULL);
}
fclose(out);
- fclose(tristate);
fclose(out_h);
fclose(out_c);
if (rename(".tmpconfig.h", name))
return 1;
- name = getenv("KCONFIG_TRISTATE");
- if (!name)
- name = "include/generated/tristate.conf";
- if (make_parent_dir(name))
- return 1;
- if (rename(".tmpconfig_tristate", name))
- return 1;
-
if (make_parent_dir(autoconf_name))
return 1;
sym_calc_value(csym);
if (mode == def_random)
- has_changed = randomize_choice_values(csym);
+ has_changed |= randomize_choice_values(csym);
else {
set_all_choice_values(csym);
has_changed = true;
return has_changed;
}
+
+void conf_rewrite_mod_or_yes(enum conf_def_mode mode)
+{
+ struct symbol *sym;
+ int i;
+ tristate old_val = (mode == def_y2m) ? yes : mod;
+ tristate new_val = (mode == def_y2m) ? mod : yes;
+
+ for_all_symbols(i, sym) {
+ if (sym_get_type(sym) == S_TRISTATE &&
+ sym->def[S_DEF_USER].tri == old_val)
+ sym->def[S_DEF_USER].tri = new_val;
+ }
+ sym_clear_all_valid();
+}
#define DEBUG_EXPR 0
-static int expr_eq(struct expr *e1, struct expr *e2);
static struct expr *expr_eliminate_yn(struct expr *e);
struct expr *expr_alloc_symbol(struct symbol *sym)
* equals some operand in the other (operands do not need to appear in the same
* order), recursively.
*/
-static int expr_eq(struct expr *e1, struct expr *e2)
+int expr_eq(struct expr *e1, struct expr *e2)
{
int res, old_count;
+ /*
+ * A NULL expr is taken to be yes, but there's also a different way to
+ * represent yes. expr_is_yes() checks for either representation.
+ */
+ if (!e1 || !e2)
+ return expr_is_yes(e1) && expr_is_yes(e2);
+
if (e1->type != e2->type)
return 0;
switch (e1->type) {
#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */
#define SYMBOL_CHANGED 0x0400 /* ? */
+#define SYMBOL_WRITTEN 0x0800 /* track info to avoid double-write to .config */
#define SYMBOL_NO_WRITE 0x1000 /* Symbol for internal use only; it will not be written */
#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
#define SYMBOL_WARNED 0x8000 /* warning has been issued */
* int "BAZ Value"
* range 1..255
*
- * Please, also check zconf.y:print_symbol() when modifying the
+ * Please, also check parser.y:print_symbol() when modifying the
* list of property types!
*/
enum prop_type {
struct property {
struct property *next; /* next property - null if last */
- struct symbol *sym; /* the symbol for which the property is associated */
enum prop_type type; /* type of property */
const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
struct expr_value visible;
struct expr *expr_copy(const struct expr *org);
void expr_free(struct expr *e);
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
+int expr_eq(struct expr *e1, struct expr *e2);
tristate expr_calc_value(struct expr *e);
struct expr *expr_trans_bool(struct expr *e);
struct expr *expr_eliminate_dups(struct expr *e);
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
+ */
+%option nostdinit noyywrap never-interactive full ecs
+%option 8bit nodefault yylineno
+%x ASSIGN_VAL HELP STRING
+%{
+
+#include <assert.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "lkc.h"
+#include "parser.tab.h"
+
+#define YY_DECL static int yylex1(void)
+
+#define START_STRSIZE 16
+
+static struct {
+ struct file *file;
+ int lineno;
+} current_pos;
+
+static int prev_prev_token = T_EOL;
+static int prev_token = T_EOL;
+static char *text;
+static int text_size, text_asize;
+
+struct buffer {
+ struct buffer *parent;
+ YY_BUFFER_STATE state;
+};
+
+static struct buffer *current_buf;
+
+static int last_ts, first_ts;
+
+static char *expand_token(const char *in, size_t n);
+static void append_expanded_string(const char *in);
+static void zconf_endhelp(void);
+static void zconf_endfile(void);
+
+static void new_string(void)
+{
+ text = xmalloc(START_STRSIZE);
+ text_asize = START_STRSIZE;
+ text_size = 0;
+ *text = 0;
+}
+
+static void append_string(const char *str, int size)
+{
+ int new_size = text_size + size + 1;
+ if (new_size > text_asize) {
+ new_size += START_STRSIZE - 1;
+ new_size &= -START_STRSIZE;
+ text = xrealloc(text, new_size);
+ text_asize = new_size;
+ }
+ memcpy(text + text_size, str, size);
+ text_size += size;
+ text[text_size] = 0;
+}
+
+static void alloc_string(const char *str, int size)
+{
+ text = xmalloc(size + 1);
+ memcpy(text, str, size);
+ text[size] = 0;
+}
+
+static void warn_ignored_character(char chr)
+{
+ fprintf(stderr,
+ "%s:%d:warning: ignoring unsupported character '%c'\n",
+ current_file->name, yylineno, chr);
+}
+%}
+
+n [A-Za-z0-9_-]
+
+%%
+ int str = 0;
+ int ts, i;
+
+#.* /* ignore comment */
+[ \t]* /* whitespaces */
+\\\n /* escaped new line */
+\n return T_EOL;
+"allnoconfig_y" return T_ALLNOCONFIG_Y;
+"bool" return T_BOOL;
+"choice" return T_CHOICE;
+"comment" return T_COMMENT;
+"config" return T_CONFIG;
+"def_bool" return T_DEF_BOOL;
+"def_tristate" return T_DEF_TRISTATE;
+"default" return T_DEFAULT;
+"defconfig_list" return T_DEFCONFIG_LIST;
+"depends" return T_DEPENDS;
+"endchoice" return T_ENDCHOICE;
+"endif" return T_ENDIF;
+"endmenu" return T_ENDMENU;
+"help" return T_HELP;
+"hex" return T_HEX;
+"if" return T_IF;
+"imply" return T_IMPLY;
+"int" return T_INT;
+"mainmenu" return T_MAINMENU;
+"menu" return T_MENU;
+"menuconfig" return T_MENUCONFIG;
+"modules" return T_MODULES;
+"on" return T_ON;
+"option" return T_OPTION;
+"optional" return T_OPTIONAL;
+"prompt" return T_PROMPT;
+"range" return T_RANGE;
+"select" return T_SELECT;
+"source" return T_SOURCE;
+"string" return T_STRING;
+"tristate" return T_TRISTATE;
+"visible" return T_VISIBLE;
+"||" return T_OR;
+"&&" return T_AND;
+"=" return T_EQUAL;
+"!=" return T_UNEQUAL;
+"<" return T_LESS;
+"<=" return T_LESS_EQUAL;
+">" return T_GREATER;
+">=" return T_GREATER_EQUAL;
+"!" return T_NOT;
+"(" return T_OPEN_PAREN;
+")" return T_CLOSE_PAREN;
+":=" return T_COLON_EQUAL;
+"+=" return T_PLUS_EQUAL;
+\"|\' {
+ str = yytext[0];
+ new_string();
+ BEGIN(STRING);
+ }
+{n}+ {
+ alloc_string(yytext, yyleng);
+ yylval.string = text;
+ return T_WORD;
+ }
+({n}|$)+ {
+ /* this token includes at least one '$' */
+ yylval.string = expand_token(yytext, yyleng);
+ if (strlen(yylval.string))
+ return T_WORD;
+ free(yylval.string);
+ }
+. warn_ignored_character(*yytext);
+
+<ASSIGN_VAL>{
+ [^[:blank:]\n]+.* {
+ alloc_string(yytext, yyleng);
+ yylval.string = text;
+ return T_ASSIGN_VAL;
+ }
+ \n { BEGIN(INITIAL); return T_EOL; }
+ .
+}
+
+<STRING>{
+ "$".* append_expanded_string(yytext);
+ [^$'"\\\n]+ {
+ append_string(yytext, yyleng);
+ }
+ \\.? {
+ append_string(yytext + 1, yyleng - 1);
+ }
+ \'|\" {
+ if (str == yytext[0]) {
+ BEGIN(INITIAL);
+ yylval.string = text;
+ return T_WORD_QUOTE;
+ } else
+ append_string(yytext, 1);
+ }
+ \n {
+ fprintf(stderr,
+ "%s:%d:warning: multi-line strings not supported\n",
+ zconf_curname(), zconf_lineno());
+ unput('\n');
+ BEGIN(INITIAL);
+ yylval.string = text;
+ return T_WORD_QUOTE;
+ }
+ <<EOF>> {
+ BEGIN(INITIAL);
+ yylval.string = text;
+ return T_WORD_QUOTE;
+ }
+}
+
+<HELP>{
+ [ \t]+ {
+ ts = 0;
+ for (i = 0; i < yyleng; i++) {
+ if (yytext[i] == '\t')
+ ts = (ts & ~7) + 8;
+ else
+ ts++;
+ }
+ last_ts = ts;
+ if (first_ts) {
+ if (ts < first_ts) {
+ zconf_endhelp();
+ return T_HELPTEXT;
+ }
+ ts -= first_ts;
+ while (ts > 8) {
+ append_string(" ", 8);
+ ts -= 8;
+ }
+ append_string(" ", ts);
+ }
+ }
+ [ \t]*\n/[^ \t\n] {
+ zconf_endhelp();
+ return T_HELPTEXT;
+ }
+ [ \t]*\n {
+ append_string("\n", 1);
+ }
+ [^ \t\n].* {
+ while (yyleng) {
+ if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t'))
+ break;
+ yyleng--;
+ }
+ append_string(yytext, yyleng);
+ if (!first_ts)
+ first_ts = last_ts;
+ }
+ <<EOF>> {
+ zconf_endhelp();
+ return T_HELPTEXT;
+ }
+}
+
+<<EOF>> {
+ BEGIN(INITIAL);
+
+ if (prev_token != T_EOL && prev_token != T_HELPTEXT)
+ fprintf(stderr, "%s:%d:warning: no new line at end of file\n",
+ current_file->name, yylineno);
+
+ if (current_file) {
+ zconf_endfile();
+ return T_EOL;
+ }
+ fclose(yyin);
+ yyterminate();
+}
+
+%%
+
+/* second stage lexer */
+int yylex(void)
+{
+ int token;
+
+repeat:
+ token = yylex1();
+
+ if (prev_token == T_EOL || prev_token == T_HELPTEXT) {
+ if (token == T_EOL) {
+ /* Do not pass unneeded T_EOL to the parser. */
+ goto repeat;
+ } else {
+ /*
+ * For the parser, update file/lineno at the first token
+ * of each statement. Generally, \n is a statement
+ * terminator in Kconfig, but it is not always true
+ * because \n could be escaped by a backslash.
+ */
+ current_pos.file = current_file;
+ current_pos.lineno = yylineno;
+ }
+ }
+
+ if (prev_prev_token == T_EOL && prev_token == T_WORD &&
+ (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL))
+ BEGIN(ASSIGN_VAL);
+
+ prev_prev_token = prev_token;
+ prev_token = token;
+
+ return token;
+}
+
+static char *expand_token(const char *in, size_t n)
+{
+ char *out;
+ int c;
+ char c2;
+ const char *rest, *end;
+
+ new_string();
+ append_string(in, n);
+
+ /* get the whole line because we do not know the end of token. */
+ while ((c = input()) != EOF) {
+ if (c == '\n') {
+ unput(c);
+ break;
+ }
+ c2 = c;
+ append_string(&c2, 1);
+ }
+
+ rest = text;
+ out = expand_one_token(&rest);
+
+ /* push back unused characters to the input stream */
+ end = rest + strlen(rest);
+ while (end > rest)
+ unput(*--end);
+
+ free(text);
+
+ return out;
+}
+
+static void append_expanded_string(const char *str)
+{
+ const char *end;
+ char *res;
+
+ str++;
+
+ res = expand_dollar(&str);
+
+ /* push back unused characters to the input stream */
+ end = str + strlen(str);
+ while (end > str)
+ unput(*--end);
+
+ append_string(res, strlen(res));
+
+ free(res);
+}
+
+void zconf_starthelp(void)
+{
+ new_string();
+ last_ts = first_ts = 0;
+ BEGIN(HELP);
+}
+
+static void zconf_endhelp(void)
+{
+ yylval.string = text;
+ BEGIN(INITIAL);
+}
+
+
+/*
+ * Try to open specified file with following names:
+ * ./name
+ * $(srctree)/name
+ * The latter is used when srctree is separate from objtree
+ * when compiling the firmware.
+ * Return NULL if file is not found.
+ */
+FILE *zconf_fopen(const char *name)
+{
+ char *env, fullname[PATH_MAX+1];
+ FILE *f;
+
+ f = fopen(name, "r");
+ if (!f && name != NULL && name[0] != '/') {
+ env = getenv(SRCTREE);
+ if (env) {
+ snprintf(fullname, sizeof(fullname),
+ "%s/%s", env, name);
+ f = fopen(fullname, "r");
+ }
+ }
+ return f;
+}
+
+void zconf_initscan(const char *name)
+{
+ yyin = zconf_fopen(name);
+ if (!yyin) {
+ fprintf(stderr, "can't find file %s\n", name);
+ exit(1);
+ }
+
+ current_buf = xmalloc(sizeof(*current_buf));
+ memset(current_buf, 0, sizeof(*current_buf));
+
+ current_file = file_lookup(name);
+ yylineno = 1;
+}
+
+void zconf_nextfile(const char *name)
+{
+ struct file *iter;
+ struct file *file = file_lookup(name);
+ struct buffer *buf = xmalloc(sizeof(*buf));
+ memset(buf, 0, sizeof(*buf));
+
+ current_buf->state = YY_CURRENT_BUFFER;
+ yyin = zconf_fopen(file->name);
+ if (!yyin) {
+ fprintf(stderr, "%s:%d: can't open file \"%s\"\n",
+ zconf_curname(), zconf_lineno(), file->name);
+ exit(1);
+ }
+ yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
+ buf->parent = current_buf;
+ current_buf = buf;
+
+ current_file->lineno = yylineno;
+ file->parent = current_file;
+
+ for (iter = current_file; iter; iter = iter->parent) {
+ if (!strcmp(iter->name, file->name)) {
+ fprintf(stderr,
+ "Recursive inclusion detected.\n"
+ "Inclusion path:\n"
+ " current file : %s\n", file->name);
+ iter = file;
+ do {
+ iter = iter->parent;
+ fprintf(stderr, " included from: %s:%d\n",
+ iter->name, iter->lineno - 1);
+ } while (strcmp(iter->name, file->name));
+ exit(1);
+ }
+ }
+
+ yylineno = 1;
+ current_file = file;
+}
+
+static void zconf_endfile(void)
+{
+ struct buffer *parent;
+
+ current_file = current_file->parent;
+ if (current_file)
+ yylineno = current_file->lineno;
+
+ parent = current_buf->parent;
+ if (parent) {
+ fclose(yyin);
+ yy_delete_buffer(YY_CURRENT_BUFFER);
+ yy_switch_to_buffer(parent->state);
+ }
+ free(current_buf);
+ current_buf = parent;
+}
+
+int zconf_lineno(void)
+{
+ return current_pos.lineno;
+}
+
+const char *zconf_curname(void)
+{
+ return current_pos.file ? current_pos.file->name : "<none>";
+}
#ifndef LKC_H
#define LKC_H
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include "expr.h"
#ifdef __cplusplus
def_default,
def_yes,
def_mod,
+ def_y2m,
+ def_m2y,
def_no,
def_random
};
/* confdata.c */
const char *conf_get_configname(void);
-const char *conf_get_autoconfig_name(void);
-char *conf_get_default_confname(void);
void sym_set_change_count(int count);
void sym_add_change_count(int count);
bool conf_set_all_new_symbols(enum conf_def_mode mode);
+void conf_rewrite_mod_or_yes(enum conf_def_mode mode);
void set_all_choice_values(struct symbol *csym);
/* confdata.c and expr.c */
fprintf(stderr, "Error in writing or end of file.\n");
}
-/* menu.c */
-void _menu_init(void);
-void menu_warn(struct menu *menu, const char *fmt, ...);
-struct menu *menu_add_menu(void);
-void menu_end_menu(void);
-void menu_add_entry(struct symbol *sym);
-void menu_add_dep(struct expr *dep);
-void menu_add_visibility(struct expr *dep);
-struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
-void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
-void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
-void menu_add_option_modules(void);
-void menu_add_option_defconfig_list(void);
-void menu_add_option_allnoconfig_y(void);
-void menu_finalize(struct menu *parent);
-void menu_set_type(int type);
-
/* util.c */
struct file *file_lookup(const char *name);
void *xmalloc(size_t size);
char *xstrdup(const char *s);
char *xstrndup(const char *s, size_t n);
-/* zconf.l */
+/* lexer.l */
int yylex(void);
struct gstr {
void str_printf(struct gstr *gs, const char *fmt, ...);
const char *str_get(struct gstr *gs);
+/* menu.c */
+void _menu_init(void);
+void menu_warn(struct menu *menu, const char *fmt, ...);
+struct menu *menu_add_menu(void);
+void menu_end_menu(void);
+void menu_add_entry(struct symbol *sym);
+void menu_add_dep(struct expr *dep);
+void menu_add_visibility(struct expr *dep);
+struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
+void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
+void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
+void menu_add_option_modules(void);
+void menu_add_option_defconfig_list(void);
+void menu_add_option_allnoconfig_y(void);
+void menu_finalize(struct menu *parent);
+void menu_set_type(int type);
+
+extern struct menu rootmenu;
+
+bool menu_is_empty(struct menu *menu);
+bool menu_is_visible(struct menu *menu);
+bool menu_has_prompt(struct menu *menu);
+const char *menu_get_prompt(struct menu *menu);
+struct menu *menu_get_root_menu(struct menu *menu);
+struct menu *menu_get_parent_menu(struct menu *menu);
+bool menu_has_help(struct menu *menu);
+const char *menu_get_help(struct menu *menu);
+struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
+void menu_get_ext_help(struct menu *menu, struct gstr *help);
+
/* symbol.c */
void sym_clear_all_valid(void);
struct symbol *sym_choice_default(struct symbol *sym);
struct property *sym_get_range_prop(struct symbol *sym);
const char *sym_get_string_default(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
-struct property *prop_alloc(enum prop_type type, struct symbol *sym);
struct symbol *prop_get_symbol(struct property *prop);
static inline tristate sym_get_tristate_value(struct symbol *sym)
void conf_set_changed_callback(void (*fn)(void));
void conf_set_message_callback(void (*fn)(const char *s));
-/* menu.c */
-extern struct menu rootmenu;
-
-bool menu_is_empty(struct menu *menu);
-bool menu_is_visible(struct menu *menu);
-bool menu_has_prompt(struct menu *menu);
-const char * menu_get_prompt(struct menu *menu);
-struct menu * menu_get_root_menu(struct menu *menu);
-struct menu * menu_get_parent_menu(struct menu *menu);
-bool menu_has_help(struct menu *menu);
-const char * menu_get_help(struct menu *menu);
-struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
-void menu_get_ext_help(struct menu *menu, struct gstr *help);
-
/* symbol.c */
extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
bool sym_string_valid(struct symbol *sym, const char *newval);
bool sym_string_within_range(struct symbol *sym, const char *str);
bool sym_set_string_value(struct symbol *sym, const char *newval);
-bool sym_is_changable(struct symbol *sym);
+bool sym_is_changeable(struct symbol *sym);
struct property * sym_get_choice_prop(struct symbol *sym);
const char * sym_get_string_value(struct symbol *sym);
void variable_add(const char *name, const char *value,
enum variable_flavor flavor);
void variable_all_del(void);
-char *expand_string(const char *in);
char *expand_dollar(const char **str);
char *expand_one_token(const char **str);
struct menu *menu_add_menu(void)
{
last_entry_ptr = ¤t_entry->list;
- return current_menu = current_entry;
+ current_menu = current_entry;
+ return current_menu;
}
void menu_end_menu(void)
sym_type_name(sym->type), sym_type_name(type));
}
-static struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
+static struct property *menu_add_prop(enum prop_type type, struct expr *expr,
+ struct expr *dep)
{
- struct property *prop = prop_alloc(type, current_entry->sym);
+ struct property *prop;
+ prop = xmalloc(sizeof(*prop));
+ memset(prop, 0, sizeof(*prop));
+ prop->type = type;
+ prop->file = current_file;
+ prop->lineno = zconf_lineno();
prop->menu = current_entry;
prop->expr = expr;
prop->visible.expr = dep;
- if (prompt) {
- if (isspace(*prompt)) {
- prop_warn(prop, "leading whitespace ignored");
- while (isspace(*prompt))
- prompt++;
- }
- if (current_entry->prompt && current_entry != &rootmenu)
- prop_warn(prop, "prompt redefined");
+ /* append property to the prop list of symbol */
+ if (current_entry->sym) {
+ struct property **propp;
- /* Apply all upper menus' visibilities to actual prompts. */
- if(type == P_PROMPT) {
- struct menu *menu = current_entry;
+ for (propp = ¤t_entry->sym->prop;
+ *propp;
+ propp = &(*propp)->next)
+ ;
+ *propp = prop;
+ }
- while ((menu = menu->parent) != NULL) {
- struct expr *dup_expr;
+ return prop;
+}
- if (!menu->visibility)
- continue;
- /*
- * Do not add a reference to the
- * menu's visibility expression but
- * use a copy of it. Otherwise the
- * expression reduction functions
- * will modify expressions that have
- * multiple references which can
- * cause unwanted side effects.
- */
- dup_expr = expr_copy(menu->visibility);
+struct property *menu_add_prompt(enum prop_type type, char *prompt,
+ struct expr *dep)
+{
+ struct property *prop = menu_add_prop(type, NULL, dep);
- prop->visible.expr
- = expr_alloc_and(prop->visible.expr,
- dup_expr);
- }
- }
+ if (isspace(*prompt)) {
+ prop_warn(prop, "leading whitespace ignored");
+ while (isspace(*prompt))
+ prompt++;
+ }
+ if (current_entry->prompt)
+ prop_warn(prop, "prompt redefined");
- current_entry->prompt = prop;
+ /* Apply all upper menus' visibilities to actual prompts. */
+ if (type == P_PROMPT) {
+ struct menu *menu = current_entry;
+
+ while ((menu = menu->parent) != NULL) {
+ struct expr *dup_expr;
+
+ if (!menu->visibility)
+ continue;
+ /*
+ * Do not add a reference to the menu's visibility
+ * expression but use a copy of it. Otherwise the
+ * expression reduction functions will modify
+ * expressions that have multiple references which
+ * can cause unwanted side effects.
+ */
+ dup_expr = expr_copy(menu->visibility);
+
+ prop->visible.expr = expr_alloc_and(prop->visible.expr,
+ dup_expr);
+ }
}
+
+ current_entry->prompt = prop;
prop->text = prompt;
return prop;
}
-struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
-{
- return menu_add_prop(type, prompt, NULL, dep);
-}
-
void menu_add_visibility(struct expr *expr)
{
current_entry->visibility = expr_alloc_and(current_entry->visibility,
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
{
- menu_add_prop(type, NULL, expr, dep);
+ menu_add_prop(type, expr, dep);
}
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
{
- menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
+ menu_add_prop(type, expr_alloc_symbol(sym), dep);
}
void menu_add_option_modules(void)
* choice value symbols.
*/
parentdep = expr_alloc_symbol(sym);
- } else if (parent->prompt)
- /* Menu node for 'menu' */
- parentdep = parent->prompt->visible.expr;
- else
- /* Menu node for 'if' */
+ } else {
+ /* Menu node for 'menu', 'if' */
parentdep = parent->dep;
+ }
/* For each child menu node... */
for (menu = parent->list; menu; menu = menu->next) {
return "";
}
+static void get_def_str(struct gstr *r, struct menu *menu)
+{
+ str_printf(r, "Defined at %s:%d\n",
+ menu->file->name, menu->lineno);
+}
+
+static void get_dep_str(struct gstr *r, struct expr *expr, const char *prefix)
+{
+ if (!expr_is_yes(expr)) {
+ str_append(r, prefix);
+ expr_gstr_print(expr, r);
+ str_append(r, "\n");
+ }
+}
+
static void get_prompt_str(struct gstr *r, struct property *prop,
struct list_head *head)
{
struct menu *submenu[8], *menu, *location = NULL;
struct jump_key *jump = NULL;
- str_printf(r, "Prompt: %s\n", prop->text);
+ str_printf(r, " Prompt: %s\n", prop->text);
+
+ get_dep_str(r, prop->menu->dep, " Depends on: ");
+ /*
+ * Most prompts in Linux have visibility that exactly matches their
+ * dependencies. For these, we print only the dependencies to improve
+ * readability. However, prompts with inline "if" expressions and
+ * prompts with a parent that has a "visible if" expression have
+ * differing dependencies and visibility. In these rare cases, we
+ * print both.
+ */
+ if (!expr_eq(prop->menu->dep, prop->visible.expr))
+ get_dep_str(r, prop->visible.expr, " Visible if: ");
+
menu = prop->menu->parent;
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
bool accessible = menu_is_visible(menu);
}
}
-/*
- * get property of type P_SYMBOL
- */
-static struct property *get_symbol_prop(struct symbol *sym)
-{
- struct property *prop = NULL;
-
- for_all_properties(sym, prop, P_SYMBOL)
- break;
- return prop;
-}
-
static void get_symbol_props_str(struct gstr *r, struct symbol *sym,
enum prop_type tok, const char *prefix)
{
}
}
}
- for_all_prompts(sym, prop)
- get_prompt_str(r, prop, head);
-
- prop = get_symbol_prop(sym);
- if (prop) {
- str_printf(r, " Defined at %s:%d\n", prop->menu->file->name,
- prop->menu->lineno);
- if (!expr_is_yes(prop->visible.expr)) {
- str_append(r, " Depends on: ");
- expr_gstr_print(prop->visible.expr, r);
- str_append(r, "\n");
+
+ /* Print the definitions with prompts before the ones without */
+ for_all_properties(sym, prop, P_SYMBOL) {
+ if (prop->menu->prompt) {
+ get_def_str(r, prop->menu);
+ get_prompt_str(r, prop->menu->prompt, head);
+ }
+ }
+
+ for_all_properties(sym, prop, P_SYMBOL) {
+ if (!prop->menu->prompt) {
+ get_def_str(r, prop->menu);
+ get_dep_str(r, prop->menu->dep, " Depends on: ");
}
}
- get_symbol_props_str(r, sym, P_SELECT, " Selects: ");
+ get_symbol_props_str(r, sym, P_SELECT, "Selects: ");
if (sym->rev_dep.expr) {
- expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]:\n");
- expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]:\n");
- expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]:\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, "Selected by [y]:\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, "Selected by [m]:\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, no, "Selected by [n]:\n");
}
- get_symbol_props_str(r, sym, P_IMPLY, " Implies: ");
+ get_symbol_props_str(r, sym, P_IMPLY, "Implies: ");
if (sym->implied.expr) {
- expr_gstr_print_revdep(sym->implied.expr, r, yes, " Implied by [y]:\n");
- expr_gstr_print_revdep(sym->implied.expr, r, mod, " Implied by [m]:\n");
- expr_gstr_print_revdep(sym->implied.expr, r, no, " Implied by [n]:\n");
+ expr_gstr_print_revdep(sym->implied.expr, r, yes, "Implied by [y]:\n");
+ expr_gstr_print_revdep(sym->implied.expr, r, mod, "Implied by [m]:\n");
+ expr_gstr_print_revdep(sym->implied.expr, r, no, "Implied by [n]:\n");
}
str_append(r, "\n\n");
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
+ */
+%{
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "lkc.h"
+
+#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
+
+#define PRINTD 0x0001
+#define DEBUG_PARSE 0x0002
+
+int cdebug = PRINTD;
+
+static void yyerror(const char *err);
+static void zconfprint(const char *err, ...);
+static void zconf_error(const char *err, ...);
+static bool zconf_endtoken(const char *tokenname,
+ const char *expected_tokenname);
+
+struct symbol *symbol_hash[SYMBOL_HASHSIZE];
+
+static struct menu *current_menu, *current_entry;
+
+%}
+
+%union
+{
+ char *string;
+ struct symbol *symbol;
+ struct expr *expr;
+ struct menu *menu;
+ enum symbol_type type;
+ enum variable_flavor flavor;
+}
+
+%token <string> T_HELPTEXT
+%token <string> T_WORD
+%token <string> T_WORD_QUOTE
+%token T_ALLNOCONFIG_Y
+%token T_BOOL
+%token T_CHOICE
+%token T_CLOSE_PAREN
+%token T_COLON_EQUAL
+%token T_COMMENT
+%token T_CONFIG
+%token T_DEFAULT
+%token T_DEFCONFIG_LIST
+%token T_DEF_BOOL
+%token T_DEF_TRISTATE
+%token T_DEPENDS
+%token T_ENDCHOICE
+%token T_ENDIF
+%token T_ENDMENU
+%token T_HELP
+%token T_HEX
+%token T_IF
+%token T_IMPLY
+%token T_INT
+%token T_MAINMENU
+%token T_MENU
+%token T_MENUCONFIG
+%token T_MODULES
+%token T_ON
+%token T_OPEN_PAREN
+%token T_OPTION
+%token T_OPTIONAL
+%token T_PLUS_EQUAL
+%token T_PROMPT
+%token T_RANGE
+%token T_SELECT
+%token T_SOURCE
+%token T_STRING
+%token T_TRISTATE
+%token T_VISIBLE
+%token T_EOL
+%token <string> T_ASSIGN_VAL
+
+%left T_OR
+%left T_AND
+%left T_EQUAL T_UNEQUAL
+%left T_LESS T_LESS_EQUAL T_GREATER T_GREATER_EQUAL
+%nonassoc T_NOT
+
+%type <symbol> nonconst_symbol
+%type <symbol> symbol
+%type <type> type logic_type default
+%type <expr> expr
+%type <expr> if_expr
+%type <string> end
+%type <menu> if_entry menu_entry choice_entry
+%type <string> word_opt assign_val
+%type <flavor> assign_op
+
+%destructor {
+ fprintf(stderr, "%s:%d: missing end statement for this entry\n",
+ $$->file->name, $$->lineno);
+ if (current_menu == $$)
+ menu_end_menu();
+} if_entry menu_entry choice_entry
+
+%%
+input: mainmenu_stmt stmt_list | stmt_list;
+
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL
+{
+ menu_add_prompt(P_MENU, $2, NULL);
+};
+
+stmt_list:
+ /* empty */
+ | stmt_list assignment_stmt
+ | stmt_list choice_stmt
+ | stmt_list comment_stmt
+ | stmt_list config_stmt
+ | stmt_list if_stmt
+ | stmt_list menu_stmt
+ | stmt_list menuconfig_stmt
+ | stmt_list source_stmt
+ | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
+ | stmt_list error T_EOL { zconf_error("invalid statement"); }
+;
+
+stmt_list_in_choice:
+ /* empty */
+ | stmt_list_in_choice comment_stmt
+ | stmt_list_in_choice config_stmt
+ | stmt_list_in_choice if_stmt_in_choice
+ | stmt_list_in_choice error T_EOL { zconf_error("invalid statement"); }
+;
+
+/* config/menuconfig entry */
+
+config_entry_start: T_CONFIG nonconst_symbol T_EOL
+{
+ $2->flags |= SYMBOL_OPTIONAL;
+ menu_add_entry($2);
+ printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name);
+};
+
+config_stmt: config_entry_start config_option_list
+{
+ printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
+};
+
+menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL
+{
+ $2->flags |= SYMBOL_OPTIONAL;
+ menu_add_entry($2);
+ printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name);
+};
+
+menuconfig_stmt: menuconfig_entry_start config_option_list
+{
+ if (current_entry->prompt)
+ current_entry->prompt->type = P_MENU;
+ else
+ zconfprint("warning: menuconfig statement without prompt");
+ printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
+};
+
+config_option_list:
+ /* empty */
+ | config_option_list config_option
+ | config_option_list depends
+ | config_option_list help
+;
+
+config_option: type prompt_stmt_opt T_EOL
+{
+ menu_set_type($1);
+ printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
+ zconf_curname(), zconf_lineno(),
+ $1);
+};
+
+config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
+{
+ menu_add_prompt(P_PROMPT, $2, $3);
+ printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
+};
+
+config_option: default expr if_expr T_EOL
+{
+ menu_add_expr(P_DEFAULT, $2, $3);
+ if ($1 != S_UNKNOWN)
+ menu_set_type($1);
+ printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
+ zconf_curname(), zconf_lineno(),
+ $1);
+};
+
+config_option: T_SELECT nonconst_symbol if_expr T_EOL
+{
+ menu_add_symbol(P_SELECT, $2, $3);
+ printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
+};
+
+config_option: T_IMPLY nonconst_symbol if_expr T_EOL
+{
+ menu_add_symbol(P_IMPLY, $2, $3);
+ printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
+};
+
+config_option: T_RANGE symbol symbol if_expr T_EOL
+{
+ menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
+ printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
+};
+
+config_option: T_OPTION T_MODULES T_EOL
+{
+ menu_add_option_modules();
+};
+
+config_option: T_OPTION T_DEFCONFIG_LIST T_EOL
+{
+ menu_add_option_defconfig_list();
+};
+
+config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
+{
+ menu_add_option_allnoconfig_y();
+};
+
+/* choice entry */
+
+choice: T_CHOICE word_opt T_EOL
+{
+ struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);
+ sym->flags |= SYMBOL_NO_WRITE;
+ menu_add_entry(sym);
+ menu_add_expr(P_CHOICE, NULL, NULL);
+ free($2);
+ printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
+};
+
+choice_entry: choice choice_option_list
+{
+ $$ = menu_add_menu();
+};
+
+choice_end: end
+{
+ if (zconf_endtoken($1, "choice")) {
+ menu_end_menu();
+ printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
+ }
+};
+
+choice_stmt: choice_entry stmt_list_in_choice choice_end
+;
+
+choice_option_list:
+ /* empty */
+ | choice_option_list choice_option
+ | choice_option_list depends
+ | choice_option_list help
+;
+
+choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
+{
+ menu_add_prompt(P_PROMPT, $2, $3);
+ printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
+};
+
+choice_option: logic_type prompt_stmt_opt T_EOL
+{
+ menu_set_type($1);
+ printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
+ zconf_curname(), zconf_lineno(), $1);
+};
+
+choice_option: T_OPTIONAL T_EOL
+{
+ current_entry->sym->flags |= SYMBOL_OPTIONAL;
+ printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
+};
+
+choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
+{
+ menu_add_symbol(P_DEFAULT, $2, $3);
+ printd(DEBUG_PARSE, "%s:%d:default\n",
+ zconf_curname(), zconf_lineno());
+};
+
+type:
+ logic_type
+ | T_INT { $$ = S_INT; }
+ | T_HEX { $$ = S_HEX; }
+ | T_STRING { $$ = S_STRING; }
+
+logic_type:
+ T_BOOL { $$ = S_BOOLEAN; }
+ | T_TRISTATE { $$ = S_TRISTATE; }
+
+default:
+ T_DEFAULT { $$ = S_UNKNOWN; }
+ | T_DEF_BOOL { $$ = S_BOOLEAN; }
+ | T_DEF_TRISTATE { $$ = S_TRISTATE; }
+
+/* if entry */
+
+if_entry: T_IF expr T_EOL
+{
+ printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
+ menu_add_entry(NULL);
+ menu_add_dep($2);
+ $$ = menu_add_menu();
+};
+
+if_end: end
+{
+ if (zconf_endtoken($1, "if")) {
+ menu_end_menu();
+ printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
+ }
+};
+
+if_stmt: if_entry stmt_list if_end
+;
+
+if_stmt_in_choice: if_entry stmt_list_in_choice if_end
+;
+
+/* menu entry */
+
+menu: T_MENU T_WORD_QUOTE T_EOL
+{
+ menu_add_entry(NULL);
+ menu_add_prompt(P_MENU, $2, NULL);
+ printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
+};
+
+menu_entry: menu menu_option_list
+{
+ $$ = menu_add_menu();
+};
+
+menu_end: end
+{
+ if (zconf_endtoken($1, "menu")) {
+ menu_end_menu();
+ printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
+ }
+};
+
+menu_stmt: menu_entry stmt_list menu_end
+;
+
+menu_option_list:
+ /* empty */
+ | menu_option_list visible
+ | menu_option_list depends
+;
+
+source_stmt: T_SOURCE T_WORD_QUOTE T_EOL
+{
+ printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
+ zconf_nextfile($2);
+ free($2);
+};
+
+/* comment entry */
+
+comment: T_COMMENT T_WORD_QUOTE T_EOL
+{
+ menu_add_entry(NULL);
+ menu_add_prompt(P_COMMENT, $2, NULL);
+ printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
+};
+
+comment_stmt: comment comment_option_list
+;
+
+comment_option_list:
+ /* empty */
+ | comment_option_list depends
+;
+
+/* help option */
+
+help_start: T_HELP T_EOL
+{
+ printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
+ zconf_starthelp();
+};
+
+help: help_start T_HELPTEXT
+{
+ if (current_entry->help) {
+ free(current_entry->help);
+ zconfprint("warning: '%s' defined with more than one help text -- only the last one will be used",
+ current_entry->sym->name ?: "<choice>");
+ }
+
+ /* Is the help text empty or all whitespace? */
+ if ($2[strspn($2, " \f\n\r\t\v")] == '\0')
+ zconfprint("warning: '%s' defined with blank help text",
+ current_entry->sym->name ?: "<choice>");
+
+ current_entry->help = $2;
+};
+
+/* depends option */
+
+depends: T_DEPENDS T_ON expr T_EOL
+{
+ menu_add_dep($3);
+ printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
+};
+
+/* visibility option */
+visible: T_VISIBLE if_expr T_EOL
+{
+ menu_add_visibility($2);
+};
+
+/* prompt statement */
+
+prompt_stmt_opt:
+ /* empty */
+ | T_WORD_QUOTE if_expr
+{
+ menu_add_prompt(P_PROMPT, $1, $2);
+};
+
+end: T_ENDMENU T_EOL { $$ = "menu"; }
+ | T_ENDCHOICE T_EOL { $$ = "choice"; }
+ | T_ENDIF T_EOL { $$ = "if"; }
+;
+
+if_expr: /* empty */ { $$ = NULL; }
+ | T_IF expr { $$ = $2; }
+;
+
+expr: symbol { $$ = expr_alloc_symbol($1); }
+ | symbol T_LESS symbol { $$ = expr_alloc_comp(E_LTH, $1, $3); }
+ | symbol T_LESS_EQUAL symbol { $$ = expr_alloc_comp(E_LEQ, $1, $3); }
+ | symbol T_GREATER symbol { $$ = expr_alloc_comp(E_GTH, $1, $3); }
+ | symbol T_GREATER_EQUAL symbol { $$ = expr_alloc_comp(E_GEQ, $1, $3); }
+ | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); }
+ | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
+ | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; }
+ | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); }
+ | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); }
+ | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); }
+;
+
+/* For symbol definitions, selects, etc., where quotes are not accepted */
+nonconst_symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); };
+
+symbol: nonconst_symbol
+ | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); }
+;
+
+word_opt: /* empty */ { $$ = NULL; }
+ | T_WORD
+
+/* assignment statement */
+
+assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }
+
+assign_op:
+ T_EQUAL { $$ = VAR_RECURSIVE; }
+ | T_COLON_EQUAL { $$ = VAR_SIMPLE; }
+ | T_PLUS_EQUAL { $$ = VAR_APPEND; }
+;
+
+assign_val:
+ /* empty */ { $$ = xstrdup(""); };
+ | T_ASSIGN_VAL
+;
+
+%%
+
+void conf_parse(const char *name)
+{
+ struct symbol *sym;
+ int i;
+
+ zconf_initscan(name);
+
+ _menu_init();
+
+ if (getenv("ZCONF_DEBUG"))
+ yydebug = 1;
+ yyparse();
+
+ /* Variables are expanded in the parse phase. We can free them here. */
+ variable_all_del();
+
+ if (yynerrs)
+ exit(1);
+ if (!modules_sym)
+ modules_sym = sym_find( "n" );
+
+ if (!menu_has_prompt(&rootmenu)) {
+ current_entry = &rootmenu;
+ menu_add_prompt(P_MENU, "Main menu", NULL);
+ }
+
+ menu_finalize(&rootmenu);
+ for_all_symbols(i, sym) {
+ if (sym_check_deps(sym))
+ yynerrs++;
+ }
+ if (yynerrs)
+ exit(1);
+ sym_set_change_count(1);
+}
+
+static bool zconf_endtoken(const char *tokenname,
+ const char *expected_tokenname)
+{
+ if (strcmp(tokenname, expected_tokenname)) {
+ zconf_error("unexpected '%s' within %s block",
+ tokenname, expected_tokenname);
+ yynerrs++;
+ return false;
+ }
+ if (current_menu->file != current_file) {
+ zconf_error("'%s' in different file than '%s'",
+ tokenname, expected_tokenname);
+ fprintf(stderr, "%s:%d: location of the '%s'\n",
+ current_menu->file->name, current_menu->lineno,
+ expected_tokenname);
+ yynerrs++;
+ return false;
+ }
+ return true;
+}
+
+static void zconfprint(const char *err, ...)
+{
+ va_list ap;
+
+ fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
+ va_start(ap, err);
+ vfprintf(stderr, err, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+
+static void zconf_error(const char *err, ...)
+{
+ va_list ap;
+
+ yynerrs++;
+ fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
+ va_start(ap, err);
+ vfprintf(stderr, err, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+
+static void yyerror(const char *err)
+{
+ fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
+}
+
+static void print_quoted_string(FILE *out, const char *str)
+{
+ const char *p;
+ int len;
+
+ putc('"', out);
+ while ((p = strchr(str, '"'))) {
+ len = p - str;
+ if (len)
+ fprintf(out, "%.*s", len, str);
+ fputs("\\\"", out);
+ str = p + 1;
+ }
+ fputs(str, out);
+ putc('"', out);
+}
+
+static void print_symbol(FILE *out, struct menu *menu)
+{
+ struct symbol *sym = menu->sym;
+ struct property *prop;
+
+ if (sym_is_choice(sym))
+ fprintf(out, "\nchoice\n");
+ else
+ fprintf(out, "\nconfig %s\n", sym->name);
+ switch (sym->type) {
+ case S_BOOLEAN:
+ fputs(" bool\n", out);
+ break;
+ case S_TRISTATE:
+ fputs(" tristate\n", out);
+ break;
+ case S_STRING:
+ fputs(" string\n", out);
+ break;
+ case S_INT:
+ fputs(" integer\n", out);
+ break;
+ case S_HEX:
+ fputs(" hex\n", out);
+ break;
+ default:
+ fputs(" ???\n", out);
+ break;
+ }
+ for (prop = sym->prop; prop; prop = prop->next) {
+ if (prop->menu != menu)
+ continue;
+ switch (prop->type) {
+ case P_PROMPT:
+ fputs(" prompt ", out);
+ print_quoted_string(out, prop->text);
+ if (!expr_is_yes(prop->visible.expr)) {
+ fputs(" if ", out);
+ expr_fprint(prop->visible.expr, out);
+ }
+ fputc('\n', out);
+ break;
+ case P_DEFAULT:
+ fputs( " default ", out);
+ expr_fprint(prop->expr, out);
+ if (!expr_is_yes(prop->visible.expr)) {
+ fputs(" if ", out);
+ expr_fprint(prop->visible.expr, out);
+ }
+ fputc('\n', out);
+ break;
+ case P_CHOICE:
+ fputs(" #choice value\n", out);
+ break;
+ case P_SELECT:
+ fputs( " select ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_IMPLY:
+ fputs( " imply ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_RANGE:
+ fputs( " range ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_MENU:
+ fputs( " menu ", out);
+ print_quoted_string(out, prop->text);
+ fputc('\n', out);
+ break;
+ case P_SYMBOL:
+ fputs( " symbol ", out);
+ fprintf(out, "%s\n", prop->menu->sym->name);
+ break;
+ default:
+ fprintf(out, " unknown prop %d!\n", prop->type);
+ break;
+ }
+ }
+ if (menu->help) {
+ int len = strlen(menu->help);
+ while (menu->help[--len] == '\n')
+ menu->help[len] = 0;
+ fprintf(out, " help\n%s\n", menu->help);
+ }
+}
+
+void zconfdump(FILE *out)
+{
+ struct property *prop;
+ struct symbol *sym;
+ struct menu *menu;
+
+ menu = rootmenu.list;
+ while (menu) {
+ if ((sym = menu->sym))
+ print_symbol(out, menu);
+ else if ((prop = menu->prompt)) {
+ switch (prop->type) {
+ case P_COMMENT:
+ fputs("\ncomment ", out);
+ print_quoted_string(out, prop->text);
+ fputs("\n", out);
+ break;
+ case P_MENU:
+ fputs("\nmenu ", out);
+ print_quoted_string(out, prop->text);
+ fputs("\n", out);
+ break;
+ default:
+ ;
+ }
+ if (!expr_is_yes(prop->visible.expr)) {
+ fputs(" depends ", out);
+ expr_fprint(prop->visible.expr, out);
+ fputc('\n', out);
+ }
+ }
+
+ if (menu->list)
+ menu = menu->list;
+ else if (menu->next)
+ menu = menu->next;
+ else while ((menu = menu->parent)) {
+ if (menu->prompt && menu->prompt->type == P_MENU)
+ fputs("\nendmenu\n", out);
+ if (menu->next) {
+ menu = menu->next;
+ break;
+ }
+ }
+ }
+}
+
+#include "menu.c"
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
static char *expand_string_with_args(const char *in, int argc, char *argv[]);
+static char *expand_string(const char *in);
static void __attribute__((noreturn)) pperror(const char *format, ...)
{
if (!strcmp(argv[0], "y"))
pperror("%s", argv[1]);
- return NULL;
+ return xstrdup("");
}
static char *do_filename(int argc, char *argv[])
return __expand_string(&in, is_end_of_str, argc, argv);
}
-char *expand_string(const char *in)
+static char *expand_string(const char *in)
{
return expand_string_with_args(in, 0, NULL);
}
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
*/
+#include <sys/types.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
-#include <sys/utsname.h>
#include "lkc.h"
.name = "y",
.curr = { "y", yes },
.flags = SYMBOL_CONST|SYMBOL_VALID,
-}, symbol_mod = {
+};
+
+struct symbol symbol_mod = {
.name = "m",
.curr = { "m", mod },
.flags = SYMBOL_CONST|SYMBOL_VALID,
-}, symbol_no = {
+};
+
+struct symbol symbol_no = {
.name = "n",
.curr = { "n", no },
.flags = SYMBOL_CONST|SYMBOL_VALID,
-}, symbol_empty = {
+};
+
+static struct symbol symbol_empty = {
.name = "",
.curr = { "", no },
.flags = SYMBOL_VALID,
struct symbol *sym_defconfig_list;
struct symbol *modules_sym;
-tristate modules_val;
+static tristate modules_val;
enum symbol_type sym_get_type(struct symbol *sym)
{
sym_set_changed(sym);
}
tri = no;
- if (sym->implied.expr && sym->dir_dep.tri != no)
+ if (sym->implied.expr)
tri = expr_calc_value(sym->implied.expr);
if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
tri = yes;
if (sym->implied.tri != no) {
sym->flags |= SYMBOL_WRITE;
newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
+ newval.tri = EXPR_AND(newval.tri,
+ sym->dir_dep.tri);
}
}
calc_newval:
sym_warn_unmet_dep(sym);
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
}
- if (newval.tri == mod &&
- (sym_get_type(sym) == S_BOOLEAN || sym->implied.tri == yes))
+ if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
newval.tri = yes;
break;
case S_STRING:
return false;
if (sym->visible <= sym->rev_dep.tri)
return false;
- if (sym->implied.tri == yes && val == mod)
- return false;
if (sym_is_choice_value(sym) && sym->visible == yes)
return val == yes;
return val >= sym->rev_dep.tri && val <= sym->visible;
return (const char *)sym->curr.val;
}
-bool sym_is_changable(struct symbol *sym)
+bool sym_is_changeable(struct symbol *sym)
{
return sym->visible > sym->rev_dep.tri;
}
memset(symbol, 0, sizeof(*symbol));
symbol->name = new_name;
symbol->type = S_UNKNOWN;
- symbol->flags |= flags;
+ symbol->flags = flags;
symbol->next = symbol_hash[hash];
symbol_hash[hash] = symbol;
}
fprintf(stderr,
- "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"
+ "For a resolution refer to Documentation/kbuild/kconfig-language.rst\n"
"subsection \"Kconfig recursive dependency limitations\"\n"
"\n");
return sym2;
}
-struct property *prop_alloc(enum prop_type type, struct symbol *sym)
-{
- struct property *prop;
- struct property **propp;
-
- prop = xmalloc(sizeof(*prop));
- memset(prop, 0, sizeof(*prop));
- prop->type = type;
- prop->sym = sym;
- prop->file = current_file;
- prop->lineno = zconf_lineno();
-
- /* append property to the prop list of symbol */
- if (sym) {
- for (propp = &sym->prop; *propp; propp = &(*propp)->next)
- ;
- *propp = prop;
- }
-
- return prop;
-}
-
struct symbol *prop_get_symbol(struct property *prop)
{
if (prop->expr && (prop->expr->type == E_SYMBOL ||
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- */
-%option nostdinit noyywrap never-interactive full ecs
-%option 8bit nodefault yylineno
-%x ASSIGN_VAL HELP STRING
-%{
-
-#include <assert.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "lkc.h"
-#include "zconf.tab.h"
-
-#define YY_DECL static int yylex1(void)
-
-#define START_STRSIZE 16
-
-static struct {
- struct file *file;
- int lineno;
-} current_pos;
-
-static int prev_prev_token = T_EOL;
-static int prev_token = T_EOL;
-static char *text;
-static int text_size, text_asize;
-
-struct buffer {
- struct buffer *parent;
- YY_BUFFER_STATE state;
-};
-
-struct buffer *current_buf;
-
-static int last_ts, first_ts;
-
-static char *expand_token(const char *in, size_t n);
-static void append_expanded_string(const char *in);
-static void zconf_endhelp(void);
-static void zconf_endfile(void);
-
-static void new_string(void)
-{
- text = xmalloc(START_STRSIZE);
- text_asize = START_STRSIZE;
- text_size = 0;
- *text = 0;
-}
-
-static void append_string(const char *str, int size)
-{
- int new_size = text_size + size + 1;
- if (new_size > text_asize) {
- new_size += START_STRSIZE - 1;
- new_size &= -START_STRSIZE;
- text = xrealloc(text, new_size);
- text_asize = new_size;
- }
- memcpy(text + text_size, str, size);
- text_size += size;
- text[text_size] = 0;
-}
-
-static void alloc_string(const char *str, int size)
-{
- text = xmalloc(size + 1);
- memcpy(text, str, size);
- text[size] = 0;
-}
-
-static void warn_ignored_character(char chr)
-{
- fprintf(stderr,
- "%s:%d:warning: ignoring unsupported character '%c'\n",
- current_file->name, yylineno, chr);
-}
-%}
-
-n [A-Za-z0-9_-]
-
-%%
- int str = 0;
- int ts, i;
-
-#.* /* ignore comment */
-[ \t]* /* whitespaces */
-\\\n /* escaped new line */
-\n return T_EOL;
-"allnoconfig_y" return T_ALLNOCONFIG_Y;
-"bool" return T_BOOL;
-"choice" return T_CHOICE;
-"comment" return T_COMMENT;
-"config" return T_CONFIG;
-"def_bool" return T_DEF_BOOL;
-"def_tristate" return T_DEF_TRISTATE;
-"default" return T_DEFAULT;
-"defconfig_list" return T_DEFCONFIG_LIST;
-"depends" return T_DEPENDS;
-"endchoice" return T_ENDCHOICE;
-"endif" return T_ENDIF;
-"endmenu" return T_ENDMENU;
-"help"|"---help---" return T_HELP;
-"hex" return T_HEX;
-"if" return T_IF;
-"imply" return T_IMPLY;
-"int" return T_INT;
-"mainmenu" return T_MAINMENU;
-"menu" return T_MENU;
-"menuconfig" return T_MENUCONFIG;
-"modules" return T_MODULES;
-"on" return T_ON;
-"option" return T_OPTION;
-"optional" return T_OPTIONAL;
-"prompt" return T_PROMPT;
-"range" return T_RANGE;
-"select" return T_SELECT;
-"source" return T_SOURCE;
-"string" return T_STRING;
-"tristate" return T_TRISTATE;
-"visible" return T_VISIBLE;
-"||" return T_OR;
-"&&" return T_AND;
-"=" return T_EQUAL;
-"!=" return T_UNEQUAL;
-"<" return T_LESS;
-"<=" return T_LESS_EQUAL;
-">" return T_GREATER;
-">=" return T_GREATER_EQUAL;
-"!" return T_NOT;
-"(" return T_OPEN_PAREN;
-")" return T_CLOSE_PAREN;
-":=" return T_COLON_EQUAL;
-"+=" return T_PLUS_EQUAL;
-\"|\' {
- str = yytext[0];
- new_string();
- BEGIN(STRING);
- }
-{n}+ {
- alloc_string(yytext, yyleng);
- yylval.string = text;
- return T_WORD;
- }
-({n}|$)+ {
- /* this token includes at least one '$' */
- yylval.string = expand_token(yytext, yyleng);
- if (strlen(yylval.string))
- return T_WORD;
- free(yylval.string);
- }
-. warn_ignored_character(*yytext);
-
-<ASSIGN_VAL>{
- [^[:blank:]\n]+.* {
- alloc_string(yytext, yyleng);
- yylval.string = text;
- return T_ASSIGN_VAL;
- }
- \n { BEGIN(INITIAL); return T_EOL; }
- .
-}
-
-<STRING>{
- "$".* append_expanded_string(yytext);
- [^$'"\\\n]+ {
- append_string(yytext, yyleng);
- }
- \\.? {
- append_string(yytext + 1, yyleng - 1);
- }
- \'|\" {
- if (str == yytext[0]) {
- BEGIN(INITIAL);
- yylval.string = text;
- return T_WORD_QUOTE;
- } else
- append_string(yytext, 1);
- }
- \n {
- fprintf(stderr,
- "%s:%d:warning: multi-line strings not supported\n",
- zconf_curname(), zconf_lineno());
- unput('\n');
- BEGIN(INITIAL);
- yylval.string = text;
- return T_WORD_QUOTE;
- }
- <<EOF>> {
- BEGIN(INITIAL);
- yylval.string = text;
- return T_WORD_QUOTE;
- }
-}
-
-<HELP>{
- [ \t]+ {
- ts = 0;
- for (i = 0; i < yyleng; i++) {
- if (yytext[i] == '\t')
- ts = (ts & ~7) + 8;
- else
- ts++;
- }
- last_ts = ts;
- if (first_ts) {
- if (ts < first_ts) {
- zconf_endhelp();
- return T_HELPTEXT;
- }
- ts -= first_ts;
- while (ts > 8) {
- append_string(" ", 8);
- ts -= 8;
- }
- append_string(" ", ts);
- }
- }
- [ \t]*\n/[^ \t\n] {
- zconf_endhelp();
- return T_HELPTEXT;
- }
- [ \t]*\n {
- append_string("\n", 1);
- }
- [^ \t\n].* {
- while (yyleng) {
- if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t'))
- break;
- yyleng--;
- }
- append_string(yytext, yyleng);
- if (!first_ts)
- first_ts = last_ts;
- }
- <<EOF>> {
- zconf_endhelp();
- return T_HELPTEXT;
- }
-}
-
-<<EOF>> {
- BEGIN(INITIAL);
-
- if (prev_token != T_EOL && prev_token != T_HELPTEXT)
- fprintf(stderr, "%s:%d:warning: no new line at end of file\n",
- current_file->name, yylineno);
-
- if (current_file) {
- zconf_endfile();
- return T_EOL;
- }
- fclose(yyin);
- yyterminate();
-}
-
-%%
-
-/* second stage lexer */
-int yylex(void)
-{
- int token;
-
-repeat:
- token = yylex1();
-
- if (prev_token == T_EOL || prev_token == T_HELPTEXT) {
- if (token == T_EOL) {
- /* Do not pass unneeded T_EOL to the parser. */
- goto repeat;
- } else {
- /*
- * For the parser, update file/lineno at the first token
- * of each statement. Generally, \n is a statement
- * terminator in Kconfig, but it is not always true
- * because \n could be escaped by a backslash.
- */
- current_pos.file = current_file;
- current_pos.lineno = yylineno;
- }
- }
-
- if (prev_prev_token == T_EOL && prev_token == T_WORD &&
- (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL))
- BEGIN(ASSIGN_VAL);
-
- prev_prev_token = prev_token;
- prev_token = token;
-
- return token;
-}
-
-static char *expand_token(const char *in, size_t n)
-{
- char *out;
- int c;
- char c2;
- const char *rest, *end;
-
- new_string();
- append_string(in, n);
-
- /* get the whole line because we do not know the end of token. */
- while ((c = input()) != EOF) {
- if (c == '\n') {
- unput(c);
- break;
- }
- c2 = c;
- append_string(&c2, 1);
- }
-
- rest = text;
- out = expand_one_token(&rest);
-
- /* push back unused characters to the input stream */
- end = rest + strlen(rest);
- while (end > rest)
- unput(*--end);
-
- free(text);
-
- return out;
-}
-
-static void append_expanded_string(const char *str)
-{
- const char *end;
- char *res;
-
- str++;
-
- res = expand_dollar(&str);
-
- /* push back unused characters to the input stream */
- end = str + strlen(str);
- while (end > str)
- unput(*--end);
-
- append_string(res, strlen(res));
-
- free(res);
-}
-
-void zconf_starthelp(void)
-{
- new_string();
- last_ts = first_ts = 0;
- BEGIN(HELP);
-}
-
-static void zconf_endhelp(void)
-{
- yylval.string = text;
- BEGIN(INITIAL);
-}
-
-
-/*
- * Try to open specified file with following names:
- * ./name
- * $(srctree)/name
- * The latter is used when srctree is separate from objtree
- * when compiling the firmware.
- * Return NULL if file is not found.
- */
-FILE *zconf_fopen(const char *name)
-{
- char *env, fullname[PATH_MAX+1];
- FILE *f;
-
- f = fopen(name, "r");
- if (!f && name != NULL && name[0] != '/') {
- env = getenv(SRCTREE);
- if (env) {
- sprintf(fullname, "%s/%s", env, name);
- f = fopen(fullname, "r");
- }
- }
- return f;
-}
-
-void zconf_initscan(const char *name)
-{
- yyin = zconf_fopen(name);
- if (!yyin) {
- fprintf(stderr, "can't find file %s\n", name);
- exit(1);
- }
-
- current_buf = xmalloc(sizeof(*current_buf));
- memset(current_buf, 0, sizeof(*current_buf));
-
- current_file = file_lookup(name);
- yylineno = 1;
-}
-
-void zconf_nextfile(const char *name)
-{
- struct file *iter;
- struct file *file = file_lookup(name);
- struct buffer *buf = xmalloc(sizeof(*buf));
- memset(buf, 0, sizeof(*buf));
-
- current_buf->state = YY_CURRENT_BUFFER;
- yyin = zconf_fopen(file->name);
- if (!yyin) {
- fprintf(stderr, "%s:%d: can't open file \"%s\"\n",
- zconf_curname(), zconf_lineno(), file->name);
- exit(1);
- }
- yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
- buf->parent = current_buf;
- current_buf = buf;
-
- current_file->lineno = yylineno;
- file->parent = current_file;
-
- for (iter = current_file; iter; iter = iter->parent) {
- if (!strcmp(iter->name, file->name)) {
- fprintf(stderr,
- "Recursive inclusion detected.\n"
- "Inclusion path:\n"
- " current file : %s\n", file->name);
- iter = file;
- do {
- iter = iter->parent;
- fprintf(stderr, " included from: %s:%d\n",
- iter->name, iter->lineno - 1);
- } while (strcmp(iter->name, file->name));
- exit(1);
- }
- }
-
- yylineno = 1;
- current_file = file;
-}
-
-static void zconf_endfile(void)
-{
- struct buffer *parent;
-
- current_file = current_file->parent;
- if (current_file)
- yylineno = current_file->lineno;
-
- parent = current_buf->parent;
- if (parent) {
- fclose(yyin);
- yy_delete_buffer(YY_CURRENT_BUFFER);
- yy_switch_to_buffer(parent->state);
- }
- free(current_buf);
- current_buf = parent;
-}
-
-int zconf_lineno(void)
-{
- return current_pos.lineno;
-}
-
-const char *zconf_curname(void)
-{
- return current_pos.file ? current_pos.file->name : "<none>";
-}
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- */
-%{
-
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "lkc.h"
-
-#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
-
-#define PRINTD 0x0001
-#define DEBUG_PARSE 0x0002
-
-int cdebug = PRINTD;
-
-static void yyerror(const char *err);
-static void zconfprint(const char *err, ...);
-static void zconf_error(const char *err, ...);
-static bool zconf_endtoken(const char *tokenname,
- const char *expected_tokenname);
-
-struct symbol *symbol_hash[SYMBOL_HASHSIZE];
-
-static struct menu *current_menu, *current_entry;
-
-%}
-
-%union
-{
- char *string;
- struct symbol *symbol;
- struct expr *expr;
- struct menu *menu;
- enum symbol_type type;
- enum variable_flavor flavor;
-}
-
-%token <string> T_HELPTEXT
-%token <string> T_WORD
-%token <string> T_WORD_QUOTE
-%token T_ALLNOCONFIG_Y
-%token T_BOOL
-%token T_CHOICE
-%token T_CLOSE_PAREN
-%token T_COLON_EQUAL
-%token T_COMMENT
-%token T_CONFIG
-%token T_DEFAULT
-%token T_DEFCONFIG_LIST
-%token T_DEF_BOOL
-%token T_DEF_TRISTATE
-%token T_DEPENDS
-%token T_ENDCHOICE
-%token T_ENDIF
-%token T_ENDMENU
-%token T_HELP
-%token T_HEX
-%token T_IF
-%token T_IMPLY
-%token T_INT
-%token T_MAINMENU
-%token T_MENU
-%token T_MENUCONFIG
-%token T_MODULES
-%token T_ON
-%token T_OPEN_PAREN
-%token T_OPTION
-%token T_OPTIONAL
-%token T_PLUS_EQUAL
-%token T_PROMPT
-%token T_RANGE
-%token T_SELECT
-%token T_SOURCE
-%token T_STRING
-%token T_TRISTATE
-%token T_VISIBLE
-%token T_EOL
-%token <string> T_ASSIGN_VAL
-
-%left T_OR
-%left T_AND
-%left T_EQUAL T_UNEQUAL
-%left T_LESS T_LESS_EQUAL T_GREATER T_GREATER_EQUAL
-%nonassoc T_NOT
-
-%type <string> prompt
-%type <symbol> nonconst_symbol
-%type <symbol> symbol
-%type <type> type logic_type default
-%type <expr> expr
-%type <expr> if_expr
-%type <string> end
-%type <menu> if_entry menu_entry choice_entry
-%type <string> word_opt assign_val
-%type <flavor> assign_op
-
-%destructor {
- fprintf(stderr, "%s:%d: missing end statement for this entry\n",
- $$->file->name, $$->lineno);
- if (current_menu == $$)
- menu_end_menu();
-} if_entry menu_entry choice_entry
-
-%%
-input: mainmenu_stmt stmt_list | stmt_list;
-
-/* mainmenu entry */
-
-mainmenu_stmt: T_MAINMENU prompt T_EOL
-{
- menu_add_prompt(P_MENU, $2, NULL);
-};
-
-stmt_list:
- /* empty */
- | stmt_list common_stmt
- | stmt_list choice_stmt
- | stmt_list menu_stmt
- | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
- | stmt_list error T_EOL { zconf_error("invalid statement"); }
-;
-
-common_stmt:
- if_stmt
- | comment_stmt
- | config_stmt
- | menuconfig_stmt
- | source_stmt
- | assignment_stmt
-;
-
-/* config/menuconfig entry */
-
-config_entry_start: T_CONFIG nonconst_symbol T_EOL
-{
- $2->flags |= SYMBOL_OPTIONAL;
- menu_add_entry($2);
- printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name);
-};
-
-config_stmt: config_entry_start config_option_list
-{
- printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
-};
-
-menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL
-{
- $2->flags |= SYMBOL_OPTIONAL;
- menu_add_entry($2);
- printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name);
-};
-
-menuconfig_stmt: menuconfig_entry_start config_option_list
-{
- if (current_entry->prompt)
- current_entry->prompt->type = P_MENU;
- else
- zconfprint("warning: menuconfig statement without prompt");
- printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
-};
-
-config_option_list:
- /* empty */
- | config_option_list config_option
- | config_option_list depends
- | config_option_list help
-;
-
-config_option: type prompt_stmt_opt T_EOL
-{
- menu_set_type($1);
- printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
- zconf_curname(), zconf_lineno(),
- $1);
-};
-
-config_option: T_PROMPT prompt if_expr T_EOL
-{
- menu_add_prompt(P_PROMPT, $2, $3);
- printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
-};
-
-config_option: default expr if_expr T_EOL
-{
- menu_add_expr(P_DEFAULT, $2, $3);
- if ($1 != S_UNKNOWN)
- menu_set_type($1);
- printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
- zconf_curname(), zconf_lineno(),
- $1);
-};
-
-config_option: T_SELECT nonconst_symbol if_expr T_EOL
-{
- menu_add_symbol(P_SELECT, $2, $3);
- printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
-};
-
-config_option: T_IMPLY nonconst_symbol if_expr T_EOL
-{
- menu_add_symbol(P_IMPLY, $2, $3);
- printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
-};
-
-config_option: T_RANGE symbol symbol if_expr T_EOL
-{
- menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
- printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
-};
-
-config_option: T_OPTION T_MODULES T_EOL
-{
- menu_add_option_modules();
-};
-
-config_option: T_OPTION T_DEFCONFIG_LIST T_EOL
-{
- menu_add_option_defconfig_list();
-};
-
-config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
-{
- menu_add_option_allnoconfig_y();
-};
-
-/* choice entry */
-
-choice: T_CHOICE word_opt T_EOL
-{
- struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);
- sym->flags |= SYMBOL_NO_WRITE;
- menu_add_entry(sym);
- menu_add_expr(P_CHOICE, NULL, NULL);
- free($2);
- printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
-};
-
-choice_entry: choice choice_option_list
-{
- $$ = menu_add_menu();
-};
-
-choice_end: end
-{
- if (zconf_endtoken($1, "choice")) {
- menu_end_menu();
- printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
- }
-};
-
-choice_stmt: choice_entry choice_block choice_end
-;
-
-choice_option_list:
- /* empty */
- | choice_option_list choice_option
- | choice_option_list depends
- | choice_option_list help
-;
-
-choice_option: T_PROMPT prompt if_expr T_EOL
-{
- menu_add_prompt(P_PROMPT, $2, $3);
- printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
-};
-
-choice_option: logic_type prompt_stmt_opt T_EOL
-{
- menu_set_type($1);
- printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
- zconf_curname(), zconf_lineno(), $1);
-};
-
-choice_option: T_OPTIONAL T_EOL
-{
- current_entry->sym->flags |= SYMBOL_OPTIONAL;
- printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
-};
-
-choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
-{
- menu_add_symbol(P_DEFAULT, $2, $3);
- printd(DEBUG_PARSE, "%s:%d:default\n",
- zconf_curname(), zconf_lineno());
-};
-
-type:
- logic_type
- | T_INT { $$ = S_INT; }
- | T_HEX { $$ = S_HEX; }
- | T_STRING { $$ = S_STRING; }
-
-logic_type:
- T_BOOL { $$ = S_BOOLEAN; }
- | T_TRISTATE { $$ = S_TRISTATE; }
-
-default:
- T_DEFAULT { $$ = S_UNKNOWN; }
- | T_DEF_BOOL { $$ = S_BOOLEAN; }
- | T_DEF_TRISTATE { $$ = S_TRISTATE; }
-
-choice_block:
- /* empty */
- | choice_block common_stmt
-;
-
-/* if entry */
-
-if_entry: T_IF expr T_EOL
-{
- printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
- menu_add_entry(NULL);
- menu_add_dep($2);
- $$ = menu_add_menu();
-};
-
-if_end: end
-{
- if (zconf_endtoken($1, "if")) {
- menu_end_menu();
- printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
- }
-};
-
-if_stmt: if_entry stmt_list if_end
-;
-
-/* menu entry */
-
-menu: T_MENU prompt T_EOL
-{
- menu_add_entry(NULL);
- menu_add_prompt(P_MENU, $2, NULL);
- printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
-};
-
-menu_entry: menu menu_option_list
-{
- $$ = menu_add_menu();
-};
-
-menu_end: end
-{
- if (zconf_endtoken($1, "menu")) {
- menu_end_menu();
- printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
- }
-};
-
-menu_stmt: menu_entry stmt_list menu_end
-;
-
-menu_option_list:
- /* empty */
- | menu_option_list visible
- | menu_option_list depends
-;
-
-source_stmt: T_SOURCE prompt T_EOL
-{
- printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
- zconf_nextfile($2);
- free($2);
-};
-
-/* comment entry */
-
-comment: T_COMMENT prompt T_EOL
-{
- menu_add_entry(NULL);
- menu_add_prompt(P_COMMENT, $2, NULL);
- printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
-};
-
-comment_stmt: comment comment_option_list
-;
-
-comment_option_list:
- /* empty */
- | comment_option_list depends
-;
-
-/* help option */
-
-help_start: T_HELP T_EOL
-{
- printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
- zconf_starthelp();
-};
-
-help: help_start T_HELPTEXT
-{
- if (current_entry->help) {
- free(current_entry->help);
- zconfprint("warning: '%s' defined with more than one help text -- only the last one will be used",
- current_entry->sym->name ?: "<choice>");
- }
-
- /* Is the help text empty or all whitespace? */
- if ($2[strspn($2, " \f\n\r\t\v")] == '\0')
- zconfprint("warning: '%s' defined with blank help text",
- current_entry->sym->name ?: "<choice>");
-
- current_entry->help = $2;
-};
-
-/* depends option */
-
-depends: T_DEPENDS T_ON expr T_EOL
-{
- menu_add_dep($3);
- printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
-};
-
-/* visibility option */
-visible: T_VISIBLE if_expr T_EOL
-{
- menu_add_visibility($2);
-};
-
-/* prompt statement */
-
-prompt_stmt_opt:
- /* empty */
- | prompt if_expr
-{
- menu_add_prompt(P_PROMPT, $1, $2);
-};
-
-prompt: T_WORD
- | T_WORD_QUOTE
-;
-
-end: T_ENDMENU T_EOL { $$ = "menu"; }
- | T_ENDCHOICE T_EOL { $$ = "choice"; }
- | T_ENDIF T_EOL { $$ = "if"; }
-;
-
-if_expr: /* empty */ { $$ = NULL; }
- | T_IF expr { $$ = $2; }
-;
-
-expr: symbol { $$ = expr_alloc_symbol($1); }
- | symbol T_LESS symbol { $$ = expr_alloc_comp(E_LTH, $1, $3); }
- | symbol T_LESS_EQUAL symbol { $$ = expr_alloc_comp(E_LEQ, $1, $3); }
- | symbol T_GREATER symbol { $$ = expr_alloc_comp(E_GTH, $1, $3); }
- | symbol T_GREATER_EQUAL symbol { $$ = expr_alloc_comp(E_GEQ, $1, $3); }
- | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); }
- | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
- | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; }
- | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); }
- | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); }
- | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); }
-;
-
-/* For symbol definitions, selects, etc., where quotes are not accepted */
-nonconst_symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); };
-
-symbol: nonconst_symbol
- | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); }
-;
-
-word_opt: /* empty */ { $$ = NULL; }
- | T_WORD
-
-/* assignment statement */
-
-assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }
-
-assign_op:
- T_EQUAL { $$ = VAR_RECURSIVE; }
- | T_COLON_EQUAL { $$ = VAR_SIMPLE; }
- | T_PLUS_EQUAL { $$ = VAR_APPEND; }
-;
-
-assign_val:
- /* empty */ { $$ = xstrdup(""); };
- | T_ASSIGN_VAL
-;
-
-%%
-
-void conf_parse(const char *name)
-{
- struct symbol *sym;
- int i;
-
- zconf_initscan(name);
-
- _menu_init();
-
- if (getenv("ZCONF_DEBUG"))
- yydebug = 1;
- yyparse();
-
- /* Variables are expanded in the parse phase. We can free them here. */
- variable_all_del();
-
- if (yynerrs)
- exit(1);
- if (!modules_sym)
- modules_sym = sym_find( "n" );
-
- if (!menu_has_prompt(&rootmenu)) {
- current_entry = &rootmenu;
- menu_add_prompt(P_MENU, "Main menu", NULL);
- }
-
- menu_finalize(&rootmenu);
- for_all_symbols(i, sym) {
- if (sym_check_deps(sym))
- yynerrs++;
- }
- if (yynerrs)
- exit(1);
- sym_set_change_count(1);
-}
-
-static bool zconf_endtoken(const char *tokenname,
- const char *expected_tokenname)
-{
- if (strcmp(tokenname, expected_tokenname)) {
- zconf_error("unexpected '%s' within %s block",
- tokenname, expected_tokenname);
- yynerrs++;
- return false;
- }
- if (current_menu->file != current_file) {
- zconf_error("'%s' in different file than '%s'",
- tokenname, expected_tokenname);
- fprintf(stderr, "%s:%d: location of the '%s'\n",
- current_menu->file->name, current_menu->lineno,
- expected_tokenname);
- yynerrs++;
- return false;
- }
- return true;
-}
-
-static void zconfprint(const char *err, ...)
-{
- va_list ap;
-
- fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
- va_start(ap, err);
- vfprintf(stderr, err, ap);
- va_end(ap);
- fprintf(stderr, "\n");
-}
-
-static void zconf_error(const char *err, ...)
-{
- va_list ap;
-
- yynerrs++;
- fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
- va_start(ap, err);
- vfprintf(stderr, err, ap);
- va_end(ap);
- fprintf(stderr, "\n");
-}
-
-static void yyerror(const char *err)
-{
- fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
-}
-
-static void print_quoted_string(FILE *out, const char *str)
-{
- const char *p;
- int len;
-
- putc('"', out);
- while ((p = strchr(str, '"'))) {
- len = p - str;
- if (len)
- fprintf(out, "%.*s", len, str);
- fputs("\\\"", out);
- str = p + 1;
- }
- fputs(str, out);
- putc('"', out);
-}
-
-static void print_symbol(FILE *out, struct menu *menu)
-{
- struct symbol *sym = menu->sym;
- struct property *prop;
-
- if (sym_is_choice(sym))
- fprintf(out, "\nchoice\n");
- else
- fprintf(out, "\nconfig %s\n", sym->name);
- switch (sym->type) {
- case S_BOOLEAN:
- fputs(" bool\n", out);
- break;
- case S_TRISTATE:
- fputs(" tristate\n", out);
- break;
- case S_STRING:
- fputs(" string\n", out);
- break;
- case S_INT:
- fputs(" integer\n", out);
- break;
- case S_HEX:
- fputs(" hex\n", out);
- break;
- default:
- fputs(" ???\n", out);
- break;
- }
- for (prop = sym->prop; prop; prop = prop->next) {
- if (prop->menu != menu)
- continue;
- switch (prop->type) {
- case P_PROMPT:
- fputs(" prompt ", out);
- print_quoted_string(out, prop->text);
- if (!expr_is_yes(prop->visible.expr)) {
- fputs(" if ", out);
- expr_fprint(prop->visible.expr, out);
- }
- fputc('\n', out);
- break;
- case P_DEFAULT:
- fputs( " default ", out);
- expr_fprint(prop->expr, out);
- if (!expr_is_yes(prop->visible.expr)) {
- fputs(" if ", out);
- expr_fprint(prop->visible.expr, out);
- }
- fputc('\n', out);
- break;
- case P_CHOICE:
- fputs(" #choice value\n", out);
- break;
- case P_SELECT:
- fputs( " select ", out);
- expr_fprint(prop->expr, out);
- fputc('\n', out);
- break;
- case P_IMPLY:
- fputs( " imply ", out);
- expr_fprint(prop->expr, out);
- fputc('\n', out);
- break;
- case P_RANGE:
- fputs( " range ", out);
- expr_fprint(prop->expr, out);
- fputc('\n', out);
- break;
- case P_MENU:
- fputs( " menu ", out);
- print_quoted_string(out, prop->text);
- fputc('\n', out);
- break;
- case P_SYMBOL:
- fputs( " symbol ", out);
- fprintf(out, "%s\n", prop->sym->name);
- break;
- default:
- fprintf(out, " unknown prop %d!\n", prop->type);
- break;
- }
- }
- if (menu->help) {
- int len = strlen(menu->help);
- while (menu->help[--len] == '\n')
- menu->help[len] = 0;
- fprintf(out, " help\n%s\n", menu->help);
- }
-}
-
-void zconfdump(FILE *out)
-{
- struct property *prop;
- struct symbol *sym;
- struct menu *menu;
-
- menu = rootmenu.list;
- while (menu) {
- if ((sym = menu->sym))
- print_symbol(out, menu);
- else if ((prop = menu->prompt)) {
- switch (prop->type) {
- case P_COMMENT:
- fputs("\ncomment ", out);
- print_quoted_string(out, prop->text);
- fputs("\n", out);
- break;
- case P_MENU:
- fputs("\nmenu ", out);
- print_quoted_string(out, prop->text);
- fputs("\n", out);
- break;
- default:
- ;
- }
- if (!expr_is_yes(prop->visible.expr)) {
- fputs(" depends ", out);
- expr_fprint(prop->visible.expr, out);
- fputc('\n', out);
- }
- }
-
- if (menu->list)
- menu = menu->list;
- else if (menu->next)
- menu = menu->next;
- else while ((menu = menu->parent)) {
- if (menu->prompt && menu->prompt->type == P_MENU)
- fputs("\nendmenu\n", out);
- if (menu->next) {
- menu = menu->next;
- break;
- }
- }
- }
-}
-
-#include "util.c"
-#include "menu.c"
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* This file holds USB constants and structures that are needed for
* USB device APIs. These are used by the USB device model, which is
* This bit flag is used in endpoint descriptors' bEndpointAddress field.
* It's also one of three fields in control requests bRequestType.
*/
-#define USB_DIR_MASK 0x80
#define USB_DIR_OUT 0 /* to device */
#define USB_DIR_IN 0x80 /* to host */
+#define USB_DIR_MASK 0x80
/*
* USB types, the second of three bRequestType fields
#define USB_REQ_GET_INTERFACE 0x0A
#define USB_REQ_SET_INTERFACE 0x0B
#define USB_REQ_SYNCH_FRAME 0x0C
+#define USB_REQ_SET_SEL 0x30
+#define USB_REQ_SET_ISOCH_DELAY 0x31
#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
#define USB_REQ_GET_ENCRYPTION 0x0E
#define USB_REQ_LOOPBACK_DATA_READ 0x16
#define USB_REQ_SET_INTERFACE_DS 0x17
+/* specific requests for USB Power Delivery */
+#define USB_REQ_GET_PARTNER_PDO 20
+#define USB_REQ_GET_BATTERY_STATUS 21
+#define USB_REQ_SET_PDO 22
+#define USB_REQ_GET_VDM 23
+#define USB_REQ_SEND_VDM 24
+
/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
* used by hubs to put ports into a new L1 suspend state, except that it
* forgot to define its number ...
#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
+/*
+ * Test Mode Selectors
+ * See USB 2.0 spec Table 9-7
+ */
+#define USB_TEST_J 1
+#define USB_TEST_K 2
+#define USB_TEST_SE0_NAK 3
+#define USB_TEST_PACKET 4
+#define USB_TEST_FORCE_ENABLE 5
+
+/* Status Type */
+#define USB_STATUS_TYPE_STANDARD 0
+#define USB_STATUS_TYPE_PTM 1
+
+/*
+ * New Feature Selectors as added by USB 3.0
+ * See USB 3.0 spec Table 9-7
+ */
+#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
+#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
+#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
+#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
+
+#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
+/*
+ * Suspend Options, Table 9-8 USB 3.0 spec
+ */
+#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
+#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
+
+/*
+ * Interface status, Figure 9-5 USB 3.0 spec
+ */
+#define USB_INTRF_STAT_FUNC_RW_CAP 1
+#define USB_INTRF_STAT_FUNC_RW 2
+
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
+/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
+#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
+#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
+#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
+
+/*
+ * Feature selectors from Table 9-8 USB Power Delivery spec
+ */
+#define USB_DEVICE_BATTERY_WAKE_MASK 40
+#define USB_DEVICE_OS_IS_PD_AWARE 41
+#define USB_DEVICE_POLICY_MODE 42
+#define USB_PORT_PR_SWAP 43
+#define USB_PORT_GOTO_MIN 44
+#define USB_PORT_RETURN_POWER 45
+#define USB_PORT_ACCEPT_PD_REQUEST 46
+#define USB_PORT_REJECT_PD_REQUEST 47
+#define USB_PORT_PORT_PD_RESET 48
+#define USB_PORT_C_PORT_PD_CHANGE 49
+#define USB_PORT_CABLE_PD_RESET 50
+#define USB_DEVICE_CHARGING_POLICY 54
/**
* struct usb_ctrlrequest - SETUP data for a USB device control request
* through the Linux-USB APIs, they are not converted to cpu byte
* order; it is the responsibility of the client code to do this.
* The single exception is when device and configuration descriptors (but
- * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
+ * not other descriptors) are read from character devices
+ * (i.e. /dev/bus/usb/BBB/DDD);
* in this case the fields are converted to host endianness by the kernel.
*/
#define USB_DT_WIRE_ADAPTER 0x21
#define USB_DT_RPIPE 0x22
#define USB_DT_CS_RADIO_CONTROL 0x23
+/* From the T10 UAS specification */
+#define USB_DT_PIPE_USAGE 0x24
/* From the USB 3.0 spec */
#define USB_DT_SS_ENDPOINT_COMP 0x30
+/* From the USB 3.1 spec */
+#define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31
/* Conventional codes for class-specific descriptors. The convention is
* defined in the USB "Common Class" Spec (3.11). Individual class specs
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
#define USB_CLASS_VIDEO 0x0e
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
+#define USB_CLASS_PERSONAL_HEALTHCARE 0x0f
+#define USB_CLASS_AUDIO_VIDEO 0x10
+#define USB_CLASS_BILLBOARD 0x11
+#define USB_CLASS_USB_TYPE_C_BRIDGE 0x12
#define USB_CLASS_MISC 0xef
#define USB_CLASS_APP_SPEC 0xfe
#define USB_CLASS_VENDOR_SPEC 0xff
/*-------------------------------------------------------------------------*/
+/* USB String descriptors can contain at most 126 characters. */
+#define USB_MAX_STRING_LEN 126
+
/* USB_DT_STRING: String descriptor */
struct usb_string_descriptor {
__u8 bLength;
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
#define USB_ENDPOINT_DIR_MASK 0x80
-#define USB_ENDPOINT_SYNCTYPE 0x0c
-#define USB_ENDPOINT_SYNC_NONE (0 << 2)
-#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
-#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
-#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
-
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
#define USB_ENDPOINT_XFER_CONTROL 0
#define USB_ENDPOINT_XFER_ISOC 1
#define USB_ENDPOINT_XFER_INT 3
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
+#define USB_ENDPOINT_MAXP_MASK 0x07ff
+#define USB_EP_MAXP_MULT_SHIFT 11
+#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT)
+#define USB_EP_MAXP_MULT(m) \
+ (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT)
+
+/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
+#define USB_ENDPOINT_INTRTYPE 0x30
+#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
+#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
+
+#define USB_ENDPOINT_SYNCTYPE 0x0c
+#define USB_ENDPOINT_SYNC_NONE (0 << 2)
+#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
+#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
+#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
+
+#define USB_ENDPOINT_USAGE_MASK 0x30
+#define USB_ENDPOINT_USAGE_DATA 0x00
+#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
+#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */
+
/*-------------------------------------------------------------------------*/
/**
static inline int usb_endpoint_xfer_isoc(
const struct usb_endpoint_descriptor *epd)
{
- return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
- USB_ENDPOINT_XFER_ISOC;
+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
+ USB_ENDPOINT_XFER_ISOC);
}
/**
return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
}
+/**
+ * usb_endpoint_maxp - get endpoint's max packet size
+ * @epd: endpoint to be checked
+ *
+ * Returns @epd's max packet bits [10:0]
+ */
+static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
+{
+ return le16_to_cpu(epd->wMaxPacketSize) & USB_ENDPOINT_MAXP_MASK;
+}
+
+/**
+ * usb_endpoint_maxp_mult - get endpoint's transactional opportunities
+ * @epd: endpoint to be checked
+ *
+ * Return @epd's wMaxPacketSize[12:11] + 1
+ */
+static inline int
+usb_endpoint_maxp_mult(const struct usb_endpoint_descriptor *epd)
+{
+ int maxp = le16_to_cpu(epd->wMaxPacketSize);
+
+ return USB_EP_MAXP_MULT(maxp) + 1;
+}
+
+static inline int usb_endpoint_interrupt_type(
+ const struct usb_endpoint_descriptor *epd)
+{
+ return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* USB_DT_SSP_ISOC_ENDPOINT_COMP: SuperSpeedPlus Isochronous Endpoint Companion
+ * descriptor
+ */
+struct usb_ssp_isoc_ep_comp_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __le16 wReseved;
+ __le32 dwBytesPerInterval;
+} __attribute__ ((packed));
+
+#define USB_DT_SSP_ISOC_EP_COMP_SIZE 8
+
/*-------------------------------------------------------------------------*/
/* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
#define USB_DT_SS_EP_COMP_SIZE 6
+/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
+static inline int
+usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
+{
+ int max_streams;
+
+ if (!comp)
+ return 0;
+
+ max_streams = comp->bmAttributes & 0x1f;
+
+ if (!max_streams)
+ return 0;
+
+ max_streams = 1 << max_streams;
+
+ return max_streams;
+}
+
+/* Bits 1:0 of bmAttributes if this is an isoc endpoint */
+#define USB_SS_MULT(p) (1 + ((p) & 0x3))
+/* Bit 7 of bmAttributes if a SSP isoc endpoint companion descriptor exists */
+#define USB_SS_SSP_ISOC_COMP(p) ((p) & (1 << 7))
+
/*-------------------------------------------------------------------------*/
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
__u8 bmAttributes; /* support for HNP, SRP, etc */
} __attribute__ ((packed));
+/* USB_DT_OTG (from OTG 2.0 supplement) */
+struct usb_otg20_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+
+ __u8 bmAttributes; /* support for HNP, SRP and ADP, etc */
+ __le16 bcdOTG; /* OTG and EH supplement release number
+ * in binary-coded decimal(i.e. 2.0 is 0200H)
+ */
+} __attribute__ ((packed));
+
/* from usb_otg_descriptor.bmAttributes */
#define USB_OTG_SRP (1 << 0)
#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
+#define USB_OTG_ADP (1 << 2) /* support ADP */
+#define OTG_STS_SELECTOR 0xF000 /* OTG status selector */
/*-------------------------------------------------------------------------*/
/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
__u8 iFunction;
} __attribute__ ((packed));
+#define USB_DT_INTERFACE_ASSOCIATION_SIZE 8
/*-------------------------------------------------------------------------*/
__u8 bNumDeviceCaps;
} __attribute__((packed));
+#define USB_DT_BOS_SIZE 5
/*-------------------------------------------------------------------------*/
/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
__u8 bReserved;
} __attribute__((packed));
+#define USB_DT_USB_WIRELESS_CAP_SIZE 11
+
+/* USB 2.0 Extension descriptor */
#define USB_CAP_TYPE_EXT 2
struct usb_ext_cap_descriptor { /* Link Power Management */
__u8 bLength;
__u8 bDescriptorType;
__u8 bDevCapabilityType;
- __u8 bmAttributes;
+ __le32 bmAttributes;
#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
+#define USB_BESL_SUPPORT (1 << 2) /* supports BESL */
+#define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/
+#define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */
+#define USB_SET_BESL_BASELINE(p) (((p) & 0xf) << 8)
+#define USB_SET_BESL_DEEP(p) (((p) & 0xf) << 12)
+#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
+#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
+} __attribute__((packed));
+
+#define USB_DT_USB_EXT_CAP_SIZE 7
+
+/*
+ * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
+ * specific device level capabilities
+ */
+#define USB_SS_CAP_TYPE 3
+struct usb_ss_cap_descriptor { /* Link Power Management */
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+ __u8 bmAttributes;
+#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
+ __le16 wSpeedSupported;
+#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
+#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
+#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
+#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
+ __u8 bFunctionalitySupport;
+ __u8 bU1devExitLat;
+ __le16 bU2DevExitLat;
+} __attribute__((packed));
+
+#define USB_DT_USB_SS_CAP_SIZE 10
+
+/*
+ * Container ID Capability descriptor: Defines the instance unique ID used to
+ * identify the instance across all operating modes
+ */
+#define CONTAINER_ID_TYPE 4
+struct usb_ss_container_id_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+ __u8 bReserved;
+ __u8 ContainerID[16]; /* 128-bit number */
} __attribute__((packed));
+#define USB_DT_USB_SS_CONTN_ID_SIZE 20
+
+/*
+ * SuperSpeed Plus USB Capability descriptor: Defines the set of
+ * SuperSpeed Plus USB specific device level capabilities
+ */
+#define USB_SSP_CAP_TYPE 0xa
+struct usb_ssp_cap_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+ __u8 bReserved;
+ __le32 bmAttributes;
+#define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0) /* sublink speed entries */
+#define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5) /* speed ID entries */
+ __le16 wFunctionalitySupport;
+#define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf)
+#define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
+#define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
+ __le16 wReserved;
+ __le32 bmSublinkSpeedAttr[1]; /* list of sublink speed attrib entries */
+#define USB_SSP_SUBLINK_SPEED_SSID (0xf) /* sublink speed ID */
+#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4) /* Lanespeed exponent */
+#define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6) /* Sublink type */
+#define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8) /* Reserved */
+#define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14) /* Link protocol */
+#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16) /* Lanespeed mantissa */
+} __attribute__((packed));
+
+/*
+ * USB Power Delivery Capability Descriptor:
+ * Defines capabilities for PD
+ */
+/* Defines the various PD Capabilities of this device */
+#define USB_PD_POWER_DELIVERY_CAPABILITY 0x06
+/* Provides information on each battery supported by the device */
+#define USB_PD_BATTERY_INFO_CAPABILITY 0x07
+/* The Consumer characteristics of a Port on the device */
+#define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08
+/* The provider characteristics of a Port on the device */
+#define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09
+
+struct usb_pd_cap_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType; /* set to USB_PD_POWER_DELIVERY_CAPABILITY */
+ __u8 bReserved;
+ __le32 bmAttributes;
+#define USB_PD_CAP_BATTERY_CHARGING (1 << 1) /* supports Battery Charging specification */
+#define USB_PD_CAP_USB_PD (1 << 2) /* supports USB Power Delivery specification */
+#define USB_PD_CAP_PROVIDER (1 << 3) /* can provide power */
+#define USB_PD_CAP_CONSUMER (1 << 4) /* can consume power */
+#define USB_PD_CAP_CHARGING_POLICY (1 << 5) /* supports CHARGING_POLICY feature */
+#define USB_PD_CAP_TYPE_C_CURRENT (1 << 6) /* supports power capabilities defined in the USB Type-C Specification */
+
+#define USB_PD_CAP_PWR_AC (1 << 8)
+#define USB_PD_CAP_PWR_BAT (1 << 9)
+#define USB_PD_CAP_PWR_USE_V_BUS (1 << 14)
+
+ __le16 bmProviderPorts; /* Bit zero refers to the UFP of the device */
+ __le16 bmConsumerPorts;
+ __le16 bcdBCVersion;
+ __le16 bcdPDVersion;
+ __le16 bcdUSBTypeCVersion;
+} __attribute__((packed));
+
+struct usb_pd_cap_battery_info_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+ /* Index of string descriptor shall contain the user friendly name for this battery */
+ __u8 iBattery;
+ /* Index of string descriptor shall contain the Serial Number String for this battery */
+ __u8 iSerial;
+ __u8 iManufacturer;
+ __u8 bBatteryId; /* uniquely identifies this battery in status Messages */
+ __u8 bReserved;
+ /*
+ * Shall contain the Battery Charge value above which this
+ * battery is considered to be fully charged but not necessarily
+ * “topped off.”
+ */
+ __le32 dwChargedThreshold; /* in mWh */
+ /*
+ * Shall contain the minimum charge level of this battery such
+ * that above this threshold, a device can be assured of being
+ * able to power up successfully (see Battery Charging 1.2).
+ */
+ __le32 dwWeakThreshold; /* in mWh */
+ __le32 dwBatteryDesignCapacity; /* in mWh */
+ __le32 dwBatteryLastFullchargeCapacity; /* in mWh */
+} __attribute__((packed));
+
+struct usb_pd_cap_consumer_port_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+ __u8 bReserved;
+ __u8 bmCapabilities;
+/* port will oerate under: */
+#define USB_PD_CAP_CONSUMER_BC (1 << 0) /* BC */
+#define USB_PD_CAP_CONSUMER_PD (1 << 1) /* PD */
+#define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2) /* USB Type-C Current */
+ __le16 wMinVoltage; /* in 50mV units */
+ __le16 wMaxVoltage; /* in 50mV units */
+ __u16 wReserved;
+ __le32 dwMaxOperatingPower; /* in 10 mW - operating at steady state */
+ __le32 dwMaxPeakPower; /* in 10mW units - operating at peak power */
+ __le32 dwMaxPeakPowerTime; /* in 100ms units - duration of peak */
+#define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff
+} __attribute__((packed));
+
+struct usb_pd_cap_provider_port_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+ __u8 bReserved1;
+ __u8 bmCapabilities;
+/* port will oerate under: */
+#define USB_PD_CAP_PROVIDER_BC (1 << 0) /* BC */
+#define USB_PD_CAP_PROVIDER_PD (1 << 1) /* PD */
+#define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2) /* USB Type-C Current */
+ __u8 bNumOfPDObjects;
+ __u8 bReserved2;
+ __le32 wPowerDataObject[];
+} __attribute__((packed));
+
+/*
+ * Precision time measurement capability descriptor: advertised by devices and
+ * hubs that support PTM
+ */
+#define USB_PTM_CAP_TYPE 0xb
+struct usb_ptm_cap_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+} __attribute__((packed));
+
+#define USB_DT_USB_PTM_ID_SIZE 3
+/*
+ * The size of the descriptor for the Sublink Speed Attribute Count
+ * (SSAC) specified in bmAttributes[4:0]. SSAC is zero-based
+ */
+#define USB_DT_USB_SSP_CAP_SIZE(ssac) (12 + (ssac + 1) * 4)
+
/*-------------------------------------------------------------------------*/
/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
USB_SPEED_HIGH, /* usb 2.0 */
USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
USB_SPEED_SUPER, /* usb 3.0 */
+ USB_SPEED_SUPER_PLUS, /* usb 3.1 */
};
+
enum usb_device_state {
/* NOTATTACHED isn't in the USB spec, and this state acts
* the same as ATTACHED ... but it's clearer this way.
*/
};
+enum usb3_link_state {
+ USB3_LPM_U0 = 0,
+ USB3_LPM_U1,
+ USB3_LPM_U2,
+ USB3_LPM_U3
+};
+
+/*
+ * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
+ * 0xff means the parent hub will accept transitions to U1, but will not
+ * initiate a transition.
+ *
+ * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
+ * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved
+ * values.
+ *
+ * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
+ * 0xff means the parent hub will accept transitions to U2, but will not
+ * initiate a transition.
+ *
+ * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
+ * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2
+ * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
+ * 65.024ms.
+ */
+#define USB3_LPM_DISABLED 0x0
+#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
+#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
+#define USB3_LPM_DEVICE_INITIATED 0xFF
+
+struct usb_set_sel_req {
+ __u8 u1_sel;
+ __u8 u1_pel;
+ __le16 u2_sel;
+ __le16 u2_pel;
+} __attribute__ ((packed));
+
+/*
+ * The Set System Exit Latency control transfer provides one byte each for
+ * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each
+ * are two bytes long.
+ */
+#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
+#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
+
+/*-------------------------------------------------------------------------*/
+
+/*
+ * As per USB compliance update, a device that is actively drawing
+ * more than 100mA from USB must report itself as bus-powered in
+ * the GetStatus(DEVICE) call.
+ * https://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
+ */
+#define USB_SELF_POWER_VBUS_MAX_DRAW 100
+
#endif /* __LINUX_USB_CH9_H */
#define __in_section(s) __attribute__((section("." # s)))
#define __visible __attribute__((externally_visible))
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+
+
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
return !ptr || IS_ERR_VALUE((unsigned long)ptr);
}
+static inline unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = w - ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res + (res >> 4)) & 0x0F;
+}
+
+static inline unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = w - ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res + (res >> 4)) & 0x0F0F;
+ return (res + (res >> 8)) & 0x00FF;
+}
+
+/**
+ * DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
+ *
+ * @TYPE: The type of each flexible array element
+ * @NAME: The name of the flexible array member
+ *
+ * In order to have a flexible array member in a union or alone in a
+ * struct, it needs to be wrapped in an anonymous struct with at least 1
+ * named member, but that member can be empty.
+ */
+#define DECLARE_FLEX_ARRAY(TYPE, NAME) \
+ struct { \
+ struct { } __empty_ ## NAME; \
+ TYPE NAME[]; \
+ }
+
+#define __bf_shf(x) (__builtin_ffsll(x) - 1)
+
+#define FIELD_MAX(_mask) \
+ ({ \
+ (typeof(_mask))((_mask) >> __bf_shf(_mask)); \
+ })
+
#endif /* __SHARED_COMPILER_H */
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* IEEE 802.11 defines
*
* Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
* Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH
* Copyright (c) 2016 - 2017 Intel Deutschland GmbH
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * Copyright (c) 2018 - 2022 Intel Corporation
*/
#ifndef __LINUX_IEEE80211_H
/* extension, added by 802.11ad */
#define IEEE80211_STYPE_DMG_BEACON 0x0000
+#define IEEE80211_STYPE_S1G_BEACON 0x0010
+
+/* bits unique to S1G beacon */
+#define IEEE80211_S1G_BCN_NEXT_TBTT 0x100
+
+/* see 802.11ah-2016 9.9 NDP CMAC frames */
+#define IEEE80211_S1G_1MHZ_NDP_BITS 25
+#define IEEE80211_S1G_1MHZ_NDP_BYTES 4
+#define IEEE80211_S1G_2MHZ_NDP_BITS 37
+#define IEEE80211_S1G_2MHZ_NDP_BYTES 5
+
+#define IEEE80211_NDP_FTYPE_CTS 0
+#define IEEE80211_NDP_FTYPE_CF_END 0
+#define IEEE80211_NDP_FTYPE_PS_POLL 1
+#define IEEE80211_NDP_FTYPE_ACK 2
+#define IEEE80211_NDP_FTYPE_PS_POLL_ACK 3
+#define IEEE80211_NDP_FTYPE_BA 4
+#define IEEE80211_NDP_FTYPE_BF_REPORT_POLL 5
+#define IEEE80211_NDP_FTYPE_PAGING 6
+#define IEEE80211_NDP_FTYPE_PREQ 7
+
+#define SM64(f, v) ((((u64)v) << f##_S) & f)
+
+/* NDP CMAC frame fields */
+#define IEEE80211_NDP_FTYPE 0x0000000000000007
+#define IEEE80211_NDP_FTYPE_S 0x0000000000000000
+
+/* 1M Probe Request 11ah 9.9.3.1.1 */
+#define IEEE80211_NDP_1M_PREQ_ANO 0x0000000000000008
+#define IEEE80211_NDP_1M_PREQ_ANO_S 3
+#define IEEE80211_NDP_1M_PREQ_CSSID 0x00000000000FFFF0
+#define IEEE80211_NDP_1M_PREQ_CSSID_S 4
+#define IEEE80211_NDP_1M_PREQ_RTYPE 0x0000000000100000
+#define IEEE80211_NDP_1M_PREQ_RTYPE_S 20
+#define IEEE80211_NDP_1M_PREQ_RSV 0x0000000001E00000
+#define IEEE80211_NDP_1M_PREQ_RSV 0x0000000001E00000
+/* 2M Probe Request 11ah 9.9.3.1.2 */
+#define IEEE80211_NDP_2M_PREQ_ANO 0x0000000000000008
+#define IEEE80211_NDP_2M_PREQ_ANO_S 3
+#define IEEE80211_NDP_2M_PREQ_CSSID 0x0000000FFFFFFFF0
+#define IEEE80211_NDP_2M_PREQ_CSSID_S 4
+#define IEEE80211_NDP_2M_PREQ_RTYPE 0x0000001000000000
+#define IEEE80211_NDP_2M_PREQ_RTYPE_S 36
+
+#define IEEE80211_ANO_NETTYPE_WILD 15
+
+/* bits unique to S1G beacon */
+#define IEEE80211_S1G_BCN_NEXT_TBTT 0x100
/* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
#define IEEE80211_CTL_EXT_POLL 0x2000
#define IEEE80211_MAX_SN IEEE80211_SN_MASK
#define IEEE80211_SN_MODULO (IEEE80211_MAX_SN + 1)
+
+/* PV1 Layout 11ah 9.8.3.1 */
+#define IEEE80211_PV1_FCTL_VERS 0x0003
+#define IEEE80211_PV1_FCTL_FTYPE 0x001c
+#define IEEE80211_PV1_FCTL_STYPE 0x00e0
+#define IEEE80211_PV1_FCTL_TODS 0x0100
+#define IEEE80211_PV1_FCTL_MOREFRAGS 0x0200
+#define IEEE80211_PV1_FCTL_PM 0x0400
+#define IEEE80211_PV1_FCTL_MOREDATA 0x0800
+#define IEEE80211_PV1_FCTL_PROTECTED 0x1000
+#define IEEE80211_PV1_FCTL_END_SP 0x2000
+#define IEEE80211_PV1_FCTL_RELAYED 0x4000
+#define IEEE80211_PV1_FCTL_ACK_POLICY 0x8000
+#define IEEE80211_PV1_FCTL_CTL_EXT 0x0f00
+
static inline bool ieee80211_sn_less(u16 sn1, u16 sn2)
{
return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1);
#define IEEE80211_MAX_FRAG_THRESHOLD 2352
#define IEEE80211_MAX_RTS_THRESHOLD 2353
#define IEEE80211_MAX_AID 2007
+#define IEEE80211_MAX_AID_S1G 8191
#define IEEE80211_MAX_TIM_LEN 251
#define IEEE80211_MAX_MESH_PEERINGS 63
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
cpu_to_le16(IEEE80211_FTYPE_DATA);
}
+/**
+ * ieee80211_is_ext - check if type is IEEE80211_FTYPE_EXT
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_is_ext(__le16 fc)
+{
+ return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
+ cpu_to_le16(IEEE80211_FTYPE_EXT);
+}
+
+
/**
* ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
* @fc: frame control bytes in little-endian byteorder
cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
}
+/**
+ * ieee80211_is_s1g_beacon - check if IEEE80211_FTYPE_EXT &&
+ * IEEE80211_STYPE_S1G_BEACON
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_is_s1g_beacon(__le16 fc)
+{
+ return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE |
+ IEEE80211_FCTL_STYPE)) ==
+ cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON);
+}
+
+/**
+ * ieee80211_next_tbtt_present - check if IEEE80211_FTYPE_EXT &&
+ * IEEE80211_STYPE_S1G_BEACON && IEEE80211_S1G_BCN_NEXT_TBTT
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_next_tbtt_present(__le16 fc)
+{
+ return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
+ cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON) &&
+ fc & cpu_to_le16(IEEE80211_S1G_BCN_NEXT_TBTT);
+}
+
+/**
+ * ieee80211_is_s1g_short_beacon - check if next tbtt present bit is set. Only
+ * true for S1G beacons when they're short.
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_is_s1g_short_beacon(__le16 fc)
+{
+ return ieee80211_is_s1g_beacon(fc) && ieee80211_next_tbtt_present(fc);
+}
+
/**
* ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
* @fc: frame control bytes in little-endian byteorder
return hdrlen;
}
+/**
+ * ieee80211_is_any_nullfunc - check if frame is regular or QoS nullfunc frame
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee80211_is_any_nullfunc(__le16 fc)
+{
+ return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
+}
+
/**
* ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
* @fc: frame control field in little-endian byteorder
u8 token;
u8 mode;
u8 type;
- u8 request[0];
+ u8 request[];
} __packed;
/**
IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING = 0x20,
};
+#define IEEE80211_MESHCONF_FORM_CONNECTED_TO_GATE 0x1
+
/**
* mesh channel switch parameters element's flag indicator
*
* @IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: 40 MHz channel width
* @IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: 80 MHz channel width
* @IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: 160 MHz or 80+80 MHz channel width
+ * @IEEE80211_OPMODE_NOTIF_BW_160_80P80: 160 / 80+80 MHz indicator flag
* @IEEE80211_OPMODE_NOTIF_RX_NSS_MASK: number of spatial streams mask
* (the NSS value is the value of this field + 1)
* @IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT: number of spatial streams shift
* using a beamforming steering matrix
*/
enum ieee80211_vht_opmode_bits {
- IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 3,
+ IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 0x03,
IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ = 0,
IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ = 1,
IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ = 2,
IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3,
+ IEEE80211_OPMODE_NOTIF_BW_160_80P80 = 0x04,
IEEE80211_OPMODE_NOTIF_RX_NSS_MASK = 0x70,
IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4,
IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 0x80,
};
+/**
+ * enum ieee80211_s1g_chanwidth
+ * These are defined in IEEE802.11-2016ah Table 10-20
+ * as BSS Channel Width
+ *
+ * @IEEE80211_S1G_CHANWIDTH_1MHZ: 1MHz operating channel
+ * @IEEE80211_S1G_CHANWIDTH_2MHZ: 2MHz operating channel
+ * @IEEE80211_S1G_CHANWIDTH_4MHZ: 4MHz operating channel
+ * @IEEE80211_S1G_CHANWIDTH_8MHZ: 8MHz operating channel
+ * @IEEE80211_S1G_CHANWIDTH_16MHZ: 16MHz operating channel
+ */
+enum ieee80211_s1g_chanwidth {
+ IEEE80211_S1G_CHANWIDTH_1MHZ = 0,
+ IEEE80211_S1G_CHANWIDTH_2MHZ = 1,
+ IEEE80211_S1G_CHANWIDTH_4MHZ = 3,
+ IEEE80211_S1G_CHANWIDTH_8MHZ = 7,
+ IEEE80211_S1G_CHANWIDTH_16MHZ = 15,
+};
+
#define WLAN_SA_QUERY_TR_ID_LEN 2
#define WLAN_MEMBERSHIP_LEN 8
#define WLAN_USER_POSITION_LEN 16
u8 link_margin;
} __packed;
+#define IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK GENMASK(2, 1)
+#define IEEE80211_ADDBA_EXT_FRAG_LEVEL_SHIFT 1
+#define IEEE80211_ADDBA_EXT_NO_FRAG BIT(0)
+#define IEEE80211_ADDBA_EXT_BUF_SIZE_MASK GENMASK(7, 5)
+#define IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT 10
+
+struct ieee80211_addba_ext_ie {
+ u8 data;
+} __packed;
+
+/**
+ * struct ieee80211_s1g_bcn_compat_ie
+ *
+ * S1G Beacon Compatibility element
+ */
+struct ieee80211_s1g_bcn_compat_ie {
+ __le16 compat_info;
+ __le16 beacon_int;
+ __le32 tsf_completion;
+} __packed;
+
+/**
+ * struct ieee80211_s1g_oper_ie
+ *
+ * S1G Operation element
+ */
+struct ieee80211_s1g_oper_ie {
+ u8 ch_width;
+ u8 oper_class;
+ u8 primary_ch;
+ u8 oper_ch;
+ __le16 basic_mcs_nss;
+} __packed;
+
+/**
+ * struct ieee80211_aid_response_ie
+ *
+ * AID Response element
+ */
+struct ieee80211_aid_response_ie {
+ __le16 aid;
+ u8 switch_count;
+ __le16 response_int;
+} __packed;
+
+struct ieee80211_s1g_cap {
+ u8 capab_info[10];
+ u8 supp_mcs_nss[5];
+} __packed;
+
+struct ieee80211_ext {
+ __le16 frame_control;
+ __le16 duration;
+ union {
+ struct {
+ u8 sa[6];
+ __le32 timestamp;
+ u8 change_seq;
+ u8 variable[0];
+ } __packed s1g_beacon;
+ struct {
+ u8 sa[6];
+ __le32 timestamp;
+ u8 change_seq;
+ u8 next_tbtt[3];
+ u8 variable[0];
+ } __packed s1g_short_beacon;
+ } u;
+} __packed __aligned(2);
+
+#define IEEE80211_TWT_CONTROL_NDP BIT(0)
+#define IEEE80211_TWT_CONTROL_RESP_MODE BIT(1)
+#define IEEE80211_TWT_CONTROL_NEG_TYPE_BROADCAST BIT(3)
+#define IEEE80211_TWT_CONTROL_RX_DISABLED BIT(4)
+#define IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT BIT(5)
+
+#define IEEE80211_TWT_REQTYPE_REQUEST BIT(0)
+#define IEEE80211_TWT_REQTYPE_SETUP_CMD GENMASK(3, 1)
+#define IEEE80211_TWT_REQTYPE_TRIGGER BIT(4)
+#define IEEE80211_TWT_REQTYPE_IMPLICIT BIT(5)
+#define IEEE80211_TWT_REQTYPE_FLOWTYPE BIT(6)
+#define IEEE80211_TWT_REQTYPE_FLOWID GENMASK(9, 7)
+#define IEEE80211_TWT_REQTYPE_WAKE_INT_EXP GENMASK(14, 10)
+#define IEEE80211_TWT_REQTYPE_PROTECTION BIT(15)
+
+enum ieee80211_twt_setup_cmd {
+ TWT_SETUP_CMD_REQUEST,
+ TWT_SETUP_CMD_SUGGEST,
+ TWT_SETUP_CMD_DEMAND,
+ TWT_SETUP_CMD_GROUPING,
+ TWT_SETUP_CMD_ACCEPT,
+ TWT_SETUP_CMD_ALTERNATE,
+ TWT_SETUP_CMD_DICTATE,
+ TWT_SETUP_CMD_REJECT,
+};
+
+struct ieee80211_twt_params {
+ __le16 req_type;
+ __le64 twt;
+ u8 min_twt_dur;
+ __le16 mantissa;
+ u8 channel;
+} __packed;
+
+struct ieee80211_twt_setup {
+ u8 dialog_token;
+ u8 element_id;
+ u8 length;
+ u8 control;
+ u8 params[];
+} __packed;
+
struct ieee80211_mgmt {
__le16 frame_control;
__le16 duration;
__le16 auth_transaction;
__le16 status_code;
/* possibly followed by Challenge text */
- u8 variable[0];
+ u8 variable[];
} __packed __aligned(4) auth;
struct {
__le16 reason_code;
__le16 capab_info;
__le16 listen_interval;
/* followed by SSID and Supported rates */
- u8 variable[0];
+ u8 variable[];
} __packed __aligned(4) assoc_req;
struct {
__le16 capab_info;
__le16 status_code;
__le16 aid;
/* followed by Supported rates */
- u8 variable[0];
+ u8 variable[];
} __packed __aligned(4) assoc_resp, reassoc_resp;
+ struct {
+ __le16 capab_info;
+ __le16 status_code;
+ u8 variable[];
+ } __packed __aligned(4) s1g_assoc_resp, s1g_reassoc_resp;
struct {
__le16 capab_info;
__le16 listen_interval;
u8 current_ap[6];
/* followed by SSID and Supported rates */
- u8 variable[0];
+ u8 variable[];
} __packed __aligned(4) reassoc_req;
struct {
__le16 reason_code;
__le16 capab_info;
/* followed by some of SSID, Supported rates,
* FH Params, DS Params, CF Params, IBSS Params, TIM */
- u8 variable[0];
+ u8 variable[];
} __packed __aligned(4) beacon;
struct {
/* only variable items: SSID, Supported rates */
- u8 variable[0];
+ DECLARE_FLEX_ARRAY(u8, variable);
} __packed __aligned(4) probe_req;
struct {
__le64 timestamp;
__le16 capab_info;
/* followed by some of SSID, Supported rates,
* FH Params, DS Params, CF Params, IBSS Params */
- u8 variable[0];
+ u8 variable[];
} __packed __aligned(4) probe_resp;
struct {
u8 category;
u8 action_code;
u8 dialog_token;
u8 status_code;
- u8 variable[0];
+ u8 variable[];
} __packed wme_action;
struct{
u8 action_code;
- u8 variable[0];
+ u8 variable[];
} __packed chan_switch;
struct{
u8 action_code;
struct ieee80211_ext_chansw_ie data;
- u8 variable[0];
+ u8 variable[];
} __packed ext_chan_switch;
struct{
u8 action_code;
__le16 capab;
__le16 timeout;
__le16 start_seq_num;
+ /* followed by BA Extension */
+ u8 variable[];
} __packed addba_req;
struct{
u8 action_code;
} __packed delba;
struct {
u8 action_code;
- u8 variable[0];
+ u8 variable[];
} __packed self_prot;
struct{
u8 action_code;
- u8 variable[0];
+ u8 variable[];
} __packed mesh_action;
struct {
u8 action;
u8 toa[6];
__le16 tod_error;
__le16 toa_error;
- u8 variable[0];
+ u8 variable[];
} __packed ftm;
+ struct {
+ u8 action_code;
+ u8 variable[];
+ } __packed s1g;
} u;
} __packed __aligned(4) action;
} u __aligned(2);
/* Supported rates membership selectors */
#define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
#define BSS_MEMBERSHIP_SELECTOR_VHT_PHY 126
+#define BSS_MEMBERSHIP_SELECTOR_HE_PHY 122
+#define BSS_MEMBERSHIP_SELECTOR_SAE_H2E 123
/* mgmt header + 1 byte category code */
#define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
/*
- * A-PMDU buffer sizes
- * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
+ * A-MPDU buffer sizes
+ * According to HT size varies from 8 to 64 frames
+ * HE adds the ability to have up to 256 frames.
+ * EHT adds the ability to have up to 1K frames.
*/
-#define IEEE80211_MIN_AMPDU_BUF 0x8
-#define IEEE80211_MAX_AMPDU_BUF 0x40
+#define IEEE80211_MIN_AMPDU_BUF 0x8
+#define IEEE80211_MAX_AMPDU_BUF_HT 0x40
+#define IEEE80211_MAX_AMPDU_BUF_HE 0x100
+#define IEEE80211_MAX_AMPDU_BUF_EHT 0x400
/* Spatial Multiplexing Power Save Modes (for capability) */
* STA can receive. Rate expressed in units of 1 Mbps.
* If this field is 0 this value should not be used to
* consider the highest RX data rate supported.
- * The top 3 bits of this field are reserved.
+ * The top 3 bits of this field indicate the Maximum NSTS,total
+ * (a beamformee capability.)
* @tx_mcs_map: TX MCS map 2 bits for each stream, total 8 streams
* @tx_highest: Indicates highest long GI VHT PPDU data rate
* STA can transmit. Rate expressed in units of 1 Mbps.
* If this field is 0 this value should not be used to
* consider the highest TX data rate supported.
- * The top 3 bits of this field are reserved.
+ * The top 2 bits of this field are reserved, the
+ * 3rd bit from the top indiciates VHT Extended NSS BW
+ * Capability.
*/
struct ieee80211_vht_mcs_info {
__le16 rx_mcs_map;
__le16 tx_highest;
} __packed;
+/* for rx_highest */
+#define IEEE80211_VHT_MAX_NSTS_TOTAL_SHIFT 13
+#define IEEE80211_VHT_MAX_NSTS_TOTAL_MASK (7 << IEEE80211_VHT_MAX_NSTS_TOTAL_SHIFT)
+
+/* for tx_highest */
+#define IEEE80211_VHT_EXT_NSS_BW_CAPABLE (1 << 13)
+
/**
* enum ieee80211_vht_mcs_support - VHT MCS support definitions
* @IEEE80211_VHT_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
__le16 basic_mcs_set;
} __packed;
+/**
+ * struct ieee80211_he_cap_elem - HE capabilities element
+ *
+ * This structure is the "HE capabilities element" fixed fields as
+ * described in P802.11ax_D4.0 section 9.4.2.242.2 and 9.4.2.242.3
+ */
+struct ieee80211_he_cap_elem {
+ u8 mac_cap_info[6];
+ u8 phy_cap_info[11];
+} __packed;
+
+#define IEEE80211_TX_RX_MCS_NSS_DESC_MAX_LEN 5
+
+/**
+ * enum ieee80211_he_mcs_support - HE MCS support definitions
+ * @IEEE80211_HE_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
+ * number of streams
+ * @IEEE80211_HE_MCS_SUPPORT_0_9: MCSes 0-9 are supported
+ * @IEEE80211_HE_MCS_SUPPORT_0_11: MCSes 0-11 are supported
+ * @IEEE80211_HE_MCS_NOT_SUPPORTED: This number of streams isn't supported
+ *
+ * These definitions are used in each 2-bit subfield of the rx_mcs_*
+ * and tx_mcs_* fields of &struct ieee80211_he_mcs_nss_supp, which are
+ * both split into 8 subfields by number of streams. These values indicate
+ * which MCSes are supported for the number of streams the value appears
+ * for.
+ */
+enum ieee80211_he_mcs_support {
+ IEEE80211_HE_MCS_SUPPORT_0_7 = 0,
+ IEEE80211_HE_MCS_SUPPORT_0_9 = 1,
+ IEEE80211_HE_MCS_SUPPORT_0_11 = 2,
+ IEEE80211_HE_MCS_NOT_SUPPORTED = 3,
+};
+
+/**
+ * struct ieee80211_he_mcs_nss_supp - HE Tx/Rx HE MCS NSS Support Field
+ *
+ * This structure holds the data required for the Tx/Rx HE MCS NSS Support Field
+ * described in P802.11ax_D2.0 section 9.4.2.237.4
+ *
+ * @rx_mcs_80: Rx MCS map 2 bits for each stream, total 8 streams, for channel
+ * widths less than 80MHz.
+ * @tx_mcs_80: Tx MCS map 2 bits for each stream, total 8 streams, for channel
+ * widths less than 80MHz.
+ * @rx_mcs_160: Rx MCS map 2 bits for each stream, total 8 streams, for channel
+ * width 160MHz.
+ * @tx_mcs_160: Tx MCS map 2 bits for each stream, total 8 streams, for channel
+ * width 160MHz.
+ * @rx_mcs_80p80: Rx MCS map 2 bits for each stream, total 8 streams, for
+ * channel width 80p80MHz.
+ * @tx_mcs_80p80: Tx MCS map 2 bits for each stream, total 8 streams, for
+ * channel width 80p80MHz.
+ */
+struct ieee80211_he_mcs_nss_supp {
+ __le16 rx_mcs_80;
+ __le16 tx_mcs_80;
+ __le16 rx_mcs_160;
+ __le16 tx_mcs_160;
+ __le16 rx_mcs_80p80;
+ __le16 tx_mcs_80p80;
+} __packed;
+
+/**
+ * struct ieee80211_he_operation - HE capabilities element
+ *
+ * This structure is the "HE operation element" fields as
+ * described in P802.11ax_D4.0 section 9.4.2.243
+ */
+struct ieee80211_he_operation {
+ __le32 he_oper_params;
+ __le16 he_mcs_nss_set;
+ /* Optional 0,1,3,4,5,7 or 8 bytes: depends on @he_oper_params */
+ u8 optional[];
+} __packed;
+
+/**
+ * struct ieee80211_he_spr - HE spatial reuse element
+ *
+ * This structure is the "HE spatial reuse element" element as
+ * described in P802.11ax_D4.0 section 9.4.2.241
+ */
+struct ieee80211_he_spr {
+ u8 he_sr_control;
+ /* Optional 0 to 19 bytes: depends on @he_sr_control */
+ u8 optional[];
+} __packed;
+
+/**
+ * struct ieee80211_he_mu_edca_param_ac_rec - MU AC Parameter Record field
+ *
+ * This structure is the "MU AC Parameter Record" fields as
+ * described in P802.11ax_D4.0 section 9.4.2.245
+ */
+struct ieee80211_he_mu_edca_param_ac_rec {
+ u8 aifsn;
+ u8 ecw_min_max;
+ u8 mu_edca_timer;
+} __packed;
+
+/**
+ * struct ieee80211_mu_edca_param_set - MU EDCA Parameter Set element
+ *
+ * This structure is the "MU EDCA Parameter Set element" fields as
+ * described in P802.11ax_D4.0 section 9.4.2.245
+ */
+struct ieee80211_mu_edca_param_set {
+ u8 mu_qos_info;
+ struct ieee80211_he_mu_edca_param_ac_rec ac_be;
+ struct ieee80211_he_mu_edca_param_ac_rec ac_bk;
+ struct ieee80211_he_mu_edca_param_ac_rec ac_vi;
+ struct ieee80211_he_mu_edca_param_ac_rec ac_vo;
+} __packed;
+
+#define IEEE80211_EHT_MCS_NSS_RX 0x0f
+#define IEEE80211_EHT_MCS_NSS_TX 0xf0
+
+/**
+ * struct ieee80211_eht_mcs_nss_supp_20mhz_only - EHT 20MHz only station max
+ * supported NSS for per MCS.
+ *
+ * For each field below, bits 0 - 3 indicate the maximal number of spatial
+ * streams for Rx, and bits 4 - 7 indicate the maximal number of spatial streams
+ * for Tx.
+ *
+ * @rx_tx_mcs7_max_nss: indicates the maximum number of spatial streams
+ * supported for reception and the maximum number of spatial streams
+ * supported for transmission for MCS 0 - 7.
+ * @rx_tx_mcs9_max_nss: indicates the maximum number of spatial streams
+ * supported for reception and the maximum number of spatial streams
+ * supported for transmission for MCS 8 - 9.
+ * @rx_tx_mcs11_max_nss: indicates the maximum number of spatial streams
+ * supported for reception and the maximum number of spatial streams
+ * supported for transmission for MCS 10 - 11.
+ * @rx_tx_mcs13_max_nss: indicates the maximum number of spatial streams
+ * supported for reception and the maximum number of spatial streams
+ * supported for transmission for MCS 12 - 13.
+ */
+struct ieee80211_eht_mcs_nss_supp_20mhz_only {
+ u8 rx_tx_mcs7_max_nss;
+ u8 rx_tx_mcs9_max_nss;
+ u8 rx_tx_mcs11_max_nss;
+ u8 rx_tx_mcs13_max_nss;
+};
+
+/**
+ * struct ieee80211_eht_mcs_nss_supp_bw - EHT max supported NSS per MCS (except
+ * 20MHz only stations).
+ *
+ * For each field below, bits 0 - 3 indicate the maximal number of spatial
+ * streams for Rx, and bits 4 - 7 indicate the maximal number of spatial streams
+ * for Tx.
+ *
+ * @rx_tx_mcs9_max_nss: indicates the maximum number of spatial streams
+ * supported for reception and the maximum number of spatial streams
+ * supported for transmission for MCS 0 - 9.
+ * @rx_tx_mcs11_max_nss: indicates the maximum number of spatial streams
+ * supported for reception and the maximum number of spatial streams
+ * supported for transmission for MCS 10 - 11.
+ * @rx_tx_mcs13_max_nss: indicates the maximum number of spatial streams
+ * supported for reception and the maximum number of spatial streams
+ * supported for transmission for MCS 12 - 13.
+ */
+struct ieee80211_eht_mcs_nss_supp_bw {
+ u8 rx_tx_mcs9_max_nss;
+ u8 rx_tx_mcs11_max_nss;
+ u8 rx_tx_mcs13_max_nss;
+};
+
+/**
+ * struct ieee80211_eht_cap_elem_fixed - EHT capabilities fixed data
+ *
+ * This structure is the "EHT Capabilities element" fixed fields as
+ * described in P802.11be_D1.4 section 9.4.2.313.
+ *
+ * @mac_cap_info: MAC capabilities, see IEEE80211_EHT_MAC_CAP*
+ * @phy_cap_info: PHY capabilities, see IEEE80211_EHT_PHY_CAP*
+ */
+struct ieee80211_eht_cap_elem_fixed {
+ u8 mac_cap_info[2];
+ u8 phy_cap_info[9];
+} __packed;
+
+/**
+ * struct ieee80211_eht_cap_elem - EHT capabilities element
+ * @fixed: fixed parts, see &ieee80211_eht_cap_elem_fixed
+ * @optional: optional parts
+ */
+struct ieee80211_eht_cap_elem {
+ struct ieee80211_eht_cap_elem_fixed fixed;
+
+ /*
+ * Followed by:
+ * Supported EHT-MCS And NSS Set field: 4, 3, 6 or 9 octets.
+ * EHT PPE Thresholds field: variable length.
+ */
+ u8 optional[];
+} __packed;
+
+/**
+ * struct ieee80211_eht_operation - eht operation element
+ *
+ * This structure is the "EHT Operation Element" fields as
+ * described in P802.11be_D1.4 section 9.4.2.311
+ *
+ * FIXME: The spec is unclear how big the fields are, and doesn't
+ * indicate the "Disabled Subchannel Bitmap Present" in the
+ * structure (Figure 9-1002a) at all ...
+ */
+struct ieee80211_eht_operation {
+ u8 chan_width;
+ u8 ccfs;
+ u8 present_bm;
+
+ u8 disable_subchannel_bitmap[];
+} __packed;
+
+#define IEEE80211_EHT_OPER_DISABLED_SUBCHANNEL_BITMAP_PRESENT 0x1
/* 802.11ac VHT Capabilities */
#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
#define IEEE80211_VHT_CAP_MAX_MPDU_MASK 0x00000003
#define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004
#define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008
+#define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
+#define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_SHIFT 2
#define IEEE80211_VHT_CAP_RXLDPC 0x00000010
#define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020
#define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040
#define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
#define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
#define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
+#define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8
#define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
#define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
#define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
#define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000
#define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000
#define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000
+#define IEEE80211_VHT_CAP_EXT_NSS_BW_SHIFT 30
+#define IEEE80211_VHT_CAP_EXT_NSS_BW_MASK 0xc0000000
+
+/**
+ * ieee80211_get_vht_max_nss - return max NSS for a given bandwidth/MCS
+ * @cap: VHT capabilities of the peer
+ * @bw: bandwidth to use
+ * @mcs: MCS index to use
+ * @ext_nss_bw_capable: indicates whether or not the local transmitter
+ * (rate scaling algorithm) can deal with the new logic
+ * (dot11VHTExtendedNSSBWCapable)
+ * @max_vht_nss: current maximum NSS as advertised by the STA in
+ * operating mode notification, can be 0 in which case the
+ * capability data will be used to derive this (from MCS support)
+ *
+ * Due to the VHT Extended NSS Bandwidth Support, the maximum NSS can
+ * vary for a given BW/MCS. This function parses the data.
+ *
+ * Note: This function is exported by cfg80211.
+ */
+int ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *cap,
+ enum ieee80211_vht_chanwidth bw,
+ int mcs, bool ext_nss_bw_capable,
+ unsigned int max_vht_nss);
+
+/**
+ * enum ieee80211_ap_reg_power - regulatory power for a Access Point
+ *
+ * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power mode
+ * @IEEE80211_REG_LPI: Indoor Access Point
+ * @IEEE80211_REG_SP: Standard power Access Point
+ * @IEEE80211_REG_VLP: Very low power Access Point
+ * @IEEE80211_REG_AP_POWER_AFTER_LAST: internal
+ * @IEEE80211_REG_AP_POWER_MAX: maximum value
+ */
+enum ieee80211_ap_reg_power {
+ IEEE80211_REG_UNSET_AP,
+ IEEE80211_REG_LPI_AP,
+ IEEE80211_REG_SP_AP,
+ IEEE80211_REG_VLP_AP,
+ IEEE80211_REG_AP_POWER_AFTER_LAST,
+ IEEE80211_REG_AP_POWER_MAX =
+ IEEE80211_REG_AP_POWER_AFTER_LAST - 1,
+};
+
+/**
+ * enum ieee80211_client_reg_power - regulatory power for a client
+ *
+ * @IEEE80211_REG_UNSET_CLIENT: Client has no regulatory power mode
+ * @IEEE80211_REG_DEFAULT_CLIENT: Default Client
+ * @IEEE80211_REG_SUBORDINATE_CLIENT: Subordinate Client
+ * @IEEE80211_REG_CLIENT_POWER_AFTER_LAST: internal
+ * @IEEE80211_REG_CLIENT_POWER_MAX: maximum value
+ */
+enum ieee80211_client_reg_power {
+ IEEE80211_REG_UNSET_CLIENT,
+ IEEE80211_REG_DEFAULT_CLIENT,
+ IEEE80211_REG_SUBORDINATE_CLIENT,
+ IEEE80211_REG_CLIENT_POWER_AFTER_LAST,
+ IEEE80211_REG_CLIENT_POWER_MAX =
+ IEEE80211_REG_CLIENT_POWER_AFTER_LAST - 1,
+};
+
+/* 802.11ax HE MAC capabilities */
+#define IEEE80211_HE_MAC_CAP0_HTC_HE 0x01
+#define IEEE80211_HE_MAC_CAP0_TWT_REQ 0x02
+#define IEEE80211_HE_MAC_CAP0_TWT_RES 0x04
+#define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_NOT_SUPP 0x00
+#define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_1 0x08
+#define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_2 0x10
+#define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_3 0x18
+#define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_MASK 0x18
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_1 0x00
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_2 0x20
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_4 0x40
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_8 0x60
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_16 0x80
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_32 0xa0
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_64 0xc0
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_UNLIMITED 0xe0
+#define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_MASK 0xe0
+
+#define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_UNLIMITED 0x00
+#define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_128 0x01
+#define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_256 0x02
+#define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_512 0x03
+#define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_MASK 0x03
+#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_0US 0x00
+#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_8US 0x04
+#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US 0x08
+#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK 0x0c
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_1 0x00
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_2 0x10
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_3 0x20
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_4 0x30
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_5 0x40
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_6 0x50
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_7 0x60
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8 0x70
+#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_MASK 0x70
+
+/* Link adaptation is split between byte HE_MAC_CAP1 and
+ * HE_MAC_CAP2. It should be set only if IEEE80211_HE_MAC_CAP0_HTC_HE
+ * in which case the following values apply:
+ * 0 = No feedback.
+ * 1 = reserved.
+ * 2 = Unsolicited feedback.
+ * 3 = both
+ */
+#define IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION 0x80
+
+#define IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION 0x01
+#define IEEE80211_HE_MAC_CAP2_ALL_ACK 0x02
+#define IEEE80211_HE_MAC_CAP2_TRS 0x04
+#define IEEE80211_HE_MAC_CAP2_BSR 0x08
+#define IEEE80211_HE_MAC_CAP2_BCAST_TWT 0x10
+#define IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP 0x20
+#define IEEE80211_HE_MAC_CAP2_MU_CASCADING 0x40
+#define IEEE80211_HE_MAC_CAP2_ACK_EN 0x80
+
+#define IEEE80211_HE_MAC_CAP3_OMI_CONTROL 0x02
+#define IEEE80211_HE_MAC_CAP3_OFDMA_RA 0x04
+
+/* The maximum length of an A-MDPU is defined by the combination of the Maximum
+ * A-MDPU Length Exponent field in the HT capabilities, VHT capabilities and the
+ * same field in the HE capabilities.
+ */
+#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_0 0x00
+#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1 0x08
+#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2 0x10
+#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3 0x18
+#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK 0x18
+#define IEEE80211_HE_MAC_CAP3_AMSDU_FRAG 0x20
+#define IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED 0x40
+#define IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS 0x80
+
+#define IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG 0x01
+#define IEEE80211_HE_MAC_CAP4_QTP 0x02
+#define IEEE80211_HE_MAC_CAP4_BQR 0x04
+#define IEEE80211_HE_MAC_CAP4_PSR_RESP 0x08
+#define IEEE80211_HE_MAC_CAP4_NDP_FB_REP 0x10
+#define IEEE80211_HE_MAC_CAP4_OPS 0x20
+#define IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU 0x40
+/* Multi TID agg TX is split between byte #4 and #5
+ * The value is a combination of B39,B40,B41
+ */
+#define IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39 0x80
+
+#define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40 0x01
+#define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41 0x02
+#define IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECTIVE_TRANSMISSION 0x04
+#define IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU 0x08
+#define IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX 0x10
+#define IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS 0x20
+#define IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING 0x40
+#define IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX 0x80
+
+#define IEEE80211_HE_VHT_MAX_AMPDU_FACTOR 20
+#define IEEE80211_HE_HT_MAX_AMPDU_FACTOR 16
+#define IEEE80211_HE_6GHZ_MAX_AMPDU_FACTOR 13
+
+/* 802.11ax HE PHY capabilities */
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G 0x02
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G 0x04
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G 0x08
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G 0x10
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK_ALL 0x1e
+
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G 0x20
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G 0x40
+#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK 0xfe
+
+#define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_20MHZ 0x01
+#define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_40MHZ 0x02
+#define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_20MHZ 0x04
+#define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_40MHZ 0x08
+#define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK 0x0f
+#define IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A 0x10
+#define IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD 0x20
+#define IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US 0x40
+/* Midamble RX/TX Max NSTS is split between byte #2 and byte #3 */
+#define IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS 0x80
+
+#define IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS 0x01
+#define IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US 0x02
+#define IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ 0x04
+#define IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ 0x08
+#define IEEE80211_HE_PHY_CAP2_DOPPLER_TX 0x10
+#define IEEE80211_HE_PHY_CAP2_DOPPLER_RX 0x20
+
+/* Note that the meaning of UL MU below is different between an AP and a non-AP
+ * sta, where in the AP case it indicates support for Rx and in the non-AP sta
+ * case it indicates support for Tx.
+ */
+#define IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO 0x40
+#define IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO 0x80
+
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM 0x00
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK 0x01
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK 0x02
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM 0x03
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK 0x03
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 0x00
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2 0x04
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM 0x00
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK 0x08
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK 0x10
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM 0x18
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK 0x18
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1 0x00
+#define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2 0x20
+#define IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU 0x40
+#define IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER 0x80
+
+#define IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE 0x01
+#define IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER 0x02
+
+/* Minimal allowed value of Max STS under 80MHz is 3 */
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 0x0c
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_5 0x10
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_6 0x14
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_7 0x18
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8 0x1c
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK 0x1c
+
+/* Minimal allowed value of Max STS above 80MHz is 3 */
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4 0x60
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5 0x80
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_6 0xa0
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_7 0xc0
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8 0xe0
+#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK 0xe0
+
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_1 0x00
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2 0x01
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_3 0x02
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_4 0x03
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_5 0x04
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_6 0x05
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_7 0x06
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_8 0x07
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK 0x07
+
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_1 0x00
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2 0x08
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_3 0x10
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_4 0x18
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_5 0x20
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_6 0x28
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_7 0x30
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_8 0x38
+#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK 0x38
+
+#define IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK 0x40
+#define IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK 0x80
+
+#define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU 0x01
+#define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU 0x02
+#define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB 0x04
+#define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB 0x08
+#define IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB 0x10
+#define IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE 0x20
+#define IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO 0x40
+#define IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT 0x80
+
+#define IEEE80211_HE_PHY_CAP7_PSR_BASED_SR 0x01
+#define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP 0x02
+#define IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI 0x04
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_1 0x08
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_2 0x10
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_3 0x18
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_4 0x20
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_5 0x28
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_6 0x30
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_7 0x38
+#define IEEE80211_HE_PHY_CAP7_MAX_NC_MASK 0x38
+#define IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ 0x40
+#define IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ 0x80
+
+#define IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI 0x01
+#define IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G 0x02
+#define IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU 0x04
+#define IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU 0x08
+#define IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI 0x10
+#define IEEE80211_HE_PHY_CAP8_MIDAMBLE_RX_TX_2X_AND_1XLTF 0x20
+#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242 0x00
+#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484 0x40
+#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996 0x80
+#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996 0xc0
+#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK 0xc0
+
+#define IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM 0x01
+#define IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK 0x02
+#define IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU 0x04
+#define IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU 0x08
+#define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB 0x10
+#define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB 0x20
+#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_0US 0x0
+#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_8US 0x1
+#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US 0x2
+#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED 0x3
+#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS 6
+#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK 0xc0
+
+#define IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF 0x01
+
+/* 802.11ax HE TX/RX MCS NSS Support */
+#define IEEE80211_TX_RX_MCS_NSS_SUPP_HIGHEST_MCS_POS (3)
+#define IEEE80211_TX_RX_MCS_NSS_SUPP_TX_BITMAP_POS (6)
+#define IEEE80211_TX_RX_MCS_NSS_SUPP_RX_BITMAP_POS (11)
+#define IEEE80211_TX_RX_MCS_NSS_SUPP_TX_BITMAP_MASK 0x07c0
+#define IEEE80211_TX_RX_MCS_NSS_SUPP_RX_BITMAP_MASK 0xf800
+
+/* TX/RX HE MCS Support field Highest MCS subfield encoding */
+enum ieee80211_he_highest_mcs_supported_subfield_enc {
+ HIGHEST_MCS_SUPPORTED_MCS7 = 0,
+ HIGHEST_MCS_SUPPORTED_MCS8,
+ HIGHEST_MCS_SUPPORTED_MCS9,
+ HIGHEST_MCS_SUPPORTED_MCS10,
+ HIGHEST_MCS_SUPPORTED_MCS11,
+};
+
+/* Calculate 802.11ax HE capabilities IE Tx/Rx HE MCS NSS Support Field size */
+static inline u8
+ieee80211_he_mcs_nss_size(const struct ieee80211_he_cap_elem *he_cap)
+{
+ u8 count = 4;
+
+ if (he_cap->phy_cap_info[0] &
+ IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G)
+ count += 4;
+
+ if (he_cap->phy_cap_info[0] &
+ IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G)
+ count += 4;
+
+ return count;
+}
+
+/* 802.11ax HE PPE Thresholds */
+#define IEEE80211_PPE_THRES_NSS_SUPPORT_2NSS (1)
+#define IEEE80211_PPE_THRES_NSS_POS (0)
+#define IEEE80211_PPE_THRES_NSS_MASK (7)
+#define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_2x966_AND_966_RU \
+ (BIT(5) | BIT(6))
+#define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK 0x78
+#define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_POS (3)
+#define IEEE80211_PPE_THRES_INFO_PPET_SIZE (3)
+#define IEEE80211_HE_PPE_THRES_INFO_HEADER_SIZE (7)
+
+/*
+ * Calculate 802.11ax HE capabilities IE PPE field size
+ * Input: Header byte of ppe_thres (first byte), and HE capa IE's PHY cap u8*
+ */
+static inline u8
+ieee80211_he_ppe_size(u8 ppe_thres_hdr, const u8 *phy_cap_info)
+{
+ u8 n;
+
+ if ((phy_cap_info[6] &
+ IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) == 0)
+ return 0;
+
+ n = hweight8(ppe_thres_hdr &
+ IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK);
+ n *= (1 + ((ppe_thres_hdr & IEEE80211_PPE_THRES_NSS_MASK) >>
+ IEEE80211_PPE_THRES_NSS_POS));
+
+ /*
+ * Each pair is 6 bits, and we need to add the 7 "header" bits to the
+ * total size.
+ */
+ n = (n * IEEE80211_PPE_THRES_INFO_PPET_SIZE * 2) + 7;
+ n = DIV_ROUND_UP(n, 8);
+
+ return n;
+}
+
+static inline bool ieee80211_he_capa_size_ok(const u8 *data, u8 len)
+{
+ const struct ieee80211_he_cap_elem *he_cap_ie_elem = (const void *)data;
+ u8 needed = sizeof(*he_cap_ie_elem);
+
+ if (len < needed)
+ return false;
+
+ needed += ieee80211_he_mcs_nss_size(he_cap_ie_elem);
+ if (len < needed)
+ return false;
+
+ if (he_cap_ie_elem->phy_cap_info[6] &
+ IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
+ if (len < needed + 1)
+ return false;
+ needed += ieee80211_he_ppe_size(data[needed],
+ he_cap_ie_elem->phy_cap_info);
+ }
+
+ return len >= needed;
+}
+
+/* HE Operation defines */
+#define IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK 0x00000007
+#define IEEE80211_HE_OPERATION_TWT_REQUIRED 0x00000008
+#define IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK 0x00003ff0
+#define IEEE80211_HE_OPERATION_RTS_THRESHOLD_OFFSET 4
+#define IEEE80211_HE_OPERATION_VHT_OPER_INFO 0x00004000
+#define IEEE80211_HE_OPERATION_CO_HOSTED_BSS 0x00008000
+#define IEEE80211_HE_OPERATION_ER_SU_DISABLE 0x00010000
+#define IEEE80211_HE_OPERATION_6GHZ_OP_INFO 0x00020000
+#define IEEE80211_HE_OPERATION_BSS_COLOR_MASK 0x3f000000
+#define IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET 24
+#define IEEE80211_HE_OPERATION_PARTIAL_BSS_COLOR 0x40000000
+#define IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED 0x80000000
+
+#define IEEE80211_6GHZ_CTRL_REG_LPI_AP 0
+#define IEEE80211_6GHZ_CTRL_REG_SP_AP 1
+
+/**
+ * ieee80211_he_6ghz_oper - HE 6 GHz operation Information field
+ * @primary: primary channel
+ * @control: control flags
+ * @ccfs0: channel center frequency segment 0
+ * @ccfs1: channel center frequency segment 1
+ * @minrate: minimum rate (in 1 Mbps units)
+ */
+struct ieee80211_he_6ghz_oper {
+ u8 primary;
+#define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH 0x3
+#define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_20MHZ 0
+#define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_40MHZ 1
+#define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_80MHZ 2
+#define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_160MHZ 3
+#define IEEE80211_HE_6GHZ_OPER_CTRL_DUP_BEACON 0x4
+#define IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO 0x38
+ u8 control;
+ u8 ccfs0;
+ u8 ccfs1;
+ u8 minrate;
+} __packed;
+
+/*
+ * In "9.4.2.161 Transmit Power Envelope element" of "IEEE Std 802.11ax-2021",
+ * it show four types in "Table 9-275a-Maximum Transmit Power Interpretation
+ * subfield encoding", and two category for each type in "Table E-12-Regulatory
+ * Info subfield encoding in the United States".
+ * So it it totally max 8 Transmit Power Envelope element.
+ */
+#define IEEE80211_TPE_MAX_IE_COUNT 8
+/*
+ * In "Table 9-277—Meaning of Maximum Transmit Power Count subfield"
+ * of "IEEE Std 802.11ax™‐2021", the max power level is 8.
+ */
+#define IEEE80211_MAX_NUM_PWR_LEVEL 8
+
+#define IEEE80211_TPE_MAX_POWER_COUNT 8
+
+/* transmit power interpretation type of transmit power envelope element */
+enum ieee80211_tx_power_intrpt_type {
+ IEEE80211_TPE_LOCAL_EIRP,
+ IEEE80211_TPE_LOCAL_EIRP_PSD,
+ IEEE80211_TPE_REG_CLIENT_EIRP,
+ IEEE80211_TPE_REG_CLIENT_EIRP_PSD,
+};
+
+/**
+ * struct ieee80211_tx_pwr_env
+ *
+ * This structure represents the "Transmit Power Envelope element"
+ */
+struct ieee80211_tx_pwr_env {
+ u8 tx_power_info;
+ s8 tx_power[IEEE80211_TPE_MAX_POWER_COUNT];
+} __packed;
+
+#define IEEE80211_TX_PWR_ENV_INFO_COUNT 0x7
+#define IEEE80211_TX_PWR_ENV_INFO_INTERPRET 0x38
+#define IEEE80211_TX_PWR_ENV_INFO_CATEGORY 0xC0
+
+/*
+ * ieee80211_he_oper_size - calculate 802.11ax HE Operations IE size
+ * @he_oper_ie: byte data of the He Operations IE, stating from the byte
+ * after the ext ID byte. It is assumed that he_oper_ie has at least
+ * sizeof(struct ieee80211_he_operation) bytes, the caller must have
+ * validated this.
+ * @return the actual size of the IE data (not including header), or 0 on error
+ */
+static inline u8
+ieee80211_he_oper_size(const u8 *he_oper_ie)
+{
+ const struct ieee80211_he_operation *he_oper = (const void *)he_oper_ie;
+ u8 oper_len = sizeof(struct ieee80211_he_operation);
+ u32 he_oper_params;
+
+ /* Make sure the input is not NULL */
+ if (!he_oper_ie)
+ return 0;
+
+ /* Calc required length */
+ he_oper_params = le32_to_cpu(he_oper->he_oper_params);
+ if (he_oper_params & IEEE80211_HE_OPERATION_VHT_OPER_INFO)
+ oper_len += 3;
+ if (he_oper_params & IEEE80211_HE_OPERATION_CO_HOSTED_BSS)
+ oper_len++;
+ if (he_oper_params & IEEE80211_HE_OPERATION_6GHZ_OP_INFO)
+ oper_len += sizeof(struct ieee80211_he_6ghz_oper);
+
+ /* Add the first byte (extension ID) to the total length */
+ oper_len++;
+
+ return oper_len;
+}
+
+/**
+ * ieee80211_he_6ghz_oper - obtain 6 GHz operation field
+ * @he_oper: HE operation element (must be pre-validated for size)
+ * but may be %NULL
+ *
+ * Return: a pointer to the 6 GHz operation field, or %NULL
+ */
+static inline const struct ieee80211_he_6ghz_oper *
+ieee80211_he_6ghz_oper(const struct ieee80211_he_operation *he_oper)
+{
+ const u8 *ret = (const void *)&he_oper->optional;
+ u32 he_oper_params;
+
+ if (!he_oper)
+ return NULL;
+
+ he_oper_params = le32_to_cpu(he_oper->he_oper_params);
+
+ if (!(he_oper_params & IEEE80211_HE_OPERATION_6GHZ_OP_INFO))
+ return NULL;
+ if (he_oper_params & IEEE80211_HE_OPERATION_VHT_OPER_INFO)
+ ret += 3;
+ if (he_oper_params & IEEE80211_HE_OPERATION_CO_HOSTED_BSS)
+ ret++;
+
+ return (const void *)ret;
+}
+
+/* HE Spatial Reuse defines */
+#define IEEE80211_HE_SPR_PSR_DISALLOWED BIT(0)
+#define IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED BIT(1)
+#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT BIT(2)
+#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT BIT(3)
+#define IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED BIT(4)
+
+/*
+ * ieee80211_he_spr_size - calculate 802.11ax HE Spatial Reuse IE size
+ * @he_spr_ie: byte data of the He Spatial Reuse IE, stating from the byte
+ * after the ext ID byte. It is assumed that he_spr_ie has at least
+ * sizeof(struct ieee80211_he_spr) bytes, the caller must have validated
+ * this
+ * @return the actual size of the IE data (not including header), or 0 on error
+ */
+static inline u8
+ieee80211_he_spr_size(const u8 *he_spr_ie)
+{
+ const struct ieee80211_he_spr *he_spr = (const void *)he_spr_ie;
+ u8 spr_len = sizeof(struct ieee80211_he_spr);
+ u8 he_spr_params;
+
+ /* Make sure the input is not NULL */
+ if (!he_spr_ie)
+ return 0;
+
+ /* Calc required length */
+ he_spr_params = he_spr->he_sr_control;
+ if (he_spr_params & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)
+ spr_len++;
+ if (he_spr_params & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT)
+ spr_len += 18;
+
+ /* Add the first byte (extension ID) to the total length */
+ spr_len++;
+
+ return spr_len;
+}
+
+/* S1G Capabilities Information field */
+#define IEEE80211_S1G_CAPABILITY_LEN 15
+
+#define S1G_CAP0_S1G_LONG BIT(0)
+#define S1G_CAP0_SGI_1MHZ BIT(1)
+#define S1G_CAP0_SGI_2MHZ BIT(2)
+#define S1G_CAP0_SGI_4MHZ BIT(3)
+#define S1G_CAP0_SGI_8MHZ BIT(4)
+#define S1G_CAP0_SGI_16MHZ BIT(5)
+#define S1G_CAP0_SUPP_CH_WIDTH GENMASK(7, 6)
+
+#define S1G_SUPP_CH_WIDTH_2 0
+#define S1G_SUPP_CH_WIDTH_4 1
+#define S1G_SUPP_CH_WIDTH_8 2
+#define S1G_SUPP_CH_WIDTH_16 3
+#define S1G_SUPP_CH_WIDTH_MAX(cap) ((1 << FIELD_GET(S1G_CAP0_SUPP_CH_WIDTH, \
+ cap[0])) << 1)
+
+#define S1G_CAP1_RX_LDPC BIT(0)
+#define S1G_CAP1_TX_STBC BIT(1)
+#define S1G_CAP1_RX_STBC BIT(2)
+#define S1G_CAP1_SU_BFER BIT(3)
+#define S1G_CAP1_SU_BFEE BIT(4)
+#define S1G_CAP1_BFEE_STS GENMASK(7, 5)
+
+#define S1G_CAP2_SOUNDING_DIMENSIONS GENMASK(2, 0)
+#define S1G_CAP2_MU_BFER BIT(3)
+#define S1G_CAP2_MU_BFEE BIT(4)
+#define S1G_CAP2_PLUS_HTC_VHT BIT(5)
+#define S1G_CAP2_TRAVELING_PILOT GENMASK(7, 6)
+
+#define S1G_CAP3_RD_RESPONDER BIT(0)
+#define S1G_CAP3_HT_DELAYED_BA BIT(1)
+#define S1G_CAP3_MAX_MPDU_LEN BIT(2)
+#define S1G_CAP3_MAX_AMPDU_LEN_EXP GENMASK(4, 3)
+#define S1G_CAP3_MIN_MPDU_START GENMASK(7, 5)
+
+#define S1G_CAP4_UPLINK_SYNC BIT(0)
+#define S1G_CAP4_DYNAMIC_AID BIT(1)
+#define S1G_CAP4_BAT BIT(2)
+#define S1G_CAP4_TIME_ADE BIT(3)
+#define S1G_CAP4_NON_TIM BIT(4)
+#define S1G_CAP4_GROUP_AID BIT(5)
+#define S1G_CAP4_STA_TYPE GENMASK(7, 6)
+
+#define S1G_CAP5_CENT_AUTH_CONTROL BIT(0)
+#define S1G_CAP5_DIST_AUTH_CONTROL BIT(1)
+#define S1G_CAP5_AMSDU BIT(2)
+#define S1G_CAP5_AMPDU BIT(3)
+#define S1G_CAP5_ASYMMETRIC_BA BIT(4)
+#define S1G_CAP5_FLOW_CONTROL BIT(5)
+#define S1G_CAP5_SECTORIZED_BEAM GENMASK(7, 6)
+
+#define S1G_CAP6_OBSS_MITIGATION BIT(0)
+#define S1G_CAP6_FRAGMENT_BA BIT(1)
+#define S1G_CAP6_NDP_PS_POLL BIT(2)
+#define S1G_CAP6_RAW_OPERATION BIT(3)
+#define S1G_CAP6_PAGE_SLICING BIT(4)
+#define S1G_CAP6_TXOP_SHARING_IMP_ACK BIT(5)
+#define S1G_CAP6_VHT_LINK_ADAPT GENMASK(7, 6)
+
+#define S1G_CAP7_TACK_AS_PS_POLL BIT(0)
+#define S1G_CAP7_DUP_1MHZ BIT(1)
+#define S1G_CAP7_MCS_NEGOTIATION BIT(2)
+#define S1G_CAP7_1MHZ_CTL_RESPONSE_PREAMBLE BIT(3)
+#define S1G_CAP7_NDP_BFING_REPORT_POLL BIT(4)
+#define S1G_CAP7_UNSOLICITED_DYN_AID BIT(5)
+#define S1G_CAP7_SECTOR_TRAINING_OPERATION BIT(6)
+#define S1G_CAP7_TEMP_PS_MODE_SWITCH BIT(7)
+
+#define S1G_CAP8_TWT_GROUPING BIT(0)
+#define S1G_CAP8_BDT BIT(1)
+#define S1G_CAP8_COLOR GENMASK(4, 2)
+#define S1G_CAP8_TWT_REQUEST BIT(5)
+#define S1G_CAP8_TWT_RESPOND BIT(6)
+#define S1G_CAP8_PV1_FRAME BIT(7)
+
+#define S1G_CAP9_LINK_ADAPT_PER_CONTROL_RESPONSE BIT(0)
+
+#define S1G_OPER_CH_WIDTH_PRIMARY_1MHZ BIT(0)
+#define S1G_OPER_CH_WIDTH_OPER GENMASK(4, 1)
+
+/* EHT MAC capabilities as defined in P802.11be_D1.4 section 9.4.2.313.2 */
+#define IEEE80211_EHT_MAC_CAP0_NSEP_PRIO_ACCESS 0x01
+#define IEEE80211_EHT_MAC_CAP0_OM_CONTROL 0x02
+#define IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE1 0x04
+#define IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE2 0x08
+#define IEEE80211_EHT_MAC_CAP0_RESTRICTED_TWT 0x10
+#define IEEE80211_EHT_MAC_CAP0_SCS_TRAFFIC_DESC 0x20
+#define IEEE80211_EHT_MAC_CAP0_MAX_AMPDU_LEN_MASK 0xc0
+#define IEEE80211_EHT_MAC_CAP0_MAX_AMPDU_LEN_3895 0
+#define IEEE80211_EHT_MAC_CAP0_MAX_AMPDU_LEN_7991 1
+#define IEEE80211_EHT_MAC_CAP0_MAX_AMPDU_LEN_11454 2
+
+/* EHT PHY capabilities as defined in P802.11be_D1.4 section 9.4.2.313.3 */
+#define IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ 0x02
+#define IEEE80211_EHT_PHY_CAP0_242_TONE_RU_GT20MHZ 0x04
+#define IEEE80211_EHT_PHY_CAP0_NDP_4_EHT_LFT_32_GI 0x08
+#define IEEE80211_EHT_PHY_CAP0_PARTIAL_BW_UL_MU_MIMO 0x10
+#define IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER 0x20
+#define IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE 0x40
+
+/* EHT beamformee number of spatial streams <= 80MHz is split */
+#define IEEE80211_EHT_PHY_CAP0_BEAMFORMEE_SS_80MHZ_MASK 0x80
+#define IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK 0x03
+
+#define IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK 0x1c
+#define IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_320MHZ_MASK 0xe0
+
+#define IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK 0x07
+#define IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK 0x38
+
+/* EHT number of sounding dimensions for 320MHz is split */
+#define IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_320MHZ_MASK 0xc0
+#define IEEE80211_EHT_PHY_CAP3_SOUNDING_DIM_320MHZ_MASK 0x01
+#define IEEE80211_EHT_PHY_CAP3_NG_16_SU_FEEDBACK 0x02
+#define IEEE80211_EHT_PHY_CAP3_NG_16_MU_FEEDBACK 0x04
+#define IEEE80211_EHT_PHY_CAP3_CODEBOOK_4_2_SU_FDBK 0x08
+#define IEEE80211_EHT_PHY_CAP3_CODEBOOK_7_5_MU_FDBK 0x10
+#define IEEE80211_EHT_PHY_CAP3_TRIG_SU_BF_FDBK 0x20
+#define IEEE80211_EHT_PHY_CAP3_TRIG_MU_BF_PART_BW_FDBK 0x40
+#define IEEE80211_EHT_PHY_CAP3_TRIG_CQI_FDBK 0x80
+
+#define IEEE80211_EHT_PHY_CAP4_PART_BW_DL_MU_MIMO 0x01
+#define IEEE80211_EHT_PHY_CAP4_PSR_SR_SUPP 0x02
+#define IEEE80211_EHT_PHY_CAP4_POWER_BOOST_FACT_SUPP 0x04
+#define IEEE80211_EHT_PHY_CAP4_EHT_MU_PPDU_4_EHT_LTF_08_GI 0x08
+#define IEEE80211_EHT_PHY_CAP4_MAX_NC_MASK 0xf0
+
+#define IEEE80211_EHT_PHY_CAP5_NON_TRIG_CQI_FEEDBACK 0x01
+#define IEEE80211_EHT_PHY_CAP5_TX_LESS_242_TONE_RU_SUPP 0x02
+#define IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP 0x04
+#define IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT 0x08
+#define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK 0x30
+#define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_0US 0
+#define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US 1
+#define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_16US 2
+#define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_20US 3
+
+/* Maximum number of supported EHT LTF is split */
+#define IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK 0xc0
+#define IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK 0x07
+
+#define IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK 0x78
+#define IEEE80211_EHT_PHY_CAP6_EHT_DUP_6GHZ_SUPP 0x80
+
+#define IEEE80211_EHT_PHY_CAP7_20MHZ_STA_RX_NDP_WIDER_BW 0x01
+#define IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ 0x02
+#define IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ 0x04
+#define IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_320MHZ 0x08
+#define IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ 0x10
+#define IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ 0x20
+#define IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ 0x40
+#define IEEE80211_EHT_PHY_CAP7_TB_SOUNDING_FDBK_RATE_LIMIT 0x80
+
+#define IEEE80211_EHT_PHY_CAP8_RX_1024QAM_WIDER_BW_DL_OFDMA 0x01
+#define IEEE80211_EHT_PHY_CAP8_RX_4096QAM_WIDER_BW_DL_OFDMA 0x02
+
+/*
+ * EHT operation channel width as defined in P802.11be_D1.4 section 9.4.2.311
+ */
+#define IEEE80211_EHT_OPER_CHAN_WIDTH 0x7
+#define IEEE80211_EHT_OPER_CHAN_WIDTH_20MHZ 0
+#define IEEE80211_EHT_OPER_CHAN_WIDTH_40MHZ 1
+#define IEEE80211_EHT_OPER_CHAN_WIDTH_80MHZ 2
+#define IEEE80211_EHT_OPER_CHAN_WIDTH_160MHZ 3
+#define IEEE80211_EHT_OPER_CHAN_WIDTH_320MHZ 4
+
+/* Calculate 802.11be EHT capabilities IE Tx/Rx EHT MCS NSS Support Field size */
+static inline u8
+ieee80211_eht_mcs_nss_size(const struct ieee80211_he_cap_elem *he_cap,
+ const struct ieee80211_eht_cap_elem_fixed *eht_cap)
+{
+ u8 count = 0;
+
+ /* on 2.4 GHz, if it supports 40 MHz, the result is 3 */
+ if (he_cap->phy_cap_info[0] &
+ IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G)
+ return 3;
+
+ /* on 2.4 GHz, these three bits are reserved, so should be 0 */
+ if (he_cap->phy_cap_info[0] &
+ IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G)
+ count += 3;
+
+ if (he_cap->phy_cap_info[0] &
+ IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G)
+ count += 3;
+
+ if (eht_cap->phy_cap_info[0] & IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ)
+ count += 3;
+
+ return count ? count : 4;
+}
+
+/* 802.11be EHT PPE Thresholds */
+#define IEEE80211_EHT_PPE_THRES_NSS_POS 0
+#define IEEE80211_EHT_PPE_THRES_NSS_MASK 0xf
+#define IEEE80211_EHT_PPE_THRES_RU_INDEX_BITMASK_MASK 0x1f0
+#define IEEE80211_EHT_PPE_THRES_INFO_PPET_SIZE 3
+#define IEEE80211_EHT_PPE_THRES_INFO_HEADER_SIZE 9
+
+/*
+ * Calculate 802.11be EHT capabilities IE EHT field size
+ */
+static inline u8
+ieee80211_eht_ppe_size(u16 ppe_thres_hdr, const u8 *phy_cap_info)
+{
+ u32 n;
+
+ if (!(phy_cap_info[5] &
+ IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT))
+ return 0;
+
+ n = hweight16(ppe_thres_hdr &
+ IEEE80211_EHT_PPE_THRES_RU_INDEX_BITMASK_MASK);
+ n *= 1 + (ppe_thres_hdr & IEEE80211_EHT_PPE_THRES_NSS_MASK);
+
+ /*
+ * Each pair is 6 bits, and we need to add the 9 "header" bits to the
+ * total size.
+ */
+ n = n * IEEE80211_EHT_PPE_THRES_INFO_PPET_SIZE * 2 +
+ IEEE80211_EHT_PPE_THRES_INFO_HEADER_SIZE;
+ return DIV_ROUND_UP(n, 8);
+}
+
+static inline bool
+ieee80211_eht_capa_size_ok(const u8 *he_capa, const u8 *data, u8 len)
+{
+ const struct ieee80211_eht_cap_elem_fixed *elem = (const void *)data;
+ u8 needed = sizeof(struct ieee80211_eht_cap_elem_fixed);
+
+ if (len < needed || !he_capa)
+ return false;
+
+ needed += ieee80211_eht_mcs_nss_size((const void *)he_capa,
+ (const void *)data);
+ if (len < needed)
+ return false;
+
+ if (elem->phy_cap_info[5] &
+ IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT) {
+ u16 ppe_thres_hdr;
+
+ if (len < needed + sizeof(ppe_thres_hdr))
+ return false;
+
+ ppe_thres_hdr = (data[needed] >> 8) + data[needed + 1];
+ needed += ieee80211_eht_ppe_size(ppe_thres_hdr,
+ elem->phy_cap_info);
+ }
+
+ return len >= needed;
+}
+
+static inline bool
+ieee80211_eht_oper_size_ok(const u8 *data, u8 len)
+{
+ const struct ieee80211_eht_operation *elem = (const void *)data;
+ u8 needed = sizeof(*elem);
+
+ if (len < needed)
+ return false;
+
+ if (elem->present_bm & IEEE80211_EHT_OPER_DISABLED_SUBCHANNEL_BITMAP_PRESENT)
+ needed += 2;
+
+ return len >= needed;
+}
+
+#define LISTEN_INT_USF GENMASK(15, 14)
+#define LISTEN_INT_UI GENMASK(13, 0)
+
+#define IEEE80211_MAX_USF FIELD_MAX(LISTEN_INT_USF)
+#define IEEE80211_MAX_UI FIELD_MAX(LISTEN_INT_UI)
/* Authentication algorithms */
#define WLAN_AUTH_OPEN 0
#define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
#define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
#define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
+#define IEEE80211_SPCT_MSR_RPRT_TYPE_LCI 8
+#define IEEE80211_SPCT_MSR_RPRT_TYPE_CIVIC 11
/* 802.11g ERP information element */
#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
/* 802.11ai */
WLAN_STATUS_FILS_AUTHENTICATION_FAILURE = 108,
WLAN_STATUS_UNKNOWN_AUTHENTICATION_SERVER = 109,
+ WLAN_STATUS_SAE_HASH_TO_ELEMENT = 126,
+ WLAN_STATUS_SAE_PK = 127,
};
WLAN_EID_VHT_OPERATION = 192,
WLAN_EID_EXTENDED_BSS_LOAD = 193,
WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
- WLAN_EID_VHT_TX_POWER_ENVELOPE = 195,
+ WLAN_EID_TX_POWER_ENVELOPE = 195,
WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
WLAN_EID_AID = 197,
WLAN_EID_QUIET_CHANNEL = 198,
WLAN_EID_OPMODE_NOTIF = 199,
+ WLAN_EID_REDUCED_NEIGHBOR_REPORT = 201,
+
+ WLAN_EID_AID_REQUEST = 210,
+ WLAN_EID_AID_RESPONSE = 211,
+ WLAN_EID_S1G_BCN_COMPAT = 213,
+ WLAN_EID_S1G_SHORT_BCN_INTERVAL = 214,
+ WLAN_EID_S1G_TWT = 216,
+ WLAN_EID_S1G_CAPABILITIES = 217,
WLAN_EID_VENDOR_SPECIFIC = 221,
WLAN_EID_QOS_PARAMETER = 222,
+ WLAN_EID_S1G_OPERATION = 232,
WLAN_EID_CAG_NUMBER = 237,
WLAN_EID_AP_CSN = 239,
WLAN_EID_FILS_INDICATION = 240,
WLAN_EID_DILS = 241,
WLAN_EID_FRAGMENT = 242,
+ WLAN_EID_RSNX = 244,
WLAN_EID_EXTENSION = 255
};
WLAN_EID_EXT_FILS_WRAPPED_DATA = 8,
WLAN_EID_EXT_FILS_PUBLIC_KEY = 12,
WLAN_EID_EXT_FILS_NONCE = 13,
+ WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE = 14,
+ WLAN_EID_EXT_HE_CAPABILITY = 35,
+ WLAN_EID_EXT_HE_OPERATION = 36,
+ WLAN_EID_EXT_UORA = 37,
+ WLAN_EID_EXT_HE_MU_EDCA = 38,
+ WLAN_EID_EXT_HE_SPR = 39,
+ WLAN_EID_EXT_NDP_FEEDBACK_REPORT_PARAMSET = 41,
+ WLAN_EID_EXT_BSS_COLOR_CHG_ANN = 42,
+ WLAN_EID_EXT_QUIET_TIME_PERIOD_SETUP = 43,
+ WLAN_EID_EXT_ESS_REPORT = 45,
+ WLAN_EID_EXT_OPS = 46,
+ WLAN_EID_EXT_HE_BSS_LOAD = 47,
+ WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME = 52,
+ WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55,
+ WLAN_EID_EXT_NON_INHERITANCE = 56,
+ WLAN_EID_EXT_KNOWN_BSSID = 57,
+ WLAN_EID_EXT_SHORT_SSID_LIST = 58,
+ WLAN_EID_EXT_HE_6GHZ_CAPA = 59,
+ WLAN_EID_EXT_UL_MU_POWER_CAPA = 60,
+ WLAN_EID_EXT_EHT_OPERATION = 106,
+ WLAN_EID_EXT_EHT_MULTI_LINK = 107,
+ WLAN_EID_EXT_EHT_CAPABILITY = 108,
};
/* Action category code */
WLAN_CATEGORY_BACK = 3,
WLAN_CATEGORY_PUBLIC = 4,
WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
+ WLAN_CATEGORY_FAST_BBS_TRANSITION = 6,
WLAN_CATEGORY_HT = 7,
WLAN_CATEGORY_SA_QUERY = 8,
WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
WLAN_CATEGORY_FST = 18,
WLAN_CATEGORY_UNPROT_DMG = 20,
WLAN_CATEGORY_VHT = 21,
+ WLAN_CATEGORY_S1G = 22,
WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
};
WLAN_KEY_LEN_BIP_GMAC_256 = 32,
};
+enum ieee80211_s1g_actioncode {
+ WLAN_S1G_AID_SWITCH_REQUEST,
+ WLAN_S1G_AID_SWITCH_RESPONSE,
+ WLAN_S1G_SYNC_CONTROL,
+ WLAN_S1G_STA_INFO_ANNOUNCE,
+ WLAN_S1G_EDCA_PARAM_SET,
+ WLAN_S1G_EL_OPERATION,
+ WLAN_S1G_TWT_SETUP,
+ WLAN_S1G_TWT_TEARDOWN,
+ WLAN_S1G_SECT_GROUP_ID_LIST,
+ WLAN_S1G_SECT_ID_FEEDBACK,
+ WLAN_S1G_TWT_INFORMATION = 11,
+};
+
#define IEEE80211_WEP_IV_LEN 4
#define IEEE80211_WEP_ICV_LEN 4
#define IEEE80211_CCMP_HDR_LEN 8
#define FILS_ERP_MAX_REALM_LEN 253
#define FILS_ERP_MAX_RRK_LEN 64
-#define PMK_MAX_LEN 48
+#define PMK_MAX_LEN 64
+#define SAE_PASSWORD_MAX_LEN 128
/* Public action codes (IEEE Std 802.11-2016, 9.6.8.1, Table 9-307) */
enum ieee80211_pub_actioncode {
*/
#define WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING BIT(2)
-/* TDLS capabilities in the the 4th byte of @WLAN_EID_EXT_CAPABILITY */
+/* Multiple BSSID capability is set in the 6th bit of 3rd byte of the
+ * @WLAN_EID_EXT_CAPABILITY information element
+ */
+#define WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT BIT(6)
+
+/* Timing Measurement protocol for time sync is set in the 7th bit of 3rd byte
+ * of the @WLAN_EID_EXT_CAPABILITY information element
+ */
+#define WLAN_EXT_CAPA3_TIMING_MEASUREMENT_SUPPORT BIT(7)
+
+/* TDLS capabilities in the 4th byte of @WLAN_EID_EXT_CAPABILITY */
#define WLAN_EXT_CAPA4_TDLS_BUFFER_STA BIT(4)
#define WLAN_EXT_CAPA4_TDLS_PEER_PSM BIT(5)
#define WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH BIT(6)
*/
#define WLAN_EXT_CAPA9_FTM_INITIATOR BIT(7)
+/* Defines support for TWT Requester and TWT Responder */
+#define WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT BIT(5)
+#define WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT BIT(6)
+
+/*
+ * When set, indicates that the AP is able to tolerate 26-tone RU UL
+ * OFDMA transmissions using HE TB PPDU from OBSS (not falsely classify the
+ * 26-tone RU UL OFDMA transmissions as radar pulses).
+ */
+#define WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT BIT(7)
+
+/* Defines support for enhanced multi-bssid advertisement*/
+#define WLAN_EXT_CAPA11_EMA_SUPPORT BIT(3)
+
/* TDLS specific payload type in the LLC/SNAP header */
#define WLAN_TDLS_SNAP_RFTYPE 0x2
WLAN_ACTION_SA_QUERY_RESPONSE = 1,
};
+/**
+ * struct ieee80211_bssid_index
+ *
+ * This structure refers to "Multiple BSSID-index element"
+ *
+ * @bssid_index: BSSID index
+ * @dtim_period: optional, overrides transmitted BSS dtim period
+ * @dtim_count: optional, overrides transmitted BSS dtim count
+ */
+struct ieee80211_bssid_index {
+ u8 bssid_index;
+ u8 dtim_period;
+ u8 dtim_count;
+};
+
+/**
+ * struct ieee80211_multiple_bssid_configuration
+ *
+ * This structure refers to "Multiple BSSID Configuration element"
+ *
+ * @bssid_count: total number of active BSSIDs in the set
+ * @profile_periodicity: the least number of beacon frames need to be received
+ * in order to discover all the nontransmitted BSSIDs in the set.
+ */
+struct ieee80211_multiple_bssid_configuration {
+ u8 bssid_count;
+ u8 profile_periodicity;
+};
+
#define SUITE(oui, id) (((oui) << 8) | (id))
/* cipher suite selectors */
#define WLAN_AKM_SUITE_TDLS SUITE(0x000FAC, 7)
#define WLAN_AKM_SUITE_SAE SUITE(0x000FAC, 8)
#define WLAN_AKM_SUITE_FT_OVER_SAE SUITE(0x000FAC, 9)
+#define WLAN_AKM_SUITE_AP_PEER_KEY SUITE(0x000FAC, 10)
#define WLAN_AKM_SUITE_8021X_SUITE_B SUITE(0x000FAC, 11)
#define WLAN_AKM_SUITE_8021X_SUITE_B_192 SUITE(0x000FAC, 12)
+#define WLAN_AKM_SUITE_FT_8021X_SHA384 SUITE(0x000FAC, 13)
#define WLAN_AKM_SUITE_FILS_SHA256 SUITE(0x000FAC, 14)
#define WLAN_AKM_SUITE_FILS_SHA384 SUITE(0x000FAC, 15)
#define WLAN_AKM_SUITE_FT_FILS_SHA256 SUITE(0x000FAC, 16)
#define WLAN_AKM_SUITE_FT_FILS_SHA384 SUITE(0x000FAC, 17)
+#define WLAN_AKM_SUITE_OWE SUITE(0x000FAC, 18)
+#define WLAN_AKM_SUITE_FT_PSK_SHA384 SUITE(0x000FAC, 19)
+#define WLAN_AKM_SUITE_PSK_SHA384 SUITE(0x000FAC, 20)
+
+#define WLAN_AKM_SUITE_WFA_DPP SUITE(WLAN_OUI_WFA, 2)
#define WLAN_MAX_KEY_LEN 32
#define WLAN_OUI_WFA 0x506f9a
#define WLAN_OUI_TYPE_WFA_P2P 9
+#define WLAN_OUI_TYPE_WFA_DPP 0x1A
#define WLAN_OUI_MICROSOFT 0x0050f2
#define WLAN_OUI_TYPE_MICROSOFT_WPA 1
#define WLAN_OUI_TYPE_MICROSOFT_WMM 2
__le16 medium_time;
} __packed;
+struct ieee80211_he_6ghz_capa {
+ /* uses IEEE80211_HE_6GHZ_CAP_* below */
+ __le16 capa;
+} __packed;
+
+/* HE 6 GHz band capabilities */
+/* uses enum ieee80211_min_mpdu_spacing values */
+#define IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START 0x0007
+/* uses enum ieee80211_vht_max_ampdu_length_exp values */
+#define IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP 0x0038
+/* uses IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_* values */
+#define IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN 0x00c0
+/* WLAN_HT_CAP_SM_PS_* values */
+#define IEEE80211_HE_6GHZ_CAP_SM_PS 0x0600
+#define IEEE80211_HE_6GHZ_CAP_RD_RESPONDER 0x0800
+#define IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS 0x1000
+#define IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS 0x2000
+
/**
* ieee80211_get_qos_ctl - get pointer to qos control bytes
* @hdr: the frame
return (u8 *)hdr + 24;
}
+/**
+ * ieee80211_get_tid - get qos TID
+ * @hdr: the frame
+ */
+static inline u8 ieee80211_get_tid(struct ieee80211_hdr *hdr)
+{
+ u8 *qc = ieee80211_get_qos_ctl(hdr);
+
+ return qc[0] & IEEE80211_QOS_CTL_TID_MASK;
+}
+
/**
* ieee80211_get_SA - get pointer to SA
* @hdr: the frame
#define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
#define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
+struct element {
+ u8 id;
+ u8 datalen;
+ u8 data[];
+} __packed;
+
+/* element iteration helpers */
+#define for_each_element(_elem, _data, _datalen) \
+ for (_elem = (const struct element *)(_data); \
+ (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
+ (int)sizeof(*_elem) && \
+ (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
+ (int)sizeof(*_elem) + _elem->datalen; \
+ _elem = (const struct element *)(_elem->data + _elem->datalen))
+
+#define for_each_element_id(element, _id, data, datalen) \
+ for_each_element(element, data, datalen) \
+ if (element->id == (_id))
+
+#define for_each_element_extid(element, extid, _data, _datalen) \
+ for_each_element(element, _data, _datalen) \
+ if (element->id == WLAN_EID_EXTENSION && \
+ element->datalen > 0 && \
+ element->data[0] == (extid))
+
+#define for_each_subelement(sub, element) \
+ for_each_element(sub, (element)->data, (element)->datalen)
+
+#define for_each_subelement_id(sub, id, element) \
+ for_each_element_id(sub, id, (element)->data, (element)->datalen)
+
+#define for_each_subelement_extid(sub, extid, element) \
+ for_each_element_extid(sub, extid, (element)->data, (element)->datalen)
+
+/* convert frequencies */
+#define MHZ_TO_KHZ(freq) ((freq) * 1000)
+#define KHZ_TO_MHZ(freq) ((freq) / 1000)
+#define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000
+#define KHZ_F "%d.%03d"
+
+/* convert powers */
+#define DBI_TO_MBI(gain) ((gain) * 100)
+#define MBI_TO_DBI(gain) ((gain) / 100)
+#define DBM_TO_MBM(gain) ((gain) * 100)
+#define MBM_TO_DBM(gain) ((gain) / 100)
+
+/**
+ * for_each_element_completed - determine if element parsing consumed all data
+ * @element: element pointer after for_each_element() or friends
+ * @data: same data pointer as passed to for_each_element() or friends
+ * @datalen: same data length as passed to for_each_element() or friends
+ *
+ * This function returns %true if all the data was parsed or considered
+ * while walking the elements. Only use this if your for_each_element()
+ * loop cannot be broken out of, otherwise it always returns %false.
+ *
+ * If some data was malformed, this returns %false since the last parsed
+ * element will not fill the whole remaining data.
+ */
+static inline bool for_each_element_completed(const struct element *element,
+ const void *data, size_t datalen)
+{
+ return (const u8 *)element == (const u8 *)data + datalen;
+}
+
+/**
+ * RSNX Capabilities:
+ * bits 0-3: Field length (n-1)
+ */
+#define WLAN_RSNX_CAPA_PROTECTED_TWT BIT(4)
+#define WLAN_RSNX_CAPA_SAE_H2E BIT(5)
+
+/*
+ * reduced neighbor report, based on Draft P802.11ax_D6.1,
+ * section 9.4.2.170 and accepted contributions.
+ */
+#define IEEE80211_AP_INFO_TBTT_HDR_TYPE 0x03
+#define IEEE80211_AP_INFO_TBTT_HDR_FILTERED 0x04
+#define IEEE80211_AP_INFO_TBTT_HDR_COLOC 0x08
+#define IEEE80211_AP_INFO_TBTT_HDR_COUNT 0xF0
+#define IEEE80211_TBTT_INFO_OFFSET_BSSID_BSS_PARAM 9
+#define IEEE80211_TBTT_INFO_OFFSET_BSSID_SSSID_BSS_PARAM 13
+
+#define IEEE80211_RNR_TBTT_PARAMS_OCT_RECOMMENDED 0x01
+#define IEEE80211_RNR_TBTT_PARAMS_SAME_SSID 0x02
+#define IEEE80211_RNR_TBTT_PARAMS_MULTI_BSSID 0x04
+#define IEEE80211_RNR_TBTT_PARAMS_TRANSMITTED_BSSID 0x08
+#define IEEE80211_RNR_TBTT_PARAMS_COLOC_ESS 0x10
+#define IEEE80211_RNR_TBTT_PARAMS_PROBE_ACTIVE 0x20
+#define IEEE80211_RNR_TBTT_PARAMS_COLOC_AP 0x40
+
+struct ieee80211_neighbor_ap_info {
+ u8 tbtt_info_hdr;
+ u8 tbtt_info_len;
+ u8 op_class;
+ u8 channel;
+} __packed;
+
+enum ieee80211_range_params_max_total_ltf {
+ IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_4 = 0,
+ IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_8,
+ IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_16,
+ IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_UNSPECIFIED,
+};
+
#endif /* __LINUX_IEEE80211_H */
struct carl9170_write_reg_byte {
__le32 addr;
__le32 count;
- u8 val[0];
+ u8 val[];
} __packed;
#define CARL9170FW_PHY_HT_ENABLE 0x4
+/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Shared CARL9170 Header
*
* Firmware descriptor format
*
* Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, see
- * http://www.gnu.org/licenses/.
*/
#ifndef __CARL9170_SHARED_FWDESC_H
/* Firmware will pass BA when BARs are queued */
CARL9170FW_RX_BA_FILTER,
- /* Firmware has support to write a byte at a time */
+ /* Firmware has support to write a byte at a time */
CARL9170FW_HAS_WREGB_CMD,
/* Pattern generator */
struct carl9170fw_fix_desc {
struct carl9170fw_desc_head head;
- struct carl9170fw_fix_entry data[0];
+ struct carl9170fw_fix_entry data[];
} __packed;
#define CARL9170FW_FIX_DESC_SIZE \
(sizeof(struct carl9170fw_fix_desc))
__le16 length;
__le16 tag;
- u8 payload[0];
+ u8 payload[];
} __packed __aligned(4);
#define AR9170_STREAM_LEN 4
#ifndef __CARL9170_SHARED_VERSION_H
#define __CARL9170_SHARED_VERSION_H
-#define CARL9170FW_VERSION_YEAR 13
-#define CARL9170FW_VERSION_MONTH 10
-#define CARL9170FW_VERSION_DAY 25
+#define CARL9170FW_VERSION_YEAR 21
+#define CARL9170FW_VERSION_MONTH 2
+#define CARL9170FW_VERSION_DAY 5
#define CARL9170FW_VERSION_GIT "1.9.9"
#endif /* __CARL9170_SHARED_VERSION_H */
struct ar9170_tx_hwdesc hdr;
union {
- struct ieee80211_hdr i3e;
+ struct ieee80211_hdr i3e __packed __aligned(2);
u8 payload[0];
} data;
} __packed __aligned(4);
struct _carl9170_tx_superframe {
struct _carl9170_tx_superdesc s;
struct _ar9170_tx_hwdesc f;
- u8 frame_data[0];
+ u8 frame_data[];
} __packed __aligned(4);
#define CARL9170_TX_SUPERDESC_LEN 24
struct ar9170_rx_frame_single {
struct ar9170_rx_head phy_head;
- struct ieee80211_hdr i3e;
+ struct ieee80211_hdr i3e __packed __aligned(2);
struct ar9170_rx_phystatus phy_tail;
struct ar9170_rx_macstatus macstatus;
-} __packed __aligned(4);
+};
struct ar9170_rx_frame_head {
struct ar9170_rx_head phy_head;
- struct ieee80211_hdr i3e;
+ struct ieee80211_hdr i3e __packed __aligned(2);
struct ar9170_rx_macstatus macstatus;
-} __packed __aligned(4);
+};
struct ar9170_rx_frame_middle {
- struct ieee80211_hdr i3e;
+ struct ieee80211_hdr i3e __packed __aligned(2);
struct ar9170_rx_macstatus macstatus;
-} __packed __aligned(4);
+};
struct ar9170_rx_frame_tail {
- struct ieee80211_hdr i3e;
+ struct ieee80211_hdr i3e __packed __aligned(2);
struct ar9170_rx_phystatus phy_tail;
struct ar9170_rx_macstatus macstatus;
} __packed __aligned(4);
struct ar9170_rx_frame_head head;
struct ar9170_rx_frame_middle middle;
struct ar9170_rx_frame_tail tail;
- } __packed __aligned(4);
-} __packed __aligned(4);
+ };
+};
static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_macstatus *t)
{
add_custom_target(
miniboot.fw ALL
${OBJCOPY} --strip-unneeded -O binary -R .sram -R .eeprom -R .fwdsc miniboot.elf miniboot.fw
- DEPENDS miniboot.elf)
+ DEPENDS miniboot.elf
+ BYPRODUCTS miniboot.fw)
-BINUTILS_VER=2.32
+BINUTILS_VER=2.38
BINUTILS_TAR=binutils-$(BINUTILS_VER).tar.xz
-BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/$(BINUTILS_TAR)"
+BINUTILS_URL="http://ftpmirror.gnu.org/gnu/binutils/$(BINUTILS_TAR)"
-NEWLIB_VER=3.1.0
+NEWLIB_VER=4.1.0
NEWLIB_TAR=newlib-$(NEWLIB_VER).tar.gz
NEWLIB_URL="ftp://sourceware.org/pub/newlib/$(NEWLIB_TAR)"
-GCC_VER=9.1.0
+GCC_VER=12.1.0
GCC_TAR=gcc-$(GCC_VER).tar.xz
-GCC_URL="https://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VER)/$(GCC_TAR)"
+GCC_URL="http://ftpmirror.gnu.org/gnu/gcc/gcc-$(GCC_VER)/$(GCC_TAR)"
-MPFR_VER=4.0.2
+MPFR_VER=4.1.0
MPFR_TAR=mpfr-$(MPFR_VER).tar.xz
-MPFR_URL="https://ftp.gnu.org/gnu/mpfr/$(MPFR_TAR)"
+MPFR_URL="http://ftpmirror.gnu.org/gnu/mpfr/$(MPFR_TAR)"
-GMP_VER=6.1.2
+GMP_VER=6.2.1
GMP_TAR=gmp-$(GMP_VER).tar.xz
-GMP_URL="https://ftp.gnu.org/gnu/gmp/$(GMP_TAR)"
+GMP_URL="http://ftpmirror.gnu.org/gnu/gmp/$(GMP_TAR)"
-MPC_VER=1.1.0
+MPC_VER=1.2.1
MPC_TAR=mpc-$(MPC_VER).tar.gz
-MPC_URL="https://ftp.gnu.org/gnu/mpc/$(MPC_TAR)"
+MPC_URL="http://ftpmirror.gnu.org/gnu/mpc/$(MPC_TAR)"
JOBS?=$(shell grep -c ^processor /proc/cpuinfo)
-87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912 src/gmp-6.1.2.tar.xz
-6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e src/mpc-1.1.0.tar.gz
-fb4fa1cc21e9060719208300a61420e4089d6de6ef59cf533b57fe74801d102a src/newlib-3.1.0.tar.gz
-1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a src/mpfr-4.0.2.tar.xz
-0ab6c55dd86a92ed561972ba15b9b70a8b9f75557f896446c82e8b36e473ee04 src/binutils-2.32.tar.xz
-79a66834e96a6050d8fe78db2c3b32fb285b230b855d0a66288235bc04b327a0 src/gcc-9.1.0.tar.xz
+fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2 src/gmp-6.2.1.tar.xz
+17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459 src/mpc-1.2.1.tar.gz
+0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f src/mpfr-4.1.0.tar.xz
+f296e372f51324224d387cc116dc37a6bd397198756746f93a2b02e9a5d40154 src/newlib-4.1.0.tar.gz
+820d9724f020a3e69cb337893a0b63c2db161dadcb0e06fc11dc29eb1e84a32c src/binutils-2.37.tar.xz
+d08edc536b54c372a1010ff6619dd274c0f1603aa49212ba20f7aa2cda36fa8b src/gcc-11.2.0.tar.xz
+e316477a914f567eccc34d5d29785b8b0f5a10208d36bbacedcc39048ecfe024 src/binutils-2.38.tar.xz
+62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b src/gcc-12.1.0.tar.xz