最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

How to print block of data

工作和技术 crifan 2111浏览 0评论

How to print block of data

By Crifan Li

Date: 05.19 2008

              /* print the buf data */

              printk(KERN_WARNING "n%s : The buf=0x%p ,data is:n",__FUNCTION__, buf);

              for(j = 0;j < 512; j+=4) /* total print one page=2048 bytes */

                  {

                            printk(KERN_WARNING "%08x ",*((u32 *)(buf+j)) );

                            /* after the first data , should not do n, then the whole block of data should do n every 32bytes */                    

                         if(j!=0 && 0 == (j+4)%32)

                                   printk(KERN_WARNING "n");

                  }

              printk(KERN_WARNING "n");

so above can change to this new version :

#define BYTES_PER_DATA              4

#define DATAS_PER_LINE               8

#define BYTES_PER_LINE              ((BYTES_PER_DATA)*(DATAS_PER_LINE))

#define TOTAL_BYTES                     2048

#define DATAS                                  ((TOTAL_BYTES)/( BYTES_PER_DATA))

/* print the buf data */

printk(KERN_WARNING "nFUNC:%s LINE:%: The buf=0x%p ,data is:n",__FUNCTION__, __LINE__. buf);

       for(j = 0;j < DATAS; j+= BYTES_PER_DATA) /* total print one page=2048 bytes */

           {

                     printk(KERN_WARNING "%08x ",*((u32 *)(buf+j)) );

                     /* after the first data , should not do n */

                     /* if the end of every line , then do n */

                         if(j!=0 && 0 == (j+ BYTES_PER_DATA)% BYTES_PER_LINE)

                            printk(KERN_WARNING "n");

           }

       printk(KERN_WARNING "n");

转载请注明:在路上 » How to print block of data

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.170 seconds, using 22.08MB memory