求助,加载内核出现0oops错误~~苦啊~~~~

发布于 2022-09-22 14:18:26 字数 3330 浏览 13 评论 0

错误如下

  1. Unable to handle kernel NULL pointer dereference at virtual address 00000000
  2. pgd = c0a40000
  3. *pgd = 00000000, *pmd = 00000000
  4. Internal error: Oops: 0
  5. CPU: 0
  6. pc : [<c6cb00a4>]    lr : [<c001f0e4>]    Not tainted
  7. sp : c0a6de04  ip : c0a6de1c  fp : c0a6de44
  8. r10: c0223020  r9 : c0a6de48  r8 : c021ae7c
  9. r7 : c021afdc  r6 : 20000000  r5 : c6cb085c  r4 : c3561560
  10. r3 : c6cb0a28  r2 : 00000000  r1 : c6cb09fc  r0 : c6cb0678
  11. Flags: nzcv  IRQs off  FIQs on  Mode SVC_32  Segment user
  12. Control: C000317F  Table: 30A40000  DAC: 00000015
  13. Process insmod (pid: 67, stackpage=c0a6d000)
  14. Stack: (0xc0a6ddf4 to 0xc0a6e000)
  15. dde0:                                              c001f0e4 c6cb00a4 00000093
  16. de00: ffffffff c3561560 0000000b c0a6de44 c0a6de1c c001f0e4 c6cb0070 ea000000
  17. de20: c0a6de90 00000001 c001f258 60000013 ffffffff c6cb0794 c0a6deac c0a6de48
  18. de40: c001e4e0 c001f034 0000000b 00000001 080097c4 ea000000 c3561560 0000000b
  19. de60: 00000000 40000013 20000000 00000000 c6cb0794 c0a6deac c0a6de90 c0a6de90
  20. de80: c001f254 c001f258 60000013 ffffffff c3561560 00000000 0000000b c6cb0060
  21. dea0: c0a6ded8 c0a6deb0 c001f30c c001f198 c6cb09f0 00000000 c6cb0794 00000060
  22. dec0: ffffffea 0202dc58 c0a6c000 c0a6df04 c0a6dedc c6cb04a8 c001f274 00000000
  23. dee0: c004511c c0044638 c0a6df04 c6cb0000 00000000 c3497000 c0a6dfa4 c0a6df08
  24. df00: c002c450 c6cb038c c3497000 c0a6df1c c3499000 0000000b c35613e0 00000060
  25. df20: c6ca0000 c6cb0060 00000b30 00000000 00000000 00000000 00000000 00000000
  26. df40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  27. df60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 bfffd0f0
  28. df80: 0202a840 0202dc58 00000080 c001e9a4 c0a6c000 00000000 00000000 c0a6dfa8
  29. dfa0: c001e820 c002bd68 bfffd0f0 c0027dc8 0201f3b0 0202dc58 ffffffff fbad2084
  30. dfc0: bfffd0f0 0202a840 0202dc58 c6cb0000 00000b30 00000000 00000000 bfffd0c0
  31. dfe0: 4009eb40 bfffd0b0 02010064 4009eb4c 60000010 0201f3b0 00000000 00000000
  32. Backtrace:
  33. Function entered at [<c001f024>] from [<c001e4e0>]
  34. Function entered at [<c001f188>] from [<c001f30c>]
  35. r7 = C6CB0060  r6 = 0000000B  r5 = 00000000  r4 = C3561560
  36. Function entered at [<c001f264>] from [<c6cb04a8>]
  37. Function entered at [<c6cb037c>] from [<c002c450>]
  38. r6 = C3497000  r5 = 00000000  r4 = C6CB0000
  39. Function entered at [<c002bd58>] from [<c001e820>]
  40. Code: e59f305c e59f505c e5932000 e59f3058 (e5924000)
  41. Kernel panic: Aiee, killing interrupt handler!
  42. In interrupt handler - not syncing

复制代码

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

待"谢繁草 2022-09-29 14:18:26

源代码如下

  1. /* driver/char/adc0809.c
  2. *  this is a adc0809 char device driver.
  3. * Any problem pls contact [email]support@hhcn.com[/email]
  4. */
  5. #include <module.h>
  6. #include <linux/fs.h>
  7. #include <linux/iobuf.h>
  8. #include <linux/major.h>
  9. #include <linux/blkdev.h>
  10. #include <linux/capability.h>
  11. #include <linux/smp_lock.h>
  12. #include <asm/uaccess.h>
  13. #include <asm/hardware.h>
  14. #include <asm/arch/cpu_s3c2410.h>
  15. #include <asm/io.h>
  16. #include <linux/vmalloc.h>
  17. #include <linux/kernel.h>
  18. #include <linux/signal.h>
  19. #include <linux/sched.h>
  20. #include <linux/timer.h>
  21. #include <linux/interrupt.h>
  22. #include <asm/irq.h>
  23. #include <asm/arch/hardware.h>
  24. #include <asm/arch/irqs.h>
  25. #include <linux/init.h>
  26. #include <linux/timer.h>
  27. //#include "adc0809_ioctl.h"
  28. MODULE_LICENSE("GPL");
  29. #define ADC0809_MAJOR 231
  30. /*define the adc0809 major node is 231*/
  31. #define adc0809_sle (*(volatile unsigned long *)ADC_GPACON)
  32. #define adc0809_sle_data (*(volatile unsigned long *)ADC_GPADATA)
  33. unsigned long ADC_GPACON, ADC_GPADATA;
  34. static unsigned long ADC_1; //ADC_1, ADC_2, ADC_3, ADC_4, ADC_5, ADC_6, ADC_7;
  35. unsigned long ADC_DATA;
  36. static unsigned long r_TCFG0,r_TCFG1,r_TCNTB1,r_TCMPB1,r_TCON,r_GPCCON;
  37. unsigned long adc_write_addr;
  38. unsigned long adc_read_addr;
  39. //int * adc_read_addr,* adc_write_addr;
  40. devfs_handle_t devfs_adc;
  41. void adc0809_interrupt(int,void *,struct pt_regs *);
  42. int  adc0809_open(struct inode *, struct file *);
  43. int  adc0809_release(struct inode *, struct file *);
  44. //int  adc0809_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
  45. ssize_t adc0809_read(struct file *, char * , size_t , loff_t *);
  46. ssize_t adc0809_write(struct file *, const char *, size_t , loff_t *);
  47. static struct file_operations adc0809_fops = {
  48.        // ioctl:          adc0809_ioctl,   //根据参数确定读取的引脚;
  49.         open:           adc0809_open,                //选中片选NGCS2(初始化ADC0809的管脚配置),初始化adc_read_addr;
  50.         read:           adc0809_read,
  51.         write:          adc0809_write,
  52.         release:        adc0809_release,
  53. };
  54. //struct timer_list timer_ForData;  // 定时器
  55. char data; //变量类型不同也会出错,之前使用unsigned long所得是一连串八位数字要么是-1
  56. //unsigned long addr;
  57. int adc0809_sum=0;
  58. /*------------中断处理函数------------------*/
  59. void adc0809_interrupt(int irq,void *d,struct pt_regs *regs)
  60. {
  61.         char adc0809_v=0,adc0809_u=0;
  62. /*clear interrupt register for INT_TIMER0*/
  63.         SRCPND &= (~0x00000800);    //bit11
  64.         INTPND = INTPND;
  65.         (*(volatile unsigned char *) ADC_1) = (char) 1;
  66.           data = (*(volatile unsigned long *) adc_read_addr);
  67.         if(data<200){adc0809_v=0;}
  68.                 else adc0809_v=1;
  69.         if(adc0809_v<adc0809_u){adc0809_sum=adc0809_sum+1;}
  70.                 else adc0809_sum=adc0809_sum;
  71.         adc0809_u=adc0809_v;
  72. printk("data:%d\n",data);
  73. printk("adc0809_u:%d\n",adc0809_u);
  74. printk("adc0809_v:%d\n",adc0809_v);
  75. printk("adc0809_sum:%d\n",adc0809_sum);
  76. }
  77. /*------- Open/close code for raw IO.-----*/
  78. int adc0809_open(struct inode *inode, struct file *filp)
  79. {
  80.           adc_read_addr = ADC_DATA;
  81.        
  82.         printk("open ok\n");
  83.           return 0;
  84. }
  85. /*------------read()----------------*/
  86. ssize_t adc0809_read(struct file *filp, char * buf,
  87.                  size_t size, loff_t *offp)
  88. {       
  89.         char key;
  90.        
  91.        
  92.         key =adc0809_sum;
  93.         printk("key_driver:%d\n",key);
  94.         copy_to_user(buf,&key,1);//put_user(key,buf);
  95.         //printk("adc0809_read:adc_read_addr=0x%x\n",adc_read_addr);
  96.         return 1;
  97. }
  98. /*------------------write()-------------------------------*/
  99. ssize_t adc0809_write(struct file *filp, const char *buf,
  100.                   size_t size, loff_t *offp)
  101. {
  102.    char key;
  103.    if (get_user(key, buf))
  104.                return -EFAULT;
  105.    printk("adc0809_write:adc_write_addr=0x%x; key = %c\n",adc_write_addr,key);
  106.         (*(volatile unsigned char *) adc_write_addr) = key;
  107.    //put_user(key,buf);
  108.    return 1;
  109. }
  110. /*----------------release()---------------------*/
  111. int adc0809_release(struct inode *inode, struct file *filp)
  112. {
  113.         printk("release ok\n");
  114.         return 0;
  115. }
  116. /*-------------------iormap()--地址影射函数---*/
  117. static int address_map(void)
  118. {
  119.            r_TCFG0 = ioremap(0x51000000,4); //定时器配置寄存器0
  120.             r_TCFG1 = ioremap(0x51000004,4); //定时器配置寄存器1
  121.             r_TCNTB1 = ioremap(0x51000018,4);
  122.            r_TCMPB1 = ioremap(0x5100001C,4);
  123.             r_TCON = ioremap(0x51000008,4);
  124.             r_GPCCON = ioremap(0x56000020,4);
  125.         ADC_GPACON = (unsigned int)ioremap(0x56000000,4);  //物理寄存器的影射,个人认为这里都是指CPLD的物理寄存器
  126.           ADC_GPADATA = ioremap(0x56000004,4);
  127.           ADC_1 = ioremap(0x10002010,4);
  128.           /*---
  129.         ADC_0 = ioremap(0x10000010,4);
  130.        
  131.           ADC_2 = ioremap(0x10004010,4);
  132.           ADC_3 = ioremap(0x10006010,4);
  133.           ADC_4 = ioremap(0x10008010,4);
  134.           ADC_5 = ioremap(0x1000a010,4);
  135.           ADC_6 = ioremap(0x1000c010,4);
  136.           ADC_7 = ioremap(0x1000e010,4);  ----*/
  137.           ADC_DATA = ioremap(0x10000020,4);
  138.             return 0;
  139. }
  140. /*--------------------------------------------------------------------------*/
  141. int __init adc0809_init(void)
  142. {
  143.   static int result;
  144.   //unsigned long gpfup;
  145.   //volatile unsigned int bankcon2;       
  146.   address_map();
  147.   printk("*********************adc0809_init**************\n");
  148. // bankcon2=(volatile unsigned int)ioremap(0x4800000c,4);
  149. // *(volatile unsigned int*)bankcon2 |= 3<<13;  //
  150.   /* select NGCS2 */
  151.   adc0809_sle |= 0x2000;
  152.   adc0809_sle_data &= (~0x2000);
  153. printk("***********00000000000000000!!***********\n");
  154.        
  155. /*-----------初始化S3C2410的时钟timer0--------------------------*/
  156.         (*(volatile unsigned int *)r_TCFG0) &= 0x11111100;//prescaler=0
  157.         (*(volatile unsigned int *)r_TCFG1) &= (~0x000000F0);//MUX1=1/2
  158. //        (*(volatile unsigned int *)r_TCFG1) &= (~0x000000D0);//MUX1=1/8  时间T=r_TCNTB1/625000(s)
  159.         (*(volatile unsigned int *)r_TCNTB1) = 25000;         //时间为10ms
  160.             (*(volatile unsigned int *)r_TCMPB1) = 0x00000000;
  161.             (*(volatile unsigned int *)r_TCON) |= 0x00000E00;
  162.            (*(volatile unsigned int *)r_TCON) &= (~0x00000200);
  163.            (*(volatile unsigned int *)r_TCON) |= 0x00000100;
  164.         disable_irq(IRQ_TIMER1);
  165.             enable_irq(IRQ_TIMER1);
  166. printk("***********11111111111111***********\n");
  167.         result=request_irq(IRQ_TIMER1,&adc0809_interrupt,SA_INTERRUPT,"adc0809",NULL);
  168. printk("***********222222222222222***********\n");
  169.         if (!result)
  170.         {
  171.                 printk("Get assigned irq %d,result=%d\n",IRQ_TIMER1,result);
  172. //                return result;
  173.         }
  174. /*--*/
  175. printk("***********Init ok!!***********\n");
  176.        
  177.         
  178.   devfs_adc =
  179.         devfs_register(NULL,"adc0809",DEVFS_FL_DEFAULT,
  180.                        ADC0809_MAJOR, 0,
  181.              S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
  182.                        &adc0809_fops,NULL);
  183.         return 0;
  184. //printk("*********************adc0809_init**************\n");
  185. }
  186. //int __init adc0809_exit(void)
  187. static void __exit adc0809_exit(void)
  188. {
  189.         (*(volatile unsigned int *)r_TCON) &= (~0x00000100);
  190.              disable_irq(IRQ_TIMER1);
  191.         free_irq(IRQ_TIMER1,NULL);
  192.              printk("exit ok\n");
  193. //free_irq(IRQ_EINT2, adc0809_interrupt);
  194.           devfs_unregister(devfs_adc);
  195. }
  196. module_init(adc0809_init);
  197. module_exit(adc0809_exit);

复制代码
通过打印信息,发现加载时
是在初始化程序int __init adc0809_init(void)
中的result=request_irq(IRQ_TIMER1,&adc0809_interrupt,SA_INTERRUPT,"adc0809",NULL);
这一局过不去
实在找不到问题所在 郁闷死了

骄兵必败 2022-09-29 14:18:26

不懂
帮顶
学习
有用

︶ ̄淡然 2022-09-29 14:18:26

我建议你用你第一天贴出来那个程序。
你这个程序错误太多了。

冰雪梦之恋 2022-09-29 14:18:26

第一天贴的程序 没有加时钟中断啊  deamice救救啊

[ 本帖最后由 ady2002 于 2008-11-20 17:00 编辑 ]

与他有关 2022-09-29 14:18:26

原帖由 dreamice 于 2008-11-20 16:54 发表
我建议你用你第一天贴出来那个程序。
你这个程序错误太多了。

希望 deamice能帮我指出错误之处哦,我也可以得到提升
第一天的程序虽然可能,我这个程序其实也就是在那个程序上加了个时钟中断,
痛苦啊~~~~~~

成熟的代价 2022-09-29 14:18:26

原帖由 ady2002 于 2008-11-20 17:08 发表

希望 deamice能帮我指出错误之处哦,我也可以得到提升
第一天的程序虽然可能,我这个程序其实也就是在那个程序上加了个时钟中断,
痛苦啊~~~~~~

我给你提的问题都很基本,但你还是没明白如何写一个中断处理程序。所以,你得时钟中断在这里就错得很离奇。

楠木可依 2022-09-29 14:18:26

原帖由 dreamice 于 2008-11-20 17:12 发表

我给你提的问题都很基本,但你还是没明白如何写一个中断处理程序。所以,你得时钟中断在这里就错得很离奇。

中断处理程序 不是 就是 中断函数  申请中断  注册 以及注销中断处理程序吗?
ldd2上看的

缱倦旧时光 2022-09-29 14:18:26

就按你说的这些基本要素,你好好检查一下你的程序是不是符合一个驱动程序的基本要求。

爱冒险 2022-09-29 14:18:26

这也不是一眼就看出来的啊。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文