|  | 
 
| 用的是一样的核,我想可能使用方法也应该差不多吧,希望达人指点! 
 740的DATASHEET上EXTxCON这个寄存器负责外设io的一些设置
 
 可是在驱动程序初始化函数中,给EXT0CON赋值(0X8A00FA49:首地址,大小及数据宽度,其他的都随便取的值),然后在IOCTL()中,能够读到这个值,但是去读0x8A000000时就出现问题了。
 u8 temp1;
 volatile u8 *data = (volatile u8 *)(0x8A000000);
 temp1 = (*data);
 
 程序运行,出现如下提示:
 CPU: 0
 pc : [<0000802440>]    lr : [<0001df30>]  not tainted
 sp : 001a7f74   ip : 001a7f40 fp : 001a7f88
 r10: 006f58d4   r9 : 00000036 r8 : 00000003
 r7 : c004f001   r6 : ffffffe7 r5 : 00119b58  r4 : 0a000000
 r3 : 20000093   r2 : 00000001 r1 : 00000001  r0 : 00000010
 flags: nzcv  irqs  on   fiqs  on  mode  svc_32  segment kernel
 control: 0
 process test_abc (pid: 11,stacpage=001a7000)
 stack:
 001a7f60:           0001df30 00080240 60000013 ffffffff 00000002 007471a0 001a7(屏幕边沿)
 001a7f80: 001a7f8c  0003f2d0 000801d0 00000000 00000000 0061ffa8 001a6000 00015
 001a7fa0: 00000000  001a7fb0 00015560 0003f218 00000000 0001ac64 00000003 c004f
 001a7fc0: 00000002  00000000 00000000 00000000 006fffa8 006fffa0 00000001 00000
 001a7fe0: 006f58d4  006fff20 006fff24 006fff10 006f2124 006f20e8 60000010 00000
 backtrace:
 function entered at [<000801c0>]  from  [<0003f2d0>]
 r5 = 007471a0  r4 = 00000002
 function entered at [<0003f208>]  from  [<00015560>]
 r8 = 00015700  r7 = 001a6000 r6 = 006fffa8 r5 = 00000000
 r4 = 00000000
 code: e3a0440a ebfe76f0 (e5941000) e59f002c ebfe76ed
 pid 11: failed 11
 
 
 我用的是静态编译,这是源程序
 #ifndef __KERNEL__
 #define __KERNEL__
 #endif
 #ifndef MODULE
 //#define MODULE
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 #include
 
 #include
 
 #endif
 
 static int adc_open(struct inode *inode,struct file *filp);
 static int adc_release(struct inode *inode,struct file *filp);
 static int adc_ioctl(struct inode *inode,struct file *filp,unsigned int cmd,unsigned long param);
 
 int adc_init(void);
 void adc_cleanup(void);
 
 #define MAJOR_NR 110
 #define DEVICE_NAME "myadc"
 
 static struct file_operations myadc_fops=
 {
 owner:THIS_MODULE,
 open:adc_open,
 release:adc_release,
 ioctl:adc_ioctl,
 };
 
 static int adc_open(struct inode *inode,struct file *filp)
 {
 MOD_INC_USE_COUNT;
 printk(KERN_ERR DEVICE_NAME":THE ADCONVERTER DRIVER OPENED!!");
 return 0;
 }
 
 static int adc_release(struct inode *inode,struct file *filp)
 {
 MOD_DEC_USE_COUNT;
 printk(KERN_ERR DEVICE_NAME":THE ADCONVERTER DRIVER RELEASED!!!");
 return 0;
 }
 
 static int adc_ioctl(struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg)
 {
 printk(KERN_ERR DEVICE_NAME":MYADC IOCTL ENTERED!!!");
 
 int num;
 volatile u32 *Reg;
 volatile u8 *Data;
 u32 temp1;
 u8 temp2;
 
 num = MINOR(inode->i_rdev);
 if(num >= 5)
 return -ENODEV;
 if(_IOC_TYPE(cmd) != MYADC_IOC_MAGIC)
 return -ENOTTY;
 if(_IOC_NR(cmd) >= MYADC_MAXNR)
 return -ENOTTY;
 
 Reg = (volatile u32 *)(EXT0CON);
 printk(KERN_ERR "ext0con=%x\n",(*Reg));
 Reg = (volatile u32 *)(EBICON);
 printk(KERN_ERR "ebicon=%x\n",(*Reg));
 Data = (volatile u8 *)(0x0a000000);//CS active
 ////////////////////////////////////////////////////////////////////////
 //temp1 = (*Data);       //////////////////error occured!!!!
 //printk(KERN_ERR "the data of current address is %x\n",temp2);
 //temp1 = (*Reg);
 //Reg = (volatile u32 *)(EXT0CON);
 //printk(KERN_ERR "ext0con=%x\n",(*Reg));
 
 return 0;
 }
 
 int adc_init(void)
 //                                                 int __init adc_init(void)
 {
 int result;
 volatile u32 *p;
 
 result = register_chrdev(MAJOR_NR,"myadc",&myadc_fops);
 if(result<0)
 {
 printk(KERN_ERR DEVICE_NAME":unable to get major %d\n",MAJOR_NR);
 return result;
 }
 //system memoty initialize
 //p = (volatile u32 *)(EBICON);
 //(*p) = 0x8a00fa49;
 
 p = (volatile u32 *)(EXT0CON);
 (*p) = 0x0a00fa49;//NEED TO BE ADUSTED
 
 
 printk(KERN_ERR DEVICE_NAME":initial OK\n");
 return 0;
 }
 
 
 void adc_cleanup(void)
 //                                              void __exit adc_cleanup(void)
 {
 unregister_chrdev(MAJOR_NR,DEVICE_NAME);
 }
 
 
 module_init(adc_init);
 module_exit(adc_cleanup);
 
 
 这是测试程序
 应用程序就是open(),ioctl(),close(),程序可以一直运行到打印EXT0CON的地方,然后再读EXT0CON配置的外部io首地址时就出错了。
 我现在还没有考虑外设,就想读一读我需要的io地址
 这样子跟时序的设置有关系吗?因为EXT0CON很多位都是关于SETUP和HOLDON时间的,而我是随便设的,我担心这也是一个导致错误的地方。
 | 
 |