Skip to content

Commit 305da35

Browse files
Merge branch 'master_devel'
2 parents 2171795 + 7366c7f commit 305da35

File tree

14 files changed

+50
-96
lines changed

14 files changed

+50
-96
lines changed

common/python_wrapper.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ export MSTFLINT_LIB_DIR=$mlibdir
1919
export LD_LIBRARY_PATH=$mlibdir
2020
export MSTFLINT_BIN_DIR=$mbindir
2121
EXEC_NAME=`basename $(readlink -f $0)`
22-
exec /usr/bin/env python $MSTFLINT_PYTHON_TOOLS/$EXEC_NAME/${EXEC_NAME}.py "$@"
22+
which python3 >/dev/null 2>&1
23+
if test $? -eq 0 ; then
24+
PYTHON_EXEC='/usr/bin/env python3'
25+
else
26+
which python2 >/dev/null 2>&1
27+
if test $? -eq 0 ; then
28+
PYTHON_EXEC='/usr/bin/env python2'
29+
fi
30+
fi
31+
32+
exec $PYTHON_EXEC $MSTFLINT_PYTHON_TOOLS/$EXEC_NAME/${EXEC_NAME}.py "$@"

dev_mgt/dev_mgt.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,3 @@ def isLivefishMode(self):
7575
return not (rc == 0)
7676
else:
7777
raise DevMgtException("Failed to load c_dev_mgt.so/libdev_mgt.dll")
78-
79-
80-
if __name__ == "__main__":
81-
mstdev = "/dev/mst/mt523_pciconf0"
82-
#mstdev = "/dev/mst/mt4113_pciconf0"
83-
devMgt = DevMgt(mstdev)
84-
print(devMgt.isLivefishMode())

flint/cmd_line_parser.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ FlagMetaData::FlagMetaData()
168168
_flags.push_back(new Flag("", "hh", 0));
169169
_flags.push_back(new Flag("i", "image", 1));
170170
_flags.push_back(new Flag("", "qq", 0));
171+
_flags.push_back(new Flag("", "low_cpu", 0));
171172
_flags.push_back(new Flag("", "nofs", 0));
172173
_flags.push_back(new Flag("", "allow_psid_change", 0));
173174
_flags.push_back(new Flag("", "allow_rom_change", 0));
@@ -501,6 +502,12 @@ void Flint::initCmdParser()
501502
" operation. This may shorten execution time when running over slow interfaces (e.g., I2C, MTUSB-1).\n"
502503
"Commands affected: query");
503504

505+
AddOptions("low_cpu",
506+
' ',
507+
"",
508+
"When specified, cpu usage will be reduced. Run time might be increased\n"
509+
"Commands affected: query");
510+
504511
AddOptions("nofs",
505512
' ',
506513
"",
@@ -809,6 +816,8 @@ ParseStatus Flint::HandleOption(string name, string value)
809816
} else if (name == "qq") {
810817
_flintParams.quick_query = true;
811818
_flintParams.skip_rom_query = true;
819+
} else if (name == "low_cpu") {
820+
_flintParams.low_cpu = true;
812821
} else if (name == "nofs") {
813822
_flintParams.nofs = true;
814823
} else if (name == "allow_psid_change") {

flint/flint_params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class FlintParams {
108108
bool blank_guids;
109109
bool clear_semaphore;
110110
bool quick_query;
111+
bool low_cpu;
111112
bool skip_rom_query;
112113
bool image_specified;
113114
string image;

flint/subcommands.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,6 +2393,9 @@ QuerySubCommand:: ~QuerySubCommand()
23932393

23942394
FlintStatus QuerySubCommand::executeCommand()
23952395
{
2396+
if (_flintParams.low_cpu) {
2397+
increase_poll_time = 1;
2398+
}
23962399
if (preFwOps() == FLINT_FAILED) {
23972400
return FLINT_FAILED;
23982401
}

include/mtcr_ul/mtcr_com_defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ typedef long long int64_t;
8787

8888
#endif
8989

90+
extern int increase_poll_time;
91+
9092
/*
9193
* MST <--> MTCR API defines
9294
*/

mlxsign_lib/mlxsign_lib.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,12 @@ int MlxSignRSA::createRSAFromPEMKeyString(const std::string& pemKey, bool isPri
360360

361361
MlxSignHMAC::MlxSignHMAC()
362362
{
363+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
363364
ctx = malloc(sizeof(HMAC_CTX));
364365
HMAC_CTX_init((HMAC_CTX*)ctx);
366+
#else
367+
ctx = HMAC_CTX_new();
368+
#endif
365369
}
366370

367371
int MlxSignHMAC::setKey(const std::vector<u_int8_t>& key)
@@ -415,8 +419,12 @@ int MlxSignHMAC::getDigest(std::vector<u_int8_t>& digest)
415419

416420
MlxSignHMAC::~MlxSignHMAC()
417421
{
422+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
418423
HMAC_CTX_cleanup((HMAC_CTX*)ctx);
419424
free(ctx);
425+
#else
426+
HMAC_CTX_free((HMAC_CTX*)ctx);
427+
#endif
420428
}
421429

422430
#endif //ENABLE_OPENSSL

mtcr_py/mtcr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class MtcrException(Exception):
6565
class MstDevice:
6666
##########################
6767
def __init__(self, dev):
68-
self.mdev = dev
68+
self.mdev = dev.encode('ascii')
6969
self.mf = 0
7070
self.mopenFunc = CMTCR.mopen
7171
self.mopenFunc.restype = c_void_p

mtcr_ul/mtcr_ul_icmd_cif.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ enum {
233233
#define QUANTUM_HW_ID 589
234234
#define SPECTRUM2_HW_ID 590
235235

236+
/***** GLOBALS *****/
237+
int increase_poll_time = 0;
238+
/***** GLOBALS *****/
239+
236240
/*************************************************************************************/
237241
/*
238242
* get_version
@@ -268,7 +272,13 @@ static int go(mfile *mf)
268272
MWRITE4_ICMD(mf, mf->icmd.ctrl_addr, reg, return ME_ICMD_STATUS_CR_FAIL);
269273

270274
DBG_PRINTF("Busy-bit raised. Waiting for command to exec...\n");
271-
char *icmd_sleep_env = getenv("MFT_CMD_SLEEP");
275+
char *icmd_sleep_env;
276+
if (increase_poll_time) {
277+
icmd_sleep_env = "70\0";
278+
}
279+
else {
280+
icmd_sleep_env = getenv("MFT_CMD_SLEEP");
281+
}
272282
int icmd_sleep = -1;
273283
if (icmd_sleep_env) {
274284
char *endptr;

reg_access/regaccess.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -275,43 +275,3 @@ def getSecureFWStatus(self):
275275

276276

277277
####################################################################################
278-
if __name__ == "__main__":
279-
280-
# mstdev = mtcr.MstDevice("/dev/mst/mt4119_pciconf1")
281-
# regAc = RegAccess(mstdev)
282-
#
283-
# reset_level = regAc.sendMFRL(0, REG_ACCESS_METHOD_GET)
284-
# print "reset level is 0x{0:x}".format(reset_level)
285-
#
286-
# uptime = regAc.getFWUptime()
287-
# print "uptime is {0}".format(uptime)
288-
#
289-
# manufacturing_base_mac = regAc.getManufacturingBaseMac()
290-
# print 'manufacturing_base_mac : 0x{0:x}'.format(manufacturing_base_mac)
291-
292-
pci_devices = ['0e:00.1', '08:00.1', '0e:00.0', '08:00.0', '0000:05:00.0']
293-
294-
pci_devices = ['81:00.0', '02:00.0', '82:00.0']
295-
296-
pci_devices = ['05:00.0']
297-
for pci_device in pci_devices:
298-
299-
print("pci device {0}".format(pci_device))
300-
mstdev = mtcr.MstDevice(pci_device)
301-
regAc = RegAccess(mstdev)
302-
303-
regAc.sendMtrcCapTakeOwnership()
304-
305-
reset_level = regAc.sendMFRL(0, REG_ACCESS_METHOD_GET)
306-
print("reset level is 0x{0:x}".format(reset_level))
307-
if mstdev != None:
308-
mstdev.close()
309-
310-
uptime = regAc.getFWUptime()
311-
print("uptime is {0}".format(uptime))
312-
313-
manufacturing_base_mac = regAc.getManufacturingBaseMac()
314-
print('manufacturing_base_mac : 0x{0:x}'.format(manufacturing_base_mac))
315-
316-
secure_fw = RegAccess(pci_device=pci_device).getSecureFWStatus()
317-
print('secure_fw : {0}'.format(secure_fw))

0 commit comments

Comments
 (0)