//test.c #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/mman.h>
int main(void) { static volatile char *reg_mem; static int axs_mem_fd = -1; axs_mem_fd = open("/dev/mem", O_RDWR|O_SYNC); if (axs_mem_fd < 0) { perror("AXS: can't open /dev/mem"); return NULL; } /* memory map */ reg_mem =(volatile char*)mmap( (caddr_t)reg_mem, 0x4, PROT_READ|PROT_WRITE, MAP_SHARED, axs_mem_fd, 0x04600000 ); if(reg_mem[0]==0x10) printf("OK"); else printf("sorry"); } host: ppc_6xx-gcc -o test test.c target: ./test Bus error need help,thanks ------------------------------ ?????Sogou.com?2G??????????! http://mail.sogou.com/recommend/sogoumail_invite_reg1.jsp?from=sogouinvitation&s_EMAIL=zengshuai%40sogou.com&username=linuxppc-embedded&FullName=linuxppc-embedded&Email=linuxppc-embedded%40ozlabs.org&verify=755eff4e640bdcfc57d93cbd8b0a9cb7