7a61a006de
JEP106 encodes JEDEC-assigned manufacture code as: a) a sequence of zero or more escape codes 0x7f; b) an odd-parity bit of the next 7 bits; c) 7 bits. The same code is often represented as a single value composed by the logical OR between: - the number of escape codes in a), shifted left by 7 positions; - the 7 bits in c). This is the preferred packed representation used by this change. Currently there are only two uses of JEP106 in openocd to get the manufacturer name: - to decode the JTAG IDCODE of each TAP, where the JEP106 code is already packed as in the preferred representation above in bits IDCODE[11:1]; - to decode the ARM CoreSight PIDR register, where the JEP106 code is split in 3 parts: = PIDR3[3:0], corresponding to bits [10:7] of the packed code; = PIDR2[2:0], corresponding to bits [6:4] of the packed code; = PIDR1[7:4], corresponding to bits [3:0] of the packed code. Wrap the existing JEP106 decode function in a simpler API using the packed code. Simplify the callers by skipping the bit unpacking. Change the manufacturer code in CoreSight table dap_partnums[] to match the packed representation, by removing the always-one bit 7 erroneously taken from PIDR bit JEDEC and included in the former table. Change-Id: I63eb4da9e6801fab25e330f1f6b792d2fd619493 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6418 Tested-by: jenkins
38 lines
2.0 KiB
C
38 lines
2.0 KiB
C
/***************************************************************************
|
|
* Copyright (C) 2015 Andreas Fritiofson *
|
|
* andreas.fritiofson@gmail.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, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* 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. If not, see <http://www.gnu.org/licenses/>. *
|
|
***************************************************************************/
|
|
|
|
#ifndef OPENOCD_HELPER_JEP106_H
|
|
#define OPENOCD_HELPER_JEP106_H
|
|
|
|
/**
|
|
* Get the manufacturer name associated with a JEP106 ID.
|
|
* @param bank The bank (number of continuation codes) of the manufacturer ID.
|
|
* @param id The 7-bit manufacturer ID (i.e. with parity stripped).
|
|
* @return A pointer to static const storage containing the name of the
|
|
* manufacturer associated with bank and id, or one of the strings
|
|
* "<invalid>" and "<unknown>".
|
|
*/
|
|
const char *jep106_table_manufacturer(unsigned int bank, unsigned int id);
|
|
|
|
static inline const char *jep106_manufacturer(unsigned int manufacturer)
|
|
{
|
|
return jep106_table_manufacturer(manufacturer >> 7, manufacturer & 0x7f);
|
|
}
|
|
|
|
#endif /* OPENOCD_HELPER_JEP106_H */
|