Linux多媒体
--------------
drivers\base
drivers\char
drivers\video
drivers\media
drivers\media\v4l2-core
drivers\media\platform
辅助工具-打印
-----------------
#define xe(fmt, ...) printk("\0013##############1.0 console start##############\n" fmt "###############1.0 console end###############\n", ##__VA_ARGS__)
#define xi(fmt, ...) printk("\0016##############1.0 console start##############\n" fmt "###############1.0 console end###############\n", ##__VA_ARGS__)
辅助工具-打印结构体
-----------------
来源:lib/vsprintf.c(vsnprintf:FORMAT_TYPE_PTR) -> lib/vsprintf.c(pointer:)
dev_info(&pdev->dev,"resource:%pR\n",pdev->resource); //打印设备资源信息.
print_hex_dump(KERN_ERR,"\t",0,16,1,pdev,sizeof(struct platform_device),true) //smsc911x_drv_probe,十六进制打印pdev结构体信息.
int hex_dump_to_buffer_xe(const void *buf, size_t len, int rowsize, int groupsize,char *linebuf, size_t linebuflen, bool ascii)
{
const u8 *ptr = buf;
int ngroups;
u8 ch;
int j, lx = 0;
int ascii_column;
int ret;
if (rowsize != 16 && rowsize != 32)
rowsize = 16;
if (len > rowsize) /* limit to one line at a time */
len = rowsize;
if (!is_power_of_2(groupsize) || groupsize > 8)
groupsize = 1;
if ((len % groupsize) != 0) /* no mixed size output */
groupsize = 1;
ngroups = len / groupsize;
ascii_column = rowsize * 2 + rowsize / groupsize + 1;
if (!linebuflen)
goto overflow1;
if (!len)
goto nil;
if (groupsize == 8) {
const u64 *ptr8 = buf;
for (j = 0; j < ngroups; j++) {
ret = snprintf(linebuf + lx, linebuflen - lx,"%s%16.16llx", j ? " " : "",get_unaligned(ptr8 + j));
if (ret >= linebuflen - lx)
goto overflow1;
lx += ret;
}
} else if (groupsize == 4) {
const u32 *ptr4 = buf;
for (j = 0; j < ngroups; j++) {
ret = snprintf(linebuf + lx, linebuflen - lx,"%s%8.8x", j ? " " : "",get_unaligned(ptr4 + j));
if (ret >= linebuflen - lx)
goto overflow1;
lx += ret;
}
} else if (groupsize == 2) {
const u16 *ptr2 = buf;
for (j = 0; j < ngroups; j++) {
ret = snprintf(linebuf + lx, linebuflen - lx,"%s%4.4x", j ? " " : "",get_unaligned(ptr2 + j));
if (ret >= linebuflen - lx)
goto overflow1;
lx += ret;
}
} else {
for (j = 0; j < len; j++) {
if (linebuflen < lx + 2)
goto overflow2;
ch = ptr[j];
linebuf[lx++] = hex_asc_hi(ch);
if (linebuflen < lx + 2)
goto overflow2;
linebuf[lx++] = hex_asc_lo(ch);
if (linebuflen < lx + 2)
goto overflow2;
linebuf[lx++] = ' ';
}
if (j)
lx--;
}
if (!ascii)
goto nil;
while (lx < ascii_column) {
if (linebuflen < lx + 2)
goto overflow2;
linebuf[lx++] = ' ';
}
for (j = 0; j < len; j++) {
if (linebuflen < lx + 2)
goto overflow2;
ch = ptr[j];
linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.';
}
nil:
linebuf[lx] = '\0';
return lx;
overflow2:
linebuf[lx++] = '\0';
overflow1:
return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1;
}
void hex_dump_xe(const char *level, const char *prefix_str, int prefix_type,int rowsize, int groupsize,const void *buf, size_t len, bool ascii)
{
const u8 *ptr = buf;
int i, linelen, remaining = len;
unsigned char linebuf[32 * 3 + 2 + 32 + 1];
if (rowsize != 16 && rowsize != 32)
rowsize = 16;
printk("\0013#############HEXDUMP START###############\n");
for (i = 0; i < len; i += rowsize)
{
linelen = min(remaining, rowsize);
remaining -= rowsize;
hex_dump_to_buffer_xe(ptr + i, linelen, rowsize, groupsize,linebuf, sizeof(linebuf), ascii);
switch (prefix_type)
{
case DUMP_PREFIX_ADDRESS:
printk("%s%s%p: %s\n",level, prefix_str, ptr + i, linebuf);
break;
case DUMP_PREFIX_OFFSET:
printk("%s%s%.8x: %s\n", level, prefix_str, i, linebuf);
break;
default:
printk("%s%s%s\n", level, prefix_str, linebuf);
break;
}
}
printk("\0013##############HEXDUMP END################\n");
}
hex_dump_xe(KERN_ERR,"\t",0,16,1,pdev,sizeof(struct platform_device),true) //smsc911x_drv_probe,十六进制打印pdev结构体信息.
控制台
-----------------
全局变量
exclusive_console
exclusive_console_stop_seq
console_seq
console_idx
console_init
con_init
##############1.0 console start##############
###############1.0 console end###############
因篇幅问题不能全部显示,请点此查看更多更全内容