/*
* msm_rpm_log_copy() - Copies messages from a volatile circular buffer in
* the RPM's shared memory into a private local buffer
* msg_buffer: pointer to local buffer (string)
* buf_len: length of local buffer in bytes
* read_start_idx: index into shared memory buffer
*
* Return value: number of bytes written to the local buffer
*
* Copies messages stored in a circular buffer in the RPM Message Memory into
* a specified local buffer. The RPM processor is unaware of these reading
* efforts, so care is taken to make sure that messages are valid both before
* and after reading. The RPM processor utilizes a ULog driver to write the
* log. The RPM processor maintains tail and head indices. These correspond
* to the next byte to write into, and the first valid byte, respectively.
* Both indices increase monotonically (except for rollover).
*
* Messages take the form of [(u32)length] [(char)data0,1,...] in which the
* length specifies the number of payload bytes. Messages must be 4 byte
* aligned, so padding is added at the end of a message as needed.
*
* Print format:
* - 0xXX, 0xXX, 0xXX
* - 0xXX
* etc...
*/
static u32 msm_rpm_log_copy(const struct msm_rpm_log_platform_data *pdata,
char *msg_buffer, u32 buf_len, u32 *read_idx)
{
u32 head_idx, tail_idx;
u32 pos = 0;
u32 i = 0;
u32 msg_len;
u32 pos_start;
char temp[4];
tail_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_TAIL);
head_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_HEAD);
while (tail_idx - head_idx > 0 && tail_idx - *read_idx > 0) {
head_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_HEAD);
if (tail_idx - *read_idx > tail_idx - head_idx) {
*read_idx = head_idx;
continue;
}
if (tail_idx - head_idx > pdata->log_len ||
!IS_ALIGNED((tail_idx | head_idx | *read_idx), 4))
break;
msg_len = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_BUFFER,
(*read_idx >> 2) & pdata->log_len_mask);
if (PADDED_LENGTH(msg_len) > tail_idx - *read_idx - 4)
msg_len = tail_idx - *read_idx - 4;
if (pos + PRINTED_LENGTH(msg_len) > buf_len)
break;
pos_start = pos;
pos += scnprintf(msg_buffer + pos, buf_len - pos, "- ");
for (i = 0; i < msg_len; i++) {
if (IS_ALIGNED(i, 4))
*((u32 *)temp) = msm_rpm_log_read(pdata,
MSM_RPM_LOG_PAGE_BUFFER,
((*read_idx + 4 + i) >> 2) &
pdata->log_len_mask);
pos += scnprintf(msg_buffer + pos, buf_len - pos,
"0x%02X, ", temp[i & 0x03]);
}
pos += scnprintf(msg_buffer + pos, buf_len - pos, "\n");
head_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_HEAD);
if (tail_idx - *read_idx > tail_idx - head_idx)
pos = pos_start;
*read_idx += PADDED_LENGTH(msg_len) + 4;
}
return pos;
}
/*
* There's very little reason to use this, you should really
* have a struct block_device just about everywhere and use
* bdevname() instead.
*/
const char *__bdevname(dev_t dev, char *buffer)
{
scnprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
MAJOR(dev), MINOR(dev));
return buffer;
}
int
p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended)
{
int i, ret, type, tag;
if (!fc)
return scnprintf(buf, buflen, "<NULL>");
type = fc->id;
tag = fc->tag;
ret = 0;
switch (type) {
case P9_TVERSION:
ret += scnprintf(buf+ret, buflen-ret,
"Tversion tag %u msize %u version '%.*s'", tag,
fc->params.tversion.msize,
fc->params.tversion.version.len,
fc->params.tversion.version.str);
break;
case P9_RVERSION:
ret += scnprintf(buf+ret, buflen-ret,
"Rversion tag %u msize %u version '%.*s'", tag,
fc->params.rversion.msize,
fc->params.rversion.version.len,
fc->params.rversion.version.str);
break;
case P9_TAUTH:
ret += scnprintf(buf+ret, buflen-ret,
"Tauth tag %u afid %d uname '%.*s' aname '%.*s'", tag,
fc->params.tauth.afid, fc->params.tauth.uname.len,
fc->params.tauth.uname.str, fc->params.tauth.aname.len,
fc->params.tauth.aname.str);
break;
case P9_RAUTH:
ret += scnprintf(buf+ret, buflen-ret, "Rauth tag %u qid ", tag);
p9_printqid(buf+ret, buflen-ret, &fc->params.rauth.qid);
break;
case P9_TATTACH:
ret += scnprintf(buf+ret, buflen-ret,
"Tattach tag %u fid %d afid %d uname '%.*s' aname '%.*s'", tag,
fc->params.tattach.fid, fc->params.tattach.afid,
fc->params.tattach.uname.len, fc->params.tattach.uname.str,
fc->params.tattach.aname.len, fc->params.tattach.aname.str);
break;
case P9_RATTACH:
ret += scnprintf(buf+ret, buflen-ret, "Rattach tag %u qid ",
tag);
p9_printqid(buf+ret, buflen-ret, &fc->params.rattach.qid);
break;
case P9_RERROR:
ret += scnprintf(buf+ret, buflen-ret,
"Rerror tag %u ename '%.*s'", tag,
fc->params.rerror.error.len,
fc->params.rerror.error.str);
if (extended)
ret += scnprintf(buf+ret, buflen-ret, " ecode %d\n",
fc->params.rerror.errno);
break;
case P9_TFLUSH:
ret += scnprintf(buf+ret, buflen-ret, "Tflush tag %u oldtag %u",
tag, fc->params.tflush.oldtag);
break;
case P9_RFLUSH:
ret += scnprintf(buf+ret, buflen-ret, "Rflush tag %u", tag);
break;
case P9_TWALK:
ret += scnprintf(buf+ret, buflen-ret,
"Twalk tag %u fid %d newfid %d nwname %d", tag,
fc->params.twalk.fid, fc->params.twalk.newfid,
fc->params.twalk.nwname);
for (i = 0; i < fc->params.twalk.nwname; i++)
ret += scnprintf(buf+ret, buflen-ret, " '%.*s'",
fc->params.twalk.wnames[i].len,
fc->params.twalk.wnames[i].str);
break;
case P9_RWALK:
ret += scnprintf(buf+ret, buflen-ret, "Rwalk tag %u nwqid %d",
tag, fc->params.rwalk.nwqid);
for (i = 0; i < fc->params.rwalk.nwqid; i++)
ret += p9_printqid(buf+ret, buflen-ret,
&fc->params.rwalk.wqids[i]);
break;
case P9_TOPEN:
ret += scnprintf(buf+ret, buflen-ret,
"Topen tag %u fid %d mode %d", tag,
fc->params.topen.fid, fc->params.topen.mode);
break;
//.........这里部分代码省略.........
开发者ID:274914765,项目名称:C,代码行数:101,代码来源:fcprint.c
示例8: debug_test_smsm
static int debug_test_smsm(char *buf, int max)
{
int i = 0;
int test_num = 0;
int ret;
/* Test case 1 - Register new callback for notification */
do {
test_num++;
SMSM_CB_TEST_INIT();
ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 0);
/* de-assert SMSM_SMD_INIT to trigger state update */
UT_EQ_INT(smsm_cb_data.cb_count, 0);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 1);
UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, SMSM_SMDINIT);
UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, 0x0);
UT_EQ_INT((int)smsm_cb_data.data, 0x1234);
/* re-assert SMSM_SMD_INIT to trigger state update */
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 2);
UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, 0x0);
UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, SMSM_SMDINIT);
/* deregister callback */
ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 2);
/* make sure state change doesn't cause any more callbacks */
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 2);
i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num);
} while (0);
/* Test case 2 - Update already registered callback */
do {
test_num++;
SMSM_CB_TEST_INIT();
ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 0);
ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_INIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 1);
/* verify both callback bits work */
INIT_COMPLETION(smsm_cb_completion);
UT_EQ_INT(smsm_cb_data.cb_count, 0);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 1);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 2);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 3);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 4);
/* deregister 1st callback */
ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 1);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 4);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
//.........这里部分代码省略.........
static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
{
struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];
struct bcr_identity *core = &cpu->core;
const struct cpuinfo_data *tbl;
char *isa_nm;
int i, be, atomic;
int n = 0;
FIX_PTR(cpu);
if (is_isa_arcompact()) {
isa_nm = "ARCompact";
be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
atomic = cpu->isa.atomic1;
if (!cpu->isa.ver) /* ISA BCR absent, use Kconfig info */
atomic = IS_ENABLED(CONFIG_ARC_HAS_LLSC);
} else {
isa_nm = "ARCv2";
be = cpu->isa.be;
atomic = cpu->isa.atomic;
}
n += scnprintf(buf + n, len - n,
"\nIDENTITY\t: ARCVER [%#02x] ARCNUM [%#02x] CHIPID [%#4x]\n",
core->family, core->cpu_id, core->chip_id);
for (tbl = &arc_cpu_tbl[0]; tbl->info.id != 0; tbl++) {
if ((core->family >= tbl->info.id) &&
(core->family <= tbl->up_range)) {
n += scnprintf(buf + n, len - n,
"processor [%d]\t: %s (%s ISA) %s\n",
cpu_id, tbl->info.str, isa_nm,
IS_AVAIL1(be, "[Big-Endian]"));
break;
}
}
if (tbl->info.id == 0)
n += scnprintf(buf + n, len - n, "UNKNOWN ARC Processor\n");
n += scnprintf(buf + n, len - n, "CPU speed\t: %u.%02u Mhz\n",
(unsigned int)(arc_get_core_freq() / 1000000),
(unsigned int)(arc_get_core_freq() / 10000) % 100);
n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s\nISA Extn\t: ",
IS_AVAIL1(cpu->timers.t0, "Timer0 "),
IS_AVAIL1(cpu->timers.t1, "Timer1 "),
IS_AVAIL2(cpu->timers.rtc, "64-bit RTC ",
CONFIG_ARC_HAS_RTC));
n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s",
IS_AVAIL2(atomic, "atomic ", CONFIG_ARC_HAS_LLSC),
IS_AVAIL2(cpu->isa.ldd, "ll64 ", CONFIG_ARC_HAS_LL64),
IS_AVAIL1(cpu->isa.unalign, "unalign (not used)"));
if (i)
n += scnprintf(buf + n, len - n, "\n\t\t: ");
if (cpu->extn_mpy.ver) {
if (cpu->extn_mpy.ver <= 0x2) { /* ARCompact */
n += scnprintf(buf + n, len - n, "mpy ");
} else {
int opt = 2; /* stock MPY/MPYH */
if (cpu->extn_mpy.dsp) /* OPT 7-9 */
opt = cpu->extn_mpy.dsp + 6;
n += scnprintf(buf + n, len - n, "mpy[opt %d] ", opt);
}
n += scnprintf(buf + n, len - n, "%s",
IS_USED_CFG(CONFIG_ARC_HAS_HW_MPY));
}
n += scnprintf(buf + n, len - n, "%s%s%s%s%s%s%s%s\n",
IS_AVAIL1(cpu->isa.div_rem, "div_rem "),
IS_AVAIL1(cpu->extn.norm, "norm "),
IS_AVAIL1(cpu->extn.barrel, "barrel-shift "),
IS_AVAIL1(cpu->extn.swap, "swap "),
IS_AVAIL1(cpu->extn.minmax, "minmax "),
IS_AVAIL1(cpu->extn.crc, "crc "),
IS_AVAIL2(1, "swape", CONFIG_ARC_HAS_SWAPE));
if (cpu->bpu.ver)
n += scnprintf(buf + n, len - n,
"BPU\t\t: %s%s match, cache:%d, Predict Table:%d\n",
IS_AVAIL1(cpu->bpu.full, "full"),
IS_AVAIL1(!cpu->bpu.full, "partial"),
cpu->bpu.num_cache, cpu->bpu.num_pred);
return buf;
}
请发表评论