资源简介
imx6平台ds90ub964调试帮助文档,包含官方debug流程说明文档,环视程序,g2d官方说明文档
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define FATAL do { fprintf(stderr “Error at line %d file %s (%d) [%s]\n“ __LINE__ __FILE__ errno strerror(errno)); exit(1); } while(0)
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
int main(int argc char **argv) {
int fd;
void *map_base *virt_addr;
unsigned long read_result writeval;
off_t target;
int access_type = ‘w‘;
if(argc < 2) {
fprintf(stderr “\nUsage:\t%s { address } [ type [ data ] ]\n“
“\taddress : memory address to act upon\n“
“\ttype : access operation type : [b]yte [h]alfword [w]ord\n“
“\tdata : data to be written\n\n“
argv[0]);
exit(1);
}
target = strtoul(argv[1] 0 0);
if(argc > 2)
access_type = tolower(argv[2][0]);
if((fd = open(“/dev/mem“ O_RDWR | O_SYNC)) == -1)
FATAL;
printf(“/dev/mem opened.\n“);
fflush(stdout);
map_base = mmap(0 MAP_SIZE PROT_READ | PROT_WRITE MAP_SHARED fd target & ~MAP_MASK);
if(map_base == (void *)-1)
FATAL;
printf(“Memory mapped at address %p.\n“ map_base);
fflush(stdout);
virt_addr = map_base + (target & MAP_MASK);
switch(access_type) {
case ‘b‘:
read_result = *((unsigned char *) virt_addr);
break;
case ‘h‘:
read_result = *((unsigned short *) virt_addr);
break;
case ‘w‘:
read_result = *((unsigned long *) virt_addr);
break;
default:
fprintf(stderr “Illegal data type ‘%c‘.\n“ access_type);
exit(2);
}
printf(“Value at address 0x%x (%p): 0x%x\n“ target virt_addr read_result);
fflush(stdout);
if(argc > 3) {
writeval = strtoul(argv[3] 0 0);
switch(access_type) {
case ‘b‘:
*((unsigned char *) virt_addr) = writeval;
read_result = *((unsigned char *) virt_addr);
break;
case ‘h‘:
*((unsigned short *) virt_addr) = writeval;
read_result = *((unsigned short *) virt_addr);
break;
case ‘w‘:
*((unsigned long *) virt_addr) = writeval;
read_result = *((unsigned long *) virt_addr);
break;
}
printf(“Written 0x%x; readback 0x%x\n“ writeval read_result);
fflush(stdout);
}
if(munmap(map_base MAP_SIZE) == -1) FATAL;
close(fd);
return 0;
}
- 上一篇:项目验收会报告.ppt
- 下一篇:LINUX内核源代码情景分析_完整完美版.pdf
相关资源
- yiubian_9819646.zip
- 2889642计算机组成原理试卷及答案(唐
- GB∕T36964-2018软件工程软件开发成本度
- Norbert_Wiener-Extrapolation_interpolation_and
- wKh2BFxCHryAAQh9AEg2DAzxD_o173.pdf
- morph数据库(4)289643
- AutodeskReCapPro201964位中文授权激活特别
- 微波技术与天线第4版_13964029.pdf
- 2e83751335d93e769646a4a9a6da9c3d.slx
- hopchen_7959641.zip
- 计算机图形学源码DDA直线、中点直线
- GB_T36964-2018软件工程软件开发成本度量
- GB∕T36964-2018软件工程软件开发成本度
评论
共有 条评论