Загрузка данных
static int32_t MONITOR_CmdCpu(int32_t argc, const char * const argv[],
int32_t rw)
{
int32_t status = SM_ERR_SUCCESS;
switch (rw)
{
default: /* read */
{
for (uint32_t cpuId = 0U; cpuId < SM_NUM_CPU;
cpuId++)
{
string cpuNameAddr;
uint32_t runMode, sleepMode;
uint64_t vector;
int32_t wName = 0;
status = LMM_CpuNameGet(s_lm, cpuId,
&cpuNameAddr, &wName);
if (status == SM_ERR_SUCCESS)
{
status = LMM_CpuInfoGet(s_lm, cpuId, &runMode,
&sleepMode, &vector);
}
if (status == SM_ERR_SUCCESS)
{
string const runModes[] =
{
"RUN",
"HOLD",
"STOP",
"SLEEP"
};
string const sleepModes[] =
{
"RUN",
"WAIT",
"STOP",
"SUSP"
};
printf("%03u: %*s => run-mode = %5s, slp-mode = %4s, vector = 0x%08X_%08X\n",
cpuId, -wName, cpuNameAddr,
runModes[runMode], sleepModes[sleepMode],
UINT64_H(vector), UINT64_L(vector));
}
else
{
/* Swallow errors cluster-level CPU instances */
status = SM_ERR_SUCCESS;
}
}
}
break;
case WRITE: /* write */
{
uint32_t cpuId = 0U;
if (argc < 2)
{
status = SM_ERR_MISSING_PARAMETERS;
}
else
{
status = MONITOR_NameToId(argv[0], &cpuId,
LMM_CpuNameGet, SM_NUM_CPU);
}
if (status == SM_ERR_SUCCESS)
{
string const subCmds[] =
{
"start",
"hold",
"stop",
"vector"
};
uint8_t subCmd = (uint8_t) MONITOR_Find(subCmds,
(int32_t) ARRAY_SIZE(subCmds), argv[1]);
switch (subCmd)
{
/* start */
case 0U:
status = LMM_CpuStart(s_lm, cpuId);
break;
/* hold */
case 1U:
status = LMM_CpuHold(s_lm, cpuId);
break;
/* stop */
case 2U:
status = LMM_CpuStop(s_lm, cpuId);
break;
/* vector */
case 3U:
{
uint64_t resetVector;
status = MONITOR_ConvU64(argv[2],
&resetVector);
if (status == SM_ERR_SUCCESS)
{
status = LMM_CpuResetVectorSet(s_lm,
cpuId, resetVector, true, true,
true, false);
}
}
break;
default:
status = SM_ERR_INVALID_PARAMETERS;
break;
}
}
else
{
status = SM_ERR_INVALID_PARAMETERS;
}
}
break;
}
/* Return status */
return status;
}