我现在在写一个按键中断驱动程序,需要实现的功能是按下一个键,在用户区去读哪一个键被按下,在内核编写read函数的时候需要调用wait_event_interruptible函数,当不满足读要求时将该进程进行休眠。加载驱动模块的时候没有错误,但当运行应用程序的时候发生了Oops报错:
Unable to handle kernel NULL pointer dereference at virtual address 0000003c
pgd = c3b38000
[0000003c] *pgd=33b26031, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#2]
Modules linked in: mykey ov9650 zd1211rw rt73usb rt2x00usb rt2x00lib mac80211 input_polldev [last unloaded: mykey]
CPU: 0 Tainted: G D (2.6.30.4-EmbedSky #13)
PC is at prepare_to_wait+0x3c/0x68
LR is at mykey_read+0x164/0x1a4 [mykey]
pc : [<c005cdec>] lr : [<bf07c328>] psr: 60000093
sp : c3b29f04 ip : c3b29f28 fp : c3b29f18
r10: c3b29f1c r9 : c3b28000 r8 : c3b28000
r7 : 00000000 r6 : bf07cd40 r5 : 00000001 r4 : 0000003c
r3 : c3b29f28 r2 : c3b29f04 r1 : c3b29f1c r0 : 60000013
Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user
Control: c000717f Table: 33b38000 DAC: 00000015
Process test-read (pid: 532, stack limit = 0xc3b28268)
Stack: (0xc3b29f04 to 0xc3b2a000)
9f00: 0000003c be90cd20 c3b29f54 c3b29f1c bf07c328 c005cdc0 00000000
9f20: c3b20000 c005cfcc c3b29f28 c3b29f28 c3b05f00 be90cd20 c3b29f78 00000003
9f40: c0036008 00000000 c3b29f74 c3b29f58 c0097448 bf07c1d4 00000000 00000000
9f60: c3b05f00 00000003 c3b29fa4 c3b29f78 c0097560 c00973a4 00000000 00000000
9f80: ffffffff 00000000 401635e8 000085cc 00000000 00008470 00000000 c3b29fa8
9fa0: c0035e60 c0097524 000085cc 00000000 00000003 be90cd20 00000004 be90cd20
9fc0: 000085cc 00000000 00008470 00000003 00000000 00000000 40025000 be90cd34
9fe0: 00000000 be90cd20 0000857c 400f047c 60000010 00000003 00363173 6a626f6b
Backtrace:
[<c005cdb0>] (prepare_to_wait+0x0/0x68) from [<bf07c328>] (mykey_read+0x164/0x1a4 [mykey])
r5:be90cd20 r4:0000003c
[<bf07c1c4>] (mykey_read+0x0/0x1a4 [mykey]) from [<c0097448>] (vfs_read+0xb4/0xe8)
[<c0097394>] (vfs_read+0x0/0xe8) from [<c0097560>] (sys_read+0x4c/0x84)
r7:00000003 r6:c3b05f00 r5:00000000 r4:00000000
[<c0097514>] (sys_read+0x0/0x84) from [<c0035e60>] (ret_fast_syscall+0x0/0x2c)
r6:00008470 r5:00000000 r4:000085cc
Code: e121f003 e591300c e1a0200d e15c0003 (05943000)
我用printk进行追踪,错误确实发生在wait_event_interruptible的函数调用,我现在也不知道到底是那里有错误,有经验的前辈们能指点一下么?能指个路往哪方向差错也行啊,先谢谢各位了! |